X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fffv1enc.c;h=749f6265f33dd67a729e7d650d74e37178000e7e;hb=b8accd1175d20ab308de69dbd06bda06a02183e3;hp=796d81f7c6541ef88b6426b487938d533166aa4f;hpb=bad70b7af6b909691f5389e14eb7d0c03db10af9;p=ffmpeg diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c index 796d81f7c65..749f6265f33 100644 --- a/libavcodec/ffv1enc.c +++ b/libavcodec/ffv1enc.c @@ -31,7 +31,6 @@ #include "libavutil/opt.h" #include "libavutil/imgutils.h" #include "libavutil/pixdesc.h" -#include "libavutil/timer.h" #include "avcodec.h" #include "internal.h" @@ -287,7 +286,6 @@ static int encode_plane(FFV1Context *s, uint8_t *src, int w, int h, sample[0][-1]= sample[1][0 ]; sample[1][ w]= sample[1][w-1]; -// { START_TIMER if (s->bits_per_raw_sample <= 8) { for (x = 0; x < w; x++) sample[0][x] = src[x * pixel_stride + stride * y]; @@ -306,7 +304,6 @@ static int encode_plane(FFV1Context *s, uint8_t *src, int w, int h, if((ret = encode_line(s, w, sample, plane_index, s->bits_per_raw_sample)) < 0) return ret; } -// STOP_TIMER("encode line") } } return 0; } @@ -334,6 +331,18 @@ static void write_quant_tables(RangeCoder *c, write_quant_table(c, quant_table[i]); } +static int contains_non_128(uint8_t (*initial_state)[CONTEXT_SIZE], + int nb_contexts) +{ + if (!initial_state) + return 0; + for (int i = 0; i < nb_contexts; i++) + for (int j = 0; j < CONTEXT_SIZE; j++) + if (initial_state[i][j] != 128) + return 1; + return 0; +} + static void write_header(FFV1Context *f) { uint8_t state[CONTEXT_SIZE]; @@ -428,10 +437,7 @@ static int write_extradata(FFV1Context *f) write_quant_tables(c, f->quant_tables[i]); for (i = 0; i < f->quant_table_count; i++) { - for (j = 0; j < f->context_count[i] * CONTEXT_SIZE; j++) - if (f->initial_states[i] && f->initial_states[i][0][j] != 128) - break; - if (j < f->context_count[i] * CONTEXT_SIZE) { + if (contains_non_128(f->initial_states[i], f->context_count[i])) { put_rac(c, state, 1); for (j = 0; j < f->context_count[i]; j++) for (k = 0; k < CONTEXT_SIZE; k++) { @@ -548,13 +554,6 @@ static av_cold int encode_init(AVCodecContext *avctx) return AVERROR_INVALIDDATA; } -#if FF_API_CODER_TYPE -FF_DISABLE_DEPRECATION_WARNINGS - if (avctx->coder_type != -1) - s->ac = avctx->coder_type > 0 ? AC_RANGE_CUSTOM_TAB : AC_GOLOMB_RICE; - else -FF_ENABLE_DEPRECATION_WARNINGS -#endif if (s->ac == 1) // Compatbility with common command line usage s->ac = AC_RANGE_CUSTOM_TAB; else if (s->ac == AC_RANGE_DEFAULT_TAB_FORCE) @@ -697,16 +696,6 @@ FF_ENABLE_DEPRECATION_WARNINGS s->ac = AC_RANGE_CUSTOM_TAB; } } -#if FF_API_PRIVATE_OPT -FF_DISABLE_DEPRECATION_WARNINGS - if (avctx->context_model) - s->context_model = avctx->context_model; - if (avctx->context_model > 1U) { - av_log(avctx, AV_LOG_ERROR, "Invalid context model %d, valid values are 0 and 1\n", avctx->context_model); - return AVERROR(EINVAL); - } -FF_ENABLE_DEPRECATION_WARNINGS -#endif if (s->ac == AC_RANGE_CUSTOM_TAB) { for (i = 1; i < 256; i++) @@ -756,12 +745,6 @@ FF_ENABLE_DEPRECATION_WARNINGS if ((ret = ff_ffv1_allocate_initial_states(s)) < 0) return ret; -#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; if (!s->chroma_planes && s->version > 3) @@ -1185,11 +1168,6 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, av_frame_unref(p); if ((ret = av_frame_ref(p, pict)) < 0) return ret; -#if FF_API_CODED_FRAME -FF_DISABLE_DEPRECATION_WARNINGS - avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; -FF_ENABLE_DEPRECATION_WARNINGS -#endif if (avctx->gop_size == 0 || f->picture_number % avctx->gop_size == 0) { put_rac(c, &keystate, 1); @@ -1233,7 +1211,7 @@ FF_ENABLE_DEPRECATION_WARNINGS bytes = ff_rac_terminate(&fs->c, 1); } else { flush_put_bits(&fs->pb); // FIXME: nicer padding - bytes = fs->ac_byte_count + (put_bits_count(&fs->pb) + 7) / 8; + bytes = fs->ac_byte_count + put_bytes_output(&fs->pb); } if (i > 0 || f->version > 2) { av_assert0(bytes < pkt->size / f->slice_count); @@ -1255,12 +1233,6 @@ FF_ENABLE_DEPRECATION_WARNINGS if (avctx->flags & AV_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->pts = @@ -1304,13 +1276,6 @@ static const AVClass ffv1_class = { .version = LIBAVUTIL_VERSION_INT, }; -#if FF_API_CODER_TYPE -static const AVCodecDefault ffv1_defaults[] = { - { "coder", "-1" }, - { NULL }, -}; -#endif - AVCodec ff_ffv1_encoder = { .name = "ffv1", .long_name = NULL_IF_CONFIG_SMALL("FFmpeg video codec #1"), @@ -1344,8 +1309,6 @@ AVCodec ff_ffv1_encoder = { AV_PIX_FMT_NONE }, -#if FF_API_CODER_TYPE - .defaults = ffv1_defaults, -#endif .priv_class = &ffv1_class, + .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, };