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