Coverage Report

Created: 2026-05-30 07:16

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
888k
{
35
888k
#if BITS_IN_JSAMPLE != 16
36
888k
  my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
37
888k
  register int y, cb, cr;
38
888k
  register _JSAMPROW outptr;
39
888k
  register _JSAMPROW inptr0, inptr1, inptr2;
40
888k
  register JDIMENSION col;
41
888k
  JDIMENSION num_cols = cinfo->output_width;
42
  /* copy these pointers into registers if possible */
43
888k
  register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit;
44
888k
  register int *Crrtab = cconvert->Cr_r_tab;
45
888k
  register int *Cbbtab = cconvert->Cb_b_tab;
46
888k
  register JLONG *Crgtab = cconvert->Cr_g_tab;
47
888k
  register JLONG *Cbgtab = cconvert->Cb_g_tab;
48
888k
  SHIFT_TEMPS
49
50
3.31M
  while (--num_rows >= 0) {
51
2.42M
    inptr0 = input_buf[0][input_row];
52
2.42M
    inptr1 = input_buf[1][input_row];
53
2.42M
    inptr2 = input_buf[2][input_row];
54
2.42M
    input_row++;
55
2.42M
    outptr = *output_buf++;
56
54.4M
    for (col = 0; col < num_cols; col++) {
57
52.0M
      y  = inptr0[col];
58
52.0M
      cb = inptr1[col];
59
52.0M
      cr = inptr2[col];
60
      /* Range-limiting is essential due to noise introduced by DCT losses. */
61
52.0M
      outptr[RGB_RED] =   range_limit[y + Crrtab[cr]];
62
52.0M
      outptr[RGB_GREEN] = range_limit[y +
63
52.0M
                              ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
64
52.0M
                                                SCALEBITS))];
65
52.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.8M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
70
#endif
71
52.0M
      outptr += RGB_PIXELSIZE;
72
52.0M
    }
73
2.42M
  }
74
#else
75
  ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
76
#endif
77
888k
}
jdcolor.c:ycc_extrgb_convert_internal
Line
Count
Source
34
547k
{
35
547k
#if BITS_IN_JSAMPLE != 16
36
547k
  my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
37
547k
  register int y, cb, cr;
38
547k
  register _JSAMPROW outptr;
39
547k
  register _JSAMPROW inptr0, inptr1, inptr2;
40
547k
  register JDIMENSION col;
41
547k
  JDIMENSION num_cols = cinfo->output_width;
42
  /* copy these pointers into registers if possible */
43
547k
  register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit;
44
547k
  register int *Crrtab = cconvert->Cr_r_tab;
45
547k
  register int *Cbbtab = cconvert->Cb_b_tab;
46
547k
  register JLONG *Crgtab = cconvert->Cr_g_tab;
47
547k
  register JLONG *Cbgtab = cconvert->Cb_g_tab;
48
547k
  SHIFT_TEMPS
49
50
2.07M
  while (--num_rows >= 0) {
51
1.52M
    inptr0 = input_buf[0][input_row];
52
1.52M
    inptr1 = input_buf[1][input_row];
53
1.52M
    inptr2 = input_buf[2][input_row];
54
1.52M
    input_row++;
55
1.52M
    outptr = *output_buf++;
56
40.7M
    for (col = 0; col < num_cols; col++) {
57
39.2M
      y  = inptr0[col];
58
39.2M
      cb = inptr1[col];
59
39.2M
      cr = inptr2[col];
60
      /* Range-limiting is essential due to noise introduced by DCT losses. */
61
39.2M
      outptr[RGB_RED] =   range_limit[y + Crrtab[cr]];
62
39.2M
      outptr[RGB_GREEN] = range_limit[y +
63
39.2M
                              ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
64
39.2M
                                                SCALEBITS))];
65
39.2M
      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
39.2M
      outptr += RGB_PIXELSIZE;
72
39.2M
    }
73
1.52M
  }
74
#else
75
  ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
