/src/libjpeg-turbo/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, 2020, 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, JSAMPIMAGE input_buf, |
25 | | JDIMENSION in_row_group_ctr, |
26 | | JSAMPARRAY output_buf) |
27 | 0 | { |
28 | 0 | my_merged_upsample_ptr upsample = (my_merged_upsample_ptr)cinfo->upsample; |
29 | 0 | register int y, cred, cgreen, cblue; |
30 | 0 | int cb, cr; |
31 | 0 | register JSAMPROW outptr; |
32 | 0 | JSAMPROW inptr0, inptr1, inptr2; |
33 | 0 | JDIMENSION col; |
34 | | /* copy these pointers into registers if possible */ |
35 | 0 | register JSAMPLE *range_limit = cinfo->sample_range_limit; |
36 | 0 | int *Crrtab = upsample->Cr_r_tab; |
37 | 0 | int *Cbbtab = upsample->Cb_b_tab; |
38 | 0 | JLONG *Crgtab = upsample->Cr_g_tab; |
39 | 0 | JLONG *Cbgtab = upsample->Cb_g_tab; |
40 | 0 | SHIFT_TEMPS |
41 | |
|
42 | 0 | inptr0 = input_buf[0][in_row_group_ctr]; |
43 | 0 | inptr1 = input_buf[1][in_row_group_ctr]; |
44 | 0 | inptr2 = input_buf[2][in_row_group_ctr]; |
45 | 0 | outptr = output_buf[0]; |
46 | | /* Loop for each pair of output pixels */ |
47 | 0 | for (col = cinfo->output_width >> 1; col > 0; col--) { |
48 | | /* Do the chroma part of the calculation */ |
49 | 0 | cb = *inptr1++; |
50 | 0 | cr = *inptr2++; |
51 | 0 | cred = Crrtab[cr]; |
52 | 0 | cgreen = (int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS); |
53 | 0 | cblue = Cbbtab[cb]; |
54 | | /* Fetch 2 Y values and emit 2 pixels */ |
55 | 0 | y = *inptr0++; |
56 | 0 | outptr[RGB_RED] = range_limit[y + cred]; |
57 | 0 | outptr[RGB_GREEN] = range_limit[y + cgreen]; |
58 | 0 | outptr[RGB_BLUE] = range_limit[y + cblue]; |
59 | | #ifdef RGB_ALPHA |
60 | 0 | outptr[RGB_ALPHA] = 0xFF; |
61 | | #endif |
62 | 0 | outptr += RGB_PIXELSIZE; |
63 | 0 | y = *inptr0++; |
64 | 0 | outptr[RGB_RED] = range_limit[y + cred]; |
65 | 0 | outptr[RGB_GREEN] = range_limit[y + cgreen]; |
66 | 0 | outptr[RGB_BLUE] = range_limit[y + cblue]; |
67 | | #ifdef RGB_ALPHA |
68 | 0 | outptr[RGB_ALPHA] = 0xFF; |
69 | | #endif |
70 | 0 | outptr += RGB_PIXELSIZE; |
71 | 0 | } |
72 | | /* If image width is odd, do the last output column separately */ |
73 | 0 | if (cinfo->output_width & 1) { |
74 | 0 | cb = *inptr1; |
75 | 0 | cr = *inptr2; |
76 | 0 | cred = Crrtab[cr]; |
77 | 0 | cgreen = (int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS); |
78 | 0 | cblue = Cbbtab[cb]; |
79 | 0 | y = *inptr0; |
80 | 0 | outptr[RGB_RED] = range_limit[y + cred]; |
81 | 0 | outptr[RGB_GREEN] = range_limit[y + cgreen]; |
82 | 0 | outptr[RGB_BLUE] = range_limit[y + cblue]; |
83 | | #ifdef RGB_ALPHA |
84 | 0 | outptr[RGB_ALPHA] = 0xFF; |
85 | | #endif |
86 | 0 | } |
87 | 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 |
88 | | |
89 | | |
90 | | /* |
91 | | * Upsample and color convert for the case of 2:1 horizontal and 2:1 vertical. |
92 | | */ |
93 | | |
94 | | INLINE |
95 | | LOCAL(void) |
96 | | h2v2_merged_upsample_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf, |
97 | | JDIMENSION in_row_group_ctr, |
98 | | JSAMPARRAY output_buf) |
99 | 0 | { |
100 | 0 | my_merged_upsample_ptr upsample = (my_merged_upsample_ptr)cinfo->upsample; |
101 | 0 | register int y, cred, cgreen, cblue; |
102 | 0 | int cb, cr; |
103 | 0 | register JSAMPROW outptr0, outptr1; |
104 | 0 | JSAMPROW inptr00, inptr01, inptr1, inptr2; |
105 | 0 | JDIMENSION col; |
106 | | /* copy these pointers into registers if possible */ |
107 | 0 | register JSAMPLE *range_limit = cinfo->sample_range_limit; |
108 | 0 | int *Crrtab = upsample->Cr_r_tab; |
109 | 0 | int *Cbbtab = upsample->Cb_b_tab; |
110 | 0 | JLONG *Crgtab = upsample->Cr_g_tab; |
111 | 0 | JLONG *Cbgtab = upsample->Cb_g_tab; |
112 | 0 | SHIFT_TEMPS |
113 | |
|
114 | 0 | inptr00 = input_buf[0][in_row_group_ctr * 2]; |
115 | 0 | inptr01 = input_buf[0][in_row_group_ctr * 2 + 1]; |
116 | 0 | inptr1 = input_buf[1][in_row_group_ctr]; |
117 | 0 | inptr2 = input_buf[2][in_row_group_ctr]; |
118 | 0 | outptr0 = output_buf[0]; |
119 | 0 | outptr1 = output_buf[1]; |
120 | | /* Loop for each group of output pixels */ |
121 | 0 | for (col = cinfo->output_width >> 1; col > 0; col--) { |
122 | | /* Do the chroma part of the calculation */ |
123 | 0 | cb = *inptr1++; |
124 | 0 | cr = *inptr2++; |
125 | 0 | cred = Crrtab[cr]; |
126 | 0 | cgreen = (int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS); |
127 | 0 | cblue = Cbbtab[cb]; |
128 | | /* Fetch 4 Y values and emit 4 pixels */ |
129 | 0 | y = *inptr00++; |
130 | 0 | outptr0[RGB_RED] = range_limit[y + cred]; |
131 | 0 | outptr0[RGB_GREEN] = range_limit[y + cgreen]; |
132 | 0 | outptr0[RGB_BLUE] = range_limit[y + cblue]; |
133 | | #ifdef RGB_ALPHA |
134 | 0 | outptr0[RGB_ALPHA] = 0xFF; |
135 | | #endif |
136 | 0 | outptr0 += RGB_PIXELSIZE; |
137 | 0 | y = *inptr00++; |
138 | 0 | outptr0[RGB_RED] = range_limit[y + cred]; |
139 | 0 | outptr0[RGB_GREEN] = range_limit[y + cgreen]; |
140 | 0 | outptr0[RGB_BLUE] = range_limit[y + cblue]; |
141 | | #ifdef RGB_ALPHA |
142 | 0 | outptr0[RGB_ALPHA] = 0xFF; |
143 | | #endif |
144 | 0 | outptr0 += RGB_PIXELSIZE; |
145 | 0 | y = *inptr01++; |
146 | 0 | outptr1[RGB_RED] = range_limit[y + cred]; |
147 | 0 | outptr1[RGB_GREEN] = range_limit[y + cgreen]; |
148 | 0 | outptr1[RGB_BLUE] = range_limit[y + cblue]; |
149 | | #ifdef RGB_ALPHA |
150 | 0 | outptr1[RGB_ALPHA] = 0xFF; |
151 | | #endif |
152 | 0 | outptr1 += RGB_PIXELSIZE; |
153 | 0 | y = *inptr01++; |
154 | 0 | outptr1[RGB_RED] = range_limit[y + cred]; |
155 | 0 | outptr1[RGB_GREEN] = range_limit[y + cgreen]; |
156 | 0 | outptr1[RGB_BLUE] = range_limit[y + cblue]; |
157 | | #ifdef RGB_ALPHA |
158 | 0 | outptr1[RGB_ALPHA] = 0xFF; |
159 | | #endif |
160 | 0 | outptr1 += RGB_PIXELSIZE; |
161 | 0 | } |
162 | | /* If image width is odd, do the last output column separately */ |
163 | 0 | if (cinfo->output_width & 1) { |
164 | 0 | cb = *inptr1; |
165 | 0 | cr = *inptr2; |
166 | 0 | cred = Crrtab[cr]; |
167 | 0 | cgreen = (int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS); |
168 | 0 | cblue = Cbbtab[cb]; |
169 | 0 | y = *inptr00; |
170 | 0 | outptr0[RGB_RED] = range_limit[y + cred]; |
171 | 0 | outptr0[RGB_GREEN] = range_limit[y + cgreen]; |
172 | 0 | outptr0[RGB_BLUE] = range_limit[y + cblue]; |
173 | | #ifdef RGB_ALPHA |
174 | 0 | outptr0[RGB_ALPHA] = 0xFF; |
175 | | #endif |
176 | 0 | y = *inptr01; |
177 | 0 | outptr1[RGB_RED] = range_limit[y + cred]; |
178 | 0 | outptr1[RGB_GREEN] = range_limit[y + cgreen]; |
179 | 0 | outptr1[RGB_BLUE] = range_limit[y + cblue]; |
180 | | #ifdef RGB_ALPHA |
181 | 0 | outptr1[RGB_ALPHA] = 0xFF; |
182 | | #endif |
183 | 0 | } |
184 | 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 |