summaryrefslogtreecommitdiffstats
path: root/sub/subreader.c
Commit message (Collapse)AuthorAgeFilesLines
* sub: turn subassconvert_ functions into sub converterswm42013-06-031-90/+10
| | | | | | | | | | | | | | | | | This means subassconvert.c is split in sd_srt.c and sd_microdvd.c. Now this code is involved in the sub conversion chain like sd_movtext is. The invocation of the converter in sd_ass.c is removed. This requires some other changes to make the new sub converter code work with loading external subtitles. Until now, subtitles loaded via subreader.c was assumed to be in plaintext, or for some formats, in ASS (except in -no-ass mode). Then these were added to an ASS_Track. Change this so that subtitles are always in their original format (as far as decoders/converters for them are available), and turn every sub event read by subreader.c as packet to the dec_sub.c subtitle chain. This removes differences between external/demuxed and -ass/-no-ass code paths further.
* sub: remove some global variableswm42013-05-301-70/+64
|
* sub: redo how -no-ass is handledwm42013-05-301-101/+1
| | | | | | | | | | | | | | | | | | | | | The -no-ass switch used to disable any use of libass for text subtitles. This is not really the case anymore, because libass is now always involved when rendering text. The only remaining use of -no-ass is disabling styling or showing subtitles on the terminal. On the other hand, the old subtitle rendering path is a big reason why the subtitle code is still a big mess with an awful number of obscure special cases. In order to simplify it, remove the old subtitle rendering code, and always go through sd_ass.c. Basically, we use ASS_Track as central data structure for storing text subtitles instead of struct sub_data. This also makes libass mandatory for all text subs, even if they are printed to the terminal in -no-video mode. (We could add something like sd_text to avoid this, but it's not worth the trouble.) struct sub_data and subreader.c are still around, even its ASS/SSA reader. But struct sub_data is freed right after converting it to ASS_Track. The internal ASS reader actually can handle some obscure cases libass can't, like files encoded in UTF-16.
* Fix some cppcheck / scan-build warningswm42013-05-061-1/+1
| | | | | | | | These were found by the cppcheck and scan-build static analyzers. Most of these aren't interesting (the 2 previous commits fix some interesting cases found by these analyzers), and they don't nearly fix all warnings. (Most of the unfixed warnings are spam, things MPlayer never cared about, or false positives.)
* subreader: fix one more unsafe sscanf call with "%["Uoti Urpala2013-05-061-1/+1
| | | | | | | | | | | | | | "%[,.:]" conversion was used with a buffer that could be shorter than the matched string. Suppress assignment of the conversion since the value wasn't used anyway, and also limit match length to 1 as it doesn't look like the intent was to match longer runs of the characters. Merged from mplayer2 commit 5cb9aac. Note that the other half of the mplayer2 commit is already part of the mpv commit d98e61e. (I'm not sure why. The mplayer2 commit date precedes mpv's, but was pushed long after the mpv change was pushed; either one of the dates is wrong, or we did the same work twice - in that case, thanks a lot...)
* subreader: fix out of bound write access when parsing .srtwm42013-04-301-4/+4
| | | | | | | | | | | | | | | | | | This broke .srt subtitles on gcc-4.8. The breakage was relatively subtle: it set all hour components to 0, while everything else was parsed successfully. But the problem is really that sscanf wrote 1 byte past the sep variable (or more, for invalid/specially prepared input). The %[..] format specifier is unbounded. Fix that by letting sscanf drop the parsed contents with "*", and also make it skip only one input character by adding "1" (=> "%*1[..."). The out of bound write could easily lead to security issues. Also, this change makes .srt subtitle parsing slightly more strict. Strictly speaking this is an unrelated change, but do it anyway. It's more correct.
* core: display subtitle codec in track listingwm42013-04-201-2/+3
| | | | | Also switch the subrip and subviewer names, which obviously have been confused.
* Fix missing ctype.h includeswm42013-03-041-0/+1
| | | | | libavutil/common.h stopped including ctype.h, and some source files were relying on recursive inclusion of this header.
* configure: remove --disable-sortsubwm42012-12-111-46/+4
| | | | | Apparently this was for debugging. There was a patch to remove it years ago, but it has been forgotten.
* subreader: fix some of ASS parser issuesUoti Urpala2012-12-031-45/+22
| | | | | | | | | | | | | | | | | | The subreader.c ASS parser (used when playing an external ASS subtitle file with --no-ass for "plaintext" display) hardcodes dialogue line syntax instead of correctly reading it from the "Format: " line in the file, but tried to support a varying amount of fields by guessing where the text field (which should be last) begins. This guessing code was buggy in many ways. Remove it and hardcode skipping 9 commas before the text field, which should work for most files. I don't consider the --no-ass case important enough to implement correct parsing now. Also fix the code removing formatting tags, which failed to remove the second in a pair of two consecutive tags. Conflicts: sub/subreader.c Merged from mplayer2 commit 91f516. Essentially reverts d5b964.
* subs: remove --utf8, simplify codeUoti Urpala2012-12-031-19/+5
| | | | | | | | | | | | | | | | | | | Remove the options --utf8 and --unicode which had no effect any more (what they once did should be doable with --subcp). The only use of corresponding variables left in code was subreader.c code using sub_utf8 as a flag indicating whether iconv conversion was active. Change the code to test the existence of iconv context instead. Conflicts: DOCS/man/en/options.rst core/cfg-mplayer.h sub/sub.c sub/sub.h sub/subreader.c Merged from mplayer2 commit ea7311. Note: --unicode was already removed
* subreader: do not skip the first char of ASS fields.cigaes2012-11-211-1/+1
| | | | | | | | | | | | Without this change, fields that can be sometimes empty and sometimes not, such as the Effect field, are counted in an inconsistent way. Since the number of fields is used to find where the text starts, it leads to internal field arriving on the video. Bug reported anonymously on the users mailing list. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35426 b3059339-0415-0410-9bf9-f77b7e298cf2
* Fix potential bugs and issues, general cleanupsreimar2012-11-201-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Most of these are reimar fixing issues found by Coverity static analyzer, and possibly some more cleanup commits independent from this. Since these commits are rather noisy, squash them all together. Try to make code a bit clearer. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35294 b3059339-0415-0410-9bf9-f77b7e298cf2 Conflicts: audio/out/ao_alsa.c Check the correct variable for NULL. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35323 b3059339-0415-0410-9bf9-f77b7e298cf2 Remove pointless unreachable code (the loop condition already checks the 0xff case). git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35325 b3059339-0415-0410-9bf9-f77b7e298cf2 Fix typo that might have caused reading beyond the string end. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35326 b3059339-0415-0410-9bf9-f77b7e298cf2 Do not needlessly use "long" types. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35331 b3059339-0415-0410-9bf9-f77b7e298cf2 Use AV_RB32 to avoid sign extension issues and validate offset before using it. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35332 b3059339-0415-0410-9bf9-f77b7e298cf2 Remove nonsense casts. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35343 b3059339-0415-0410-9bf9-f77b7e298cf2 Fix crash in case sh_audio allocation failed. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35348 b3059339-0415-0410-9bf9-f77b7e298cf2 Fix potential NULL dereference. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35351 b3059339-0415-0410-9bf9-f77b7e298cf2 Conflicts: libmpcodecs/ad_ffmpeg.c Note: Slightly modified. Fix malloc failure check to check the correct variable. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35353 b3059339-0415-0410-9bf9-f77b7e298cf2 Avoid code duplication and pointless casts. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35363 b3059339-0415-0410-9bf9-f77b7e298cf2 Conflicts: stream/tv.c Error out if an invalid channel list name was specified instead of continuing and reading outside array bounds all over the place. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35364 b3059339-0415-0410-9bf9-f77b7e298cf2 Conflicts: stream/tv.c Make array "static const". git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35365 b3059339-0415-0410-9bf9-f77b7e298cf2 Properly free resources even when encountering many parse errors. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35367 b3059339-0415-0410-9bf9-f77b7e298cf2 Conflicts: parser-cfg.c Avoid leaks in error handling. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35380 b3059339-0415-0410-9bf9-f77b7e298cf2 Do not do sign comparisons on "char" type which can be both signed or unsigned. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35381 b3059339-0415-0410-9bf9-f77b7e298cf2 Free cookies file data after parsing it. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35382 b3059339-0415-0410-9bf9-f77b7e298cf2 http_set_field only makes a copy of the string, so we still need to free it. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35383 b3059339-0415-0410-9bf9-f77b7e298cf2 check4proxies does not modify input URL, so mark it const. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35390 b3059339-0415-0410-9bf9-f77b7e298cf2 Remove proxy "support" from stream_rtp and stream_upd, trying to use a http proxy for UDP connections makes no sense. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35394 b3059339-0415-0410-9bf9-f77b7e298cf2 Conflicts: stream/stream_rtp.c stream/stream_udp.c Add url_new_with_proxy function to reduce code duplication and memleaks. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35395 b3059339-0415-0410-9bf9-f77b7e298cf2 Conflicts: stream/pnm.c stream/stream_live555.c stream/stream_nemesi.c stream/stream_rtsp.c Fix off-by-one errors in file descriptor validity checks. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35402 b3059339-0415-0410-9bf9-f77b7e298cf2 Remove pointless cast. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35403 b3059339-0415-0410-9bf9-f77b7e298cf2 Abort when opening the file failed instead of calling "write" with an invalid descriptor. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35404 b3059339-0415-0410-9bf9-f77b7e298cf2 Remove pointless local variable. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35411 b3059339-0415-0410-9bf9-f77b7e298cf2 Conflicts: stream/http.c
* subreader: replace sub_free() by talloc destructorwm42012-11-161-6/+7
| | | | Makes it less annoying to free the sub_data.
* Rename directories, move files (step 2 of 2)wm42012-11-121-3/+3
| | | | | | | | | | | | Finish renaming directories and moving files. Adjust all include statements to make the previous commit compile. The two commits are separate, because git is bad at tracking renames and content changes at the same time. Also take this as an opportunity to remove the separation between "common" and "mplayer" sources in the Makefile. ("common" used to be shared between mplayer and mencoder.)
* subreader: do not write outside array boundsreimar2012-10-311-2/+4
| | | | | | | Extra checks to ensure we really do not write outside array bounds. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35313 b3059339-0415-0410-9bf9-f77b7e298cf2
* sub: simplify code by always defining sub_cpwm42012-08-031-1/+3
|
* subreader: eliminate duplicate subtitle linesmplayer-svn2012-08-031-0/+10
| | | | | | | | Eliminate duplicate subtitle lines which will most likely be artefacts from ASS effects. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@34574 b3059339-0415-0410-9bf9-f77b7e298cf2 Author: reimar
* subreader: SSA reader: do not strip commas in commandsmplayer-svn2012-08-031-0/+3
| | | | | git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@34573 b3059339-0415-0410-9bf9-f77b7e298cf2 Author: reimar
* subreader: fix reading of aqr/subrip09 subtitlesmplayer-svn2012-08-031-8/+8
| | | | | | | | | NULL return would indicate EOF, thus the "clear subtitle" entries would cause sub file parsing to stop. In addition the wrong sub end times would be used with CONFIG_SORTSUB. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@33993 b3059339-0415-0410-9bf9-f77b7e298cf2 Author: reimar
* subreader: get rid of some code duplicationmplayer-svn2012-08-031-64/+34
| | | | | git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@33992 b3059339-0415-0410-9bf9-f77b7e298cf2 Author: reimar
* Remove dead codewm42012-08-011-259/+0
| | | | | | | | | | | | | This was done with the help of callcatcher [1]. Only functions which are statically known to be unused are removed. Some unused functions are not removed yet, because they might be needed in the near future (such as open_output_stream for the encode branch). There is one user visible change: the --subcc option did nothing, and is removed with this commit. [1] http://www.skynet.ie/~caolan/Packages/callcatcher.html
* osd: remove freetype font rendering codewm42012-07-281-83/+0
| | | | | | | | | | | | The previous commit made libass the default OSD renderer. This commit removes the disabled freetype renderer completely. The commits were done separately to make rolling back easier, because using libass for OSD rendering is a risky choice. Also remove freetype/fontconfig/fribidi code. This is all done by libass now. If mplayer is compiled without libass, no OSD is displayed.
* osd: use libass for OSD renderingwm42012-07-281-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The OSD will now be rendered with libass. The old rendering code, which used freetype/fontconfig and did text layout manually, is disabled. To re-enable the old code, use the --disable-libass-osd configure switch. Some switches do nothing with the new code enabled, such as -subalign, -sub-bg-alpha, -sub-bg-color, and many more. (The reason is mostly that the code for rendering unstyled subtitles with libass doesn't make any attempts to support them. Some of them could be supported in theory.) Teletext rendering is not implemented in the new OSD rendering code. I don't have any teletext sources for testing, and since teletext is being phased out world-wide, the need for this is questionable. Note that rendering is extremely inefficient, mostly because the libass output is blended with the extremely strange mplayer OSD format. This could be improved at a later point. Remove most OSD rendering from vo_aa.c, because that was extremely hacky, can't be made work with osd_libass, and didn't work anyway in my tests. Internally, some cleanup is done. Subtitle and OSD related variable declarations were literally all over the place. Move them to sub.h and sub.c, which were hoarding most of these declarations already. Make the player core in mplayer.c free of concerns like bitmap font loading. The old OSD rendering code has been moved to osd_ft.c. The font_load.c and font_load_ft.c are only needed and compiled if the old OSD rendering code is configured.
* Fix minor memory leak from 2003wm42012-02-251-2/+8
|
* subreader.c: don't run FriBiDi code if using libassUoti Urpala2011-09-231-1/+4
| | | | | | | | Libass has its own BiDi handling now, and preprocessing the subtitles with FriBiDi before passing them to libass breaks things. Disable our own FriBiDi code when libass rendering is used. This affects external subtitle files of other formats parsed with subreader.c and converted to ASS tracks.
* subreader: SAMI subs: wrap line if neededreimar2011-06-291-0/+2
| | | | | | | Start a new line if there's no space left to append to the previous one. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@33471 b3059339-0415-0410-9bf9-f77b7e298cf2
* find_subfiles: move sub_filenames() hereClément Bœsch2011-04-201-280/+0
| | | | | | | | | | Move sub_filenames() and related code from subreader.c to new file find_subfiles.c. This function is used to find subtitle files that should be loaded for the current video; this functionality is not specific to the particular kind of text subtitle handling implemented in subreader.c. Also reindent and prettify the moved code a bit.
* sub/OSD: move some related files to sub/Uoti Urpala2011-01-261-0/+2504