[FFmpeg-devel] [PATCH] RGB48 support

Michael Niedermayer michaelni
Mon May 21 22:04:59 CEST 2007


Hi

On Mon, May 21, 2007 at 03:17:32PM +0200, Ivo wrote:
> Hi,
> 
> The attached patch adds RGB48 (i.e. 16-bits per component) support to 
> libswscale. This opens up the possibility to support full-blown PAM/PPM as 
> well as DXT/Cineon.

this adds alot of specific convertion functions, they should either be under
#ifndef CONFIG_SMALL or better a more specific define as most users likely
will be happy with the slow and generic convertion code for *48


[...]

> +static inline int rgb48togray16_template(SwsContext *c, uint8_t *src[],
> +                                         int srcStride[], int srcSliceY,
> +                                         int srcSliceH, uint8_t *dst[],
> +                                         int dstStride[], const int srcLE,
> +                                         const int dstLE) {
> +    int length      = c->srcW,
> +        y           = srcSliceY,
> +        height      = srcSliceH,
> +        stride_s2   = srcStride[0] / 2,
> +        stride_d2   = dstStride[0] / 2,
> +        i, j;
> +    unsigned int r, g, b, gray;
> +    const unsigned int fr = 19661, fg = 38666, fb = 7209;
> +    uint16_t *s = (uint16_t *) src[0], *d = (uint16_t *) dst[0] + stride_d2 * y;
> +
> +    for (i=0; i<height; i++) {
> +        for (j=0; j<length; j++) {
> +            r    = srcLE ? le2me_16(s[3*j  ]) : be2me_16(s[3*j  ]);
> +            g    = srcLE ? le2me_16(s[3*j+1]) : be2me_16(s[3*j+1]);
> +            b    = srcLE ? le2me_16(s[3*j+2]) : be2me_16(s[3*j+2]);
> +            gray = (fr*r + fg*g + fb*b) >> 16;
> +            d[j] = dstLE ? le2me_16(gray) : be2me_16(gray);
> +        }
> +        s += stride_s2;
> +        d += stride_d2;
> +    }
> +    return height;
> +}

is it really needed to include this funtion 4 times in the object?
wouldnt a simple if/else per line and maybe a optional bswap pass
for non-native gray work too?

also the coeffs should not be hardcoded but rather taken depending
on the selected colorspace stuff, thought thats a minor nitpick
which also applies to plenty of already existing code


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

Dictatorship naturally arises out of democracy, and the most aggravated
form of tyranny and slavery out of the most extreme liberty. -- Plato
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070521/306e37d8/attachment.pgp>



More information about the ffmpeg-devel mailing list