It is a copy of FFV1Context.quant_tables[quant_table_index].
Unified · Split
| @@ -59,7 +59,6 @@ typedef struct VlcState { · 58 unmodified lines | ||
| 59 | 59 | } VlcState; |
| 60 | 60 | |
| 61 | 61 | typedef struct PlaneContext { |
| 62 | − int16_t quant_table[MAX_CONTEXT_INPUTS][256]; | |
| 63 | 62 | int quant_table_index; |
| 64 | 63 | int context_count; |
| 65 | 64 | uint8_t (*state)[CONTEXT_SIZE]; |
| @@ -29,25 +29,25 @@ static inline int RENAME(predict)(TYPE *src, TYPE *last) · 28 unmodified lines | ||
| 29 | 29 | return mid_pred(L, L + T - LT, T); |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | −static inline int RENAME(get_context)(PlaneContext *p, TYPE *src, | |
| 33 | − TYPE *last, TYPE *last2) | |
| 32 | +static inline int RENAME(get_context)(const int16_t quant_table[MAX_CONTEXT_INPUTS][256], | |
| 33 | + TYPE *src, TYPE *last, TYPE *last2) | |
| 34 | 34 | { |
| 35 | 35 | const int LT = last[-1]; |
| 36 | 36 | const int T = last[0]; |
| 37 | 37 | const int RT = last[1]; |
| 38 | 38 | const int L = src[-1]; |
| 39 | 39 | |
| 40 | − if (p->quant_table[3][127] || p->quant_table[4][127]) { | |
| 40 | + if (quant_table[3][127] || quant_table[4][127]) { | |
| 41 | 41 | const int TT = last2[0]; |
| 42 | 42 | const int LL = src[-2]; |
| 43 | − return p->quant_table[0][(L - LT) & 0xFF] + | |
| 44 | − p->quant_table[1][(LT - T) & 0xFF] + | |
| 45 | − p->quant_table[2][(T - RT) & 0xFF] + | |
| 46 | − p->quant_table[3][(LL - L) & 0xFF] + | |
| 47 | − p->quant_table[4][(TT - T) & 0xFF]; | |
| 43 | + return quant_table[0][(L - LT) & 0xFF] + | |
| 44 | + quant_table[1][(LT - T) & 0xFF] + | |
| 45 | + quant_table[2][(T - RT) & 0xFF] + | |
| 46 | + quant_table[3][(LL - L) & 0xFF] + | |
| 47 | + quant_table[4][(TT - T) & 0xFF]; | |
| 48 | 48 | } else |
| 49 | − return p->quant_table[0][(L - LT) & 0xFF] + | |
| 50 | − p->quant_table[1][(LT - T) & 0xFF] + | |
| 51 | − p->quant_table[2][(T - RT) & 0xFF]; | |
| 49 | + return quant_table[0][(L - LT) & 0xFF] + | |
| 50 | + quant_table[1][(LT - T) & 0xFF] + | |
| 51 | + quant_table[2][(T - RT) & 0xFF]; | |
| 52 | 52 | } |
| 53 | 53 | |
| @@ -117,7 +117,8 @@ static int is_input_end(FFV1Context *s, GetBitContext *gb) · 116 unmodified lines | ||
| 117 | 117 | #define RENAME(name) name ## 32 |
| 118 | 118 | #include "ffv1dec_template.c" |
| 119 | 119 | |
| 120 | −static int decode_plane(FFV1Context *s, FFV1SliceContext *sc, | |
| 120 | +static int decode_plane(FFV1Context *f, | |
| 121 | + FFV1Context *s, FFV1SliceContext *sc, | |
| 121 | 122 | GetBitContext *gb, |
| 122 | 123 | uint8_t *src, int w, int h, int stride, int plane_index, |
| 123 | 124 | int pixel_stride) |
| @@ -141,13 +142,13 @@ static int decode_plane(FFV1Context *s, FFV1SliceContext *sc, · 17 unmodified lines | ||
| 141 | 142 | sample[0][w] = sample[0][w - 1]; |
| 142 | 143 | |
| 143 | 144 | if (s->avctx->bits_per_raw_sample <= 8) { |
| 144 | − int ret = decode_line(s, sc, gb, w, sample, plane_index, 8); | |
| 145 | + int ret = decode_line(f, s, sc, gb, w, sample, plane_index, 8); | |
| 145 | 146 | if (ret < 0) |
| 146 | 147 | return ret; |
| 147 | 148 | for (x = 0; x < w; x++) |
| 148 | 149 | src[x*pixel_stride + stride * y] = sample[1][x]; |
| 149 | 150 | } else { |
| 150 | − int ret = decode_line(s, sc, gb, w, sample, plane_index, s->avctx->bits_per_raw_sample); | |
| 151 | + int ret = decode_line(f, s, sc, gb, w, sample, plane_index, s->avctx->bits_per_raw_sample); | |
| 151 | 152 | if (ret < 0) |
| 152 | 153 | return ret; |
| 153 | 154 | if (s->packed_at_lsb) { |
| @@ -207,7 +208,6 @@ static int decode_slice_header(const FFV1Context *f, FFV1Context *fs, · 53 unmodified lines | ||
| 207 | 208 | return -1; |
| 208 | 209 | } |
| 209 | 210 | p->quant_table_index = idx; |
| 210 | − memcpy(p->quant_table, f->quant_tables[idx], sizeof(p->quant_table)); | |
| 211 | 211 | context_count = f->context_count[idx]; |
| 212 | 212 | |
| 213 | 213 | if (p->context_count < context_count) { |
| @@ -335,29 +335,29 @@ static int decode_slice(AVCodecContext *c, void *arg) · 121 unmodified lines | ||
| 335 | 335 | const int chroma_height = AV_CEIL_RSHIFT(height, f->chroma_v_shift); |
| 336 | 336 | const int cx = x >> f->chroma_h_shift; |
| 337 | 337 | const int cy = y >> f->chroma_v_shift; |
| 338 | − decode_plane(fs, sc, &gb, p->data[0] + ps*x + y*p->linesize[0], width, height, p->linesize[0], 0, 1); | |
| 338 | + decode_plane(f, fs, sc, &gb, p->data[0] + ps*x + y*p->linesize[0], width, height, p->linesize[0], 0, 1); | |
| 339 | 339 | |
| 340 | 340 | if (f->chroma_planes) { |
| 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 | + decode_plane(f, fs, sc, &gb, p->data[1] + ps*cx+cy*p->linesize[1], chroma_width, chroma_height, p->linesize[1], 1, 1); | |
| 342 | + decode_plane(f, fs, sc, &gb, p->data[2] + ps*cx+cy*p->linesize[2], chroma_width, chroma_height, p->linesize[2], 1, 1); | |
| 343 | 343 | } |
| 344 | 344 | if (fs->transparency) |
| 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); | |
| 345 | + decode_plane(f, 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); | |
| 346 | 346 | } else if (f->colorspace == 0) { |
| 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 | + decode_plane(f, fs, sc, &gb, p->data[0] + ps*x + y*p->linesize[0] , width, height, p->linesize[0], 0, 2); | |
| 348 | + decode_plane(f, fs, sc, &gb, p->data[0] + ps*x + y*p->linesize[0] + 1, width, height, p->linesize[0], 1, 2); | |
| 349 | 349 | } else if (f->use32bit) { |
| 350 | 350 | uint8_t *planes[4] = { p->data[0] + ps * x + y * p->linesize[0], |
| 351 | 351 | p->data[1] + ps * x + y * p->linesize[1], |
| 352 | 352 | p->data[2] + ps * x + y * p->linesize[2], |
| 353 | 353 | p->data[3] + ps * x + y * p->linesize[3] }; |
| 354 | − decode_rgb_frame32(fs, sc, &gb, planes, width, height, p->linesize); | |
| 354 | + decode_rgb_frame32(f, fs, sc, &gb, planes, width, height, p->linesize); | |
| 355 | 355 | } else { |
| 356 | 356 | uint8_t *planes[4] = { p->data[0] + ps * x + y * p->linesize[0], |
| 357 | 357 | p->data[1] + ps * x + y * p->linesize[1], |
| 358 | 358 | p->data[2] + ps * x + y * p->linesize[2], |
| 359 | 359 | p->data[3] + ps * x + y * p->linesize[3] }; |
| 360 | − decode_rgb_frame(fs, sc, &gb, planes, width, height, p->linesize); | |
| 360 | + decode_rgb_frame(f, fs, sc, &gb, planes, width, height, p->linesize); | |
| 361 | 361 | } |
| 362 | 362 | if (fs->ac != AC_GOLOMB_RICE && f->version > 2) { |
| 363 | 363 | int v; |
| @@ -830,11 +830,7 @@ static int read_header(FFV1Context *f) · 466 unmodified lines | ||
| 830 | 830 | return AVERROR_INVALIDDATA; |
| 831 | 831 | } |
| 832 | 832 | p->quant_table_index = idx; |
| 833 | − memcpy(p->quant_table, f->quant_tables[idx], | |
| 834 | − sizeof(p->quant_table)); | |
| 835 | 833 | context_count = f->context_count[idx]; |
| 836 | − } else { | |
| 837 | − memcpy(p->quant_table, f->quant_tables[0], sizeof(p->quant_table)); | |
| 838 | 834 | } |
| 839 | 835 | |
| 840 | 836 | if (f->version <= 2) { |
| @@ -23,11 +23,14 @@ · 22 unmodified lines | ||
| 23 | 23 | #include "ffv1_template.c" |
| 24 | 24 | |
| 25 | 25 | static av_always_inline int |
| 26 | −RENAME(decode_line)(FFV1Context *s, FFV1SliceContext *sc, GetBitContext *gb, | |
| 26 | +RENAME(decode_line)(FFV1Context *f, | |
| 27 | + FFV1Context *s, FFV1SliceContext *sc, | |
| 28 | + GetBitContext *gb, | |
| 27 | 29 | int w, TYPE *sample[2], int plane_index, int bits) |
| 28 | 30 | { |
| 29 | 31 | PlaneContext *const p = &s->plane[plane_index]; |
| 30 | 32 | RangeCoder *const c = &s->c; |
| 33 | + const int16_t (*quant_table)[256] = f->quant_tables[p->quant_table_index]; | |
| 31 | 34 | int x; |
| 32 | 35 | int run_count = 0; |
| 33 | 36 | int run_mode = 0; |
| @@ -57,7 +60,8 @@ RENAME(decode_line)(FFV1Context *s, FFV1SliceContext *sc, GetBitContext *gb, · 23 unmodified lines | ||
| 57 | 60 | return AVERROR_INVALIDDATA; |
| 58 | 61 | } |
| 59 | 62 | |
| 60 | − context = RENAME(get_context)(p, sample[1] + x, sample[0] + x, sample[1] + x); | |
| 63 | + context = RENAME(get_context)(quant_table, | |
| 64 | + sample[1] + x, sample[0] + x, sample[1] + x); | |
| 61 | 65 | if (context < 0) { |
| 62 | 66 | context = -context; |
| 63 | 67 | sign = 1; |
| @@ -127,7 +131,8 @@ RENAME(decode_line)(FFV1Context *s, FFV1SliceContext *sc, GetBitContext *gb, · 63 unmodified lines | ||
| 127 | 131 | return 0; |
| 128 | 132 | } |
| 129 | 133 | |
| 130 | −static int RENAME(decode_rgb_frame)(FFV1Context *s, FFV1SliceContext *sc, | |
| 134 | +static int RENAME(decode_rgb_frame)(FFV1Context *f, | |
| 135 | + FFV1Context *s, FFV1SliceContext *sc, | |
| 131 | 136 | GetBitContext *gb, |
| 132 | 137 | uint8_t *src[4], int w, int h, int stride[4]) |
| 133 | 138 | { |
| @@ -158,9 +163,9 @@ static int RENAME(decode_rgb_frame)(FFV1Context *s, FFV1SliceContext *sc, · 24 unmodified lines | ||
| 158 | 163 | sample[p][1][-1]= sample[p][0][0 ]; |
| 159 | 164 | sample[p][0][ w]= sample[p][0][w-1]; |
| 160 | 165 | if (lbd && s->slice_coding_mode == 0) |
| 161 | − ret = RENAME(decode_line)(s, sc, gb, w, sample[p], (p + 1)/2, 9); | |
| 166 | + ret = RENAME(decode_line)(f, s, sc, gb, w, sample[p], (p + 1)/2, 9); | |
| 162 | 167 | else |
| 163 | − ret = RENAME(decode_line)(s, sc, gb, w, sample[p], (p + 1)/2, bits + (s->slice_coding_mode != 1)); | |
| 168 | + ret = RENAME(decode_line)(f, s, sc, gb, w, sample[p], (p + 1)/2, bits + (s->slice_coding_mode != 1)); | |
| 164 | 169 | if (ret < 0) |
| 165 | 170 | return ret; |
| 166 | 171 | } |
| @@ -269,7 +269,8 @@ static inline void put_vlc_symbol(PutBitContext *pb, VlcState *const state, · 268 unmodified lines | ||
| 269 | 269 | #define RENAME(name) name ## 32 |
| 270 | 270 | #include "ffv1enc_template.c" |
| 271 | 271 | |
| 272 | −static int encode_plane(FFV1Context *s, FFV1SliceContext *sc, | |
| 272 | +static int encode_plane(FFV1Context *f, | |
| 273 | + FFV1Context *s, FFV1SliceContext *sc, | |
| 273 | 274 | const uint8_t *src, int w, int h, |
| 274 | 275 | int stride, int plane_index, int pixel_stride) |
| 275 | 276 | { |
| @@ -289,7 +290,7 @@ static int encode_plane(FFV1Context *s, FFV1SliceContext *sc, · 13 unmodified lines | ||
| 289 | 290 | if (s->bits_per_raw_sample <= 8) { |
| 290 | 291 | for (x = 0; x < w; x++) |
| 291 | 292 | sample[0][x] = src[x * pixel_stride + stride * y]; |
| 292 | − if((ret = encode_line(s, sc, w, sample, plane_index, 8)) < 0) | |
| 293 | + if((ret = encode_line(f, s, sc, w, sample, plane_index, 8)) < 0) | |
| 293 | 294 | return ret; |
| 294 | 295 | } else { |
| 295 | 296 | if (s->packed_at_lsb) { |
| @@ -301,7 +302,7 @@ static int encode_plane(FFV1Context *s, FFV1SliceContext *sc, · 5 unmodified lines | ||
| 301 | 302 | sample[0][x] = ((uint16_t*)(src + stride*y))[x] >> (16 - s->bits_per_raw_sample); |
| 302 | 303 | } |
| 303 | 304 | } |
| 304 | − if((ret = encode_line(s, sc, w, sample, plane_index, s->bits_per_raw_sample)) < 0) | |
| 305 | + if((ret = encode_line(f, s, sc, w, sample, plane_index, s->bits_per_raw_sample)) < 0) | |
| 305 | 306 | return ret; |
| 306 | 307 | } |
| 307 | 308 | } |
| @@ -741,7 +742,6 @@ static av_cold int encode_init(AVCodecContext *avctx) · 433 unmodified lines | ||
| 741 | 742 | |
| 742 | 743 | p->quant_table_index = s->context_model; |
| 743 | 744 | p->context_count = s->context_count[p->quant_table_index]; |
| 744 | − memcpy(p->quant_table, s->quant_tables[p->quant_table_index], sizeof(p->quant_table)); | |
| 745 | 745 | } |
| 746 | 746 | |
| 747 | 747 | if ((ret = ff_ffv1_allocate_initial_states(s)) < 0) |
| @@ -1066,21 +1066,21 @@ retry: · 318 unmodified lines | ||
| 1066 | 1066 | const int cx = x >> f->chroma_h_shift; |
| 1067 | 1067 | const int cy = y >> f->chroma_v_shift; |
| 1068 | 1068 | |
| 1069 | − ret = encode_plane(fs, sc, p->data[0] + ps*x + y*p->linesize[0], width, height, p->linesize[0], 0, 1); | |
| 1069 | + ret = encode_plane(f, fs, sc, p->data[0] + ps*x + y*p->linesize[0], width, height, p->linesize[0], 0, 1); | |
| 1070 | 1070 | |
| 1071 | 1071 | if (f->chroma_planes) { |
| 1072 | − ret |= encode_plane(fs, sc, p->data[1] + ps*cx+cy*p->linesize[1], chroma_width, chroma_height, p->linesize[1], 1, 1); | |
| 1073 | − ret |= encode_plane(fs, sc, p->data[2] + ps*cx+cy*p->linesize[2], chroma_width, chroma_height, p->linesize[2], 1, 1); | |
| 1072 | + ret |= encode_plane(f, fs, sc, p->data[1] + ps*cx+cy*p->linesize[1], chroma_width, chroma_height, p->linesize[1], 1, 1); | |
| 1073 | + ret |= encode_plane(f, fs, sc, p->data[2] + ps*cx+cy*p->linesize[2], chroma_width, chroma_height, p->linesize[2], 1, 1); | |
| 1074 | 1074 | } |
| 1075 | 1075 | if (fs->transparency) |
| 1076 | − ret |= encode_plane(fs, sc, p->data[3] + ps*x + y*p->linesize[3], width, height, p->linesize[3], 2, 1); | |
| 1076 | + ret |= encode_plane(f, fs, sc, p->data[3] + ps*x + y*p->linesize[3], width, height, p->linesize[3], 2, 1); | |
| 1077 | 1077 | } else if (c->pix_fmt == AV_PIX_FMT_YA8) { |
| 1078 | − ret = encode_plane(fs, sc, p->data[0] + ps*x + y*p->linesize[0], width, height, p->linesize[0], 0, 2); | |
| 1079 | − ret |= encode_plane(fs, sc, p->data[0] + 1 + ps*x + y*p->linesize[0], width, height, p->linesize[0], 1, 2); | |
| 1078 | + ret = encode_plane(f, fs, sc, p->data[0] + ps*x + y*p->linesize[0], width, height, p->linesize[0], 0, 2); | |
| 1079 | + ret |= encode_plane(f, fs, sc, p->data[0] + 1 + ps*x + y*p->linesize[0], width, height, p->linesize[0], 1, 2); | |
| 1080 | 1080 | } else if (f->use32bit) { |
| 1081 | − ret = encode_rgb_frame32(fs, sc, planes, width, height, p->linesize); | |
| 1081 | + ret = encode_rgb_frame32(f, fs, sc, planes, width, height, p->linesize); | |
| 1082 | 1082 | } else { |
| 1083 | − ret = encode_rgb_frame(fs, sc, planes, width, height, p->linesize); | |
| 1083 | + ret = encode_rgb_frame(f, fs, sc, planes, width, height, p->linesize); | |
| 1084 | 1084 | } |
| 1085 | 1085 | |
| 1086 | 1086 | if (ret < 0) { |
| @@ -23,7 +23,8 @@ · 22 unmodified lines | ||
| 23 | 23 | #include "ffv1_template.c" |
| 24 | 24 | |
| 25 | 25 | static av_always_inline int |
| 26 | −RENAME(encode_line)(FFV1Context *s, FFV1SliceContext *sc, | |
| 26 | +RENAME(encode_line)(FFV1Context *f, | |
| 27 | + FFV1Context *s, FFV1SliceContext *sc, | |
| 27 | 28 | int w, TYPE *sample[3], int plane_index, int bits) |
| 28 | 29 | { |
| 29 | 30 | PlaneContext *const p = &s->plane[plane_index]; |
| @@ -60,7 +61,8 @@ RENAME(encode_line)(FFV1Context *s, FFV1SliceContext *sc, · 30 unmodified lines | ||
| 60 | 61 | for (x = 0; x < w; x++) { |
| 61 | 62 | int diff, context; |
| 62 | 63 | |
| 63 | − context = RENAME(get_context)(p, sample[0] + x, sample[1] + x, sample[2] + x); | |
| 64 | + context = RENAME(get_context)(f->quant_tables[p->quant_table_index], | |
| 65 | + sample[0] + x, sample[1] + x, sample[2] + x); | |
| 64 | 66 | diff = sample[0][x] - RENAME(predict)(sample[0] + x, sample[1] + x); |
| 65 | 67 | |
| 66 | 68 | if (context < 0) { |
| @@ -124,7 +126,8 @@ RENAME(encode_line)(FFV1Context *s, FFV1SliceContext *sc, · 57 unmodified lines | ||
| 124 | 126 | return 0; |
| 125 | 127 | } |
| 126 | 128 | |
| 127 | −static int RENAME(encode_rgb_frame)(FFV1Context *s, FFV1SliceContext *sc, | |
| 129 | +static int RENAME(encode_rgb_frame)(FFV1Context *f, | |
| 130 | + FFV1Context *s, FFV1SliceContext *sc, | |
| 128 | 131 | const uint8_t *src[4], |
| 129 | 132 | int w, int h, const int stride[4]) |
| 130 | 133 | { |
| @@ -193,9 +196,9 @@ static int RENAME(encode_rgb_frame)(FFV1Context *s, FFV1SliceContext *sc, · 62 unmodified lines | ||
| 193 | 196 | sample[p][0][-1] = sample[p][1][0 ]; |
| 194 | 197 | sample[p][1][ w] = sample[p][1][w-1]; |
| 195 | 198 | if (lbd && s->slice_coding_mode == 0) |
| 196 | − ret = RENAME(encode_line)(s, sc, w, sample[p], (p + 1) / 2, 9); | |
| 199 | + ret = RENAME(encode_line)(f, s, sc, w, sample[p], (p + 1) / 2, 9); | |
| 197 | 200 | else |
| 198 | − ret = RENAME(encode_line)(s, sc, w, sample[p], (p + 1) / 2, bits + (s->slice_coding_mode != 1)); | |
| 201 | + ret = RENAME(encode_line)(f, s, sc, w, sample[p], (p + 1) / 2, bits + (s->slice_coding_mode != 1)); | |
| 199 | 202 | if (ret < 0) |
| 200 | 203 | return ret; |
| 201 | 204 | } |