comparison snow.c @ 9374:c3a8ca9d0477 libavcodec

Factorize release_buffer()
author michael
date Thu, 09 Apr 2009 20:44:18 +0000
parents 78c2ddc32bed
children 2f04b571d69b
comparison
equal deleted inserted replaced
9373:78c2ddc32bed 9374:c3a8ca9d0477
4165 s->current_picture.key_frame= s->keyframe; 4165 s->current_picture.key_frame= s->keyframe;
4166 4166
4167 return 0; 4167 return 0;
4168 } 4168 }
4169 4169
4170 static void release_buffer(AVCodecContext *avctx){
4171 SnowContext *s = avctx->priv_data;
4172 int i;
4173
4174 if(s->last_picture[s->max_ref_frames-1].data[0]){
4175 avctx->release_buffer(avctx, &s->last_picture[s->max_ref_frames-1]);
4176 for(i=0; i<9; i++)
4177 if(s->halfpel_plane[s->max_ref_frames-1][1+i/3][i%3])
4178 av_free(s->halfpel_plane[s->max_ref_frames-1][1+i/3][i%3] - EDGE_WIDTH*(1+s->current_picture.linesize[i%3]));
4179 }
4180 }
4181
4170 static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data){ 4182 static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data){
4171 SnowContext *s = avctx->priv_data; 4183 SnowContext *s = avctx->priv_data;
4172 RangeCoder * const c= &s->c; 4184 RangeCoder * const c= &s->c;
4173 AVFrame *pict = data; 4185 AVFrame *pict = data;
4174 const int width= s->avctx->width; 4186 const int width= s->avctx->width;
4413 4425
4414 } 4426 }
4415 4427
4416 update_last_header_values(s); 4428 update_last_header_values(s);
4417 4429
4418 if(s->last_picture[s->max_ref_frames-1].data[0]){ 4430 release_buffer(avctx);
4419 avctx->release_buffer(avctx, &s->last_picture[s->max_ref_frames-1]);
4420 for(i=0; i<9; i++)
4421 if(s->halfpel_plane[s->max_ref_frames-1][1+i/3][i%3])
4422 av_free(s->halfpel_plane[s->max_ref_frames-1][1+i/3][i%3] - EDGE_WIDTH*(1+s->current_picture.linesize[i%3]));
4423 }
4424 4431
4425 s->current_picture.coded_picture_number = avctx->frame_number; 4432 s->current_picture.coded_picture_number = avctx->frame_number;
4426 s->current_picture.pict_type = pict->pict_type; 4433 s->current_picture.pict_type = pict->pict_type;
4427 s->current_picture.quality = pict->quality; 4434 s->current_picture.quality = pict->quality;
4428 s->m.frame_bits = 8*(s->c.bytestream - s->c.bytestream_start); 4435 s->m.frame_bits = 8*(s->c.bytestream - s->c.bytestream_start);
4504 int buf_size = avpkt->size; 4511 int buf_size = avpkt->size;
4505 SnowContext *s = avctx->priv_data; 4512 SnowContext *s = avctx->priv_data;
4506 RangeCoder * const c= &s->c; 4513 RangeCoder * const c= &s->c;
4507 int bytes_read; 4514 int bytes_read;
4508 AVFrame *picture = data; 4515 AVFrame *picture = data;
4509 int level, orientation, plane_index, i; 4516 int level, orientation, plane_index;
4510 4517
4511 ff_init_range_decoder(c, buf, buf_size); 4518 ff_init_range_decoder(c, buf, buf_size);
4512 ff_build_rac_states(c, 0.05*(1LL<<32), 256-8); 4519 ff_build_rac_states(c, 0.05*(1LL<<32), 256-8);
4513 4520
4514 s->current_picture.pict_type= FF_I_TYPE; //FIXME I vs. P 4521 s->current_picture.pict_type= FF_I_TYPE; //FIXME I vs. P
4643 4650
4644 } 4651 }
4645 4652
4646 emms_c(); 4653 emms_c();
4647 4654
4648 if(s->last_picture[s->max_ref_frames-1].data[0]){ 4655 release_buffer(avctx);
4649 avctx->release_buffer(avctx, &s->last_picture[s->max_ref_frames-1]);
4650 for(i=0; i<9; i++)
4651 if(s->halfpel_plane[s->max_ref_frames-1][1+i/3][i%3])
4652 av_free(s->halfpel_plane[s->max_ref_frames-1][1+i/3][i%3] - EDGE_WIDTH*(1+s->current_picture.linesize[i%3]));
4653 }
4654 4656
4655 if(!(s->avctx->debug&2048)) 4657 if(!(s->avctx->debug&2048))
4656 *picture= s->current_picture; 4658 *picture= s->current_picture;
4657 else 4659 else
4658 *picture= s->mconly_picture; 4660 *picture= s->mconly_picture;