Advertisement
jyavenard

11159.patch

Dec 25th, 2012
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.41 KB | None | 0 0
  1. diff --git a/mythtv/external/FFmpeg/libavcodec/h264.c b/mythtv/external/FFmpeg/libavcodec/h264.c
  2. index 3b91039..f765c8d 100644
  3. --- a/mythtv/external/FFmpeg/libavcodec/h264.c
  4. +++ b/mythtv/external/FFmpeg/libavcodec/h264.c
  5. @@ -1448,29 +1448,10 @@ static void decode_postinit(H264Context *h, int setup_finished)
  6.  
  7. if (s->avctx->strict_std_compliance >= FF_COMPLIANCE_STRICT &&
  8. !h->sps.bitstream_restriction_flag) {
  9. - s->avctx->has_b_frames = MAX_DELAYED_PIC_COUNT - 1;
  10. + s->avctx->has_b_frames = MAX_DELAYED_PIC_COUNT;
  11. s->low_delay = 0;
  12. }
  13.  
  14. - for (i = 0; 1; i++) {
  15. - if(i == MAX_DELAYED_PIC_COUNT || cur->poc < h->last_pocs[i]){
  16. - if(i)
  17. - h->last_pocs[i-1] = cur->poc;
  18. - break;
  19. - } else if(i) {
  20. - h->last_pocs[i-1]= h->last_pocs[i];
  21. - }
  22. - }
  23. - out_of_order = MAX_DELAYED_PIC_COUNT - i;
  24. - if( cur->f.pict_type == AV_PICTURE_TYPE_B
  25. - || (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))
  26. - out_of_order = FFMAX(out_of_order, 1);
  27. - if(s->avctx->has_b_frames < out_of_order && !h->sps.bitstream_restriction_flag){
  28. - av_log(s->avctx, AV_LOG_VERBOSE, "Increasing reorder buffer to %d\n", out_of_order);
  29. - s->avctx->has_b_frames = out_of_order;
  30. - s->low_delay = 0;
  31. - }
  32. -
  33. pics = 0;
  34. while (h->delayed_pic[pics])
  35. pics++;
  36. @@ -1496,6 +1477,29 @@ static void decode_postinit(H264Context *h, int setup_finished)
  37. h->next_outputed_poc = INT_MIN;
  38. out_of_order = out->poc < h->next_outputed_poc;
  39.  
  40. + if(h->sps.bitstream_restriction_flag && s->avctx->has_b_frames >= h->sps.num_reorder_frames)
  41. + { }
  42. + else if (out_of_order && pics-1 == s->avctx->has_b_frames &&
  43. + s->avctx->has_b_frames < MAX_DELAYED_PIC_COUNT) {
  44. + int cnt = 0, invalid = 0;
  45. + for (i = 0; i < MAX_DELAYED_PIC_COUNT; i++) {
  46. + cnt += out->poc < h->last_pocs[i];
  47. + invalid += h->last_pocs[i] == INT_MIN;
  48. + }
  49. + if (invalid + cnt < MAX_DELAYED_PIC_COUNT) {
  50. + s->avctx->has_b_frames = FFMAX(s->avctx->has_b_frames, cnt);
  51. + } else if (cnt) {
  52. + for (i = 0; i < MAX_DELAYED_PIC_COUNT; i++)
  53. + h->last_pocs[i] = INT_MIN;
  54. + }
  55. + s->low_delay = 0;
  56. + } else if (s->low_delay &&
  57. + ((h->next_outputed_poc != INT_MIN && out->poc > h->next_outputed_poc + 2) ||
  58. + cur->f.pict_type == AV_PICTURE_TYPE_B)) {
  59. + s->low_delay = 0;
  60. + s->avctx->has_b_frames++;
  61. + }
  62. +
  63. if (out_of_order || pics > s->avctx->has_b_frames) {
  64. out->f.reference &= ~DELAYED_PIC_REF;
  65. // for frame threading, the owner must be the second field's thread or
  66. @@ -1504,6 +1508,8 @@ static void decode_postinit(H264Context *h, int setup_finished)
  67. for (i = out_idx; h->delayed_pic[i]; i++)
  68. h->delayed_pic[i] = h->delayed_pic[i + 1];
  69. }
  70. + memmove(h->last_pocs, &h->last_pocs[1], sizeof(*h->last_pocs) * (MAX_DELAYED_PIC_COUNT - 1));
  71. + h->last_pocs[MAX_DELAYED_PIC_COUNT - 1] = out->poc;
  72. if (!out_of_order && pics > s->avctx->has_b_frames) {
  73. h->next_output_pic = out;
  74. if (out_idx == 0 && h->delayed_pic[0] && (h->delayed_pic[0]->f.key_frame || h->delayed_pic[0]->mmco_reset)) {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement