Coverage Report

Created: 2023-06-07 06:03

/src/libjpeg-turbo.main/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
875k
{
35
875k
#if BITS_IN_JSAMPLE != 16
36
875k
  my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
37
875k
  register int y, cb, cr;
38
875k
  register _JSAMPROW outptr;
39
875k
  register _JSAMPROW inptr0, inptr1, inptr2;
40
875k
  register JDIMENSION col;
41
875k
  JDIMENSION num_cols = cinfo->output_width;
42
  /* copy these pointers into registers if possible */
43
875k
  register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit;
44
875k
  register int *Crrtab = cconvert->Cr_r_tab;
45
875k
  register int *Cbbtab = cconvert->Cb_b_tab;
46
875k
  register JLONG *Crgtab = cconvert->Cr_g_tab;
47
875k
  register JLONG *Cbgtab = cconvert->Cb_g_tab;
48
875k
  SHIFT_TEMPS
49
50
2.74M
  while (--num_rows >= 0) {
51
1.87M
    inptr0 = input_buf[0][input_row];
52
1.87M
    inptr1 = input_buf[1][input_row];
53
1.87M
    inptr2 = input_buf[2][input_row];
54
1.87M
    input_row++;
55
1.87M
    outptr = *output_buf++;
56
80.0M
    for (col = 0; col < num_cols; col++) {
57
78.2M
      y  = inptr0[col];
58
78.2M
      cb = inptr1[col];
59
78.2M
      cr = inptr2[col];
60
      /* Range-limiting is essential due to noise introduced by DCT losses. */
61
78.2M
      outptr[RGB_RED] =   range_limit[y + Crrtab[cr]];
62
78.2M
      outptr[RGB_GREEN] = range_limit[y +
63
78.2M
                              ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
64
78.2M
                                                SCALEBITS))];
65
78.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
18.5M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
70
#endif
71
78.2M
      outptr += RGB_PIXELSIZE;
72
78.2M
    }
73
1.87M
  }
74
#else
75
  ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
76
#endif
77
875k
}
jdcolor.c:ycc_extrgb_convert_internal
Line
Count
Source
34
769k
{
35
769k
#if BITS_IN_JSAMPLE != 16
36
769k
  my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
37
769k
  register int y, cb, cr;
38
769k
  register _JSAMPROW outptr;
39
769k
  register _JSAMPROW inptr0, inptr1, inptr2;
40
769k
  register JDIMENSION col;
41
769k
  JDIMENSION num_cols = cinfo->output_width;
42
  /* copy these pointers into registers if possible */
43
769k
  register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit;
44
769k
  register int *Crrtab = cconvert->Cr_r_tab;
45
769k
  register int *Cbbtab = cconvert->Cb_b_tab;
46
769k
  register JLONG *Crgtab = cconvert->Cr_g_tab;
47
769k
  register JLONG *Cbgtab = cconvert->Cb_g_tab;
48
769k
  SHIFT_TEMPS
49
50
2.42M
  while (--num_rows >= 0) {
51
1.65M
    inptr0 = input_buf[0][input_row];
52
1.65M
    inptr1 = input_buf[1][input_row];
53
1.65M
    inptr2 = input_buf[2][input_row];
54
1.65M
    input_row++;
55
1.65M
    outptr = *output_buf++;
56
61.2M
    for (col = 0; col < num_cols; col++) {
57
59.6M
      y  = inptr0[col];
58
59.6M
      cb = inptr1[col];
59
59.6M
      cr = inptr2[col];
60
      /* Range-limiting is essential due to noise introduced by DCT losses. */
61
59.6M
      outptr[RGB_RED] =   range_limit[y + Crrtab[cr]];
62
59.6M
      outptr[RGB_GREEN] = range_limit[y +
63
59.6M
                              ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
64
59.6M
                                                SCALEBITS))];
65
59.6M
      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
59.6M
      outptr += RGB_PIXELSIZE;
72
59.6M
    }
73
1.65M
  }
74
#else
75
  ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
76
#endif
77
769k
}
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
106k
{
35
106k
#if BITS_IN_JSAMPLE != 16
36
106k
  my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
37
106k
  register int y, cb, cr;
38
106k
  register _JSAMPROW outptr;
39
106k
  register _JSAMPROW inptr0, inptr1, inptr2;
40
106k
  register JDIMENSION col;
41
106k
  JDIMENSION num_cols = cinfo->output_width;
42
  /* copy these pointers into registers if possible */
43
106k
  register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit;
44
106k
  register int *Crrtab = cconvert->Cr_r_tab;
45
106k
  register int *Cbbtab = cconvert->Cb_b_tab;
46
106k
  register JLONG *Crgtab = cconvert->Cr_g_tab;
47
106k
  register JLONG *Cbgtab = cconvert->Cb_g_tab;
48
106k
  SHIFT_TEMPS
49
50
323k
  while (--num_rows >= 0) {
51
217k
    inptr0 = input_buf[0][input_row];
52
217k
    inptr1 = input_buf[1][input_row];
53
217k
    inptr2 = input_buf[2][input_row];
54
217k
    input_row++;
55
217k
    outptr = *output_buf++;
56
18.8M
    for (col = 0; col < num_cols; col++) {
57
18.5M
      y  = inptr0[col];
58
18.5M
      cb = inptr1[col];
59
18.5M
      cr = inptr2[col];
60
      /* Range-limiting is essential due to noise introduced by DCT losses. */
61
18.5M
      outptr[RGB_RED] =   range_limit[y + Crrtab[cr]];
62
18.5M
      outptr[RGB_GREEN] = range_limit[y +
63
18.5M
                              ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
64
18.5M
                                                SCALEBITS))];
65
18.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
18.5M
#ifdef RGB_ALPHA
69
18.5M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
70
18.5M
#endif
71
18.5M
      outptr += RGB_PIXELSIZE;
72
18.5M
    }
