X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fdvdsubdec.c;h=91906b9df43f720d27847a082f2909a705eef2b0;hb=d947464ad41ea634ab19f8d631bfc035e4a902c1;hp=f1ac9e353e361980a613c6fe0352adbcb43ccbb1;hpb=aebc5b2284db1f40a5b3e2e9a2bf406f606436c7;p=ffmpeg diff --git a/libavcodec/dvdsubdec.c b/libavcodec/dvdsubdec.c index f1ac9e353e3..91906b9df43 100644 --- a/libavcodec/dvdsubdec.c +++ b/libavcodec/dvdsubdec.c @@ -27,7 +27,6 @@ #include "libavutil/colorspace.h" #include "libavutil/opt.h" #include "libavutil/imgutils.h" -#include "libavutil/avstring.h" #include "libavutil/bswap.h" typedef struct DVDSubContext @@ -83,10 +82,7 @@ static int decode_run_8bit(GetBitContext *gb, int *color) { int len; int has_run = get_bits1(gb); - if (get_bits1(gb)) - *color = get_bits(gb, 8); - else - *color = get_bits(gb, 2); + *color = get_bits(gb, 2 + 6*get_bits1(gb)); if (has_run) { if (get_bits1(gb)) { len = get_bits(gb, 7); @@ -128,6 +124,8 @@ static int decode_rle(uint8_t *bitmap, int linesize, int w, int h, uint8_t used_ len = decode_run_8bit(&gb, &color); else len = decode_run_2bit(&gb, &color); + if (len != INT_MAX && len > w - x) + return AVERROR_INVALIDDATA; len = FFMIN(len, w - x); memset(d + x, color, len); used_color[color] = 1; @@ -411,15 +409,6 @@ static int decode_dvd_subtitles(DVDSubContext *ctx, AVSubtitle *sub_header, sub_header->rects[0]->type = SUBTITLE_BITMAP; sub_header->rects[0]->linesize[0] = w; sub_header->rects[0]->flags = is_menu ? AV_SUBTITLE_FLAG_FORCED : 0; - -#if FF_API_AVPICTURE -FF_DISABLE_DEPRECATION_WARNINGS - for (i = 0; i < 4; i++) { - sub_header->rects[0]->pict.data[i] = sub_header->rects[0]->data[i]; - sub_header->rects[0]->pict.linesize[i] = sub_header->rects[0]->linesize[i]; - } -FF_ENABLE_DEPRECATION_WARNINGS -#endif } } if (next_cmd_pos < cmd_pos) { @@ -506,15 +495,6 @@ static int find_smallest_bounding_rectangle(DVDSubContext *ctx, AVSubtitle *s) s->rects[0]->x += x1; s->rects[0]->y += y1; -#if FF_API_AVPICTURE -FF_DISABLE_DEPRECATION_WARNINGS - for (i = 0; i < 4; i++) { - s->rects[0]->pict.data[i] = s->rects[0]->data[i]; - s->rects[0]->pict.linesize[i] = s->rects[0]->linesize[i]; - } -FF_ENABLE_DEPRECATION_WARNINGS -#endif - return 1; } @@ -596,6 +576,7 @@ static int dvdsub_decode(AVCodecContext *avctx, } if (is_menu < 0) { + ctx->buf_size = 0; no_subtitle: reset_rects(sub); *data_size = 0; @@ -626,18 +607,6 @@ static int dvdsub_decode(AVCodecContext *avctx, return buf_size; } -static void parse_palette(DVDSubContext *ctx, char *p) -{ - int i; - - ctx->has_palette = 1; - for(i=0;i<16;i++) { - ctx->palette[i] = strtoul(p, &p, 16); - while(*p == ',' || av_isspace(*p)) - p++; - } -} - static int parse_ifo_palette(DVDSubContext *ctx, char *p) { FILE *ifo; @@ -719,7 +688,8 @@ static int dvdsub_parse_extradata(AVCodecContext *avctx) break; if (strncmp("palette:", data, 8) == 0) { - parse_palette(ctx, data + 8); + ctx->has_palette = 1; + ff_dvdsub_parse_palette(ctx->palette, data + 8); } else if (strncmp("size:", data, 5) == 0) { int w, h; if (sscanf(data + 5, "%dx%d", &w, &h) == 2) { @@ -748,8 +718,10 @@ static av_cold int dvdsub_init(AVCodecContext *avctx) if (ctx->ifo_str) parse_ifo_palette(ctx, ctx->ifo_str); - if (ctx->palette_str) - parse_palette(ctx, ctx->palette_str); + if (ctx->palette_str) { + ctx->has_palette = 1; + ff_dvdsub_parse_palette(ctx->palette, ctx->palette_str); + } if (ctx->has_palette) { int i; av_log(avctx, AV_LOG_DEBUG, "palette:");