Showing the changes to libavcodec (1 of 1 file). Show all
Unified · Split
| @@ -46,7 +46,7 @@ static inline av_flatten int get_symbol_inline(RangeCoder *c, uint8_t *state, · 45 unmodified lines | |||
| 46 | if (get_rac(c, state + 0)) | 46 | if (get_rac(c, state + 0)) |
| 47 | return 0; | 47 | return 0; |
| 48 | else { | 48 | else { |
| 49 | int i, e; | 49 | int e; |
| 50 | unsigned a; | 50 | unsigned a; |
| 51 | e = 0; | 51 | e = 0; |
| 52 | while (get_rac(c, state + 1 + FFMIN(e, 9))) { // 1..10 | 52 | while (get_rac(c, state + 1 + FFMIN(e, 9))) { // 1..10 |
| @@ -56,7 +56,7 @@ static inline av_flatten int get_symbol_inline(RangeCoder *c, uint8_t *state, · 3 unmodified lines | |||
| 56 | } | 56 | } |
| 57 | 57 | ||
| 58 | a = 1; | 58 | a = 1; |
| 59 | for (i = e - 1; i >= 0; i--) | 59 | for (int i = e - 1; i >= 0; i--) |
| 60 | a += a + get_rac(c, state + 22 + FFMIN(i, 9)); // 22..31 | 60 | a += a + get_rac(c, state + 22 + FFMIN(i, 9)); // 22..31 |
| 61 | 61 | ||
| 62 | e = -(is_signed && get_rac(c, state + 11 + FFMIN(e, 10))); // 11..21 | 62 | e = -(is_signed && get_rac(c, state + 11 + FFMIN(e, 10))); // 11..21 |
| @@ -167,7 +167,7 @@ static int decode_slice_header(const FFV1Context *f, FFV1Context *fs) · 104 unmodified lines | |||
| 167 | { | 167 | { |
| 168 | RangeCoder *c = &fs->c; | 168 | RangeCoder *c = &fs->c; |
| 169 | uint8_t state[CONTEXT_SIZE]; | 169 | uint8_t state[CONTEXT_SIZE]; |
| 170 | unsigned ps, i, context_count; | 170 | unsigned ps, context_count; |
| 171 | int sx, sy, sw, sh; | 171 | int sx, sy, sw, sh; |
| 172 | 172 | ||
| 173 | memset(state, 128, sizeof(state)); | 173 | memset(state, 128, sizeof(state)); |
| @@ -197,7 +197,7 @@ static int decode_slice_header(const FFV1Context *f, FFV1Context *fs) · 23 unmodified lines | |||
| 197 | if (fs->ac == AC_GOLOMB_RICE && fs->slice_width >= (1<<23)) | 197 | if (fs->ac == AC_GOLOMB_RICE && fs->slice_width >= (1<<23)) |
| 198 | return AVERROR_INVALIDDATA; | 198 | return AVERROR_INVALIDDATA; |
| 199 | 199 | ||
| 200 | for (i = 0; i < f->plane_count; i++) { | 200 | for (unsigned i = 0; i < f->plane_count; i++) { |
| 201 | PlaneContext * const p = &fs->plane[i]; | 201 | PlaneContext * const p = &fs->plane[i]; |
| 202 | int idx = get_symbol(c, state, 0); | 202 | int idx = get_symbol(c, state, 0); |
| 203 | if (idx >= (unsigned)f->quant_table_count) { | 203 | if (idx >= (unsigned)f->quant_table_count) { |
| @@ -259,7 +259,7 @@ static int decode_slice(AVCodecContext *c, void *arg) · 55 unmodified lines | |||
| 259 | int width, height, x, y, ret; | 259 | int width, height, x, y, ret; |
| 260 | const int ps = av_pix_fmt_desc_get(c->pix_fmt)->comp[0].step; | 260 | const int ps = av_pix_fmt_desc_get(c->pix_fmt)->comp[0].step; |
| 261 | AVFrame * const p = f->cur; | 261 | AVFrame * const p = f->cur; |
| 262 | int i, si; | 262 | int si; |
| 263 | 263 | ||
| 264 | for( si=0; fs != f->slice_context[si]; si ++) | 264 | for( si=0; fs != f->slice_context[si]; si ++) |
| 265 | ; | 265 | ; |
| @@ -276,7 +276,7 @@ static int decode_slice(AVCodecContext *c, void *arg) · 10 unmodified lines | |||
| 276 | if (!(p->flags & AV_FRAME_FLAG_KEY)) | 276 | if (!(p->flags & AV_FRAME_FLAG_KEY)) |
| 277 | fsdst->slice_damaged |= fssrc->slice_damaged; | 277 | fsdst->slice_damaged |= fssrc->slice_damaged; |
| 278 | 278 | ||
| 279 | for (i = 0; i < f->plane_count; i++) { | 279 | for (int i = 0; i < f->plane_count; i++) { |
| 280 | PlaneContext *psrc = &fssrc->plane[i]; | 280 | PlaneContext *psrc = &fssrc->plane[i]; |
| 281 | PlaneContext *pdst = &fsdst->plane[i]; | 281 | PlaneContext *pdst = &fsdst->plane[i]; |
| 282 | 282 | ||
| @@ -424,7 +424,7 @@ static int read_extra_header(FFV1Context *f) · 141 unmodified lines | |||
| 424 | { | 424 | { |
| 425 | RangeCoder *const c = &f->c; | 425 | RangeCoder *const c = &f->c; |
| 426 | uint8_t state[CONTEXT_SIZE]; | 426 | uint8_t state[CONTEXT_SIZE]; |
| 427 | int i, j, k, ret; | 427 | int ret; |
| 428 | uint8_t state2[32][CONTEXT_SIZE]; | 428 | uint8_t state2[32][CONTEXT_SIZE]; |
| 429 | unsigned crc = 0; | 429 | unsigned crc = 0; |
| 430 | 430 | ||
| @@ -453,7 +453,7 @@ static int read_extra_header(FFV1Context *f) · 22 unmodified lines | |||
| 453 | f->ac = get_symbol(c, state, 0); | 453 | f->ac = get_symbol(c, state, 0); |
| 454 | 454 | ||
| 455 | if (f->ac == AC_RANGE_CUSTOM_TAB) { | 455 | if (f->ac == AC_RANGE_CUSTOM_TAB) { |
| 456 | for (i = 1; i < 256; i++) | 456 | for (int i = 1; i < 256; i++) |
| 457 | f->state_transition[i] = get_symbol(c, state, 1) + c->one_state[i]; | 457 | f->state_transition[i] = get_symbol(c, state, 1) + c->one_state[i]; |
| 458 | } | 458 | } |
| 459 | 459 | ||
| @@ -492,7 +492,7 @@ static int read_extra_header(FFV1Context *f) · 32 unmodified lines | |||
| 492 | return AVERROR_INVALIDDATA; | 492 | return AVERROR_INVALIDDATA; |
| 493 | } | 493 | } |
| 494 | 494 | ||
| 495 | for (i = 0; i < f->quant_table_count; i++) { | 495 | for (int i = 0; i < f->quant_table_count; i++) { |
| 496 | f->context_count[i] = read_quant_tables(c, f->quant_tables[i]); | 496 | f->context_count[i] = read_quant_tables(c, f->quant_tables[i]); |
| 497 | if (f->context_count[i] < 0) { | 497 | if (f->context_count[i] < 0) { |
| 498 | av_log(f->avctx, AV_LOG_ERROR, "read_quant_table error\n"); | 498 | av_log(f->avctx, AV_LOG_ERROR, "read_quant_table error\n"); |
| @@ -502,10 +502,10 @@ static int read_extra_header(FFV1Context *f) · 3 unmodified lines | |||
| 502 | if ((ret = ff_ffv1_allocate_initial_states(f)) < 0) | 502 | if ((ret = ff_ffv1_allocate_initial_states(f)) < 0) |
| 503 | return ret; | 503 | return ret; |
| 504 | 504 | ||
| 505 | for (i = 0; i < f->quant_table_count; i++) | 505 | for (int i = 0; i < f->quant_table_count; i++) |
| 506 | if (get_rac(c, state)) { | 506 | if (get_rac(c, state)) { |
| 507 | for (j = 0; j < f->context_count[i]; j++) | 507 | for (int j = 0; j < f->context_count[i]; j++) |
| 508 | for (k = 0; k < CONTEXT_SIZE; k++) { | 508 | for (int k = 0; k < CONTEXT_SIZE; k++) { |
| 509 | int pred = j ? f->initial_states[i][j - 1][k] : 128; | 509 | int pred = j ? f->initial_states[i][j - 1][k] : 128; |
| 510 | f->initial_states[i][j][k] = | 510 | f->initial_states[i][j][k] = |
| 511 | (pred + get_symbol(c, state2[k], 1)) & 0xFF; | 511 | (pred + get_symbol(c, state2[k], 1)) & 0xFF; |
| @@ -550,7 +550,7 @@ static int read_extra_header(FFV1Context *f) · 38 unmodified lines | |||
| 550 | static int read_header(FFV1Context *f) | 550 | static int read_header(FFV1Context *f) |
| 551 | { | 551 | { |
| 552 | uint8_t state[CONTEXT_SIZE]; | 552 | uint8_t state[CONTEXT_SIZE]; |
| 553 | int i, j, context_count = -1; //-1 to avoid warning | 553 | int context_count = -1; //-1 to avoid warning |
| 554 | RangeCoder *const c = &f->slice_context[0]->c; | 554 | RangeCoder *const c = &f->slice_context[0]->c; |
| 555 | 555 | ||
| 556 | memset(state, 128, sizeof(state)); | 556 | memset(state, 128, sizeof(state)); |
| @@ -566,7 +566,7 @@ static int read_header(FFV1Context *f) · 9 unmodified lines | |||
| 566 | f->ac = get_symbol(c, state, 0); | 566 | f->ac = get_symbol(c, state, 0); |
| 567 | 567 | ||
| 568 | if (f->ac == AC_RANGE_CUSTOM_TAB) { | 568 | if (f->ac == AC_RANGE_CUSTOM_TAB) { |
| 569 | for (i = 1; i < 256; i++) { | 569 | for (int i = 1; i < 256; i++) { |
| 570 | int st = get_symbol(c, state, 1) + c->one_state[i]; | 570 | int st = get_symbol(c, state, 1) + c->one_state[i]; |
| 571 | if (st < 1 || st > 255) { | 571 | if (st < 1 || st > 255) { |
| 572 | av_log(f->avctx, AV_LOG_ERROR, "invalid state transition %d\n", st); | 572 | av_log(f->avctx, AV_LOG_ERROR, "invalid state transition %d\n", st); |
| @@ -790,7 +790,7 @@ static int read_header(FFV1Context *f) · 217 unmodified lines | |||
| 790 | return AVERROR_INVALIDDATA; | 790 | return AVERROR_INVALIDDATA; |
| 791 | } | 791 | } |
| 792 | 792 | ||
| 793 | for (j = 0; j < f->slice_count; j++) { | 793 | for (int j = 0; j < f->slice_count; j++) { |
| 794 | FFV1Context *fs = f->slice_context[j]; | 794 | FFV1Context *fs = f->slice_context[j]; |
| 795 | fs->ac = f->ac; | 795 | fs->ac = f->ac; |
| 796 | fs->packed_at_lsb = f->packed_at_lsb; | 796 | fs->packed_at_lsb = f->packed_at_lsb; |
| @@ -819,7 +819,7 @@ static int read_header(FFV1Context *f) · 22 unmodified lines | |||
| 819 | && (unsigned)fs->slice_y + (uint64_t)fs->slice_height <= f->height); | 819 | && (unsigned)fs->slice_y + (uint64_t)fs->slice_height <= f->height); |
| 820 | } | 820 | } |
| 821 | 821 | ||
| 822 | for (i = 0; i < f->plane_count; i++) { | 822 | for (int i = 0; i < f->plane_count; i++) { |
| 823 | PlaneContext *const p = &fs->plane[i]; | 823 | PlaneContext *const p = &fs->plane[i]; |
| 824 | 824 | ||
| 825 | if (f->version == 2) { | 825 | if (f->version == 2) { |
| @@ -874,7 +874,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *rframe, · 48 unmodified lines | |||
| 874 | int buf_size = avpkt->size; | 874 | int buf_size = avpkt->size; |
| 875 | FFV1Context *f = avctx->priv_data; | 875 | FFV1Context *f = avctx->priv_data; |
| 876 | RangeCoder *const c = &f->slice_context[0]->c; | 876 | RangeCoder *const c = &f->slice_context[0]->c; |
| 877 | int i, ret, key_frame; | 877 | int ret, key_frame; |
| 878 | uint8_t keystate = 128; | 878 | uint8_t keystate = 128; |
| 879 | uint8_t *buf_p; | 879 | uint8_t *buf_p; |
| 880 | AVFrame *p; | 880 | AVFrame *p; |
| @@ -908,6 +908,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *rframe, · 27 unmodified lines | |||
| 908 | } else { | 908 | } else { |
| 909 | int w = avctx->width; | 909 | int w = avctx->width; |
| 910 | int s = 1 + w / (1<<23); | 910 | int s = 1 + w / (1<<23); |
| 911 | int i; | ||
| 911 | 912 | ||
| 912 | w /= s; | 913 | w /= s; |
| 913 | 914 | ||
| @@ -941,7 +942,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *rframe, · 27 unmodified lines | |||
| 941 | ff_thread_finish_setup(avctx); | 942 | ff_thread_finish_setup(avctx); |
| 942 | 943 | ||
| 943 | buf_p = buf + buf_size; | 944 | buf_p = buf + buf_size; |
| 944 | for (i = f->slice_count - 1; i >= 0; i--) { | 945 | for (int i = f->slice_count - 1; i >= 0; i--) { |
| 945 | FFV1Context *fs = f->slice_context[i]; | 946 | FFV1Context *fs = f->slice_context[i]; |
| 946 | int trailer = 3 + 5*!!f->ec; | 947 | int trailer = 3 + 5*!!f->ec; |
| 947 | int v; | 948 | int v; |
| @@ -991,15 +992,14 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *rframe, · 43 unmodified lines | |||
| 991 | f->slice_count, | 992 | f->slice_count, |
| 992 | sizeof(void*)); | 993 | sizeof(void*)); |
| 993 | 994 | ||
| 994 | for (i = f->slice_count - 1; i >= 0; i--) { | 995 | for (int i = f->slice_count - 1; i >= 0; i--) { |
| 995 | FFV1Context *fs = f->slice_context[i]; | 996 | FFV1Context *fs = f->slice_context[i]; |
| 996 | int j; | ||
| 997 | if (fs->slice_damaged && f->last_picture.f) { | 997 | if (fs->slice_damaged && f->last_picture.f) { |
| 998 | const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt); | 998 | const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt); |
| 999 | const uint8_t *src[4]; | 999 | const uint8_t *src[4]; |
| 1000 | uint8_t *dst[4]; | 1000 | uint8_t *dst[4]; |
| 1001 | ff_progress_frame_await(&f->last_picture, INT_MAX); | 1001 | ff_progress_frame_await(&f->last_picture, INT_MAX); |
| 1002 | for (j = 0; j < desc->nb_components; j++) { | 1002 | for (int j = 0; j < desc->nb_components; j++) { |
| 1003 | int pixshift = desc->comp[j].depth > 8; | 1003 | int pixshift = desc->comp[j].depth > 8; |
| 1004 | int sh = (j == 1 || j == 2) ? f->chroma_h_shift : 0; | 1004 | int sh = (j == 1 || j == 2) ? f->chroma_h_shift : 0; |
| 1005 | int sv = (j == 1 || j == 2) ? f->chroma_v_shift : 0; | 1005 | int sv = (j == 1 || j == 2) ? f->chroma_v_shift : 0; |
| @@ -1064,7 +1064,6 @@ static int update_thread_context(AVCodecContext *dst, const AVCodecContext *src) · 58 unmodified lines | |||
| 1064 | { | 1064 | { |
| 1065 | FFV1Context *fsrc = src->priv_data; | 1065 | FFV1Context *fsrc = src->priv_data; |
| 1066 | FFV1Context *fdst = dst->priv_data; | 1066 | FFV1Context *fdst = dst->priv_data; |
| 1067 | int i; | ||
| 1068 | 1067 | ||
| 1069 | if (dst == src) | 1068 | if (dst == src) |
| 1070 | return 0; | 1069 | return 0; |
| @@ -1075,7 +1074,7 @@ static int update_thread_context(AVCodecContext *dst, const AVCodecContext *src) · 4 unmodified lines | |||
| 1075 | sizeof(fdst->state_transition)); | 1074 | sizeof(fdst->state_transition)); |
| 1076 | memcpy(fdst->quant_table, fsrc->quant_table, sizeof(fsrc->quant_table)); | 1075 | memcpy(fdst->quant_table, fsrc->quant_table, sizeof(fsrc->quant_table)); |
| 1077 | 1076 | ||
| 1078 | for (i = 0; i < fdst->num_h_slices * fdst->num_v_slices; i++) { | 1077 | for (int i = 0; i < fdst->num_h_slices * fdst->num_v_slices; i++) { |
| 1079 | FFV1Context *fssrc = fsrc->slice_context[i]; | 1078 | FFV1Context *fssrc = fsrc->slice_context[i]; |
| 1080 | FFV1Context *fsdst = fdst->slice_context[i]; | 1079 | FFV1Context *fsdst = fdst->slice_context[i]; |
| 1081 | copy_fields(fsdst, fssrc, fsrc); | 1080 | copy_fields(fsdst, fssrc, fsrc); |