Advertisement
Guest User

joakim

a guest
Mar 30th, 2012
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.66 KB | None | 0 0
  1. From 3b6417ff1e86c2aa72fc5360f67be2db8b83b80d Mon Sep 17 00:00:00 2001
  2. From: CrystalP <CrystalP@xbmc.org>
  3. Date: Wed, 5 Oct 2011 13:13:25 -0400
  4. Subject: [PATCH 1/1] dxva-h264 Fix dxva playback of streams that don't start
  5. with an I-Frame.
  6.  
  7. GPUs with ATI UVDa and UVD+ have trouble when decoding doesn't start on an
  8. I-Frame, and they don't recover on later I-Frames.
  9.  
  10. The variable to track the first I-Frame is in H264Context so that it can be
  11. reset by code in h264 when initializing the context or flushing.
  12.  
  13. credits isidrogar, see ticket #11772.
  14. sample on team ftp, samples/11772/CSI_ New York - TV3 - 2008-09-16_1.ts
  15. ---
  16. libavcodec/dxva2_h264.c | 8 ++++++++
  17. libavcodec/h264.c | 2 ++
  18. libavcodec/h264.h | 2 ++
  19. 3 files changed, 12 insertions(+)
  20.  
  21. diff --git a/libavcodec/dxva2_h264.c b/libavcodec/dxva2_h264.c
  22. index af91e02..b7e0251 100644
  23. --- a/libavcodec/dxva2_h264.c
  24. +++ b/libavcodec/dxva2_h264.c
  25. @@ -432,6 +432,14 @@ static int end_frame(AVCodecContext *avctx)
  26.  
  27. if (ctx_pic->slice_count <= 0 || ctx_pic->bitstream_size <= 0)
  28. return -1;
  29. +
  30. + // Wait for an I-frame before start decoding. Workaround for ATI UVD and UVD+ GPUs
  31. + if (!h->got_first_iframe) {
  32. + if (!(ctx_pic->pp.wBitFields & (1 << 15)))
  33. + return -1;
  34. + h->got_first_iframe = 1;
  35. + }
  36. +
  37. return ff_dxva2_common_end_frame(avctx, s,
  38. &ctx_pic->pp, sizeof(ctx_pic->pp),
  39. &ctx_pic->qm, sizeof(ctx_pic->qm),
  40. diff --git a/libavcodec/h264.c b/libavcodec/h264.c
  41. index d010b55..98c7a5d 100644
  42. --- a/libavcodec/h264.c
  43. +++ b/libavcodec/h264.c
  44. @@ -2372,6 +2372,7 @@ static void flush_dpb(AVCodecContext *avctx){
  45. h->delayed_pic[i]->f.reference = 0;
  46. h->delayed_pic[i]= NULL;
  47. }
  48. + h->got_first_iframe = 0;
  49. h->outputed_poc=h->next_outputed_poc= INT_MIN;
  50. h->prev_interlaced_frame = 1;
  51. idr(h);
  52. @@ -2819,6 +2820,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0){
  53. }
  54. s->first_field = 0;
  55. h->prev_interlaced_frame = 1;
  56. + h->got_first_iframe = 0;
  57.  
  58. init_scan_tables(h);
  59. if (ff_h264_alloc_tables(h) < 0) {
  60. diff --git a/libavcodec/h264.h b/libavcodec/h264.h
  61. index d0dfca3..f4df997 100644
  62. --- a/libavcodec/h264.h
  63. +++ b/libavcodec/h264.h
  64. @@ -584,6 +584,8 @@ typedef struct H264Context{
  65. int luma_weight_flag[2]; ///< 7.4.3.2 luma_weight_lX_flag
  66. int chroma_weight_flag[2]; ///< 7.4.3.2 chroma_weight_lX_flag
  67.  
  68. + int got_first_iframe;
  69. +
  70. // Timestamp stuff
  71. int sei_buffering_period_present; ///< Buffering period SEI flag
  72. int initial_cpb_removal_delay[32]; ///< Initial timestamps for CPBs
  73. --
  74. 1.7.9.4
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement