mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
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>
This commit is contained in:
parent
93d672967d
commit
5eb4af6c59
@ -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
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user