[FFmpeg-devel] Adding 10-bit depth YUV

Øyvind Kolås pippin
Sat May 12 04:08:27 CEST 2007


On 5/11/07, Michael Niedermayer <michaelni at gmx.at> wrote:
> On Fri, May 11, 2007 at 01:55:40PM +0200, ?yvind Kol?s wrote:
> > On 5/10/07, Michael Niedermayer <michaelni at gmx.at> wrote:
> iam not speaking about n routines to convert n formats we have that since
> years but 1 routine to convert n formats based on a description of the
> format (like where how many bits are which component ...)
> the intent is to make it very easy to add new pixel formats and then
> just write fast conversation functions when its actually needed

This is exactly what babl provides.

A sample of some of the code in babl/base/model-ycbcr.c

static void
formats (void)
{
  babl_format_new (
    "name", "Y'CbCr u8",
    "id", BABL_YCBCR420,
    "planar",
    babl_model_id (BABL_YCBCR),
    babl_type_id (BABL_U8_LUMA),
    babl_sampling (1, 1),
    babl_component_id (BABL_LUMA),
    babl_type_id (BABL_U8_CHROMA),
    babl_sampling (2, 2),
    babl_component_id (BABL_CB),
    babl_sampling (2, 2),
    babl_component_id (BABL_CR),
    NULL);
  return;

  babl_format_new (
    "name", "y'cbcr420",
    "id", BABL_YCBCR420,
    "planar",
    babl_model_id (BABL_YCBCR),
    babl_type_id (BABL_U8_LUMA),
    babl_sampling (1, 1),
    babl_component_id (BABL_LUMA),
    babl_type_id (BABL_U8_CHROMA),
    babl_sampling (2, 2),
    babl_component_id (BABL_CB),
    babl_sampling (2, 2),
    babl_component_id (BABL_CR),
    NULL);

This registers a new named format, with a given model, and the
corresponding packing
of the named components, and their datatypes.

> also anything float is unacceptable

The floating point code in babl is only run to verify that the
bitshifting/sse/foo code is performing the conversions correctly on
small sample buffers. Only if there are no chain of fast paths
available conversions the fallback floating point code is run.
Profiling provides insight into which additional fast paths must be
added.

This works quite well for me now, but a solution I would find even
more elegant would be to keep the grammar for describing new models,
components and formats but use a retargetable JIT compiler that
created optimal conversions.

/?yvind K.
-- 
?The future is already here. It's just not very evenly distributed?
                                                 -- William Gibson
http://pippin.gimp.org/                            http://ffii.org/




More information about the ffmpeg-devel mailing list