Hi, On Sun, Jul 1, 2012 at 9:46 AM, Martin Storsjö <[email protected]> wrote: > On Sat, 30 Jun 2012, Ronald S. Bultje wrote: > >> From: "Ronald S. Bultje" <[email protected]> >> >> --- >> libavcodec/snow.c | 4 ++++ >> libavcodec/snow.h | 3 ++- >> libavcodec/snowenc.c | 2 +- >> 3 files changed, 7 insertions(+), 2 deletions(-) >> >> diff --git a/libavcodec/snow.c b/libavcodec/snow.c >> index edd7d07..870bbef 100644 >> --- a/libavcodec/snow.c >> +++ b/libavcodec/snow.c >> @@ -386,6 +386,7 @@ av_cold int ff_snow_common_init(AVCodecContext >> *avctx){ >> SnowContext *s = avctx->priv_data; >> int width, height; >> int i, j; >> + int emu_buf_size; >> >> s->avctx= avctx; >> s->max_ref_frames=1; //just make sure its not an invalid value in case >> of no initial keyframe >> @@ -449,6 +450,8 @@ av_cold int ff_snow_common_init(AVCodecContext >> *avctx){ >> >> s->avctx->get_buffer(s->avctx, &s->mconly_picture); >> s->scratchbuf = av_malloc(s->mconly_picture.linesize[0]*7*MB_SIZE); >> + emu_buf_size = s->mconly_picture.linesize[0] * (2 * MB_SIZE + >> HTAPS_MAX - 1); >> + s->emu_edge_buffer = av_malloc(emu_buf_size); >> >> return 0; >> } >> @@ -632,6 +635,7 @@ av_cold void ff_snow_common_end(SnowContext *s) >> >> av_freep(&s->block); >> av_freep(&s->scratchbuf); >> + av_freep(&s->emu_edge_buffer); >> >> for(i=0; i<MAX_REF_FRAMES; i++){ >> av_freep(&s->ref_mvs[i]); >> diff --git a/libavcodec/snow.h b/libavcodec/snow.h >> index 3ceb6af..05f1eba 100644 >> --- a/libavcodec/snow.h >> +++ b/libavcodec/snow.h >> @@ -164,6 +164,7 @@ typedef struct SnowContext{ >> MpegEncContext m; // needed for motion estimation, should not be used >> for anything else, the idea is to eventually make the motion estimation >> independent of MpegEncContext, so this will be removed then (FIXME/XXX) >> >> uint8_t *scratchbuf; >> + uint8_t *emu_edge_buffer; >> }SnowContext; >> >> /* Tables */ >> @@ -284,7 +285,7 @@ static av_always_inline void add_yblock(SnowContext >> *s, int sliced, slice_buffer >> BlockNode *rb= lb+1; >> uint8_t *block[4]; >> int tmp_step= src_stride >= 7*MB_SIZE ? MB_SIZE : MB_SIZE*src_stride; >> - uint8_t *tmp = s->scratchbuf; >> + uint8_t *tmp = s->emu_edge_buffer; >> uint8_t *ptmp; >> int x,y; >> > > If I drop this hunk, it works fine.
I'm not quite sure why, I suppose we don't allocate enough memory then? This hunk is not unrelated, "tmp" here is the same function argument as the VLA in the encoder that this patch replaces, and thus should be identical. Since scratchbuf is much bigger, the idea is to use this one in encoder and decoder, and use scratchbuf (the bigger one) only in the encoder where the bigger buffer is required (for something entirely different, another function argument to the same function, basically, see the encoder). Does valgrind tell you anything? Ronald _______________________________________________ libav-devel mailing list [email protected] https://lists.libav.org/mailman/listinfo/libav-devel
