History

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.)

Andreas Rheinhardt committed 1 year ago

Commit 8e070e11 parent f80a9391 file · +5 −5Browse files

Unified · Split

libavcodec/snowenc.c+5−5
@@ -68,6 +68,8 @@ typedef struct SnowEncContext { · 67 unmodified lines
6868 unsigned me_cache_generation;
6969
7070 uint64_t encoding_error[SNOW_MAX_PLANES];
71+
72+ IDWTELEM obmc_scratchpad[MB_SIZE * MB_SIZE * 12 * 2];
7173 } SnowEncContext;
7274
7375 static void init_ref(MotionEstContext *c, const uint8_t *const src[3],
@@ -234,8 +236,7 @@ static av_cold int encode_init(AVCodecContext *avctx) · 160 unmodified lines
234236
235237 mpv->me.temp =
236238 mpv->me.scratchpad = av_calloc(avctx->width + 64, 2*16*2*sizeof(uint8_t));
237− mpv->c.sc.obmc_scratchpad = av_mallocz(MB_SIZE*MB_SIZE*12*sizeof(uint32_t));
238− if (!mpv->me.scratchpad || !mpv->c.sc.obmc_scratchpad)
239+ if (!mpv->me.scratchpad)
239240 return AVERROR(ENOMEM);
240241
241242 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) · 428 unmodified lines
670671 const int obmc_stride= plane_index ? (2*block_size)>>s->chroma_h_shift : 2*block_size;
671672 const int ref_stride= s->current_picture->linesize[plane_index];
672673 const uint8_t *src = s->input_picture->data[plane_index];
673− IDWTELEM *dst = (IDWTELEM*)enc->m.s.c.sc.obmc_scratchpad + plane_index * block_size * block_size * 4; //FIXME change to unsigned
674+ IDWTELEM *dst = enc->obmc_scratchpad + plane_index * block_size * block_size * 4; //FIXME change to unsigned
674675 const int b_stride = s->b_width << s->block_max_depth;
675676 const int w= p->width;
676677 const int h= p->height;
@@ -768,7 +769,7 @@ static int get_block_rd(SnowEncContext *enc, int mb_x, int mb_y, · 91 unmodified lines
768769 const int ref_stride= s->current_picture->linesize[plane_index];
769770 uint8_t *dst= s->current_picture->data[plane_index];
770771 const uint8_t *src = s->input_picture->data[plane_index];
771− IDWTELEM *pred = (IDWTELEM*)enc->m.s.c.sc.obmc_scratchpad + plane_index * block_size * block_size * 4;
772+ IDWTELEM *pred = enc->obmc_scratchpad + plane_index * block_size * block_size * 4;
772773 uint8_t *cur = s->scratchbuf;
773774 uint8_t *tmp = s->emu_edge_buffer;
774775 const int b_stride = s->b_width << s->block_max_depth;
@@ -2091,7 +2092,6 @@ static av_cold int encode_end(AVCodecContext *avctx) · 1316 unmodified lines
20912092
20922093 enc->m.s.me.temp = NULL;
20932094 av_freep(&enc->m.s.me.scratchpad);
2094− av_freep(&enc->m.s.c.sc.obmc_scratchpad);
20952095
20962096 av_freep(&avctx->stats_out);
20972097

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t