Skip to content

Commit

Permalink
Temporary fix for #11159: Fix playback of HD-PVR recording
Browse files Browse the repository at this point in the history
This revert FFmpeg commit bfca351
(ref https://ffmpeg.org/trac/ffmpeg/ticket/2062)
  • Loading branch information
jyavenard committed Dec 26, 2012
1 parent 16c178d commit d34833f
Showing 1 changed file with 25 additions and 19 deletions.
44 changes: 25 additions & 19 deletions mythtv/external/FFmpeg/libavcodec/h264.c
Expand Up @@ -1452,25 +1452,6 @@ static void decode_postinit(H264Context *h, int setup_finished)
s->low_delay = 0;
}

for (i = 0; 1; i++) {
if(i == MAX_DELAYED_PIC_COUNT || cur->poc < h->last_pocs[i]){
if(i)
h->last_pocs[i-1] = cur->poc;
break;
} else if(i) {
h->last_pocs[i-1]= h->last_pocs[i];
}
}
out_of_order = MAX_DELAYED_PIC_COUNT - i;
if( cur->f.pict_type == AV_PICTURE_TYPE_B
|| (h->last_pocs[MAX_DELAYED_PIC_COUNT-2] > INT_MIN && h->last_pocs[MAX_DELAYED_PIC_COUNT-1] - h->last_pocs[MAX_DELAYED_PIC_COUNT-2] > 2))
out_of_order = FFMAX(out_of_order, 1);
if(s->avctx->has_b_frames < out_of_order && !h->sps.bitstream_restriction_flag){
av_log(s->avctx, AV_LOG_VERBOSE, "Increasing reorder buffer to %d\n", out_of_order);
s->avctx->has_b_frames = out_of_order;
s->low_delay = 0;
}

pics = 0;
while (h->delayed_pic[pics])
pics++;
Expand All @@ -1496,6 +1477,29 @@ static void decode_postinit(H264Context *h, int setup_finished)
h->next_outputed_poc = INT_MIN;
out_of_order = out->poc < h->next_outputed_poc;

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) {
int cnt = 0, invalid = 0;
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->avctx->has_b_frames++;
}

if (out_of_order || pics > s->avctx->has_b_frames) {
out->f.reference &= ~DELAYED_PIC_REF;
// for frame threading, the owner must be the second field's thread or
Expand All @@ -1504,6 +1508,8 @@ static void decode_postinit(H264Context *h, int setup_finished)
for (i = out_idx; h->delayed_pic[i]; i++)
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) {
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)) {
Expand Down

4 comments on commit d34833f

@Glidos
Copy link

@Glidos Glidos commented on d34833f Jan 27, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently this breaks playback of BBC HD and BBC 1 HD

@bas-t
Copy link
Contributor

@bas-t bas-t commented on d34833f Jan 30, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And all HD channels in the Ziggo Netherlands area as well

@Glidos
Copy link

@Glidos Glidos commented on d34833f Jan 30, 2013 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bas-t
Copy link
Contributor

@bas-t bas-t commented on d34833f Jan 30, 2013 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.