Coverage Report

Created: 2026-03-12 08:02

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.30M
{
35
1.30M
#if BITS_IN_JSAMPLE != 16
36
1.30M
  my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
37
1.30M
  register int y, cb, cr;
38
1.30M
  register _JSAMPROW outptr;
39
1.30M
  register _JSAMPROW inptr0, inptr1, inptr2;
40
1.30M
  register JDIMENSION col;
41
1.30M
  JDIMENSION num_cols = cinfo->output_width;
42
  /* copy these pointers into registers if possible */
43
1.30M
  register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit;
44
1.30M
  register int *Crrtab = cconvert->Cr_r_tab;
45
1.30M
  register int *Cbbtab = cconvert->Cb_b_tab;
46
1.30M
  register JLONG *Crgtab = cconvert->Cr_g_tab;
47
1.30M
  register JLONG *Cbgtab = cconvert->Cb_g_tab;
48
1.30M
  SHIFT_TEMPS
49
50
4.41M
  while (--num_rows >= 0) {
51
3.11M
    inptr0 = input_buf[0][input_row];
52
3.11M
    inptr1 = input_buf[1][input_row];
53
3.11M
    inptr2 = input_buf[2][input_row];
54
3.11M
    input_row++;
55
3.11M
    outptr = *output_buf++;
56
60.6M
    for (col = 0; col < num_cols; col++) {
57
57.5M
      y  = inptr0[col];
58
57.5M
      cb = inptr1[col];
59
57.5M
      cr = inptr2[col];
60
      /* Range-limiting is essential due to noise introduced by DCT losses. */
61
57.5M
      outptr[RGB_RED] =   range_limit[y + Crrtab[cr]];
62
57.5M
      outptr[RGB_GREEN] = range_limit[y +
63
57.5M
                              ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
64
57.5M
                                                SCALEBITS))];
65
57.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
14.0M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
70
#endif
71
57.5M
      outptr += RGB_PIXELSIZE;
72
57.5M
    }
73
3.11M
  }
74
#else
75
  ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
76
#endif
77
1.30M
}
jdcolor.c:ycc_extrgb_convert_internal
Line
Count
Source
34
801k
{
35
801k
#if BITS_IN_JSAMPLE != 16
36
801k
  my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
37
801k
  register int y, cb, cr;
38
801k
  register _JSAMPROW outptr;
39
801k
  register _JSAMPROW inptr0, inptr1, inptr2;
40
801k
  register JDIMENSION col;
41
801k
  JDIMENSION num_cols = cinfo->output_width;
42
  /* copy these pointers into registers if possible */
43
801k
  register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit;
44
801k
  register int *Crrtab = cconvert->Cr_r_tab;
45
801k
  register int *Cbbtab = cconvert->Cb_b_tab;
46
801k
  register JLONG *Crgtab = cconvert->Cr_g_tab;
47
801k
  register JLONG *Cbgtab = cconvert->Cb_g_tab;
48
801k
  SHIFT_TEMPS
49
50
2.77M
  while (--num_rows >= 0) {
51
1.97M
    inptr0 = input_buf[0][input_row];
52
1.97M
    inptr1 = input_buf[1][input_row];
53
1.97M
    inptr2 = input_buf[2][input_row];
54
1.97M
    input_row++;
55
1.97M
    outptr = *output_buf++;
56
45.5M
    for (col = 0; col < num_cols; col++) {
57
43.5M
      y  = inptr0[col];
58
43.5M
      cb = inptr1[col];
59
43.5M
      cr = inptr2[col];
60
      /* Range-limiting is essential due to noise introduced by DCT losses. */
61
43.5M
      outptr[RGB_RED] =   range_limit[y + Crrtab[cr]];
62
43.5M
      outptr[RGB_GREEN] = range_limit[y +
63
43.5M
                              ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
64
43.5M
                                                SCALEBITS))];
65
43.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
43.5M
      outptr += RGB_PIXELSIZE;
72
43.5M
    }
73
1.97M
  }
74
#else
75
  ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
