summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Chapman <dave@dchapman.com>2006-08-12 09:27:26 +0000
committerDave Chapman <dave@dchapman.com>2006-08-12 09:27:26 +0000
commit7fe7427de8568f78acd447bd072377bdbf406127 (patch)
tree965268a575c7bc66a0620b61d25605c954400cb4
parent2c002d894d00d405b3f08994a95c079d8d108a19 (diff)
downloadrockbox-7fe7427de8568f78acd447bd072377bdbf406127.tar.gz
rockbox-7fe7427de8568f78acd447bd072377bdbf406127.zip
Clean up the #ifdefs surrounding the definition of lcd_yuv_blit() and add an initial (untested) implementation for the Gigabeat
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10541 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/plugins/mpegplayer/video_out_rockbox.c5
-rw-r--r--firmware/export/lcd.h10
-rw-r--r--firmware/target/arm/gigabeat/meg-fx/lcd-meg-fx.c99
3 files changed, 104 insertions, 10 deletions
diff --git a/apps/plugins/mpegplayer/video_out_rockbox.c b/apps/plugins/mpegplayer/video_out_rockbox.c
index cac5cf3d5c..7bce6aadaa 100644
--- a/apps/plugins/mpegplayer/video_out_rockbox.c
+++ b/apps/plugins/mpegplayer/video_out_rockbox.c
@@ -200,10 +200,7 @@ static void rockbox_draw_frame (vo_instance_t * instance,
(void)id;
(void)instance;
-#if (CONFIG_LCD == LCD_IPODCOLOR || CONFIG_LCD == LCD_IPODNANO \
- || CONFIG_LCD == LCD_H300 || CONFIG_LCD == LCD_IPODVIDEO \
- || CONFIG_LCD == LCD_X5) \
- && !defined(SIMULATOR)
+#if defined(HAVE_LCD_COLOR) && !defined(SIMULATOR)
rb->lcd_yuv_blit(buf,
0,0,image_width,
output_x,output_y,output_width,output_height);
diff --git a/firmware/export/lcd.h b/firmware/export/lcd.h
index 147940fa4f..b74a9d30c7 100644
--- a/firmware/export/lcd.h
+++ b/firmware/export/lcd.h
@@ -71,12 +71,10 @@ extern void lcd_puts_scroll_style(int x, int y, const unsigned char* string,
int style);
extern void lcd_icon(int icon, bool enable);
-#if CONFIG_LCD == LCD_IPODCOLOR || CONFIG_LCD == LCD_IPODNANO \
- || CONFIG_LCD == LCD_H300 || CONFIG_LCD == LCD_IPODVIDEO \
- || CONFIG_LCD == LCD_X5
-void lcd_yuv_blit(unsigned char * const src[3],
- int src_x, int src_y, int stride,
- int x, int y, int width, int height);
+#if defined(HAVE_LCD_COLOR) && !defined(SIMULATOR)
+extern void lcd_yuv_blit(unsigned char * const src[3],
+ int src_x, int src_y, int stride,
+ int x, int y, int width, int height);
#endif
#if defined(SIMULATOR) || defined(HAVE_LCD_BITMAP)
diff --git a/firmware/target/arm/gigabeat/meg-fx/lcd-meg-fx.c b/firmware/target/arm/gigabeat/meg-fx/lcd-meg-fx.c
index 5ec62271ad..7c8185d6c8 100644
--- a/firmware/target/arm/gigabeat/meg-fx/lcd-meg-fx.c
+++ b/firmware/target/arm/gigabeat/meg-fx/lcd-meg-fx.c
@@ -29,3 +29,102 @@ void lcd_update(void)
{
lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT);
}
+
+#define CSUB_X 2
+#define CSUB_Y 2
+
+#define RYFAC (31*257)
+#define GYFAC (63*257)
+#define BYFAC (31*257)
+#define RVFAC 11170 /* 31 * 257 * 1.402 */
+#define GVFAC (-11563) /* 63 * 257 * -0.714136 */
+#define GUFAC (-5572) /* 63 * 257 * -0.344136 */
+#define BUFAC 14118 /* 31 * 257 * 1.772 */
+
+#define ROUNDOFFS (127*257)
+
+/* Performance function to blit a YUV bitmap directly to the LCD */
+void lcd_yuv_blit(unsigned char * const src[3],
+ int src_x, int src_y, int stride,
+ int x, int y, int width, int height)
+{
+ fb_data *dst, *dst_end;
+
+ width = (width + 1) & ~1;
+
+ dst = (fb_data*)FRAME + LCD_WIDTH * y + x;
+ dst_end = dst + LCD_WIDTH * height;
+
+ do
+ {
+ fb_data *dst_row = dst;
+ fb_data *row_end = dst_row + width;
+ const unsigned char *ysrc = src[0] + stride * src_y + src_x;
+ int y, u, v;
+ int red, green, blue;
+ unsigned rbits, gbits, bbits;
+
+ /* upsampling, YUV->RGB conversion and reduction to RGB565 in one go */
+ const unsigned char *usrc = src[1] + (stride/CSUB_X) * (src_y/CSUB_Y)
+ + (src_x/CSUB_X);
+ const unsigned char *vsrc = src[2] + (stride/CSUB_X) * (src_y/CSUB_Y)
+ + (src_x/CSUB_X);
+ int xphase = src_x % CSUB_X;
+ int rc, gc, bc;
+
+ u = *usrc++ - 128;
+ v = *vsrc++ - 128;
+ rc = RVFAC * v + ROUNDOFFS;
+ gc = GVFAC * v + GUFAC * u + ROUNDOFFS;
+ bc = BUFAC * u + ROUNDOFFS;
+
+ do
+ {
+ y = *ysrc++;
+ red = RYFAC * y + rc;
+ green = GYFAC * y + gc;
+ blue = BYFAC * y + bc;
+
+ if ((unsigned)red > (RYFAC*255+ROUNDOFFS))
+ {
+ if (red < 0)
+ red = 0;
+ else
+ red = (RYFAC*255+ROUNDOFFS);
+ }
+ if ((unsigned)green > (GYFAC*255+ROUNDOFFS))
+ {
+ if (green < 0)
+ green = 0;
+ else
+ green = (GYFAC*255+ROUNDOFFS);
+ }
+ if ((unsigned)blue > (BYFAC*255+ROUNDOFFS))
+ {
+ if (blue < 0)
+ blue = 0;
+ else
+ blue = (BYFAC*255+ROUNDOFFS);
+ }
+ rbits = ((unsigned)red) >> 16 ;
+ gbits = ((unsigned)green) >> 16 ;
+ bbits = ((unsigned)blue) >> 16 ;
+ *dst_row++ = (rbits << 11) | (gbits << 5) | bbits;
+
+ if (++xphase >= CSUB_X)
+ {
+ u = *usrc++ - 128;
+ v = *vsrc++ - 128;
+ rc = RVFAC * v + ROUNDOFFS;
+ gc = GVFAC * v + GUFAC * u + ROUNDOFFS;
+ bc = BUFAC * u + ROUNDOFFS;
+ xphase = 0;
+ }
+ }
+ while (dst_row < row_end);
+
+ src_y++;
+ dst += LCD_WIDTH;
+ }
+ while (dst < dst_end);
+}