Guest User

Untitled

a guest
Jan 27th, 2013
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.79 KB | None | 0 0
  1. diff --git a/mythtv/external/FFmpeg/libavcodec/h264.c b/mythtv/external/FFmpeg/libavcodec/h264.c
  2. index e533a48..a558966 100644
  3. --- a/mythtv/external/FFmpeg/libavcodec/h264.c
  4. +++ b/mythtv/external/FFmpeg/libavcodec/h264.c
  5. @@ -1113,6 +1113,8 @@ av_cold int ff_h264_decode_init(AVCodecContext *avctx)
  6. s->low_delay = 0;
  7. }
  8.  
  9. + h->have_seen_idr = 0;
  10. +
  11. return 0;
  12. }
  13.  
  14. @@ -1452,6 +1454,28 @@ static void decode_postinit(H264Context *h, int setup_finished)
  15. s->low_delay = 0;
  16. }
  17.  
  18. + if (!h->have_seen_idr) {
  19. + // Good for BBC HD, bad for HD-PVR
  20. + for (i = 0; 1; i++) {
  21. + if(i == MAX_DELAYED_PIC_COUNT || cur->poc < h->last_pocs[i]){
  22. + if(i)
  23. + h->last_pocs[i-1] = cur->poc;
  24. + break;
  25. + } else if(i) {
  26. + h->last_pocs[i-1]= h->last_pocs[i];
  27. + }
  28. + }
  29. + out_of_order = MAX_DELAYED_PIC_COUNT - i;
  30. + if( cur->f.pict_type == AV_PICTURE_TYPE_B
  31. + || (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))
  32. + out_of_order = FFMAX(out_of_order, 1);
  33. + if(s->avctx->has_b_frames < out_of_order && !h->sps.bitstream_restriction_flag){
  34. + av_log(s->avctx, AV_LOG_WARNING, "Increasing reorder buffer to %d\n", out_of_order);
  35. + s->avctx->has_b_frames = out_of_order;
  36. + s->low_delay = 0;
  37. + }
  38. + }
  39. +
  40. pics = 0;
  41. while (h->delayed_pic[pics])
  42. pics++;
  43. @@ -1477,6 +1501,8 @@ static void decode_postinit(H264Context *h, int setup_finished)
  44. h->next_outputed_poc = INT_MIN;
  45. out_of_order = out->poc < h->next_outputed_poc;
  46.  
  47. + if (h->have_seen_idr) {
  48. + // Bad for BBC HD, good for HD-PVR
  49. if (h->sps.bitstream_restriction_flag &&
  50. s->avctx->has_b_frames >= h->sps.num_reorder_frames) {
  51. } else if (out_of_order && pics - 1 == s->avctx->has_b_frames &&
  52. @@ -1499,6 +1525,7 @@ static void decode_postinit(H264Context *h, int setup_finished)
  53. s->low_delay = 0;
  54. s->avctx->has_b_frames++;
  55. }
  56. + }
  57.  
  58. if (out_of_order || pics > s->avctx->has_b_frames) {
  59. out->f.reference &= ~DELAYED_PIC_REF;
  60. @@ -1508,8 +1535,11 @@ static void decode_postinit(H264Context *h, int setup_finished)
  61. for (i = out_idx; h->delayed_pic[i]; i++)
  62. h->delayed_pic[i] = h->delayed_pic[i + 1];
  63. }
  64. + if (h->have_seen_idr) {
  65. + // Bad for BBC HD, good for HD-PVR
  66. memmove(h->last_pocs, &h->last_pocs[1], sizeof(*h->last_pocs) * (MAX_DELAYED_PIC_COUNT - 1));
  67. h->last_pocs[MAX_DELAYED_PIC_COUNT - 1] = out->poc;
  68. + }
  69. if (!out_of_order && pics > s->avctx->has_b_frames) {
  70. h->next_output_pic = out;
  71. if (out_idx == 0 && h->delayed_pic[0] && (h->delayed_pic[0]->f.key_frame || h->delayed_pic[0]->mmco_reset)) {
  72. @@ -3863,6 +3893,7 @@ again:
  73. goto end;
  74. }
  75. idr(h); // FIXME ensure we don't lose some frames if there is reordering
  76. + h->have_seen_idr = 1;
  77. case NAL_SLICE:
  78. init_get_bits(&hx->s.gb, ptr, bit_length);
  79. hx->intra_gb_ptr =
  80. diff --git a/mythtv/external/FFmpeg/libavcodec/h264.h b/mythtv/external/FFmpeg/libavcodec/h264.h
  81. index 4d07a8a..ae9ee50 100644
  82. --- a/mythtv/external/FFmpeg/libavcodec/h264.h
  83. +++ b/mythtv/external/FFmpeg/libavcodec/h264.h
  84. @@ -601,6 +601,7 @@ typedef struct H264Context {
  85. uint8_t parse_history[4];
  86. int parse_history_count;
  87. int parse_last_mb;
  88. + int have_seen_idr;
  89. } H264Context;
  90.  
  91. 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