diff options
| author | Tim Redfern <tim@eclectronics.org> | 2013-12-29 12:19:38 +0000 |
|---|---|---|
| committer | Tim Redfern <tim@eclectronics.org> | 2013-12-29 12:19:38 +0000 |
| commit | f7813a5324be39d13ab536c245d15dfc602a7849 (patch) | |
| tree | fad99148b88823d34a5df2f0a25881a002eb291b /ffmpeg/libavcodec/dvbsubdec.c | |
| parent | b7a5a477b8ff4d4e3028b9dfb9a9df0a41463f92 (diff) | |
basic type mechanism working
Diffstat (limited to 'ffmpeg/libavcodec/dvbsubdec.c')
| -rw-r--r-- | ffmpeg/libavcodec/dvbsubdec.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/ffmpeg/libavcodec/dvbsubdec.c b/ffmpeg/libavcodec/dvbsubdec.c index 955925a..8f4e984 100644 --- a/ffmpeg/libavcodec/dvbsubdec.c +++ b/ffmpeg/libavcodec/dvbsubdec.c @@ -34,8 +34,6 @@ #define cm (ff_cropTbl + MAX_NEG_CROP) #ifdef DEBUG -#undef fprintf -#undef perror #if 0 static void png_save(const char *filename, uint8_t *bitmap, int w, int h, uint32_t *rgba_palette) @@ -933,7 +931,7 @@ static void dvbsub_parse_object_segment(AVCodecContext *avctx, } -static void dvbsub_parse_clut_segment(AVCodecContext *avctx, +static int dvbsub_parse_clut_segment(AVCodecContext *avctx, const uint8_t *buf, int buf_size) { DVBSubContext *ctx = avctx->priv_data; @@ -986,7 +984,7 @@ static void dvbsub_parse_clut_segment(AVCodecContext *avctx, if (depth == 0) { av_log(avctx, AV_LOG_ERROR, "Invalid clut depth 0x%x!\n", *buf); - return; + return 0; } full_range = (*buf++) & 1; @@ -1012,15 +1010,21 @@ static void dvbsub_parse_clut_segment(AVCodecContext *avctx, YUV_TO_RGB2_CCIR(r, g, b, y); av_dlog(avctx, "clut %d := (%d,%d,%d,%d)\n", entry_id, r, g, b, alpha); + if (!!(depth & 0x80) + !!(depth & 0x40) + !!(depth & 0x20) > 1) { + av_dlog(avctx, "More than one bit level marked: %x\n", depth); + if (avctx->strict_std_compliance > FF_COMPLIANCE_NORMAL) + return AVERROR_INVALIDDATA; + } if (depth & 0x80) clut->clut4[entry_id] = RGBA(r,g,b,255 - alpha); - if (depth & 0x40) + else if (depth & 0x40) clut->clut16[entry_id] = RGBA(r,g,b,255 - alpha); - if (depth & 0x20) + else if (depth & 0x20) clut->clut256[entry_id] = RGBA(r,g,b,255 - alpha); } } + return 0; } @@ -1353,8 +1357,8 @@ static void dvbsub_parse_display_definition_segment(AVCodecContext *avctx, if (info_byte & 1<<3) { // display_window_flag display_def->x = bytestream_get_be16(&buf); - display_def->y = bytestream_get_be16(&buf); display_def->width = bytestream_get_be16(&buf) - display_def->x + 1; + display_def->y = bytestream_get_be16(&buf); display_def->height = bytestream_get_be16(&buf) - display_def->y + 1; } } @@ -1456,6 +1460,7 @@ static int dvbsub_decode(AVCodecContext *avctx, int page_id; int segment_length; int i; + int ret; int got_segment = 0; av_dlog(avctx, "DVB sub packet:\n"); @@ -1502,7 +1507,8 @@ static int dvbsub_decode(AVCodecContext *avctx, got_segment |= 2; break; case DVBSUB_CLUT_SEGMENT: - dvbsub_parse_clut_segment(avctx, p, segment_length); + ret = dvbsub_parse_clut_segment(avctx, p, segment_length); + if (ret < 0) return ret; got_segment |= 4; break; case DVBSUB_OBJECT_SEGMENT: @@ -1536,11 +1542,11 @@ static int dvbsub_decode(AVCodecContext *avctx, AVCodec ff_dvbsub_decoder = { .name = "dvbsub", + .long_name = NULL_IF_CONFIG_SMALL("DVB subtitles"), .type = AVMEDIA_TYPE_SUBTITLE, .id = AV_CODEC_ID_DVB_SUBTITLE, .priv_data_size = sizeof(DVBSubContext), .init = dvbsub_init_decoder, .close = dvbsub_close_decoder, .decode = dvbsub_decode, - .long_name = NULL_IF_CONFIG_SMALL("DVB subtitles"), }; |
