diff mbox series

[FFmpeg-devel,2/2] lavc/dxv: treat DXT5-tagged files as DXT4

Message ID 20240202003400.30850-2-connorbworley@gmail.com
State New
Headers show
Series [FFmpeg-devel,1/2] lavc/texturedsp: fix premult2straight inversion | expand

Checks

Context Check Description
yinshiyou/commit_msg_loongarch64 warning Please wrap lines in the body of the commit message between 60 and 72 characters.
andriy/commit_msg_x86 warning Please wrap lines in the body of the commit message between 60 and 72 characters.
andriy/make_x86 success Make finished
andriy/make_fate_x86 fail Make fate failed

Commit Message

Connor Worley Feb. 2, 2024, 12:34 a.m. UTC
DXV files seem to misnomer DXT5 and really encode DXT4 with premultiplied alpha.
At least, this is what Resolume alley does. To check, encode some input with alpha
as "Normal Quality, With Alpha" in Alley, then decode the output with this change
-- results are true to the original input compared to git-master.

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

Comments

Connor Worley Feb. 2, 2024, 12:53 a.m. UTC | #1
Attached is a comparison of the input and decoding with DXT4 and DXT5.

DXT5 produces dark outlines that are not present in the input.

Also, I have a prototype "Normal Quality, With Alpha" encoder that produces
nasty results in Resolume unless alpha is premultiplied. All of this points
to DXV misnomering DXT5.
diff mbox series

Patch

diff --git a/libavcodec/dxv.c b/libavcodec/dxv.c
index 5923811b29..1e6791e63f 100644
--- a/libavcodec/dxv.c
+++ b/libavcodec/dxv.c
@@ -1074,7 +1074,8 @@  static int dxv_decode(AVCodecContext *avctx, AVFrame *frame,
         break;
     case MKBETAG('D', 'X', 'T', '5'):
         decompress_tex = dxv_decompress_dxt5;
-        ctx->tex_funct = ctx->texdsp.dxt5_block;
+        /* DXV misnomers DXT5, alpha is premultiplied so use DXT4 instead */
+        ctx->tex_funct = ctx->texdsp.dxt4_block;
         ctx->tex_rat   = 4;
         ctx->tex_step  = 16;
         msgcomp = "DXTR5";