73
217k
  }
74
#else
75
  ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
76
#endif
77
106k
}
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
7.11M
{
92
7.11M
  register _JSAMPROW inptr, outptr;
93
7.11M
  register JDIMENSION col;
94
7.11M
  JDIMENSION num_cols = cinfo->output_width;
95
96
18.8M
  while (--num_rows >= 0) {
97
11.7M
    inptr = input_buf[0][input_row++];
98
11.7M
    outptr = *output_buf++;
99
899M
    for (col = 0; col < num_cols; col++) {
100
887M
      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
27.1M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
105
#endif
106
887M
      outptr += RGB_PIXELSIZE;
107
887M
    }
108
11.7M
  }
109
7.11M
}
jdcolor.c:gray_extrgb_convert_internal
Line
Count
Source
91
6.77M
{
92
6.77M
  register _JSAMPROW inptr, outptr;
93
6.77M
  register JDIMENSION col;
94
6.77M
  JDIMENSION num_cols = cinfo->output_width;
95
96
17.9M
  while (--num_rows >= 0) {
97
11.1M
    inptr = input_buf[0][input_row++];
98
11.1M
    outptr = *output_buf++;
99
871M
    for (col = 0; col < num_cols; col++) {
100
860M
      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
860M
      outptr += RGB_PIXELSIZE;
107
860M
    }
108
11.1M
  }
109
6.77M
}
Unexecuted instantiation: jdcolor.c:gray_extrgbx_convert_internal
Unexecuted instantiation: jdcolor.c:gray_extbgr_convert_internal
jdcolor.c:gray_extbgrx_convert_internal
Line
Count
Source
91
341k
{
92
341k
  register _JSAMPROW inptr, outptr;
93
341k
  register JDIMENSION col;
94
341k
  JDIMENSION num_cols = cinfo->output_width;
95
96
910k
  while (--num_rows >= 0) {
97
568k
    inptr = input_buf[0][input_row++];
98
568k
    outptr = *output_buf++;
99
27.6M
    for (col = 0; col < num_cols; col++) {
100
27.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
27.1M
#ifdef RGB_ALPHA
104
27.1M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
105
27.1M
#endif
106
27.1M
      outptr += RGB_PIXELSIZE;
107
27.1M
    }
108
568k
  }
109
341k
}
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
47.0k
{
122
47.0k
  register _JSAMPROW inptr0, inptr1, inptr2;
123
47.0k
  register _JSAMPROW outptr;
124
47.0k
  register JDIMENSION col;
125
47.0k
  JDIMENSION num_cols = cinfo->output_width;
126
127
200k
  while (--num_rows >= 0) {
128
153k
    inptr0 = input_buf[0][input_row];
129
153k
    inptr1 = input_buf[1][input_row];
130
153k
    inptr2 = input_buf[2][input_row];
131
153k
    input_row++;
132
153k
    outptr = *output_buf++;
133
3.53M
    for (col = 0; col < num_cols; col++) {
134
3.37M
      outptr[RGB_RED] = inptr0[col];
135
3.37M
      outptr[RGB_GREEN] = inptr1[col];
136
3.37M
      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
3.37M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
141
#endif
142
3.37M
      outptr += RGB_PIXELSIZE;
143
3.37M
    }
144
153k
  }
145
47.0k
}
Unexecuted instantiation: jdcolor.c:rgb_extrgb_convert_internal
Unexecuted instantiation: jdcolor.c:rgb_extrgbx_convert_internal
Unexecuted instantiation: jdcolor.c:rgb_extbgr_convert_internal
jdcolor.c:rgb_extbgrx_convert_internal
Line
Count
Source
121
47.0k
{
122
47.0k
  register _JSAMPROW inptr0, inptr1, inptr2;
123
47.0k
  register _JSAMPROW outptr;
124
47.0k
  register JDIMENSION col;
125
47.0k
  JDIMENSION num_cols = cinfo->output_width;
126
127
200k
  while (--num_rows >= 0) {
128
153k
    inptr0 = input_buf[0][input_row];
129
153k
    inptr1 = input_buf[1][input_row];
130
153k
    inptr2 = input_buf[2][input_row];
131
153k
    input_row++;
132
153k
    outptr = *output_buf++;
133
3.53M
    for (col = 0; col < num_cols; col++) {
134
3.37M
      outptr[RGB_RED] = inptr0[col];
135
3.37M
      outptr[RGB_GREEN] = inptr1[col];
136
3.37M
      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.37M
#ifdef RGB_ALPHA
140
3.37M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
141
3.37M
#endif
142
3.37M
      outptr += RGB_PIXELSIZE;
143
3.37M
    }
144
153k
  }
145
47.0k
}
Unexecuted instantiation: jdcolor.c:rgb_extxbgr_convert_internal
Unexecuted instantiation: jdcolor.c:rgb_extxrgb_convert_internal
Unexecuted instantiation: jdcolor.c:rgb_rgb_convert_internal