Coverage Report

Created: 2025-10-10 07:05

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