Coverage Report

Created: 2026-07-10 11:04

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/work/workdir/UnpackedTarball/libjpeg-turbo/src/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
160M
{
35
160M
#if BITS_IN_JSAMPLE != 16
36
160M
  my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
37
160M
  register int y, cb, cr;
38
160M
  register _JSAMPROW outptr;
39
160M
  register _JSAMPROW inptr0, inptr1, inptr2;
40
160M
  register JDIMENSION col;
41
160M
  JDIMENSION num_cols = cinfo->output_width;
42
  /* copy these pointers into registers if possible */
43
160M
  register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit;
44
160M
  register int *Crrtab = cconvert->Cr_r_tab;
45
160M
  register int *Cbbtab = cconvert->Cb_b_tab;
46
160M
  register JLONG *Crgtab = cconvert->Cr_g_tab;
47
160M
  register JLONG *Cbgtab = cconvert->Cb_g_tab;
48
160M
  SHIFT_TEMPS
49
50
320M
  while (--num_rows >= 0) {
51
160M
    inptr0 = input_buf[0][input_row];
52
160M
    inptr1 = input_buf[1][input_row];
53
160M
    inptr2 = input_buf[2][input_row];
54
160M
    input_row++;
55
160M
    outptr = *output_buf++;
56
1.50G
    for (col = 0; col < num_cols; col++) {
57
1.34G
      y  = inptr0[col];
58
1.34G
      cb = inptr1[col];
59
1.34G
      cr = inptr2[col];
60
      /* Range-limiting is essential due to noise introduced by DCT losses. */
61
1.34G
      outptr[RGB_RED] =   range_limit[y + Crrtab[cr]];
62
1.34G
      outptr[RGB_GREEN] = range_limit[y +
63
1.34G
                              ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
64
1.34G
                                                SCALEBITS))];
65
1.34G
      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
0
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
70
#endif
71
1.34G
      outptr += RGB_PIXELSIZE;
72
1.34G
    }
73
160M
  }
74
#else
75
  ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
76
#endif
77
160M
}
Unexecuted instantiation: jdcolor.c:ycc_extrgb_convert_internal
Unexecuted instantiation: jdcolor.c:ycc_extrgbx_convert_internal
jdcolor.c:ycc_extbgr_convert_internal
Line
Count
Source
34
5.88M
{
35
5.88M
#if BITS_IN_JSAMPLE != 16
36
5.88M
  my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
37
5.88M
  register int y, cb, cr;
38
5.88M
  register _JSAMPROW outptr;
39
5.88M
  register _JSAMPROW inptr0, inptr1, inptr2;
40
5.88M
  register JDIMENSION col;
41
5.88M
  JDIMENSION num_cols = cinfo->output_width;
42
  /* copy these pointers into registers if possible */
43
5.88M
  register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit;
44
5.88M
  register int *Crrtab = cconvert->Cr_r_tab;
45
5.88M
  register int *Cbbtab = cconvert->Cb_b_tab;
46
5.88M
  register JLONG *Crgtab = cconvert->Cr_g_tab;
47
5.88M
  register JLONG *Cbgtab = cconvert->Cb_g_tab;
48
5.88M
  SHIFT_TEMPS
49
50
11.7M
  while (--num_rows >= 0) {
51
5.88M
    inptr0 = input_buf[0][input_row];
52
5.88M
    inptr1 = input_buf[1][input_row];
53
5.88M
    inptr2 = input_buf[2][input_row];
54
5.88M
    input_row++;
55
5.88M
    outptr = *output_buf++;
56
523M
    for (col = 0; col < num_cols; col++) {
57
517M
      y  = inptr0[col];
58
517M
      cb = inptr1[col];
59
517M
      cr = inptr2[col];
60
      /* Range-limiting is essential due to noise introduced by DCT losses. */
61
517M
      outptr[RGB_RED] =   range_limit[y + Crrtab[cr]];
62
517M
      outptr[RGB_GREEN] = range_limit[y +
63
517M
                              ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
64
517M
                                                SCALEBITS))];
65
517M
      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
517M
      outptr += RGB_PIXELSIZE;
72
517M
    }
73
5.88M
  }
74
#else
75
  ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
