#include "libavutil/opt.h"
#include "libavutil/imgutils.h"
#include "libavutil/pixdesc.h"
-#include "libavutil/timer.h"
#include "avcodec.h"
#include "internal.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];
if((ret = encode_line(s, w, sample, plane_index, s->bits_per_raw_sample)) < 0)
return ret;
}
-// STOP_TIMER("encode line") }
}
return 0;
}
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];
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++) {
put_symbol(c, state, f->intra = (f->avctx->gop_size < 2), 0);
}
- f->avctx->extradata_size = ff_rac_terminate(c);
+ f->avctx->extradata_size = ff_rac_terminate(c, 0);
v = av_crc(av_crc_get_table(AV_CRC_32_IEEE), 0, f->avctx->extradata, f->avctx->extradata_size);
AV_WL32(f->avctx->extradata + f->avctx->extradata_size, v);
f->avctx->extradata_size += 4;
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)
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++)
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)
encode_slice_header(f, fs);
}
if (fs->ac == AC_GOLOMB_RICE) {
- if (f->version > 2)
- put_rac(&fs->c, (uint8_t[]) { 129 }, 0);
- fs->ac_byte_count = f->version > 2 || (!x && !y) ? ff_rac_terminate(&fs->c) : 0;
+ fs->ac_byte_count = f->version > 2 || (!x && !y) ? ff_rac_terminate(&fs->c, f->version > 2) : 0;
init_put_bits(&fs->pb,
fs->c.bytestream_start + fs->ac_byte_count,
fs->c.bytestream_end - fs->c.bytestream_start - fs->ac_byte_count);
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);
int bytes;
if (fs->ac != AC_GOLOMB_RICE) {
- uint8_t state = 129;
- put_rac(&fs->c, &state, 0);
- bytes = ff_rac_terminate(&fs->c);
+ 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);
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 =
.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"),
AV_PIX_FMT_NONE
},
-#if FF_API_CODER_TYPE
- .defaults = ffv1_defaults,
-#endif
.priv_class = &ffv1_class,
+ .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
};