#10407 closed defect (fixed)

Incorrect decode of 32 bit DWA encoded EXR

Reported by: slipperyseal Owned by:
Priority: normal Component: avcodec
Version: git-master Keywords: exr dwaa dwab
Cc: slipperyseal Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

I created 16 and 32 bit DWA encoded EXR images from the same source image (from Blender).

16 bit DWA files decode fine in ffmpeg while there seems to be an issue with 32 bit DWA.

Looking at the code I can see when decoding DWA EXR files, ffmpeg runs 16 bit or 32 bit decoders but always targets a 32bit space. There is common code which then transforms that intermediate output to linear space.

libavcodec/exr.c

On line 1122 is a scaling factor for the linear space conversion.

const float scale = s->pixel_type == EXR_FLOAT ? 2.f : 1.f;

When pixels are EXR_FLOAT (32 bit) the scaling factor is set to 2.f which produces underexposed images.
If I set the scaling factor to always be 1.0, both file conversions appear correct and "identical".

const float scale = 1.f;

With this change applied, I logged pixel values (prior to apply_trc) and saw the results almost identical (probably because of float size precision).

Perhaps this scaling factor was originally required at one time but now is compensated for in the 32 bit decoder?

I havn't been able to locate any DWA files other than those I generate with Blender, but I can confirm that when importing both types into DaVinci Resolve, they appear identical. Therefor I don't think the 32 bit file is at fault.

Note that a RGB colour space conversion also needs to be applied when converting EXRs.

# Convert dwaa_16_0001.exr to png

ffmpeg -y -start_number 1 -f image2 -apply_trc iec61966_2_1 -i dwaa_16_%04d.exr dwaa_16_%04d.png

# Convert dwaa_32_0001.exr to png

ffmpeg -y -start_number 1 -f image2 -apply_trc iec61966_2_1 -i dwaa_32_%04d.exr dwaa_32_%04d.png

Attachments (2)

dwaa_16_0001.exr (91.1 KB ) - added by slipperyseal 18 months ago.
16 bit DWA EXR file for testing
dwaa_32_0001.exr (91.1 KB ) - added by slipperyseal 18 months ago.
32 bit DWA EXR file for testing

Download all attachments as: .zip

Change History (3)

by slipperyseal, 18 months ago

Attachment: dwaa_16_0001.exr added

16 bit DWA EXR file for testing

by slipperyseal, 18 months ago

Attachment: dwaa_32_0001.exr added

32 bit DWA EXR file for testing

comment:1 by Elon Musk, 18 months ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.