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
68 unsigned me_cache_generation;68 unsigned me_cache_generation;
69 69
70 uint64_t encoding_error[SNOW_MAX_PLANES];70 uint64_t encoding_error[SNOW_MAX_PLANES];
71
72 IDWTELEM obmc_scratchpad[MB_SIZE * MB_SIZE * 12 * 2];
71} SnowEncContext;73} SnowEncContext;
72 74
73static void init_ref(MotionEstContext *c, const uint8_t *const src[3],75static 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
234 236
235 mpv->me.temp =237 mpv->me.temp =
236 mpv->me.scratchpad = av_calloc(avctx->width + 64, 2*16*2*sizeof(uint8_t));238 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));239 if (!mpv->me.scratchpad)
238 if (!mpv->me.scratchpad || !mpv->c.sc.obmc_scratchpad)
239 return AVERROR(ENOMEM);240 return AVERROR(ENOMEM);
240 241
241 mpv->me.mv_penalty = ff_h263_get_mv_penalty();242 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
670 const int obmc_stride= plane_index ? (2*block_size)>>s->chroma_h_shift : 2*block_size;671 const int obmc_stride= plane_index ? (2*block_size)>>s->chroma_h_shift : 2*block_size;
671 const int ref_stride= s->current_picture->linesize[plane_index];672 const int ref_stride= s->current_picture->linesize[plane_index];
672 const uint8_t *src = s->input_picture->data[plane_index];673 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 unsigned674 IDWTELEM *dst = enc->obmc_scratchpad + plane_index * block_size * block_size * 4; //FIXME change to unsigned
674 const int b_stride = s->b_width << s->block_max_depth;675 const int b_stride = s->b_width << s->block_max_depth;
675 const int w= p->width;676 const int w= p->width;
676 const int h= p->height;677 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
768 const int ref_stride= s->current_picture->linesize[plane_index];769 const int ref_stride= s->current_picture->linesize[plane_index];
769 uint8_t *dst= s->current_picture->data[plane_index];770 uint8_t *dst= s->current_picture->data[plane_index];
770 const uint8_t *src = s->input_picture->data[plane_index];771 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;
772 uint8_t *cur = s->scratchbuf;773 uint8_t *cur = s->scratchbuf;
773 uint8_t *tmp = s->emu_edge_buffer;774 uint8_t *tmp = s->emu_edge_buffer;
774 const int b_stride = s->b_width << s->block_max_depth;775 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
2091 2092
2092 enc->m.s.me.temp = NULL;2093 enc->m.s.me.temp = NULL;
2093 av_freep(&enc->m.s.me.scratchpad);2094 av_freep(&enc->m.s.me.scratchpad);
2094 av_freep(&enc->m.s.c.sc.obmc_scratchpad);
2095 2095
2096 av_freep(&avctx->stats_out);2096 av_freep(&avctx->stats_out);
2097 2097

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