Coverage Report

Created: 2025-11-24 06:37

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
1.04M
{
35
1.04M
#if BITS_IN_JSAMPLE != 16
36
1.04M
  my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
37
1.04M
  register int y, cb, cr;
38
1.04M
  register _JSAMPROW outptr;
39
1.04M
  register _JSAMPROW inptr0, inptr1, inptr2;
40
1.04M
  register JDIMENSION col;
41
1.04M
  JDIMENSION num_cols = cinfo->output_width;
42
  /* copy these pointers into registers if possible */
43
1.04M
  register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit;
44
1.04M
  register int *Crrtab = cconvert->Cr_r_tab;
45
1.04M
  register int *Cbbtab = cconvert->Cb_b_tab;
46
1.04M
  register JLONG *Crgtab = cconvert->Cr_g_tab;
47
1.04M
  register JLONG *Cbgtab = cconvert->Cb_g_tab;
48
1.04M
  SHIFT_TEMPS
49
50
3.16M
  while (--num_rows >= 0) {
51
2.11M
    inptr0 = input_buf[0][input_row];
52
2.11M
    inptr1 = input_buf[1][input_row];
53
2.11M
    inptr2 = input_buf[2][input_row];
54
2.11M
    input_row++;
55
2.11M
    outptr = *output_buf++;
56
95.1M
    for (col = 0; col < num_cols; col++) {
57
93.0M
      y  = inptr0[col];
58
93.0M
      cb = inptr1[col];
59
93.0M
      cr = inptr2[col];
60
      /* Range-limiting is essential due to noise introduced by DCT losses. */
61
93.0M
      outptr[RGB_RED] =   range_limit[y + Crrtab[cr]];
62
93.0M
      outptr[RGB_GREEN] = range_limit[y +
63
93.0M
                              ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
64
93.0M
                                                SCALEBITS))];
65
93.0M
      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
12.0M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
70
#endif
71
93.0M
      outptr += RGB_PIXELSIZE;
72
93.0M
    }
73
2.11M
  }
74
#else
75
  ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
76
#endif
77
1.04M
}
jdcolor.c:ycc_extrgb_convert_internal
Line
Count
Source
34
1.00M
{
35
1.00M
#if BITS_IN_JSAMPLE != 16
36
1.00M
  my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
37
1.00M
  register int y, cb, cr;
38
1.00M
  register _JSAMPROW outptr;
39
1.00M
  register _JSAMPROW inptr0, inptr1, inptr2;
40
1.00M
  register JDIMENSION col;
41
1.00M
  JDIMENSION num_cols = cinfo->output_width;
42
  /* copy these pointers into registers if possible */
43
1.00M
  register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit;
44
1.00M
  register int *Crrtab = cconvert->Cr_r_tab;
45
1.00M
  register int *Cbbtab = cconvert->Cb_b_tab;
46
1.00M
  register JLONG *Crgtab = cconvert->Cr_g_tab;
47
1.00M
  register JLONG *Cbgtab = cconvert->Cb_g_tab;
48
1.00M
  SHIFT_TEMPS
49
50
3.02M
  while (--num_rows >= 0) {
51
2.01M
    inptr0 = input_buf[0][input_row];
52
2.01M
    inptr1 = input_buf[1][input_row];
53
2.01M
    inptr2 = input_buf[2][input_row];
54
2.01M
    input_row++;
55
2.01M
    outptr = *output_buf++;
56
83.0M
    for (col = 0; col < num_cols; col++) {
57
80.9M
      y  = inptr0[col];
58
80.9M
      cb = inptr1[col];
59
80.9M
      cr = inptr2[col];
60
      /* Range-limiting is essential due to noise introduced by DCT losses. */
61
80.9M
      outptr[RGB_RED] =   range_limit[y + Crrtab[cr]];
62
80.9M
      outptr[RGB_GREEN] = range_limit[y +
63
80.9M
                              ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
64
80.9M
                                                SCALEBITS))];
65
80.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
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
70
#endif
71
80.9M
      outptr += RGB_PIXELSIZE;
72
80.9M
    }
73
2.01M
  }
74
#else
75
  ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
76
#endif
77
1.00M
}
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
39.9k
{
35
39.9k
#if BITS_IN_JSAMPLE != 16
36
39.9k
  my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
37
39.9k
  register int y, cb, cr;
38
39.9k
  register _JSAMPROW outptr;
39
39.9k
  register _JSAMPROW inptr0, inptr1, inptr2;
40
39.9k
  register JDIMENSION col;
41
39.9k
  JDIMENSION num_cols = cinfo->output_width;
42
  /* copy these pointers into registers if possible */
43
39.9k
  register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit;
44
39.9k
  register int *Crrtab = cconvert->Cr_r_tab;
45
39.9k
  register int *Cbbtab = cconvert->Cb_b_tab;
46
39.9k
  register JLONG *Crgtab = cconvert->Cr_g_tab;
47
39.9k
  register JLONG *Cbgtab = cconvert->Cb_g_tab;
48
39.9k
  SHIFT_TEMPS
49
50
140k
  while (--num_rows >= 0) {
51
100k
    inptr0 = input_buf[0][input_row];
52
100k
    inptr1 = input_buf[1][input_row];
53
100k
    inptr2 = input_buf[2][input_row];
54
100k
    input_row++;
55
100k
    outptr = *output_buf++;
56
12.1M
    for (col = 0; col < num_cols; col++) {
57
12.0M
      y  = inptr0[col];
58
12.0M
      cb = inptr1[col];
59
12.0M
      cr = inptr2[col];
60
      /* Range-limiting is essential due to noise introduced by DCT losses. */
61
12.0M
      outptr[RGB_RED] =   range_limit[y + Crrtab[cr]];
62
12.0M
      outptr[RGB_GREEN] = range_limit[y +
63
12.0M
                              ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
64
12.0M
                                                SCALEBITS))];
65
12.0M
      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
12.0M
#ifdef RGB_ALPHA
69
12.0M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
70
12.0M
#endif
71
12.0M
      outptr += RGB_PIXELSIZE;
72
12.0M
    }
73
100k
  }
74
#else
75
  ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
76
#endif
77
39.9k
}
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
8.79M
{
92
8.79M
  register _JSAMPROW inptr, outptr;
93
8.79M
  register JDIMENSION col;
94
8.79M
  JDIMENSION num_cols = cinfo->output_width;
95
96
24.5M
  while (--num_rows >= 0) {
97
15.7M
    inptr = input_buf[0][input_row++];
98
15.7M
    outptr = *output_buf++;
99
781M
    for (col = 0; col < num_cols; col++) {
100
765M
      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
53.3M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
105
#endif
106
765M
      outptr += RGB_PIXELSIZE;
107
765M
    }
108
15.7M
  }
109
8.79M
}
jdcolor.c:gray_extrgb_convert_internal
Line
Count
Source
91
5.47M
{
92
5.47M
  register _JSAMPROW inptr, outptr;
93
5.47M
  register JDIMENSION col;
94
5.47M
  JDIMENSION num_cols = cinfo->output_width;
95
96
17.5M
  while (--num_rows >= 0) {
97
12.0M
    inptr = input_buf[0][input_row++];
98
12.0M
    outptr = *output_buf++;
99
683M
    for (col = 0; col < num_cols; col++) {
100
671M
      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
671M
      outptr += RGB_PIXELSIZE;
107
671M
    }
108
12.0M
  }
109
5.47M
}
Unexecuted instantiation: jdcolor.c:gray_extrgbx_convert_internal
jdcolor.c:gray_extbgr_convert_internal
Line
Count
Source
91
1.71M
{
92
1.71M
  register _JSAMPROW inptr, outptr;
93
1.71M
  register JDIMENSION col;
94
1.71M
  JDIMENSION num_cols = cinfo->output_width;
95
96
3.43M
  while (--num_rows >= 0) {
97
1.71M
    inptr = input_buf[0][input_row++];
98
1.71M
    outptr = *output_buf++;
99
42.3M
    for (col = 0; col < num_cols; col++) {
100
40.6M
      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
40.6M
      outptr += RGB_PIXELSIZE;
107
40.6M
    }
108
1.71M
  }
109
1.71M
}
jdcolor.c:gray_extbgrx_convert_internal
Line
Count
Source
91
309k
{
92
309k
  register _JSAMPROW inptr, outptr;
93
309k
  register JDIMENSION col;
94
309k
  JDIMENSION num_cols = cinfo->output_width;
95
96
974k
  while (--num_rows >= 0) {
97
664k
    inptr = input_buf[0][input_row++];
98
664k
    outptr = *output_buf++;
99
30.0M
    for (col = 0; col < num_cols; col++) {
100
29.4M
      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
29.4M
#ifdef RGB_ALPHA
104
29.4M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
105
29.4M
#endif
106
29.4M
      outptr += RGB_PIXELSIZE;
107
29.4M
    }
108
664k
  }
109
309k
}
Unexecuted instantiation: jdcolor.c:gray_extxbgr_convert_internal
jdcolor.c:gray_extxrgb_convert_internal
Line
Count
Source
91
1.28M
{
92
1.28M
  register _JSAMPROW inptr, outptr;
93
1.28M
  register JDIMENSION col;
94
1.28M
  JDIMENSION num_cols = cinfo->output_width;
95
96
2.57M
  while (--num_rows >= 0) {
97
1.28M
    inptr = input_buf[0][input_row++];
98
1.28M
    outptr = *output_buf++;
99
25.2M
    for (col = 0; col < num_cols; col++) {
100
23.9M
      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
23.9M
#ifdef RGB_ALPHA
104
23.9M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
105
23.9M
#endif
106
23.9M
      outptr += RGB_PIXELSIZE;
107
23.9M
    }
108
1.28M
  }
109
1.28M
}
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
185k
{
122
185k
  register _JSAMPROW inptr0, inptr1, inptr2;
123
185k
  register _JSAMPROW outptr;
124
185k
  register JDIMENSION col;
125
185k
  JDIMENSION num_cols = cinfo->output_width;
126
127
429k
  while (--num_rows >= 0) {
128
244k
    inptr0 = input_buf[0][input_row];
129
244k
    inptr1 = input_buf[1][input_row];
130
244k
    inptr2 = input_buf[2][input_row];
131
244k
    input_row++;
132
244k
    outptr = *output_buf++;
133
15.9M
    for (col = 0; col < num_cols; col++) {
134
15.7M
      outptr[RGB_RED] = inptr0[col];
135
15.7M
      outptr[RGB_GREEN] = inptr1[col];
136
15.7M
      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
8.16M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
141
#endif
142
15.7M
      outptr += RGB_PIXELSIZE;
143
15.7M
    }
144
244k
  }
145
185k
}
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.1k
{
122
68.1k
  register _JSAMPROW inptr0, inptr1, inptr2;
123
68.1k
  register _JSAMPROW outptr;
124
68.1k
  register JDIMENSION col;
125
68.1k
  JDIMENSION num_cols = cinfo->output_width;
126
127
136k
  while (--num_rows >= 0) {
128
68.6k
    inptr0 = input_buf[0][input_row];
129
68.6k
    inptr1 = input_buf[1][input_row];
130
68.6k
    inptr2 = input_buf[2][input_row];
131
68.6k
    input_row++;
132
68.6k
    outptr = *output_buf++;
133
7.65M
    for (col = 0; col < num_cols; col++) {
134
7.58M
      outptr[RGB_RED] = inptr0[col];
135
7.58M
      outptr[RGB_GREEN] = inptr1[col];
136
7.58M
      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
7.58M
      outptr += RGB_PIXELSIZE;
143
7.58M
    }
144
68.6k
  }
145
68.1k
}
jdcolor.c:rgb_extbgrx_convert_internal
Line
Count
Source
121
65.9k
{
122
65.9k
  register _JSAMPROW inptr0, inptr1, inptr2;
123
65.9k
  register _JSAMPROW outptr;
124
65.9k
  register JDIMENSION col;
125
65.9k
  JDIMENSION num_cols = cinfo->output_width;
126
127
190k
  while (--num_rows >= 0) {
128
124k
    inptr0 = input_buf[0][input_row];
129
124k
    inptr1 = input_buf[1][input_row];
130
124k
    inptr2 = input_buf[2][input_row];
131
124k
    input_row++;
132
124k
    outptr = *output_buf++;
133
3.85M
    for (col = 0; col < num_cols; col++) {
134
3.73M
      outptr[RGB_RED] = inptr0[col];
135
3.73M
      outptr[RGB_GREEN] = inptr1[col];
136
3.73M
      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.73M
#ifdef RGB_ALPHA
140
3.73M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
141
3.73M
#endif
142
3.73M
      outptr += RGB_PIXELSIZE;
143
3.73M
    }
144
124k
  }
145
65.9k
}
Unexecuted instantiation: jdcolor.c:rgb_extxbgr_convert_internal
jdcolor.c:rgb_extxrgb_convert_internal
Line
Count
Source
121
51.1k
{
122
51.1k
  register _JSAMPROW inptr0, inptr1, inptr2;
123
51.1k
  register _JSAMPROW outptr;
124
51.1k
  register JDIMENSION col;
125
51.1k
  JDIMENSION num_cols = cinfo->output_width;
126
127
102k
  while (--num_rows >= 0) {
128
51.5k
    inptr0 = input_buf[0][input_row];
129
51.5k
    inptr1 = input_buf[1][input_row];
130
51.5k
    inptr2 = input_buf[2][input_row];
131
51.5k
    input_row++;
132
51.5k
    outptr = *output_buf++;
133
4.48M
    for (col = 0; col < num_cols; col++) {
134
4.43M
      outptr[RGB_RED] = inptr0[col];
135
4.43M
      outptr[RGB_GREEN] = inptr1[col];
136
4.43M
      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.43M
#ifdef RGB_ALPHA
140
4.43M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
141
4.43M
#endif
142
4.43M
      outptr += RGB_PIXELSIZE;
143
4.43M
    }
144
51.5k
  }
145
51.1k
}
Unexecuted instantiation: jdcolor.c:rgb_rgb_convert_internal