76
#endif
77
801k
}
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
498k
{
35
498k
#if BITS_IN_JSAMPLE != 16
36
498k
  my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
37
498k
  register int y, cb, cr;
38
498k
  register _JSAMPROW outptr;
39
498k
  register _JSAMPROW inptr0, inptr1, inptr2;
40
498k
  register JDIMENSION col;
41
498k
  JDIMENSION num_cols = cinfo->output_width;
42
  /* copy these pointers into registers if possible */
43
498k
  register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit;
44
498k
  register int *Crrtab = cconvert->Cr_r_tab;
45
498k
  register int *Cbbtab = cconvert->Cb_b_tab;
46
498k
  register JLONG *Crgtab = cconvert->Cr_g_tab;
47
498k
  register JLONG *Cbgtab = cconvert->Cb_g_tab;
48
498k
  SHIFT_TEMPS
49
50
1.64M
  while (--num_rows >= 0) {
51
1.14M
    inptr0 = input_buf[0][input_row];
52
1.14M
    inptr1 = input_buf[1][input_row];
53
1.14M
    inptr2 = input_buf[2][input_row];
54
1.14M
    input_row++;
55
1.14M
    outptr = *output_buf++;
56
15.1M
    for (col = 0; col < num_cols; col++) {
57
14.0M
      y  = inptr0[col];
58
14.0M
      cb = inptr1[col];
59
14.0M
      cr = inptr2[col];
60
      /* Range-limiting is essential due to noise introduced by DCT losses. */
61
14.0M
      outptr[RGB_RED] =   range_limit[y + Crrtab[cr]];
62
14.0M
      outptr[RGB_GREEN] = range_limit[y +
63
14.0M
                              ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
64
14.0M
                                                SCALEBITS))];
65
14.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
14.0M
#ifdef RGB_ALPHA
69
14.0M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
70
14.0M
#endif
71
14.0M
      outptr += RGB_PIXELSIZE;
72
14.0M
    }
73
1.14M
  }
74
#else
75
  ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
76
#endif
77
498k
}
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.8M
  while (--num_rows >= 0) {
97
19.5M
    inptr = input_buf[0][input_row++];
98
19.5M
    outptr = *output_buf++;
99
923M
    for (col = 0; col < num_cols; col++) {
100
904M
      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
189M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
105
#endif
106
904M
      outptr += RGB_PIXELSIZE;
107
904M
    }
108
19.5M
  }
