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.)
Unified · Split
| @@ -68,6 +68,8 @@ typedef struct SnowEncContext { · 67 unmodified lines | ||
| 68 | 68 | unsigned me_cache_generation; |
| 69 | 69 | |
| 70 | 70 | uint64_t encoding_error[SNOW_MAX_PLANES]; |
| 71 | + | |
| 72 | + IDWTELEM obmc_scratchpad[MB_SIZE * MB_SIZE * 12 * 2]; | |
| 71 | 73 | } SnowEncContext; |
| 72 | 74 | |
| 73 | 75 | 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 | ||
| 234 | 236 | |
| 235 | 237 | mpv->me.temp = |
| 236 | 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)); | |
| 238 | − if (!mpv->me.scratchpad || !mpv->c.sc.obmc_scratchpad) | |
| 239 | + if (!mpv->me.scratchpad) | |
| 239 | 240 | return AVERROR(ENOMEM); |
| 240 | 241 | |
| 241 | 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 | 671 | const int obmc_stride= plane_index ? (2*block_size)>>s->chroma_h_shift : 2*block_size; |
| 671 | 672 | const int ref_stride= s->current_picture->linesize[plane_index]; |
| 672 | 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 unsigned | |
| 674 | + IDWTELEM *dst = enc->obmc_scratchpad + plane_index * block_size * block_size * 4; //FIXME change to unsigned | |
| 674 | 675 | const int b_stride = s->b_width << s->block_max_depth; |
| 675 | 676 | const int w= p->width; |
| 676 | 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 | 769 | const int ref_stride= s->current_picture->linesize[plane_index]; |
| 769 | 770 | uint8_t *dst= s->current_picture->data[plane_index]; |
| 770 | 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 | 773 | uint8_t *cur = s->scratchbuf; |
| 773 | 774 | uint8_t *tmp = s->emu_edge_buffer; |
| 774 | 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 | 2093 | enc->m.s.me.temp = NULL; |
| 2093 | 2094 | av_freep(&enc->m.s.me.scratchpad); |
| 2094 | − av_freep(&enc->m.s.c.sc.obmc_scratchpad); | |
| 2095 | 2095 | |
| 2096 | 2096 | av_freep(&avctx->stats_out); |
| 2097 | 2097 | |