X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fffv1dec_template.c;h=1b7f6c4bf560432228d75e14b09421979da226dc;hb=6f9d7c556d5f466c604fe76723950b834c5d1af4;hp=f8a42a6d44cac90be20ac8713f56d4345545b863;hpb=41cd5af3250ef976f0a48adeb6dbccc9b2683e58;p=ffmpeg diff --git a/libavcodec/ffv1dec_template.c b/libavcodec/ffv1dec_template.c index f8a42a6d44c..1b7f6c4bf56 100644 --- a/libavcodec/ffv1dec_template.c +++ b/libavcodec/ffv1dec_template.c @@ -50,6 +50,11 @@ static av_always_inline int RENAME(decode_line)(FFV1Context *s, int w, for (x = 0; x < w; x++) { int diff, context, sign; + if (!(x & 1023)) { + if (is_input_end(s)) + return AVERROR_INVALIDDATA; + } + context = RENAME(get_context)(p, sample[1] + x, sample[0] + x, sample[1] + x); if (context < 0) { context = -context; @@ -81,6 +86,11 @@ static av_always_inline int RENAME(decode_line)(FFV1Context *s, int w, run_mode = 2; } } + while (run_count > 1 && w-x > 1) { + sample[1][x] = RENAME(predict)(sample[1] + x, sample[0] + x); + x++; + run_count--; + } run_count--; if (run_count < 0) { run_mode = 0; @@ -107,7 +117,7 @@ static av_always_inline int RENAME(decode_line)(FFV1Context *s, int w, return 0; } -static void RENAME(decode_rgb_frame)(FFV1Context *s, uint8_t *src[4], int w, int h, int stride[4]) +static int RENAME(decode_rgb_frame)(FFV1Context *s, uint8_t *src[4], int w, int h, int stride[4]) { int x, y, p; TYPE *sample[4][2]; @@ -127,6 +137,7 @@ static void RENAME(decode_rgb_frame)(FFV1Context *s, uint8_t *src[4], int w, int for (y = 0; y < h; y++) { for (p = 0; p < 3 + transparency; p++) { + int ret; TYPE *temp = sample[p][0]; // FIXME: try a normal buffer sample[p][0] = sample[p][1]; @@ -135,9 +146,11 @@ static void RENAME(decode_rgb_frame)(FFV1Context *s, uint8_t *src[4], int w, int sample[p][1][-1]= sample[p][0][0 ]; sample[p][0][ w]= sample[p][0][w-1]; if (lbd && s->slice_coding_mode == 0) - RENAME(decode_line)(s, w, sample[p], (p + 1)/2, 9); + ret = RENAME(decode_line)(s, w, sample[p], (p + 1)/2, 9); else - RENAME(decode_line)(s, w, sample[p], (p + 1)/2, bits + (s->slice_coding_mode != 1)); + ret = RENAME(decode_line)(s, w, sample[p], (p + 1)/2, bits + (s->slice_coding_mode != 1)); + if (ret < 0) + return ret; } for (x = 0; x < w; x++) { int g = sample[0][1][x]; @@ -168,4 +181,5 @@ static void RENAME(decode_rgb_frame)(FFV1Context *s, uint8_t *src[4], int w, int } } } + return 0; }