diff options
Diffstat (limited to 'apps/plugins')
-rw-r--r-- | apps/plugins/jpeg/yuv2rgb.c | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/apps/plugins/jpeg/yuv2rgb.c b/apps/plugins/jpeg/yuv2rgb.c index ed88d5416a..2395f232b2 100644 --- a/apps/plugins/jpeg/yuv2rgb.c +++ b/apps/plugins/jpeg/yuv2rgb.c | |||
@@ -236,7 +236,20 @@ static fb_data (* const pixel_funcs[COLOUR_NUM_MODES][DITHER_NUM_MODES])(void) = | |||
236 | [DITHER_DIFFUSION] = pixel_fsdither_to_lcd, | 236 | [DITHER_DIFFUSION] = pixel_fsdither_to_lcd, |
237 | }, | 237 | }, |
238 | }; | 238 | }; |
239 | 239 | ||
240 | /* These defines are used fornormal horizontal strides and vertical strides. */ | ||
241 | #if defined(LCD_STRIDEFORMAT) && LCD_STRIDEFORMAT == VERTICAL_STRIDE | ||
242 | #define LCDADDR(x, y) (rb->lcd_framebuffer + LCD_HEIGHT*(x) + (y)) | ||
243 | #define ROWENDOFFSET (width*LCD_HEIGHT) | ||
244 | #define ROWOFFSET (1) | ||
245 | #define COLOFFSET (LCD_HEIGHT) | ||
246 | #else | ||
247 | #define LCDADDR(x, y) (rb->lcd_framebuffer + LCD_WIDTH*(y) + (x)) | ||
248 | #define ROWENDOFFSET (width) | ||
249 | #define ROWOFFSET (LCD_WIDTH) | ||
250 | #define COLOFFSET (1) | ||
251 | #endif | ||
252 | |||
240 | /** | 253 | /** |
241 | * Draw a partial YUV colour bitmap | 254 | * Draw a partial YUV colour bitmap |
242 | * | 255 | * |
@@ -251,6 +264,7 @@ void yuv_bitmap_part(unsigned char *src[3], int csub_x, int csub_y, | |||
251 | fb_data *dst, *dst_end; | 264 | fb_data *dst, *dst_end; |
252 | fb_data (*pixel_func)(void); | 265 | fb_data (*pixel_func)(void); |
253 | struct rgb_pixel px; | 266 | struct rgb_pixel px; |
267 | int dst_inc; | ||
254 | 268 | ||
255 | if (x + width > LCD_WIDTH) | 269 | if (x + width > LCD_WIDTH) |
256 | width = LCD_WIDTH - x; /* Clip right */ | 270 | width = LCD_WIDTH - x; /* Clip right */ |
@@ -268,8 +282,8 @@ void yuv_bitmap_part(unsigned char *src[3], int csub_x, int csub_y, | |||
268 | 282 | ||
269 | pixel = &px; | 283 | pixel = &px; |
270 | 284 | ||
271 | dst = rb->lcd_framebuffer + LCD_WIDTH * y + x; | 285 | dst = LCDADDR(x, y); |
272 | dst_end = dst + LCD_WIDTH * height; | 286 | dst_end = LCDADDR(x, y+height); |
273 | 287 | ||
274 | if (colour_mode == COLOURMODE_GRAY) | 288 | if (colour_mode == COLOURMODE_GRAY) |
275 | csub_y = 0; /* Ignore Cb, Cr */ | 289 | csub_y = 0; /* Ignore Cb, Cr */ |
@@ -304,15 +318,17 @@ void yuv_bitmap_part(unsigned char *src[3], int csub_x, int csub_y, | |||
304 | if (px.inc == 1) | 318 | if (px.inc == 1) |
305 | { | 319 | { |
306 | /* Scan is L->R */ | 320 | /* Scan is L->R */ |
321 | dst_inc = COLOFFSET; | ||
307 | dst_row = dst; | 322 | dst_row = dst; |
308 | row_end = dst_row + width; | 323 | row_end = dst_row + ROWENDOFFSET; |
309 | px.col = src_x; | 324 | px.col = src_x; |
310 | } | 325 | } |
311 | else | 326 | else |
312 | { | 327 | { |
313 | /* Scan is R->L */ | 328 | /* Scan is R->L */ |
314 | row_end = dst - 1; | 329 | dst_inc = -COLOFFSET; |
315 | dst_row = row_end + width; | 330 | row_end = dst + dst_inc; |
331 | dst_row = row_end + ROWENDOFFSET; | ||
316 | px.col = src_x + width - 1; | 332 | px.col = src_x + width - 1; |
317 | } | 333 | } |
318 | 334 | ||
@@ -350,7 +366,7 @@ void yuv_bitmap_part(unsigned char *src[3], int csub_x, int csub_y, | |||
350 | px.b = y + bu; | 366 | px.b = y + bu; |
351 | 367 | ||
352 | *dst_row = pixel_func(); | 368 | *dst_row = pixel_func(); |
353 | dst_row += px.inc; | 369 | dst_row += dst_inc; |
354 | 370 | ||
355 | if (dst_row == row_end) | 371 | if (dst_row == row_end) |
356 | break; | 372 | break; |
@@ -379,13 +395,13 @@ void yuv_bitmap_part(unsigned char *src[3], int csub_x, int csub_y, | |||
379 | px.g = px.r = px.b = YFAC*(*ysrc); | 395 | px.g = px.r = px.b = YFAC*(*ysrc); |
380 | *dst_row = pixel_func(); | 396 | *dst_row = pixel_func(); |
381 | ysrc += px.inc; | 397 | ysrc += px.inc; |
382 | dst_row += px.inc; | 398 | dst_row += dst_inc; |
383 | } | 399 | } |
384 | while (dst_row != row_end); | 400 | while (dst_row != row_end); |
385 | } | 401 | } |
386 | 402 | ||
387 | src_y++; | 403 | src_y++; |
388 | dst += LCD_WIDTH; | 404 | dst += ROWOFFSET; |
389 | } | 405 | } |
390 | while (dst < dst_end); | 406 | while (dst < dst_end); |
391 | } | 407 | } |