[FFmpeg-trac] #10407(avcodec:new): Incorrect decode of 32 bit DWA encoded EXR
FFmpeg
trac at avcodec.org
Thu Jun 8 09:45:42 EEST 2023
#10407: Incorrect decode of 32 bit DWA encoded EXR
-------------------------------------+-------------------------------------
Reporter: | Type: defect
slipperyseal |
Status: new | Priority: normal
Component: avcodec | Version: git-
Keywords: exr dwaa | master
dwab | Blocked By:
Blocking: | Reproduced by developer: 0
Analyzed by developer: 0 |
-------------------------------------+-------------------------------------
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
}}}
--
Ticket URL: <https://trac.ffmpeg.org/ticket/10407>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker
More information about the FFmpeg-trac
mailing list