/src/mozilla-central/media/libjpeg/jdmrgext.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * jdmrgext.c |
3 | | * |
4 | | * This file was part of the Independent JPEG Group's software: |
5 | | * Copyright (C) 1994-1996, Thomas G. Lane. |
6 | | * libjpeg-turbo Modifications: |
7 | | * Copyright (C) 2011, 2015, D. R. Commander. |
8 | | * For conditions of distribution and use, see the accompanying README.ijg |
9 | | * file. |
10 | | * |
11 | | * This file contains code for merged upsampling/color conversion. |
12 | | */ |
13 | | |
14 | | |
15 | | /* This file is included by jdmerge.c */ |
16 | | |
17 | | |
18 | | /* |
19 | | * Upsample and color convert for the case of 2:1 horizontal and 1:1 vertical. |
20 | | */ |
21 | | |
22 | | INLINE |
23 | | LOCAL(void) |
24 | | h2v1_merged_upsample_internal (j_decompress_ptr cinfo, |
25 | | JSAMPIMAGE input_buf, |
26 | | JDIMENSION in_row_group_ctr, |
27 | | JSAMPARRAY output_buf) |
28 | 0 | { |
29 | 0 | my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; |
30 | 0 | register int y, cred, cgreen, cblue; |
31 | 0 | int cb, cr; |
32 | 0 | register JSAMPROW outptr; |
33 | 0 | JSAMPROW inptr0, inptr1, inptr2; |
34 | 0 | JDIMENSION col; |
35 | 0 | /* copy these pointers into registers if possible */ |
36 | 0 | register JSAMPLE * range_limit = cinfo->sample_range_limit; |
37 | 0 | int * Crrtab = upsample->Cr_r_tab; |
38 | 0 | int * Cbbtab = upsample->Cb_b_tab; |
39 | 0 | JLONG * Crgtab = upsample->Cr_g_tab; |
40 | 0 | JLONG * Cbgtab = upsample->Cb_g_tab; |
41 | 0 | SHIFT_TEMPS |
42 | 0 |
|
43 | 0 | inptr0 = input_buf[0][in_row_group_ctr]; |
44 | 0 | inptr1 = input_buf[1][in_row_group_ctr]; |
45 | 0 | inptr2 = input_buf[2][in_row_group_ctr]; |
46 | 0 | outptr = output_buf[0]; |
47 | 0 | /* Loop for each pair of output pixels */ |
48 | 0 | for (col = cinfo->output_width >> 1; col > 0; col--) { |
49 | 0 | /* Do the chroma part of the calculation */ |
50 | 0 | cb = GETJSAMPLE(*inptr1++); |
51 | 0 | cr = GETJSAMPLE(*inptr2++); |
52 | 0 | cred = Crrtab[cr]; |
53 | 0 | cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS); |
54 | 0 | cblue = Cbbtab[cb]; |
55 | 0 | /* Fetch 2 Y values and emit 2 pixels */ |
56 | 0 | y = GETJSAMPLE(*inptr0++); |
57 | 0 | outptr[RGB_RED] = range_limit[y + cred]; |
58 | 0 | outptr[RGB_GREEN] = range_limit[y + cgreen]; |
59 | 0 | outptr[RGB_BLUE] = range_limit[y + cblue]; |
60 | | #ifdef RGB_ALPHA |
61 | 0 | outptr[RGB_ALPHA] = 0xFF; |
62 | | #endif |
63 | 0 | outptr += RGB_PIXELSIZE; |
64 | 0 | y = GETJSAMPLE(*inptr0++); |
65 | 0 | outptr[RGB_RED] = range_limit[y + cred]; |
66 | 0 | outptr[RGB_GREEN] = range_limit[y + cgreen]; |
67 | 0 | outptr[RGB_BLUE] = range_limit[y + cblue]; |
68 | | #ifdef RGB_ALPHA |
69 | 0 | outptr[RGB_ALPHA] = 0xFF; |
70 | | #endif |
71 | 0 | outptr += RGB_PIXELSIZE; |
72 | 0 | } |
73 | 0 | /* If image width is odd, do the last output column separately */ |
74 | 0 | if (cinfo->output_width & 1) { |
75 | 0 | cb = GETJSAMPLE(*inptr1); |
76 | 0 | cr = GETJSAMPLE(*inptr2); |
77 | 0 | cred = Crrtab[cr]; |
78 | 0 | cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS); |
79 | 0 | cblue = Cbbtab[cb]; |
80 | 0 | y = GETJSAMPLE(*inptr0); |
81 | 0 | outptr[RGB_RED] = range_limit[y + cred]; |
82 | 0 | outptr[RGB_GREEN] = range_limit[y + cgreen]; |
83 | 0 | outptr[RGB_BLUE] = range_limit[y + cblue]; |
84 | | #ifdef RGB_ALPHA |
85 | 0 | outptr[RGB_ALPHA] = 0xFF; |
86 | | #endif |
87 | | } |
88 | 0 | } Unexecuted instantiation: jdmerge.c:extrgb_h2v1_merged_upsample_internal Unexecuted instantiation: jdmerge.c:extrgbx_h2v1_merged_upsample_internal Unexecuted instantiation: jdmerge.c:extbgr_h2v1_merged_upsample_internal Unexecuted instantiation: jdmerge.c:extbgrx_h2v1_merged_upsample_internal Unexecuted instantiation: jdmerge.c:extxbgr_h2v1_merged_upsample_internal Unexecuted instantiation: jdmerge.c:extxrgb_h2v1_merged_upsample_internal Unexecuted instantiation: jdmerge.c:h2v1_merged_upsample_internal |
89 | | |
90 | | |
91 | | /* |
92 | | * Upsample and color convert for the case of 2:1 horizontal and 2:1 vertical. |
93 | | */ |
94 | | |
95 | | INLINE |
96 | | LOCAL(void) |
97 | | h2v2_merged_upsample_internal (j_decompress_ptr cinfo, |
98 | | JSAMPIMAGE input_buf, |
99 | | JDIMENSION in_row_group_ctr, |
100 | | JSAMPARRAY output_buf) |
101 | 0 | { |
102 | 0 | my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; |
103 | 0 | register int y, cred, cgreen, cblue; |
104 | 0 | int cb, cr; |
105 | 0 | register JSAMPROW outptr0, outptr1; |
106 | 0 | JSAMPROW inptr00, inptr01, inptr1, inptr2; |
107 | 0 | JDIMENSION col; |
108 | 0 | /* copy these pointers into registers if possible */ |
109 | 0 | register JSAMPLE * range_limit = cinfo->sample_range_limit; |
110 | 0 | int * Crrtab = upsample->Cr_r_tab; |
111 | 0 | int * Cbbtab = upsample->Cb_b_tab; |
112 | 0 | JLONG * Crgtab = upsample->Cr_g_tab; |
113 | 0 | JLONG * Cbgtab = upsample->Cb_g_tab; |
114 | 0 | SHIFT_TEMPS |
115 | 0 |
|
116 | 0 | inptr00 = input_buf[0][in_row_group_ctr*2]; |
117 | 0 | inptr01 = input_buf[0][in_row_group_ctr*2 + 1]; |
118 | 0 | inptr1 = input_buf[1][in_row_group_ctr]; |
119 | 0 | inptr2 = input_buf[2][in_row_group_ctr]; |
120 | 0 | outptr0 = output_buf[0]; |
121 | 0 | outptr1 = output_buf[1]; |
122 | 0 | /* Loop for each group of output pixels */ |
123 | 0 | for (col = cinfo->output_width >> 1; col > 0; col--) { |
124 | 0 | /* Do the chroma part of the calculation */ |
125 | 0 | cb = GETJSAMPLE(*inptr1++); |
126 | 0 | cr = GETJSAMPLE(*inptr2++); |
127 | 0 | cred = Crrtab[cr]; |
128 | 0 | cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS); |
129 | 0 | cblue = Cbbtab[cb]; |
130 | 0 | /* Fetch 4 Y values and emit 4 pixels */ |
131 | 0 | y = GETJSAMPLE(*inptr00++); |
132 | 0 | outptr0[RGB_RED] = range_limit[y + cred]; |
133 | 0 | outptr0[RGB_GREEN] = range_limit[y + cgreen]; |
134 | 0 | outptr0[RGB_BLUE] = range_limit[y + cblue]; |
135 | | #ifdef RGB_ALPHA |
136 | 0 | outptr0[RGB_ALPHA] = 0xFF; |
137 | | #endif |
138 | 0 | outptr0 += RGB_PIXELSIZE; |
139 | 0 | y = GETJSAMPLE(*inptr00++); |
140 | 0 | outptr0[RGB_RED] = range_limit[y + cred]; |
141 | 0 | outptr0[RGB_GREEN] = range_limit[y + cgreen]; |
142 | 0 | outptr0[RGB_BLUE] = range_limit[y + cblue]; |
143 | | #ifdef RGB_ALPHA |
144 | 0 | outptr0[RGB_ALPHA] = 0xFF; |
145 | | #endif |
146 | 0 | outptr0 += RGB_PIXELSIZE; |
147 | 0 | y = GETJSAMPLE(*inptr01++); |
148 | 0 | outptr1[RGB_RED] = range_limit[y + cred]; |
149 | 0 | outptr1[RGB_GREEN] = range_limit[y + cgreen]; |
150 | 0 | outptr1[RGB_BLUE] = range_limit[y + cblue]; |
151 | | #ifdef RGB_ALPHA |
152 | 0 | outptr1[RGB_ALPHA] = 0xFF; |
153 | | #endif |
154 | 0 | outptr1 += RGB_PIXELSIZE; |
155 | 0 | y = GETJSAMPLE(*inptr01++); |
156 | 0 | outptr1[RGB_RED] = range_limit[y + cred]; |
157 | 0 | outptr1[RGB_GREEN] = range_limit[y + cgreen]; |
158 | 0 | outptr1[RGB_BLUE] = range_limit[y + cblue]; |
159 | | #ifdef RGB_ALPHA |
160 | 0 | outptr1[RGB_ALPHA] = 0xFF; |
161 | | #endif |
162 | 0 | outptr1 += RGB_PIXELSIZE; |
163 | 0 | } |
164 | 0 | /* If image width is odd, do the last output column separately */ |
165 | 0 | if (cinfo->output_width & 1) { |
166 | 0 | cb = GETJSAMPLE(*inptr1); |
167 | 0 | cr = GETJSAMPLE(*inptr2); |
168 | 0 | cred = Crrtab[cr]; |
169 | 0 | cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS); |
170 | 0 | cblue = Cbbtab[cb]; |
171 | 0 | y = GETJSAMPLE(*inptr00); |
172 | 0 | outptr0[RGB_RED] = range_limit[y + cred]; |
173 | 0 | outptr0[RGB_GREEN] = range_limit[y + cgreen]; |
174 | 0 | outptr0[RGB_BLUE] = range_limit[y + cblue]; |
175 | | #ifdef RGB_ALPHA |
176 | 0 | outptr0[RGB_ALPHA] = 0xFF; |
177 | | #endif |
178 | 0 | y = GETJSAMPLE(*inptr01); |
179 | 0 | outptr1[RGB_RED] = range_limit[y + cred]; |
180 | 0 | outptr1[RGB_GREEN] = range_limit[y + cgreen]; |
181 | 0 | outptr1[RGB_BLUE] = range_limit[y + cblue]; |
182 | | #ifdef RGB_ALPHA |
183 | 0 | outptr1[RGB_ALPHA] = 0xFF; |
184 | | #endif |
185 | | } |
186 | 0 | } Unexecuted instantiation: jdmerge.c:extrgb_h2v2_merged_upsample_internal Unexecuted instantiation: jdmerge.c:extrgbx_h2v2_merged_upsample_internal Unexecuted instantiation: jdmerge.c:extbgr_h2v2_merged_upsample_internal Unexecuted instantiation: jdmerge.c:extbgrx_h2v2_merged_upsample_internal Unexecuted instantiation: jdmerge.c:extxbgr_h2v2_merged_upsample_internal Unexecuted instantiation: jdmerge.c:extxrgb_h2v2_merged_upsample_internal Unexecuted instantiation: jdmerge.c:h2v2_merged_upsample_internal |