Coverage Report

Created: 2026-06-12 06:28

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
936k
{
35
936k
#if BITS_IN_JSAMPLE != 16
36
936k
  my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
37
936k
  register int y, cb, cr;
38
936k
  register _JSAMPROW outptr;
39
936k
  register _JSAMPROW inptr0, inptr1, inptr2;
40
936k
  register JDIMENSION col;
41
936k
  JDIMENSION num_cols = cinfo->output_width;
42
  /* copy these pointers into registers if possible */
43
936k
  register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit;
44
936k
  register int *Crrtab = cconvert->Cr_r_tab;
45
936k
  register int *Cbbtab = cconvert->Cb_b_tab;
46
936k
  register JLONG *Crgtab = cconvert->Cr_g_tab;
47
936k
  register JLONG *Cbgtab = cconvert->Cb_g_tab;
48
936k
  SHIFT_TEMPS
49
50
3.58M
  while (--num_rows >= 0) {
51
2.65M
    inptr0 = input_buf[0][input_row];
52
2.65M
    inptr1 = input_buf[1][input_row];
53
2.65M
    inptr2 = input_buf[2][input_row];
54
2.65M
    input_row++;
55
2.65M
    outptr = *output_buf++;
56
58.7M
    for (col = 0; col < num_cols; col++) {
57
56.1M
      y  = inptr0[col];
58
56.1M
      cb = inptr1[col];
59
56.1M
      cr = inptr2[col];
60
      /* Range-limiting is essential due to noise introduced by DCT losses. */
61
56.1M
      outptr[RGB_RED] =   range_limit[y + Crrtab[cr]];
62
56.1M
      outptr[RGB_GREEN] = range_limit[y +
63
56.1M
                              ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
64
56.1M
                                                SCALEBITS))];
65
56.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
#ifdef RGB_ALPHA
69
13.4M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
70
#endif
71
56.1M
      outptr += RGB_PIXELSIZE;
72
56.1M
    }
73
2.65M
  }
74
#else
75
  ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
76
#endif
77
936k
}
jdcolor.c:ycc_extrgb_convert_internal
Line
Count
Source
34
554k
{
35
554k
#if BITS_IN_JSAMPLE != 16
36
554k
  my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
37
554k
  register int y, cb, cr;
38
554k
  register _JSAMPROW outptr;
39
554k
  register _JSAMPROW inptr0, inptr1, inptr2;
40
554k
  register JDIMENSION col;
41
554k
  JDIMENSION num_cols = cinfo->output_width;
42
  /* copy these pointers into registers if possible */
43
554k
  register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit;
44
554k
  register int *Crrtab = cconvert->Cr_r_tab;
45
554k
  register int *Cbbtab = cconvert->Cb_b_tab;
46
554k
  register JLONG *Crgtab = cconvert->Cr_g_tab;
47
554k
  register JLONG *Cbgtab = cconvert->Cb_g_tab;
48
554k
  SHIFT_TEMPS
49
50
2.21M
  while (--num_rows >= 0) {
51
1.65M
    inptr0 = input_buf[0][input_row];
52
1.65M
    inptr1 = input_buf[1][input_row];
53
1.65M
    inptr2 = input_buf[2][input_row];
54
1.65M
    input_row++;
55
1.65M
    outptr = *output_buf++;
56
44.3M
    for (col = 0; col < num_cols; col++) {
57
42.6M
      y  = inptr0[col];
58
42.6M
      cb = inptr1[col];
59
42.6M
      cr = inptr2[col];
60
      /* Range-limiting is essential due to noise introduced by DCT losses. */
61
42.6M
      outptr[RGB_RED] =   range_limit[y + Crrtab[cr]];
62
42.6M
      outptr[RGB_GREEN] = range_limit[y +
63
42.6M
                              ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
64
42.6M
                                                SCALEBITS))];
65
42.6M
      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
42.6M
      outptr += RGB_PIXELSIZE;
72
42.6M
    }
73
1.65M
  }
74
#else
75
  ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
