diff mbox series

[FFmpeg-devel] avcodec/nvdec_mpeg2: fix order of quant matrix coefficients

Message ID 20230515105104.1162-1-h.leppkes@gmail.com
State New
Headers show
Series [FFmpeg-devel] avcodec/nvdec_mpeg2: fix order of quant matrix coefficients | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Hendrik Leppkes May 15, 2023, 10:51 a.m. UTC
mpeg2dec stores them permutated for the IDCT, nvdec expects them in
plain raster order.
---
 libavcodec/nvdec_mpeg12.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Hendrik Leppkes May 15, 2023, 11:30 a.m. UTC | #1
On Mon, May 15, 2023 at 12:51 PM Hendrik Leppkes <h.leppkes@gmail.com> wrote:
>
> mpeg2dec stores them permutated for the IDCT, nvdec expects them in
> plain raster order.
> ---
>  libavcodec/nvdec_mpeg12.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/libavcodec/nvdec_mpeg12.c b/libavcodec/nvdec_mpeg12.c
> index e10735587d..3b9ff60734 100644
> --- a/libavcodec/nvdec_mpeg12.c
> +++ b/libavcodec/nvdec_mpeg12.c
> @@ -83,8 +83,9 @@ static int nvdec_mpeg12_start_frame(AVCodecContext *avctx, const uint8_t *buffer
>      };
>
>      for (i = 0; i < 64; ++i) {
> -        ppc->QuantMatrixIntra[i] = s->intra_matrix[i];
> -        ppc->QuantMatrixInter[i] = s->inter_matrix[i];
> +        int n = s->idsp.idct_permutation[i];
> +        ppc->QuantMatrixIntra[i] = s->intra_matrix[n];
> +        ppc->QuantMatrixInter[i] = s->inter_matrix[n];
>      }
>
>      return 0;
> --
> 2.40.1.windows.1
>

Apparently mpeg4 and VDPAU have the same issue. I can test and fix
mpeg4, but do not have VDPAU setup, so .. untested commits incoming?

- Hendrik
Hendrik Leppkes May 15, 2023, 12:01 p.m. UTC | #2
On Mon, May 15, 2023 at 1:30 PM Hendrik Leppkes <h.leppkes@gmail.com> wrote:
>
> Apparently mpeg4 and VDPAU have the same issue. I can test and fix
> mpeg4, but do not have VDPAU setup, so .. untested commits incoming?
>

Tested and confirmed mpeg2 and mpeg4 are fixed for NVDEC, and elenril
tested VDPAU with the same result.
OK'ed by BtbN on IRC.

Going to push later today.

- Hendrik
diff mbox series

Patch

diff --git a/libavcodec/nvdec_mpeg12.c b/libavcodec/nvdec_mpeg12.c
index e10735587d..3b9ff60734 100644
--- a/libavcodec/nvdec_mpeg12.c
+++ b/libavcodec/nvdec_mpeg12.c
@@ -83,8 +83,9 @@  static int nvdec_mpeg12_start_frame(AVCodecContext *avctx, const uint8_t *buffer
     };
 
     for (i = 0; i < 64; ++i) {
-        ppc->QuantMatrixIntra[i] = s->intra_matrix[i];
-        ppc->QuantMatrixInter[i] = s->inter_matrix[i];
+        int n = s->idsp.idct_permutation[i];
+        ppc->QuantMatrixIntra[i] = s->intra_matrix[n];
+        ppc->QuantMatrixInter[i] = s->inter_matrix[n];
     }
 
     return 0;