Coverage Report

Created: 2023-12-14 14:07

/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
2.34M
{
35
2.34M
#if BITS_IN_JSAMPLE != 16
36
2.34M
  my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
37
2.34M
  register int y, cb, cr;
38
2.34M
  register _JSAMPROW outptr;
39
2.34M
  register _JSAMPROW inptr0, inptr1, inptr2;
40
2.34M
  register JDIMENSION col;
41
2.34M
  JDIMENSION num_cols = cinfo->output_width;
42
  /* copy these pointers into registers if possible */
43
2.34M
  register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit;
44
2.34M
  register int *Crrtab = cconvert->Cr_r_tab;
45
2.34M
  register int *Cbbtab = cconvert->Cb_b_tab;
46
2.34M
  register JLONG *Crgtab = cconvert->Cr_g_tab;
47
2.34M
  register JLONG *Cbgtab = cconvert->Cb_g_tab;
48
2.34M
  SHIFT_TEMPS
49
50
8.97M
  while (--num_rows >= 0) {
51
6.63M
    inptr0 = input_buf[0][input_row];
52
6.63M
    inptr1 = input_buf[1][input_row];
53
6.63M
    inptr2 = input_buf[2][input_row];
54
6.63M
    input_row++;
55
6.63M
    outptr = *output_buf++;
56
194M
    for (col = 0; col < num_cols; col++) {
57
187M
      y  = inptr0[col];
58
187M
      cb = inptr1[col];
59
187M
      cr = inptr2[col];
60
      /* Range-limiting is essential due to noise introduced by DCT losses. */
61
187M
      outptr[RGB_RED] =   range_limit[y + Crrtab[cr]];
62
187M
      outptr[RGB_GREEN] = range_limit[y +
63
187M
                              ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
64
187M
                                                SCALEBITS))];
65
187M
      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
23.8M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
70
#endif
71
187M
      outptr += RGB_PIXELSIZE;
72
187M
    }
73
6.63M
  }
74
#else
75
  ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
76
#endif
77
2.34M
}
jdcolor.c:ycc_extrgb_convert_internal
Line
Count
Source
34
1.69M
{
35
1.69M
#if BITS_IN_JSAMPLE != 16
36
1.69M
  my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
37
1.69M
  register int y, cb, cr;
38
1.69M
  register _JSAMPROW outptr;
39
1.69M
  register _JSAMPROW inptr0, inptr1, inptr2;
40
1.69M
  register JDIMENSION col;
41
1.69M
  JDIMENSION num_cols = cinfo->output_width;
42
  /* copy these pointers into registers if possible */
43
1.69M
  register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit;
44
1.69M
  register int *Crrtab = cconvert->Cr_r_tab;
45
1.69M
  register int *Cbbtab = cconvert->Cb_b_tab;
46
1.69M
  register JLONG *Crgtab = cconvert->Cr_g_tab;
47
1.69M
  register JLONG *Cbgtab = cconvert->Cb_g_tab;
48
1.69M
  SHIFT_TEMPS
49
50
6.63M
  while (--num_rows >= 0) {
51
4.94M
    inptr0 = input_buf[0][input_row];
52
4.94M
    inptr1 = input_buf[1][input_row];
53
4.94M
    inptr2 = input_buf[2][input_row];
54
4.94M
    input_row++;
55
4.94M
    outptr = *output_buf++;
56
168M
    for (col = 0; col < num_cols; col++) {
57
163M
      y  = inptr0[col];
58
163M
      cb = inptr1[col];
59
163M
      cr = inptr2[col];
60
      /* Range-limiting is essential due to noise introduced by DCT losses. */
61
163M
      outptr[RGB_RED] =   range_limit[y + Crrtab[cr]];
62
163M
      outptr[RGB_GREEN] = range_limit[y +
63
163M
                              ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
64
163M
                                                SCALEBITS))];
65
163M
      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
163M
      outptr += RGB_PIXELSIZE;
72
163M
    }
73
4.94M
  }
74
#else
75
  ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
76
#endif
77
1.69M
}
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
655k
{
35
655k
#if BITS_IN_JSAMPLE != 16
36
655k
  my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
37
655k
  register int y, cb, cr;
38
655k
  register _JSAMPROW outptr;
39
655k
  register _JSAMPROW inptr0, inptr1, inptr2;
40
655k
  register JDIMENSION col;
41
655k
  JDIMENSION num_cols = cinfo->output_width;
42
  /* copy these pointers into registers if possible */
43
655k
  register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit;
44
655k
  register int *Crrtab = cconvert->Cr_r_tab;
45
655k
  register int *Cbbtab = cconvert->Cb_b_tab;
46
655k
  register JLONG *Crgtab = cconvert->Cr_g_tab;
47
655k
  register JLONG *Cbgtab = cconvert->Cb_g_tab;
48
655k
  SHIFT_TEMPS
49
50
2.33M
  while (--num_rows >= 0) {
51
1.68M
    inptr0 = input_buf[0][input_row];
52
1.68M
    inptr1 = input_buf[1][input_row];
53
1.68M
    inptr2 = input_buf[2][input_row];
54
1.68M
    input_row++;
55
1.68M
    outptr = *output_buf++;
56
25.5M
    for (col = 0; col < num_cols; col++) {
57
23.8M
      y  = inptr0[col];
58
23.8M
      cb = inptr1[col];
59
23.8M
      cr = inptr2[col];
60
      /* Range-limiting is essential due to noise introduced by DCT losses. */
61
23.8M
      outptr[RGB_RED] =   range_limit[y + Crrtab[cr]];
62
23.8M
      outptr[RGB_GREEN] = range_limit[y +
63
23.8M
                              ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
64
23.8M
                                                SCALEBITS))];
65
23.8M
      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
23.8M
#ifdef RGB_ALPHA
69
23.8M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
70
23.8M
#endif
71
23.8M
      outptr += RGB_PIXELSIZE;
72
23.8M
    }
