# HG changeset patch # User michael # Date 1216991346 0 # Node ID 4ac8769cbb01ba6d535db517284c95ef55eb5e50 # Parent 309c5980276927323898b6ef18b19f345b05659b Make remove_long() call unreference_pic() internally. diff -r 309c59802769 -r 4ac8769cbb01 h264.c --- a/h264.c Fri Jul 25 12:56:58 2008 +0000 +++ b/h264.c Fri Jul 25 13:09:06 2008 +0000 @@ -61,7 +61,7 @@ static void svq3_add_idct_c(uint8_t *dst, DCTELEM *block, int stride, int qp, int dc); static void filter_mb( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr, unsigned int linesize, unsigned int uvlinesize); static void filter_mb_fast( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr, unsigned int linesize, unsigned int uvlinesize); -static Picture * remove_long(H264Context *h, int i); +static Picture * remove_long(H264Context *h, int i, int ref_mask); static av_always_inline uint32_t pack16to32(int a, int b){ #ifdef WORDS_BIGENDIAN @@ -3297,10 +3297,7 @@ int i; for(i=0; i<16; i++){ - if (h->long_ref[i] != NULL) { - unreference_pic(h, h->long_ref[i], 0); - remove_long(h, i); - } + remove_long(h, i, 0); } assert(h->long_ref_count==0); @@ -3393,15 +3390,17 @@ * that list. * @return the removed picture or NULL if an error occurs */ -static Picture * remove_long(H264Context *h, int i){ +static Picture * remove_long(H264Context *h, int i, int ref_mask){ Picture *pic; pic= h->long_ref[i]; if (pic){ - assert(h->long_ref[i]->long_ref == 1); - h->long_ref[i]->long_ref= 0; - h->long_ref[i]= NULL; - h->long_ref_count--; + if(unreference_pic(h, pic, ref_mask)){ + assert(h->long_ref[i]->long_ref == 1); + h->long_ref[i]->long_ref= 0; + h->long_ref[i]= NULL; + h->long_ref_count--; + } } return pic; @@ -3474,8 +3473,7 @@ } else { int frame_num = mmco[i].short_pic_num >> FIELD_PICTURE; - pic= remove_long(h, mmco[i].long_arg); - if(pic) unreference_pic(h, pic, 0); + remove_long(h, mmco[i].long_arg, 0); h->long_ref[ mmco[i].long_arg ]= remove_short(h, frame_num); if (h->long_ref[ mmco[i].long_arg ]){ @@ -3488,8 +3486,7 @@ j = pic_num_extract(h, mmco[i].long_arg, &structure); pic = h->long_ref[j]; if (pic) { - if (unreference_pic(h, pic, structure ^ PICT_FRAME)) - remove_long(h, j); + remove_long(h, j, structure ^ PICT_FRAME); } else if(s->avctx->debug&FF_DEBUG_MMCO) av_log(h->s.avctx, AV_LOG_DEBUG, "mmco: unref long failure\n"); break; @@ -3503,8 +3500,7 @@ */ if (h->long_ref[mmco[i].long_arg] != s->current_picture_ptr) { - pic= remove_long(h, mmco[i].long_arg); - if(pic) unreference_pic(h, pic, 0); + remove_long(h, mmco[i].long_arg, 0); h->long_ref[ mmco[i].long_arg ]= s->current_picture_ptr; h->long_ref[ mmco[i].long_arg ]->long_ref=1; @@ -3518,8 +3514,7 @@ assert(mmco[i].long_arg <= 16); // just remove the long term which index is greater than new max for(j = mmco[i].long_arg; j<16; j++){ - pic = remove_long(h, j); - if (pic) unreference_pic(h, pic, 0); + remove_long(h, j, 0); } break; case MMCO_RESET: @@ -3528,8 +3523,7 @@ if(pic) unreference_pic(h, pic, 0); } for(j = 0; j < 16; j++) { - pic= remove_long(h, j); - if(pic) unreference_pic(h, pic, 0); + remove_long(h, j, 0); } s->current_picture_ptr->poc= s->current_picture_ptr->field_poc[0]= @@ -3590,13 +3584,12 @@ break; assert(i < 16); - pic = h->long_ref[i]; - remove_long(h, i); + remove_long(h, i, 0); } else { pic = h->short_ref[h->short_ref_count - 1]; remove_short_at_index(h, h->short_ref_count - 1); - } - unreference_pic(h, pic, 0); + unreference_pic(h, pic, 0); + } } print_short_term(h);