Coverage Report

Created: 2023-06-07 06:03

/src/libjpeg-turbo.2.1.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, 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
  my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
36
875k
  register int y, cb, cr;
37
875k
  register JSAMPROW outptr;
38
875k
  register JSAMPROW inptr0, inptr1, inptr2;
39
875k
  register JDIMENSION col;
40
875k
  JDIMENSION num_cols = cinfo->output_width;
41
  /* copy these pointers into registers if possible */
42
875k
  register JSAMPLE *range_limit = cinfo->sample_range_limit;
43
875k
  register int *Crrtab = cconvert->Cr_r_tab;
44
875k
  register int *Cbbtab = cconvert->Cb_b_tab;
45
875k
  register JLONG *Crgtab = cconvert->Cr_g_tab;
46
875k
  register JLONG *Cbgtab = cconvert->Cb_g_tab;
47
875k
  SHIFT_TEMPS
48
49
2.74M
  while (--num_rows >= 0) {
50
1.87M
    inptr0 = input_buf[0][input_row];
51
1.87M
    inptr1 = input_buf[1][input_row];
52
1.87M
    inptr2 = input_buf[2][input_row];
53
1.87M
    input_row++;
54
1.87M
    outptr = *output_buf++;
55
80.0M
    for (col = 0; col < num_cols; col++) {
56
78.2M
      y  = inptr0[col];
57
78.2M
      cb = inptr1[col];
58
78.2M
      cr = inptr2[col];
59
      /* Range-limiting is essential due to noise introduced by DCT losses. */
60
78.2M
      outptr[RGB_RED] =   range_limit[y + Crrtab[cr]];
61
78.2M
      outptr[RGB_GREEN] = range_limit[y +
62
78.2M
                              ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
63
78.2M
                                                SCALEBITS))];
64
78.2M
      outptr[RGB_BLUE] =  range_limit[y + Cbbtab[cb]];
65
      /* Set unused byte to MAXJSAMPLE so it can be interpreted as an opaque */
66
      /* alpha channel value */
67
#ifdef RGB_ALPHA
68
18.5M
      outptr[RGB_ALPHA] = MAXJSAMPLE;
69
#endif
70
78.2M
      outptr += RGB_PIXELSIZE;
71
78.2M
    }
72
1.87M
  }
73
875k
}
jdcolor.c:ycc_extrgb_convert_internal
Line
Count
Source
34
769k
{
35
769k
  my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
36
769k
  register int y, cb, cr;
37
769k
  register JSAMPROW outptr;
38
769k
  register JSAMPROW inptr0, inptr1, inptr2;
39
769k
  register JDIMENSION col;
40
769k
  JDIMENSION num_cols = cinfo->output_width;
41
  /* copy these pointers into registers if possible */
42
769k
  register JSAMPLE *range_limit = cinfo->sample_range_limit;
43
769k
  register int *Crrtab = cconvert->Cr_r_tab;
44
769k
  register int *Cbbtab = cconvert->Cb_b_tab;
45
769k
  register JLONG *Crgtab = cconvert->Cr_g_tab;
46
769k
  register JLONG *Cbgtab = cconvert->Cb_g_tab;
47
769k
  SHIFT_TEMPS
48
49
2.42M
  while (--num_rows >= 0) {
50
1.65M
    inptr0 = input_buf[0][input_row];
51
1.65M
    inptr1 = input_buf[1][input_row];
52
1.65M
    inptr2 = input_buf[2][input_row];
53
1.65M
    input_row++;
54
1.65M
    outptr = *output_buf++;
55
61.2M
    for (col = 0; col < num_cols; col++) {
56
59.6M
      y  = inptr0[col];
57
59.6M
      cb = inptr1[col];
58
59.6M
      cr = inptr2[col];
59
      /* Range-limiting is essential due to noise introduced by DCT losses. */
60
59.6M
      outptr[RGB_RED] =   range_limit[y + Crrtab[cr]];
61
59.6M
      outptr[RGB_GREEN] = range_limit[y +
62
59.6M
                              ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
63
59.6M
                                                SCALEBITS))];
64
59.6M
      outptr[RGB_BLUE] =  range_limit[y + Cbbtab[cb]];
65
      /* Set unused byte to MAXJSAMPLE so it can be interpreted as an opaque */
66
      /* alpha channel value */
67
#ifdef RGB_ALPHA
68
      outptr[RGB_ALPHA] = MAXJSAMPLE;
69
#endif
70
59.6M
      outptr += RGB_PIXELSIZE;
71
59.6M
    }
72
1.65M
  }
73
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
  my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
36
106k
  register int y, cb, cr;
