[flac-dev] METADATA_BLOCK_PICTURE indexed-color field

Ralph Giles giles at thaumas.net
Wed Jul 7 15:49:35 UTC 2021


I think it makes the most sense to consider these fields informational.
So a programme might display it in a 'properties' panel, or use it to
label the image in an index, or even use it to choose which picture to
display when there are multiple options.

But it can't really be used for critical decisions, like allocating an
buffer to receive the decoded image. Any time you have a header with
duplicate information like this (the same information is usually
available in the image data stream) then the copy in the header can be
incorrect, and players have to handle that by either rejecting the file
(unfriendly unless everyone does it) or picking which one to expect.

As Martijn says, figuring this out for gif is work, and even for png
the flac code indicates it's not as easy as you'd think. Indexed image
*displays* (as opposed to image files) are also rare these days, so
getting it right isn't critical. The SHOULD distinction compared with
MUST for the width and height probably reflect this.

It looks like the flac code tries, but punts when determining an
accurate count is complicated. Copying this code, or doing something
similar based on your own project's image decoders should be fine.

IMHO,
Ralph

On Wed, 2021-07-07 at 15:05 +0200, Martijn van Beurden wrote:
> Op ma 5 jul. 2021 om 15:07 schreef leo60228 <leo at 60228.dev>:
> > I'm not clear on the utility of this. Do any programs made use of
> > it?
> > What do they use it for?
> 
> It's hard to tell whether any program uses this. The manual says
> 
> Otherwise, you must specify the width in pixels, height in pixels,
> and
> color depth in bits-per-pixel. If the image has indexed colors you
> should also specify the number of colors used. When manually
> specified, it is not checked against the file for accuracy.
> 
> It says should, where it says color depth must be specified. I cannot
> find out how FLAC actually sets this by itself. Maybe you can
> decipher
> this bit of code to find out:
> https://github.com/xiph/flac/blob/master/src/share/grabbag/picture.c#L259
> _______________________________________________
> flac-dev mailing list
> flac-dev at xiph.org
> http://lists.xiph.org/mailman/listinfo/flac-dev




More information about the flac-dev mailing list