76
#endif
77
554k
}
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
381k
{
35
381k
#if BITS_IN_JSAMPLE != 16
36
381k
  my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
37
381k
  register int y, cb, cr;
38
381k
  register _JSAMPROW outptr;
39
381k
  register _JSAMPROW inptr0, inptr1, inptr2;
40
381k
  register JDIMENSION col;
41
381k
  JDIMENSION num_cols = cinfo->output_width;
42
  /* copy these pointers into registers if possible */
43
381k
  register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit;
44
381k
  register int *Crrtab = cconvert->Cr_r_tab;
45
381k
  register int *Cbbtab = cconvert->Cb_b_tab;
46
381k
  register JLONG *Crgtab = cconvert->Cr_g_tab;
47
381k
  register JLONG *Cbgtab = cconvert->Cb_g_tab;
48
381k
  SHIFT_TEMPS
49
50
1.37M
  while (--num_rows >= 0) {
51
995k
    inptr0 = input_buf[0][input_row];
52
995k
    inptr1 = input_buf[1][input_row];
53
995k
    inptr2 = input_buf[2][input_row];
54
995k
    input_row++;
55
995k
    outptr = *output_buf++;
56
14.4M
    for (col = 0; col < num_cols; col++) {
57
13.4M
      y  = inptr0[col];
58
13.4M
      cb = inptr1[col];
59
13.4M
      cr = inptr2[col];
60
      /* Range-limiting is essential due to noise introduced by DCT losses. */
61
13.4M
      outptr[RGB_RED] =   range_limit[y + Crrtab[cr]];
62
13.4M
      outptr[RGB_GREEN] = range_limit[y +
63
13.4M
                              ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
64
13.4M
                                                SCALEBITS))];
65
13.4M
      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.4M
#ifdef RGB_ALPHA
69
13.4M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
70
13.4M
#endif
71
13.4M
      outptr += RGB_PIXELSIZE;
72
13.4M
    }
73
995k
  }
74
#else
75
  ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
76
#endif
77
381k
}
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
11.1M
{
92
11.1M
  register _JSAMPROW inptr, outptr;
93
11.1M
  register JDIMENSION col;
94
11.1M
  JDIMENSION num_cols = cinfo->output_width;
95
96
31.4M
  while (--num_rows >= 0) {
97
20.3M
    inptr = input_buf[0][input_row++];
98
20.3M
    outptr = *output_buf++;
99
1.01G
    for (col = 0; col < num_cols; col++) {
100
993M
      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
205M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
105
#endif
106
993M
      outptr += RGB_PIXELSIZE;
107
993M
    }
108
20.3M
  }
109
11.1M
}
jdcolor.c:gray_extrgb_convert_internal
Line
Count
Source
91
5.92M
{
92
5.92M
  register _JSAMPROW inptr, outptr;
93
5.92M
  register JDIMENSION col;
94
5.92M
  JDIMENSION num_cols = cinfo->output_width;
95
96
18.0M
  while (--num_rows >= 0) {
97
12.0M
    inptr = input_buf[0][input_row++];
98
12.0M
    outptr = *output_buf++;
99
779M
    for (col = 0; col < num_cols; col++) {
100
767M
      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
767M
      outptr += RGB_PIXELSIZE;
107
767M
    }
108
12.0M
  }
109
5.92M
}
Unexecuted instantiation: jdcolor.c:gray_extrgbx_convert_internal
jdcolor.c:gray_extbgr_convert_internal
Line
Count
Source
91
1.30M
{
92
1.30M
  register _JSAMPROW inptr, outptr;
93
1.30M
  register JDIMENSION col;
94
1.30M
  JDIMENSION num_cols = cinfo->output_width;
95
96
2.61M
  while (--num_rows >= 0) {
97
1.30M
    inptr = input_buf[0][input_row++];
98
1.30M
    outptr = *output_buf++;
99
21.4M
    for (col = 0; col < num_cols; col++) {
100
20.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
20.1M
      outptr += RGB_PIXELSIZE;
107
20.1M
    }
108
1.30M
  }
109
1.30M
}
jdcolor.c:gray_extbgrx_convert_internal
Line
Count
Source
91
2.92M
{
92
2.92M
  register _JSAMPROW inptr, outptr;
93
2.92M
  register JDIMENSION col;
94
2.92M
  JDIMENSION num_cols = cinfo->output_width;
95
96
8.85M
  while (--num_rows >= 0) {
97
5.93M
    inptr = input_buf[0][input_row++];
98
5.93M
    outptr = *output_buf++;
99
200M
    for (col = 0; col < num_cols; col++) {
100
194M
      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
194M
#ifdef RGB_ALPHA
104
194M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
105
194M
#endif
106
194M
      outptr += RGB_PIXELSIZE;
107
194M
    }
108
5.93M
  }
109
2.92M
}
Unexecuted instantiation: jdcolor.c:gray_extxbgr_convert_internal
jdcolor.c:gray_extxrgb_convert_internal
Line
Count
Source
91
979k
{
92
979k
  register _JSAMPROW inptr, outptr;
93
979k
  register JDIMENSION col;
94
979k
  JDIMENSION num_cols = cinfo->output_width;
95
96
1.95M
  while (--num_rows >= 0) {
97
979k
    inptr = input_buf[0][input_row++];
98
979k
    outptr = *output_buf++;
99
12.8M
    for (col = 0; col < num_cols; col++) {
100
11.8M
      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
11.8M
#ifdef RGB_ALPHA
104
11.8M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
105
11.8M
#endif
106
11.8M
      outptr += RGB_PIXELSIZE;
107
11.8M
    }
108
979k
  }
109
979k
}
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
967k
{
122
967k
  register _JSAMPROW inptr0, inptr1, inptr2;
123
967k
  register _JSAMPROW outptr;
124
967k
  register JDIMENSION col;
125
967k
  JDIMENSION num_cols = cinfo->output_width;
126
127
2.71M
  while (--num_rows >= 0) {
128
1.75M
    inptr0 = input_buf[0][input_row];
129
1.75M
    inptr1 = input_buf[1][input_row];
130
1.75M
    inptr2 = input_buf[2][input_row];
131
1.75M
    input_row++;
132
1.75M
    outptr = *output_buf++;
133
45.6M
    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.1M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
141
#endif
142
43.9M
      outptr += RGB_PIXELSIZE;
143
43.9M
    }
144
1.75M
  }
