From 3000df35d31f09f13a7c662e2f96bcd7d0f6ac13 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 1 Jun 2013 19:44:55 +0200 Subject: sub: basic subtitle converters Add a basic infrastructure for subtitle converters. These converters work sort-of like decoders, except that they produce packets instead of subtitle bitmaps. They are put in front of actual decoders. Start with sd_movtext. 4 lines of code are blown up to a 55 lines file, but fortunately this is not going to be that bad for the following converters. --- sub/sd.h | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'sub/sd.h') diff --git a/sub/sd.h b/sub/sd.h index 42f7b8a445..fadfe55edc 100644 --- a/sub/sd.h +++ b/sub/sd.h @@ -26,6 +26,14 @@ struct sd { // Shared renderer for ASS - done to avoid reloading embedded fonts. struct ass_library *ass_library; struct ass_renderer *ass_renderer; + + // Set by sub converter + const char *output_codec; + char *output_extradata; + int output_extradata_len; + + // Internal buffer for sd_conv_* functions + struct sd_conv_buffer *sd_conv_buffer; }; struct sd_functions { @@ -33,11 +41,22 @@ struct sd_functions { bool (*supports_format)(const char *format); int (*init)(struct sd *sd); void (*decode)(struct sd *sd, struct demux_packet *packet); + void (*reset)(struct sd *sd); + void (*uninit)(struct sd *sd); + + // decoder void (*get_bitmaps)(struct sd *sd, struct mp_osd_res dim, double pts, struct sub_bitmaps *res); char *(*get_text)(struct sd *sd, double pts); - void (*reset)(struct sd *sd); - void (*uninit)(struct sd *sd); + + // converter + struct demux_packet *(*get_converted)(struct sd *sd); }; +void sd_conv_add_packet(struct sd *sd, void *data, int data_len, double pts, + double duration); +struct demux_packet *sd_conv_def_get_converted(struct sd *sd); +void sd_conv_def_reset(struct sd *sd); +void sd_conv_def_uninit(struct sd *sd); + #endif -- cgit v1.2.3