[Flac-dev] 64-bit FLAC structure sizes and padding
Erik de Castro Lopo
mle+la at mega-nerd.com
Mon May 30 00:20:11 PDT 2011
Jerker Bäck wrote:
> Erik, thanks for the swift answer. Your right, I haven't seen any issues
> yet. But it a thought stroke me when implementing edit capabilities of FLAC
> vorbis comments. I've already implemented reading vorbis comments from FLAC
> files in 64-bit and it works without any issues. This now leave me a bit
> confused, since it should have issues(!).
No it shouldn't, at least not if FLAC was well designed and from
everything I've seen, FLAC is well designed.
> Using the MS 64-bit compiler on Windows 7/2008R2 64-bit. Static libFLAC
> compiled with compiler default 8 byte boundary alignment.
>
> Now consider this:
>
> typedef struct {
> FLAC__uint32 length;
> FLAC__byte *entry;
> } FLAC__StreamMetadata_VorbisComment_Entry;
>
> The compiler (with default settings) should interpret this as
>
> typedef struct {
> FLAC__uint32 length;
> uint32_t __padding;
> FLAC__byte *entry;
> } FLAC__StreamMetadata_VorbisComment_Entry;
>
> Sizeof structure: 32-bit - 8 bytes, 64-bit - 16 bytes
>
> How on earth does the compiler find entry correctly when reading (it does,
> but how)?
The compiler figures this out because the platform ABI [0]
specifies how much padding there is and all compilers should
follow the platform ABI.
Furthermore, the structs above are *only* for communication
between the client application and the library. Those structs
are not actually used to store data in a FLAC file.
HTH,
Erik
[0] https://secure.wikimedia.org/wikipedia/en/wiki/Application_binary_interface
--
----------------------------------------------------------------------
Erik de Castro Lopo
http://www.mega-nerd.com/
More information about the Flac-dev
mailing list