comparison h264.c @ 7393:309c59802769 libavcodec

Merge oddly duplicated remove_long/remove_long_at_index() function.
author michael
date Fri, 25 Jul 2008 12:56:58 +0000
parents 95787edebd24
children 4ac8769cbb01
comparison
equal deleted inserted replaced
7392:95787edebd24 7393:309c59802769
59 59
60 static void svq3_luma_dc_dequant_idct_c(DCTELEM *block, int qp); 60 static void svq3_luma_dc_dequant_idct_c(DCTELEM *block, int qp);
61 static void svq3_add_idct_c(uint8_t *dst, DCTELEM *block, int stride, int qp, int dc); 61 static void svq3_add_idct_c(uint8_t *dst, DCTELEM *block, int stride, int qp, int dc);
62 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); 62 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);
63 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); 63 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);
64 static void remove_long_at_index(H264Context *h, int i); 64 static Picture * remove_long(H264Context *h, int i);
65 65
66 static av_always_inline uint32_t pack16to32(int a, int b){ 66 static av_always_inline uint32_t pack16to32(int a, int b){
67 #ifdef WORDS_BIGENDIAN 67 #ifdef WORDS_BIGENDIAN
68 return (b&0xFFFF) + (a<<16); 68 return (b&0xFFFF) + (a<<16);
69 #else 69 #else
3297 int i; 3297 int i;
3298 3298
3299 for(i=0; i<16; i++){ 3299 for(i=0; i<16; i++){
3300 if (h->long_ref[i] != NULL) { 3300 if (h->long_ref[i] != NULL) {
3301 unreference_pic(h, h->long_ref[i], 0); 3301 unreference_pic(h, h->long_ref[i], 0);
3302 remove_long_at_index(h, i); 3302 remove_long(h, i);
3303 } 3303 }
3304 } 3304 }
3305 assert(h->long_ref_count==0); 3305 assert(h->long_ref_count==0);
3306 3306
3307 for(i=0; i<h->short_ref_count; i++){ 3307 for(i=0; i<h->short_ref_count; i++){
3388 return pic; 3388 return pic;
3389 } 3389 }
3390 3390
3391 /** 3391 /**
3392 * Remove a picture from the long term reference list by its index in 3392 * Remove a picture from the long term reference list by its index in
3393 * that list. This does no checking on the provided index; it is assumed 3393 * that list.
3394 * to be valid. The removed entry is set to NULL. Other entries are unaffected.
3395 * @param i index into h->long_ref of picture to remove.
3396 */
3397 static void remove_long_at_index(H264Context *h, int i){
3398 assert(h->long_ref[i]->long_ref == 1);
3399 h->long_ref[i]->long_ref= 0;
3400 h->long_ref[i]= NULL;
3401 h->long_ref_count--;
3402 }
3403
3404 /**
3405 *
3406 * @return the removed picture or NULL if an error occurs 3394 * @return the removed picture or NULL if an error occurs
3407 */ 3395 */
3408 static Picture * remove_long(H264Context *h, int i){ 3396 static Picture * remove_long(H264Context *h, int i){
3409 Picture *pic; 3397 Picture *pic;
3410 3398
3411 pic= h->long_ref[i]; 3399 pic= h->long_ref[i];
3412 if (pic) 3400 if (pic){
3413 remove_long_at_index(h, i); 3401 assert(h->long_ref[i]->long_ref == 1);
3402 h->long_ref[i]->long_ref= 0;
3403 h->long_ref[i]= NULL;
3404 h->long_ref_count--;
3405 }
3414 3406
3415 return pic; 3407 return pic;
3416 } 3408 }
3417 3409
3418 /** 3410 /**
3495 case MMCO_LONG2UNUSED: 3487 case MMCO_LONG2UNUSED:
3496 j = pic_num_extract(h, mmco[i].long_arg, &structure); 3488 j = pic_num_extract(h, mmco[i].long_arg, &structure);
3497 pic = h->long_ref[j]; 3489 pic = h->long_ref[j];
3498 if (pic) { 3490 if (pic) {
3499 if (unreference_pic(h, pic, structure ^ PICT_FRAME)) 3491 if (unreference_pic(h, pic, structure ^ PICT_FRAME))
3500 remove_long_at_index(h, j); 3492 remove_long(h, j);
3501 } else if(s->avctx->debug&FF_DEBUG_MMCO) 3493 } else if(s->avctx->debug&FF_DEBUG_MMCO)
3502 av_log(h->s.avctx, AV_LOG_DEBUG, "mmco: unref long failure\n"); 3494 av_log(h->s.avctx, AV_LOG_DEBUG, "mmco: unref long failure\n");
3503 break; 3495 break;
3504 case MMCO_LONG: 3496 case MMCO_LONG:
3505 // Comment below left from previous code as it is an interresting note. 3497 // Comment below left from previous code as it is an interresting note.
3597 if (h->long_ref[i]) 3589 if (h->long_ref[i])
3598 break; 3590 break;
3599 3591
3600 assert(i < 16); 3592 assert(i < 16);
3601 pic = h->long_ref[i]; 3593 pic = h->long_ref[i];
3602 remove_long_at_index(h, i); 3594 remove_long(h, i);
3603 } else { 3595 } else {
3604 pic = h->short_ref[h->short_ref_count - 1]; 3596 pic = h->short_ref[h->short_ref_count - 1];
3605 remove_short_at_index(h, h->short_ref_count - 1); 3597 remove_short_at_index(h, h->short_ref_count - 1);
3606 } 3598 }
3607 unreference_pic(h, pic, 0); 3599 unreference_pic(h, pic, 0);