76
#endif
77
547k
}
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
340k
{
35
340k
#if BITS_IN_JSAMPLE != 16
36
340k
  my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
37
340k
  register int y, cb, cr;
38
340k
  register _JSAMPROW outptr;
39
340k
  register _JSAMPROW inptr0, inptr1, inptr2;
40
340k
  register JDIMENSION col;
41
340k
  JDIMENSION num_cols = cinfo->output_width;
42
  /* copy these pointers into registers if possible */
43
340k
  register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit;
44
340k
  register int *Crrtab = cconvert->Cr_r_tab;
45
340k
  register int *Cbbtab = cconvert->Cb_b_tab;
46
340k
  register JLONG *Crgtab = cconvert->Cr_g_tab;
47
340k
  register JLONG *Cbgtab = cconvert->Cb_g_tab;
48
340k
  SHIFT_TEMPS
49
50
1.23M
  while (--num_rows >= 0) {
51
894k
    inptr0 = input_buf[0][input_row];
52
894k
    inptr1 = input_buf[1][input_row];
53
894k
    inptr2 = input_buf[2][input_row];
54
894k
    input_row++;
55
894k
    outptr = *output_buf++;
56
13.7M
    for (col = 0; col < num_cols; col++) {
57
12.8M
      y  = inptr0[col];
58
12.8M
      cb = inptr1[col];
59
12.8M
      cr = inptr2[col];
60
      /* Range-limiting is essential due to noise introduced by DCT losses. */
61
12.8M
      outptr[RGB_RED] =   range_limit[y + Crrtab[cr]];
62
12.8M
      outptr[RGB_GREEN] = range_limit[y +
63
12.8M
                              ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
64
12.8M
                                                SCALEBITS))];
65
12.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
12.8M
#ifdef RGB_ALPHA
69
12.8M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
70
12.8M
#endif
71
12.8M
      outptr += RGB_PIXELSIZE;
72
12.8M
    }
73
894k
  }
74
#else
75
  ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
76
#endif
77
340k
}
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.8M
  while (--num_rows >= 0) {
97
20.6M
    inptr = input_buf[0][input_row++];
98
20.6M
    outptr = *output_buf++;
99
982M
    for (col = 0; col < num_cols; col++) {
100
962M
      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
199M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
105
#endif
106
962M
      outptr += RGB_PIXELSIZE;
107
962M
    }
108
20.6M
  }
109
11.1M
}
jdcolor.c:gray_extrgb_convert_internal
Line
Count
Source
91
5.93M
{
92
5.93M
  register _JSAMPROW inptr, outptr;
93
5.93M
  register JDIMENSION col;
94
5.93M
  JDIMENSION num_cols = cinfo->output_width;
95
96
18.2M
  while (--num_rows >= 0) {
97
12.2M
    inptr = input_buf[0][input_row++];
98
12.2M
    outptr = *output_buf++;
99
753M
    for (col = 0; col < num_cols; col++) {
100
741M
      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
741M
      outptr += RGB_PIXELSIZE;
107
741M
    }
108
12.2M
  }
109
5.93M
}
Unexecuted instantiation: jdcolor.c:gray_extrgbx_convert_internal
jdcolor.c:gray_extbgr_convert_internal
Line
Count
Source
91
1.34M
{
92
1.34M
  register _JSAMPROW inptr, outptr;
93
1.34M
  register JDIMENSION col;
94
1.34M
  JDIMENSION num_cols = cinfo->output_width;
95
96
2.68M
  while (--num_rows >= 0) {
97
1.34M
    inptr = input_buf[0][input_row++];
98
1.34M
    outptr = *output_buf++;
99
22.0M
    for (col = 0; col < num_cols; col++) {
100
20.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
20.6M
      outptr += RGB_PIXELSIZE;
107
20.6M
    }
108
1.34M
  }
109
1.34M
}
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.92M
  while (--num_rows >= 0) {
97
6.00M
    inptr = input_buf[0][input_row++];
98
6.00M
    outptr = *output_buf++;
99
193M
    for (col = 0; col < num_cols; col++) {
100
187M
      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
187M
#ifdef RGB_ALPHA
104
187M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
105
187M
#endif
106
187M
      outptr += RGB_PIXELSIZE;
107
187M
    }
108
6.00M
  }
