Coverage Report

Created: 2026-04-12 06:05

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libjpeg-turbo.3.0.x/jdcolext.c
Line
Count
Source
1
/*
2
 * jdcolext.c
3
 *
4
 * This file was part of the Independent JPEG Group's software:
5
 * Copyright (C) 1991-1997, Thomas G. Lane.
6
 * libjpeg-turbo Modifications:
7
 * Copyright (C) 2009, 2011, 2015, 2022-2023, D. R. Commander.
8
 * For conditions of distribution and use, see the accompanying README.ijg
9
 * file.
10
 *
11
 * This file contains output colorspace conversion routines.
12
 */
13
14
15
/* This file is included by jdcolor.c */
16
17
18
/*
19
 * Convert some rows of samples to the output colorspace.
20
 *
21
 * Note that we change from noninterleaved, one-plane-per-component format
22
 * to interleaved-pixel format.  The output buffer is therefore three times
23
 * as wide as the input buffer.
24
 * A starting row offset is provided only for the input buffer.  The caller
25
 * can easily adjust the passed output_buf value to accommodate any row
26
 * offset required on that side.
27
 */
28
29
INLINE
30
LOCAL(void)
31
ycc_rgb_convert_internal(j_decompress_ptr cinfo, _JSAMPIMAGE input_buf,
32
                         JDIMENSION input_row, _JSAMPARRAY output_buf,
33
                         int num_rows)
34
999k
{
35
999k
#if BITS_IN_JSAMPLE != 16
36
999k
  my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
37
999k
  register int y, cb, cr;
38
999k
  register _JSAMPROW outptr;
39
999k
  register _JSAMPROW inptr0, inptr1, inptr2;
40
999k
  register JDIMENSION col;
41
999k
  JDIMENSION num_cols = cinfo->output_width;
42
  /* copy these pointers into registers if possible */
43
999k
  register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit;
44
999k
  register int *Crrtab = cconvert->Cr_r_tab;
45
999k
  register int *Cbbtab = cconvert->Cb_b_tab;
46
999k
  register JLONG *Crgtab = cconvert->Cr_g_tab;
47
999k
  register JLONG *Cbgtab = cconvert->Cb_g_tab;
48
999k
  SHIFT_TEMPS
49
50
3.51M
  while (--num_rows >= 0) {
51
2.51M
    inptr0 = input_buf[0][input_row];
52
2.51M
    inptr1 = input_buf[1][input_row];
53
2.51M
    inptr2 = input_buf[2][input_row];
54
2.51M
    input_row++;
55
2.51M
    outptr = *output_buf++;
56
56.5M
    for (col = 0; col < num_cols; col++) {
57
53.9M
      y  = inptr0[col];
58
53.9M
      cb = inptr1[col];
59
53.9M
      cr = inptr2[col];
60
      /* Range-limiting is essential due to noise introduced by DCT losses. */
61
53.9M
      outptr[RGB_RED] =   range_limit[y + Crrtab[cr]];
62
53.9M
      outptr[RGB_GREEN] = range_limit[y +
63
53.9M
                              ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
64
53.9M
                                                SCALEBITS))];
65
53.9M
      outptr[RGB_BLUE] =  range_limit[y + Cbbtab[cb]];
66
      /* Set unused byte to _MAXJSAMPLE so it can be interpreted as an */
67
      /* opaque alpha channel value */
68
#ifdef RGB_ALPHA
69
13.1M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
70
#endif
71
53.9M
      outptr += RGB_PIXELSIZE;
72
53.9M
    }
73
2.51M
  }
74
#else
75
  ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
