Coverage Report

Created: 2023-10-07 15:08

/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
15.4M
{
35
15.4M
#if BITS_IN_JSAMPLE != 16
36
15.4M
  my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
37
15.4M
  register int y, cb, cr;
38
15.4M
  register _JSAMPROW outptr;
39
15.4M
  register _JSAMPROW inptr0, inptr1, inptr2;
40
15.4M
  register JDIMENSION col;
41
15.4M
  JDIMENSION num_cols = cinfo->output_width;
42
  /* copy these pointers into registers if possible */
43
15.4M
  register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit;
44
15.4M
  register int *Crrtab = cconvert->Cr_r_tab;
45
15.4M
  register int *Cbbtab = cconvert->Cb_b_tab;
46
15.4M
  register JLONG *Crgtab = cconvert->Cr_g_tab;
47
15.4M
  register JLONG *Cbgtab = cconvert->Cb_g_tab;
48
15.4M
  SHIFT_TEMPS
49
50
58.0M
  while (--num_rows >= 0) {
51
42.5M
    inptr0 = input_buf[0][input_row];
52
42.5M
    inptr1 = input_buf[1][input_row];
53
42.5M
    inptr2 = input_buf[2][input_row];
54
42.5M
    input_row++;
55
42.5M
    outptr = *output_buf++;
56
1.29G
    for (col = 0; col < num_cols; col++) {
57
1.25G
      y  = inptr0[col];
58
1.25G
      cb = inptr1[col];
59
1.25G
      cr = inptr2[col];
60
      /* Range-limiting is essential due to noise introduced by DCT losses. */
61
1.25G
      outptr[RGB_RED] =   range_limit[y + Crrtab[cr]];
62
1.25G
      outptr[RGB_GREEN] = range_limit[y +
63
1.25G
                              ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
64
1.25G
                                                SCALEBITS))];
65
1.25G
      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
205M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
70
#endif
71
1.25G
      outptr += RGB_PIXELSIZE;
72
1.25G
    }
73
42.5M
  }
74
#else
75
  ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
76
#endif
77
15.4M
}
jdcolor.c:ycc_extrgb_convert_internal
Line
Count
Source
34
10.2M
{
35
10.2M
#if BITS_IN_JSAMPLE != 16
36
10.2M
  my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
37
10.2M
  register int y, cb, cr;
38
10.2M
  register _JSAMPROW outptr;
39
10.2M
  register _JSAMPROW inptr0, inptr1, inptr2;
40
10.2M
  register JDIMENSION col;
41
10.2M
  JDIMENSION num_cols = cinfo->output_width;
42
  /* copy these pointers into registers if possible */
43
10.2M
  register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit;
44
10.2M
  register int *Crrtab = cconvert->Cr_r_tab;
45
10.2M
  register int *Cbbtab = cconvert->Cb_b_tab;
46
10.2M
  register JLONG *Crgtab = cconvert->Cr_g_tab;
47
10.2M
  register JLONG *Cbgtab = cconvert->Cb_g_tab;
48
10.2M
  SHIFT_TEMPS
49
50
41.0M
  while (--num_rows >= 0) {
51
30.7M
    inptr0 = input_buf[0][input_row];
52
30.7M
    inptr1 = input_buf[1][input_row];
53
30.7M
    inptr2 = input_buf[2][input_row];
54
30.7M
    input_row++;
55
30.7M
    outptr = *output_buf++;
56
1.07G
    for (col = 0; col < num_cols; col++) {
57
1.04G
      y  = inptr0[col];
58
1.04G
      cb = inptr1[col];
59
1.04G
      cr = inptr2[col];
60
      /* Range-limiting is essential due to noise introduced by DCT losses. */
61
1.04G
      outptr[RGB_RED] =   range_limit[y + Crrtab[cr]];
62
1.04G
      outptr[RGB_GREEN] = range_limit[y +
63
1.04G
                              ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
64
1.04G
                                                SCALEBITS))];
65
1.04G
      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
1.04G
      outptr += RGB_PIXELSIZE;
72
1.04G
    }
73
30.7M
  }
74
#else
75
  ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
76
#endif
77
10.2M
}
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
5.19M
{
35
5.19M
#if BITS_IN_JSAMPLE != 16
36
5.19M
  my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
37
5.19M
  register int y, cb, cr;
38
5.19M
  register _JSAMPROW outptr;
39
5.19M
  register _JSAMPROW inptr0, inptr1, inptr2;
40
5.19M
  register JDIMENSION col;
41
5.19M
  JDIMENSION num_cols = cinfo->output_width;
42
  /* copy these pointers into registers if possible */
43
5.19M
  register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit;
44
5.19M
  register int *Crrtab = cconvert->Cr_r_tab;
45
5.19M
  register int *Cbbtab = cconvert->Cb_b_tab;
46
5.19M
  register JLONG *Crgtab = cconvert->Cr_g_tab;
47
5.19M
  register JLONG *Cbgtab = cconvert->Cb_g_tab;
48
5.19M
  SHIFT_TEMPS
49
50
16.9M
  while (--num_rows >= 0) {
51
11.7M
    inptr0 = input_buf[0][input_row];
52
11.7M
    inptr1 = input_buf[1][input_row];
53
11.7M
    inptr2 = input_buf[2][input_row];
54
11.7M
    input_row++;
55
11.7M
    outptr = *output_buf++;
56
216M
    for (col = 0; col < num_cols; col++) {
57
205M
      y  = inptr0[col];
58
205M
      cb = inptr1[col];
59
205M
      cr = inptr2[col];
60
      /* Range-limiting is essential due to noise introduced by DCT losses. */
61
205M
      outptr[RGB_RED] =   range_limit[y + Crrtab[cr]];
62
205M
      outptr[RGB_GREEN] = range_limit[y +
63
205M
                              ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
64
205M
                                                SCALEBITS))];
65
205M
      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
205M
#ifdef RGB_ALPHA
69
205M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
70
205M
#endif
71
205M
      outptr += RGB_PIXELSIZE;
72
205M
    }
