Mercurial > libavcodec.hg
comparison h264.c @ 7383:c4e5f2158b20 libavcodec
Simplify strange obfuscated code in MMCO_LONG handling.
Note, this might change behavior for invalid bitstreams.
author | michael |
---|---|
date | Fri, 25 Jul 2008 00:13:02 +0000 |
parents | f9e70983fc35 |
children | 8b9a02536781 |
comparison
equal
deleted
inserted
replaced
7382:f9e70983fc35 | 7383:c4e5f2158b20 |
---|---|
3452 | 3452 |
3453 if((s->avctx->debug&FF_DEBUG_MMCO) && mmco_count==0) | 3453 if((s->avctx->debug&FF_DEBUG_MMCO) && mmco_count==0) |
3454 av_log(h->s.avctx, AV_LOG_DEBUG, "no mmco here\n"); | 3454 av_log(h->s.avctx, AV_LOG_DEBUG, "no mmco here\n"); |
3455 | 3455 |
3456 for(i=0; i<mmco_count; i++){ | 3456 for(i=0; i<mmco_count; i++){ |
3457 int structure, frame_num, unref_pic; | 3457 int structure, frame_num; |
3458 if(s->avctx->debug&FF_DEBUG_MMCO) | 3458 if(s->avctx->debug&FF_DEBUG_MMCO) |
3459 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); | 3459 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); |
3460 | 3460 |
3461 switch(mmco[i].opcode){ | 3461 switch(mmco[i].opcode){ |
3462 case MMCO_SHORT2UNUSED: | 3462 case MMCO_SHORT2UNUSED: |
3496 remove_long_at_index(h, j); | 3496 remove_long_at_index(h, j); |
3497 } else if(s->avctx->debug&FF_DEBUG_MMCO) | 3497 } else if(s->avctx->debug&FF_DEBUG_MMCO) |
3498 av_log(h->s.avctx, AV_LOG_DEBUG, "mmco: unref long failure\n"); | 3498 av_log(h->s.avctx, AV_LOG_DEBUG, "mmco: unref long failure\n"); |
3499 break; | 3499 break; |
3500 case MMCO_LONG: | 3500 case MMCO_LONG: |
3501 unref_pic = 1; | 3501 // Comment below left from previous code as it is an interresting note. |
3502 if (FIELD_PICTURE && !s->first_field) { | |
3503 if (h->long_ref[mmco[i].long_arg] == s->current_picture_ptr) { | |
3504 /* Just mark second field as referenced */ | |
3505 unref_pic = 0; | |
3506 } else if (s->current_picture_ptr->reference) { | |
3507 /* First field in pair is in short term list or | 3502 /* First field in pair is in short term list or |
3508 * at a different long term index. | 3503 * at a different long term index. |
3509 * This is not allowed; see 7.4.3, notes 2 and 3. | 3504 * This is not allowed; see 7.4.3, notes 2 and 3. |
3510 * Report the problem and keep the pair where it is, | 3505 * Report the problem and keep the pair where it is, |
3511 * and mark this field valid. | 3506 * and mark this field valid. |
3512 */ | 3507 */ |
3513 av_log(h->s.avctx, AV_LOG_ERROR, | 3508 |
3514 "illegal long term reference assignment for second " | 3509 if (h->long_ref[mmco[i].long_arg] != s->current_picture_ptr) { |
3515 "field in complementary field pair (first field is " | |
3516 "short term or has non-matching long index)\n"); | |
3517 unref_pic = 0; | |
3518 } | |
3519 } | |
3520 | |
3521 if (unref_pic) { | |
3522 pic= remove_long(h, mmco[i].long_arg); | 3510 pic= remove_long(h, mmco[i].long_arg); |
3523 if(pic) unreference_pic(h, pic, 0); | 3511 if(pic) unreference_pic(h, pic, 0); |
3524 | 3512 |
3525 h->long_ref[ mmco[i].long_arg ]= s->current_picture_ptr; | 3513 h->long_ref[ mmco[i].long_arg ]= s->current_picture_ptr; |
3526 h->long_ref[ mmco[i].long_arg ]->long_ref=1; | 3514 h->long_ref[ mmco[i].long_arg ]->long_ref=1; |