aboutsummaryrefslogtreecommitdiffhomepage
path: root/sub/ass_mp.c
Commit message (Collapse)AuthorAge
* options: move most subtitle and OSD rendering options to sub structsGravatar wm42018-01-02
| | | | | | | | | | | | | | | | | | | | | | | | | | | Remove them from the big MPOpts struct and move them to their sub structs. In the places where their fields are used, create a private copy of the structs, instead of accessing the semi-deprecated global option struct instance (mpv_global.opts) directly. This actually makes accessing these options finally thread-safe. They weren't even if they should have for years. (Including some potential for undefined behavior when e.g. the OSD font was changed at runtime.) This is mostly transparent. All options get moved around, but most users of the options just need to access a different struct (changing sd.opts to a different type changes a lot of uses, for example). One thing which has to be considered and could cause potential regressions is that the new option copies must be explicitly updated. sub_update_opts() takes care of this for example. Another thing is that writing to the option structs manually won't work, because the changes won't be propagated to other copies. Apparently the only affected case is the implementation of the sub-step command, which tries to change sub_delay. Handle this one explicitly (osd_changed() doesn't need to be called anymore, because changing the option triggers UPDATE_OSD, and updates the OSD as a consequence). The way the option value is propagated is rather hacky, but for now this will do.
* msg: reinterpret a bunch of message levelsGravatar Niklas Haas2017-12-15
| | | | | | | | | | | | | | | | | | | | | | I've decided that MP_TRACE means “noisy spam per frame”, whereas MP_DBG just means “more verbose debugging messages than MSGL_V”. Basically, MSGL_DBG shouldn't create spam per frame like it currently does, and MSGL_V should make sense to the end-user and provide mostly additional informational output. MP_DBG is basically what I want to make the new default for --log-file, so the cut-off point for MP_DBG is if we probably want to know if for debugging purposes but the user most likely doesn't care about on the terminal. Also, the debug callbacks for libass and ffmpeg got bumped in their verbosity levels slightly, because being external components they're a bit less relevant to mpv debugging, and a bit too over-eager in what they consider to be relevant information. I exclusively used the "try it on my machine and remove messages from MSGL_* until it does what I want it to" approach of refactoring, so YMMV.
* ass_mp: change license to LGPLGravatar wm42017-04-20
| | | | | | | Somewhat chaostic history: libass/ass_mp.* -> ass_mp.* -> sub/ass_mp.* As far as I can tell, everyone who ever touched these files has agreed to the relicensing.
* ass_mp: reallocate cached subtitle image data on format changesGravatar wm42017-04-18
| | | | | | | | When the format of the subtitle bitmaps changes, such as with taking screenshots with vo_vaapi (RGBA for the VO vs. Y8 for screenshots), the cache image obviously needs to be recreated. Fixes #4325.
* sub: add justify of subtitlesGravatar Dan Oscarsson2017-02-01
| | | | | | | | To make it easier for the eyes, multi line subtitles should be left justified (for most languages). This adds an option to define how subtitles are to be justified inpendently of how they are aligned. Also add option to enable --sub-justify to be applied on ASS subtitles.
* sub: change how libass output is converted to RGBA in some casesGravatar wm42016-07-03
| | | | | | | | | | | | | | | | | This affects VOs (or other code which render OSD) which does not support the LIBASS format, but only RGBA. Instead of having a converter stage in osd.c, make mp_ass_packer_pack() output directly in RGBA. In general, this is work towards refcounted subtitle images. Although we could keep the "converter" design, doing it this way seems simpler, at least considering the current situation with only 2 OSD formats. It also prevents copying & packing the data twice, which will lead to better performance. (Although I guess this case is not important at all.) It also fixes --force-rgba-osd-rendering when used with vo_opengl, vo_vdpau, and vo_direct3d.
* sub: move around some codeGravatar wm42016-07-03
| | | | | Put the packing code into separate functions. Preparation for the following commit.
* sub: set ASS sub bitmap data to correct pointerGravatar wm42016-07-01
| | | | | Point it to the copied data. Doesn't really matter at this point, but later it might have left dangling pointers.
* sub: pack libass bitmaps directly in sd_ass.c and osd_libass.cGravatar wm42016-06-30
| | | | | | | | | | | | | | | | Change all producer of libass images to packing the bitmaps into a single larger bitmap directly when they're output. This is supposed to help working towards refcounted sub bitmaps. This will reduce performance for VOs like vo_xv, but not for vo_opengl. vo_opengl simply will pick up the pre-packed sub bitmaps, and skip packing them again. vo_xv will copy and pack the sub bitmaps unnecessarily - but if we want sub bitmap refcounting, they'd have to be copied anyway. The packing code cannot be removed yet from vo_opengl, because there are certain corner cases that still produce unpackad other sub bitmaps. Actual refcounting will also require more work.
* osd: add italic font for osdGravatar st4t1k2016-04-08
|
* osd: refactor how mp_ass_render_frame() is calledGravatar wm42016-03-08
| | | | | | | | Instead of passing an explicit cache to the function, the res parameter is used. Also, instead of replacing its contents, sub bitmaps are now appended to it (all assuming the format doesn't actually change). This is preparation for the following commits.
* ass_mp: add mp_ass_flush_old_events()Gravatar Aman Gupta2016-01-18
|
* sub: remove unused function, move another oneGravatar wm42015-11-29
| | | | | mp_ass_default_track() was not used by anything anymore (commit 5a89150a got rid of it). mp_ass_add_default_styles() is used by sd_ass.c only.
* osd: fix and cleanup font style managementGravatar wm42015-11-29
| | | | | | | | | | | Commit 2b07d3eb merged progbar and OSD text renderer into one ASS_Track, but it confused the styles. Specifically, if both progbar and OSD are visible, the create_ass_track() call made by the progbar code will reset the style adjusted by the OSD text code. Change create_ass_track() not to add any styles. Instead let the caller manage the styles. They are now referenced by name, and lazily added if they don't exist yet. This is also much cleaner.
* sub: remove use of semi-deprecated libass fieldGravatar wm42015-10-28
| | | | | In newer libass version, this does nothing, and will be removed on the next API/ABI bump.
* Update license headersGravatar Marcin Kurczewski2015-04-13
| | | | Signed-off-by: wm4 <wm4@nowhere>
* sub: add --sub-text-bold optionGravatar wm42015-04-01
| | | | This was basically requested.
* osd: simplify an aspect of change detection handlingGravatar wm42015-03-18
| | | | | | | | | | | | | | | | | | There was a somewhat obscure optimization in the OSD and subtitle rendering path: if only the position of the sub-images changed, and not the actual image data, uploading of the image data could be skipped. In theory, this could speed up things like scrolling subtitles. But it turns out that even in the rare cases subtitles have such scrolls or axis-aligned movement, modern libass rarely signals this kind of change. Possibly this is because of sub-pixel handling and such, which break this. As such, it's a worthless optimization and just introduces additional complexity and subtle bugs (especially in cases libass does the opposite: incorrectly signaling a position change only, which happened before). Remove this optimization, and rename bitmap_pos_id to change_id.
* sub: fully update plaintext subtitle styles at runtimeGravatar wm42015-02-24
| | | | | | | | | | | | | | | Update options like --sub-text-margin-y at runtime. These are somewhat of a problem, because ass_set_selective_style_override() (intentionally) does not override them. This should be fixed in libass (by providing additional override modes), but for now this will do. Also change the signature of mp_ass_configure(), so we can get access to the track. Additionally, drop the redundant setting of the style Alignment (it's overwritten by mp_ass_set_style()). See #1622 (again).
* sub: move mp_ass_configure() codeGravatar wm42015-02-24
| | | | | sd_ass.c is the only user, and the function is starting to become extremely "special". No other changes.
* sub: apply text subtitle style overrides more eagerlyGravatar wm42015-02-24
| | | | | | | | | | Basically abuse the style override mechanism meant for ASS (mp_ass_set_style()) to update text subtitle styling at runtime too. This even has the advantage that the style will be overridden, even if the text subtitle converted (like sd_lavc_conv.c) dares to add a fixed style in the styles section. Probably helps with #1622.
* libass: remove redundant checks for LIBASS_VERSIONGravatar Ben Boeckel2015-02-24
| | | | Since 0.12.1 is the minimum, just assume it in the code too.
* sub: mess with styling defaults, change --ass-use-margins behaviorGravatar wm42015-02-16
| | | | | | | | | | | | | | | | | | | Now --ass-use-margins doesn't apply to normal subtitles anymore. This is probably the inverse from the mpv behavior users expected so far, and thus a breaking change, so rename the option, that the user at least has a chance to lookup the option and decide whether the new behavior is wanted or not. The basic idea here is: - plain text subtitles should have a certain useful defalt behavior, like actually using margins - ASS subtitles should never be broken by default - ASS subtitles should look and behave like plaintext subtitles if the --ass-style-override=force option is used This also subtly changes --sub-scale-with-window and adds the --ass- scale-with-window option. Since this one isn't so important, don't bother with compatibility.
* osd: customizable subtitle and OSD positionGravatar wm42015-02-16
| | | | | | You can set in which "corner" the OSD and subtitles are shown. I'd prefer it a bit more general (so you could set the alignment using a factor), but the libass API does not provide this.
* ta: rename MP_TALLOC_ELEMS to MP_TALLOC_AVAILGravatar Ben Boeckel2015-01-27
| | | | | The macro actually returns the *available* space in the array, not how much is actually filled in.
* sub: add option to not scale subtitles with windowGravatar wm42015-01-05
| | | | | | | | | | | | | --sub-scale-by-window=no attempts to keep subs always at the same pixel size. The implementation is a bit all over the place, because it compensates already done scaling by an inverse scale factor, but it will probably do its job. Fixes #1424. (The semantics and name of --sub-scale-with-window are kept, and this adds a new option - the name is confusingly similar, but it's actually analogue to --osd-scale-by-window.)
* sub: adjustments to --ass-style-override optionGravatar wm42014-10-17
| | | | | | | | | | Now requires newest libass git. Since this feature wasn't part of a libass release yet, I'm not bothering making the mpv code compatible with as how it was previously implemented (it will just be disabled with any older libass). CC: @mpv-player/stable (because mpv-build uses libass git, and this breaks the feature)
* ass: remove some pointless ifdefferyGravatar wm42014-07-22
| | | | | This will print compiler warnings about unused variables with older libass versions, but that's harmless.
* Basic xdg directory implementationGravatar Kenneth Zhou2014-06-26
| | | | | | | | | | Search $XDG_CONFIG_HOME and $XDG_CONFIG_DIRS for config files. This also negates the need to have separate user and global variants of mp_find_config_file() Closes #864, #109. Signed-off-by: wm4 <wm4@nowhere>
* sub: add --sub-scale-with-window optionGravatar wm42014-06-14
| | | | Implements the feature requested in #839 and #186.
* Add more constGravatar wm42014-06-11
| | | | | | | While I'm not very fond of "const", it's important for declarations (it decides whether a symbol is emitted in a read-only or read/write section). Fix all these cases, so we have writeable global data only when we really need.
* sub: add --ass-style-override=force optionGravatar wm42014-06-05
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (The old "force" choice of that option is renamed to "force-default".) This allows overriding native ASS script subtitle styles with the style provided by the --sub-text-* options (like --sub-text-font etc.). This is disabled by default, and needs to be explicitly enabled with the --ass-style-override=force option and input property. This uses in fact exactly the same options (--sub-text-*) and semantics as the ones used to configure unstyled text subtitles. It's recommended to combine this with this in the mpv config file: ass-force-style="ScaledBorderAndShadow=1" # work around dumb libass behavior Also, adding a key binding to toggle this behavior should be added, because overriding can easily break: L cycle ass-style-override This would cycle override behavior on Shift+L and allows quickly disabling/enabling style overrides. Note: ASS should be considered a vector format rather than a subtitle format. There is no easy or reliable way to determine whether the style of a given subtitle event can be changed without destroying visuals or not. This patch relies on a simple heuristic, which often works and often breaks.
* osd/libass: use BorderStyle=4 for backgroundGravatar wm42014-06-01
| | | | Avoids (some) overlaps. Hopefully fixes #822.
* ass_mp: don't use --subcp for --ass-stylesGravatar wm42014-03-31
| | | | | | | | | | | | | The --ass-styles option is implemented by calling ass_read_styles(). This function can take a codepage (so libass will use iconv to convert it). This was implemented before our --subcp option was changed, and this code was not updated. Now libass fails opening iconv, because --subcp is not always (and not by default) a valid iconv codepage. Just always pass NULL, which means the file passed to --ass-styles must be in UTF-8. The --ass-styles option is a fringe option anyway (and will destroy your subtitles), so having codepage support for it isn't important at all.
* msg: rename mp_msg_log -> mp_msgGravatar wm42013-12-21
| | | | Same for companion functions.
* msg: convert defines to enumGravatar wm42013-12-21
| | | | Also get rid of MSGL_HINT and the many MSGL_DBG* levels.
* path lookup functions: mp_msg conversionsGravatar wm42013-12-21
| | | | | | | | | | | | | | | | | There's a single mp_msg() in path.c, but all path lookup functions seem to depend on it, so we get a rat-tail of stuff we have to change. This is probably a good thing though, because we can have the path lookup functions also access options, so we could allow overriding the default config path, or ignore the MPV_HOME environment variable, and such things. Also take the chance to consistently add talloc_ctx parameters to the path lookup functions. Also, this change causes a big mess on configfiles.c. It's the same issue: everything suddenly needs a (different) context argument. Make it less wild by providing a mp_load_auto_profiles() function, which isolates most of it to configfiles.c.
* sub/osd: mp_msg conversionsGravatar wm42013-12-21
|
* Split mpvcore/ into common/, misc/, bstr/Gravatar wm42013-12-17
|
* Move options/config related files from mpvcore/ to options/Gravatar wm42013-12-17
| | | | | | | | | 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.
* osd_libass: update styles when OSD changes PlayResGravatar wm42013-12-15
| | | | | | | The OSD style settings depend on the PlayRes, simply because all style values are implicitly scaled by the PlayResY in libass. Also, the OSC changes the PlayResY in certain situations, so something could go wrong. But not sure if this actually matters in practice.
* osd: use separate ASS_Renderer for each OSD objectGravatar wm42013-12-15
| | | | | | | | This simplifies things, although it is slightly less efficient (probably uses a bit more memory). This also happens to fix that the OSC dropped the libass cache on every frame.
* osd: add option for "unscaled" OSDGravatar wm42013-12-10
|
* Rename sub.c/.h to osd.c/.hGravatar wm42013-11-24
| | | | | This was way too misleading. osd.c merely calls the subtitle renderers, instead of actually dealing with subtitles.
* osd_libass: add "Default" dummy styleGravatar wm42013-09-26
| | | | | | This is pretty much a hack for the OSC. It will allow it to rely on a somewhat predictable style, instead of having to overwrite all user OSD settings manually with override tags.
* options: allow selecting the libass shaperGravatar wm42013-09-25
| | | | | | I'm using the word "languages" instead of "scripts" in the manpage, but I think that's easier to understand with a smaller amount of descriptions.
* options: make --ass-hinting a choice, instead of using magic numbersGravatar wm42013-09-25
| | | | | options.c still doesn't use the constants defined by the libass headers, but it's still better than exposing those to the user directly.
* sub/ass_mp: remove superfluous message prefixesGravatar Martin Herkt2013-09-23
|
* core: move contents to mpvcore (2/2)Gravatar Stefano Pigozzi2013-08-06
| | | | Followup commit. Fixes all the files references.
* sub: add demux_libass wrapper, drop old hacksGravatar wm42013-06-25
| | | | | | | | | | | | demux_libass.c allows us to make subtitle format detection part of the normal file loading process. libass has no probe function, but trying to load the start of a file (the first 4 KB) is good enough. Hope that libass can even handle random binary input gracefully without printing stupid log messages, and that the libass parser doesn't accept too many non-ASS files as input. This doesn't handle the -subcp option correctly yet. This will be fixed later.