diff mbox series

[FFmpeg-devel] lavc/dxv: fix incorrect back-reference index calculation in DXT5 decoding

Message ID 20240130062626.98273-1-connorbworley@gmail.com
State Accepted
Commit 1eeee68d8eb678665730bdd7862598be15867028
Headers show
Series [FFmpeg-devel] lavc/dxv: fix incorrect back-reference index calculation in DXT5 decoding | 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

Connor Worley Jan. 30, 2024, 6:26 a.m. UTC
This bug causes the DXT5 decoder to produce incorrect block texture data.
After the fix, textures are visually correct and match data decoded by
Resolume Alley (extracted with Nvida Nsight for comparison). Current FATE DXT5
samples did not cover this case.

Signed-off-by: Connor Worley <connorbworley@gmail.com>
---
 libavcodec/dxv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Connor Worley Jan. 30, 2024, 6:29 a.m. UTC | #1
Attached are the input file used for comparison with Alley, and
before-and-after images generated with
`ffmpeg -i dice_dxt5.mov -f image2 out.png`

On Mon, Jan 29, 2024 at 10:26 PM Connor Worley <connorbworley@gmail.com>
wrote:

> This bug causes the DXT5 decoder to produce incorrect block texture data.
> After the fix, textures are visually correct and match data decoded by
> Resolume Alley (extracted with Nvida Nsight for comparison). Current FATE
> DXT5
> samples did not cover this case.
>
> Signed-off-by: Connor Worley <connorbworley@gmail.com>
> ---
>  libavcodec/dxv.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavcodec/dxv.c b/libavcodec/dxv.c
> index b29adf8ad9..be1216da86 100644
> --- a/libavcodec/dxv.c
> +++ b/libavcodec/dxv.c
> @@ -755,7 +755,7 @@ static int dxv_decompress_dxt5(AVCodecContext *avctx)
>                  break;
>              case 2:
>                  /* Copy two dwords from a previous index */
> -                idx = 8 + bytestream2_get_le16(gbc);
> +                idx = 8 + 4 * bytestream2_get_le16(gbc);
>                  if (idx > pos || (unsigned int)(pos - idx) + 2 >
> ctx->tex_size / 4)
>                      return AVERROR_INVALIDDATA;
>                  prev = AV_RL32(ctx->tex_data + 4 * (pos - idx));
> --
> 2.40.1
>
>
Connor Worley Feb. 1, 2024, 8:41 p.m. UTC | #2
Got some confirmation that this patch fixes
https://trac.ffmpeg.org/ticket/10264
Paul B Mahol Feb. 1, 2024, 9:15 p.m. UTC | #3
On Thu, Feb 1, 2024 at 9:41 PM Connor Worley <connorbworley@gmail.com>
wrote:

> Got some confirmation that this patch fixes
> https://trac.ffmpeg.org/ticket/10264
>
>
Thanks for the fix. I had encountered similar artifacts but failed to fix
it, and then removed files long ago, but i got them from the web so will
recheck if this indeed fixes it too.


> --
> Connor Worley
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>
Connor Worley Feb. 5, 2024, 6:31 a.m. UTC | #4
Given that Paul is no longer a maintainer, can someone else please take a
look?
diff mbox series

Patch

diff --git a/libavcodec/dxv.c b/libavcodec/dxv.c
index b29adf8ad9..be1216da86 100644
--- a/libavcodec/dxv.c
+++ b/libavcodec/dxv.c
@@ -755,7 +755,7 @@  static int dxv_decompress_dxt5(AVCodecContext *avctx)
                 break;
             case 2:
                 /* Copy two dwords from a previous index */
-                idx = 8 + bytestream2_get_le16(gbc);
+                idx = 8 + 4 * bytestream2_get_le16(gbc);
                 if (idx > pos || (unsigned int)(pos - idx) + 2 > ctx->tex_size / 4)
                     return AVERROR_INVALIDDATA;
                 prev = AV_RL32(ctx->tex_data + 4 * (pos - idx));