I'm not sure whether the question might get lost in mplayer-cvslog, so here once more: 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? Ingo
Hi, On Tue, Apr 05, 2011 at 10:30:32PM +0200, Ingo Brückl wrote:
I'm not sure whether the question might get lost in mplayer-cvslog, so here once more:
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? Regards, Erik -- Ringing telephones (and other symmetric communication lines) are the bane of focused work. -- René Pfeiffer
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
On Tue, Apr 05, 2011 at 10:30:32PM +0200, Ingo Brückl wrote:
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?
The PNG specification is irrelevant. The libavcodec decoder decodes to PIX_FMT_RGB32 which means each pixel is a 32 bit value in native endianness with the (I think) highest bits being red, followed by green and blue. Since the code works byte-wise, it is correct to do different things on big- and little-endian.
participants (3)
-
Erik Auerswald -
Ingo Brückl -
Reimar Döffinger