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

Connor Worley connorbworley at gmail.com
Tue Jan 30 08:29:03 EET 2024


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 at 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 at 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dice_dxt5.mov
Type: video/quicktime
Size: 132318 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20240129/91dd28de/attachment.mov>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bug.png
Type: image/png
Size: 258957 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20240129/91dd28de/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fix.png
Type: image/png
Size: 232816 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20240129/91dd28de/attachment-0001.png>


More information about the ffmpeg-devel mailing list