ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinha...@outlook.com> | 
Tue Mar 25 03:35:09 2025 +0100| [8e070e1a75252eb41d96397b5fe9ea4d77d6c1ff] | 
committer: Andreas Rheinhardt

avcodec/snowenc: Don't allocate obmc_scratchpad separately

Put it into SnowEncContext instead. Also use the proper type
(it is only used as IDWTELEM aka short).

(The allocation code allocated it in units of uint32_t,
yet it was never used in this way. I made the array so big
that the size (in bytes) does not change.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinha...@outlook.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8e070e1a75252eb41d96397b5fe9ea4d77d6c1ff
---

 libavcodec/snowenc.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/libavcodec/snowenc.c b/libavcodec/snowenc.c
index 7818c79fa6..8e7712fe5f 100644
--- a/libavcodec/snowenc.c
+++ b/libavcodec/snowenc.c
@@ -68,6 +68,8 @@ typedef struct SnowEncContext {
     unsigned me_cache_generation;
 
     uint64_t encoding_error[SNOW_MAX_PLANES];
+
+    IDWTELEM obmc_scratchpad[MB_SIZE * MB_SIZE * 12 * 2];
 } SnowEncContext;
 
 static void init_ref(MotionEstContext *c, const uint8_t *const src[3],
@@ -234,8 +236,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
 
     mpv->me.temp      =
     mpv->me.scratchpad = av_calloc(avctx->width + 64, 2*16*2*sizeof(uint8_t));
-    mpv->c.sc.obmc_scratchpad = 
av_mallocz(MB_SIZE*MB_SIZE*12*sizeof(uint32_t));
-    if (!mpv->me.scratchpad || !mpv->c.sc.obmc_scratchpad)
+    if (!mpv->me.scratchpad)
         return AVERROR(ENOMEM);
 
     mpv->me.mv_penalty = ff_h263_get_mv_penalty();
@@ -670,7 +671,7 @@ static int get_dc(SnowEncContext *enc, int mb_x, int mb_y, 
int plane_index)
     const int obmc_stride= plane_index ? (2*block_size)>>s->chroma_h_shift : 
2*block_size;
     const int ref_stride= s->current_picture->linesize[plane_index];
     const uint8_t *src = s->input_picture->data[plane_index];
-    IDWTELEM *dst = (IDWTELEM*)enc->m.s.c.sc.obmc_scratchpad + plane_index * 
block_size * block_size * 4; //FIXME change to unsigned
+    IDWTELEM *dst = enc->obmc_scratchpad + plane_index * block_size * 
block_size * 4; //FIXME change to unsigned
     const int b_stride = s->b_width << s->block_max_depth;
     const int w= p->width;
     const int h= p->height;
@@ -768,7 +769,7 @@ static int get_block_rd(SnowEncContext *enc, int mb_x, int 
mb_y,
     const int ref_stride= s->current_picture->linesize[plane_index];
     uint8_t *dst= s->current_picture->data[plane_index];
     const uint8_t *src = s->input_picture->data[plane_index];
-    IDWTELEM *pred = (IDWTELEM*)enc->m.s.c.sc.obmc_scratchpad + plane_index * 
block_size * block_size * 4;
+    IDWTELEM *pred = enc->obmc_scratchpad + plane_index * block_size * 
block_size * 4;
     uint8_t *cur = s->scratchbuf;
     uint8_t *tmp = s->emu_edge_buffer;
     const int b_stride = s->b_width << s->block_max_depth;
@@ -2091,7 +2092,6 @@ static av_cold int encode_end(AVCodecContext *avctx)
 
     enc->m.s.me.temp = NULL;
     av_freep(&enc->m.s.me.scratchpad);
-    av_freep(&enc->m.s.c.sc.obmc_scratchpad);
 
     av_freep(&avctx->stats_out);
 

_______________________________________________
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to