X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fffv1dec.c;h=7430bea960bc8ac16ccfb3ac65b364f724f32f7f;hb=bc70684e74a185d7b80c8b80bdedda659cb581b8;hp=2ffd3ef991bb170e590eaa8ce0c8f3016c56c500;hpb=665e5b0fba41a8bae2269d9ce8929a24002e5907;p=ffmpeg diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c index 2ffd3ef991b..7430bea960b 100644 --- a/libavcodec/ffv1dec.c +++ b/libavcodec/ffv1dec.c @@ -786,7 +786,7 @@ static int read_header(FFV1Context *f) if (f->version == 2) { int idx = get_symbol(c, state, 0); - if (idx > (unsigned)f->quant_table_count) { + if (idx >= (unsigned)f->quant_table_count) { av_log(f->avctx, AV_LOG_ERROR, "quant_table_index out of range\n"); return AVERROR_INVALIDDATA; @@ -888,8 +888,10 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac int trailer = 3 + 5*!!f->ec; int v; - if (i || f->version > 2) v = AV_RB24(buf_p-trailer) + trailer; - else v = buf_p - c->bytestream_start; + if (i || f->version > 2) { + if (trailer > buf_p - buf) v = INT_MAX; + else v = AV_RB24(buf_p-trailer) + trailer; + } else v = buf_p - c->bytestream_start; if (buf_p - c->bytestream_start < v) { av_log(avctx, AV_LOG_ERROR, "Slice pointer chain broken\n"); ff_thread_report_progress(&f->picture, INT_MAX, 0); @@ -950,8 +952,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac (fs->slice_y >> sv) + ((fs->slice_x >> sh) << pixshift); } - if (desc->flags & AV_PIX_FMT_FLAG_PAL || - desc->flags & FF_PSEUDOPAL) { + if (desc->flags & AV_PIX_FMT_FLAG_PAL) { dst[1] = p->data[1]; src[1] = f->last_picture.f->data[1]; } @@ -977,34 +978,6 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac return buf_size; } -#if HAVE_THREADS -static int init_thread_copy(AVCodecContext *avctx) -{ - FFV1Context *f = avctx->priv_data; - int i, ret; - - f->picture.f = NULL; - f->last_picture.f = NULL; - f->sample_buffer = NULL; - f->max_slice_count = 0; - f->slice_count = 0; - - for (i = 0; i < f->quant_table_count; i++) { - av_assert0(f->version > 1); - f->initial_states[i] = av_memdup(f->initial_states[i], - f->context_count[i] * sizeof(*f->initial_states[i])); - } - - f->picture.f = av_frame_alloc(); - f->last_picture.f = av_frame_alloc(); - - if ((ret = ff_ffv1_init_slice_contexts(f)) < 0) - return ret; - - return 0; -} -#endif - static void copy_fields(FFV1Context *fsdst, FFV1Context *fssrc, FFV1Context *fsrc) { fsdst->version = fsrc->version; @@ -1079,7 +1052,7 @@ static int update_thread_context(AVCodecContext *dst, const AVCodecContext *src) } #endif -AVCodec ff_ffv1_decoder = { +const AVCodec ff_ffv1_decoder = { .name = "ffv1", .long_name = NULL_IF_CONFIG_SMALL("FFmpeg video codec #1"), .type = AVMEDIA_TYPE_VIDEO, @@ -1088,7 +1061,6 @@ AVCodec ff_ffv1_decoder = { .init = decode_init, .close = ff_ffv1_close, .decode = decode_frame, - .init_thread_copy = ONLY_IF_THREADS_ENABLED(init_thread_copy), .update_thread_context = ONLY_IF_THREADS_ENABLED(update_thread_context), .capabilities = AV_CODEC_CAP_DR1 /*| AV_CODEC_CAP_DRAW_HORIZ_BAND*/ | AV_CODEC_CAP_FRAME_THREADS | AV_CODEC_CAP_SLICE_THREADS,