From 02ce316ade9ba932ad405383278d6b01c54e5fc4 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 1 Jun 2013 19:44:12 +0200 Subject: 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. --- sub/sd.h | 40 +++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) (limited to 'sub/sd.h') diff --git a/sub/sd.h b/sub/sd.h index 123a9bc45d..42f7b8a445 100644 --- a/sub/sd.h +++ b/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 -- cgit v1.2.3