73
11.7M
  }
74
#else
75
  ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
76
#endif
77
5.19M
}
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
4.85M
{
92
4.85M
  register _JSAMPROW inptr, outptr;
93
4.85M
  register JDIMENSION col;
94
4.85M
  JDIMENSION num_cols = cinfo->output_width;
95
96
13.5M
  while (--num_rows >= 0) {
97
8.71M
    inptr = input_buf[0][input_row++];
98
8.71M
    outptr = *output_buf++;
99
431M
    for (col = 0; col < num_cols; col++) {
100
422M
      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
17.8M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
105
#endif
106
422M
      outptr += RGB_PIXELSIZE;
107
422M
    }
108
8.71M
  }
109
4.85M
}
jdcolor.c:gray_extrgb_convert_internal
Line
Count
Source
91
4.58M
{
92
4.58M
  register _JSAMPROW inptr, outptr;
93
4.58M
  register JDIMENSION col;
94
4.58M
  JDIMENSION num_cols = cinfo->output_width;
95
96
12.8M
  while (--num_rows >= 0) {
97
8.31M
    inptr = input_buf[0][input_row++];
98
8.31M
    outptr = *output_buf++;
99
413M
    for (col = 0; col < num_cols; col++) {
100
405M
      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
405M
      outptr += RGB_PIXELSIZE;
107
405M
    }
108
8.31M
  }
109
4.58M
}
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
273k
{
92
273k
  register _JSAMPROW inptr, outptr;
93
273k
  register JDIMENSION col;
94
273k
  JDIMENSION num_cols = cinfo->output_width;
95
96
676k
  while (--num_rows >= 0) {
97
403k
    inptr = input_buf[0][input_row++];
98
403k
    outptr = *output_buf++;
99
18.2M
    for (col = 0; col < num_cols; col++) {
100
17.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
17.8M
#ifdef RGB_ALPHA
104
17.8M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
105
17.8M
#endif
106
17.8M
      outptr += RGB_PIXELSIZE;
107
17.8M
    }
108
403k
  }
109
273k
}
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.00M
{
122
1.00M
  register _JSAMPROW inptr0, inptr1, inptr2;
123
1.00M
  register _JSAMPROW outptr;
124
1.00M
  register JDIMENSION col;
125
1.00M
  JDIMENSION num_cols = cinfo->output_width;
126
127
3.04M
  while (--num_rows >= 0) {
128
2.03M
    inptr0 = input_buf[0][input_row];
129
2.03M
    inptr1 = input_buf[1][input_row];
130
2.03M
    inptr2 = input_buf[2][input_row];
131
2.03M
    input_row++;
132
2.03M
    outptr = *output_buf++;
133
47.1M
    for (col = 0; col < num_cols; col++) {
134
45.1M
      outptr[RGB_RED] = inptr0[col];
135
45.1M
      outptr[RGB_GREEN] = inptr1[col];
136
45.1M
      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
45.1M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
141
#endif
142
45.1M
      outptr += RGB_PIXELSIZE;
143
45.1M
    }
144
2.03M
  }
145
1.00M
}
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
1.00M
{
122
1.00M
  register _JSAMPROW inptr0, inptr1, inptr2;
123
1.00M
  register _JSAMPROW outptr;
124
1.00M
  register JDIMENSION col;
125
1.00M
  JDIMENSION num_cols = cinfo->output_width;
126
127
3.04M
  while (--num_rows >= 0) {
128
2.03M
    inptr0 = input_buf[0][input_row];
129
2.03M
    inptr1 = input_buf[1][input_row];
130
2.03M
    inptr2 = input_buf[2][input_row];
131
2.03M
    input_row++;
132
2.03M
    outptr = *output_buf++;
133
47.1M
    for (col = 0; col < num_cols; col++) {
134
45.1M
      outptr[RGB_RED] = inptr0[col];
135
45.1M
      outptr[RGB_GREEN] = inptr1[col];
136
45.1M
      outptr[RGB_BLUE] = inptr2[col];
137
      /* Set unused byte to _MAXJSAMPLE so it can be interpreted as an */
138
      /* opaque alpha channel value */
139
45.1M
#ifdef RGB_ALPHA
140
45.1M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
141
45.1M
#endif
142
45.1M
      outptr += RGB_PIXELSIZE;
143
45.1M
    }
144
2.03M
  }
145
1.00M
}
Unexecuted instantiation: jdcolor.c:rgb_extxbgr_convert_internal
Unexecuted instantiation: jdcolor.c:rgb_extxrgb_convert_internal
Unexecuted instantiation: jdcolor.c:rgb_rgb_convert_internal