diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-07-04 00:55:00 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-07-04 01:02:01 +0200 |
commit | 5eb4af6c5942735b02adf0fac3e9d4cb55b09785 (patch) | |
tree | e2e3680e598d5bf5cc5935a5c637478506f3077f | |
parent | 93d672967d05f9769bbeb2ac6ceb8cbde302c273 (diff) | |
download | ffmpeg-5eb4af6c5942735b02adf0fac3e9d4cb55b09785.tar.gz |
snow: move init code that depends on picture paramaters to after these parameters are known.
This should fix debug 2048 amongth other things
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | libavcodec/snow.c | 29 | ||||
-rw-r--r-- | libavcodec/snowdec.c | 3 |
2 files changed, 21 insertions, 11 deletions
diff --git a/libavcodec/snow.c b/libavcodec/snow.c index 04072501ad..a4fe8b603a 100644 --- a/libavcodec/snow.c +++ b/libavcodec/snow.c @@ -394,8 +394,7 @@ mca( 8, 8,8) av_cold int ff_snow_common_init(AVCodecContext *avctx){ SnowContext *s = avctx->priv_data; int width, height; - int i, j, ret; - int emu_buf_size; + int i, j; s->avctx= avctx; s->max_ref_frames=1; //just make sure its not an invalid value in case of no initial keyframe @@ -458,14 +457,6 @@ av_cold int ff_snow_common_init(AVCodecContext *avctx){ for(j=0; j<MAX_REF_FRAMES; j++) ff_scale_mv_ref[i][j] = 256*(i+1)/(j+1); - if ((ret = s->avctx->get_buffer(s->avctx, &s->mconly_picture)) < 0) { -// av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed\n"); -// return ret; - } - FF_ALLOCZ_OR_GOTO(avctx, s->scratchbuf, FFMAX(s->mconly_picture.linesize[0], 2*width+256)*7*MB_SIZE, fail); - emu_buf_size = FFMAX(s->mconly_picture.linesize[0], 2*width+256) * (2 * MB_SIZE + HTAPS_MAX - 1); - FF_ALLOC_OR_GOTO(avctx, s->emu_edge_buffer, emu_buf_size, fail); - return 0; fail: return AVERROR(ENOMEM); @@ -474,6 +465,22 @@ fail: int ff_snow_common_init_after_header(AVCodecContext *avctx) { SnowContext *s = avctx->priv_data; int plane_index, level, orientation; + int ret, emu_buf_size; + + if(!s->scratchbuf) { + if ((ret = s->avctx->get_buffer(s->avctx, &s->mconly_picture)) < 0) { + av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed\n"); + return ret; + } + FF_ALLOCZ_OR_GOTO(avctx, s->scratchbuf, FFMAX(s->mconly_picture.linesize[0], 2*avctx->width+256)*7*MB_SIZE, fail); + emu_buf_size = FFMAX(s->mconly_picture.linesize[0], 2*avctx->width+256) * (2 * MB_SIZE + HTAPS_MAX - 1); + FF_ALLOC_OR_GOTO(avctx, s->emu_edge_buffer, emu_buf_size, fail); + } + + if(s->mconly_picture.format != avctx->pix_fmt) { + av_log(avctx, AV_LOG_ERROR, "pixel format changed\n"); + return AVERROR_INVALIDDATA; + } for(plane_index=0; plane_index<3; plane_index++){ int w= s->avctx->width; @@ -522,6 +529,8 @@ int ff_snow_common_init_after_header(AVCodecContext *avctx) { } return 0; +fail: + return AVERROR(ENOMEM); } #define USE_HALFPEL_PLANE 0 diff --git a/libavcodec/snowdec.c b/libavcodec/snowdec.c index 11a54dca71..f3d4656332 100644 --- a/libavcodec/snowdec.c +++ b/libavcodec/snowdec.c @@ -406,7 +406,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac s->current_picture.pict_type= AV_PICTURE_TYPE_I; //FIXME I vs. P if(decode_header(s)<0) return -1; - ff_snow_common_init_after_header(avctx); + if ((res=ff_snow_common_init_after_header(avctx)) < 0) + return res; // realloc slice buffer for the case that spatial_decomposition_count changed ff_slice_buffer_destroy(&s->sb); |