1 From c5562890c7c3e495a1995bfa64f730806020e8d6 Mon Sep 17 00:00:00 2001
2 From: Hendrik Leppkes <h.leppkes@gmail.com>
3 Date: Thu, 12 Dec 2013 21:12:52 +0100
4 Subject: [PATCH] dxva2_vc1: fix signaling of intensity compensation values
6 lumscale/lumshift don't get reset back to their default values if
7 intensity compensation is not active, and a wrong signaling here can
10 Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
12 xbmc/lib/ffmpeg/libavcodec/dxva2_vc1.c | 29 ++++++++++++++++++++++++-----
13 1 file changed, 24 insertions(+), 5 deletions(-)
15 diff --git a/xbmc/lib/ffmpeg/libavcodec/dxva2_vc1.c b/xbmc/lib/ffmpeg/libavcodec/dxva2_vc1.c
16 index bf4e8e0..995b3e3 100644
17 --- a/xbmc/lib/ffmpeg/libavcodec/dxva2_vc1.c
18 +++ b/xbmc/lib/ffmpeg/libavcodec/dxva2_vc1.c
19 @@ -38,6 +38,15 @@ static void fill_picture_parameters(AVCodecContext *avctx,
21 const MpegEncContext *s = &v->s;
22 const Picture *current_picture = s->current_picture_ptr;
25 + // determine if intensity compensation is needed
26 + if (s->pict_type == AV_PICTURE_TYPE_P) {
27 + if ((v->fcm == ILACE_FRAME && v->intcomp) || (v->fcm != ILACE_FRAME && v->mv_mode == MV_PMODE_INTENSITY_COMP)) {
28 + if (v->lumscale != 32 || v->lumshift != 0 || (s->picture_structure != PICT_FRAME && (v->lumscale2 != 32 && v->lumshift2 != 0)))
33 memset(pp, 0, sizeof(*pp));
34 pp->wDecodedPictureIndex =
35 @@ -74,7 +83,7 @@ static void fill_picture_parameters(AVCodecContext *avctx,
36 pp->bBidirectionalAveragingMode = (1 << 7) |
37 ((ctx->cfg->ConfigIntraResidUnsigned != 0) << 6) |
38 ((ctx->cfg->ConfigResidDiffAccelerator != 0) << 5) |
39 - ((v->lumscale != 32 || v->lumshift != 0) << 4) |
41 ((v->profile == PROFILE_ADVANCED) << 3);
42 pp->bMVprecisionAndChromaRelation = ((v->mv_mode == MV_PMODE_1MV_HPEL_BILIN) << 3) |
44 @@ -125,12 +134,22 @@ static void fill_picture_parameters(AVCodecContext *avctx,
45 pp->bMV_RPS = (v->fcm == ILACE_FIELD && pp->bPicBackwardPrediction) ? v->refdist + 9 : 0;
46 pp->bReservedBits = v->pq;
47 if (s->picture_structure == PICT_FRAME) {
48 - pp->wBitstreamFcodes = v->lumscale;
49 - pp->wBitstreamPCEelements = v->lumshift;
51 + pp->wBitstreamFcodes = v->lumscale;
52 + pp->wBitstreamPCEelements = v->lumshift;
54 + pp->wBitstreamFcodes = 32;
55 + pp->wBitstreamPCEelements = 0;
58 /* Syntax: (top_field_param << 8) | bottom_field_param */
59 - pp->wBitstreamFcodes = (v->lumscale << 8) | v->lumscale;
60 - pp->wBitstreamPCEelements = (v->lumshift << 8) | v->lumshift;
62 + pp->wBitstreamFcodes = (v->lumscale << 8) | v->lumscale2;
63 + pp->wBitstreamPCEelements = (v->lumshift << 8) | v->lumshift2;
65 + pp->wBitstreamFcodes = (32 << 8) | 32;
66 + pp->wBitstreamPCEelements = 0;
69 pp->bBitstreamConcealmentNeed = 0;
70 pp->bBitstreamConcealmentMethod = 0;