Mercurial > libavcodec.hg
comparison dvbsubdec.c @ 12164:59ba77fe9922 libavcodec
Pass the composition and ancillary ID for DVB subtitles via extradata instead
of sub_id, this allows detecting when that information is not available and
just decode everything.
In addition extradata is required for many codecs and thus in contrast to
sub_id generally already passed on by any programs using libav*.
Also ask for a sample if we encounter a stream with multiple/changing IDs.
author | reimar |
---|---|
date | Wed, 14 Jul 2010 17:28:40 +0000 |
parents | 0f987eea1349 |
children |
comparison
equal
deleted
inserted
replaced
12163:9cfc564bc3e6 | 12164:59ba77fe9922 |
---|---|
356 static av_cold int dvbsub_init_decoder(AVCodecContext *avctx) | 356 static av_cold int dvbsub_init_decoder(AVCodecContext *avctx) |
357 { | 357 { |
358 int i, r, g, b, a = 0; | 358 int i, r, g, b, a = 0; |
359 DVBSubContext *ctx = avctx->priv_data; | 359 DVBSubContext *ctx = avctx->priv_data; |
360 | 360 |
361 ctx->composition_id = avctx->sub_id & 0xffff; | 361 if (!avctx->extradata || avctx->extradata_size != 4) { |
362 ctx->ancillary_id = avctx->sub_id >> 16; | 362 av_log(avctx, AV_LOG_WARNING, "Invalid extradata, subtitle streams may be combined!\n"); |
363 ctx->composition_id = -1; | |
364 ctx->ancillary_id = -1; | |
365 } else { | |
366 ctx->composition_id = AV_RB16(avctx->extradata); | |
367 ctx->ancillary_id = AV_RB16(avctx->extradata + 2); | |
368 } | |
363 | 369 |
364 default_clut.id = -1; | 370 default_clut.id = -1; |
365 default_clut.next = NULL; | 371 default_clut.next = NULL; |
366 | 372 |
367 default_clut.clut4[0] = RGBA( 0, 0, 0, 0); | 373 default_clut.clut4[0] = RGBA( 0, 0, 0, 0); |
1432 page_id = AV_RB16(p); | 1438 page_id = AV_RB16(p); |
1433 p += 2; | 1439 p += 2; |
1434 segment_length = AV_RB16(p); | 1440 segment_length = AV_RB16(p); |
1435 p += 2; | 1441 p += 2; |
1436 | 1442 |
1437 if (page_id == ctx->composition_id || page_id == ctx->ancillary_id) { | 1443 if (page_id == ctx->composition_id || page_id == ctx->ancillary_id || |
1444 ctx->composition_id == -1 || ctx->ancillary_id == -1) { | |
1438 switch (segment_type) { | 1445 switch (segment_type) { |
1439 case DVBSUB_PAGE_SEGMENT: | 1446 case DVBSUB_PAGE_SEGMENT: |
1440 dvbsub_parse_page_segment(avctx, p, segment_length); | 1447 dvbsub_parse_page_segment(avctx, p, segment_length); |
1441 break; | 1448 break; |
1442 case DVBSUB_REGION_SEGMENT: | 1449 case DVBSUB_REGION_SEGMENT: |