[RFC] Bayer colorspaces: CODEC_ID, PIX_FMT or both?
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. 2. CODEC_ID Easy route; no changes required to libswscale, pixdesc, et al 3. BOTH (CODEC_ID and PIX_FMT) 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? -- Peter (A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)
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.
2. CODEC_ID
Easy route; no changes required to libswscale, pixdesc, et al
3. BOTH (CODEC_ID and PIX_FMT)
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 codec. 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
On Sun, Jan 30, 2011 at 11:45:51AM +1100, Peter Ross wrote: [...]
3. BOTH (CODEC_ID and PIX_FMT)
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?
this is best [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Good people do not need laws to tell them to act responsibly, while bad people will find a way around the laws. -- Plato
On Sun, Jan 30, 2011 at 02:20:59AM +0100, Michael Niedermayer wrote:
On Sun, Jan 30, 2011 at 11:45:51AM +1100, Peter Ross wrote: [...]
3. BOTH (CODEC_ID and PIX_FMT)
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.
There are also formats using this approach with ordinary RGB. e.g. 16-bits consumed per R/G/B component, but the dynamic range is 14-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?
this is best
Okay. If the demuxer uses AVCodecContext.bits_per_coded_sample to indicate the number of bits-per-sample, should it describe 'per component sample' or 'per pixel sample'. Enclosed is a patch for scaling up these formats within rawdec. Not sure if rawdec is the best place for this; keen to hear opinions. -- Peter (A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)
participants (4)
-
mans@mansr.com -
michaelni@gmx.at -
Peter Ross -
pross@xvid.org