Coverage Report

Created: 2024-08-27 12:18

/src/libjpeg-turbo.main/jdmrg565.c
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * jdmrg565.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) 2013, Linaro Limited.
8
 * Copyright (C) 2014-2015, 2018, 2020, 2022, D. R. Commander.
9
 * For conditions of distribution and use, see the accompanying README.ijg
10
 * file.
11
 *
12
 * This file contains code for merged upsampling/color conversion.
13
 */
14
15
16
INLINE
17
LOCAL(void)
18
h2v1_merged_upsample_565_internal(j_decompress_ptr cinfo,
19
                                  _JSAMPIMAGE input_buf,
20
                                  JDIMENSION in_row_group_ctr,
21
                                  _JSAMPARRAY output_buf)
22
0
{
23
0
  my_merged_upsample_ptr upsample = (my_merged_upsample_ptr)cinfo->upsample;
24
0
  register int y, cred, cgreen, cblue;
25
0
  int cb, cr;
26
0
  register _JSAMPROW outptr;
27
0
  _JSAMPROW inptr0, inptr1, inptr2;
28
0
  JDIMENSION col;
29
  /* copy these pointers into registers if possible */
30
0
  register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit;
31
0
  int *Crrtab = upsample->Cr_r_tab;
32
0
  int *Cbbtab = upsample->Cb_b_tab;
33
0
  JLONG *Crgtab = upsample->Cr_g_tab;
34
0
  JLONG *Cbgtab = upsample->Cb_g_tab;
35
0
  unsigned int r, g, b;
36
0
  JLONG rgb;
37
0
  SHIFT_TEMPS
38
39
0
  inptr0 = input_buf[0][in_row_group_ctr];
40
0
  inptr1 = input_buf[1][in_row_group_ctr];
41
0
  inptr2 = input_buf[2][in_row_group_ctr];
42
0
  outptr = output_buf[0];
43
44
  /* Loop for each pair of output pixels */
45
0
  for (col = cinfo->output_width >> 1; col > 0; col--) {
46
    /* Do the chroma part of the calculation */
47
0
    cb = *inptr1++;
48
0
    cr = *inptr2++;
49
0
    cred = Crrtab[cr];
50
0
    cgreen = (int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
51
0
    cblue = Cbbtab[cb];
52
53
    /* Fetch 2 Y values and emit 2 pixels */
54
0
    y  = *inptr0++;
55
0
    r = range_limit[y + cred];
56
0
    g = range_limit[y + cgreen];
57
0
    b = range_limit[y + cblue];
58
0
    rgb = PACK_SHORT_565(r, g, b);
59
60
0
    y  = *inptr0++;
61
0
    r = range_limit[y + cred];
62
0
    g = range_limit[y + cgreen];
63
0
    b = range_limit[y + cblue];
64
0
    rgb = PACK_TWO_PIXELS(rgb, PACK_SHORT_565(r, g, b));
65
66
0
    WRITE_TWO_PIXELS(outptr, rgb);
67
0
    outptr += 4;
68
0
  }
69
70
  /* If image width is odd, do the last output column separately */
71
0
  if (cinfo->output_width & 1) {
72
0
    cb = *inptr1;
73
0
    cr = *inptr2;
74
0
    cred = Crrtab[cr];
75
0
    cgreen = (int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
76
0
    cblue = Cbbtab[cb];
77
0
    y  = *inptr0;
78
0
    r = range_limit[y + cred];
79
0
    g = range_limit[y + cgreen];
80
0
    b = range_limit[y + cblue];
81
0
    rgb = PACK_SHORT_565(r, g, b);
82
0
    *(INT16 *)outptr = (INT16)rgb;
83
0
  }
84
0
}
Unexecuted instantiation: jdmerge.c:h2v1_merged_upsample_565_be
Unexecuted instantiation: jdmerge.c:h2v1_merged_upsample_565_le
85
86
87
INLINE
88
LOCAL(void)
89
h2v1_merged_upsample_565D_internal(j_decompress_ptr cinfo,
90
                                   _JSAMPIMAGE input_buf,
91
                                   JDIMENSION in_row_group_ctr,
92
                                   _JSAMPARRAY output_buf)
93
0
{
94
0
  my_merged_upsample_ptr upsample = (my_merged_upsample_ptr)cinfo->upsample;
95
0
  register int y, cred, cgreen, cblue;
96
0
  int cb, cr;
97
0
  register _JSAMPROW outptr;
98
0
  _JSAMPROW inptr0, inptr1, inptr2;
99
0
  JDIMENSION col;
100
  /* copy these pointers into registers if possible */
101
0
  register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit;
102
0
  int *Crrtab = upsample->Cr_r_tab;
103
0
  int *Cbbtab = upsample->Cb_b_tab;
104
0
  JLONG *Crgtab = upsample->Cr_g_tab;
105
0
  JLONG *Cbgtab = upsample->Cb_g_tab;
106
0
  JLONG d0 = dither_matrix[cinfo->output_scanline & DITHER_MASK];
107
0
  unsigned int r, g, b;
108
0
  JLONG rgb;
109
0
  SHIFT_TEMPS
110
111
0
  inptr0 = input_buf[0][in_row_group_ctr];
112
0
  inptr1 = input_buf[1][in_row_group_ctr];
113
0
  inptr2 = input_buf[2][in_row_group_ctr];
114
0
  outptr = output_buf[0];
115
116
  /* Loop for each pair of output pixels */
117
0
  for (col = cinfo->output_width >> 1; col > 0; col--) {
118
    /* Do the chroma part of the calculation */
119
0
    cb = *inptr1++;
120
0
    cr = *inptr2++;
121
0
    cred = Crrtab[cr];
122
0
    cgreen = (int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
123
0
    cblue = Cbbtab[cb];
124
125
    /* Fetch 2 Y values and emit 2 pixels */
126
0
    y  = *inptr0++;
127
0
    r = range_limit[DITHER_565_R(y + cred, d0)];
128
0
    g = range_limit[DITHER_565_G(y + cgreen, d0)];
129
0
    b = range_limit[DITHER_565_B(y + cblue, d0)];
130
0
    d0 = DITHER_ROTATE(d0);
131
0
    rgb = PACK_SHORT_565(r, g, b);
132
133
0
    y  = *inptr0++;
134
0
    r = range_limit[DITHER_565_R(y + cred, d0)];
135
0
    g = range_limit[DITHER_565_G(y + cgreen, d0)];
136
0
    b = range_limit[DITHER_565_B(y + cblue, d0)];
137
0
    d0 = DITHER_ROTATE(d0);
138
0
    rgb = PACK_TWO_PIXELS(rgb, PACK_SHORT_565(r, g, b));
139
140
0
    WRITE_TWO_PIXELS(outptr, rgb);
141
0
    outptr += 4;
142
0
  }
143
144
  /* If image width is odd, do the last output column separately */
145
0
  if (cinfo->output_width & 1) {
146
0
    cb = *inptr1;
147
0
    cr = *inptr2;
148
0
    cred = Crrtab[cr];
149
0
    cgreen = (int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
150
0
    cblue = Cbbtab[cb];
151
0
    y  = *inptr0;
152
0
    r = range_limit[DITHER_565_R(y + cred, d0)];
153
0
    g = range_limit[DITHER_565_G(y + cgreen, d0)];
154
0
    b = range_limit[DITHER_565_B(y + cblue, d0)];
155
0
    rgb = PACK_SHORT_565(r, g, b);
156
0
    *(INT16 *)outptr = (INT16)rgb;
157
0
  }
158
0
}
Unexecuted instantiation: jdmerge.c:h2v1_merged_upsample_565D_be
Unexecuted instantiation: jdmerge.c:h2v1_merged_upsample_565D_le
159
160
161
INLINE
162
LOCAL(void)
163
h2v2_merged_upsample_565_internal(j_decompress_ptr cinfo, _JSAMPIMAGE input_buf,
164
                                  JDIMENSION in_row_group_ctr,
165
                                  _JSAMPARRAY output_buf)
166
0
{
167
0
  my_merged_upsample_ptr upsample = (my_merged_upsample_ptr)cinfo->upsample;
168
0
  register int y, cred, cgreen, cblue;
169
0
  int cb, cr;
170
0
  register _JSAMPROW outptr0, outptr1;
171
0
  _JSAMPROW inptr00, inptr01, inptr1, inptr2;
172
0
  JDIMENSION col;
173
  /* copy these pointers into registers if possible */
174
0
  register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit;
175
0
  int *Crrtab = upsample->Cr_r_tab;
176
0
  int *Cbbtab = upsample->Cb_b_tab;
177
0
  JLONG *Crgtab = upsample->Cr_g_tab;
178
0
  JLONG *Cbgtab = upsample->Cb_g_tab;
179
0
  unsigned int r, g, b;
180
0
  JLONG rgb;
181
0
  SHIFT_TEMPS
182
183
0
  inptr00 = input_buf[0][in_row_group_ctr * 2];
184
0
  inptr01 = input_buf[0][in_row_group_ctr * 2 + 1];
185
0
  inptr1 = input_buf[1][in_row_group_ctr];
186
0
  inptr2 = input_buf[2][in_row_group_ctr];
187
0
  outptr0 = output_buf[0];
188
0
  outptr1 = output_buf[1];
189
190
  /* Loop for each group of output pixels */
191
0
  for (col = cinfo->output_width >> 1; col > 0; col--) {
192
    /* Do the chroma part of the calculation */
193
0
    cb = *inptr1++;
194
0
    cr = *inptr2++;
195
0
    cred = Crrtab[cr];
196
0
    cgreen = (int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
197
0
    cblue = Cbbtab[cb];
198
199
    /* Fetch 4 Y values and emit 4 pixels */
200
0
    y  = *inptr00++;
201
0
    r = range_limit[y + cred];
202
0
    g = range_limit[y + cgreen];
203
0
    b = range_limit[y + cblue];
204
0
    rgb = PACK_SHORT_565(r, g, b);
205
206
0
    y  = *inptr00++;
207
0
    r = range_limit[y + cred];
208
0
    g = range_limit[y + cgreen];
209
0
    b = range_limit[y + cblue];
210
0
    rgb = PACK_TWO_PIXELS(rgb, PACK_SHORT_565(r, g, b));
211
212
0
    WRITE_TWO_PIXELS(outptr0, rgb);
213
0
    outptr0 += 4;
214
215
0
    y  = *inptr01++;
216
0
    r = range_limit[y + cred];
217
0
    g = range_limit[y + cgreen];
218
0
    b = range_limit[y + cblue];
219
0
    rgb = PACK_SHORT_565(r, g, b);
220
221
0
    y  = *inptr01++;
222
0
    r = range_limit[y + cred];
223
0
    g = range_limit[y + cgreen];
224
0
    b = range_limit[y + cblue];
225
0
    rgb = PACK_TWO_PIXELS(rgb, PACK_SHORT_565(r, g, b));
226
227
0
    WRITE_TWO_PIXELS(outptr1, rgb);
228
0
    outptr1 += 4;
229
0
  }
230
231
  /* If image width is odd, do the last output column separately */
232
0
  if (cinfo->output_width & 1) {
233
0
    cb = *inptr1;
234
0
    cr = *inptr2;
235
0
    cred = Crrtab[cr];
236
0
    cgreen = (int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
237
0
    cblue = Cbbtab[cb];
238
239
0
    y  = *inptr00;
240
0
    r = range_limit[y + cred];
241
0
    g = range_limit[y + cgreen];
242
0
    b = range_limit[y + cblue];
243
0
    rgb = PACK_SHORT_565(r, g, b);
244
0
    *(INT16 *)outptr0 = (INT16)rgb;
245
246
0
    y  = *inptr01;
247
0
    r = range_limit[y + cred];
248
0
    g = range_limit[y + cgreen];
249
0
    b = range_limit[y + cblue];
250
0
    rgb = PACK_SHORT_565(r, g, b);
251
0
    *(INT16 *)outptr1 = (INT16)rgb;
252
0
  }
253
0
}
Unexecuted instantiation: jdmerge.c:h2v2_merged_upsample_565_be
Unexecuted instantiation: jdmerge.c:h2v2_merged_upsample_565_le
254
255
256
INLINE
257
LOCAL(void)
258
h2v2_merged_upsample_565D_internal(j_decompress_ptr cinfo,
259
                                   _JSAMPIMAGE input_buf,
260
                                   JDIMENSION in_row_group_ctr,
261
                                   _JSAMPARRAY output_buf)
262
0
{
263
0
  my_merged_upsample_ptr upsample = (my_merged_upsample_ptr)cinfo->upsample;
264
0
  register int y, cred, cgreen, cblue;
265
0
  int cb, cr;
266
0
  register _JSAMPROW outptr0, outptr1;
267
0
  _JSAMPROW inptr00, inptr01, inptr1, inptr2;
268
0
  JDIMENSION col;
269
  /* copy these pointers into registers if possible */
270
0
  register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit;
271
0
  int *Crrtab = upsample->Cr_r_tab;
272
0
  int *Cbbtab = upsample->Cb_b_tab;
273
0
  JLONG *Crgtab = upsample->Cr_g_tab;
274
0
  JLONG *Cbgtab = upsample->Cb_g_tab;
275
0
  JLONG d0 = dither_matrix[cinfo->output_scanline & DITHER_MASK];
276
0
  JLONG d1 = dither_matrix[(cinfo->output_scanline + 1) & DITHER_MASK];
277
0
  unsigned int r, g, b;
278
0
  JLONG rgb;
279
0
  SHIFT_TEMPS
280
281
0
  inptr00 = input_buf[0][in_row_group_ctr * 2];
282
0
  inptr01 = input_buf[0][in_row_group_ctr * 2 + 1];
283
0
  inptr1 = input_buf[1][in_row_group_ctr];
284
0
  inptr2 = input_buf[2][in_row_group_ctr];
285
0
  outptr0 = output_buf[0];
286
0
  outptr1 = output_buf[1];
287
288
  /* Loop for each group of output pixels */
289
0
  for (col = cinfo->output_width >> 1; col > 0; col--) {
290
    /* Do the chroma part of the calculation */
291
0
    cb = *inptr1++;
292
0
    cr = *inptr2++;
293
0
    cred = Crrtab[cr];
294
0
    cgreen = (int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
295
0
    cblue = Cbbtab[cb];
296
297
    /* Fetch 4 Y values and emit 4 pixels */
298
0
    y  = *inptr00++;
299
0
    r = range_limit[DITHER_565_R(y + cred, d0)];
300
0
    g = range_limit[DITHER_565_G(y + cgreen, d0)];
301
0
    b = range_limit[DITHER_565_B(y + cblue, d0)];
302
0
    d0 = DITHER_ROTATE(d0);
303
0
    rgb = PACK_SHORT_565(r, g, b);
304
305
0
    y  = *inptr00++;
306
0
    r = range_limit[DITHER_565_R(y + cred, d0)];
307
0
    g = range_limit[DITHER_565_G(y + cgreen, d0)];
308
0
    b = range_limit[DITHER_565_B(y + cblue, d0)];
309
0
    d0 = DITHER_ROTATE(d0);
310
0
    rgb = PACK_TWO_PIXELS(rgb, PACK_SHORT_565(r, g, b));
311
312
0
    WRITE_TWO_PIXELS(outptr0, rgb);
313
0
    outptr0 += 4;
314
315
0
    y  = *inptr01++;
316
0
    r = range_limit[DITHER_565_R(y + cred, d1)];
317
0
    g = range_limit[DITHER_565_G(y + cgreen, d1)];
318
0
    b = range_limit[DITHER_565_B(y + cblue, d1)];
319
0
    d1 = DITHER_ROTATE(d1);
320
0
    rgb = PACK_SHORT_565(r, g, b);
321
322
0
    y  = *inptr01++;
323
0
    r = range_limit[DITHER_565_R(y + cred, d1)];
324
0
    g = range_limit[DITHER_565_G(y + cgreen, d1)];
325
0
    b = range_limit[DITHER_565_B(y + cblue, d1)];
326
0
    d1 = DITHER_ROTATE(d1);
327
0
    rgb = PACK_TWO_PIXELS(rgb, PACK_SHORT_565(r, g, b));
328
329
0
    WRITE_TWO_PIXELS(outptr1, rgb);
330
0
    outptr1 += 4;
331
0
  }
332
333
  /* If image width is odd, do the last output column separately */
334
0
  if (cinfo->output_width & 1) {
335
0
    cb = *inptr1;
336
0
    cr = *inptr2;
337
0
    cred = Crrtab[cr];
338
0
    cgreen = (int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
339
0
    cblue = Cbbtab[cb];
340
341
0
    y  = *inptr00;
342
0
    r = range_limit[DITHER_565_R(y + cred, d0)];
343
0
    g = range_limit[DITHER_565_G(y + cgreen, d0)];
344
0
    b = range_limit[DITHER_565_B(y + cblue, d0)];
345
0
    rgb = PACK_SHORT_565(r, g, b);
346
0
    *(INT16 *)outptr0 = (INT16)rgb;
347
348
0
    y  = *inptr01;
349
0
    r = range_limit[DITHER_565_R(y + cred, d1)];
350
0
    g = range_limit[DITHER_565_G(y + cgreen, d1)];
351
0
    b = range_limit[DITHER_565_B(y + cblue, d1)];
352
0
    rgb = PACK_SHORT_565(r, g, b);
353
0
    *(INT16 *)outptr1 = (INT16)rgb;
354
0
  }
355
0
}
Unexecuted instantiation: jdmerge.c:h2v2_merged_upsample_565D_be
Unexecuted instantiation: jdmerge.c:h2v2_merged_upsample_565D_le