mirror of
https://github.com/mpv-player/mpv.git
synced 2025-12-28 05:33:14 +00:00
sub: refactor
Make the sub decoder stuff independent from sh_sub (except for initialization of course). Sub decoders now access a struct sd only, instead of getting access to sh_sub. The glue code in dec_sub.c is similarily independent from osd. Some simplifications are made. For example, the switch_id stuff is unneeded: the frontend code just has to make sure to call osd_changed() any time subtitles are switched. This is also preparation for introducing subtitle converters. It's much cleaner to completely separate demuxer header/renderer glue/decoders for this purpose, especially since sub converters might completely change how demuxer headers have to be interpreted. Also pass data as demux_packets. Currently, this doesn't help much, but libavcodec converters might need scary stuff like packet side data, so it's perhaps better to go with passing packets.
This commit is contained in:
40
sub/sd.h
40
sub/sd.h
@@ -2,20 +2,42 @@
|
||||
#define MPLAYER_SD_H
|
||||
|
||||
#include "dec_sub.h"
|
||||
#include "demux/demux_packet.h"
|
||||
|
||||
struct sd {
|
||||
struct MPOpts *opts;
|
||||
|
||||
const struct sd_functions *driver;
|
||||
void *priv;
|
||||
|
||||
const char *codec;
|
||||
|
||||
// Extra header data passed from demuxer
|
||||
char *extradata;
|
||||
int extradata_len;
|
||||
|
||||
// Video resolution used for subtitle decoding. Doesn't necessarily match
|
||||
// the resolution of the VO, nor does it have to be the OSD resolution.
|
||||
int sub_video_w, sub_video_h;
|
||||
|
||||
// Make sd_ass use an existing track
|
||||
struct ass_track *ass_track;
|
||||
|
||||
// Shared renderer for ASS - done to avoid reloading embedded fonts.
|
||||
struct ass_library *ass_library;
|
||||
struct ass_renderer *ass_renderer;
|
||||
};
|
||||
|
||||
struct sd_functions {
|
||||
bool accept_packets_in_advance;
|
||||
bool (*supports_format)(const char *format);
|
||||
int (*init)(struct sh_sub *sh, struct osd_state *osd);
|
||||
void (*decode)(struct sh_sub *sh, struct osd_state *osd,
|
||||
void *data, int data_len, double pts, double duration);
|
||||
void (*get_bitmaps)(struct sh_sub *sh, struct osd_state *osd,
|
||||
struct mp_osd_res dim, double pts,
|
||||
int (*init)(struct sd *sd);
|
||||
void (*decode)(struct sd *sd, struct demux_packet *packet);
|
||||
void (*get_bitmaps)(struct sd *sd, struct mp_osd_res dim, double pts,
|
||||
struct sub_bitmaps *res);
|
||||
char *(*get_text)(struct sh_sub *sh, struct osd_state *osd, double pts);
|
||||
void (*reset)(struct sh_sub *sh, struct osd_state *osd);
|
||||
void (*switch_off)(struct sh_sub *sh, struct osd_state *osd);
|
||||
void (*uninit)(struct sh_sub *sh);
|
||||
char *(*get_text)(struct sd *sd, double pts);
|
||||
void (*reset)(struct sd *sd);
|
||||
void (*uninit)(struct sd *sd);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user