145
967k
}
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.2k
{
122
68.2k
  register _JSAMPROW inptr0, inptr1, inptr2;
123
68.2k
  register _JSAMPROW outptr;
124
68.2k
  register JDIMENSION col;
125
68.2k
  JDIMENSION num_cols = cinfo->output_width;
126
127
137k
  while (--num_rows >= 0) {
128
69.3k
    inptr0 = input_buf[0][input_row];
129
69.3k
    inptr1 = input_buf[1][input_row];
130
69.3k
    inptr2 = input_buf[2][input_row];
131
69.3k
    input_row++;
132
69.3k
    outptr = *output_buf++;
133
6.85M
    for (col = 0; col < num_cols; col++) {
134
6.78M
      outptr[RGB_RED] = inptr0[col];
135
6.78M
      outptr[RGB_GREEN] = inptr1[col];
136
6.78M
      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.78M
      outptr += RGB_PIXELSIZE;
143
6.78M
    }
144
69.3k
  }
145
68.2k
}
jdcolor.c:rgb_extbgrx_convert_internal
Line
Count
Source
121
847k
{
122
847k
  register _JSAMPROW inptr0, inptr1, inptr2;
123
847k
  register _JSAMPROW outptr;
124
847k
  register JDIMENSION col;
125
847k
  JDIMENSION num_cols = cinfo->output_width;
126
127
2.47M
  while (--num_rows >= 0) {
128
1.62M
    inptr0 = input_buf[0][input_row];
129
1.62M
    inptr1 = input_buf[1][input_row];
130
1.62M
    inptr2 = input_buf[2][input_row];
131
1.62M
    input_row++;
132
1.62M
    outptr = *output_buf++;
133
34.8M
    for (col = 0; col < num_cols; col++) {
134
33.2M
      outptr[RGB_RED] = inptr0[col];
135
33.2M
      outptr[RGB_GREEN] = inptr1[col];
136
33.2M
      outptr[RGB_BLUE] = inptr2[col];
137
      /* Set unused byte to _MAXJSAMPLE so it can be interpreted as an */
138
      /* opaque alpha channel value */
139
33.2M
#ifdef RGB_ALPHA
140
33.2M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
141
33.2M
#endif
142
33.2M
      outptr += RGB_PIXELSIZE;
143
33.2M
    }
144
1.62M
  }
145
847k
}
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.00M
    for (col = 0; col < num_cols; col++) {
134
3.95M
      outptr[RGB_RED] = inptr0[col];
135
3.95M
      outptr[RGB_GREEN] = inptr1[col];
136
3.95M
      outptr[RGB_BLUE] = inptr2[col];
137
      /* Set unused byte to _MAXJSAMPLE so it can be interpreted as an */
138
      /* opaque alpha channel value */
139
3.95M
#ifdef RGB_ALPHA
140
3.95M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
141
3.95M
#endif
142
3.95M
      outptr += RGB_PIXELSIZE;
143
3.95M
    }
144
52.0k
  }
145
51.2k
}
Unexecuted instantiation: jdcolor.c:rgb_rgb_convert_internal