[MPlayer-dev-eng] PNG and endianness

Ingo Brückl ib at wupperonline.de
Wed Apr 6 12:48:14 CEST 2011


Erik Auerswald wrote on Wed, 6 Apr 2011 10:09:50 +0200:

>>   static void Normalize (txSample *bf)
>>   {
>>     unsigned long i;
>>
>>     for (i = 0; i < bf->ImageSize; i += 4)
>>   #if HAVE_BIGENDIAN
>>       bf->Image[i] = 0;
>>   #else
>>       bf->Image[i + 3] = 0;
>>   #endif
>>   }
>>
>> The PNG specification says that all integers that require more than one byte
>> shall be in network byte order which is big-endian AFAIK, so there should not
>> be such distinction, should it?

> So on big endian systems the PNG integers are in native byte order,
> for little endian systems they are not. The distinction seems to be
> needed. Does it work?

Of course it works (on my - little-endian - machine). It seems that I made
some thoughtless errors.

First of all I thought that the (32 bpp) pixel format is ARGB in png files,
which is wrong. It is RGBA.

Secondly I thought that the png pixel(s format) gets copied into the Image
buffer, but this is wrong. The buffer gets filled BGRA. (I assume that is
because of the litte-endianness of my machine and done by
avcodec_decode_video2() and/or memcpy_pic().)

I assume now that the buffer won't get filled RGBA on big-endian machines,
but ARGB.

BTW, what is the data format avcodec_decode_video2() and memcpy_pic()
produce? Is it Bitmap Image File format data? (This would be ARGB and thus
stored BGRA on little-endian machines.)

Ingo


More information about the MPlayer-dev-eng mailing list