Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libavcodec/snow.c29
-rw-r--r--libavcodec/snowdec.c3
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);