OLD | NEW |
1 /* | 1 /* |
2 * jdmaster.c | 2 * jdmaster.c |
3 * | 3 * |
4 * This file was part of the Independent JPEG Group's software: | 4 * This file was part of the Independent JPEG Group's software: |
5 * Copyright (C) 1991-1997, Thomas G. Lane. | 5 * Copyright (C) 1991-1997, Thomas G. Lane. |
6 * Modified 2002-2009 by Guido Vollbeding. | 6 * Modified 2002-2009 by Guido Vollbeding. |
7 * libjpeg-turbo Modifications: | 7 * libjpeg-turbo Modifications: |
8 * Copyright (C) 2009-2011, D. R. Commander. | 8 * Copyright (C) 2009-2011, D. R. Commander. |
| 9 * Copyright (C) 2013, Linaro Limited. |
| 10 |
9 * For conditions of distribution and use, see the accompanying README file. | 11 * For conditions of distribution and use, see the accompanying README file. |
10 * | 12 * |
11 * This file contains master control logic for the JPEG decompressor. | 13 * This file contains master control logic for the JPEG decompressor. |
12 * These routines are concerned with selecting the modules to be executed | 14 * These routines are concerned with selecting the modules to be executed |
13 * and with determining the number of passes and the work to be done in each | 15 * and with determining the number of passes and the work to be done in each |
14 * pass. | 16 * pass. |
15 */ | 17 */ |
16 | 18 |
17 #define JPEG_INTERNALS | 19 #define JPEG_INTERNALS |
18 #include "jinclude.h" | 20 #include "jinclude.h" |
(...skipping 25 matching lines...) Expand all Loading... |
44 * CRUCIAL: this must match the actual capabilities of jdmerge.c! | 46 * CRUCIAL: this must match the actual capabilities of jdmerge.c! |
45 */ | 47 */ |
46 | 48 |
47 LOCAL(boolean) | 49 LOCAL(boolean) |
48 use_merged_upsample (j_decompress_ptr cinfo) | 50 use_merged_upsample (j_decompress_ptr cinfo) |
49 { | 51 { |
50 #ifdef UPSAMPLE_MERGING_SUPPORTED | 52 #ifdef UPSAMPLE_MERGING_SUPPORTED |
51 /* Merging is the equivalent of plain box-filter upsampling */ | 53 /* Merging is the equivalent of plain box-filter upsampling */ |
52 if (cinfo->do_fancy_upsampling || cinfo->CCIR601_sampling) | 54 if (cinfo->do_fancy_upsampling || cinfo->CCIR601_sampling) |
53 return FALSE; | 55 return FALSE; |
54 /* jdmerge.c only supports YCC=>RGB color conversion */ | 56 /* jdmerge.c only supports YCC=>RGB and YCC=>RGB565 color conversion */ |
55 if (cinfo->jpeg_color_space != JCS_YCbCr || cinfo->num_components != 3 || | 57 if (cinfo->jpeg_color_space != JCS_YCbCr || cinfo->num_components != 3 || |
56 (cinfo->out_color_space != JCS_RGB && | 58 (cinfo->out_color_space != JCS_RGB && |
| 59 cinfo->out_color_space != JCS_RGB565 && |
57 cinfo->out_color_space != JCS_EXT_RGB && | 60 cinfo->out_color_space != JCS_EXT_RGB && |
58 cinfo->out_color_space != JCS_EXT_RGBX && | 61 cinfo->out_color_space != JCS_EXT_RGBX && |
59 cinfo->out_color_space != JCS_EXT_BGR && | 62 cinfo->out_color_space != JCS_EXT_BGR && |
60 cinfo->out_color_space != JCS_EXT_BGRX && | 63 cinfo->out_color_space != JCS_EXT_BGRX && |
61 cinfo->out_color_space != JCS_EXT_XBGR && | 64 cinfo->out_color_space != JCS_EXT_XBGR && |
62 cinfo->out_color_space != JCS_EXT_XRGB && | 65 cinfo->out_color_space != JCS_EXT_XRGB && |
63 cinfo->out_color_space != JCS_EXT_RGBA && | 66 cinfo->out_color_space != JCS_EXT_RGBA && |
64 cinfo->out_color_space != JCS_EXT_BGRA && | 67 cinfo->out_color_space != JCS_EXT_BGRA && |
65 cinfo->out_color_space != JCS_EXT_ABGR && | 68 cinfo->out_color_space != JCS_EXT_ABGR && |
66 cinfo->out_color_space != JCS_EXT_ARGB) || | 69 cinfo->out_color_space != JCS_EXT_ARGB)) |
67 cinfo->out_color_components != rgb_pixelsize[cinfo->out_color_space]) | 70 return FALSE; |
| 71 if ((cinfo->out_color_space == JCS_RGB565 && |
| 72 cinfo->out_color_components != 3) || |
| 73 (cinfo->out_color_space != JCS_RGB565 && |
| 74 cinfo->out_color_components != rgb_pixelsize[cinfo->out_color_space])) |
68 return FALSE; | 75 return FALSE; |
69 /* and it only handles 2h1v or 2h2v sampling ratios */ | 76 /* and it only handles 2h1v or 2h2v sampling ratios */ |
70 if (cinfo->comp_info[0].h_samp_factor != 2 || | 77 if (cinfo->comp_info[0].h_samp_factor != 2 || |
71 cinfo->comp_info[1].h_samp_factor != 1 || | 78 cinfo->comp_info[1].h_samp_factor != 1 || |
72 cinfo->comp_info[2].h_samp_factor != 1 || | 79 cinfo->comp_info[2].h_samp_factor != 1 || |
73 cinfo->comp_info[0].v_samp_factor > 2 || | 80 cinfo->comp_info[0].v_samp_factor > 2 || |
74 cinfo->comp_info[1].v_samp_factor != 1 || | 81 cinfo->comp_info[1].v_samp_factor != 1 || |
75 cinfo->comp_info[2].v_samp_factor != 1) | 82 cinfo->comp_info[2].v_samp_factor != 1) |
76 return FALSE; | 83 return FALSE; |
77 /* furthermore, it doesn't work if we've scaled the IDCTs differently */ | 84 /* furthermore, it doesn't work if we've scaled the IDCTs differently */ |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 case JCS_EXT_BGRX: | 352 case JCS_EXT_BGRX: |
346 case JCS_EXT_XBGR: | 353 case JCS_EXT_XBGR: |
347 case JCS_EXT_XRGB: | 354 case JCS_EXT_XRGB: |
348 case JCS_EXT_RGBA: | 355 case JCS_EXT_RGBA: |
349 case JCS_EXT_BGRA: | 356 case JCS_EXT_BGRA: |
350 case JCS_EXT_ABGR: | 357 case JCS_EXT_ABGR: |
351 case JCS_EXT_ARGB: | 358 case JCS_EXT_ARGB: |
352 cinfo->out_color_components = rgb_pixelsize[cinfo->out_color_space]; | 359 cinfo->out_color_components = rgb_pixelsize[cinfo->out_color_space]; |
353 break; | 360 break; |
354 case JCS_YCbCr: | 361 case JCS_YCbCr: |
| 362 case JCS_RGB565: |
355 cinfo->out_color_components = 3; | 363 cinfo->out_color_components = 3; |
356 break; | 364 break; |
357 case JCS_CMYK: | 365 case JCS_CMYK: |
358 case JCS_YCCK: | 366 case JCS_YCCK: |
359 cinfo->out_color_components = 4; | 367 cinfo->out_color_components = 4; |
360 break; | 368 break; |
361 default: /* else must be same colorspace as in file */ | 369 default: /* else must be same colorspace as in file */ |
362 cinfo->out_color_components = cinfo->num_components; | 370 cinfo->out_color_components = cinfo->num_components; |
363 break; | 371 break; |
364 } | 372 } |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
724 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, | 732 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, |
725 SIZEOF(my_decomp_master)); | 733 SIZEOF(my_decomp_master)); |
726 cinfo->master = (struct jpeg_decomp_master *) master; | 734 cinfo->master = (struct jpeg_decomp_master *) master; |
727 master->pub.prepare_for_output_pass = prepare_for_output_pass; | 735 master->pub.prepare_for_output_pass = prepare_for_output_pass; |
728 master->pub.finish_output_pass = finish_output_pass; | 736 master->pub.finish_output_pass = finish_output_pass; |
729 | 737 |
730 master->pub.is_dummy_pass = FALSE; | 738 master->pub.is_dummy_pass = FALSE; |
731 | 739 |
732 master_selection(cinfo); | 740 master_selection(cinfo); |
733 } | 741 } |
OLD | NEW |