Hi,

On Thu, Jan 12, 2012 at 11:14 AM, Paul B Mahol <[email protected]> wrote:
> ---
>  libswscale/rgb2rgb.c          |   12 ++++++++++++
>  libswscale/rgb2rgb.h          |    1 +
>  libswscale/swscale_unscaled.c |    1 +
>  3 files changed, 14 insertions(+), 0 deletions(-)
>
> diff --git a/libswscale/rgb2rgb.c b/libswscale/rgb2rgb.c
> index 9fbb6cf..802ed96 100644
> --- a/libswscale/rgb2rgb.c
> +++ b/libswscale/rgb2rgb.c
> @@ -183,6 +183,18 @@ void rgb16tobgr32(const uint8_t *src, uint8_t *dst, int 
> src_size)
>     }
>  }
>
> +void rgb12to15(const uint8_t *src, uint8_t *dst, int src_size)
> +{
> +    const uint16_t *end;
> +    uint16_t *d = (uint16_t *)dst;
> +    const uint16_t *s = (const uint16_t *)src;
> +    end = s + src_size/2;
> +    while (s < end) {
> +        *d++ = ((*s & 0xF00) << 3) | ((*s & 0xF0) << 2) | ((*s & 0xF) << 1);
> +        s++;
> +    }
> +}

This leaves the bottom bits empty. I'd prefer something that is
perhaps slightly slower, but more accurate:

rgb = *s;
r   = rgb & 0xf00;
g   = rgb & 0x0f0;
b   = rgb & 0x00f;
r   = (r << 3) | ((r & 0x800) >> 1);
g   = (g << 2) | ((g & 0x080) >> 2);
b   = (b << 1) | ((b & 0x008) >> 3);
*d = r | g | b;

Ronald
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to