[Ffmpeg-devel] New pixel formats

Michael Niedermayer michaelni
Tue Aug 22 21:01:51 CEST 2006


Hi

On Tue, Aug 22, 2006 at 11:56:20AM +0200, Luca Abeni wrote:
> Hi,
> 
> On Sun, 2006-08-20 at 16:45 +0200, Luca Abeni wrote:
> [...]
> > I'll rewrite a (hopefully) more correct conversion table, and I'll post
> > it together with some comments.
> Ok, before doing that I need to fully understand the "RGBA vs ARGB vs
> BGRA vs ABGR" thing...
> 
> So, I read the comment about RGB32 in avutil.h, and I understand that
> RGB32 is stored as BGRA on little endian architectures and ARGB on big
> endian architectures.
> In fact, I see
> #ifdef WORDS_BIGENDIAN
> #define PIX_FMT_BGRA PIX_FMT_NONE
> #define PIX_FMT_ARGB PIX_FMT_RGB32
> #else
> #define PIX_FMT_BGRA PIX_FMT_RGB32
> #define PIX_FMT_ARGB PIX_FMT_NONE
> #endif
> which is ok according to the comment. So, we can add PIX_FMT_BGR32, and
> change the PIX_FMT_NONE above in PIX_FMT_BGR32, right?

no, BGR32 should IMHO be (msb)ABGR(lsb) not (msb)BGRA(lsb)


> Then, we need to add other two formats (any suggestions about good names
> for them?) and to define PIX_FMT_RGBA and PIX_FMT_ABGR to them according
> to the endianess... Is this correct?

yes, we could also change existing names if its needed to keep things sanely
named


> 
> 
> But then I looked at mplayer/libmpcodecs/img_format.h, and I see:
> #ifdef WORDS_BIGENDIAN
> #define IMGFMT_ABGR IMGFMT_RGB32
> #define IMGFMT_BGRA (IMGFMT_RGB32|64)
> #define IMGFMT_ARGB IMGFMT_BGR32
> #define IMGFMT_RGBA (IMGFMT_BGR32|64)
> #else
> #define IMGFMT_ABGR (IMGFMT_BGR32|64)
> #define IMGFMT_BGRA IMGFMT_BGR32
> #define IMGFMT_ARGB (IMGFMT_RGB32|64)
> #define IMGFMT_RGBA IMGFMT_RGB32
> #endif
> which seems to contraddict the definitions in avutil.h: on big endian
> architectures, is ARGB equivalent to BGR32 (as in img_format.h), or to
> RGB32 (as in avutil.h)?
> Or maybe the two files use different naming conventions?

exactly, ffmpeg should follow the idea that the order of the chars in the
name matches the order in memory for formats which are specified based on
memory order
PIX_FMT_BGRA is (first byte)B G R A(last byte)

and it matches the order within a number as displayed normally if the
order is specified within a native integer
PIX_FMT_RGB32 is 0xAARRGGBB


and the names arpi originaly choose for mplayer where based on open gl
i and probably others added more format names to mplayer over the time
currently mplayers RGB names match ffmpeg with the exception of a BGR<->RGB
xchange for stuff specified based on native types

if someone would propose to change either id probably not be opposed ...

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

In the past you could go to a library and read, borrow or copy any book
Today you'd get arrested for mere telling someone where the library is




More information about the ffmpeg-devel mailing list