| @@ -94,14 +94,14 @@ static inline int get_vlc_symbol(GetBitContext *gb, VlcState *const state, · 93 unmodified lines |
| 94 | 94 | return ret; |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | | −static int is_input_end(FFV1Context *s) |
| 97 | +static int is_input_end(FFV1Context *s, GetBitContext *gb) |
| 98 | 98 | { |
| 99 | 99 | if (s->ac != AC_GOLOMB_RICE) { |
| 100 | 100 | RangeCoder *const c = &s->c; |
| 101 | 101 | if (c->overread > MAX_OVERREAD) |
| 102 | 102 | return AVERROR_INVALIDDATA; |
| 103 | 103 | } else { |
| 104 | | − if (get_bits_left(&s->gb) < 1) |
| 104 | + if (get_bits_left(gb) < 1) |
| 105 | 105 | return AVERROR_INVALIDDATA; |
| 106 | 106 | } |
| 107 | 107 | return 0; |
| @@ -118,6 +118,7 @@ static int is_input_end(FFV1Context *s) · 10 unmodified lines |
| 118 | 118 | #include "ffv1dec_template.c" |
| 119 | 119 | |
| 120 | 120 | static int decode_plane(FFV1Context *s, FFV1SliceContext *sc, |
| 121 | + GetBitContext *gb, |
| 121 | 122 | uint8_t *src, int w, int h, int stride, int plane_index, |
| 122 | 123 | int pixel_stride) |
| 123 | 124 | { |
| @@ -140,13 +141,13 @@ static int decode_plane(FFV1Context *s, FFV1SliceContext *sc, · 16 unmodified lines |
| 140 | 141 | sample[0][w] = sample[0][w - 1]; |
| 141 | 142 | |
| 142 | 143 | if (s->avctx->bits_per_raw_sample <= 8) { |
| 143 | | − int ret = decode_line(s, sc, w, sample, plane_index, 8); |
| 144 | + int ret = decode_line(s, sc, gb, w, sample, plane_index, 8); |
| 144 | 145 | if (ret < 0) |
| 145 | 146 | return ret; |
| 146 | 147 | for (x = 0; x < w; x++) |
| 147 | 148 | src[x*pixel_stride + stride * y] = sample[1][x]; |
| 148 | 149 | } else { |
| 149 | | − int ret = decode_line(s, sc, w, sample, plane_index, s->avctx->bits_per_raw_sample); |
| 150 | + int ret = decode_line(s, sc, gb, w, sample, plane_index, s->avctx->bits_per_raw_sample); |
| 150 | 151 | if (ret < 0) |
| 151 | 152 | return ret; |
| 152 | 153 | if (s->packed_at_lsb) { |
| @@ -262,6 +263,7 @@ static int decode_slice(AVCodecContext *c, void *arg) · 109 unmodified lines |
| 262 | 263 | AVFrame * const p = f->picture.f; |
| 263 | 264 | const int si = (FFV1Context**)arg - f->slice_context; |
| 264 | 265 | FFV1SliceContext *sc = &f->slices[si]; |
| 266 | + GetBitContext gb; |
| 265 | 267 | |
| 266 | 268 | if (f->fsrc && !(p->flags & AV_FRAME_FLAG_KEY) && f->last_picture.f) |
| 267 | 269 | ff_progress_frame_await(&f->last_picture, si); |
| @@ -322,7 +324,7 @@ static int decode_slice(AVCodecContext *c, void *arg) · 54 unmodified lines |
| 322 | 324 | if (f->version == 3 && f->micro_version > 1 || f->version > 3) |
| 323 | 325 | get_rac(&fs->c, (uint8_t[]) { 129 }); |
| 324 | 326 | fs->ac_byte_count = f->version > 2 || (!x && !y) ? fs->c.bytestream - fs->c.bytestream_start - 1 : 0; |
| 325 | | − init_get_bits(&fs->gb, |
| 327 | + init_get_bits(&gb, |
| 326 | 328 | fs->c.bytestream_start + fs->ac_byte_count, |
| 327 | 329 | (fs->c.bytestream_end - fs->c.bytestream_start - fs->ac_byte_count) * 8); |
| 328 | 330 | } |
| @@ -333,29 +335,29 @@ static int decode_slice(AVCodecContext *c, void *arg) · 4 unmodified lines |
| 333 | 335 | const int chroma_height = AV_CEIL_RSHIFT(height, f->chroma_v_shift); |
| 334 | 336 | const int cx = x >> f->chroma_h_shift; |
| 335 | 337 | const int cy = y >> f->chroma_v_shift; |
| 336 | | − decode_plane(fs, sc, p->data[0] + ps*x + y*p->linesize[0], width, height, p->linesize[0], 0, 1); |
| 338 | + decode_plane(fs, sc, &gb, p->data[0] + ps*x + y*p->linesize[0], width, height, p->linesize[0], 0, 1); |
| 337 | 339 | |
| 338 | 340 | if (f->chroma_planes) { |
| 339 | | − decode_plane(fs, sc, p->data[1] + ps*cx+cy*p->linesize[1], chroma_width, chroma_height, p->linesize[1], 1, 1); |
| 340 | | − decode_plane(fs, sc, p->data[2] + ps*cx+cy*p->linesize[2], chroma_width, chroma_height, p->linesize[2], 1, 1); |
| 341 | + decode_plane(fs, sc, &gb, p->data[1] + ps*cx+cy*p->linesize[1], chroma_width, chroma_height, p->linesize[1], 1, 1); |
| 342 | + decode_plane(fs, sc, &gb, p->data[2] + ps*cx+cy*p->linesize[2], chroma_width, chroma_height, p->linesize[2], 1, 1); |
| 341 | 343 | } |
| 342 | 344 | if (fs->transparency) |
| 343 | | − decode_plane(fs, sc, p->data[3] + ps*x + y*p->linesize[3], width, height, p->linesize[3], (f->version >= 4 && !f->chroma_planes) ? 1 : 2, 1); |
| 345 | + decode_plane(fs, sc, &gb, p->data[3] + ps*x + y*p->linesize[3], width, height, p->linesize[3], (f->version >= 4 && !f->chroma_planes) ? 1 : 2, 1); |
| 344 | 346 | } else if (f->colorspace == 0) { |
| 345 | | − decode_plane(fs, sc, p->data[0] + ps*x + y*p->linesize[0] , width, height, p->linesize[0], 0, 2); |
| 346 | | − decode_plane(fs, sc, p->data[0] + ps*x + y*p->linesize[0] + 1, width, height, p->linesize[0], 1, 2); |
| 347 | + decode_plane(fs, sc, &gb, p->data[0] + ps*x + y*p->linesize[0] , width, height, p->linesize[0], 0, 2); |
| 348 | + decode_plane(fs, sc, &gb, p->data[0] + ps*x + y*p->linesize[0] + 1, width, height, p->linesize[0], 1, 2); |
| 347 | 349 | } else if (f->use32bit) { |
| 348 | 350 | uint8_t *planes[4] = { p->data[0] + ps * x + y * p->linesize[0], |
| 349 | 351 | p->data[1] + ps * x + y * p->linesize[1], |
| 350 | 352 | p->data[2] + ps * x + y * p->linesize[2], |
| 351 | 353 | p->data[3] + ps * x + y * p->linesize[3] }; |
| 352 | | − decode_rgb_frame32(fs, sc, planes, width, height, p->linesize); |
| 354 | + decode_rgb_frame32(fs, sc, &gb, planes, width, height, p->linesize); |
| 353 | 355 | } else { |
| 354 | 356 | uint8_t *planes[4] = { p->data[0] + ps * x + y * p->linesize[0], |
| 355 | 357 | p->data[1] + ps * x + y * p->linesize[1], |
| 356 | 358 | p->data[2] + ps * x + y * p->linesize[2], |
| 357 | 359 | p->data[3] + ps * x + y * p->linesize[3] }; |
| 358 | | − decode_rgb_frame(fs, sc, planes, width, height, p->linesize); |
| 360 | + decode_rgb_frame(fs, sc, &gb, planes, width, height, p->linesize); |
| 359 | 361 | } |
| 360 | 362 | if (fs->ac != AC_GOLOMB_RICE && f->version > 2) { |
| 361 | 363 | int v; |