Search
lxdream.org :: lxdream/src/pvr2/yuv.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/pvr2/yuv.c
changeset 281:2019e605cb27
next282:01e53698ff38
author nkeynes
date Sun Jan 14 02:55:25 2007 +0000 (13 years ago)
permissions -rw-r--r--
last change Add work-in-progress YUV support
file annotate diff log raw
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/src/pvr2/yuv.c Sun Jan 14 02:55:25 2007 +0000
1.3 @@ -0,0 +1,61 @@
1.4 +/**
1.5 + * $Id: yuv.c,v 1.1 2007-01-14 02:55:25 nkeynes Exp $
1.6 + *
1.7 + * YUV420 and YUV422 decoding
1.8 + *
1.9 + * Copyright (c) 2005 Nathan Keynes.
1.10 + *
1.11 + * This program is free software; you can redistribute it and/or modify
1.12 + * it under the terms of the GNU General Public License as published by
1.13 + * the Free Software Foundation; either version 2 of the License, or
1.14 + * (at your option) any later version.
1.15 + *
1.16 + * This program is distributed in the hope that it will be useful,
1.17 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.19 + * GNU General Public License for more details.
1.20 + */
1.21 +#include "dream.h"
1.22 +
1.23 +#define YUV420_BLOCK_SIZE 384
1.24 +
1.25 +static inline uint16_t decode_yuv420_to_rgb565_pixel( uint8_t y, uint8_t u, uint8_t v )
1.26 +{
1.27 +
1.28 +
1.29 +}
1.30 +
1.31 +/**
1.32 + * Convert a single 16x16 yuv420 block to rgb565.
1.33 + * @param dest output memory location for this block
1.34 + * @param src start of source block
1.35 + * @param stride length of overall line in pixels (ie 16-bit words)
1.36 + */
1.37 +static void decode_yuv420_to_rgb565_block( uint16_t *dest, uint8_t *src, uint32_t stride )
1.38 +{
1.39 + uint8_t *up = *src;
1.40 + uint8_t *vp = u + 64;
1.41 + uint8_t *yp = v + 64;
1.42 +
1.43 + for( int yb=0; yb<16; yb++ ) {
1.44 + for( int xb=0; xb<16; xb++ ) {
1.45 + uint8_t y = *yp++;
1.46 + uint8_t u = up[xb>>1 + (yb>>1)<<3];
1.47 + uint8_t v = vp[xb>>1 + (yb>>1)<<3];
1.48 + *dest++ = decode_yuv420_to_rgb565_block(y,u,v);
1.49 + }
1.50 + dest = dest + stride - 16;
1.51 + }
1.52 +}
1.53 +
1.54 +void decode_yuv420_to_rgb565( uint16_t *dest, uint8_t *src, int width, int height )
1.55 +{
1.56 + uint16_t *p;
1.57 + for( int j=0; j<height; j++ ) {
1.58 + for( int i=0; i<width; i++ ) {
1.59 + p = dest + (j<<5)*width + i<<5;
1.60 + decode_yuv420_to_rgb565_block( p, src, width );
1.61 + src += YUV420_BLOCK_SIZE;
1.62 + }
1.63 + }
1.64 +}
.