This is an automated email from the git hooks/post-receive script. Git pushed a commit to branch master in repository ffmpeg.
commit 23a58c6c3651885ec56e9dc7da1253dd7ba4abd6 Author: Andreas Rheinhardt <[email protected]> AuthorDate: Fri Feb 27 17:55:18 2026 +0100 Commit: Andreas Rheinhardt <[email protected]> CommitDate: Tue Mar 3 13:07:46 2026 +0100 avcodec/h264dec,mpeg_er: Move allocating er buffers to ff_er_init() (This also stops zero-allocating er_temp_buffer for H.264, reverting back to the behavior from before commit 0a1dc817237b8546189960efd523257b4f62e1ab.) Signed-off-by: Andreas Rheinhardt <[email protected]> --- libavcodec/error_resilience.c | 12 +++++++++++- libavcodec/error_resilience.h | 2 +- libavcodec/h264dec.c | 6 +----- libavcodec/mpeg_er.c | 14 +------------- 4 files changed, 14 insertions(+), 20 deletions(-) diff --git a/libavcodec/error_resilience.c b/libavcodec/error_resilience.c index 76d5bfa73b..8cf5bc6a3c 100644 --- a/libavcodec/error_resilience.c +++ b/libavcodec/error_resilience.c @@ -39,12 +39,22 @@ #include "threadframe.h" #include "threadprogress.h" -av_cold void ff_er_init(ERContext *const s) +av_cold int ff_er_init(ERContext *const s) { MECmpContext mecc; + unsigned mb_array_size = s->mb_height * s->mb_stride; + + s->error_status_table = av_mallocz(mb_array_size); + if (!s->error_status_table) + return AVERROR(ENOMEM); + s->er_temp_buffer = av_malloc_array(mb_array_size, 4*sizeof(int) + 1); + if (!s->er_temp_buffer) + return AVERROR(ENOMEM); ff_me_cmp_init(&mecc, s->avctx); s->sad = mecc.sad[0]; + + return 0; } /** diff --git a/libavcodec/error_resilience.h b/libavcodec/error_resilience.h index 6c8736a445..1beae5a6b0 100644 --- a/libavcodec/error_resilience.h +++ b/libavcodec/error_resilience.h @@ -90,7 +90,7 @@ typedef struct ERContext { void *opaque; } ERContext; -void ff_er_init(ERContext *const s); +int ff_er_init(ERContext *const s); void ff_er_frame_start(ERContext *s); diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c index e430bc58fc..809a938386 100644 --- a/libavcodec/h264dec.c +++ b/libavcodec/h264dec.c @@ -220,8 +220,6 @@ int ff_h264_alloc_tables(H264Context *h) } if (CONFIG_ERROR_RESILIENCE) { - const int er_size = h->mb_height * h->mb_stride * (4*sizeof(int) + 1); - int mb_array_size = h->mb_height * h->mb_stride; int y_size = (2 * h->mb_width + 1) * (2 * h->mb_height + 1); int yc_size = y_size + 2 * big_mb_num; @@ -239,8 +237,6 @@ int ff_h264_alloc_tables(H264Context *h) // error resilience code looks cleaner with this if (!FF_ALLOCZ_TYPED_ARRAY(er->mb_index2xy, h->mb_num + 1) || - !FF_ALLOCZ_TYPED_ARRAY(er->error_status_table, mb_array_size) || - !FF_ALLOCZ_TYPED_ARRAY(er->er_temp_buffer, er_size) || !FF_ALLOCZ_TYPED_ARRAY(h->dc_val_base, yc_size)) return AVERROR(ENOMEM); // ff_h264_free_tables will clean up for us @@ -256,7 +252,7 @@ int ff_h264_alloc_tables(H264Context *h) for (int i = 0; i < yc_size; i++) h->dc_val_base[i] = 1024; - ff_er_init(er); + return ff_er_init(er); } return 0; diff --git a/libavcodec/mpeg_er.c b/libavcodec/mpeg_er.c index 93eb9221d7..5bb5ed8441 100644 --- a/libavcodec/mpeg_er.c +++ b/libavcodec/mpeg_er.c @@ -96,7 +96,6 @@ static void mpeg_er_decode_mb(void *opaque, int ref, int mv_dir, int mv_type, av_cold int ff_mpeg_er_init(MpegEncContext *s) { ERContext *er = &s->er; - int mb_array_size = s->mb_height * s->mb_stride; er->avctx = s->avctx; @@ -111,22 +110,11 @@ av_cold int ff_mpeg_er_init(MpegEncContext *s) er->dc_val[1] = er->dc_val[0] + s->b8_stride * 2 * s->buffer_pools.alloc_mb_height + s->mb_stride; er->dc_val[2] = er->dc_val[1] + s->mb_stride * (s->buffer_pools.alloc_mb_height + 1); - er->er_temp_buffer = av_malloc(s->mb_height * s->mb_stride * (4*sizeof(int) + 1)); - er->error_status_table = av_mallocz(mb_array_size); - if (!er->er_temp_buffer || !er->error_status_table) - goto fail; - er->mbskip_table = s->mbskip_table; er->mbintra_table = s->mbintra_table; er->decode_mb = mpeg_er_decode_mb; er->opaque = s; - ff_er_init(er); - - return 0; -fail: - av_freep(&er->er_temp_buffer); - av_freep(&er->error_status_table); - return AVERROR(ENOMEM); + return ff_er_init(er); } _______________________________________________ ffmpeg-cvslog mailing list -- [email protected] To unsubscribe send an email to [email protected]
