MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / encode_init_internal

Function encode_init_internal

libavcodec/ffv1enc.c:977–1071  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

975}
976
977static av_cold int encode_init_internal(AVCodecContext *avctx)
978{
979 int ret;
980 FFV1Context *s = avctx->priv_data;
981
982 if ((ret = ff_ffv1_common_init(avctx, s)) < 0)
983 return ret;
984
985 if (s->ac == 1) // Compatibility with common command line usage
986 s->ac = AC_RANGE_CUSTOM_TAB;
987 else if (s->ac == AC_RANGE_DEFAULT_TAB_FORCE)
988 s->ac = AC_RANGE_DEFAULT_TAB;
989
990 ret = ff_ffv1_encode_setup_plane_info(avctx, avctx->pix_fmt);
991 if (ret < 0)
992 return ret;
993
994 if (s->bits_per_raw_sample > (s->version > 3 ? 16 : 8) && !s->remap_mode) {
995 if (s->ac == AC_GOLOMB_RICE) {
996 av_log(avctx, AV_LOG_INFO,
997 "high bits_per_raw_sample, forcing range coder\n");
998 s->ac = AC_RANGE_CUSTOM_TAB;
999 }
1000 }
1001
1002
1003 ret = ff_ffv1_encode_init(avctx);
1004 if (ret < 0)
1005 return ret;
1006
1007 if (s->version > 1) {
1008 if ((ret = ff_ffv1_encode_determine_slices(avctx)) < 0)
1009 return ret;
1010
1011 if ((ret = ff_ffv1_write_extradata(avctx)) < 0)
1012 return ret;
1013 }
1014
1015 if ((ret = ff_ffv1_init_slice_contexts(s)) < 0)
1016 return ret;
1017 s->slice_count = s->max_slice_count;
1018
1019 for (int j = 0; j < s->slice_count; j++) {
1020 FFV1SliceContext *sc = &s->slices[j];
1021
1022 for (int i = 0; i < s->plane_count; i++) {
1023 PlaneContext *const p = &s->slices[j].plane[i];
1024
1025 p->quant_table_index = s->context_model;
1026 p->context_count = s->context_count[p->quant_table_index];
1027 }
1028 av_assert0(s->remap_mode >= 0);
1029 if (s->remap_mode) {
1030 for (int p = 0; p < 1 + 2*s->chroma_planes + s->transparency ; p++) {
1031 if (s->bits_per_raw_sample == 32) {
1032 sc->unit[p] = av_malloc_array(sc->slice_width, sc->slice_height * sizeof(**sc->unit));
1033 if (!sc->unit[p])
1034 return AVERROR(ENOMEM);

Callers

nothing calls this directly

Calls 11

ff_ffv1_common_initFunction · 0.85
av_logFunction · 0.85
ff_ffv1_encode_initFunction · 0.85
ff_ffv1_write_extradataFunction · 0.85
av_malloc_arrayFunction · 0.85
ff_build_rac_statesFunction · 0.85
av_malloczFunction · 0.50

Tested by

no test coverage detected