aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLynne <dev@lynne.ee>2024-10-13 12:07:27 +0200
committerLynne <dev@lynne.ee>2024-11-18 07:54:22 +0100
commita6c58353ac033798fb799cd761e6a78b4fb12d60 (patch)
tree736ab01d0e28a0a262a9a6081939d3ef4415952d
parent12ea1cde571757ff7219d40eb478f3f8d5f7a371 (diff)
downloadffmpeg-a6c58353ac033798fb799cd761e6a78b4fb12d60.tar.gz
ffv1enc: move slice allocation out of generic encode init
-rw-r--r--libavcodec/ffv1enc.c48
1 files changed, 24 insertions, 24 deletions
diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c
index 3174de8d40..352a0fde13 100644
--- a/libavcodec/ffv1enc.c
+++ b/libavcodec/ffv1enc.c
@@ -738,32 +738,8 @@ av_cold int ff_ffv1_encode_init(AVCodecContext *avctx)
/* Disable slices when the version doesn't support them */
s->num_h_slices = 1;
s->num_v_slices = 1;
- } else {
- if ((ret = encode_determine_slices(avctx)) < 0)
- return ret;
-
- if ((ret = ff_ffv1_write_extradata(avctx)) < 0)
- return ret;
- }
-
- if ((ret = ff_ffv1_init_slice_contexts(s)) < 0)
- return ret;
- s->slice_count = s->max_slice_count;
-
- for (int j = 0; j < s->slice_count; j++) {
- for (int i = 0; i < s->plane_count; i++) {
- PlaneContext *const p = &s->slices[j].plane[i];
-
- p->quant_table_index = s->context_model;
- p->context_count = s->context_count[p->quant_table_index];
- }
-
- ff_build_rac_states(&s->slices[j].c, 0.05 * (1LL << 32), 256 - 8);
}
- if ((ret = ff_ffv1_init_slices_state(s)) < 0)
- return ret;
-
return 0;
}
@@ -942,6 +918,30 @@ static int encode_init_internal(AVCodecContext *avctx)
if (ret < 0)
return ret;
+ if ((ret = encode_determine_slices(avctx)) < 0)
+ return ret;
+
+ if ((ret = ff_ffv1_write_extradata(avctx)) < 0)
+ return ret;
+
+ if ((ret = ff_ffv1_init_slice_contexts(s)) < 0)
+ return ret;
+ s->slice_count = s->max_slice_count;
+
+ for (int j = 0; j < s->slice_count; j++) {
+ for (int i = 0; i < s->plane_count; i++) {
+ PlaneContext *const p = &s->slices[j].plane[i];
+
+ p->quant_table_index = s->context_model;
+ p->context_count = s->context_count[p->quant_table_index];
+ }
+
+ ff_build_rac_states(&s->slices[j].c, 0.05 * (1LL << 32), 256 - 8);
+ }
+
+ if ((ret = ff_ffv1_init_slices_state(s)) < 0)
+ return ret;
+
#define STATS_OUT_SIZE 1024 * 1024 * 6
if (avctx->flags & AV_CODEC_FLAG_PASS1) {
avctx->stats_out = av_mallocz(STATS_OUT_SIZE);