summaryrefslogtreecommitdiff
path: root/libavcodec/snow.c
diff options
context:
space:
mode:
Diffstat (limited to 'libavcodec/snow.c')
-rw-r--r--libavcodec/snow.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/libavcodec/snow.c b/libavcodec/snow.c
index b2c6714a40..126acf3cb5 100644
--- a/libavcodec/snow.c
+++ b/libavcodec/snow.c
@@ -471,7 +471,7 @@ int ff_snow_common_init_after_header(AVCodecContext *avctx) {
int ret, emu_buf_size;
if(!s->scratchbuf) {
- if ((ret = ff_get_buffer(s->avctx, &s->mconly_picture)) < 0) {
+ if ((ret = ff_get_buffer(s->avctx, &s->mconly_picture, AV_GET_BUFFER_FLAG_REF)) < 0) {
av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return ret;
}
@@ -586,7 +586,7 @@ void ff_snow_release_buffer(AVCodecContext *avctx)
int i;
if(s->last_picture[s->max_ref_frames-1].data[0]){
- avctx->release_buffer(avctx, &s->last_picture[s->max_ref_frames-1]);
+ av_frame_unref(&s->last_picture[s->max_ref_frames-1]);
for(i=0; i<9; i++)
if(s->halfpel_plane[s->max_ref_frames-1][1+i/3][i%3])
av_free(s->halfpel_plane[s->max_ref_frames-1][1+i/3][i%3] - EDGE_WIDTH*(1+s->current_picture.linesize[i%3]));
@@ -595,6 +595,7 @@ void ff_snow_release_buffer(AVCodecContext *avctx)
int ff_snow_frame_start(SnowContext *s){
AVFrame tmp;
+ int i;
int w= s->avctx->width; //FIXME round up to x16 ?
int h= s->avctx->height;
@@ -612,13 +613,14 @@ int ff_snow_frame_start(SnowContext *s){
ff_snow_release_buffer(s->avctx);
- tmp= s->last_picture[s->max_ref_frames-1];
- memmove(s->last_picture+1, s->last_picture, (s->max_ref_frames-1)*sizeof(AVFrame));
+ av_frame_move_ref(&tmp, &s->last_picture[s->max_ref_frames-1]);
+ for(i=s->max_ref_frames-1; i>0; i--)
+ av_frame_move_ref(&s->last_picture[i+1], &s->last_picture[i]);
memmove(s->halfpel_plane+1, s->halfpel_plane, (s->max_ref_frames-1)*sizeof(void*)*4*4);
if(USE_HALFPEL_PLANE && s->current_picture.data[0])
halfpel_interpol(s, s->halfpel_plane[0], &s->current_picture);
- s->last_picture[0]= s->current_picture;
- s->current_picture= tmp;
+ av_frame_move_ref(&s->last_picture[0], &s->current_picture);
+ av_frame_move_ref(&s->current_picture, &tmp);
if(s->keyframe){
s->ref_frames= 0;
@@ -634,8 +636,7 @@ int ff_snow_frame_start(SnowContext *s){
}
}
- s->current_picture.reference= 3;
- if(ff_get_buffer(s->avctx, &s->current_picture) < 0){
+ if(ff_get_buffer(s->avctx, &s->current_picture, AV_GET_BUFFER_FLAG_REF) < 0){
av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
@@ -670,7 +671,7 @@ av_cold void ff_snow_common_end(SnowContext *s)
av_freep(&s->ref_scores[i]);
if(s->last_picture[i].data[0]) {
av_assert0(s->last_picture[i].data[0] != s->current_picture.data[0]);
- s->avctx->release_buffer(s->avctx, &s->last_picture[i]);
+ av_frame_unref(&s->last_picture[i]);
}
}
@@ -683,8 +684,6 @@ av_cold void ff_snow_common_end(SnowContext *s)
}
}
}
- if (s->mconly_picture.data[0])
- s->avctx->release_buffer(s->avctx, &s->mconly_picture);
- if (s->current_picture.data[0])
- s->avctx->release_buffer(s->avctx, &s->current_picture);
+ av_frame_unref(&s->mconly_picture);
+ av_frame_unref(&s->current_picture);
}