Coverage Report

Created: 2025-11-11 06:32

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.06M
{
35
1.06M
#if BITS_IN_JSAMPLE != 16
36
1.06M
  my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
37
1.06M
  register int y, cb, cr;
38
1.06M
  register _JSAMPROW outptr;
39
1.06M
  register _JSAMPROW inptr0, inptr1, inptr2;
40
1.06M
  register JDIMENSION col;
41
1.06M
  JDIMENSION num_cols = cinfo->output_width;
42
  /* copy these pointers into registers if possible */
43
1.06M
  register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit;
44
1.06M
  register int *Crrtab = cconvert->Cr_r_tab;
45
1.06M
  register int *Cbbtab = cconvert->Cb_b_tab;
46
1.06M
  register JLONG *Crgtab = cconvert->Cr_g_tab;
47
1.06M
  register JLONG *Cbgtab = cconvert->Cb_g_tab;
48
1.06M
  SHIFT_TEMPS
49
50
3.22M
  while (--num_rows >= 0) {
51
2.16M
    inptr0 = input_buf[0][input_row];
52
2.16M
    inptr1 = input_buf[1][input_row];
53
2.16M
    inptr2 = input_buf[2][input_row];
54
2.16M
    input_row++;
55
2.16M
    outptr = *output_buf++;
56
97.2M
    for (col = 0; col < num_cols; col++) {
57
95.0M
      y  = inptr0[col];
58
95.0M
      cb = inptr1[col];
59
95.0M
      cr = inptr2[col];
60
      /* Range-limiting is essential due to noise introduced by DCT losses. */
61
95.0M
      outptr[RGB_RED] =   range_limit[y + Crrtab[cr]];
62
95.0M
      outptr[RGB_GREEN] = range_limit[y +
63
95.0M
                              ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
64
95.0M
                                                SCALEBITS))];
65
95.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.3M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
70
#endif
71
95.0M
      outptr += RGB_PIXELSIZE;
72
95.0M
    }
73
2.16M
  }
74
#else
75
  ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
76
#endif
77
1.06M
}
jdcolor.c:ycc_extrgb_convert_internal
Line
Count
Source
34
1.02M
{
35
1.02M
#if BITS_IN_JSAMPLE != 16
36
1.02M
  my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
37
1.02M
  register int y, cb, cr;
38
1.02M
  register _JSAMPROW outptr;
39
1.02M
  register _JSAMPROW inptr0, inptr1, inptr2;
40
1.02M
  register JDIMENSION col;
41
1.02M
  JDIMENSION num_cols = cinfo->output_width;
42
  /* copy these pointers into registers if possible */
43
1.02M
  register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit;
44
1.02M
  register int *Crrtab = cconvert->Cr_r_tab;
45
1.02M
  register int *Cbbtab = cconvert->Cb_b_tab;
46
1.02M
  register JLONG *Crgtab = cconvert->Cr_g_tab;
47
1.02M
  register JLONG *Cbgtab = cconvert->Cb_g_tab;
48
1.02M
  SHIFT_TEMPS
49
50
3.08M
  while (--num_rows >= 0) {
51
2.06M
    inptr0 = input_buf[0][input_row];
52
2.06M
    inptr1 = input_buf[1][input_row];
53
2.06M
    inptr2 = input_buf[2][input_row];
54
2.06M
    input_row++;
55
2.06M
    outptr = *output_buf++;
56
84.8M
    for (col = 0; col < num_cols; col++) {
57
82.7M
      y  = inptr0[col];
58
82.7M
      cb = inptr1[col];
59
82.7M
      cr = inptr2[col];
60
      /* Range-limiting is essential due to noise introduced by DCT losses. */
61
82.7M
      outptr[RGB_RED] =   range_limit[y + Crrtab[cr]];
62
82.7M
      outptr[RGB_GREEN] = range_limit[y +
63
82.7M
                              ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
64
82.7M
                                                SCALEBITS))];
65
82.7M
      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
82.7M
      outptr += RGB_PIXELSIZE;
72
82.7M
    }
73
2.06M
  }
74
#else
75
  ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
76
#endif
77
1.02M
}
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.4M
    for (col = 0; col < num_cols; col++) {
57
12.3M
      y  = inptr0[col];
58
12.3M
      cb = inptr1[col];
59
12.3M
      cr = inptr2[col];
60
      /* Range-limiting is essential due to noise introduced by DCT losses. */
61
12.3M
      outptr[RGB_RED] =   range_limit[y + Crrtab[cr]];
62
12.3M
      outptr[RGB_GREEN] = range_limit[y +
63
12.3M
                              ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
64
12.3M
                                                SCALEBITS))];
65
12.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
12.3M
#ifdef RGB_ALPHA
69
12.3M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
70
12.3M
#endif
71
12.3M
      outptr += RGB_PIXELSIZE;
