2012-08-25 16:47:50 +02:00
|
|
|
#ifndef MPLAYER_DEC_SUB_H
|
|
|
|
#define MPLAYER_DEC_SUB_H
|
|
|
|
|
2012-09-28 21:19:36 +02:00
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
2013-11-24 12:58:06 +01:00
|
|
|
#include "osd.h"
|
2012-10-04 17:16:40 +02:00
|
|
|
|
2013-11-23 21:37:15 +01:00
|
|
|
struct sh_stream;
|
2013-12-21 19:06:37 +01:00
|
|
|
struct mpv_global;
|
2013-06-01 19:44:12 +02:00
|
|
|
struct demux_packet;
|
2017-02-07 17:05:17 +01:00
|
|
|
struct mp_recorder_sink;
|
2012-10-04 17:16:32 +02:00
|
|
|
|
2013-06-01 19:44:12 +02:00
|
|
|
struct dec_sub;
|
|
|
|
struct sd;
|
|
|
|
|
2013-06-29 01:34:11 +02:00
|
|
|
enum sd_ctrl {
|
|
|
|
SD_CTRL_SUB_STEP,
|
2013-07-15 01:48:25 +02:00
|
|
|
SD_CTRL_SET_VIDEO_PARAMS,
|
2015-11-17 01:54:02 +01:00
|
|
|
SD_CTRL_SET_TOP,
|
2015-12-27 01:25:32 +01:00
|
|
|
SD_CTRL_SET_VIDEO_DEF_FPS,
|
2016-09-13 03:15:14 +02:00
|
|
|
SD_CTRL_UPDATE_SPEED,
|
2013-06-29 01:34:11 +02:00
|
|
|
};
|
|
|
|
|
2016-03-03 18:48:56 +01:00
|
|
|
struct attachment_list {
|
|
|
|
struct demux_attachment *entries;
|
|
|
|
int num_entries;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct dec_sub *sub_create(struct mpv_global *global, struct sh_stream *sh,
|
|
|
|
struct attachment_list *attachments);
|
2013-06-01 19:44:12 +02:00
|
|
|
void sub_destroy(struct dec_sub *sub);
|
sub: uglify sub decoder with locking
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.
2014-01-17 23:13:09 +01:00
|
|
|
void sub_lock(struct dec_sub *sub);
|
|
|
|
void sub_unlock(struct dec_sub *sub);
|
2013-06-01 19:44:12 +02:00
|
|
|
|
sub: make preloading more robust
Subtitles can be preloaded, which means they're fully read and copied
into ASS_Track. This in turn is mainly for the sake of being able to do
subtitle seeking (when it comes down to it, subtitle seeking is the
cause for most trouble here).
Commit a714f8e92 broke preloaded subtitles which have events with
unknown duration, such as some MicroDVD samples. The event list gets
cleared on every seek, so the property of being preloaded obviously gets
lost.
Fix this by moving most of the preloading logic to dec_sub.c. If the
subtitle list gets cleared, they are not considered preloaded anymore,
and the logic for demuxed subtitles is used.
As another minor thing, preloadeding subtitles did neither disable the
demux stream, nor did it discard packets. Thus you could get queue
overflows in theory (harmless, but annoying). Fix this by explicitly
discarding packets in preloaded mode.
In summary, now the only difference between preloaded and normal
demuxing are:
1. a seek is issued, and all packets are read on start
2. during playback, discard the packets instead of feeding them to the
subtitle decoder
This is still petty annoying. It would be nice if maintaining the
subtitle index (and maybe a subtitle packet cache for instant subtitle
presentation when seeking back) could be maintained in the demuxer
instead. Half of all file formats with interleaved subtitles have
this anyway (mp4, mkv muxed with newer mkvmerge).
2016-03-06 14:50:36 +01:00
|
|
|
bool sub_can_preload(struct dec_sub *sub);
|
|
|
|
void sub_preload(struct dec_sub *sub);
|
2015-12-29 01:35:52 +01:00
|
|
|
bool sub_read_packets(struct dec_sub *sub, double video_pts);
|
2016-07-03 18:33:28 +02:00
|
|
|
void sub_get_bitmaps(struct dec_sub *sub, struct mp_osd_res dim, int format,
|
|
|
|
double pts, struct sub_bitmaps *res);
|
2013-06-01 19:44:12 +02:00
|
|
|
char *sub_get_text(struct dec_sub *sub, double pts);
|
|
|
|
void sub_reset(struct dec_sub *sub);
|
2015-12-26 18:35:36 +01:00
|
|
|
void sub_select(struct dec_sub *sub, bool selected);
|
2017-02-07 17:05:17 +01:00
|
|
|
void sub_set_recorder_sink(struct dec_sub *sub, struct mp_recorder_sink *sink);
|
2013-06-01 19:44:12 +02:00
|
|
|
|
2013-06-29 01:34:11 +02:00
|
|
|
int sub_control(struct dec_sub *sub, enum sd_ctrl cmd, void *arg);
|
2012-09-01 19:49:04 +02:00
|
|
|
|
2012-08-25 16:47:50 +02:00
|
|
|
#endif
|