[FFmpeg-devel] [PATCH v2 5/6] ffv1enc: move slice allocation out of generic encode init
Lynne
dev at lynne.ee
Mon Nov 11 05:40:17 EET 2024
---
libavcodec/ffv1enc.c | 36 ++++++++++++++++++------------------
1 file changed, 18 insertions(+), 18 deletions(-)
diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c
index a106e2130a..7572594f3e 100644
--- a/libavcodec/ffv1enc.c
+++ b/libavcodec/ffv1enc.c
@@ -710,24 +710,6 @@ av_cold int ff_ffv1_encode_init(AVCodecContext *avctx)
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;
}
@@ -937,6 +919,24 @@ slices_ok:
if (ret < 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);
--
2.45.2.753.g447d99e1c3b
More information about the ffmpeg-devel
mailing list