Commit c29457f2 authored by michael's avatar michael

Factorize release_buffer()


git-svn-id: file:///var/local/repositories/ffmpeg/trunk@18397 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent dddfcd3a
...@@ -4167,6 +4167,18 @@ static int frame_start(SnowContext *s){ ...@@ -4167,6 +4167,18 @@ static int frame_start(SnowContext *s){
return 0; return 0;
} }
static void release_buffer(AVCodecContext *avctx){
SnowContext *s = avctx->priv_data;
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]);
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]));
}
}
static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data){ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data){
SnowContext *s = avctx->priv_data; SnowContext *s = avctx->priv_data;
RangeCoder * const c= &s->c; RangeCoder * const c= &s->c;
...@@ -4415,12 +4427,7 @@ redo_frame: ...@@ -4415,12 +4427,7 @@ redo_frame:
update_last_header_values(s); update_last_header_values(s);
if(s->last_picture[s->max_ref_frames-1].data[0]){ release_buffer(avctx);
avctx->release_buffer(avctx, &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]));
}
s->current_picture.coded_picture_number = avctx->frame_number; s->current_picture.coded_picture_number = avctx->frame_number;
s->current_picture.pict_type = pict->pict_type; s->current_picture.pict_type = pict->pict_type;
...@@ -4506,7 +4513,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac ...@@ -4506,7 +4513,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
RangeCoder * const c= &s->c; RangeCoder * const c= &s->c;
int bytes_read; int bytes_read;
AVFrame *picture = data; AVFrame *picture = data;
int level, orientation, plane_index, i; int level, orientation, plane_index;
ff_init_range_decoder(c, buf, buf_size); ff_init_range_decoder(c, buf, buf_size);
ff_build_rac_states(c, 0.05*(1LL<<32), 256-8); ff_build_rac_states(c, 0.05*(1LL<<32), 256-8);
...@@ -4645,12 +4652,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac ...@@ -4645,12 +4652,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
emms_c(); emms_c();
if(s->last_picture[s->max_ref_frames-1].data[0]){ release_buffer(avctx);
avctx->release_buffer(avctx, &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]));
}
if(!(s->avctx->debug&2048)) if(!(s->avctx->debug&2048))
*picture= s->current_picture; *picture= s->current_picture;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment