Coverage Report

Created: 2026-04-28 06:57

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
973k
{
35
973k
#if BITS_IN_JSAMPLE != 16
36
973k
  my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
37
973k
  register int y, cb, cr;
38
973k
  register _JSAMPROW outptr;
39
973k
  register _JSAMPROW inptr0, inptr1, inptr2;
40
973k
  register JDIMENSION col;
41
973k
  JDIMENSION num_cols = cinfo->output_width;
42
  /* copy these pointers into registers if possible */
43
973k
  register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit;
44
973k
  register int *Crrtab = cconvert->Cr_r_tab;
45
973k
  register int *Cbbtab = cconvert->Cb_b_tab;
46
973k
  register JLONG *Crgtab = cconvert->Cr_g_tab;
47
973k
  register JLONG *Cbgtab = cconvert->Cb_g_tab;
48
973k
  SHIFT_TEMPS
49
50
3.46M
  while (--num_rows >= 0) {
51
2.49M
    inptr0 = input_buf[0][input_row];
52
2.49M
    inptr1 = input_buf[1][input_row];
53
2.49M
    inptr2 = input_buf[2][input_row];
54
2.49M
    input_row++;
55
2.49M
    outptr = *output_buf++;
56
57.3M
    for (col = 0; col < num_cols; col++) {
57
54.9M
      y  = inptr0[col];
58
54.9M
      cb = inptr1[col];
59
54.9M
      cr = inptr2[col];
60
      /* Range-limiting is essential due to noise introduced by DCT losses. */
61
54.9M
      outptr[RGB_RED] =   range_limit[y + Crrtab[cr]];
62
54.9M
      outptr[RGB_GREEN] = range_limit[y +
63
54.9M
                              ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
64
54.9M
                                                SCALEBITS))];
65
54.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.3M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
70
#endif
71
54.9M
      outptr += RGB_PIXELSIZE;
72
54.9M
    }
73
2.49M
  }
74
#else
75
  ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
76
#endif
77
973k
}
jdcolor.c:ycc_extrgb_convert_internal
Line
Count
Source
34
581k
{
35
581k
#if BITS_IN_JSAMPLE != 16
36
581k
  my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
37
581k
  register int y, cb, cr;
38
581k
  register _JSAMPROW outptr;
39
581k
  register _JSAMPROW inptr0, inptr1, inptr2;
40
581k
  register JDIMENSION col;
41
581k
  JDIMENSION num_cols = cinfo->output_width;
42
  /* copy these pointers into registers if possible */
43
581k
  register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit;
44
581k
  register int *Crrtab = cconvert->Cr_r_tab;
45
581k
  register int *Cbbtab = cconvert->Cb_b_tab;
46
581k
  register JLONG *Crgtab = cconvert->Cr_g_tab;
47
581k
  register JLONG *Cbgtab = cconvert->Cb_g_tab;
48
581k
  SHIFT_TEMPS
49
50
2.13M
  while (--num_rows >= 0) {
51
1.55M
    inptr0 = input_buf[0][input_row];
52
1.55M
    inptr1 = input_buf[1][input_row];
53
1.55M
    inptr2 = input_buf[2][input_row];
54
1.55M
    input_row++;
55
1.55M
    outptr = *output_buf++;
56
43.1M
    for (col = 0; col < num_cols; col++) {
57
41.5M
      y  = inptr0[col];
58
41.5M
      cb = inptr1[col];
59
41.5M
      cr = inptr2[col];
60
      /* Range-limiting is essential due to noise introduced by DCT losses. */
61
41.5M
      outptr[RGB_RED] =   range_limit[y + Crrtab[cr]];
62
41.5M
      outptr[RGB_GREEN] = range_limit[y +
63
41.5M
                              ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
64
41.5M
                                                SCALEBITS))];
65
41.5M
      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
41.5M
      outptr += RGB_PIXELSIZE;
72
41.5M
    }
73
1.55M
  }
74
#else
75
  ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
76
#endif
77
581k
}
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
392k
{
35
392k
#if BITS_IN_JSAMPLE != 16
36
392k
  my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
37
392k
  register int y, cb, cr;
38
392k
  register _JSAMPROW outptr;
39
392k
  register _JSAMPROW inptr0, inptr1, inptr2;
40
392k
  register JDIMENSION col;
41
392k
  JDIMENSION num_cols = cinfo->output_width;
42
  /* copy these pointers into registers if possible */
43
392k
  register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit;
44
392k
  register int *Crrtab = cconvert->Cr_r_tab;
45
392k
  register int *Cbbtab = cconvert->Cb_b_tab;
46
392k
  register JLONG *Crgtab = cconvert->Cr_g_tab;
47
392k
  register JLONG *Cbgtab = cconvert->Cb_g_tab;
48
392k
  SHIFT_TEMPS
49
50
1.33M
  while (--num_rows >= 0) {
51
939k
    inptr0 = input_buf[0][input_row];
52
939k
    inptr1 = input_buf[1][input_row];
53
939k
    inptr2 = input_buf[2][input_row];
54
939k
    input_row++;
55
939k
    outptr = *output_buf++;
56
14.2M
    for (col = 0; col < num_cols; col++) {
57
13.3M
      y  = inptr0[col];
58
13.3M
      cb = inptr1[col];
59
13.3M
      cr = inptr2[col];
60
      /* Range-limiting is essential due to noise introduced by DCT losses. */
61
13.3M
      outptr[RGB_RED] =   range_limit[y + Crrtab[cr]];
62
13.3M
      outptr[RGB_GREEN] = range_limit[y +
63
13.3M
                              ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
64
13.3M
                                                SCALEBITS))];
65
13.3M
      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.3M
#ifdef RGB_ALPHA
69
13.3M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
70
13.3M
#endif
71
13.3M
      outptr += RGB_PIXELSIZE;
72
13.3M
    }
73
939k
  }
74
#else
75
  ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
76
#endif
77
392k
}
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.7M
{
92
10.7M
  register _JSAMPROW inptr, outptr;
93
10.7M
  register JDIMENSION col;
94
10.7M
  JDIMENSION num_cols = cinfo->output_width;
95
96
30.7M
  while (--num_rows >= 0) {
97
19.9M
    inptr = input_buf[0][input_row++];
98
19.9M
    outptr = *output_buf++;
99
1.00G
    for (col = 0; col < num_cols; col++) {
100
984M
      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
204M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
105
#endif
106
984M
      outptr += RGB_PIXELSIZE;
107
984M
    }
108
19.9M
  }
109
10.7M
}
jdcolor.c:gray_extrgb_convert_internal
Line
Count
Source
91
5.54M
{
92
5.54M
  register _JSAMPROW inptr, outptr;
93
5.54M
  register JDIMENSION col;
94
5.54M
  JDIMENSION num_cols = cinfo->output_width;
95
96
17.2M
  while (--num_rows >= 0) {
97
11.7M
    inptr = input_buf[0][input_row++];
98
11.7M
    outptr = *output_buf++;
99
767M
    for (col = 0; col < num_cols; col++) {
100
756M
      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
756M
      outptr += RGB_PIXELSIZE;
107
756M
    }
108
11.7M
  }
109
5.54M
}
Unexecuted instantiation: jdcolor.c:gray_extrgbx_convert_internal
jdcolor.c:gray_extbgr_convert_internal
Line
Count
Source
91
1.40M
{
92
1.40M
  register _JSAMPROW inptr, outptr;
93
1.40M
  register JDIMENSION col;
94
1.40M
  JDIMENSION num_cols = cinfo->output_width;
95
96
2.80M
  while (--num_rows >= 0) {
97
1.40M
    inptr = input_buf[0][input_row++];
98
1.40M
    outptr = *output_buf++;
99
25.1M
    for (col = 0; col < num_cols; col++) {
100
23.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
#ifdef RGB_ALPHA
104
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
105
#endif
106
23.7M
      outptr += RGB_PIXELSIZE;
107
23.7M
    }
108
1.40M
  }
109
1.40M
}
jdcolor.c:gray_extbgrx_convert_internal
Line
Count
Source
91
2.74M
{
92
2.74M
  register _JSAMPROW inptr, outptr;
93
2.74M
  register JDIMENSION col;
94
2.74M
  JDIMENSION num_cols = cinfo->output_width;
95
96
8.53M
  while (--num_rows >= 0) {
97
5.78M
    inptr = input_buf[0][input_row++];
98
5.78M
    outptr = *output_buf++;
99
196M
    for (col = 0; col < num_cols; col++) {
100
190M
      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
190M
#ifdef RGB_ALPHA
104
190M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
105
190M
#endif
106
190M
      outptr += RGB_PIXELSIZE;
107
190M
    }
108
5.78M
  }
109
2.74M
}
Unexecuted instantiation: jdcolor.c:gray_extxbgr_convert_internal
jdcolor.c:gray_extxrgb_convert_internal
Line
Count
Source
91
1.05M
{
92
1.05M
  register _JSAMPROW inptr, outptr;
93
1.05M
  register JDIMENSION col;
94
1.05M
  JDIMENSION num_cols = cinfo->output_width;
95
96
2.10M
  while (--num_rows >= 0) {
97
1.05M
    inptr = input_buf[0][input_row++];
98
1.05M
    outptr = *output_buf++;
99
15.1M
    for (col = 0; col < num_cols; col++) {
100
14.0M
      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
14.0M
#ifdef RGB_ALPHA
104
14.0M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
105
14.0M
#endif
106
14.0M
      outptr += RGB_PIXELSIZE;
107
14.0M
    }
108
1.05M
  }
109
1.05M
}
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
948k
{
122
948k
  register _JSAMPROW inptr0, inptr1, inptr2;
123
948k
  register _JSAMPROW outptr;
124
948k
  register JDIMENSION col;
125
948k
  JDIMENSION num_cols = cinfo->output_width;
126
127
2.73M
  while (--num_rows >= 0) {
128
1.78M
    inptr0 = input_buf[0][input_row];
129
1.78M
    inptr1 = input_buf[1][input_row];
130
1.78M
    inptr2 = input_buf[2][input_row];
131
1.78M
    input_row++;
132
1.78M
    outptr = *output_buf++;
133
45.1M
    for (col = 0; col < num_cols; col++) {
134
43.4M
      outptr[RGB_RED] = inptr0[col];
135
43.4M
      outptr[RGB_GREEN] = inptr1[col];
136
43.4M
      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
36.6M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
141
#endif
142
43.4M
      outptr += RGB_PIXELSIZE;
143
43.4M
    }
144
1.78M
  }
145
948k
}
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.84M
    for (col = 0; col < num_cols; col++) {
134
6.77M
      outptr[RGB_RED] = inptr0[col];
135
6.77M
      outptr[RGB_GREEN] = inptr1[col];
136
6.77M
      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.77M
      outptr += RGB_PIXELSIZE;
143
6.77M
    }
144
69.3k
  }
145
68.2k
}
jdcolor.c:rgb_extbgrx_convert_internal
Line
Count
Source
121
829k
{
122
829k
  register _JSAMPROW inptr0, inptr1, inptr2;
123
829k
  register _JSAMPROW outptr;
124
829k
  register JDIMENSION col;
125
829k
  JDIMENSION num_cols = cinfo->output_width;
126
127
2.49M
  while (--num_rows >= 0) {
128
1.66M
    inptr0 = input_buf[0][input_row];
129
1.66M
    inptr1 = input_buf[1][input_row];
130
1.66M
    inptr2 = input_buf[2][input_row];
131
1.66M
    input_row++;
132
1.66M
    outptr = *output_buf++;
133
34.3M
    for (col = 0; col < num_cols; col++) {
134
32.6M
      outptr[RGB_RED] = inptr0[col];
135
32.6M
      outptr[RGB_GREEN] = inptr1[col];
136
32.6M
      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.6M
#ifdef RGB_ALPHA
140
32.6M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
141
32.6M
#endif
142
32.6M
      outptr += RGB_PIXELSIZE;
143
32.6M
    }
144
1.66M
  }
145
829k
}
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
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.04M
    for (col = 0; col < num_cols; col++) {
134
3.99M
      outptr[RGB_RED] = inptr0[col];
135
3.99M
      outptr[RGB_GREEN] = inptr1[col];
136
3.99M
      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.99M
#ifdef RGB_ALPHA
140
3.99M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
141
3.99M
#endif
142
3.99M
      outptr += RGB_PIXELSIZE;
143
3.99M
    }
144
52.0k
  }
145
51.1k
}
Unexecuted instantiation: jdcolor.c:rgb_rgb_convert_internal