73
1.68M
  }
74
#else
75
  ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
76
#endif
77
655k
}
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
1.40M
{
92
1.40M
  register _JSAMPROW inptr, outptr;
93
1.40M
  register JDIMENSION col;
94
1.40M
  JDIMENSION num_cols = cinfo->output_width;
95
96
3.30M
  while (--num_rows >= 0) {
97
1.90M
    inptr = input_buf[0][input_row++];
98
1.90M
    outptr = *output_buf++;
99
70.5M
    for (col = 0; col < num_cols; col++) {
100
68.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
692k
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
105
#endif
106
68.6M
      outptr += RGB_PIXELSIZE;
107
68.6M
    }
108
1.90M
  }
109
1.40M
}
jdcolor.c:gray_extrgb_convert_internal
Line
Count
Source
91
1.33M
{
92
1.33M
  register _JSAMPROW inptr, outptr;
93
1.33M
  register JDIMENSION col;
94
1.33M
  JDIMENSION num_cols = cinfo->output_width;
95
96
3.16M
  while (--num_rows >= 0) {
97
1.83M
    inptr = input_buf[0][input_row++];
98
1.83M
    outptr = *output_buf++;
99
69.7M
    for (col = 0; col < num_cols; col++) {
100
67.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
#ifdef RGB_ALPHA
104
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
105
#endif
106
67.9M
      outptr += RGB_PIXELSIZE;
107
67.9M
    }
108
1.83M
  }
109
1.33M
}
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
66.1k
{
92
66.1k
  register _JSAMPROW inptr, outptr;
93
66.1k
  register JDIMENSION col;
94
66.1k
  JDIMENSION num_cols = cinfo->output_width;
95
96
139k
  while (--num_rows >= 0) {
97
73.6k
    inptr = input_buf[0][input_row++];
98
73.6k
    outptr = *output_buf++;
99
766k
    for (col = 0; col < num_cols; col++) {
100
692k
      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
692k
#ifdef RGB_ALPHA
104
692k
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
105
692k
#endif
106
692k
      outptr += RGB_PIXELSIZE;
107
692k
    }
108
73.6k
  }
109
66.1k
}
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
464k
{
122
464k
  register _JSAMPROW inptr0, inptr1, inptr2;
123
464k
  register _JSAMPROW outptr;
124
464k
  register JDIMENSION col;
125
464k
  JDIMENSION num_cols = cinfo->output_width;
126
127
1.48M
  while (--num_rows >= 0) {
128
1.02M
    inptr0 = input_buf[0][input_row];
129
1.02M
    inptr1 = input_buf[1][input_row];
130
1.02M
    inptr2 = input_buf[2][input_row];
131
1.02M
    input_row++;
132
1.02M
    outptr = *output_buf++;
133
26.0M
    for (col = 0; col < num_cols; col++) {
134
24.9M
      outptr[RGB_RED] = inptr0[col];
135
24.9M
      outptr[RGB_GREEN] = inptr1[col];
136
24.9M
      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
24.9M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
141
#endif
142
24.9M
      outptr += RGB_PIXELSIZE;
143
24.9M
    }
144
1.02M
  }
145
464k
}
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
464k
{
122
464k
  register _JSAMPROW inptr0, inptr1, inptr2;
123
464k
  register _JSAMPROW outptr;
124
464k
  register JDIMENSION col;
125
464k
  JDIMENSION num_cols = cinfo->output_width;
126
127
1.48M
  while (--num_rows >= 0) {
128
1.02M
    inptr0 = input_buf[0][input_row];
129
1.02M
    inptr1 = input_buf[1][input_row];
130
1.02M
    inptr2 = input_buf[2][input_row];
131
1.02M
    input_row++;
132
1.02M
    outptr = *output_buf++;
133
26.0M
    for (col = 0; col < num_cols; col++) {
134
24.9M
      outptr[RGB_RED] = inptr0[col];
135
24.9M
      outptr[RGB_GREEN] = inptr1[col];
136
24.9M
      outptr[RGB_BLUE] = inptr2[col];
137
      /* Set unused byte to _MAXJSAMPLE so it can be interpreted as an */
138
      /* opaque alpha channel value */
139
24.9M
#ifdef RGB_ALPHA
140
24.9M
      outptr[RGB_ALPHA] = _MAXJSAMPLE;
141
24.9M
#endif
142
24.9M
      outptr += RGB_PIXELSIZE;
143
24.9M
    }
144
1.02M
  }
145
464k
}
Unexecuted instantiation: jdcolor.c:rgb_extxbgr_convert_internal
Unexecuted instantiation: jdcolor.c:rgb_extxrgb_convert_internal
Unexecuted instantiation: jdcolor.c:rgb_rgb_convert_internal