Opened 6 months ago

Last modified 3 months ago

#10640 new defect

Incorrect interpretation of PNG data in "monob" pixel format

Reported by: Joey Sodergren Owned by:
Priority: normal Component: ffmpeg
Version: 6.1 Keywords: png
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:
Since this summer, I've been doing a lot of experimentation with PNG optimization. As part of my process, I started running files through FFMPEG to re-encode them as a sort of "encoding normalization" step. (Don't ask why this is necessary... I experimentally proved it helped the rest of my system produce better / smaller results.) I have recently discovered a bug in FFMPEG's ability to read some PNG files. While FFMPEG does appear to be aware that images in the pal8 pixel format can contain transparency data, it does not appear to be aware that images in the monob pixel format can also contain transparency data, and is improperly crushing it to opaque pixels.

How to reproduce:

  1. The files Palette_Mode.png and Monob_Mode.png are encoded with different pixel formats, but they both store their pixels as single bits.
    • These two files should be attached to this ticket.
    • If you download them on Windows, inspect their Properties and open the Details tab. You should see Bit depth 1.
  2. The files Palette_Mode.png and Monob_Mode.png should appear visually identical: fully opaque white glyphs on a fully transparent background.
% ffprobe -hide_banner -v error -show_entries frame=pix_fmt Palette_Mode.png

[FRAME]
pix_fmt=pal8
[/FRAME]

% ffprobe -hide_banner -v error -show_entries frame=pix_fmt Monob_Mode.png

[FRAME]
pix_fmt=monob
[/FRAME]

% ffmpeg -hide_banner -v error -i Palette_Mode.png -c png -pix_fmt rgba -update 1 Pal_Expand.png

% ffmpeg -hide_banner -v error -i Monob_Mode.png -c png -pix_fmt rgba -update 1 Mono_Expand.png

At this point, inspect the files Pal_Expand.png and Mono_Expand.png. The file Pal_Expand.png should appear visually identical to the input. The file Mono_Expand.png, however, should not. Its transparent background will be improperly crushed to opaque black.

Attachments (2)

Palette_Mode.png (781 bytes ) - added by Joey Sodergren 6 months ago.
Monob_Mode.png (715 bytes ) - added by Joey Sodergren 6 months ago.

Download all attachments as: .zip

Change History (5)

by Joey Sodergren, 6 months ago

Attachment: Palette_Mode.png added

by Joey Sodergren, 6 months ago

Attachment: Monob_Mode.png added

comment:1 by Joey Sodergren, 5 months ago

I have upgraded my copy of FFMPEG to 6.1, and I can confirm the issue is still present. (I'm not particularly surprised, though. No one seems to have tested this other than myself.)

Last edited 3 months ago by Joey Sodergren (previous) (diff)

comment:2 by Joey Sodergren, 4 months ago

Version: 6.06.1

comment:3 by Joey Sodergren, 3 months ago

Keywords: png added
Note: See TracTickets for help on using tickets.