76
#endif
77
999k
}
jdcolor.c:ycc_extrgb_convert_internal
Line
Count
Source
34
601k
{
35
601k
#if BITS_IN_JSAMPLE != 16
36
601k
  my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
37
601k
  register int y, cb, cr;
38
601k
  register _JSAMPROW outptr;
39
601k
  register _JSAMPROW inptr0, inptr1, inptr2;
40
601k
  register JDIMENSION col;
41
601k
  JDIMENSION num_cols = cinfo->output_width;
42
  /* copy these pointers into registers if possible */
43
601k
  register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit;
44
601k
  register int *Crrtab = cconvert->Cr_r_tab;
45
601k
  register int *Cbbtab = cconvert->Cb_b_tab;
46
601k
  register JLONG *Crgtab = cconvert->Cr_g_tab;
47
601k
  register JLONG *Cbgtab = cconvert->Cb_g_tab;
48
601k
  SHIFT_TEMPS
49
50
2.16M
  while (--num_rows >= 0) {
51
1.56M
    inptr0 = input_buf[0][input_row];
52
1.56M
    inptr1 = input_buf[1][input_row];
53
1.56M
    inptr2 = input_buf[2][input_row];
54
1.56M
    input_row++;
55
1.56M
    outptr = *output_buf++;
56
42.4M
    for (col = 0; col < num_cols; col++) {
57
40.8M
      y  = inptr0[col];
58
40.8M
      cb = inptr1[col];
59
40.8M
      cr = inptr2[col];
60
      /* Range-limiting is essential due to noise introduced by DCT losses. */
61
40.8M
      outptr[RGB_RED] =   range_limit[y + Crrtab[cr]];
62
40.8M
      outptr[RGB_GREEN] = range_limit[y +
63
40.8M
                              ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
64
40.8M
                                                SCALEBITS))];
65
40.8M
      outptr[RGB_BLUE] =  range_limit[y + Cbbtab[cb]];
66
      /* Set unused byte to _MAXJSAMPLE so it can be interpreted as an */
67
      /* opaque alpha channel value */
68
#ifdef RGB_ALPHA
69
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
70
#endif
71
40.8M
      outptr += RGB_PIXELSIZE;
72
40.8M
    }
73
1.56M
  }
74
#else
75
  ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
76
#endif
77
601k
}
Unexecuted instantiation: jdcolor.c:ycc_extrgbx_convert_internal
Unexecuted instantiation: jdcolor.c:ycc_extbgr_convert_internal
jdcolor.c:ycc_extbgrx_convert_internal
Line
Count
Source
34
398k
{
35
398k
#if BITS_IN_JSAMPLE != 16
36
398k
  my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
37
398k
  register int y, cb, cr;
38
398k
  register _JSAMPROW outptr;
39
398k
  register _JSAMPROW inptr0, inptr1, inptr2;
40
398k
  register JDIMENSION col;
41
398k
  JDIMENSION num_cols = cinfo->output_width;
42
  /* copy these pointers into registers if possible */
43
398k
  register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit;
44
398k
  register int *Crrtab = cconvert->Cr_r_tab;
45
398k
  register int *Cbbtab = cconvert->Cb_b_tab;
46
398k
  register JLONG *Crgtab = cconvert->Cr_g_tab;
47
398k
  register JLONG *Cbgtab = cconvert->Cb_g_tab;
48
398k
  SHIFT_TEMPS
49
50
1.34M
  while (--num_rows >= 0) {
51
943k
    inptr0 = input_buf[0][input_row];
52
943k
    inptr1 = input_buf[1][input_row];
53
943k
    inptr2 = input_buf[2][input_row];
54
943k
    input_row++;
55
943k
    outptr = *output_buf++;
56
14.0M
    for (col = 0; col < num_cols; col++) {
57
13.1M
      y  = inptr0[col];
58
13.1M
      cb = inptr1[col];
59
13.1M
      cr = inptr2[col];
60
      /* Range-limiting is essential due to noise introduced by DCT losses. */
61
13.1M
      outptr[RGB_RED] =   range_limit[y + Crrtab[cr]];
62
13.1M
      outptr[RGB_GREEN] = range_limit[y +
63
13.1M
                              ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
64
13.1M
                                                SCALEBITS))];
65
13.1M
      outptr[RGB_BLUE] =  range_limit[y + Cbbtab[cb]];
66
      /* Set unused byte to _MAXJSAMPLE so it can be interpreted as an */
67
      /* opaque alpha channel value */
68
13.1M
#ifdef RGB_ALPHA
69
13.1M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
70
13.1M
#endif
71
13.1M
      outptr += RGB_PIXELSIZE;
72
13.1M
    }
