aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2025-03-25 03:35:09 +0100
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2025-03-29 01:42:55 +0100
commit8e070e1a75252eb41d96397b5fe9ea4d77d6c1ff (patch)
tree1a942f9ca462461997fea8288243f067e36a599b
parentf80a939a2e53d536f406f28f13462c981304277a (diff)
downloadffmpeg-8e070e1a75252eb41d96397b5fe9ea4d77d6c1ff.tar.gz
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.rheinhardt@outlook.com>
-rw-r--r--libavcodec/snowenc.c10
1 files 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);