Mercurial > libavcodec.hg
comparison h264.c @ 10511:bfea93e47391 libavcodec
Try to fix has_b_frame calculation for open gop files.
Fixes issue1523
author | michael |
---|---|
date | Tue, 10 Nov 2009 20:24:41 +0000 |
parents | 59ec306245a4 |
children | 6ec7b5450ca7 |
comparison
equal
deleted
inserted
replaced
10510:26fcf45bb486 | 10511:bfea93e47391 |
---|---|
7793 } | 7793 } |
7794 | 7794 |
7795 if(!(s->flags2 & CODEC_FLAG2_CHUNKS) || (s->mb_y >= s->mb_height && s->mb_height)){ | 7795 if(!(s->flags2 & CODEC_FLAG2_CHUNKS) || (s->mb_y >= s->mb_height && s->mb_height)){ |
7796 Picture *out = s->current_picture_ptr; | 7796 Picture *out = s->current_picture_ptr; |
7797 Picture *cur = s->current_picture_ptr; | 7797 Picture *cur = s->current_picture_ptr; |
7798 int i, pics, cross_idr, out_of_order, out_idx; | 7798 int i, pics, out_of_order, out_idx; |
7799 | 7799 |
7800 field_end(h); | 7800 field_end(h); |
7801 | 7801 |
7802 if (cur->field_poc[0]==INT_MAX || cur->field_poc[1]==INT_MAX) { | 7802 if (cur->field_poc[0]==INT_MAX || cur->field_poc[1]==INT_MAX) { |
7803 /* Wait for second field. */ | 7803 /* Wait for second field. */ |
7897 for(i=1; h->delayed_pic[i] && !h->delayed_pic[i]->key_frame && !h->delayed_pic[i]->mmco_reset; i++) | 7897 for(i=1; h->delayed_pic[i] && !h->delayed_pic[i]->key_frame && !h->delayed_pic[i]->mmco_reset; i++) |
7898 if(h->delayed_pic[i]->poc < out->poc){ | 7898 if(h->delayed_pic[i]->poc < out->poc){ |
7899 out = h->delayed_pic[i]; | 7899 out = h->delayed_pic[i]; |
7900 out_idx = i; | 7900 out_idx = i; |
7901 } | 7901 } |
7902 cross_idr = !!h->delayed_pic[i] || h->delayed_pic[0]->key_frame || h->delayed_pic[0]->mmco_reset; | 7902 if(s->avctx->has_b_frames == 0 && (h->delayed_pic[0]->key_frame || h->delayed_pic[0]->mmco_reset)) |
7903 | 7903 h->outputed_poc= INT_MIN; |
7904 out_of_order = !cross_idr && out->poc < h->outputed_poc; | 7904 out_of_order = out->poc < h->outputed_poc; |
7905 | 7905 |
7906 if(h->sps.bitstream_restriction_flag && s->avctx->has_b_frames >= h->sps.num_reorder_frames) | 7906 if(h->sps.bitstream_restriction_flag && s->avctx->has_b_frames >= h->sps.num_reorder_frames) |
7907 { } | 7907 { } |
7908 else if((out_of_order && pics-1 == s->avctx->has_b_frames && s->avctx->has_b_frames < MAX_DELAYED_PIC_COUNT) | 7908 else if((out_of_order && pics-1 == s->avctx->has_b_frames && s->avctx->has_b_frames < MAX_DELAYED_PIC_COUNT) |
7909 || (s->low_delay && | 7909 || (s->low_delay && |
7910 ((!cross_idr && out->poc > h->outputed_poc + 2) | 7910 ((h->outputed_poc != INT_MIN && out->poc > h->outputed_poc + 2) |
7911 || cur->pict_type == FF_B_TYPE))) | 7911 || cur->pict_type == FF_B_TYPE))) |
7912 { | 7912 { |
7913 s->low_delay = 0; | 7913 s->low_delay = 0; |
7914 s->avctx->has_b_frames++; | 7914 s->avctx->has_b_frames++; |
7915 } | 7915 } |
7920 h->delayed_pic[i] = h->delayed_pic[i+1]; | 7920 h->delayed_pic[i] = h->delayed_pic[i+1]; |
7921 } | 7921 } |
7922 if(!out_of_order && pics > s->avctx->has_b_frames){ | 7922 if(!out_of_order && pics > s->avctx->has_b_frames){ |
7923 *data_size = sizeof(AVFrame); | 7923 *data_size = sizeof(AVFrame); |
7924 | 7924 |
7925 if(out_idx==0 && h->delayed_pic[0] && (h->delayed_pic[0]->key_frame || h->delayed_pic[0]->mmco_reset)) { | |
7926 h->outputed_poc = INT_MIN; | |
7927 } else | |
7925 h->outputed_poc = out->poc; | 7928 h->outputed_poc = out->poc; |
7926 *pict= *(AVFrame*)out; | 7929 *pict= *(AVFrame*)out; |
7927 }else{ | 7930 }else{ |
7928 av_log(avctx, AV_LOG_DEBUG, "no picture\n"); | 7931 av_log(avctx, AV_LOG_DEBUG, "no picture\n"); |
7929 } | 7932 } |