73
943k
  }
74
#else
75
  ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
76
#endif
77
398k
}
Unexecuted instantiation: jdcolor.c:ycc_extxbgr_convert_internal
Unexecuted instantiation: jdcolor.c:ycc_extxrgb_convert_internal
Unexecuted instantiation: jdcolor.c:ycc_rgb_convert_internal
78
79
80
/*
81
 * Convert grayscale to RGB: just duplicate the graylevel three times.
82
 * This is provided to support applications that don't want to cope
83
 * with grayscale as a separate case.
84
 */
85
86
INLINE
87
LOCAL(void)
88
gray_rgb_convert_internal(j_decompress_ptr cinfo, _JSAMPIMAGE input_buf,
89
                          JDIMENSION input_row, _JSAMPARRAY output_buf,
90
                          int num_rows)
91
10.3M
{
92
10.3M
  register _JSAMPROW inptr, outptr;
93
10.3M
  register JDIMENSION col;
94
10.3M
  JDIMENSION num_cols = cinfo->output_width;
95
96
29.4M
  while (--num_rows >= 0) {
97
19.1M
    inptr = input_buf[0][input_row++];
98
19.1M
    outptr = *output_buf++;
99
940M
    for (col = 0; col < num_cols; col++) {
100
921M
      outptr[RGB_RED] = outptr[RGB_GREEN] = outptr[RGB_BLUE] = inptr[col];
101
      /* Set unused byte to _MAXJSAMPLE so it can be interpreted as an */
102
      /* opaque alpha channel value */
103
#ifdef RGB_ALPHA
104
192M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
105
#endif
106
921M
      outptr += RGB_PIXELSIZE;
107
921M
    }
108
19.1M
  }
109
10.3M
}
jdcolor.c:gray_extrgb_convert_internal
Line
Count
Source
91
5.30M
{
92
5.30M
  register _JSAMPROW inptr, outptr;
93
5.30M
  register JDIMENSION col;
94
5.30M
  JDIMENSION num_cols = cinfo->output_width;
95
96
16.5M
  while (--num_rows >= 0) {
97
11.2M
    inptr = input_buf[0][input_row++];
98
11.2M
    outptr = *output_buf++;
99
717M
    for (col = 0; col < num_cols; col++) {
100
705M
      outptr[RGB_RED] = outptr[RGB_GREEN] = outptr[RGB_BLUE] = inptr[col];
101
      /* Set unused byte to _MAXJSAMPLE so it can be interpreted as an */
102
      /* opaque alpha channel value */
103
#ifdef RGB_ALPHA
104
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
105
#endif
106
705M
      outptr += RGB_PIXELSIZE;
107
705M
    }
108
11.2M
  }
109
5.30M
}
Unexecuted instantiation: jdcolor.c:gray_extrgbx_convert_internal
jdcolor.c:gray_extbgr_convert_internal
Line
Count
Source
91
1.36M
{
92
1.36M
  register _JSAMPROW inptr, outptr;
93
1.36M
  register JDIMENSION col;
94
1.36M
  JDIMENSION num_cols = cinfo->output_width;
95
96
2.73M
  while (--num_rows >= 0) {
97
1.36M
    inptr = input_buf[0][input_row++];
98
1.36M
    outptr = *output_buf++;
99
24.5M
    for (col = 0; col < num_cols; col++) {
100
23.1M
      outptr[RGB_RED] = outptr[RGB_GREEN] = outptr[RGB_BLUE] = inptr[col];
101
      /* Set unused byte to _MAXJSAMPLE so it can be interpreted as an */
102
      /* opaque alpha channel value */
103
#ifdef RGB_ALPHA
104
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
105
#endif
106
23.1M
      outptr += RGB_PIXELSIZE;
107
23.1M
    }
108
1.36M
  }
109
1.36M
}
jdcolor.c:gray_extbgrx_convert_internal
Line
Count
Source
91
2.62M
{
92
2.62M
  register _JSAMPROW inptr, outptr;
93
2.62M
  register JDIMENSION col;
94
2.62M
  JDIMENSION num_cols = cinfo->output_width;
95
96
8.16M
  while (--num_rows >= 0) {
97
5.53M
    inptr = input_buf[0][input_row++];
98
5.53M
    outptr = *output_buf++;
99
184M
    for (col = 0; col < num_cols; col++) {
100
178M
      outptr[RGB_RED] = outptr[RGB_GREEN] = outptr[RGB_BLUE] = inptr[col];
101
      /* Set unused byte to _MAXJSAMPLE so it can be interpreted as an */
102
      /* opaque alpha channel value */
103
178M
#ifdef RGB_ALPHA
104
178M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
105
178M
#endif
106
178M
      outptr += RGB_PIXELSIZE;
107
178M
    }
108
5.53M
  }
109
2.62M
}
Unexecuted instantiation: jdcolor.c:gray_extxbgr_convert_internal
jdcolor.c:gray_extxrgb_convert_internal
Line
Count
Source
91
1.02M
{
92
1.02M
  register _JSAMPROW inptr, outptr;
93
1.02M
  register JDIMENSION col;
94
1.02M
  JDIMENSION num_cols = cinfo->output_width;
95
96
2.05M
  while (--num_rows >= 0) {
97
1.02M
    inptr = input_buf[0][input_row++];
98
1.02M
    outptr = *output_buf++;
99
14.7M
    for (col = 0; col < num_cols; col++) {
100
13.7M
      outptr[RGB_RED] = outptr[RGB_GREEN] = outptr[RGB_BLUE] = inptr[col];
101
      /* Set unused byte to _MAXJSAMPLE so it can be interpreted as an */
102
      /* opaque alpha channel value */
103
13.7M
#ifdef RGB_ALPHA
104
13.7M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
105
13.7M
#endif
106
13.7M
      outptr += RGB_PIXELSIZE;
107
13.7M
    }
108
1.02M
  }
109
1.02M
}
Unexecuted instantiation: jdcolor.c:gray_rgb_convert_internal
110
111
112
/*
113
 * Convert RGB to extended RGB: just swap the order of source pixels
114
 */
