/src/mozilla-central/media/libjpeg/jccolext.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * jccolext.c |
3 | | * |
4 | | * This file was part of the Independent JPEG Group's software: |
5 | | * Copyright (C) 1991-1996, Thomas G. Lane. |
6 | | * libjpeg-turbo Modifications: |
7 | | * Copyright (C) 2009-2012, 2015, D. R. Commander. |
8 | | * For conditions of distribution and use, see the accompanying README.ijg |
9 | | * file. |
10 | | * |
11 | | * This file contains input colorspace conversion routines. |
12 | | */ |
13 | | |
14 | | |
15 | | /* This file is included by jccolor.c */ |
16 | | |
17 | | |
18 | | /* |
19 | | * Convert some rows of samples to the JPEG colorspace. |
20 | | * |
21 | | * Note that we change from the application's interleaved-pixel format |
22 | | * to our internal noninterleaved, one-plane-per-component format. |
23 | | * The input buffer is therefore three times as wide as the output buffer. |
24 | | * |
25 | | * A starting row offset is provided only for the output buffer. The caller |
26 | | * can easily adjust the passed input_buf value to accommodate any row |
27 | | * offset required on that side. |
28 | | */ |
29 | | |
30 | | INLINE |
31 | | LOCAL(void) |
32 | | rgb_ycc_convert_internal (j_compress_ptr cinfo, |
33 | | JSAMPARRAY input_buf, JSAMPIMAGE output_buf, |
34 | | JDIMENSION output_row, int num_rows) |
35 | 0 | { |
36 | 0 | my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; |
37 | 0 | register int r, g, b; |
38 | 0 | register JLONG * ctab = cconvert->rgb_ycc_tab; |
39 | 0 | register JSAMPROW inptr; |
40 | 0 | register JSAMPROW outptr0, outptr1, outptr2; |
41 | 0 | register JDIMENSION col; |
42 | 0 | JDIMENSION num_cols = cinfo->image_width; |
43 | 0 |
|
44 | 0 | while (--num_rows >= 0) { |
45 | 0 | inptr = *input_buf++; |
46 | 0 | outptr0 = output_buf[0][output_row]; |
47 | 0 | outptr1 = output_buf[1][output_row]; |
48 | 0 | outptr2 = output_buf[2][output_row]; |
49 | 0 | output_row++; |
50 | 0 | for (col = 0; col < num_cols; col++) { |
51 | 0 | r = GETJSAMPLE(inptr[RGB_RED]); |
52 | 0 | g = GETJSAMPLE(inptr[RGB_GREEN]); |
53 | 0 | b = GETJSAMPLE(inptr[RGB_BLUE]); |
54 | 0 | inptr += RGB_PIXELSIZE; |
55 | 0 | /* If the inputs are 0..MAXJSAMPLE, the outputs of these equations |
56 | 0 | * must be too; we do not need an explicit range-limiting operation. |
57 | 0 | * Hence the value being shifted is never negative, and we don't |
58 | 0 | * need the general RIGHT_SHIFT macro. |
59 | 0 | */ |
60 | 0 | /* Y */ |
61 | 0 | outptr0[col] = (JSAMPLE) |
62 | 0 | ((ctab[r+R_Y_OFF] + ctab[g+G_Y_OFF] + ctab[b+B_Y_OFF]) |
63 | 0 | >> SCALEBITS); |
64 | 0 | /* Cb */ |
65 | 0 | outptr1[col] = (JSAMPLE) |
66 | 0 | ((ctab[r+R_CB_OFF] + ctab[g+G_CB_OFF] + ctab[b+B_CB_OFF]) |
67 | 0 | >> SCALEBITS); |
68 | 0 | /* Cr */ |
69 | 0 | outptr2[col] = (JSAMPLE) |
70 | 0 | ((ctab[r+R_CR_OFF] + ctab[g+G_CR_OFF] + ctab[b+B_CR_OFF]) |
71 | 0 | >> SCALEBITS); |
72 | 0 | } |
73 | 0 | } |
74 | 0 | } Unexecuted instantiation: jccolor.c:extrgb_ycc_convert_internal Unexecuted instantiation: jccolor.c:extrgbx_ycc_convert_internal Unexecuted instantiation: jccolor.c:extbgr_ycc_convert_internal Unexecuted instantiation: jccolor.c:extbgrx_ycc_convert_internal Unexecuted instantiation: jccolor.c:extxbgr_ycc_convert_internal Unexecuted instantiation: jccolor.c:extxrgb_ycc_convert_internal Unexecuted instantiation: jccolor.c:rgb_ycc_convert_internal |
75 | | |
76 | | |
77 | | /**************** Cases other than RGB -> YCbCr **************/ |
78 | | |
79 | | |
80 | | /* |
81 | | * Convert some rows of samples to the JPEG colorspace. |
82 | | * This version handles RGB->grayscale conversion, which is the same |
83 | | * as the RGB->Y portion of RGB->YCbCr. |
84 | | * We assume rgb_ycc_start has been called (we only use the Y tables). |
85 | | */ |
86 | | |
87 | | INLINE |
88 | | LOCAL(void) |
89 | | rgb_gray_convert_internal (j_compress_ptr cinfo, |
90 | | JSAMPARRAY input_buf, JSAMPIMAGE output_buf, |
91 | | JDIMENSION output_row, int num_rows) |
92 | 0 | { |
93 | 0 | my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; |
94 | 0 | register int r, g, b; |
95 | 0 | register JLONG * ctab = cconvert->rgb_ycc_tab; |
96 | 0 | register JSAMPROW inptr; |
97 | 0 | register JSAMPROW outptr; |
98 | 0 | register JDIMENSION col; |
99 | 0 | JDIMENSION num_cols = cinfo->image_width; |
100 | 0 |
|
101 | 0 | while (--num_rows >= 0) { |
102 | 0 | inptr = *input_buf++; |
103 | 0 | outptr = output_buf[0][output_row]; |
104 | 0 | output_row++; |
105 | 0 | for (col = 0; col < num_cols; col++) { |
106 | 0 | r = GETJSAMPLE(inptr[RGB_RED]); |
107 | 0 | g = GETJSAMPLE(inptr[RGB_GREEN]); |
108 | 0 | b = GETJSAMPLE(inptr[RGB_BLUE]); |
109 | 0 | inptr += RGB_PIXELSIZE; |
110 | 0 | /* Y */ |
111 | 0 | outptr[col] = (JSAMPLE) |
112 | 0 | ((ctab[r+R_Y_OFF] + ctab[g+G_Y_OFF] + ctab[b+B_Y_OFF]) |
113 | 0 | >> SCALEBITS); |
114 | 0 | } |
115 | 0 | } |
116 | 0 | } Unexecuted instantiation: jccolor.c:extrgb_gray_convert_internal Unexecuted instantiation: jccolor.c:extrgbx_gray_convert_internal Unexecuted instantiation: jccolor.c:extbgr_gray_convert_internal Unexecuted instantiation: jccolor.c:extbgrx_gray_convert_internal Unexecuted instantiation: jccolor.c:extxbgr_gray_convert_internal Unexecuted instantiation: jccolor.c:extxrgb_gray_convert_internal Unexecuted instantiation: jccolor.c:rgb_gray_convert_internal |
117 | | |
118 | | |
119 | | /* |
120 | | * Convert some rows of samples to the JPEG colorspace. |
121 | | * This version handles extended RGB->plain RGB conversion |
122 | | */ |
123 | | |
124 | | INLINE |
125 | | LOCAL(void) |
126 | | rgb_rgb_convert_internal (j_compress_ptr cinfo, |
127 | | JSAMPARRAY input_buf, JSAMPIMAGE output_buf, |
128 | | JDIMENSION output_row, int num_rows) |
129 | 0 | { |
130 | 0 | register JSAMPROW inptr; |
131 | 0 | register JSAMPROW outptr0, outptr1, outptr2; |
132 | 0 | register JDIMENSION col; |
133 | 0 | JDIMENSION num_cols = cinfo->image_width; |
134 | 0 |
|
135 | 0 | while (--num_rows >= 0) { |
136 | 0 | inptr = *input_buf++; |
137 | 0 | outptr0 = output_buf[0][output_row]; |
138 | 0 | outptr1 = output_buf[1][output_row]; |
139 | 0 | outptr2 = output_buf[2][output_row]; |
140 | 0 | output_row++; |
141 | 0 | for (col = 0; col < num_cols; col++) { |
142 | 0 | outptr0[col] = GETJSAMPLE(inptr[RGB_RED]); |
143 | 0 | outptr1[col] = GETJSAMPLE(inptr[RGB_GREEN]); |
144 | 0 | outptr2[col] = GETJSAMPLE(inptr[RGB_BLUE]); |
145 | 0 | inptr += RGB_PIXELSIZE; |
146 | 0 | } |
147 | 0 | } |
148 | 0 | } Unexecuted instantiation: jccolor.c:extrgb_rgb_convert_internal Unexecuted instantiation: jccolor.c:extrgbx_rgb_convert_internal Unexecuted instantiation: jccolor.c:extbgr_rgb_convert_internal Unexecuted instantiation: jccolor.c:extbgrx_rgb_convert_internal Unexecuted instantiation: jccolor.c:extxbgr_rgb_convert_internal Unexecuted instantiation: jccolor.c:extxrgb_rgb_convert_internal Unexecuted instantiation: jccolor.c:rgb_rgb_convert_internal |