Make remove_short() match remove_long() in that it calls unreference_pic().

Originally committed as revision 14395 to svn://svn.ffmpeg.org/ffmpeg/trunk
pull/126/head
Michael Niedermayer 17 years ago
parent 472c9a58a8
commit d9e3242213
  1. 21
      libavcodec/h264.c

@ -3370,7 +3370,7 @@ static void remove_short_at_index(H264Context *h, int i){
* *
* @return the removed picture or NULL if an error occurs * @return the removed picture or NULL if an error occurs
*/ */
static Picture * remove_short(H264Context *h, int frame_num){ static Picture * remove_short(H264Context *h, int frame_num, int ref_mask){
MpegEncContext * const s = &h->s; MpegEncContext * const s = &h->s;
Picture *pic; Picture *pic;
int i; int i;
@ -3379,8 +3379,10 @@ static Picture * remove_short(H264Context *h, int frame_num){
av_log(h->s.avctx, AV_LOG_DEBUG, "remove short %d count %d\n", frame_num, h->short_ref_count); av_log(h->s.avctx, AV_LOG_DEBUG, "remove short %d count %d\n", frame_num, h->short_ref_count);
pic = find_short(h, frame_num, &i); pic = find_short(h, frame_num, &i);
if (pic) if (pic){
if(unreference_pic(h, pic, ref_mask))
remove_short_at_index(h, i); remove_short_at_index(h, i);
}
return pic; return pic;
} }
@ -3467,14 +3469,14 @@ static int execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count){
case MMCO_SHORT2UNUSED: case MMCO_SHORT2UNUSED:
if(s->avctx->debug&FF_DEBUG_MMCO) if(s->avctx->debug&FF_DEBUG_MMCO)
av_log(h->s.avctx, AV_LOG_DEBUG, "mmco: unref short %d count %d\n", h->mmco[i].short_pic_num, h->short_ref_count); av_log(h->s.avctx, AV_LOG_DEBUG, "mmco: unref short %d count %d\n", h->mmco[i].short_pic_num, h->short_ref_count);
if (unreference_pic(h, pic, structure ^ PICT_FRAME)) remove_short(h, frame_num, structure ^ PICT_FRAME);
remove_short_at_index(h, j);
break; break;
case MMCO_SHORT2LONG: case MMCO_SHORT2LONG:
if (h->long_ref[mmco[i].long_arg] != pic) if (h->long_ref[mmco[i].long_arg] != pic)
remove_long(h, mmco[i].long_arg, 0); remove_long(h, mmco[i].long_arg, 0);
h->long_ref[ mmco[i].long_arg ]= remove_short(h, frame_num); remove_short_at_index(h, j);
h->long_ref[ mmco[i].long_arg ]= pic;
if (h->long_ref[ mmco[i].long_arg ]){ if (h->long_ref[ mmco[i].long_arg ]){
h->long_ref[ mmco[i].long_arg ]->long_ref=1; h->long_ref[ mmco[i].long_arg ]->long_ref=1;
h->long_ref_count++; h->long_ref_count++;
@ -3517,8 +3519,7 @@ static int execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count){
break; break;
case MMCO_RESET: case MMCO_RESET:
while(h->short_ref_count){ while(h->short_ref_count){
pic= remove_short(h, h->short_ref[0]->frame_num); remove_short(h, h->short_ref[0]->frame_num, 0);
if(pic) unreference_pic(h, pic, 0);
} }
for(j = 0; j < 16; j++) { for(j = 0; j < 16; j++) {
remove_long(h, j, 0); remove_long(h, j, 0);
@ -3551,9 +3552,8 @@ static int execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count){
"in complementary field pair " "in complementary field pair "
"(first field is long term)\n"); "(first field is long term)\n");
} else { } else {
pic= remove_short(h, s->current_picture_ptr->frame_num); pic= remove_short(h, s->current_picture_ptr->frame_num, 0);
if(pic){ if(pic){
unreference_pic(h, pic, 0);
av_log(h->s.avctx, AV_LOG_ERROR, "illegal short term buffer state detected\n"); av_log(h->s.avctx, AV_LOG_ERROR, "illegal short term buffer state detected\n");
} }
@ -3585,8 +3585,7 @@ static int execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count){
remove_long(h, i, 0); remove_long(h, i, 0);
} else { } else {
pic = h->short_ref[h->short_ref_count - 1]; pic = h->short_ref[h->short_ref_count - 1];
remove_short_at_index(h, h->short_ref_count - 1); remove_short(h, pic->frame_num, 0);
unreference_pic(h, pic, 0);
} }
} }

Loading…
Cancel
Save