Mercurial > libavcodec.hg
comparison h264.c @ 5756:db5a041fd77c libavcodec
Rename MMCO stuff to prepare for h264/PAFF implementation.
patch by Jeff Downs, heydowns a borg d com
original thread:
Subject: [FFmpeg-devel] [PATCH] Implement PAFF in H.264
Date: 18/09/07 20:30
author | andoma |
---|---|
date | Tue, 02 Oct 2007 14:35:20 +0000 |
parents | 0591d5928fe8 |
children | b526d558cb20 |
comparison
equal
deleted
inserted
replaced
5755:b45894d869da | 5756:db5a041fd77c |
---|---|
3226 if((s->avctx->debug&FF_DEBUG_MMCO) && mmco_count==0) | 3226 if((s->avctx->debug&FF_DEBUG_MMCO) && mmco_count==0) |
3227 av_log(h->s.avctx, AV_LOG_DEBUG, "no mmco here\n"); | 3227 av_log(h->s.avctx, AV_LOG_DEBUG, "no mmco here\n"); |
3228 | 3228 |
3229 for(i=0; i<mmco_count; i++){ | 3229 for(i=0; i<mmco_count; i++){ |
3230 if(s->avctx->debug&FF_DEBUG_MMCO) | 3230 if(s->avctx->debug&FF_DEBUG_MMCO) |
3231 av_log(h->s.avctx, AV_LOG_DEBUG, "mmco:%d %d %d\n", h->mmco[i].opcode, h->mmco[i].short_frame_num, h->mmco[i].long_index); | 3231 av_log(h->s.avctx, AV_LOG_DEBUG, "mmco:%d %d %d\n", h->mmco[i].opcode, h->mmco[i].short_pic_num, h->mmco[i].long_arg); |
3232 | 3232 |
3233 switch(mmco[i].opcode){ | 3233 switch(mmco[i].opcode){ |
3234 case MMCO_SHORT2UNUSED: | 3234 case MMCO_SHORT2UNUSED: |
3235 pic= remove_short(h, mmco[i].short_frame_num); | 3235 pic= remove_short(h, mmco[i].short_pic_num); |
3236 if(pic) | 3236 if(pic) |
3237 unreference_pic(h, pic); | 3237 unreference_pic(h, pic); |
3238 else if(s->avctx->debug&FF_DEBUG_MMCO) | 3238 else if(s->avctx->debug&FF_DEBUG_MMCO) |
3239 av_log(h->s.avctx, AV_LOG_DEBUG, "mmco: remove_short() failure\n"); | 3239 av_log(h->s.avctx, AV_LOG_DEBUG, "mmco: remove_short() failure\n"); |
3240 break; | 3240 break; |
3241 case MMCO_SHORT2LONG: | 3241 case MMCO_SHORT2LONG: |
3242 pic= remove_long(h, mmco[i].long_index); | 3242 pic= remove_long(h, mmco[i].long_arg); |
3243 if(pic) unreference_pic(h, pic); | 3243 if(pic) unreference_pic(h, pic); |
3244 | 3244 |
3245 h->long_ref[ mmco[i].long_index ]= remove_short(h, mmco[i].short_frame_num); | 3245 h->long_ref[ mmco[i].long_arg ]= remove_short(h, mmco[i].short_pic_num); |
3246 if (h->long_ref[ mmco[i].long_index ]){ | 3246 if (h->long_ref[ mmco[i].long_arg ]){ |
3247 h->long_ref[ mmco[i].long_index ]->long_ref=1; | 3247 h->long_ref[ mmco[i].long_arg ]->long_ref=1; |
3248 h->long_ref_count++; | 3248 h->long_ref_count++; |
3249 } | 3249 } |
3250 break; | 3250 break; |
3251 case MMCO_LONG2UNUSED: | 3251 case MMCO_LONG2UNUSED: |
3252 pic= remove_long(h, mmco[i].long_index); | 3252 pic= remove_long(h, mmco[i].long_arg); |
3253 if(pic) | 3253 if(pic) |
3254 unreference_pic(h, pic); | 3254 unreference_pic(h, pic); |
3255 else if(s->avctx->debug&FF_DEBUG_MMCO) | 3255 else if(s->avctx->debug&FF_DEBUG_MMCO) |
3256 av_log(h->s.avctx, AV_LOG_DEBUG, "mmco: remove_long() failure\n"); | 3256 av_log(h->s.avctx, AV_LOG_DEBUG, "mmco: remove_long() failure\n"); |
3257 break; | 3257 break; |
3258 case MMCO_LONG: | 3258 case MMCO_LONG: |
3259 pic= remove_long(h, mmco[i].long_index); | 3259 pic= remove_long(h, mmco[i].long_arg); |
3260 if(pic) unreference_pic(h, pic); | 3260 if(pic) unreference_pic(h, pic); |
3261 | 3261 |
3262 h->long_ref[ mmco[i].long_index ]= s->current_picture_ptr; | 3262 h->long_ref[ mmco[i].long_arg ]= s->current_picture_ptr; |
3263 h->long_ref[ mmco[i].long_index ]->long_ref=1; | 3263 h->long_ref[ mmco[i].long_arg ]->long_ref=1; |
3264 h->long_ref_count++; | 3264 h->long_ref_count++; |
3265 | 3265 |
3266 current_is_long=1; | 3266 current_is_long=1; |
3267 break; | 3267 break; |
3268 case MMCO_SET_MAX_LONG: | 3268 case MMCO_SET_MAX_LONG: |
3269 assert(mmco[i].long_index <= 16); | 3269 assert(mmco[i].long_arg <= 16); |
3270 // just remove the long term which index is greater than new max | 3270 // just remove the long term which index is greater than new max |
3271 for(j = mmco[i].long_index; j<16; j++){ | 3271 for(j = mmco[i].long_arg; j<16; j++){ |
3272 pic = remove_long(h, j); | 3272 pic = remove_long(h, j); |
3273 if (pic) unreference_pic(h, pic); | 3273 if (pic) unreference_pic(h, pic); |
3274 } | 3274 } |
3275 break; | 3275 break; |
3276 case MMCO_RESET: | 3276 case MMCO_RESET: |
3311 MpegEncContext * const s = &h->s; | 3311 MpegEncContext * const s = &h->s; |
3312 int i; | 3312 int i; |
3313 | 3313 |
3314 if(h->nal_unit_type == NAL_IDR_SLICE){ //FIXME fields | 3314 if(h->nal_unit_type == NAL_IDR_SLICE){ //FIXME fields |
3315 s->broken_link= get_bits1(gb) -1; | 3315 s->broken_link= get_bits1(gb) -1; |
3316 h->mmco[0].long_index= get_bits1(gb) - 1; // current_long_term_idx | 3316 h->mmco[0].long_arg= get_bits1(gb) - 1; // current_long_term_idx |
3317 if(h->mmco[0].long_index == -1) | 3317 if(h->mmco[0].long_arg == -1) |
3318 h->mmco_index= 0; | 3318 h->mmco_index= 0; |
3319 else{ | 3319 else{ |
3320 h->mmco[0].opcode= MMCO_LONG; | 3320 h->mmco[0].opcode= MMCO_LONG; |
3321 h->mmco_index= 1; | 3321 h->mmco_index= 1; |
3322 } | 3322 } |
3325 for(i= 0; i<MAX_MMCO_COUNT; i++) { | 3325 for(i= 0; i<MAX_MMCO_COUNT; i++) { |
3326 MMCOOpcode opcode= get_ue_golomb(gb); | 3326 MMCOOpcode opcode= get_ue_golomb(gb); |
3327 | 3327 |
3328 h->mmco[i].opcode= opcode; | 3328 h->mmco[i].opcode= opcode; |
3329 if(opcode==MMCO_SHORT2UNUSED || opcode==MMCO_SHORT2LONG){ | 3329 if(opcode==MMCO_SHORT2UNUSED || opcode==MMCO_SHORT2LONG){ |
3330 h->mmco[i].short_frame_num= (h->frame_num - get_ue_golomb(gb) - 1) & ((1<<h->sps.log2_max_frame_num)-1); //FIXME fields | 3330 h->mmco[i].short_pic_num= (h->frame_num - get_ue_golomb(gb) - 1) & ((1<<h->sps.log2_max_frame_num)-1); //FIXME fields |
3331 /* if(h->mmco[i].short_frame_num >= h->short_ref_count || h->short_ref[ h->mmco[i].short_frame_num ] == NULL){ | 3331 /* if(h->mmco[i].short_pic_num >= h->short_ref_count || h->short_ref[ h->mmco[i].short_pic_num ] == NULL){ |
3332 av_log(s->avctx, AV_LOG_ERROR, "illegal short ref in memory management control operation %d\n", mmco); | 3332 av_log(s->avctx, AV_LOG_ERROR, "illegal short ref in memory management control operation %d\n", mmco); |
3333 return -1; | 3333 return -1; |
3334 }*/ | 3334 }*/ |
3335 } | 3335 } |
3336 if(opcode==MMCO_SHORT2LONG || opcode==MMCO_LONG2UNUSED || opcode==MMCO_LONG || opcode==MMCO_SET_MAX_LONG){ | 3336 if(opcode==MMCO_SHORT2LONG || opcode==MMCO_LONG2UNUSED || opcode==MMCO_LONG || opcode==MMCO_SET_MAX_LONG){ |
3337 unsigned int long_index= get_ue_golomb(gb); | 3337 unsigned int long_index= get_ue_golomb(gb); |
3338 if(/*h->mmco[i].long_index >= h->long_ref_count || h->long_ref[ h->mmco[i].long_index ] == NULL*/ long_index >= 16){ | 3338 if(/*h->mmco[i].long_arg >= h->long_ref_count || h->long_ref[ h->mmco[i].long_arg ] == NULL*/ long_index >= 16){ |
3339 av_log(h->s.avctx, AV_LOG_ERROR, "illegal long ref in memory management control operation %d\n", opcode); | 3339 av_log(h->s.avctx, AV_LOG_ERROR, "illegal long ref in memory management control operation %d\n", opcode); |
3340 return -1; | 3340 return -1; |
3341 } | 3341 } |
3342 h->mmco[i].long_index= long_index; | 3342 h->mmco[i].long_arg= long_index; |
3343 } | 3343 } |
3344 | 3344 |
3345 if(opcode > (unsigned)MMCO_LONG){ | 3345 if(opcode > (unsigned)MMCO_LONG){ |
3346 av_log(h->s.avctx, AV_LOG_ERROR, "illegal memory management control operation %d\n", opcode); | 3346 av_log(h->s.avctx, AV_LOG_ERROR, "illegal memory management control operation %d\n", opcode); |
3347 return -1; | 3347 return -1; |
3353 }else{ | 3353 }else{ |
3354 assert(h->long_ref_count + h->short_ref_count <= h->sps.ref_frame_count); | 3354 assert(h->long_ref_count + h->short_ref_count <= h->sps.ref_frame_count); |
3355 | 3355 |
3356 if(h->long_ref_count + h->short_ref_count == h->sps.ref_frame_count){ //FIXME fields | 3356 if(h->long_ref_count + h->short_ref_count == h->sps.ref_frame_count){ //FIXME fields |
3357 h->mmco[0].opcode= MMCO_SHORT2UNUSED; | 3357 h->mmco[0].opcode= MMCO_SHORT2UNUSED; |
3358 h->mmco[0].short_frame_num= h->short_ref[ h->short_ref_count - 1 ]->frame_num; | 3358 h->mmco[0].short_pic_num= h->short_ref[ h->short_ref_count - 1 ]->frame_num; |
3359 h->mmco_index= 1; | 3359 h->mmco_index= 1; |
3360 }else | 3360 }else |
3361 h->mmco_index= 0; | 3361 h->mmco_index= 0; |
3362 } | 3362 } |
3363 } | 3363 } |