109
2.92M
}
Unexecuted instantiation: jdcolor.c:gray_extxbgr_convert_internal
jdcolor.c:gray_extxrgb_convert_internal
Line
Count
Source
91
1.00M
{
92
1.00M
  register _JSAMPROW inptr, outptr;
93
1.00M
  register JDIMENSION col;
94
1.00M
  JDIMENSION num_cols = cinfo->output_width;
95
96
2.01M
  while (--num_rows >= 0) {
97
1.00M
    inptr = input_buf[0][input_row++];
98
1.00M
    outptr = *output_buf++;
99
13.2M
    for (col = 0; col < num_cols; col++) {
100
12.2M
      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
12.2M
#ifdef RGB_ALPHA
104
12.2M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
105
12.2M
#endif
106
12.2M
      outptr += RGB_PIXELSIZE;
107
12.2M
    }
108
1.00M
  }
109
1.00M
}
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
898k
{
122
898k
  register _JSAMPROW inptr0, inptr1, inptr2;
123
898k
  register _JSAMPROW outptr;
124
898k
  register JDIMENSION col;
125
898k
  JDIMENSION num_cols = cinfo->output_width;
126
127
2.47M
  while (--num_rows >= 0) {
128
1.58M
    inptr0 = input_buf[0][input_row];
129
1.58M
    inptr1 = input_buf[1][input_row];
130
1.58M
    inptr2 = input_buf[2][input_row];
131
1.58M
    input_row++;
132
1.58M
    outptr = *output_buf++;
133
43.9M
    for (col = 0; col < num_cols; col++) {
134
42.4M
      outptr[RGB_RED] = inptr0[col];
135
42.4M
      outptr[RGB_GREEN] = inptr1[col];
136
42.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.3M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
141
#endif
142
42.4M
      outptr += RGB_PIXELSIZE;
143
42.4M
    }
144
1.58M
  }
145
898k
}
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
67.9k
{
122
67.9k
  register _JSAMPROW inptr0, inptr1, inptr2;
123
67.9k
  register _JSAMPROW outptr;
124
67.9k
  register JDIMENSION col;
125
67.9k
  JDIMENSION num_cols = cinfo->output_width;
126
127
136k
  while (--num_rows >= 0) {
128
68.8k
    inptr0 = input_buf[0][input_row];
129
68.8k
    inptr1 = input_buf[1][input_row];
130
68.8k
    inptr2 = input_buf[2][input_row];
131
68.8k
    input_row++;
132
68.8k
    outptr = *output_buf++;
133
6.12M
    for (col = 0; col < num_cols; col++) {
134
6.05M
      outptr[RGB_RED] = inptr0[col];
135
6.05M
      outptr[RGB_GREEN] = inptr1[col];
136
6.05M
      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.05M
      outptr += RGB_PIXELSIZE;
143
6.05M
    }
144
68.8k
  }
145
67.9k
}
jdcolor.c:rgb_extbgrx_convert_internal
Line
Count
Source
121
779k
{
122
779k
  register _JSAMPROW inptr0, inptr1, inptr2;
123
779k
  register _JSAMPROW outptr;
124
779k
  register JDIMENSION col;
125
779k
  JDIMENSION num_cols = cinfo->output_width;
126
127
2.23M
  while (--num_rows >= 0) {
128
1.46M
    inptr0 = input_buf[0][input_row];
129
1.46M
    inptr1 = input_buf[1][input_row];
130
1.46M
    inptr2 = input_buf[2][input_row];
131
1.46M
    input_row++;
132
1.46M
    outptr = *output_buf++;
133
34.2M
    for (col = 0; col < num_cols; col++) {
134
32.8M
      outptr[RGB_RED] = inptr0[col];
135
32.8M
      outptr[RGB_GREEN] = inptr1[col];
136
32.8M
      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.8M
#ifdef RGB_ALPHA
140
32.8M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
141
32.8M
#endif
142
32.8M
      outptr += RGB_PIXELSIZE;
143
32.8M
    }
144
1.46M
  }
145
779k
}
Unexecuted instantiation: jdcolor.c:rgb_extxbgr_convert_internal
jdcolor.c:rgb_extxrgb_convert_internal
Line
Count
Source
121
50.9k
{
122
50.9k
  register _JSAMPROW inptr0, inptr1, inptr2;
123
50.9k
  register _JSAMPROW outptr;
124
50.9k
  register JDIMENSION col;
125
50.9k
  JDIMENSION num_cols = cinfo->output_width;
126
127
102k
  while (--num_rows >= 0) {
128
51.6k
    inptr0 = input_buf[0][input_row];
129
51.6k
    inptr1 = input_buf[1][input_row];
130
51.6k
    inptr2 = input_buf[2][input_row];
131
51.6k
    input_row++;
132
51.6k
    outptr = *output_buf++;
133
3.60M
    for (col = 0; col < num_cols; col++) {
134
3.55M
      outptr[RGB_RED] = inptr0[col];
135
3.55M
      outptr[RGB_GREEN] = inptr1[col];
136
3.55M
      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.55M
#ifdef RGB_ALPHA
140
3.55M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
141
3.55M
#endif
142
3.55M
      outptr += RGB_PIXELSIZE;
143
3.55M
    }
144
51.6k
  }
145
50.9k
}
Unexecuted instantiation: jdcolor.c:rgb_rgb_convert_internal