Skip to content

flacparse: fix broken reordering of flac metadata

Each FLAC metadata block starts with a flag denoting whether it is the last metadata block. The existing flacparse code moves any existing VORBISCOMMENT block to immediately follow the STREAMINFO block without changing any block's last-metadata-block flag. If no VORBISCOMMENT block exists, it created one with the last-metadata-block flag set to true. This results in gstflacdec sometimes giving bad headers to libflac when trying to play perfectly valid FLAC files depending on the file's metadata ordering. Depending on the contents of the other metadata blocks, current versions of libflac may or may not return FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER when given this broken metadata. This is most noticeable with files that have a large cover art image attached where VORBISCOMMENT is the very last metadata block with no PADDING afterwards.

This patch changes that behavior so that:

  1. For FLAC files that already have a VORBISCOMMENT block, the metadata order is preserved.
  2. For FLAC files that do not have a VORBISCOMMENT block, the generated dummy VORBISCOMMENT is placed immediately after STREAMINFO and inherits the last-metadata-block flag from STREAMINFO.

#484 (closed)

Edited by Jennifer Berringer

Merge request reports