[FFmpeg-trac] #11279(avcodec:new): Aspect ratio defined by the PNG resolution chunk “pHYs” is misinterpreted as its reciprocal

FFmpeg trac at avcodec.org
Fri Nov 1 13:26:58 EET 2024


#11279: Aspect ratio defined by the PNG resolution chunk “pHYs” is misinterpreted
as its reciprocal
------------------------------------+-----------------------------------
             Reporter:  goodbye     |                    Owner:  (none)
                 Type:  defect      |                   Status:  new
             Priority:  normal      |                Component:  avcodec
              Version:  git-master  |               Resolution:
             Keywords:  png         |               Blocked By:
             Blocking:              |  Reproduced by developer:  0
Analyzed by developer:  0           |
------------------------------------+-----------------------------------
Description changed by goodbye:

Old description:

> The PNG {{{pHYs}}} chunk describes the resolution/pixel density of an
> image, which can be in abstract units (in which case it only defines the
> pixel aspect ratio) or in pixels per metre.
>
> FFmpeg interprets the X:Y resolution ratio directly as a X:Y PAR, but in
> actuality, it’s the reciprocal.  This is because the resolution is
> specified as a “pixels per unit” value and not “units per pixel”, as is
> typically the case with PARs.  The X:Y PAR is equal to the Y:X ratio of
> resolutions specified in the chunk.
>
> Both of these images, from the libpng test suite, are supposed to have a
> DAR of 1:1, but FFmpeg misinterprets them to have DARs of 16:1 and 1:16:
> * http://www.libpng.org/pub/png/PngSuite/cdhn2c08.png
> * http://www.libpng.org/pub/png/PngSuite/cdfn2c08.png
>
> The issue has been present from the very beginning, since parsing the
> {{{pHYs}}} chunk was introduced in commit
> 8288c2b6cb072b61f664bc8ab4c1b0a5a8db0ead, and is still present as of
> commit 1864025458021a2d2c542f56e268ee1106f84460 (libavcodec/pngdec.c
> lines 648–649)
>
> The PNG encoder has the complementary problem of writing a reciprocal
> ratio into the {{{pHYs}} chunk, introduced with commit
> f58f90238fc63090da34c9fdb1d06d724d929f6d (now libavcodec/pngenc.c lines
> 394–395)

New description:

 The PNG {{{pHYs}}} chunk describes the resolution/pixel density of an
 image, which can be in abstract units (in which case it only defines the
 pixel aspect ratio) or in pixels per metre.

 FFmpeg interprets the X:Y resolution ratio directly as a X:Y PAR, but in
 actuality, it’s the reciprocal.  This is because the resolution is
 specified as a “pixels per unit” value and not “units per pixel”, as is
 typically the case with PARs.  The X:Y PAR is equal to the Y:X ratio of
 resolutions specified in the chunk.

 Both of these images, from the libpng test suite, are supposed to have a
 DAR of 1:1, but FFmpeg misinterprets them to have DARs of 16:1 and 1:16:
 * http://www.libpng.org/pub/png/PngSuite/cdhn2c08.png
 * http://www.libpng.org/pub/png/PngSuite/cdfn2c08.png

 The issue has been present from the very beginning, since parsing the
 {{{pHYs}}} chunk was introduced in commit
 8288c2b6cb072b61f664bc8ab4c1b0a5a8db0ead, and is still present as of
 commit 1864025458021a2d2c542f56e268ee1106f84460 (libavcodec/pngdec.c lines
 648–649)

 The PNG encoder has the complementary problem of writing a reciprocal
 ratio into the {{{pHYs}}} chunk, introduced with commit
 f58f90238fc63090da34c9fdb1d06d724d929f6d (now libavcodec/pngenc.c lines
 394–395)

--
-- 
Ticket URL: <https://trac.ffmpeg.org/ticket/11279#comment:3>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list