Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/mythtv/external/FFmpeg/libavcodec/h264.c b/mythtv/external/FFmpeg/libavcodec/h264.c
- index e533a48..a558966 100644
- --- a/mythtv/external/FFmpeg/libavcodec/h264.c
- +++ b/mythtv/external/FFmpeg/libavcodec/h264.c
- @@ -1113,6 +1113,8 @@ av_cold int ff_h264_decode_init(AVCodecContext *avctx)
- s->low_delay = 0;
- }
- + h->have_seen_idr = 0;
- +
- return 0;
- }
- @@ -1452,6 +1454,28 @@ static void decode_postinit(H264Context *h, int setup_finished)
- s->low_delay = 0;
- }
- + if (!h->have_seen_idr) {
- + // Good for BBC HD, bad for HD-PVR
- + 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_WARNING, "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++;
- @@ -1477,6 +1501,8 @@ 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->have_seen_idr) {
- + // Bad for BBC HD, good for HD-PVR
- 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 &&
- @@ -1499,6 +1525,7 @@ static void decode_postinit(H264Context *h, int setup_finished)
- 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;
- @@ -1508,8 +1535,11 @@ 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];
- }
- + if (h->have_seen_idr) {
- + // Bad for BBC HD, good for HD-PVR
- 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)) {
- @@ -3863,6 +3893,7 @@ again:
- goto end;
- }
- idr(h); // FIXME ensure we don't lose some frames if there is reordering
- + h->have_seen_idr = 1;
- case NAL_SLICE:
- init_get_bits(&hx->s.gb, ptr, bit_length);
- hx->intra_gb_ptr =
- diff --git a/mythtv/external/FFmpeg/libavcodec/h264.h b/mythtv/external/FFmpeg/libavcodec/h264.h
- index 4d07a8a..ae9ee50 100644
- --- a/mythtv/external/FFmpeg/libavcodec/h264.h
- +++ b/mythtv/external/FFmpeg/libavcodec/h264.h
- @@ -601,6 +601,7 @@ typedef struct H264Context {
- uint8_t parse_history[4];
- int parse_history_count;
- int parse_last_mb;
- + int have_seen_idr;
- } H264Context;
- extern const uint8_t ff_h264_chroma_qp[7][QP_MAX_NUM + 1]; ///< One chroma qp table for each possible bit depth (8-14).
Advertisement
Add Comment
Please, Sign In to add comment