37
106k
  register JSAMPROW outptr;
38
106k
  register JSAMPROW inptr0, inptr1, inptr2;
39
106k
  register JDIMENSION col;
40
106k
  JDIMENSION num_cols = cinfo->output_width;
41
  /* copy these pointers into registers if possible */
42
106k
  register JSAMPLE *range_limit = cinfo->sample_range_limit;
43
106k
  register int *Crrtab = cconvert->Cr_r_tab;
44
106k
  register int *Cbbtab = cconvert->Cb_b_tab;
45
106k
  register JLONG *Crgtab = cconvert->Cr_g_tab;
46
106k
  register JLONG *Cbgtab = cconvert->Cb_g_tab;
47
106k
  SHIFT_TEMPS
48
49
323k
  while (--num_rows >= 0) {
50
217k
    inptr0 = input_buf[0][input_row];
51
217k
    inptr1 = input_buf[1][input_row];
52
217k
    inptr2 = input_buf[2][input_row];
53
217k
    input_row++;
54
217k
    outptr = *output_buf++;
55
18.8M
    for (col = 0; col < num_cols; col++) {
56
18.5M
      y  = inptr0[col];
57
18.5M
      cb = inptr1[col];
58
18.5M
      cr = inptr2[col];
59
      /* Range-limiting is essential due to noise introduced by DCT losses. */
60
18.5M
      outptr[RGB_RED] =   range_limit[y + Crrtab[cr]];
61
18.5M
      outptr[RGB_GREEN] = range_limit[y +
62
18.5M
                              ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
63
18.5M
                                                SCALEBITS))];
64
18.5M
      outptr[RGB_BLUE] =  range_limit[y + Cbbtab[cb]];
65
      /* Set unused byte to MAXJSAMPLE so it can be interpreted as an opaque */
66
      /* alpha channel value */
67
18.5M
#ifdef RGB_ALPHA
68
18.5M
      outptr[RGB_ALPHA] = MAXJSAMPLE;
69
18.5M
#endif
70
18.5M
      outptr += RGB_PIXELSIZE;
71
18.5M
    }
72
217k
  }
73
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
74
75
76
/*
77
 * Convert grayscale to RGB: just duplicate the graylevel three times.
78
 * This is provided to support applications that don't want to cope
79
 * with grayscale as a separate case.
80
 */
81
82
INLINE
83
LOCAL(void)
84
gray_rgb_convert_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
85
                          JDIMENSION input_row, JSAMPARRAY output_buf,
86
                          int num_rows)