109
10.3M
}
jdcolor.c:gray_extrgb_convert_internal
Line
Count
Source
91
5.46M
{
92
5.46M
  register _JSAMPROW inptr, outptr;
93
5.46M
  register JDIMENSION col;
94
5.46M
  JDIMENSION num_cols = cinfo->output_width;
95
96
17.1M
  while (--num_rows >= 0) {
97
11.6M
    inptr = input_buf[0][input_row++];
98
11.6M
    outptr = *output_buf++;
99
701M
    for (col = 0; col < num_cols; col++) {
100
689M
      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
689M
      outptr += RGB_PIXELSIZE;
107
689M
    }
108
11.6M
  }
109
5.46M
}
Unexecuted instantiation: jdcolor.c:gray_extrgbx_convert_internal
jdcolor.c:gray_extbgr_convert_internal
Line
Count
Source
91
1.22M
{
92
1.22M
  register _JSAMPROW inptr, outptr;
93
1.22M
  register JDIMENSION col;
94
1.22M
  JDIMENSION num_cols = cinfo->output_width;
95
96
2.45M
  while (--num_rows >= 0) {
97
1.22M
    inptr = input_buf[0][input_row++];
98
1.22M
    outptr = *output_buf++;
99
25.9M
    for (col = 0; col < num_cols; col++) {
100
24.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
24.6M
      outptr += RGB_PIXELSIZE;
107
24.6M
    }
108
1.22M
  }
109
1.22M
}
jdcolor.c:gray_extbgrx_convert_internal
Line
Count
Source
91
2.70M
{
92
2.70M
  register _JSAMPROW inptr, outptr;
93
2.70M
  register JDIMENSION col;
94
2.70M
  JDIMENSION num_cols = cinfo->output_width;
95
96
8.45M
  while (--num_rows >= 0) {
97
5.74M
    inptr = input_buf[0][input_row++];
98
5.74M
    outptr = *output_buf++;
99
180M
    for (col = 0; col < num_cols; col++) {
100
174M
      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
174M
#ifdef RGB_ALPHA
104
174M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
105
174M
#endif
106
174M
      outptr += RGB_PIXELSIZE;
107
174M
    }
108
5.74M
  }
109
2.70M
}
Unexecuted instantiation: jdcolor.c:gray_extxbgr_convert_internal
jdcolor.c:gray_extxrgb_convert_internal
Line
Count
Source
91
921k
{
92
921k
  register _JSAMPROW inptr, outptr;
93
921k
  register JDIMENSION col;
94
921k
  JDIMENSION num_cols = cinfo->output_width;
95
96
1.84M
  while (--num_rows >= 0) {
97
921k
    inptr = input_buf[0][input_row++];
98
921k
    outptr = *output_buf++;
99
15.5M
    for (col = 0; col < num_cols; col++) {
100
14.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
14.6M
#ifdef RGB_ALPHA
104
14.6M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
105
14.6M
#endif
106
14.6M
      outptr += RGB_PIXELSIZE;
107
14.6M
    }
108
921k
  }
109
921k
}
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
918k
{
122
918k
  register _JSAMPROW inptr0, inptr1, inptr2;
123
918k
  register _JSAMPROW outptr;
124
918k
  register JDIMENSION col;
125
918k
  JDIMENSION num_cols = cinfo->output_width;
126
127
2.51M
  while (--num_rows >= 0) {
128
1.59M
    inptr0 = input_buf[0][input_row];
129
1.59M
    inptr1 = input_buf[1][input_row];
130
1.59M
    inptr2 = input_buf[2][input_row];
131
1.59M
    input_row++;
132
1.59M
    outptr = *output_buf++;
133
40.2M
    for (col = 0; col < num_cols; col++) {
134
38.6M
      outptr[RGB_RED] = inptr0[col];
135
38.6M
      outptr[RGB_GREEN] = inptr1[col];
136
38.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
#ifdef RGB_ALPHA
140
32.6M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
141
#endif
142
38.6M
      outptr += RGB_PIXELSIZE;
143
38.6M
    }
144
1.59M
  }
145
918k
}
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.6k
{
122
67.6k
  register _JSAMPROW inptr0, inptr1, inptr2;
123
67.6k
  register _JSAMPROW outptr;
124
67.6k
  register JDIMENSION col;
125
67.6k
  JDIMENSION num_cols = cinfo->output_width;
126
127
135k
  while (--num_rows >= 0) {
128
68.1k
    inptr0 = input_buf[0][input_row];
129
68.1k
    inptr1 = input_buf[1][input_row];
130
68.1k
    inptr2 = input_buf[2][input_row];
131
68.1k
    input_row++;
132
68.1k
    outptr = *output_buf++;
133
6.00M
    for (col = 0; col < num_cols; col++) {
134
5.93M
      outptr[RGB_RED] = inptr0[col];
135
5.93M
      outptr[RGB_GREEN] = inptr1[col];
136
5.93M
      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
5.93M
      outptr += RGB_PIXELSIZE;
143
5.93M
    }
144
68.1k
  }
145
67.6k
}
jdcolor.c:rgb_extbgrx_convert_internal
Line
Count
Source
121
799k
{
122
799k
  register _JSAMPROW inptr0, inptr1, inptr2;
123
799k
  register _JSAMPROW outptr;
124
799k
  register JDIMENSION col;
125
799k
  JDIMENSION num_cols = cinfo->output_width;
126
127
2.27M
  while (--num_rows >= 0) {
128
1.47M
    inptr0 = input_buf[0][input_row];
129
1.47M
    inptr1 = input_buf[1][input_row];
130
1.47M
    inptr2 = input_buf[2][input_row];
131
1.47M
    input_row++;
132
1.47M
    outptr = *output_buf++;
133
30.6M
    for (col = 0; col < num_cols; col++) {
134
29.2M
      outptr[RGB_RED] = inptr0[col];
135
29.2M
      outptr[RGB_GREEN] = inptr1[col];
136
29.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
29.2M
#ifdef RGB_ALPHA
140
29.2M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
141
29.2M
#endif
142
29.2M
      outptr += RGB_PIXELSIZE;
143
29.2M
    }
144
1.47M
  }
145
799k
}
Unexecuted instantiation: jdcolor.c:rgb_extxbgr_convert_internal
jdcolor.c:rgb_extxrgb_convert_internal
Line
Count
Source
121
50.7k
{
122
50.7k
  register _JSAMPROW inptr0, inptr1, inptr2;
123
50.7k
  register _JSAMPROW outptr;
124
50.7k
  register JDIMENSION col;
125
50.7k
  JDIMENSION num_cols = cinfo->output_width;
126
127
101k
  while (--num_rows >= 0) {
128
51.1k
    inptr0 = input_buf[0][input_row];
129
51.1k
    inptr1 = input_buf[1][input_row];
130
51.1k
    inptr2 = input_buf[2][input_row];
131
51.1k
    input_row++;
132
51.1k
    outptr = *output_buf++;
133
3.52M
    for (col = 0; col < num_cols; col++) {
134
3.46M
      outptr[RGB_RED] = inptr0[col];
135
3.46M
      outptr[RGB_GREEN] = inptr1[col];
136
3.46M
      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.46M
#ifdef RGB_ALPHA
140
3.46M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
141
3.46M
#endif
142
3.46M
      outptr += RGB_PIXELSIZE;
143
3.46M
    }
144
51.1k
  }
145
50.7k
}
Unexecuted instantiation: jdcolor.c:rgb_rgb_convert_internal