summaryrefslogtreecommitdiffstats
path: root/sub/sd_ass.c
Commit message (Collapse)AuthorAgeFilesLines
* sub: add option to workaround broken mkv fileswm42014-08-141-1/+1
| | | | See additions to options.rst.
* sub: remove old style override optionwm42014-06-051-27/+0
| | | | Didn't work too well.
* sub: fix undefined behavior in ASS color calculation (2)wm42014-05-101-2/+2
| | | | Same problem as previous commit, fix by using the MP_ASS_RGBA() macro.
* demux_libass: change how external ASS subtitles are loadedwm42014-03-151-9/+4
| | | | | | | | | | Instead of parsing the ASS file in demux_libass.c and trying to pass the ASS_Track to the subtitle renderer, just read all file data in demux_libass.c, and let the subtitle renderer pass the file contents to ass_process_codec_private(). (This happens to parse full files too.) Makes the code simpler, though it also relies harder on the (messy) probe logic in demux_libass.c.
* sd_ass: add a very simple and evil way to override ASS subtitle styleswm42014-03-011-0/+27
| | | | | | --ass-style-override=force now attempts to override the 'Default' style. May or may not work. In some situations it will work, but also mess up seemingly unrelated things like signs typeset with ASS.
* sub: fix crash with certain uses of --vf=subwm42014-01-261-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | If, for some reason, the subtitle renderer attempts to render a subtitle before SD_CTRL_SET_VIDEO_PARAMS was called, it passed a value calculated from invalid values. This can happen with --vf=sub and --start. The crash happens if 1. there was a subtitle packet that falls into the timestamp of the rendered video frame, 2. the playloop hasn't informed the subtitle decoder about the video resolution yet (normally unneeded, because that is used for weird corner cases only, so this code is a bit fuzzy), and 3. something actually requests a frame to be drawn from the subtitle renderer, like with vf_sub. The actual crash was due to passing NaN as pixel aspect to libass, which then created glyphs with ridiculous sizes, involving a few integer overflows and unchecked mallocs. The sd_lavc.c and sd_spu.c cases probably don't crash, but I'm not sure, and it's better fix them anyway. Not bothering with sd_spu.c, this crap is for compatibility and will be removed soon. Note that this would have been no problem, had the code checked whether SD_CTRL_SET_VIDEO_PARAMS was actually called. This commit adds such a check (although it basically checks after using the parameters). Regression since 49caa0a7 and 633fde4a.
* sub/osd: mp_msg conversionswm42013-12-211-4/+4
|
* Split mpvcore/ into common/, misc/, bstr/wm42013-12-171-2/+2
|
* Move options/config related files from mpvcore/ to options/wm42013-12-171-1/+1
| | | | | | | | | Since m_option.h and options.h are extremely often included, a lot of files have to be changed. Moving path.c/h to options/ is a bit questionable, but since this is mainly about access to config files (which are also handled in options/), it's probably ok.
* Rename sub.c/.h to osd.c/.hwm42013-11-241-1/+0
| | | | | This was way too misleading. osd.c merely calls the subtitle renderers, instead of actually dealing with subtitles.
* sd_ass, sd_lavc: use the input video's pixel aspect for scaling subtitles.Rudolf Polzer2013-11-071-1/+4
| | | | | | | The previous code used the output video's pixel aspect for stretching purposes, breaking rendering with e.g. -vf scale in the chain. Now subtitles are stretched using the input video's pixel aspect only, matching the intentions of the original subtitle author.
* command: sub_seek: avoid getting stuckwm42013-10-071-2/+5
| | | | | | | | | First, don't try to seek if the result is 0 (i.e. nothing found, or subtitle event happens to be exactly on spot). Second, since we never can make sure that we actually seek to the exact subtitle PTS (seeking "snaps" to video PTS), offset the seek by 10ms. Since most subtitle events are longer than 10ms, this should work fine.
* sd_ass: minor simplificationwm42013-09-241-14/+8
| | | | | There shouldn't be any functional changes. Just reduce the amount of pointless temporary variables.
* sd_ass: remove dead codewm42013-09-241-48/+0
| | | | | | This code was made inactive some months ago. At this time it wasn't entirely clear whether this code was still needed, but now I'm pretty sure it isn't. Even if it is, it didn't work anymore.
* core: move contents to mpvcore (2/2)Stefano Pigozzi2013-08-061-3/+3
| | | | Followup commit. Fixes all the files references.
* sd_ass: remove unused variable warningStefano Pigozzi2013-07-201-1/+1
| | | | The `track` variable is used only if `LIBASS_VERSION >= 0x01020000`.
* sd_ass: fix font aspect ratio with non-ASS subswm42013-07-161-4/+4
| | | | | | For subtitles that were not ASS, the subtitle font aspect was always set to that of the video, the exact opposite of how it was supposed to behave.
* Fix build on Libavwm42013-07-151-0/+1
| | | | Sigh, why does this happen all the time...
* sd_ass: scale blur by original video size if requestedwm42013-07-151-0/+9
|
* sd_add: add terrible hack for (xy-)vsfilter compatibilitywm42013-07-151-9/+132
| | | | | | Much has been said about this topic, we don't need to say even more. See additions to options.rst.
* sd_ass: convert pts to integer for get_text()wm42013-06-291-3/+2
| | | | Gives more consistent rounding, which makes sub_step behave better.
* dec_sub: introduce sub_control(), use it for sub_stepwm42013-06-291-10/+15
| | | | | | | This means the direct libass usage can be removed from command.c, and no weird hacks for retrieving the ASS_Track are needed. Also fix a bug when using this feature with ordered chapters.
* sd_ass: fix nonsensewm42013-06-251-1/+4
| | | | | | Actually check the newly added text for whitespace, and not the uninitialized buffer after it. Also, if an even is only whitespace, don't add it at all.
* sd_ass: disable special handling of subtitles with duration 0wm42013-06-251-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | sd_ass contains some code that treats subtitle events with duration 0 specially, and adjust their duration so that they will disappear with the next event. This is most likely not needed anymore. Some subtitle formats allow omitting the duration so that the event is visible until the next one, but both subreader.c as well as libavformat subtitle demuxers already handle this. Subtitles embedded in mp4 files (movtext) used to trigger this code. But these files appear to export subtitle duration correctly (at least libavcodec's movtext decoder is using this assumption). Since commit 6dbedd2 changed demux_lavf to actually copy the packet duration field, the code removed with this commit isn't needed anymore for correct display of movtext subtitles. (The change in sd_movtext is for dropping empty subtitle events, which would now be "displayed" - libavcodec does the same.) On the other hand, this code incorrectly displayed hidden events in .srt subtitles. See for example the first event in SubRip_capability_tester.srt (part of FFmpeg's FATE). These intentionally have a duration of 0, and should not be displayed. (As of with this commit, they are still displayed in external .srt subs because of subreader.c hacks.) However, we can't be 100% sure that this code is really unneeded, so just comment the code. Hopefully it can be removed if there are no regressions after some weeks or months.
* sd_ass: handle libavformat ASS comment packets as wellwm42013-06-231-17/+13
| | | | | | | | | | | | Currently, we are filtering libavformat style ASS packets by checking whether they are prefixed "Dialogue: ". Unfortunately, comment packets are demuxed too. These start with "Comment: ", so they are not caught. Change the filtering, and use the codec ID instead. libavformat uses "ssa" as codec ID for ASS subtitles, while mpv uses "ass". Also, at least FFmpeg will change the ASS packet format to the same format mpv and Matroska use, and identify these with "ass" as codec ID, so this is works out nicely.
* sub: add name field to all sub decoderswm42013-06-031-0/+1
| | | | Might help with debugging.
* sd_ass: add default style if there aren't any styleswm42013-06-031-4/+8
| | | | | | | | | | | | | | | | | | | The default style is added by mp_ass_default_track(), but not by ass_new_track(). Considering this, the previous condition at this point didn't make much sense anymore: the actual (converted) subtitle format doesn't matter much for what styling should be applied. What matters is if the subtitle was originally ASS, or if it was converted to it. Change the code such that the default style is added if there aren't any, even after reading sub extradata. (The extradata contains the ASS header, including the style section.) This might change behavior with scripts that don't define any styles. The change is either with this commit or with an earlier commit in this branch, depending on the situation - there are multiple places where default styles are added in libass API functions, and it's all a big mess. Other than with very old or broken files (where different behavior doesn't matter much), the current code should be pretty safe, though.
* sub: never set VSFilter aspect if the ASS subtitle is convertedwm42013-06-031-1/+2
| | | | | | | | When e.g. converting SRT to ASS, we certainly don't want them stretched by video aspect ratio, even if that's necessary for native ASS subtitles. Annoying weird details...
* sub: don't check for duplicates on sub conversionwm42013-06-031-5/+7
| | | | | | | This mirrors commit "sub: remove check_duplicate_plaintext_event()". That code was basically duplicated. In general, this code is still needed when doing conversion during demuxing (mostly because you can seek during demuxing, which will cause duplicate events by replaying).
* sd_ass: strip empty/whitespace lines in -no-ass modewm42013-06-031-1/+13
| | | | | Will just destroy output. In some cases empty newlines might be used by bad scripts for spacing; too bad for them.
* sub: make use of libavcodec subtitle converterswm42013-06-031-0/+7
| | | | | | | | | | This allows using some formats that were not supported until now, like WebVTT. We still prefer the internal subtitle reader (subreader.c), because 1. Libav, and 2. random things which we probably want to keep, such as control over formatting, codepage stuff, or various mysterious postprecessing done in that code.
* sub: turn subassconvert_ functions into sub converterswm42013-06-031-23/+15
| | | | | | | | | | | | | | | | | 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: basic subtitle converterswm42013-06-031-3/+2
| | | | | | | | | | Add a basic infrastructure for subtitle converters. These converters work sort-of like decoders, except that they produce packets instead of subtitle bitmaps. They are put in front of actual decoders. Start with sd_movtext. 4 lines of code are blown up to a 55 lines file, but fortunately this is not going to be that bad for the following converters.
* sub: refactorwm42013-06-011-41/+39
| | | | | | | | | | | | | | | | | | | | Make the sub decoder stuff independent from sh_sub (except for initialization of course). Sub decoders now access a struct sd only, instead of getting access to sh_sub. The glue code in dec_sub.c is similarily independent from osd. Some simplifications are made. For example, the switch_id stuff is unneeded: the frontend code just has to make sure to call osd_changed() any time subtitles are switched. This is also preparation for introducing subtitle converters. It's much cleaner to completely separate demuxer header/renderer glue/decoders for this purpose, especially since sub converters might completely change how demuxer headers have to be interpreted. Also pass data as demux_packets. Currently, this doesn't help much, but libavcodec converters might need scary stuff like packet side data, so it's perhaps better to go with passing packets.
* core: add demux_sub pseudo demuxerwm42013-06-011-27/+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-011-0/+14
| | | | Just pushing some code around.
* sub: add sd_spu.c to wrap spudec, cleanup mplayer.cwm42013-05-301-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: redo how -no-ass is handledwm42013-05-301-8/+94
| | | | | | | | | | | | | | | | | | | | | 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.
* sub, demux: identify subtitle types with the codec namewm42013-04-201-4/+13
| | | | | | | | | 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.
* sd_ass: free external subtitle trackswm42012-12-141-0/+6
|
* sub: clear libavformat demuxed subtitles on seekingwm42012-12-031-0/+6
| | | | | | libavformat demuxes ass subtitles in a broken way, that forces the player to throw away all subtitle events received so far. See mplayer svn commit 31293.
* sd_ass: fix ASS subtitles coming from demux_lavfwm42012-11-161-3/+7
| | | | | libavformat demuxes ASS subtitles as complete ASS event, rather than Matroska-mangled events without time codes.
* Rename directories, move files (step 2 of 2)wm42012-11-121-4/+4
| | | | | | | | | | | | 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.)
* VO, sub: refactorwm42012-10-241-6/+6
| | | | | | | | | | | | | | | | | | Remove VFCTRL_DRAW_OSD, VFCAP_EOSD_FILTER, VFCAP_EOSD_RGBA, VFCAP_EOSD, VOCTRL_DRAW_EOSD, VOCTRL_GET_EOSD_RES, VOCTRL_QUERY_EOSD_FORMAT. Remove draw_osd_with_eosd(), which rendered the OSD by calling VOCTRL_DRAW_EOSD. Change VOs to call osd_draw() directly, which takes a callback as argument. (This basically works like the old OSD API, except multiple OSD bitmap formats are supported and caching is possible.) Remove all mentions of "eosd". It's simply "osd" now. Make OSD size per-OSD-object, as they can be different when using vf_sub. Include display_par/video_par in resolution change detection. Fix the issue with margin borders in vo_corevideo.
* sub: fix text subtitle aspect ratio with vo_xv and vo_lavc, refactorwm42012-10-241-2/+2
| | | | | | | | | | | | | | | | | | | This fixes that vo_xv didn't display text subtitles correctly when using anamorphic video. It didn't pass the aspect information to the subtitle renderer. Also, try to render OSD correctly with respect to aspect ratio settings: on vo_xv, the OSD is rendered into the video, and needs to be "stretched" too when playing anamorphic video. When the -monitorpixelaspect option is used, even with VOs such as vo_opengl the OSD has to be rendered with that aspect ratio. As preparation for future commits, replace the weird vsfilter_scale value with a somewhat more sensible video_par member. Also, struct mp_eosd_res is a better place for the aspect ratio parameters, as OSD needs this too. Use osd_draw_on_image() directly in vo_lavc, which fixes aspect ratio issues as well.
* Merge branch 'master' into osd_changeswm42012-10-161-1/+3
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: Makefile command.c libvo/gl_common.c libvo/vo_corevideo.m libvo/vo_opengl.c libvo/vo_opengl_old.c libvo/vo_opengl_shaders.glsl sub/ass_mp.c sub/osd_libass.c sub/sd_ass.c
| * sub: add --ass-style-override option to disable style overrideswm42012-10-121-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are a number of options which modify ASS subtitle rendering. Most of these do things that can interfere with the styling done by subtitle scripts, resulting in incorrect rendering. Add the --ass-style-override option to make it easy to disable all overrides. This helps trouble- shooting, and makes it more practical to use the override features. (You can simply toggle the ass-style-override property at runtime, should one of the style override options break subtitle rendering at a certain point.) This mainly affects whether most --ass-* options are applied, as well as --sub-pos. Some things, like explicit style overrides loaded with --ass-force-style, can't be changed at runtime using the ass-style-override property.
* | sub: cosmetics: move things aroundwm42012-10-161-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Move sub-bitmap definitions from dec_sub.h to sub.h. While it's a bit odd that OSD data structures are in a file named sub.h, it's definitely way too strange to have them in a file about subtitle decoding. (Maybe sub.h/.c and the sub/ directory should be split out and renamed "osd" at a later point.) Remove including ass_mp.h (and the libass headers) where possible. Remove typedefs for mp_eosd_res and sub_bitmaps structs. Store a mp_eosd_res struct in osd_state instead of just w/h. Note that sbtitles might be rendered using different sizes/margins when filters are involved (the subtitle renderer is not supposed to use the OSD res directly, and the "dim" member removed in the previous commit is something different).
* | sub: cleanup: don't pass parameters via global variableswm42012-10-161-5/+6
| | | | | | | | | | | | | | | | | | | | | | Passing parameters from caller to subtitle renderer was done by temporarily setting certain members in the osd_state struct (which for all practical purposes are as good as global variables). This was the only purpose of these members. Rather than using such a messy way to pass parameter, put these into a struct sub_render_params. The struct was already introduced in earlier commits, and this commit just removes the parameter passing hack.
* | sub: remove logic for disabling hinting on scaled EOSDwm42012-10-161-1/+1
| | | | | | | | | | | | | | | | | | | | | | This was an extremely obscure setting, as it was used only with vo_gl if its scaled-osd suboption was used. If you really want this, you can set the desired ass-hinting value directly, and there will be literally no loss in functionality. Note that this didn't actually test whether the EOSD was scaled. Basically, it only checked whether vo_gl had the scaled-osd suboption set.
* | sub: allow rendering OSD in ASS image format directly, simplifywm4