115
116
INLINE
117
LOCAL(void)
118
rgb_rgb_convert_internal(j_decompress_ptr cinfo, _JSAMPIMAGE input_buf,
119
                         JDIMENSION input_row, _JSAMPARRAY output_buf,
120
                         int num_rows)
121
894k
{
122
894k
  register _JSAMPROW inptr0, inptr1, inptr2;
123
894k
  register _JSAMPROW outptr;
124
894k
  register JDIMENSION col;
125
894k
  JDIMENSION num_cols = cinfo->output_width;
126
127
2.47M
  while (--num_rows >= 0) {
128
1.57M
    inptr0 = input_buf[0][input_row];
129
1.57M
    inptr1 = input_buf[1][input_row];
130
1.57M
    inptr2 = input_buf[2][input_row];
131
1.57M
    input_row++;
132
1.57M
    outptr = *output_buf++;
133
45.4M
    for (col = 0; col < num_cols; col++) {
134
43.9M
      outptr[RGB_RED] = inptr0[col];
135
43.9M
      outptr[RGB_GREEN] = inptr1[col];
136
43.9M
      outptr[RGB_BLUE] = inptr2[col];
137
      /* Set unused byte to _MAXJSAMPLE so it can be interpreted as an */
138
      /* opaque alpha channel value */
139
#ifdef RGB_ALPHA
140
37.0M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
141
#endif
142
43.9M
      outptr += RGB_PIXELSIZE;
143
43.9M
    }
144
1.57M
  }
145
894k
}
Unexecuted instantiation: jdcolor.c:rgb_extrgb_convert_internal
Unexecuted instantiation: jdcolor.c:rgb_extrgbx_convert_internal
jdcolor.c:rgb_extbgr_convert_internal
Line
Count
Source
121
68.3k
{
122
68.3k
  register _JSAMPROW inptr0, inptr1, inptr2;
123
68.3k
  register _JSAMPROW outptr;
124
68.3k
  register JDIMENSION col;
125
68.3k
  JDIMENSION num_cols = cinfo->output_width;
126
127
137k
  while (--num_rows >= 0) {
128
69.4k
    inptr0 = input_buf[0][input_row];
129
69.4k
    inptr1 = input_buf[1][input_row];
130
69.4k
    inptr2 = input_buf[2][input_row];
131
69.4k
    input_row++;
132
69.4k
    outptr = *output_buf++;
133
6.98M
    for (col = 0; col < num_cols; col++) {
134
6.91M
      outptr[RGB_RED] = inptr0[col];
135
6.91M
      outptr[RGB_GREEN] = inptr1[col];
136
6.91M
      outptr[RGB_BLUE] = inptr2[col];
137
      /* Set unused byte to _MAXJSAMPLE so it can be interpreted as an */
138
      /* opaque alpha channel value */
139
#ifdef RGB_ALPHA
140
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
141
#endif
142
6.91M
      outptr += RGB_PIXELSIZE;
143
6.91M
    }
144
69.4k
  }
145
68.3k
}
jdcolor.c:rgb_extbgrx_convert_internal
Line
Count
Source
121
774k
{
122
774k
  register _JSAMPROW inptr0, inptr1, inptr2;
123
774k
  register _JSAMPROW outptr;
124
774k
  register JDIMENSION col;
125
774k
  JDIMENSION num_cols = cinfo->output_width;
126
127
2.23M
  while (--num_rows >= 0) {
128
1.45M
    inptr0 = input_buf[0][input_row];
129
1.45M
    inptr1 = input_buf[1][input_row];
130
1.45M
    inptr2 = input_buf[2][input_row];
131
1.45M
    input_row++;
132
1.45M
    outptr = *output_buf++;
133
34.3M
    for (col = 0; col < num_cols; col++) {
134
32.9M
      outptr[RGB_RED] = inptr0[col];
135
32.9M
      outptr[RGB_GREEN] = inptr1[col];
136
32.9M
      outptr[RGB_BLUE] = inptr2[col];
137
      /* Set unused byte to _MAXJSAMPLE so it can be interpreted as an */
138
      /* opaque alpha channel value */
139
32.9M
#ifdef RGB_ALPHA
140
32.9M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
141
32.9M
#endif
142
32.9M
      outptr += RGB_PIXELSIZE;
143
32.9M
    }
144
1.45M
  }
145
774k
}
Unexecuted instantiation: jdcolor.c:rgb_extxbgr_convert_internal
jdcolor.c:rgb_extxrgb_convert_internal
Line
Count
Source
121
51.2k
{
122
51.2k
  register _JSAMPROW inptr0, inptr1, inptr2;
123
51.2k
  register _JSAMPROW outptr;
124
51.2k
  register JDIMENSION col;
125
51.2k
  JDIMENSION num_cols = cinfo->output_width;
126
127
103k
  while (--num_rows >= 0) {
128
52.0k
    inptr0 = input_buf[0][input_row];
129
52.0k
    inptr1 = input_buf[1][input_row];
130
52.0k
    inptr2 = input_buf[2][input_row];
131
52.0k
    input_row++;
132
52.0k
    outptr = *output_buf++;
133
4.13M
    for (col = 0; col < num_cols; col++) {
134
4.07M
      outptr[RGB_RED] = inptr0[col];
135
4.07M
      outptr[RGB_GREEN] = inptr1[col];
136
4.07M
      outptr[RGB_BLUE] = inptr2[col];
137
      /* Set unused byte to _MAXJSAMPLE so it can be interpreted as an */
138
      /* opaque alpha channel value */
139
4.07M
#ifdef RGB_ALPHA
140
4.07M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
141
4.07M
#endif
142
4.07M
      outptr += RGB_PIXELSIZE;
143
4.07M
    }
144
52.0k
  }
145
51.2k
}
Unexecuted instantiation: jdcolor.c:rgb_rgb_convert_internal