aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorelupus <elupus@xbmc.org>2011-07-03 19:40:36 +0200
committerelupus <elupus@xbmc.org>2011-07-03 20:47:22 +0200
commit6345c791826dea18afd9ede362d002298b5aee3e (patch)
tree2499e972c406c94918e14a87a1ee6e0d8dd184a2 /lib
parent3c8a4c9973fe7432a4f0ee40ae4e39c0a689c680 (diff)
added: workaround for different handling of scaling lists for ATI cards
Diffstat (limited to 'lib')
-rw-r--r--lib/ffmpeg/libavcodec/avcodec.h1
-rw-r--r--lib/ffmpeg/libavcodec/dxva2_h264.c14
-rw-r--r--lib/ffmpeg/patches/0049-Added-ability-to-enable-workaround-for-dxva2-decodin.patch70
3 files changed, 83 insertions, 2 deletions
diff --git a/lib/ffmpeg/libavcodec/avcodec.h b/lib/ffmpeg/libavcodec/avcodec.h
index 4745980fd1..cb96c6fb66 100644
--- a/lib/ffmpeg/libavcodec/avcodec.h
+++ b/lib/ffmpeg/libavcodec/avcodec.h
@@ -1429,6 +1429,7 @@ typedef struct AVCodecContext {
#define FF_BUG_DC_CLIP 4096
#define FF_BUG_MS 8192 ///< Work around various bugs in Microsoft's broken decoders.
#define FF_BUG_TRUNCATED 16384
+#define FF_BUG_DXVA2_SCALING_LIST_ZIGZAG 32768 ///< Work around for DXVA2 and old UVD/UVD+ ATI video cards
//#define FF_BUG_FAKE_SCALABILITY 16 //Autodetection should work 100%.
/**
diff --git a/lib/ffmpeg/libavcodec/dxva2_h264.c b/lib/ffmpeg/libavcodec/dxva2_h264.c
index 17fb2b55c3..7b81c8e03b 100644
--- a/lib/ffmpeg/libavcodec/dxva2_h264.c
+++ b/lib/ffmpeg/libavcodec/dxva2_h264.c
@@ -150,10 +150,19 @@ static void fill_picture_parameters(struct dxva_context *ctx, const H264Context
//pp->SliceGroupMap[810]; /* XXX not implemented by FFmpeg */
}
-static void fill_scaling_lists(const H264Context *h, DXVA_Qmatrix_H264 *qm)
+static void fill_scaling_lists(AVCodecContext *avctx, const H264Context *h, DXVA_Qmatrix_H264 *qm)
{
unsigned i, j;
memset(qm, 0, sizeof(*qm));
+ if (avctx->workaround_bugs & FF_BUG_DXVA2_SCALING_LIST_ZIGZAG) { // For old UVD/UVD+ ATI cards
+ for (i = 0; i < 6; i++)
+ for (j = 0; j < 16; j++)
+ qm->bScalingLists4x4[i][j] = h->pps.scaling_matrix4[i][j];
+
+ for (i = 0; i < 2; i++)
+ for (j = 0; j < 64; j++)
+ qm->bScalingLists8x8[i][j] = h->pps.scaling_matrix8[i][j];
+ } else {
for (i = 0; i < 6; i++)
for (j = 0; j < 16; j++)
qm->bScalingLists4x4[i][j] = h->pps.scaling_matrix4[i][zigzag_scan[j]];
@@ -161,6 +170,7 @@ static void fill_scaling_lists(const H264Context *h, DXVA_Qmatrix_H264 *qm)
for (i = 0; i < 2; i++)
for (j = 0; j < 64; j++)
qm->bScalingLists8x8[i][j] = h->pps.scaling_matrix8[i][ff_zigzag_direct[j]];
+ }
}
static int is_slice_short(struct dxva_context *ctx)
@@ -370,7 +380,7 @@ static int start_frame(AVCodecContext *avctx,
fill_picture_parameters(ctx, h, &ctx_pic->pp);
/* Fill up DXVA_Qmatrix_H264 */
- fill_scaling_lists(h, &ctx_pic->qm);
+ fill_scaling_lists(avctx, h, &ctx_pic->qm);
ctx_pic->slice_count = 0;
ctx_pic->bitstream_size = 0;
diff --git a/lib/ffmpeg/patches/0049-Added-ability-to-enable-workaround-for-dxva2-decodin.patch b/lib/ffmpeg/patches/0049-Added-ability-to-enable-workaround-for-dxva2-decodin.patch
new file mode 100644
index 0000000000..e64905729e
--- /dev/null
+++ b/lib/ffmpeg/patches/0049-Added-ability-to-enable-workaround-for-dxva2-decodin.patch
@@ -0,0 +1,70 @@
+From f4a0791e9ee825ef54d370b82fce97c9cac92d26 Mon Sep 17 00:00:00 2001
+From: Joakim Plate <elupus@ecce.se>
+Date: Sun, 3 Jul 2011 17:18:50 +0200
+Subject: [PATCH] Added ability to enable workaround for dxva2 decoding using older ATI cards
+
+The workaround need to be enabled per pci id which can not
+be detected inside ffmpeg. So this adds a flag that enabled
+the alternate behavior.
+---
+ libavcodec/avcodec.h | 1 +
+ libavcodec/dxva2_h264.c | 14 ++++++++++++--
+ 2 files changed, 13 insertions(+), 2 deletions(-)
+
+diff --git a/lib/ffmpeg/libavcodec/avcodec.h b/lib/ffmpeg/libavcodec/avcodec.h
+index 1eb10ab..d642203 100644
+--- a/lib/ffmpeg/libavcodec/avcodec.h
++++ b/lib/ffmpeg/libavcodec/avcodec.h
+@@ -1441,6 +1441,7 @@ typedef struct AVCodecContext {
+ #define FF_BUG_DC_CLIP 4096
+ #define FF_BUG_MS 8192 ///< Work around various bugs in Microsoft's broken decoders.
+ #define FF_BUG_TRUNCATED 16384
++#define FF_BUG_DXVA2_SCALING_LIST_ZIGZAG 32768 ///< Work around for DXVA2 and old UVD/UVD+ ATI video cards
+ //#define FF_BUG_FAKE_SCALABILITY 16 //Autodetection should work 100%.
+
+ /**
+diff --git a/lib/ffmpeg/libavcodec/dxva2_h264.c b/lib/ffmpeg/libavcodec/dxva2_h264.c
+index bc80e98..3ad8fcf 100644
+--- a/lib/ffmpeg/libavcodec/dxva2_h264.c
++++ b/lib/ffmpeg/libavcodec/dxva2_h264.c
+@@ -150,10 +150,19 @@ static void fill_picture_parameters(struct dxva_context *ctx, const H264Context
+ //pp->SliceGroupMap[810]; /* XXX not implemented by FFmpeg */
+ }
+
+-static void fill_scaling_lists(const H264Context *h, DXVA_Qmatrix_H264 *qm)
++static void fill_scaling_lists(AVCodecContext *avctx, const H264Context *h, DXVA_Qmatrix_H264 *qm)
+ {
+ unsigned i, j;
+ memset(qm, 0, sizeof(*qm));
++ if (avctx->workaround_bugs & FF_BUG_DXVA2_SCALING_LIST_ZIGZAG) { // For old UVD/UVD+ ATI cards
++ for (i = 0; i < 6; i++)
++ for (j = 0; j < 16; j++)
++ qm->bScalingLists4x4[i][j] = h->pps.scaling_matrix4[i][j];
++
++ for (i = 0; i < 2; i++)
++ for (j = 0; j < 64; j++)
++ qm->bScalingLists8x8[i][j] = h->pps.scaling_matrix8[i][j];
++ } else {
+ for (i = 0; i < 6; i++)
+ for (j = 0; j < 16; j++)
+ qm->bScalingLists4x4[i][j] = h->pps.scaling_matrix4[i][zigzag_scan[j]];
+@@ -161,6 +170,7 @@ static void fill_scaling_lists(const H264Context *h, DXVA_Qmatrix_H264 *qm)
+ for (i = 0; i < 2; i++)
+ for (j = 0; j < 64; j++)
+ qm->bScalingLists8x8[i][j] = h->pps.scaling_matrix8[i][ff_zigzag_direct[j]];
++ }
+ }
+
+ static int is_slice_short(struct dxva_context *ctx)
+@@ -370,7 +380,7 @@ static int start_frame(AVCodecContext *avctx,
+ fill_picture_parameters(ctx, h, &ctx_pic->pp);
+
+ /* Fill up DXVA_Qmatrix_H264 */
+- fill_scaling_lists(h, &ctx_pic->qm);
++ fill_scaling_lists(avctx, h, &ctx_pic->qm);
+
+ ctx_pic->slice_count = 0;
+ ctx_pic->bitstream_size = 0;
+--
+1.7.4.msysgit.0
+