summaryrefslogtreecommitdiffstats
path: root/player/sub.c
Commit message (Collapse)AuthorAgeFilesLines
* player: don't crash when using sub_seek without subtitleswm42014-11-231-2/+0
| | | | | | Recent regression. It turns out the assertion was completely unneeded. Fixes #1285.
* sub: workaround braindead libass APIwm42014-11-151-7/+14
| | | | | | | | | | | | | | | | libass won't use embedded fonts, unless ass_set_fonts() (called by mp_ass_configure_fonts()) is called. However, we call this function when the ASS_Renderer is initialized, which is long before the .ass file is actually loaded. (I'm not sure why it tries to keep 1 ASS_Renderer, but it always did this.) Fix by calling mp_ass_configure_fonts() after loading them. This also means this function will be called multiple times - hopefully this is harmless (it will reinit fontconfig every time, though). While we're at it, also initialize the ASS_Renderer lazily. Fixes #1244.
* sub: remove osd_get_sub()wm42014-11-011-4/+4
| | | | | Trades one strange thing against another, but seems slightly less strange.
* sub: be more flexible about changes to how subtitles are renderedwm42014-10-311-20/+32
| | | | | | | | | For example, if --force-window is used, and video is switched off during playback, then you need to redecide the rendering method to get subs displayed correctly. Do this by moving the state setup code into a function, and call it on every frame.
* player: move some libass setup code to sub.cwm42014-10-031-0/+94
| | | | | | | | | | | | | | | Also recreate ASS_Library on every file played. This means we can move the code out of main.c as well. Recreating the ASS_Library object has no disadvantages, because it literally stores only the message callback, the (per-file) font attachment as byte arrays, and the set of style overrides. Hopefully this thing can be removed from the libass API entirely at some point. The only reason why the player core creates the ASS_Renderer, instead of the subtitle renderer, is because we want to cache the loaded fonts across ordered chapter transitions, so this probably still has to stay around for now.
* player: remove central uninit_player() function and flags messwm42014-10-031-24/+27
| | | | | | | | | | | | | | Each subsystem (or similar thing) had an INITIALIZED_ flag assigned. The main use of this was that you could pass a bitmask of these flags to uninit_player(). Except in some situations where you wanted to uninitialize nearly everything, this wasn't really useful. Moreover, it was quite annoying that subsystems had most of the code in a specific file, but the uninit code in loadfile.c (because that's where uninit_player() was implemented). Simplify all this. Remove the flags; e.g. instead of testing for the INITIALIZED_AO flag, test whether mpctx->ao is set. Move uninit code to separate functions, e.g. uninit_audio_out().
* sub: approximate subtitle display in no-video modewm42014-09-251-0/+3
| | | | | | | | | | | | | | | | | | | | | | This makes subtitle display somewhat work if no video is displayed, but a VO window exists (--force-window or cover art display). The main problem with normal subtitle display is that it's locked to video: it uses the video PTS as reference, and the subtitles advance only if a new video frame is displayed. In audio-only mode on the other hand, no video frame is ever displayed (or only 1 in the cover art case). You would need a workaround to adjust the subtitle PTS, and you would have to decide with what frequency to update the display. In general, there is no "right" display FPS for subtitles. Some formats (ASS) have animations parameterized by time, and any refresh rate could be used. Sidestep these problems by enabling the text OSD-based subtitle mechanism. This is similar to --no-sub-ass, and updates and renders subtitles with plain OSD. It has some caveats: no bitmap subs, somewhat incorrect timing, no formatting. Timing in particular is a bit strange and depends how often the audio output asks for new data, or other events that happen to wakeup the playloop.
* sub: fix possible deadlock with --no-sub-ass and similarwm42014-09-061-6/+1
| | | | | | | | | | | | | | | This is a deadlock caused by a lock order issue: sub/osd.c locks the OSD first, then the subtitle decoder lock. player/sub.c does the reverse. Fix this by discussing away the requirement for locking (see below), which allows us to drop the broken sub lock. sub_get_text() still acquires and releases the sub decoder lock, but it's not held at the same time as the OSD lock anymore, so it should be fine. Originally, the sub lock was acquired because sub_get_text() returns a pointer to a mutable string. We simply declare that it's ok to call it unlocked, as long as only 1 thread accesses it, which works out fine in this case.
* player: use virtual time for --audio-file with ordered chapterswm42014-08-151-8/+1
| | | | | | | | | Apparently users prefer this behavior. It was used for subtitles too, so move the code to calculate the video offset into a separate function. Seeking also needs to be fixed. Fixes #1018.
* sub: add option to workaround broken mkv fileswm42014-08-141-1/+3
| | | | See additions to options.rst.
* sub: call sub_reset() on seeks onlywm42014-08-141-2/+0
| | | | | | | | | | | | | | | | | sub_reset() was called on cycling subtitle tracks and on seeking. Since we don't want that subtitles disppear on cycling, sd_lavc.c didn't clear its internal subtitle queue on reset, which meant that seeking with PGS subtitles could leave the subtitle on screen (PGS subtitles usually don't have a duration set). Call it only on seeking, so we can also strictly clear the subtitle queue in sd_lavc. (This still can go very wrong if you disable a subtitle, seek, and enable it again - for example, if used with libavformat that uses "SSA" style demuxed ASS subtitle packets. That shouldn't happen with newer libavformat versions, and the user can "correct" it anyway by executing a seek while the subtitle is selected.)
* sub: fix subtitle timing for TSwm42014-08-041-2/+6
| | | | | | | | The subtitle timing logic always used the demuxer's start time as video offset. This made external subtitle files "just work" with file formats like TS, which usually have a non-0 start time. But it was wrong for subtitles muxed with the TS, so adjust the time offset explicitly with external files only.
* sub: don't read packets if video and audio are disabledwm42014-08-041-1/+1
| | | | | | | | | Although disabling both video and audio is surely an obscure corner case, it's allowed, and we don't want the demuxer to skip arbitrary packets. Basically, make the heuristic for checking interleaved files affect external files only.
* player: split seek_reset()wm42014-07-301-0/+6
| | | | | | | | This also reduces some code duplication with other parts of the code. The changfe is mostly cosmetic, although there are also some subtle changes in behavior. At least one change is that the big desync message is now printed after every seek.
* player: fix desync when seeking and switching external trackswm42014-07-291-4/+1
| | | | | | | | | | | | If you for example use --audio-file, disable the external track, seek, and enable the external track again, the playback position of the external file was off, and you would get major A/V desync. This was actually supposed to work, but broke at some time ago (probably commit 2b87415f). It didn't work, because it attempted to seek the stream if it was already selected, which was always true due to reselect_demux_streams() being called before that. Fix by putting the initial selection and the seek together.
* sub: offset subtitle timing to video start PTSwm42014-07-221-1/+2
| | | | | | | | | | | | This allows using external subtitle files with e.g. transport stream files that don't start at time 0. Note that if the .ts file has timestamp resets, everything goes south. But I guess this was already the case before, unless there are external subtitle files that also include timestamp resets, which is unlikely. (On the other hand, you could for example expect that it works with embedded DVB subtitles, that were somehow captured from the same stream and use the same timestamps.)
* dvd, bluray, cdda: add demux_disc containing all related hackswm42014-07-051-41/+0
| | | | | | | | | | | | DVD and Bluray (and to some extent cdda) require awful hacks all over the codebase to make them work. The main reason is that they act like container, but are entirely implemented on the stream layer. The raw mpeg data resulting from these streams must be "extended" with the container-like metadata transported via STREAM_CTRLs. The result were hacks all over demux.c and some higher-level parts. Add a "disc" pseudo-demuxer, and move all these hacks and special-cases to it.
* sub: fix undefined behavior with dvd://wm42014-06-281-1/+1
| | | | | | The string could get reallocated. CC: @mpv-player/stable
* video: handle colorspace and aspect overrides separatelywm42014-05-021-1/+2
| | | | | Now the video filter code handles these explicitly, which should increase robustness (or at least find bugs earlier).
* 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.
* sub: uglify sub decoder with lockingwm42014-01-171-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | The plan is to make the whole OSD thread-safe, and we start with this. We just put locks on all entry points (fortunately, dec_sub.c and all sd_*.c decoders are very closed off, and only the entry points in dec_sub.h let you access it). I think this is pretty ugly, but at least it's very simple. There's a special case with sub_get_bitmaps(): this function returns pointers to decoder data (specifically, libass images). There's no way to synchronize this internally, so expose sub_lock/sub_unlock functions. To make things simpler, and especially because the lock is sort-of exposed to the outside world, make the locks recursive. Although the only case where this is actually needed (although trivial) is sub_set_extradata(). One corner case are ASS subtitles: for some reason, we keep a single ASS_Renderer instance for subtitles around (probably to avoid rescanning fonts with ordered chapters), and this ASS_Renderer instance is not synchronized. Also, demux_libass.c loads ASS_Track objects, which are directly passed to sd_ass.c. These things are not synchronized (and would be hard to synchronize), and basically we're out of luck. But I think for now, accesses happen reasonably serialized, so there is no actual problem yet, even if we start to access OSD from other threads.
* Fix subtitle delay inversionMartin Herkt2014-01-061-1/+1
|
* player: add --secondary-sid for displaying a second subtitle streamwm42013-12-241-45/+80
| | | | | | | 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.
* player: add infrastructure to select multiple tracks at oncewm42013-12-241-2/+2
| | | | | Of course this does not allow decoding multiple tracks at once; it just adds some minor infrastructure, which could be used to achieve this.
* player: redo demuxer stream selectionwm42013-12-241-5/+5
| | | | | | | Use struct track to decide what stream to select. Add a "selected" field and use that in some places instead of checking mpctx->current_track.
* sub/osd: mp_msg conversionswm42013-12-211-1/+1
|
* player: replace some overlooked mp_msgswm42013-12-191-5/+3
| | | | | There are still some using IDENTIFY, and some without context in configfiles.c.
* 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 mp_core.h to core.hwm42013-12-171-1/+1
| | | | Get rid of the mp_ prefix.
* Move mpvcore/player/ to player/wm42013-12-171-0/+233