summaryrefslogtreecommitdiffstats
path: root/sub/osd_libass.c
Commit message (Collapse)AuthorAgeFilesLines
* osd: fix and cleanup font style managementwm42015-11-291-48/+59
| | | | | | | | | | | 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.
* osd: use the same ASS_Renderer for OSD text and progbarwm42015-11-281-29/+41
| | | | | | Reduces memory usage and startup times. The implementation is a bit weird, because both OSD parts have conflicting requirements on the used ASS styles.
* player: remove OSD subtitle render pathwm42015-11-171-30/+0
| | | | | | | | | | | | | | | | | | | This was used with --no-sub-ass (aka --no-ass). This option (which is not yet removed) strips all styling from the subtitles, and renders them as plaintext only. For some reason, it originally seemed convenient to reuse all the OSD text rendering code (osd_libass.c). While this was indeed simple, it had a bad influence on the rest of the code. For example, it had to decide whether to go through the OSD code path, or the proper subtitle renderer in sd_ass.c. Kill the OSD subtitle renderer. Reimplement --no-sub-ass and also "secondary" subtitles in sd_ass.c. fill_plaintext() contains some rather minor code duplication with osd_libass.c for setting up a dummy ASS_Event and escaping the stripped text. Since sd_ass.c already has to handle "normal" text subtitles, and has code for stripping ASS tags, this remains all relatively simple. Remove all the unnecessary crap from the rest of the code.
* options: remove --use-text-osdwm42015-10-241-3/+0
|
* osd: delay libass initialization as far as possiblewm42015-09-071-5/+9
| | | | | | | | | | | | Until now, most OSD objects created the associated ASS_Renderer instance as soon as possible, even if nothing was going to be rendered. Maybe this was even intentional. Change this for the sake of lowering resource usage, and strictly initialize ASS_Renderer only when it's really needed. For the OSC, initialization has to be forced, because of the insane mechanism for translating mouse coordinates to OSD coordinates.
* Update license headersMarcin Kurczewski2015-04-131-4/+4
| | | | Signed-off-by: wm4 <wm4@nowhere>
* osd: force alignment for OSD barwm42015-02-241-1/+2
| | | | | | | | Overwrite the alignment applied by the OSD style. Additionally, remove the initialization of the Alignment field in create_ass_track(); the value is always overwritten by mp_ass_set_style() later. Fixes #1626.
* osd: always reset style paramswm42015-02-241-11/+8
| | | | | | | There was some logic to set certain things on init only. Not sure why this was done (saving some cheap calculations?) - but since the next call would override these style settings by applying the usual subtitle style, I don't think this was intended.
* libass: remove redundant checks for LIBASS_VERSIONBen Boeckel2015-02-241-2/+0
| | | | Since 0.12.1 is the minimum, just assume it in the code too.
* player: add option not to use OSD/fontconfigwm42014-11-251-0/+3
| | | | | | | Makeshift-solution for working around certain fontconfig issues. With --use-text-osd=no, libass and fontconfig won't be initialized, and fontconfig won't block everything with scanning for fonts.
* Add some missing "const"swm42014-10-101-2/+2
| | | | | | | The one in msg.c was mistakenly removed with commit e99a37f6. I didn't actually test the change in ao_sndio.c (but obviously "ap" shouldn't be static).
* command: allow using ASS tags on OSD messageswm42014-09-181-2/+12
| | | | | | | | | | | We don't allow this by default, because it would be silly if random external data (like filenames or file tags) could accidentally trigger them. Add a property that magically disables this ASS tag escaping. Note that malicious input could still disable ASS tag escaping by itself. This would be annoying but harmless.
* Move compat/ and bstr/ directory contents somewhere elsewm42014-08-291-1/+1
| | | | | | | | | bstr.c doesn't really deserve its own directory, and compat had just a few files, most of which may as well be in osdep. There isn't really any justification for these extra directories, so get rid of them. The compat/libav.h was empty - just delete it. We changed our approach to API compatibility, and will likely not need it anymore.
* sub: uglify OSD code path with lockingwm42014-01-181-17/+21
| | | | | | | | | | | | | | | Do two things: 1. add locking to struct osd_state 2. make struct osd_state opaque While 1. is somewhat simple, 2. is quite horrible. Lots of code accesses lots of osd_state (and osd_object) members. To make sure everything is accessed synchronously, I prefer making osd_state opaque, even if it means adding pretty dumb accessors. All of this is meant to allow running VO in their own threads. Eventually, VOs will request OSD on their own, which means osd_state will be accessed from foreign threads.
* osd_libass: use bstr_xappend()wm42013-12-301-22/+25
| | | | Partially, just enough to drop mp_append_utf8_buffer().
* player: add --secondary-sid for displaying a second subtitle streamwm42013-12-241-3/+6
| | | | | | | This is relatively hacky, but it's Christmas, so it's ok. This does two things: 1. allow selecting two subtitle tracks, and 2. include a hack that renders the second subtitle always as toptitle. See manpage additions how to use this.
* sub/osd: mp_msg conversionswm42013-12-211-2/+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.
* osd_libass: update styles when OSD changes PlayReswm42013-12-151-5/+10
| | | | | | | 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 objectwm42013-12-151-39/+47
| | | | | | | | 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" OSDwm42013-12-101-1/+6
|
* Rename sub.c/.h to osd.c/.hwm42013-11-241-1/+1
| | | | | This was way too misleading. osd.c merely calls the subtitle renderers, instead of actually dealing with subtitles.
* osd_libass: add "Default" dummy stylewm42013-09-261-0/+7
| | | | | | 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.
* Add initial Lua scripting supportwm42013-09-261-0/+42
| | | | | | | | | | | | | | | | | | | | | | This is preliminary. There are still tons of issues, and any aspect of scripting may change in the future. I decided to merge this (preliminary) work now because it makes it easier to develop it, not because it's done. lua.rst is clear enough about it (plus some sarcasm). This requires linking to Lua. Lua has no official pkg-config file, but there are distribution specific .pc files, all with different names. Adding a non-pkg-config based configure test was considered, but we'd rather not. One major complication is that libquvi links against Lua too, and if the Lua version is different from mpv's, you will get a crash as soon as libquvi uses Lua. (libquvi by design always runs when a file is opened.) I would consider this the problem of distros and whoever builds mpv, but to make things easier for users, we add a terrible runtime test to the configure script, which probes whether libquvi will crash. This is disabled when cross-compiling, but in that case we hope the user knows what he is doing.
* osc: rename osd_font, add some glyphsChrisK22013-09-081-4/+2
| | | | | | | | | | Cherry picked from various commits in lua_experiment by ChrisK2. The metrics of the OSD symbols change slightly, possibly due to the font editor that was used, and the metrics were not correct to begin with. (But the real reason seems unknown.) Remove the rescaling of the OSD font in ASS_USE_OSD_FONT, because the height more or less fits now. (This change wasn't in the lua_experiment branch.)
* osd_libass: make sure Z-order is well defined for multiple eventswm42013-09-081-0/+1
| | | | Otherwise, events may overlap in arbitrary ways.
* core: move contents to mpvcore (2/2)Stefano Pigozzi2013-08-061-3/+3
| | | | Followup commit. Fixes all the files references.
* Cleanup some include statementswm42013-07-121-1/+1
|
* ass_mp: provide function to add default styleswm42013-06-031-3/+3
|
* sub: remove some global variableswm42013-05-301-1/+1
|
* sub: redo how -no-ass is handledwm42013-05-301-9/+3
| | | | | | | | | | | | | | | | | | | | | 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.
* 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-301-65/+165
| | | | | | | | | | | | | | | | | | | | | | | | | | 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).
* 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
|
* sub: add --sub-text-* options to unstyled text subtitles fontwm42013-01-051-1/+1
| | | | | | | 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.
* osd: make the OSD and sub font more customizablewm42012-11-201-23/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Make more aspects of the OSD font customizable. This also affects the font used for unstyled subtitles (such as SRT), or when using the --no-ass option. This adds back some customizability that was lost with commit 74e7a1 (osd: use libass for OSD rendering). Removed options: --ass-border-color --ass-color --font --subfont --subfont-text-scale Added options: --osd-color --osd-border --osd-back-color --osd-shadow-color --osd-font --osd-font-size --osd-border-size --osd-margin-x --osd-margin-y --osd-shadow-offset --osd-spacing --sub-scale The font size is now specified in pixels as it would be rendered on a window with a height of 720 pixels. OSD and subtitles are always scaled with the window height, so specifying or expecting an absolute font size doesn't make sense. Such scaled pixel units are used to specify font border etc. as well. (Note: the font size is directly passed to libass. How the fonts are actually rasterized is outside of our control, but in theory ASS font sizes map to "script" pixels and then are scaled to screen size.) The default settings should be about the same, with slight difference due to rounding to the new scales. The OSD and subtitle fonts are not separately configurable. It has limited use and would double the number of newly added options, which would be more confusing than helpful. It could be easily added later, should the need arise. Other small details that change: - ASS_Style.Encoding is not set to -1 for subs anymore (assuming subs use VSFilter direction in -no-ass mode too) - use a different WrapStyle for OSD - ASS forced styles are not applied to OSD
* Rename directories, move files (step 2 of 2)wm42012-11-121-2/+2
| | | | | | | | | | | | 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.)
* Merge branch 'master' into osd_changeswm42012-10-241-2/+2
|\ | | | | | | | | Conflicts: libvo/vo_xv.c
| * osd_libass: increase robustness when handling internal OSD escapeswm42012-10-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The \xFF escape is used internally to insert special OSD symbols (which need a font change to the internal OSD font). There was potential for breakage when \xFF was followed by \0, because then "in" would be advanced past the string's end. Normally this can't happen, as it would require invalid UTF-8 input data. But we don't check input for UTF-8 validness, so there's a potential issue here. Garbled output is ok on invalid UTF-8 input, but crashing is not. Make it more robust by checking for this.
| * osd_libass: fix stupid dangling pointer crashwm42012-10-221-1/+1
| | | | | | | | | | | | | | | | | | | | append_utf8_buffer() reallocates the buffer passed to it, and returns the new pointer. This bug was originally introduced in mplayer2 when that project merged mpv's osd_libass.c. That merge changed some minor things, including ASS escape handling. When mpv used this better method of escape handling too (commit 0ff7dd992fb0), the bug was duplicated.
* | options: remove --subfont-autoscale (changes default font scale)wm42012-10-241-13/+1
| | | | | | | | | | | | | | | | | | The code for this option attempted to emulate the old as-documented behavior. It wasn't very good at it, and now that the old OSD code has been removed, it's entirely pointless. This removes the factor 1.7 with which --subfont-text-scale was multiplied.
* | VO, sub: refactorwm42012-10-241-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-9/+6
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| * osd_libass: fix \n escapeswm42012-10-141-8/+3
| | | | | | | | | | | | | | | | | | Apparently libass can't be made to not interpret "\n" as escape. That means "\n" can't be printed literally. Use the same hack that was added to mplayer2 when that project merged osd_libass.c: add an invisible zero-width joiner character between "\" and "n". It seems U+FEFF is deprecated, because it has been redefined as BOM mark. Use U+2060, which seems to be the replacement.
| * sub: enable sub-pos with libasswm42012-10-121-1/+3
| | | | | | | | | | | | | | | | | | | | The --sub-pos option and sub-pos property control the vertical position of a subtitle. Also change how sub-pos is handled in the old subtitle renderer (used with -no-ass). The new behavior doesn't render subtitles out of the screen if the subtitle is located near the top screen border and has too many lines.
* | sub: cosmetics: move things aroundwm42012-10-161-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | |