summaryrefslogtreecommitdiffstats
path: root/sub
Commit message (Collapse)AuthorAgeFilesLines
* core: add demux_sub pseudo demuxerwm42013-06-012-30/+5
| | | | | | | | | | | | | | | Subtitle files are opened in mplayer.c, not using the demuxer infrastructure in general. Pretend that this is not the case (outside of the loading code) by opening a pseudo demuxer that does nothing. One advantage is that the initialization code is now the same, and there's no confusion about what the difference between track->stream, track->sh_sub and mpctx->sh_sub is supposed to be. This is a bit stupid, and it would be much better if there were proper subtitle demuxers (there are many in recent FFmpeg, but not Libav). So for now this is just a transition to a more proper architecture. Look at demux_sub like an artifical limb: it's ugly, but don't hate it - it helps you to get on with your life.
* sub: various minor subtitle related changeswm42013-06-015-32/+25
| | | | Just pushing some code around.
* sub: remove some global variableswm42013-05-307-118/+76
|
* spudec: restore --sub-forced-only supportwm42013-05-301-0/+2
| | | | | | This was broken with 84829a4 "Merge branch 'osd_changes' into master". The new OSD/subtitle code never respected the --sub-forced-only option, and the old code containing the code for this was removed in fd5c4a1.
* sub: add sd_spu.c to wrap spudec, cleanup mplayer.cwm42013-05-308-46/+149
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This unifies the subtitle rendering path. Now all subtitle rendering goes through sd_ass.c/sd_lavc.c/sd_spu.c. Before that commit, the spudec.h functions were used directly in mplayer.c, which introduced many special cases. Add sd_spu.c, which is just a small wrapper connecting the new subtitle render API with the dusty old vobsub decoder in spudec.c. One detail that changes is that we always pass the palette as extra data, instead of passing the libdvdread palette as pointer to spudec directly. This is a bit roundabout, but actually makes the code simpler and more elegant: the difference between DVD and non-DVD dvdsubs is reduced. Ideally, we would just delete spudec.c and use libavcodec's DVD sub decoder. However, DVD playback with demux_mpg produces packets incompatible to lavc. There are incompatibilities the other way around as well: packets from libavformat's vobsub demuxer are incompatible to spudec.c. So we define a new subtitle codec name for demux_mpg subs, "dvd_subtitle_mpg", which only sd_spu can decode. There is actually code in spudec.c to "assemble" fragments into complete packets, but using the whole spudec.c is easier than trying to move this code into demux_mpg to fix subtitle packets. As additional complication, Libav 9.x can't decode DVD subs correctly, so use sd_spu in that case as well.
* sub: remove check_duplicate_plaintext_event()wm42013-05-301-19/+0
| | | | | | | | | | | | | This was once needed to handle subtitle packages coming from a demuxer, where seeking back might repeat previous events. This doesn't happen anymore, and this code is used to convert complete files. So if there are any duplicate lines, they must have been duplicated in the file, and the old subtitle renderer would have shown them twice as well. Today checking for duplicate events happens in sd_ass.c (and has been for a while). There's no reason to keep this code, and it actually causes trouble. Loading big subtitle files is extremely slow because this makes adding n subtitles O(n^2).
* sub: redo how -no-ass is handledwm42013-05-3011-323/+159
| | | | | | | | | | | | | | | | | | | | | 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.
* add osd-scale commandPaul B Mahol2013-05-141-0/+8
| | | | | | | Signed-off-by: Paul B Mahol <onemda@gmail.com> Modified to add docs for --osd-scale option, and adjusted to the previous commit by wm4.
* command: simplify sub OSD updatewm42013-05-142-6/+4
| | | | | We can just update all OSD elements in these cases. This way we can also reuse it for commands which need to update the OSD for other reasons.
* Fix some cppcheck / scan-build warningswm42013-05-062-2/+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.
* subassconverter: silence clang warningStefano Pigozzi2013-04-281-1/+1
|
* osd: convert OSD font to OpenTypewm42013-04-272-0/+0
| | | | | | | | | | | | | | | | | | The old OSD font was a PostScript Type 1 font. Convert it to OpenType to work around a fontconfig bug [1]. OpenType is a more modern format, and the font file is quite a bit smaller, so this is actually a nice change. The conversion was done by opening the font with fontforge and saving it as OpenType (CFF). fontforge showed a warning when doing this: The font contains errors. Self Intersecting Bad Private Dictionary These seem to be harmless. [1] https://bugs.freedesktop.org/show_bug.cgi?id=63922
* subassconvert: do not escape likely ASS override tagswm42013-04-261-1/+19
| | | | | | | | | | | | | | | | | | | | | | | Usually SubRip files are not expected to contain ASS override tags, but unfortunately these files seem to become more common. Example from a real file: 1 00:00:00,800 --> 00:00:15,000 {\an8}本字幕由 {\c&H26F4FF&}ShinY {\c&HFFAE1A&}深影字幕组{\c&HFFFFFF&} 原创翻译制作 subassconvert.c escaped '{', so that libass displayed the above line literally. Try to apply a simple heuristic to detect whether '{' is likely to start an ASS tag: if the string starts with '{\', and there is a closing '}', assume it's an ASS tag, otherwise escape the '{' properly. If it's a likely ASS tag, it's passed through to libass. The end result is that the above script is displayed in color, while at the same time legitimate uses of '{' and '}' should work fine. We assume that nobody uses {...} for commenting text in SubRip files. (This kind of comment is popular and legal in ASS files, though.)
* subassconvert: add more web colorswm42013-04-201-24/+153
| | | | | | | | Now includes the complete list from [1] at this time. Switch from BGR to RGB to match with that list. [1] http://www.w3.org/TR/css3-color/#svg-color
* core: display subtitle codec in track listingwm42013-04-202-2/+4
| | | | | Also switch the subrip and subviewer names, which obviously have been confused.
* sub, demux: identify subtitle types with the codec namewm42013-04-205-25/+60
| | | | | | | | | Get rid of the 1-char subtitle type field. Use sh_stream->codec instead just like audio and video do. Use codec names as defined by libavcodec for simplicity, even if they're somewhat verbose and annoying. Note that ffmpeg might switch to "ass" as codec name for ASS, so we don't bother with the current silly "ssa" name.
* sub: add --osd-blur and --sub-text-blur optionswm42013-04-133-0/+5
| | | | | | | | | These require bleeding edge libass (latest git version), and will be ignored otherwise. I'm not sure about the blur factor and scaling. The ASS/VSFilter semantics for blur scaling are a bad mess. Might require further investigation.
* osd_libass: actually free ASS_Trackswm42013-04-121-0/+6
| | | | Not a real leak, just for getting clean valgrind reports on exit.
* osd: fix OSD bar position markerwm42013-04-021-0/+10
|
* osd: disable border for inner part of the OSD barwm42013-03-311-1/+1
|
* osd: draw the OSD bar with ASS vector drawingswm42013-03-302-67/+172
| | | | | | | | | | | | | | | | | | | | | | | | | | Drawing the bar with vector drawings (instead with characters from the OSD font) offers more flexibility and looks better. This also adds chapter marks to the OSD bar, which are visible as small triangles on the top and bottom inner border of the bar. Change the default position of the OSD bar below the center of the screen. This is less annoying than putting the bar directly into the center of the view, where it obscures the video. The new position is not quite on the bottom of the screen to avoid collisions with subtitles. The old centered position can be forced with ``--osd-bar-align-y=0``. Also make it possible to change the OSD bar width/height with the new --osd-bar-w and --osd-bar-h options. It's possible that the new OSD bar renders much slower than the old one. There are two reasons for this: 1. the character based bar allowed libass to cache each character, while the vector drawing forces it to redraw every time the bar position changes. 2., the bar position is updated at a much higher granularity (the bar position is passed along as float instead of as integer in the range 0-100, so the bar will be updated on every single video frame).
* sub: don't crash on GBRP videowm42013-03-281-2/+4
| | | | | mp_get_yuv2rgb_coeffs() will crash if the colorspace is explicitly set to RGB.
* sub: print messages before and after font setupwm42013-03-201-0/+2
| | | | | | | Helps on Windows, where fontconfig may take some time to finish. Print it with -v only, because that message would be annoying anywhere else.
* Prefix CODEC_ID_ with AV_wm42013-03-131-5/+5
| | | | | | | | | The old names have been deprecated a while ago, but were needed for supporting older ffmpeg/libav versions. The deprecated identifiers have been removed from recent Libav and FFmpeg git. This change breaks compatibility with Libav 0.8.x and equivalent FFmpeg releases.
* Fix missing ctype.h includeswm42013-03-042-0/+2
| | | | | libavutil/common.h stopped including ctype.h, and some source files were relying on recursive inclusion of this header.
* vo: remove and cleanup globalsAlexander Preisinger2013-03-041-1/+1
| | | | | | | | Removes almost every global variabel in vo.h and puts them in a special struct in MPOpts for video output related options. Also we completly remove the options/globals pts and refresh rate because they were unused.
* fix clang compiler warningsStefano Pigozzi2013-03-031-1/+1
|
* m_option: don't define OPT_BASE_STRUCT by defaultwm42013-03-011-1/+0
| | | | | | | | | | | OPT_BASE_STRUCT defines which struct the OPT_ macros (like OPT_INT etc.) reference implicitly, since these macros take struct member names but no struct type. Normally, only cfg-mplayer.h should need this, and other places shouldn't be bothered with having to #undef it. (Some files, like demux_lavf.c, still store their options in MPOpts. In the long term, this should be removed, and handled like e.g. with VO suboptions instead.)
* vo_caca: remove OSD supportwm42013-02-242-22/+0
| | | | | | Recent changes to the OSD code made vo_caca crash when showing OSD. Since this is a joke VO (== I'd rather not waste my time with it), remove the OSD support. It wasn't that great anyway.
* cleanup: remove duplicated function, move escape parsing functionwm42013-02-161-18/+11
|
* osd: always update already visible OSD bar on seekswm42013-02-161-2/+4
| | | | | | | | | Seeks can be performed with OSD bar invisible (e.g. "osd-msg seek ..." command), and then an already visible bar won't be updated. But the bar will stick around until the OSD text is hidden. This is confusing, so change it that the bar is updated. (Making the bar disappear on such seeks would require much more changes, so we're lazy and go with this commit.)
* osd: add --osd-bar-align-x/y options to control OSD bar positionwm42013-02-141-2/+19
|
* Check return values of some mp_find_..._config_file function calls for NULLwm42013-02-091-2/+3
|
* sub: add experimental --force-rgba-osd-rendering switchwm42013-01-131-1/+6
|
* draw_bmp: use multiple bounding boxeswm42013-01-131-27/+20
| | | | | Seems to make it about up to 20% faster in some cases. Slightly slower in some others.
* img_convert: use multiple bounding boxes for ASS->RGBAwm42013-01-131-26/+47
| | | | | | Should be more efficient in situations both subtitles and toptitles are shown, because no blending has to be performed for the video between them.
* img_convert: add sub_bitmap bounding box functionswm42013-01-135-25/+97
| | | | mp_sub_bitmaps_bb is just sub_bitmaps_bb renamed/moved.
* draw_bmp: don't copy Y plane on up/down-samplingwm42013-01-131-5/+46
| | | | | | | | | | | Image areas with subtitles are upsampled to 4:4:4 in order to render the subtitles (makes blending easier). Try not to copy the Y plane on upsampling. The libswscale API requires this, but this commit works it around by scaling the chroma planes separately as AV_PIX_FMT_GRAY8. The Y plane is not touched at all. This is done for 420p8 only, which is the most commonly needed case. For other formats, the old way is used. Seems to make ASS rendering faster about 15% in the setup I tested.
* draw_bmp: do not reallocate upsample temp image on each framewm42013-01-131-2/+14
| | | | Doesn't seem to help too much...
* draw_bmp: refactorwm42013-01-131-17/+31
|
* draw_bmp: always allocate cachewm42013-01-131-26/+25
| | | | | | Allocate it even if it's needed. The actually done work is almost the same, except that the code is a bit simpler. May need more memory at once for RGB subs that use more than one part, which is rare.
* mp_image: add mp_image_crop()wm42013-01-131-12/+2
| | | | Actually stolen from draw_bmp.c.
* vo_xv, vo_x11: simplify OSD redrawingwm42013-01-134-149/+1
| | | | | | | | | | | | | In order to support OSD redrawing for vo_xv and vo_x11, draw_bmp.c included an awkward "backup" mechanism to copy and restore image regions that have been changed by OSD/subtitles. Replace this by a much simpler mechanism: keep a reference to the original image, and use that to restore the Xv/X framebuffers. In the worst case, this may increase cache pressure and memory usage, even if no OSD or subtitles are rendered. In practice, it seems to be always faster.
* sub: do not copy the target image if there is no OSD/subswm42013-01-132-0/+26
| | | | | | | | | | | | | | | | | | | | | It's not easy to tell whether the OSD/subs are empty, or if something is drawn. In general you have to use osd_draw() with a custom callback. If nothing is visible, the callback is never invoked. (The actual reason why this is so "hard" is the implementation of osd_libass.c, which doesn't allow separating rendering and drawing of OSD elements, because all OSD elements share the same ASS_Renderer.) To simplify avoiding copies, make osd_draw_on_image() instead of the caller use mp_image_make_writeable(). Introduce osd_draw_on_image_p(), which works like osd_draw_on_image(), but gets the new image allocation from an image pool. This is supposed to be an optimization, because it reduces the frequency of large allocations/deallocations for image data. The result of this is that the frequency of copies needed in conjunction with vf_sub, screenshots, and vo_lavc (encoding) should be reduced. vf_sub now always does true pass-through if no subs are shown. Drop the pts check from vf_sub. This didn't make much sense.
* draw_bmp: better way to find 444 formatwm42013-01-131-43/+13
| | | | | | | | | | | | | Even though #ifdef ACCURATE is removed, the result should be about the same. The fallback is only used by packed YUV formats (YUYV, NV12), and doing 16 bit for them instead of 8 bit is not useful. A side effect is that Y8 (gray) is not converted drawing subs, and for alpha formats, the alpha plane is not removed. This means the number of planes after upsampling can be 1-4 (1: gray, 2: gray+alpha, 3: planar, 4: planar+alpha). The code has to be adjusted accordingly to work on the color planes only. Also remove the workaround for the chroma shift 31 hack.
* video: cleanup: replace old mp_image function nameswm42013-01-132-9/+9
| | | | | mp_image_alloc() also changes argument order compared to alloc_mpi(). The format now comes first, then width/height.
* mp_image: simplify image allocationwm42013-01-131-16/+15
| | | | | | | | | | | | | | | | | | | | | | | | mp_image_alloc_planes() allocated images with minimal stride, even if the resulting stride was unaligned. It was the responsibility of vf_get_image() to set an image's width to something larger than required to get an aligned stride, and then crop it. Always allocate with aligned strides instead. Get rid of IMGFMT_IF09 special handling. This format is not used anymore. (IF09 has 4x4 chroma sub-sampling, and that is what it was mainly used for - this is still supported.) Get rid of swapped chroma plane allocation. This is not used anywhere, and VOs like vo_xv, vo_direct3d and vo_sdl do their own swapping. Always round chroma width/height up instead of down. Consider 4:2:0 and an uneven image size. For luma, the size was left uneven, and the chroma size was rounded down. This doesn't make sense, because chroma would be missing for the bottom/right border. Remove mp_image_new_empty() and mp_image_alloc_planes(), they were not used anymore, except in draw_bmp.c. (It's still allowed to setup mp_images manually, you just can't allocate image data with them anymore - this is also done in draw_bmp.c.)
* mp_image: require using mp_image_set_size() for setting w/hwm42013-01-131-5/+1
| | | | | | | | | | | | | | Setting the size of a mp_image must be done with mp_image_set_size() now. Do this to guarantee that the redundant fields (like chroma_width) are updated consistently. Replacing the redundant fields by function calls would probably be better, but there are too many uses of them, and is a bit less convenient. Most code actually called mp_image_setfmt(), which did this as well. This commit just makes things a bit more explicit. Warning: the video filter chain still sets up mp_images manually, and vf_get_image() is not updated.
* cleanup: ass_mp.h: remove dummy declarationswm42013-01-061-15/+1
|
* sub: add --sub-text-* options to unstyled text subtitles fontwm42013-01-052-2/+2
| | | | | | | Before this commit, the --osd-* options (like --osd-font-size etc.) configured both the OSD and subtitle font. Make them separate, and add --sub-text-* options (like --sub-text-size etc.). Now --osd-* affects the OSD font only, and --sub-text-* unstyled text subtitles only.
* demux_mpg, ass_mp: fix warningsRudolf Polzer2012-12-281-0/+4
| | | | | | | | The warnings in demux_mpg were silenced by additional no-operation casts. A variable in ass_mp was used only for some versions of libass; now the declaration is in that version #ifdef too to avoid a compiler warning.
* sub: add ASS to RGBA conversionwm42012-12-284-2/+83
| | | | | This makes implementing new VOs easier, because they don't have to support the ASS format.
* path: add mp_find_config_file and reorganize some of the codeStefano Pigozzi2012-12-152-14/+9
| | | | | | | | | | | | | | Add `mp_find_config_file` to search different known paths and use that in ass_mp to look for the fontconfig configuration file. Some incidental changes spawned by this feature where: * Buffer allocation for the strings containing the paths is now performed with talloc. All of the allocations are done on a NULL context, but it still improves readability of the code. * Move the OSX function for lookup inside of a bundle: this code path was currently not used by the bundle generated with `make osxbundle`. The plan is to use it again in a future commit to get a fontconfig config file.
* ass_mp: allow to use a custom fontconfig configuration fileStefano Pigozzi2012-12-151-9/+14
| | | | | | This allows to use a fontconfig fonts.conf that is customized for mpv. The configuration file is assumed to be located at `~/.mpv/fonts.conf`. If not found the default fcontconfig config file is used.
* sd_ass: free external subtitle trackswm42012-12-141-0/+6
|
* sd_lavc: keep subs on subtitle track switchingwm42012-12-121-1/+7
| | | | |