mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-01-24 00:02:53 +00:00
avcodec/dvbsubdec: Allow selecting the substream, or all substreams
Fixes Ticket 2161 Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
parent
f6518e51b8
commit
3f87a17063
@ -209,6 +209,8 @@ Never compute CLUT
|
||||
@item 1
|
||||
Always compute CLUT and override the one provided in the stream.
|
||||
@end table
|
||||
@item dvb_substream
|
||||
Selects the dvb substream, or all substreams if -1 which is default.
|
||||
|
||||
@end table
|
||||
|
||||
|
@ -238,6 +238,7 @@ typedef struct DVBSubContext {
|
||||
int compute_edt; /**< if 1 end display time calculated using pts
|
||||
if 0 (Default) calculated using time out */
|
||||
int compute_clut;
|
||||
int substream;
|
||||
int64_t prev_start;
|
||||
DVBSubRegion *region_list;
|
||||
DVBSubCLUT *clut_list;
|
||||
@ -368,17 +369,22 @@ static av_cold int dvbsub_init_decoder(AVCodecContext *avctx)
|
||||
int i, r, g, b, a = 0;
|
||||
DVBSubContext *ctx = avctx->priv_data;
|
||||
|
||||
if (!avctx->extradata || (avctx->extradata_size < 4) || ((avctx->extradata_size % 5 != 0) && (avctx->extradata_size != 4))) {
|
||||
if (ctx->substream < 0) {
|
||||
ctx->composition_id = -1;
|
||||
ctx->ancillary_id = -1;
|
||||
} else if (!avctx->extradata || (avctx->extradata_size < 4) || ((avctx->extradata_size % 5 != 0) && (avctx->extradata_size != 4))) {
|
||||
av_log(avctx, AV_LOG_WARNING, "Invalid DVB subtitles stream extradata!\n");
|
||||
ctx->composition_id = -1;
|
||||
ctx->ancillary_id = -1;
|
||||
} else {
|
||||
if (avctx->extradata_size > 5) {
|
||||
av_log(avctx, AV_LOG_WARNING, "Decoding first DVB subtitles sub-stream\n");
|
||||
if (avctx->extradata_size > 5*ctx->substream + 2) {
|
||||
ctx->composition_id = AV_RB16(avctx->extradata + 5*ctx->substream);
|
||||
ctx->ancillary_id = AV_RB16(avctx->extradata + 5*ctx->substream + 2);
|
||||
} else {
|
||||
av_log(avctx, AV_LOG_WARNING, "Selected DVB subtitles sub-stream %d is not available\n", ctx->substream);
|
||||
ctx->composition_id = AV_RB16(avctx->extradata);
|
||||
ctx->ancillary_id = AV_RB16(avctx->extradata + 2);
|
||||
}
|
||||
|
||||
ctx->composition_id = AV_RB16(avctx->extradata);
|
||||
ctx->ancillary_id = AV_RB16(avctx->extradata + 2);
|
||||
}
|
||||
|
||||
ctx->version = -1;
|
||||
@ -1715,6 +1721,7 @@ end:
|
||||
static const AVOption options[] = {
|
||||
{"compute_edt", "compute end of time using pts or timeout", offsetof(DVBSubContext, compute_edt), FF_OPT_TYPE_INT, {.i64 = 0}, 0, 1, DS},
|
||||
{"compute_clut", "compute clut when not available(-1) or always(1) or never(0)", offsetof(DVBSubContext, compute_clut), FF_OPT_TYPE_INT, {.i64 = -1}, -1, 1, DS},
|
||||
{"dvb_substream", "", offsetof(DVBSubContext, substream), FF_OPT_TYPE_INT, {.i64 = -1}, -1, 63, DS},
|
||||
{NULL}
|
||||
};
|
||||
static const AVClass dvbsubdec_class = {
|
||||
|
Loading…
Reference in New Issue
Block a user