mirror of https://git.ffmpeg.org/ffmpeg.git
h264: improve calculation of codec delay.
Fixes the following conformance suite samples: HCBP1_HHI_A.264, HCBP2_HHI_A.264, HCMP1_HHI_A.264 (main) HCHP1_HHI_B.264, HCHP2_HHI_A.264, HCHP3_HHI_A.264 (frext)
This commit is contained in:
parent
ed669c9bec
commit
ea2bb12e3e
|
@ -1095,6 +1095,7 @@ int ff_h264_decode_extradata(H264Context *h)
|
||||||
av_cold int ff_h264_decode_init(AVCodecContext *avctx){
|
av_cold int ff_h264_decode_init(AVCodecContext *avctx){
|
||||||
H264Context *h= avctx->priv_data;
|
H264Context *h= avctx->priv_data;
|
||||||
MpegEncContext * const s = &h->s;
|
MpegEncContext * const s = &h->s;
|
||||||
|
int i;
|
||||||
|
|
||||||
MPV_decode_defaults(s);
|
MPV_decode_defaults(s);
|
||||||
|
|
||||||
|
@ -1119,6 +1120,8 @@ av_cold int ff_h264_decode_init(AVCodecContext *avctx){
|
||||||
|
|
||||||
h->thread_context[0] = h;
|
h->thread_context[0] = h;
|
||||||
h->outputed_poc = h->next_outputed_poc = INT_MIN;
|
h->outputed_poc = h->next_outputed_poc = INT_MIN;
|
||||||
|
for (i = 0; i < MAX_DELAYED_PIC_COUNT; i++)
|
||||||
|
h->last_pocs[i] = INT_MIN;
|
||||||
h->prev_poc_msb= 1<<16;
|
h->prev_poc_msb= 1<<16;
|
||||||
h->x264_build = -1;
|
h->x264_build = -1;
|
||||||
ff_h264_reset_sei(h);
|
ff_h264_reset_sei(h);
|
||||||
|
@ -1459,11 +1462,23 @@ static void decode_postinit(H264Context *h, int setup_finished){
|
||||||
|
|
||||||
if(h->sps.bitstream_restriction_flag && s->avctx->has_b_frames >= h->sps.num_reorder_frames)
|
if(h->sps.bitstream_restriction_flag && s->avctx->has_b_frames >= h->sps.num_reorder_frames)
|
||||||
{ }
|
{ }
|
||||||
else if((out_of_order && pics-1 == s->avctx->has_b_frames && s->avctx->has_b_frames < MAX_DELAYED_PIC_COUNT)
|
else if (out_of_order && pics-1 == s->avctx->has_b_frames &&
|
||||||
|| (s->low_delay &&
|
s->avctx->has_b_frames < MAX_DELAYED_PIC_COUNT) {
|
||||||
((h->next_outputed_poc != INT_MIN && out->poc > h->next_outputed_poc + 2)
|
int cnt = 0, invalid = 0;
|
||||||
|| cur->f.pict_type == AV_PICTURE_TYPE_B)))
|
for (i = 0; i < MAX_DELAYED_PIC_COUNT; i++) {
|
||||||
{
|
cnt += out->poc < h->last_pocs[i];
|
||||||
|
invalid += h->last_pocs[i] == INT_MIN;
|
||||||
|
}
|
||||||
|
if (invalid + cnt < MAX_DELAYED_PIC_COUNT) {
|
||||||
|
s->avctx->has_b_frames = FFMAX(s->avctx->has_b_frames, cnt);
|
||||||
|
} else if (cnt) {
|
||||||
|
for (i = 0; i < MAX_DELAYED_PIC_COUNT; i++)
|
||||||
|
h->last_pocs[i] = INT_MIN;
|
||||||
|
}
|
||||||
|
s->low_delay = 0;
|
||||||
|
} else if (s->low_delay &&
|
||||||
|
((h->next_outputed_poc != INT_MIN && out->poc > h->next_outputed_poc + 2) ||
|
||||||
|
cur->f.pict_type == AV_PICTURE_TYPE_B)) {
|
||||||
s->low_delay = 0;
|
s->low_delay = 0;
|
||||||
s->avctx->has_b_frames++;
|
s->avctx->has_b_frames++;
|
||||||
}
|
}
|
||||||
|
@ -1475,6 +1490,8 @@ static void decode_postinit(H264Context *h, int setup_finished){
|
||||||
for(i=out_idx; h->delayed_pic[i]; i++)
|
for(i=out_idx; h->delayed_pic[i]; i++)
|
||||||
h->delayed_pic[i] = h->delayed_pic[i+1];
|
h->delayed_pic[i] = h->delayed_pic[i+1];
|
||||||
}
|
}
|
||||||
|
memmove(h->last_pocs, &h->last_pocs[1], sizeof(*h->last_pocs) * (MAX_DELAYED_PIC_COUNT - 1));
|
||||||
|
h->last_pocs[MAX_DELAYED_PIC_COUNT - 1] = out->poc;
|
||||||
if(!out_of_order && pics > s->avctx->has_b_frames){
|
if(!out_of_order && pics > s->avctx->has_b_frames){
|
||||||
h->next_output_pic = out;
|
h->next_output_pic = out;
|
||||||
if (out_idx == 0 && h->delayed_pic[0] && (h->delayed_pic[0]->f.key_frame || h->delayed_pic[0]->mmco_reset)) {
|
if (out_idx == 0 && h->delayed_pic[0] && (h->delayed_pic[0]->f.key_frame || h->delayed_pic[0]->mmco_reset)) {
|
||||||
|
|
|
@ -488,6 +488,7 @@ typedef struct H264Context{
|
||||||
Picture *long_ref[32];
|
Picture *long_ref[32];
|
||||||
Picture default_ref_list[2][32]; ///< base reference list for all slices of a coded picture
|
Picture default_ref_list[2][32]; ///< base reference list for all slices of a coded picture
|
||||||
Picture *delayed_pic[MAX_DELAYED_PIC_COUNT+2]; //FIXME size?
|
Picture *delayed_pic[MAX_DELAYED_PIC_COUNT+2]; //FIXME size?
|
||||||
|
int last_pocs[MAX_DELAYED_PIC_COUNT];
|
||||||
Picture *next_output_pic;
|
Picture *next_output_pic;
|
||||||
int outputed_poc;
|
int outputed_poc;
|
||||||
int next_outputed_poc;
|
int next_outputed_poc;
|
||||||
|
|
Loading…
Reference in New Issue