76
#endif
77
5.88M
}
Unexecuted instantiation: jdcolor.c:ycc_extbgrx_convert_internal
Unexecuted instantiation: jdcolor.c:ycc_extxbgr_convert_internal
Unexecuted instantiation: jdcolor.c:ycc_extxrgb_convert_internal
jdcolor.c:ycc_rgb_convert_internal
Line
Count
Source
34
154M
{
35
154M
#if BITS_IN_JSAMPLE != 16
36
154M
  my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
37
154M
  register int y, cb, cr;
38
154M
  register _JSAMPROW outptr;
39
154M
  register _JSAMPROW inptr0, inptr1, inptr2;
40
154M
  register JDIMENSION col;
41
154M
  JDIMENSION num_cols = cinfo->output_width;
42
  /* copy these pointers into registers if possible */
43
154M
  register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit;
44
154M
  register int *Crrtab = cconvert->Cr_r_tab;
45
154M
  register int *Cbbtab = cconvert->Cb_b_tab;
46
154M
  register JLONG *Crgtab = cconvert->Cr_g_tab;
47
154M
  register JLONG *Cbgtab = cconvert->Cb_g_tab;
48
154M
  SHIFT_TEMPS
49
50
308M
  while (--num_rows >= 0) {
51
154M
    inptr0 = input_buf[0][input_row];
52
154M
    inptr1 = input_buf[1][input_row];
53
154M
    inptr2 = input_buf[2][input_row];
54
154M
    input_row++;
55
154M
    outptr = *output_buf++;
56
977M
    for (col = 0; col < num_cols; col++) {
57
823M
      y  = inptr0[col];
58
823M
      cb = inptr1[col];
59
823M
      cr = inptr2[col];
60
      /* Range-limiting is essential due to noise introduced by DCT losses. */
61
823M
      outptr[RGB_RED] =   range_limit[y + Crrtab[cr]];
62
823M
      outptr[RGB_GREEN] = range_limit[y +
63
823M
                              ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
64
823M
                                                SCALEBITS))];
65
823M
      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
823M
      outptr += RGB_PIXELSIZE;
72
823M
    }
73
154M
  }
74
#else
75
  ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
76
#endif
77
154M
}
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
0
{
92
0
  register _JSAMPROW inptr, outptr;
93
0
  register JDIMENSION col;
94
0
  JDIMENSION num_cols = cinfo->output_width;
95
96
0
  while (--num_rows >= 0) {
97
0
    inptr = input_buf[0][input_row++];
98
0
    outptr = *output_buf++;
99
0
    for (col = 0; col < num_cols; col++) {
100
0
      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
0
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
105
#endif
106
0
      outptr += RGB_PIXELSIZE;
107
0
    }
108
0
  }
109
0
}
Unexecuted instantiation: jdcolor.c:gray_extrgb_convert_internal
Unexecuted instantiation: jdcolor.c:gray_extrgbx_convert_internal
Unexecuted instantiation: jdcolor.c:gray_extbgr_convert_internal
Unexecuted instantiation: jdcolor.c:gray_extbgrx_convert_internal
Unexecuted instantiation: jdcolor.c:gray_extxbgr_convert_internal
Unexecuted instantiation: jdcolor.c:gray_extxrgb_convert_internal
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
1.62M
{
122
1.62M
  register _JSAMPROW inptr0, inptr1, inptr2;
123
1.62M
  register _JSAMPROW outptr;
124
1.62M
  register JDIMENSION col;
125
1.62M
  JDIMENSION num_cols = cinfo->output_width;
126
127
3.24M
  while (--num_rows >= 0) {
128
1.62M
    inptr0 = input_buf[0][input_row];
129
1.62M
    inptr1 = input_buf[1][input_row];
130
1.62M
    inptr2 = input_buf[2][input_row];
131
1.62M
    input_row++;
132
1.62M
    outptr = *output_buf++;
133
82.8M
    for (col = 0; col < num_cols; col++) {
134
81.2M
      outptr[RGB_RED] = inptr0[col];
135
81.2M
      outptr[RGB_GREEN] = inptr1[col];
136
81.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
#ifdef RGB_ALPHA
140
0
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
141
#endif
142
81.2M
      outptr += RGB_PIXELSIZE;
143
81.2M
    }
144
1.62M
  }
145
1.62M
}
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
1.62M
{
122
1.62M
  register _JSAMPROW inptr0, inptr1, inptr2;
123
1.62M
  register _JSAMPROW outptr;
124
1.62M
  register JDIMENSION col;
125
1.62M
  JDIMENSION num_cols = cinfo->output_width;
126
127
3.24M
  while (--num_rows >= 0) {
128
1.62M
    inptr0 = input_buf[0][input_row];
129
1.62M
    inptr1 = input_buf[1][input_row];
130
1.62M
    inptr2 = input_buf[2][input_row];
131
1.62M
    input_row++;
132
1.62M
    outptr = *output_buf++;
133
82.8M
    for (col = 0; col < num_cols; col++) {
134
81.2M
      outptr[RGB_RED] = inptr0[col];
135
81.2M
      outptr[RGB_GREEN] = inptr1[col];
136
81.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
#ifdef RGB_ALPHA
140
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
141
#endif
142
81.2M
      outptr += RGB_PIXELSIZE;
143
81.2M
    }
144
1.62M
  }
145
1.62M
}
Unexecuted instantiation: jdcolor.c:rgb_extbgrx_convert_internal
Unexecuted instantiation: jdcolor.c:rgb_extxbgr_convert_internal
Unexecuted instantiation: jdcolor.c:rgb_extxrgb_convert_internal
Unexecuted instantiation: jdcolor.c:rgb_rgb_convert_internal