[FFmpeg-devel] [RFC] Bayer colorspaces: CODEC_ID, PIX_FMT or both?

Måns Rullgård mans
Sun Jan 30 02:02:01 CET 2011

Peter Ross <pross at xvid.org> writes:

> Hi,
> Any ideas/comments/opinions on how bayer colorspaces should be handled
> by FFmpeg. Here the advantages that I can see of each approach.
> 1. PIX_FMT
> Enables avfilters to be written that operate on native bayer colorspace.
> Other users of libswscale can take advantage of these.
> Easy route; no changes required to libswscale, pixdesc, et al
> Some bayer implementations pack the samples. e.g. 12-bit RGGB, means
> each sample consumes 12 bits in memory. Other bayer implementations
> pad each samples out to 16-bits.
> A hybrid implementation would have PIX_FMTs defined for 8-bit and
> 16-bit sample sizes, and make a BAYER codec available to unpack the
> samples into PIX_FMT_BAYER_xxxx16{LE|BE}
> Comments?

There is already a precedent for a hybrid approach: the v210 codec
converts packed 10-bit YUV4:2:2 to/from 16-bit.  There are also the
audio sample formats, where normal ones are handled simply as a
SampleFormat, while more exotic packings (e.g. DVD 24-bit) use a

I think a similar approach makes sense for Bayer formats, i.e.
byte-aligned variants should get a PixelFormat while more imaginative
packings get decoded into a nicer form (still Bayer).

M?ns Rullg?rd
mans at mansr.com

More information about the ffmpeg-devel mailing list