87
22.8M
{
88
22.8M
  register JSAMPROW inptr, outptr;
89
22.8M
  register JDIMENSION col;
90
22.8M
  JDIMENSION num_cols = cinfo->output_width;
91
92
59.3M
  while (--num_rows >= 0) {
93
36.4M
    inptr = input_buf[0][input_row++];
94
36.4M
    outptr = *output_buf++;
95
1.97G
    for (col = 0; col < num_cols; col++) {
96
1.94G
      outptr[RGB_RED] = outptr[RGB_GREEN] = outptr[RGB_BLUE] = inptr[col];
97
      /* Set unused byte to MAXJSAMPLE so it can be interpreted as an opaque */
98
      /* alpha channel value */
99
#ifdef RGB_ALPHA
100
63.6M
      outptr[RGB_ALPHA] = MAXJSAMPLE;
101
#endif
102
1.94G
      outptr += RGB_PIXELSIZE;
103
1.94G
    }
104
36.4M
  }
105
22.8M
}
jdcolor.c:gray_extrgb_convert_internal
Line
Count
Source
87
18.5M
{
88
18.5M
  register JSAMPROW inptr, outptr;
89
18.5M
  register JDIMENSION col;
90
18.5M
  JDIMENSION num_cols = cinfo->output_width;
91
92
50.0M
  while (--num_rows >= 0) {
93
31.5M
    inptr = input_buf[0][input_row++];
94
31.5M
    outptr = *output_buf++;
95
1.82G
    for (col = 0; col < num_cols; col++) {
96
1.79G
      outptr[RGB_RED] = outptr[RGB_GREEN] = outptr[RGB_BLUE] = inptr[col];
97
      /* Set unused byte to MAXJSAMPLE so it can be interpreted as an opaque */
98
      /* alpha channel value */
99
#ifdef RGB_ALPHA
100
      outptr[RGB_ALPHA] = MAXJSAMPLE;
101
#endif
102
1.79G
      outptr += RGB_PIXELSIZE;
103
1.79G
    }
104
31.5M
  }
105
18.5M
}
Unexecuted instantiation: jdcolor.c:gray_extrgbx_convert_internal
jdcolor.c:gray_extbgr_convert_internal
Line
Count
Source
87
2.46M
{
88
2.46M
  register JSAMPROW inptr, outptr;
89
2.46M
  register JDIMENSION col;
90
2.46M
  JDIMENSION num_cols = cinfo->output_width;
91
92
4.93M
  while (--num_rows >= 0) {
93
2.46M
    inptr = input_buf[0][input_row++];
94
2.46M
    outptr = *output_buf++;
95
89.4M
    for (col = 0; col < num_cols; col++) {
96
86.9M
      outptr[RGB_RED] = outptr[RGB_GREEN] = outptr[RGB_BLUE] = inptr[col];
97
      /* Set unused byte to MAXJSAMPLE so it can be interpreted as an opaque */
98
      /* alpha channel value */
99
#ifdef RGB_ALPHA
100
      outptr[RGB_ALPHA] = MAXJSAMPLE;
101
#endif
102
86.9M
      outptr += RGB_PIXELSIZE;
103
86.9M
    }
104
2.46M
  }
105
2.46M
}
jdcolor.c:gray_extbgrx_convert_internal
Line
Count
Source
87
1.11M
{
88
1.11M
  register JSAMPROW inptr, outptr;
89
1.11M
  register JDIMENSION col;
90
1.11M
  JDIMENSION num_cols = cinfo->output_width;
91
92
2.78M
  while (--num_rows >= 0) {
93
1.67M
    inptr = input_buf[0][input_row++];
94
1.67M
    outptr = *output_buf++;
95
42.9M
    for (col = 0; col < num_cols; col++) {
96
41.2M
      outptr[RGB_RED] = outptr[RGB_GREEN] = outptr[RGB_BLUE] = inptr[col];
97
      /* Set unused byte to MAXJSAMPLE so it can be interpreted as an opaque */
98
      /* alpha channel value */
99
41.2M
#ifdef RGB_ALPHA
100
41.2M
      outptr[RGB_ALPHA] = MAXJSAMPLE;
101
41.2M
#endif
102
41.2M
      outptr += RGB_PIXELSIZE;
103
41.2M
    }
104
1.67M
  }
105
1.11M
}
Unexecuted instantiation: jdcolor.c:gray_extxbgr_convert_internal
jdcolor.c:gray_extxrgb_convert_internal
Line
Count
Source
87
783k
{
88
783k
  register JSAMPROW inptr, outptr;
89
783k
  register JDIMENSION col;
90
783k
  JDIMENSION num_cols = cinfo->output_width;
91
92
1.56M
  while (--num_rows >= 0) {
93
783k
    inptr = input_buf[0][input_row++];
94
783k
    outptr = *output_buf++;
95
23.1M
    for (col = 0; col < num_cols; col++) {
96
22.4M
      outptr[RGB_RED] = outptr[RGB_GREEN] = outptr[RGB_BLUE] = inptr[col];
97
      /* Set unused byte to MAXJSAMPLE so it can be interpreted as an opaque */
98
      /* alpha channel value */
99
22.4M
#ifdef RGB_ALPHA
100
22.4M
      outptr[RGB_ALPHA] = MAXJSAMPLE;
101
22.4M
#endif
102
22.4M
      outptr += RGB_PIXELSIZE;
103
22.4M
    }
104
783k
  }
105
783k
}
Unexecuted instantiation: jdcolor.c:gray_rgb_convert_internal
106
107
108
/*
109
 * Convert RGB to extended RGB: just swap the order of source pixels
110
 */
111
112
INLINE
113
LOCAL(void)
114
rgb_rgb_convert_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
115
                         JDIMENSION input_row, JSAMPARRAY output_buf,
116
                         int num_rows)
