Index: apps/plugins/mpegplayer/mpegplayer.c =================================================================== --- apps/plugins/mpegplayer/mpegplayer.c (revision 13016) +++ apps/plugins/mpegplayer/mpegplayer.c (working copy) @@ -275,12 +275,12 @@ } #ifndef HAVE_LCD_COLOR - gray_show(false); + //gray_show(false); #endif result = mpeg_menu(); #ifndef HAVE_LCD_COLOR - gray_show(true); + //gray_show(true); #endif /* The menu can change the font, so restore */ @@ -966,8 +966,8 @@ size_t n; size_t disk_buf_len; #ifndef HAVE_LCD_COLOR - long graysize; - int grayscales; + //long graysize; + //int grayscales; #endif /* We define this here so it is on the main stack (in IRAM) */ @@ -1005,15 +1005,15 @@ #ifndef HAVE_LCD_COLOR /* initialize the grayscale buffer: 32 bitplanes for 33 shades of gray. */ - grayscales = gray_init(rb, buffer, buffer_size, false, LCD_WIDTH, LCD_HEIGHT, - 32, 2<<8, &graysize) + 1; - buffer += graysize; - buffer_size -= graysize; - if (grayscales < 33 || buffer_size <= 0) - { - rb->splash(HZ, "gray buf error"); - return PLUGIN_ERROR; - } +// grayscales = gray_init(rb, buffer, buffer_size, false, LCD_WIDTH, LCD_HEIGHT, +// 32, 2<<8, &graysize) + 1; +// buffer += graysize; +// buffer_size -= graysize; +// if (grayscales < 33 || buffer_size <= 0) +// { +// rb->splash(HZ, "gray buf error"); +// return PLUGIN_ERROR; +// } #endif buffer_size &= ~(0x7ff); /* Round buffer down to nearest 2KB */ @@ -1100,7 +1100,7 @@ videostatus = STREAM_PLAYING; #ifndef HAVE_LCD_COLOR - gray_show(true); + //gray_show(true); #endif /* We put the video thread on the second processor for multi-core targets. */ @@ -1152,7 +1152,7 @@ } #ifndef HAVE_LCD_COLOR - gray_release(); + // gray_release(); #endif rb->remove_thread(audiothread_id); Index: apps/plugins/mpegplayer/video_out_rockbox.c =================================================================== --- apps/plugins/mpegplayer/video_out_rockbox.c (revision 13016) +++ apps/plugins/mpegplayer/video_out_rockbox.c (working copy) @@ -187,6 +187,61 @@ } #endif +/* Draw a Bayer ordered dithered bitmap from the luma channel */ +static void dithered_luma_bitmap_part(unsigned char * const src[3], + int src_x, int src_y, int stride, + int x, int y, int width, int height) +{ + static const int pattern[8][8] = { + { 0, 32, 8, 40, 2, 34, 10, 42}, /* 8x8 Bayer ordered dithering */ + {48, 16, 56, 24, 50, 18, 58, 26}, /* pattern. Each input pixel */ + {12, 44, 4, 36, 14, 46, 6, 38}, /* is scaled to the 0..63 range */ + {60, 28, 52, 20, 62, 30, 54, 22}, /* before looking in this table */ + { 3, 35, 11, 43, 1, 33, 9, 41}, /* to determine the action. */ + {51, 19, 59, 27, 49, 17, 57, 25}, + {15, 47, 7, 39, 13, 45, 5, 37}, + {63, 31, 55, 23, 61, 29, 53, 21} }; + const unsigned char *start = src[0]; + +#if 0 + /* nothing to draw? */ + if ((width <= 0) || (height <= 0) || (x >= LCD_WIDTH) || (y >= LCD_HEIGHT) + || (x + width <= 0) || (y + height <= 0)) + return; + + /* clipping */ + if (x < 0) + { + width += x; + src_x -= x; + x = 0; + } + if (y < 0) + { + height += y; + src_y -= y; + y = 0; + } + if (x + width > LCD_WIDTH) + width = LCD_WIDTH - x; + if (y + height > LCD_HEIGHT) + height = LCD_HEIGHT - y; +#endif + + do { + if ((*start++ >> 2) <= pattern[x & 7][y & 7]) { + rb->lcd_drawpixel(x, y); + } + + if (x++ >= width) { + start += stride - x; + y++; + x = 0; + } + } while(y < height); +} + + void vo_draw_frame (uint8_t * const * buf) { #ifdef HAVE_LCD_COLOR @@ -200,15 +255,20 @@ output_x,output_y,output_width,output_height); #endif #else - gray_ub_gray_bitmap_part(buf[0],0,0,image_width, - output_x,output_y,output_width,output_height); + rb->lcd_clear_display(); + dithered_luma_bitmap_part(buf,0,0,image_width, + output_x,output_y,output_width,output_height); + rb->lcd_update_rect(output_x, output_y, output_width, output_height); + +// gray_ub_gray_bitmap_part(buf[0],0,0,image_width, +// output_x,output_y,output_width,output_height); #endif } #if LCD_WIDTH >= LCD_HEIGHT #define SCREEN_WIDTH LCD_WIDTH #define SCREEN_HEIGHT LCD_HEIGHT -#else /* Assume the screen is rotates on portraid LCDs */ +#else /* Assume the screen is rotated on portrait LCDs */ #define SCREEN_WIDTH LCD_HEIGHT #define SCREEN_HEIGHT LCD_WIDTH #endif