72
12.3M
    }
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.75M
{
92
8.75M
  register _JSAMPROW inptr, outptr;
93
8.75M
  register JDIMENSION col;
94
8.75M
  JDIMENSION num_cols = cinfo->output_width;
95
96
24.4M
  while (--num_rows >= 0) {
97
15.6M
    inptr = input_buf[0][input_row++];
98
15.6M
    outptr = *output_buf++;
99
785M
    for (col = 0; col < num_cols; col++) {
100
770M
      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
54.1M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
105
#endif
106
770M
      outptr += RGB_PIXELSIZE;
107
770M
    }
108
15.6M
  }
109
8.75M
}
jdcolor.c:gray_extrgb_convert_internal
Line
Count
Source
91
5.42M
{
92
5.42M
  register _JSAMPROW inptr, outptr;
93
5.42M
  register JDIMENSION col;
94
5.42M
  JDIMENSION num_cols = cinfo->output_width;
95
96
17.3M
  while (--num_rows >= 0) {
97
11.9M
    inptr = input_buf[0][input_row++];
98
11.9M
    outptr = *output_buf++;
99
687M
    for (col = 0; col < num_cols; col++) {
100
675M
      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
675M
      outptr += RGB_PIXELSIZE;
107
675M
    }
108
11.9M
  }
109
5.42M
}
Unexecuted instantiation: jdcolor.c:gray_extrgbx_convert_internal
jdcolor.c:gray_extbgr_convert_internal
Line
Count
Source
91
1.72M
{
92
1.72M
  register _JSAMPROW inptr, outptr;
93
1.72M
  register JDIMENSION col;
94
1.72M
  JDIMENSION num_cols = cinfo->output_width;
95
96
3.44M
  while (--num_rows >= 0) {
97
1.72M
    inptr = input_buf[0][input_row++];
98
1.72M
    outptr = *output_buf++;
99
42.5M
    for (col = 0; col < num_cols; col++) {
100
40.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
#ifdef RGB_ALPHA
104
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
105
#endif
106
40.8M
      outptr += RGB_PIXELSIZE;
107
40.8M
    }
108
1.72M
  }
109
1.72M
}
jdcolor.c:gray_extbgrx_convert_internal
Line
Count
Source
91
314k
{
92
314k
  register _JSAMPROW inptr, outptr;
93
314k
  register JDIMENSION col;
94
314k
  JDIMENSION num_cols = cinfo->output_width;
95
96
992k
  while (--num_rows >= 0) {
97
677k
    inptr = input_buf[0][input_row++];
98
677k
    outptr = *output_buf++;
99
30.8M
    for (col = 0; col < num_cols; col++) {
100
30.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
30.1M
#ifdef RGB_ALPHA
104
30.1M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
105
30.1M
#endif
106
30.1M
      outptr += RGB_PIXELSIZE;
107
30.1M
    }
108
677k
  }
109
314k
}
Unexecuted instantiation: jdcolor.c:gray_extxbgr_convert_internal
jdcolor.c:gray_extxrgb_convert_internal
Line
Count
Source
91
1.29M
{
92
1.29M
  register _JSAMPROW inptr, outptr;
93
1.29M
  register JDIMENSION col;
94
1.29M
  JDIMENSION num_cols = cinfo->output_width;
95
96
2.58M
  while (--num_rows >= 0) {
97
1.29M
    inptr = input_buf[0][input_row++];
98
1.29M
    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.29M
  }
109
1.29M
}
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
430k
  while (--num_rows >= 0) {
128
245k
    inptr0 = input_buf[0][input_row];
129
245k
    inptr1 = input_buf[1][input_row];
130
245k
    inptr2 = input_buf[2][input_row];
131
245k
    input_row++;
132
245k
    outptr = *output_buf++;
133
16.0M
    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.20M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
141
#endif
142
15.7M
      outptr += RGB_PIXELSIZE;
143
15.7M
    }
144
245k
  }
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.63M
    for (col = 0; col < num_cols; col++) {
134
7.56M
      outptr[RGB_RED] = inptr0[col];
135
7.56M
      outptr[RGB_GREEN] = inptr1[col];
136
7.56M
      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.56M
      outptr += RGB_PIXELSIZE;
143
7.56M
    }
144
68.6k
  }
145
68.1k
}
jdcolor.c:rgb_extbgrx_convert_internal
Line
Count
Source
121
66.2k
{
122
66.2k
  register _JSAMPROW inptr0, inptr1, inptr2;
123
66.2k
  register _JSAMPROW outptr;
124
66.2k
  register JDIMENSION col;
125
66.2k
  JDIMENSION num_cols = cinfo->output_width;
126
127
191k
  while (--num_rows >= 0) {
128
125k
    inptr0 = input_buf[0][input_row];
129
125k
    inptr1 = input_buf[1][input_row];
130
125k
    inptr2 = input_buf[2][input_row];
131
125k
    input_row++;
132
125k
    outptr = *output_buf++;
133
3.90M
    for (col = 0; col < num_cols; col++) {
134
3.77M
      outptr[RGB_RED] = inptr0[col];
135
3.77M
      outptr[RGB_GREEN] = inptr1[col];
136
3.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
3.77M
#ifdef RGB_ALPHA
140
3.77M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
141
3.77M
#endif
142
3.77M
      outptr += RGB_PIXELSIZE;
143
3.77M
    }
144
125k
  }
145
66.2k
}
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.4k
    inptr0 = input_buf[0][input_row];
129
51.4k
    inptr1 = input_buf[1][input_row];
130
51.4k
    inptr2 = input_buf[2][input_row];
131
51.4k
    input_row++;
132
51.4k
    outptr = *output_buf++;
133
4.47M
    for (col = 0; col < num_cols; col++) {
134
4.42M
      outptr[RGB_RED] = inptr0[col];
135
4.42M
      outptr[RGB_GREEN] = inptr1[col];
136
4.42M
      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.42M
#ifdef RGB_ALPHA
140
4.42M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
141
4.42M
#endif
142
4.42M
      outptr += RGB_PIXELSIZE;
143
4.42M
    }
144
51.4k
  }
145
51.1k
}
Unexecuted instantiation: jdcolor.c:rgb_rgb_convert_internal