X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fffv1enc.c;h=df1d990b92e36e7239d141b86bf1275c2fbc2977;hb=bf52f773913cf74bdf0d2c8c2cb4473fa1b7801e;hp=179453db5edb69650c92cc33927a1e6e2ce24f22;hpb=a6064b12b481072abe0df53e5996cf103994526f;p=ffmpeg diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c index 179453db5ed..df1d990b92e 100644 --- a/libavcodec/ffv1enc.c +++ b/libavcodec/ffv1enc.c @@ -71,7 +71,7 @@ static void find_best_state(uint8_t best_state[256][256], best_len[k] = len; best_state[i][k] = j; } - for (m = 0; m < 256; m++) + for (m = 1; m < 256; m++) if (occ[m]) { newocc[one_state[m]] += occ[m] * p; newocc[256 - one_state[256 - m]] += occ[m] * (1 - p); @@ -160,7 +160,7 @@ static inline void put_vlc_symbol(PutBitContext *pb, VlcState *const state, code = v ^ ((2 * state->drift + state->count) >> 31); #endif - av_dlog(NULL, "v:%d/%d bias:%d error:%d drift:%d count:%d k:%d\n", v, code, + ff_dlog(NULL, "v:%d/%d bias:%d error:%d drift:%d count:%d k:%d\n", v, code, state->bias, state->error_sum, state->drift, state->count, k); set_sr_golomb(pb, code, k, 12, bits); @@ -234,7 +234,7 @@ static av_always_inline int encode_line(FFV1Context *s, int w, } } - av_dlog(s->avctx, "count:%d index:%d, mode:%d, x:%d pos:%d\n", + ff_dlog(s->avctx, "count:%d index:%d, mode:%d, x:%d pos:%d\n", run_count, run_index, run_mode, x, (int)put_bits_count(&s->pb)); @@ -293,8 +293,8 @@ static void encode_plane(FFV1Context *s, uint8_t *src, int w, int h, } } -static void encode_rgb_frame(FFV1Context *s, uint8_t *src[3], int w, int h, - int stride[3]) +static void encode_rgb_frame(FFV1Context *s, const uint8_t *src[3], + int w, int h, const int stride[3]) { int x, y, p, i; const int ring_size = s->avctx->context_model ? 3 : 2; @@ -320,15 +320,15 @@ static void encode_rgb_frame(FFV1Context *s, uint8_t *src[3], int w, int h, for (x = 0; x < w; x++) { int b, g, r, av_uninit(a); if (lbd) { - unsigned v = *((uint32_t *)(src[0] + x * 4 + stride[0] * y)); + unsigned v = *((const uint32_t *)(src[0] + x * 4 + stride[0] * y)); b = v & 0xFF; g = (v >> 8) & 0xFF; r = (v >> 16) & 0xFF; a = v >> 24; } else { - b = *((uint16_t *)(src[0] + x * 2 + stride[0] * y)); - g = *((uint16_t *)(src[1] + x * 2 + stride[1] * y)); - r = *((uint16_t *)(src[2] + x * 2 + stride[2] * y)); + b = *((const uint16_t *)(src[0] + x * 2 + stride[0] * y)); + g = *((const uint16_t *)(src[1] + x * 2 + stride[1] * y)); + r = *((const uint16_t *)(src[2] + x * 2 + stride[2] * y)); } b -= g; @@ -721,11 +721,11 @@ static av_cold int ffv1_encode_init(AVCodecContext *avctx) if ((ret = ffv1_allocate_initial_states(s)) < 0) return ret; - avctx->coded_frame = av_frame_alloc(); - if (!avctx->coded_frame) - return AVERROR(ENOMEM); - +#if FF_API_CODED_FRAME +FF_DISABLE_DEPRECATION_WARNINGS avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; +FF_ENABLE_DEPRECATION_WARNINGS +#endif if (!s->transparency) s->plane_count = 2; @@ -863,12 +863,12 @@ static void encode_slice_header(FFV1Context *f, FFV1Context *fs) put_symbol(c, state, f->plane[j].quant_table_index, 0); av_assert0(f->plane[j].quant_table_index == f->avctx->context_model); } - if (!f->avctx->coded_frame->interlaced_frame) + if (!f->frame->interlaced_frame) put_symbol(c, state, 3, 0); else - put_symbol(c, state, 1 + !f->avctx->coded_frame->top_field_first, 0); - put_symbol(c, state, f->avctx->coded_frame->sample_aspect_ratio.num, 0); - put_symbol(c, state, f->avctx->coded_frame->sample_aspect_ratio.den, 0); + put_symbol(c, state, 1 + !f->frame->top_field_first, 0); + put_symbol(c, state, f->frame->sample_aspect_ratio.num, 0); + put_symbol(c, state, f->frame->sample_aspect_ratio.den, 0); } static int encode_slice(AVCodecContext *c, void *arg) @@ -884,7 +884,7 @@ static int encode_slice(AVCodecContext *c, void *arg) ? (f->bits_per_raw_sample > 8) + 1 : 4; - if (c->coded_frame->key_frame) + if (f->key_frame) ffv1_clear_slice_state(f, fs); if (f->version > 2) { encode_slice_header(f, fs); @@ -916,9 +916,9 @@ static int encode_slice(AVCodecContext *c, void *arg) encode_plane(fs, p->data[3] + ps * x + y * p->linesize[3], width, height, p->linesize[3], 2); } else { - uint8_t *planes[3] = { p->data[0] + ps * x + y * p->linesize[0], - p->data[1] + ps * x + y * p->linesize[1], - p->data[2] + ps * x + y * p->linesize[2] }; + const uint8_t *planes[3] = { p->data[0] + ps * x + y * p->linesize[0], + p->data[1] + ps * x + y * p->linesize[1], + p->data[2] + ps * x + y * p->linesize[2] }; encode_rgb_frame(fs, planes, width, height, p->linesize); } emms_c(); @@ -931,7 +931,6 @@ static int ffv1_encode_frame(AVCodecContext *avctx, AVPacket *pkt, { FFV1Context *f = avctx->priv_data; RangeCoder *const c = &f->slice_context[0]->c; - AVFrame *const p = avctx->coded_frame; int used_count = 0; uint8_t keystate = 128; uint8_t *buf_p; @@ -951,12 +950,12 @@ static int ffv1_encode_frame(AVCodecContext *avctx, AVPacket *pkt, if (avctx->gop_size == 0 || f->picture_number % avctx->gop_size == 0) { put_rac(c, &keystate, 1); - p->key_frame = 1; + f->key_frame = 1; f->gob_count++; write_header(f); } else { put_rac(c, &keystate, 0); - p->key_frame = 0; + f->key_frame = 0; } if (f->ac > 1) { @@ -1050,9 +1049,15 @@ static int ffv1_encode_frame(AVCodecContext *avctx, AVPacket *pkt, } else if (avctx->flags & CODEC_FLAG_PASS1) avctx->stats_out[0] = '\0'; +#if FF_API_CODED_FRAME +FF_DISABLE_DEPRECATION_WARNINGS + avctx->coded_frame->key_frame = f->key_frame; +FF_ENABLE_DEPRECATION_WARNINGS +#endif + f->picture_number++; pkt->size = buf_p - pkt->data; - pkt->flags |= AV_PKT_FLAG_KEY * p->key_frame; + pkt->flags |= AV_PKT_FLAG_KEY * f->key_frame; *got_packet = 1; return 0; @@ -1060,7 +1065,6 @@ static int ffv1_encode_frame(AVCodecContext *avctx, AVPacket *pkt, static av_cold int ffv1_encode_close(AVCodecContext *avctx) { - av_frame_free(&avctx->coded_frame); ffv1_close(avctx); return 0; }