summaryrefslogtreecommitdiffstats
path: root/sub/osd_libass.c
Commit message (Collapse)AuthorAgeFilesLines
* osd: don't skip leading whitespace on the first line eitherwm42017-11-021-1/+1
| | | | Stupid libass.
* osd: don't strip leading whitespace in messageswm42017-10-301-0/+7
| | | | Do this by replacing the first space after a line break with "\h".
* osd_libass: avoid libass warnings if scripts set ASS text earlywm42017-07-161-19/+29
| | | | | | | | | | | | | | | | Lua scripts can call osd_set_external() early (before the VO window is created and obj->vo_res is filled), in which case the PlayResX field would be set to nonsense, and libass would print a pointless warning. There's an easy and a hard fix: either just go on and pass dummy values to libass (basically like before, just clamp them to avoid the values which make libass print the warning). Or attempt to update the PlayRes field to correct values on rendering (since at rendering time, you always know the screen size and the correct values). Do the latter. Since various things use PlayRes for scaling things, this might still not be fully ideal. This is a general problem with the async scripting interface.
* command: shorten long playlists on OSDwm42017-01-261-5/+23
| | | | | | | | | | | | A hacky, convoluted, half-working mess that attempts to cut off overlong playlists. It does so by relying on the ASS formatting rule that the font size is specified in the virtual PlayResY resolution. This means we can (normally) easily tell how many lines fit on the screen. On the other hand, this does not work if the text is wrapped. This as a kludge until a Betterâ„¢ solution is available.
* osd: fix OSD redrawing after removing external overlayswm42016-09-201-0/+2
|
* osd: fix OSD getting stuck with --blend-subtitles=yeswm42016-09-161-2/+3
| | | | | | | | | | | | | If --blend-subtitles=yes is given, vo_opengl will call osd_draw() multiple times, once for subtitles, and once for OSD. This meant that the want_redraw flag was reset before the OSD was rendered, which in turn meant that update_osd() was never called. It seems like removing the per-OSD object want_redraw wasn't such a good idea. Fix it by reintroducing such a flag for OSDTYPE_OSD only. Also, the want_redraw flag is now unused, so kill it. Another regression caused by commit 9c9cf125. Fixes #3535.
* osd: slightly simplify update logicwm42016-09-151-2/+2
| | | | | | | | | | | | | | | | Remove the per-part force_redraw flags, and instead make the difference between flagging dirty state and returning it to the player frontend more explicit. The big issue is that 1. the OSD needs to know the dirty state, and it should be cleared strictly when it is re-rendered (force_redraw flag), and 2. the player core needs to be notified once, and the notification must be reset (want_redraw flag). The call in loadfile.c is replaced by making osd_set_sub() set the change flag. Increasing the change flag on dirty state (the force_redraw check in render_object()) should not be needed, because OSD part renderers set it correctly (at least now). Doing this just because someone pointed this out.
* sub: pass preferred OSD format to subtitle rendererswm42016-07-031-2/+2
| | | | | | | | The intention is to let mp_ass_packer_pack() produce different output for the RGBA and LIBASS formats. VOs (or whatever generates the OSD) currently do not signal a preferred format, and this mechanism just exists to switch between RGBA and LIBASS formats correctly, preferring LIBASS if the VO supports it.
* sub: pack libass bitmaps directly in sd_ass.c and osd_libass.cwm42016-06-301-11/+22
| | | | | | | | | | | | | | | | 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: make osd_ass_0/1 defineswm42016-05-031-6/+3
| | | | So we can concatenate them with strings at compile time.
* osd, lua: manage multiple ASS overlays set with set_osd_ass() callswm42016-03-081-19/+62
| | | | | | | | | | | | | | | | | | | | | | | | | Until now, there was only 1 global ASS overlay that could be set by all scripts. This was often perceived as bug when multiple scripts tried to set their own ASS overlay. This was kind of hard to solve because the script could set its own ASS PlayResX/Y, which makes it impossible to share a single ASS_Renderer for multiple scripts. The OSC unfortunately makes use of this feature (and unfortunately can't be fixed because it's a POS), so we're stuck with this complication. Implement the worst-case solution and fix this by creating separate ASS track and renderer objects for each script that wants to set an ASS overlay. The z-order is decided by the order the scripts set their text first. This is essentially random, unless you do it at script init, and you pass scripts in a specific order. Script initialization is currently serialized (as a feature), so the first loaded script gets lowest Z-order. The Lua script API interestingly remains the same. (And also will remain undocumented, unsupported, and potentially volatile.)
* osd: restructure and move ASS objects into its own structwm42016-03-081-58/+73
| | | | | | All ASS objects used by the OSD renderer go into struct ass_state. Preparation for the following commit.
* osd: refactor how mp_ass_render_frame() is calledwm42016-03-081-4/+7
| | | | | | | | 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.
* osd, lua: remove weird OSD scalingwm42016-03-071-10/+0
| | | | | | | | | | | | | | | | | | | | | Do not scale OSD mouse input to the ASS OSD script resolution. The original idea of this mechanism was that the user doesn't have to care about the actual resolution of anything, and can just use the OSD resolution consistently. But this made things worse. Remove the implicit scaling, and always use the screen resolution. (Except with --vo=xv, where additional scaling is forced upon everything.) Drop get_osd_resolution(). There is no replacement. Rename get_screen_size() and get_screen_margins() to use "osd" instead of "screen". For anything but --vo=xv these are equivalent, but with --vo=xv the OSD resolution has additional implicit scaling. Add code to osc.lua which emulates the old behavior. Note that none of the changed functions were public API, so implicit breakage of scripts which used it is just going to happen.
* Relicense some non-MPlayer source files to LGPL 2.1 or laterwm42016-01-191-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This covers source files which were added in mplayer2 and mpv times only, and where all code is covered by LGPL relicensing agreements. There are probably more files to which this applies, but I'm being conservative here. A file named ao_sdl.c exists in MPlayer too, but the mpv one is a complete rewrite, and was added some time after the original ao_sdl.c was removed. The same applies to vo_sdl.c, for which the SDL2 API is radically different in addition (MPlayer supports SDL 1.2 only). common.c contains only code written by me. But common.h is a strange case: although it originally was named mp_common.h and exists in MPlayer too, by now it contains only definitions written by uau and me. The exceptions are the CONTROL_ defines - thus not changing the license of common.h yet. codec_tags.c contained once large tables generated from MPlayer's codecs.conf, but all of these tables were removed. From demux_playlist.c I'm removing a code fragment from someone who was not asked; this probably could be done later (see commit 15dccc37). misc.c is a bit complicated to reason about (it was split off mplayer.c and thus contains random functions out of this file), but actually all functions have been added post-MPlayer. Except get_relative_time(), which was written by uau, but looks similar to 3 different versions of something similar in each of the Unix/win32/OSX timer source files. I'm not sure what that means in regards to copyright, so I've just moved it into another still-GPL source file for now. screenshot.c once had some minor parts of MPlayer's vf_screenshot.c, but they're all gone.
* mpv_talloc.h: rename from talloc.hDmitrij D. Czarkoff2016-01-111-1/+1
| | | | This change helps avoiding conflict with talloc.h from libtalloc.
* 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