diff options
author | Amaury Pouly <pamaury@rockbox.org> | 2011-07-24 19:12:27 +0000 |
---|---|---|
committer | Amaury Pouly <pamaury@rockbox.org> | 2011-07-24 19:12:27 +0000 |
commit | 855e3c6f0f7b32375b054781fd4d419e1b0fc306 (patch) | |
tree | 69e41e99885bf6fac7912ba487b51f6229708b53 | |
parent | 1df8072c08134c72327cd90c1e5fe858d139a66e (diff) |
imx233/fuze+: implement lcd_blit_yuv (untested)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30207 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | firmware/target/arm/imx233/sansa-fuzeplus/lcd-fuzeplus.c | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/firmware/target/arm/imx233/sansa-fuzeplus/lcd-fuzeplus.c b/firmware/target/arm/imx233/sansa-fuzeplus/lcd-fuzeplus.c index dba54373be..2e49e4d3d0 100644 --- a/firmware/target/arm/imx233/sansa-fuzeplus/lcd-fuzeplus.c +++ b/firmware/target/arm/imx233/sansa-fuzeplus/lcd-fuzeplus.c @@ -18,6 +18,7 @@ * KIND, either express or implied. * ****************************************************************************/ +#include <sys/types.h> /* off_t */ #include <string.h> #include "cpu.h" #include "system.h" @@ -35,6 +36,8 @@ extern void lcd_copy_buffer_rect(fb_data *dst, const fb_data *src, int width, int height); +static unsigned lcd_yuv_options = 0; + #ifdef HAVE_LCD_ENABLE static bool lcd_on = false; #endif @@ -517,3 +520,74 @@ void lcd_update_rect(int x, int y, int width, int height) (void) height; lcd_update(); } + +void lcd_yuv_set_options(unsigned options) +{ + lcd_yuv_options = options; +} + +/* Line write helper function for lcd_yuv_blit. Write two lines of yuv420. */ +extern void lcd_write_yuv420_lines(fb_data *dst, + unsigned char const * const src[3], + int width, + int stride); +extern void lcd_write_yuv420_lines_odither(fb_data *dst, + unsigned char const * const src[3], + int width, + int stride, + int x_screen, /* To align dither pattern */ + int y_screen); +/* Performance function to blit a YUV bitmap directly to the LCD */ +/* So the LCD_WIDTH is now the height */ +void lcd_blit_yuv(unsigned char * const src[3], + int src_x, int src_y, int stride, + int x, int y, int width, int height) +{ + /* Caches for chroma data so it only need be recaculated every other + line */ + unsigned char const * yuv_src[3]; + off_t z; + +#ifdef HAVE_LCD_ENABLE + if (!lcd_on) + return; +#endif + + /* Sorry, but width and height must be >= 2 or else */ + width &= ~1; + height >>= 1; + + y = LCD_WIDTH - 1 - y; + fb_data *dst = (fb_data*)FRAME + x * LCD_WIDTH + y; + + z = stride*src_y; + yuv_src[0] = src[0] + z + src_x; + yuv_src[1] = src[1] + (z >> 2) + (src_x >> 1); + yuv_src[2] = src[2] + (yuv_src[1] - src[1]); + + if (lcd_yuv_options & LCD_YUV_DITHER) + { + do + { + lcd_write_yuv420_lines_odither(dst, yuv_src, width, stride, y, x); + yuv_src[0] += stride << 1; /* Skip down two luma lines */ + yuv_src[1] += stride >> 1; /* Skip down one chroma line */ + yuv_src[2] += stride >> 1; + dst -= 2; + y -= 2; + } + while (--height > 0); + } + else + { + do + { + lcd_write_yuv420_lines(dst, yuv_src, width, stride); + yuv_src[0] += stride << 1; /* Skip down two luma lines */ + yuv_src[1] += stride >> 1; /* Skip down one chroma line */ + yuv_src[2] += stride >> 1; + dst -= 2; + } + while (--height > 0); + } +} |