117
452k
{
118
452k
  register JSAMPROW inptr0, inptr1, inptr2;
119
452k
  register JSAMPROW outptr;
120
452k
  register JDIMENSION col;
121
452k
  JDIMENSION num_cols = cinfo->output_width;
122
123
1.26M
  while (--num_rows >= 0) {
124
817k
    inptr0 = input_buf[0][input_row];
125
817k
    inptr1 = input_buf[1][input_row];
126
817k
    inptr2 = input_buf[2][input_row];
127
817k
    input_row++;
128
817k
    outptr = *output_buf++;
129
29.6M
    for (col = 0; col < num_cols; col++) {
130
28.7M
      outptr[RGB_RED] = inptr0[col];
131
28.7M
      outptr[RGB_GREEN] = inptr1[col];
132
28.7M
      outptr[RGB_BLUE] = inptr2[col];
133
      /* Set unused byte to MAXJSAMPLE so it can be interpreted as an opaque */
134
      /* alpha channel value */
135
#ifdef RGB_ALPHA
136
9.69M
      outptr[RGB_ALPHA] = MAXJSAMPLE;
137
#endif
138
28.7M
      outptr += RGB_PIXELSIZE;
139
28.7M
    }
140
817k
  }
141
452k
}
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
117
270k
{
118
270k
  register JSAMPROW inptr0, inptr1, inptr2;
119
270k
  register JSAMPROW outptr;
120
270k
  register JDIMENSION col;
121
270k
  JDIMENSION num_cols = cinfo->output_width;
122
123
691k
  while (--num_rows >= 0) {
124
420k
    inptr0 = input_buf[0][input_row];
125
420k
    inptr1 = input_buf[1][input_row];
126
420k
    inptr2 = input_buf[2][input_row];
127
420k
    input_row++;
128
420k
    outptr = *output_buf++;
129
19.5M
    for (col = 0; col < num_cols; col++) {
130
19.0M
      outptr[RGB_RED] = inptr0[col];
131
19.0M
      outptr[RGB_GREEN] = inptr1[col];
132
19.0M
      outptr[RGB_BLUE] = inptr2[col];
133
      /* Set unused byte to MAXJSAMPLE so it can be interpreted as an opaque */
134
      /* alpha channel value */
135
#ifdef RGB_ALPHA
136
      outptr[RGB_ALPHA] = MAXJSAMPLE;
137
#endif
138
19.0M
      outptr += RGB_PIXELSIZE;
139
19.0M
    }
140
420k
  }
141
270k
}
jdcolor.c:rgb_extbgrx_convert_internal
Line
Count
Source
117
101k
{
118
101k
  register JSAMPROW inptr0, inptr1, inptr2;
119
101k
  register JSAMPROW outptr;
120
101k
  register JDIMENSION col;
121
101k
  JDIMENSION num_cols = cinfo->output_width;
122
123
363k
  while (--num_rows >= 0) {
124
262k
    inptr0 = input_buf[0][input_row];
125
262k
    inptr1 = input_buf[1][input_row];
126
262k
    inptr2 = input_buf[2][input_row];
127
262k
    input_row++;
128
262k
    outptr = *output_buf++;
129
6.37M
    for (col = 0; col < num_cols; col++) {
130
6.10M
      outptr[RGB_RED] = inptr0[col];
131
6.10M
      outptr[RGB_GREEN] = inptr1[col];
132
6.10M
      outptr[RGB_BLUE] = inptr2[col];
133
      /* Set unused byte to MAXJSAMPLE so it can be interpreted as an opaque */
134
      /* alpha channel value */
135
6.10M
#ifdef RGB_ALPHA
136
6.10M
      outptr[RGB_ALPHA] = MAXJSAMPLE;
137
6.10M
#endif
138
6.10M
      outptr += RGB_PIXELSIZE;
139
6.10M
    }
140
262k
  }
141
101k
}
Unexecuted instantiation: jdcolor.c:rgb_extxbgr_convert_internal
jdcolor.c:rgb_extxrgb_convert_internal
Line
Count
Source
117
80.5k
{
118
80.5k
  register JSAMPROW inptr0, inptr1, inptr2;
119
80.5k
  register JSAMPROW outptr;
120
80.5k
  register JDIMENSION col;
121
80.5k
  JDIMENSION num_cols = cinfo->output_width;
122
123
215k
  while (--num_rows >= 0) {
124
134k
    inptr0 = input_buf[0][input_row];
125
134k
    inptr1 = input_buf[1][input_row];
126
134k
    inptr2 = input_buf[2][input_row];
127
134k
    input_row++;
128
134k
    outptr = *output_buf++;
129
3.72M
    for (col = 0; col < num_cols; col++) {
130
3.58M
      outptr[RGB_RED] = inptr0[col];
131
3.58M
      outptr[RGB_GREEN] = inptr1[col];
132
3.58M
      outptr[RGB_BLUE] = inptr2[col];
133
      /* Set unused byte to MAXJSAMPLE so it can be interpreted as an opaque */
134
      /* alpha channel value */
135
3.58M
#ifdef RGB_ALPHA
136
3.58M
      outptr[RGB_ALPHA] = MAXJSAMPLE;
137
3.58M
#endif
138
3.58M
      outptr += RGB_PIXELSIZE;
139
3.58M
    }
140
134k
  }
141
80.5k
}
Unexecuted instantiation: jdcolor.c:rgb_rgb_convert_internal