Coverage Report

Created: 2024-05-20 07:14

/src/skia/third_party/externals/libjpeg-turbo/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, 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
1.10M
{
35
1.10M
  my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
36
1.10M
  register int y, cb, cr;
37
1.10M
  register JSAMPROW outptr;
38
1.10M
  register JSAMPROW inptr0, inptr1, inptr2;
39
1.10M
  register JDIMENSION col;
40
1.10M
  JDIMENSION num_cols = cinfo->output_width;
41
  /* copy these pointers into registers if possible */
42
1.10M
  register JSAMPLE *range_limit = cinfo->sample_range_limit;
43
1.10M
  register int *Crrtab = cconvert->Cr_r_tab;
44
1.10M
  register int *Cbbtab = cconvert->Cb_b_tab;
45
1.10M
  register JLONG *Crgtab = cconvert->Cr_g_tab;
46
1.10M
  register JLONG *Cbgtab = cconvert->Cb_g_tab;
47
1.10M
  SHIFT_TEMPS
48
49
2.21M
  while (--num_rows >= 0) {
50
1.10M
    inptr0 = input_buf[0][input_row];
51
1.10M
    inptr1 = input_buf[1][input_row];
52
1.10M
    inptr2 = input_buf[2][input_row];
53
1.10M
    input_row++;
54
1.10M
    outptr = *output_buf++;
55
74.7M
    for (col = 0; col < num_cols; col++) {
56
73.6M
      y  = inptr0[col];
57
73.6M
      cb = inptr1[col];
58
73.6M
      cr = inptr2[col];
59
      /* Range-limiting is essential due to noise introduced by DCT losses. */
60
73.6M
      outptr[RGB_RED] =   range_limit[y + Crrtab[cr]];
61
73.6M
      outptr[RGB_GREEN] = range_limit[y +
62
73.6M
                              ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
63
73.6M
                                                SCALEBITS))];
64
73.6M
      outptr[RGB_BLUE] =  range_limit[y + Cbbtab[cb]];
65
      /* Set unused byte to 0xFF so it can be interpreted as an opaque */
66
      /* alpha channel value */
67
#ifdef RGB_ALPHA
68
73.6M
      outptr[RGB_ALPHA] = 0xFF;
69
#endif
70
73.6M
      outptr += RGB_PIXELSIZE;
71
73.6M
    }
72
1.10M
  }
73
1.10M
}
Unexecuted instantiation: jdcolor.c:ycc_extrgb_convert_internal
jdcolor.c:ycc_extrgbx_convert_internal
Line
Count
Source
34
15.0k
{
35
15.0k
  my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
36
15.0k
  register int y, cb, cr;
37
15.0k
  register JSAMPROW outptr;
38
15.0k
  register JSAMPROW inptr0, inptr1, inptr2;
39
15.0k
  register JDIMENSION col;
40
15.0k
  JDIMENSION num_cols = cinfo->output_width;
41
  /* copy these pointers into registers if possible */
42
15.0k
  register JSAMPLE *range_limit = cinfo->sample_range_limit;
43
15.0k
  register int *Crrtab = cconvert->Cr_r_tab;
44
15.0k
  register int *Cbbtab = cconvert->Cb_b_tab;
45
15.0k
  register JLONG *Crgtab = cconvert->Cr_g_tab;
46
15.0k
  register JLONG *Cbgtab = cconvert->Cb_g_tab;
47
15.0k
  SHIFT_TEMPS
48
49
30.0k
  while (--num_rows >= 0) {
50
15.0k
    inptr0 = input_buf[0][input_row];
51
15.0k
    inptr1 = input_buf[1][input_row];
52
15.0k
    inptr2 = input_buf[2][input_row];
53
15.0k
    input_row++;
54
15.0k
    outptr = *output_buf++;
55
176k
    for (col = 0; col < num_cols; col++) {
56
161k
      y  = inptr0[col];
57
161k
      cb = inptr1[col];
58
161k
      cr = inptr2[col];
59
      /* Range-limiting is essential due to noise introduced by DCT losses. */
60
161k
      outptr[RGB_RED] =   range_limit[y + Crrtab[cr]];
61
161k
      outptr[RGB_GREEN] = range_limit[y +
62
161k
                              ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
63
161k
                                                SCALEBITS))];
64
161k
      outptr[RGB_BLUE] =  range_limit[y + Cbbtab[cb]];
65
      /* Set unused byte to 0xFF so it can be interpreted as an opaque */
66
      /* alpha channel value */
67
161k
#ifdef RGB_ALPHA
68
161k
      outptr[RGB_ALPHA] = 0xFF;
69
161k
#endif
70
161k
      outptr += RGB_PIXELSIZE;
71
161k
    }
72
15.0k
  }
73
15.0k
}
Unexecuted instantiation: jdcolor.c:ycc_extbgr_convert_internal
jdcolor.c:ycc_extbgrx_convert_internal
Line
Count
Source
34
1.09M
{
35
1.09M
  my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
36
1.09M
  register int y, cb, cr;
37
1.09M
  register JSAMPROW outptr;
38
1.09M
  register JSAMPROW inptr0, inptr1, inptr2;
39
1.09M
  register JDIMENSION col;
40
1.09M
  JDIMENSION num_cols = cinfo->output_width;
41
  /* copy these pointers into registers if possible */
42
1.09M
  register JSAMPLE *range_limit = cinfo->sample_range_limit;
43
1.09M
  register int *Crrtab = cconvert->Cr_r_tab;
44
1.09M
  register int *Cbbtab = cconvert->Cb_b_tab;
45
1.09M
  register JLONG *Crgtab = cconvert->Cr_g_tab;
46
1.09M
  register JLONG *Cbgtab = cconvert->Cb_g_tab;
47
1.09M
  SHIFT_TEMPS
48
49
2.18M
  while (--num_rows >= 0) {
50
1.09M
    inptr0 = input_buf[0][input_row];
51
1.09M
    inptr1 = input_buf[1][input_row];
52
1.09M
    inptr2 = input_buf[2][input_row];
53
1.09M
    input_row++;
54
1.09M
    outptr = *output_buf++;
55
74.5M
    for (col = 0; col < num_cols; col++) {
56
73.5M
      y  = inptr0[col];
57
73.5M
      cb = inptr1[col];
58
73.5M
      cr = inptr2[col];
59
      /* Range-limiting is essential due to noise introduced by DCT losses. */
60
73.5M
      outptr[RGB_RED] =   range_limit[y + Crrtab[cr]];
61
73.5M
      outptr[RGB_GREEN] = range_limit[y +
62
73.5M
                              ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
63
73.5M
                                                SCALEBITS))];
64
73.5M
      outptr[RGB_BLUE] =  range_limit[y + Cbbtab[cb]];
65
      /* Set unused byte to 0xFF so it can be interpreted as an opaque */
66
      /* alpha channel value */
67
73.5M
#ifdef RGB_ALPHA
68
73.5M
      outptr[RGB_ALPHA] = 0xFF;
69
73.5M
#endif
70
73.5M
      outptr += RGB_PIXELSIZE;
71
73.5M
    }
72
1.09M
  }
73
1.09M
}
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
85.8k
{
88
85.8k
  register JSAMPROW inptr, outptr;
89
85.8k
  register JDIMENSION col;
90
85.8k
  JDIMENSION num_cols = cinfo->output_width;
91
92
171k
  while (--num_rows >= 0) {
93
85.8k
    inptr = input_buf[0][input_row++];
94
85.8k
    outptr = *output_buf++;
95
1.82M
    for (col = 0; col < num_cols; col++) {
96
1.74M
      outptr[RGB_RED] = outptr[RGB_GREEN] = outptr[RGB_BLUE] = inptr[col];
97
      /* Set unused byte to 0xFF so it can be interpreted as an opaque */
98
      /* alpha channel value */
99
#ifdef RGB_ALPHA
100
1.74M
      outptr[RGB_ALPHA] = 0xFF;
101
#endif
102
1.74M
      outptr += RGB_PIXELSIZE;
103
1.74M
    }
104
85.8k
  }
105
85.8k
}
Unexecuted instantiation: jdcolor.c:gray_extrgb_convert_internal
jdcolor.c:gray_extrgbx_convert_internal
Line
Count
Source
87
85.8k
{
88
85.8k
  register JSAMPROW inptr, outptr;
89
85.8k
  register JDIMENSION col;
90
85.8k
  JDIMENSION num_cols = cinfo->output_width;
91
92
171k
  while (--num_rows >= 0) {
93
85.8k
    inptr = input_buf[0][input_row++];
94
85.8k
    outptr = *output_buf++;
95
1.82M
    for (col = 0; col < num_cols; col++) {
96
1.74M
      outptr[RGB_RED] = outptr[RGB_GREEN] = outptr[RGB_BLUE] = inptr[col];
97
      /* Set unused byte to 0xFF so it can be interpreted as an opaque */
98
      /* alpha channel value */
99
1.74M
#ifdef RGB_ALPHA
100
1.74M
      outptr[RGB_ALPHA] = 0xFF;
101
1.74M
#endif
102
1.74M
      outptr += RGB_PIXELSIZE;
103
1.74M
    }
104
85.8k
  }
105
85.8k
}
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
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
47.0k
{
118
47.0k
  register JSAMPROW inptr0, inptr1, inptr2;
119
47.0k
  register JSAMPROW outptr;
120
47.0k
  register JDIMENSION col;
121
47.0k
  JDIMENSION num_cols = cinfo->output_width;
122
123
94.0k
  while (--num_rows >= 0) {
124
47.0k
    inptr0 = input_buf[0][input_row];
125
47.0k
    inptr1 = input_buf[1][input_row];
126
47.0k
    inptr2 = input_buf[2][input_row];
127
47.0k
    input_row++;
128
47.0k
    outptr = *output_buf++;
129
2.43M
    for (col = 0; col < num_cols; col++) {
130
2.38M
      outptr[RGB_RED] = inptr0[col];
131
2.38M
      outptr[RGB_GREEN] = inptr1[col];
132
2.38M
      outptr[RGB_BLUE] = inptr2[col];
133
      /* Set unused byte to 0xFF so it can be interpreted as an opaque */
134
      /* alpha channel value */
135
#ifdef RGB_ALPHA
136
2.38M
      outptr[RGB_ALPHA] = 0xFF;
137
#endif
138
2.38M
      outptr += RGB_PIXELSIZE;
139
2.38M
    }
140
47.0k
  }
141
47.0k
}
Unexecuted instantiation: jdcolor.c:rgb_extrgb_convert_internal
jdcolor.c:rgb_extrgbx_convert_internal
Line
Count
Source
117
5.10k
{
118
5.10k
  register JSAMPROW inptr0, inptr1, inptr2;
119
5.10k
  register JSAMPROW outptr;
120
5.10k
  register JDIMENSION col;
121
5.10k
  JDIMENSION num_cols = cinfo->output_width;
122
123
10.2k
  while (--num_rows >= 0) {
124
5.10k
    inptr0 = input_buf[0][input_row];
125
5.10k
    inptr1 = input_buf[1][input_row];
126
5.10k
    inptr2 = input_buf[2][input_row];
127
5.10k
    input_row++;
128
5.10k
    outptr = *output_buf++;
129
102k
    for (col = 0; col < num_cols; col++) {
130
97.4k
      outptr[RGB_RED] = inptr0[col];
131
97.4k
      outptr[RGB_GREEN] = inptr1[col];
132
97.4k
      outptr[RGB_BLUE] = inptr2[col];
133
      /* Set unused byte to 0xFF so it can be interpreted as an opaque */
134
      /* alpha channel value */
135
97.4k
#ifdef RGB_ALPHA
136
97.4k
      outptr[RGB_ALPHA] = 0xFF;
137
97.4k
#endif
138
97.4k
      outptr += RGB_PIXELSIZE;
139
97.4k
    }
140
5.10k
  }
141
5.10k
}
Unexecuted instantiation: jdcolor.c:rgb_extbgr_convert_internal
jdcolor.c:rgb_extbgrx_convert_internal
Line
Count
Source
117
41.9k
{
118
41.9k
  register JSAMPROW inptr0, inptr1, inptr2;
119
41.9k
  register JSAMPROW outptr;
120
41.9k
  register JDIMENSION col;
121
41.9k
  JDIMENSION num_cols = cinfo->output_width;
122
123
83.8k
  while (--num_rows >= 0) {
124
41.9k
    inptr0 = input_buf[0][input_row];
125
41.9k
    inptr1 = input_buf[1][input_row];
126
41.9k
    inptr2 = input_buf[2][input_row];
127
41.9k
    input_row++;
128
41.9k
    outptr = *output_buf++;
129
2.33M
    for (col = 0; col < num_cols; col++) {
130
2.29M
      outptr[RGB_RED] = inptr0[col];
131
2.29M
      outptr[RGB_GREEN] = inptr1[col];
132
2.29M
      outptr[RGB_BLUE] = inptr2[col];
133
      /* Set unused byte to 0xFF so it can be interpreted as an opaque */
134
      /* alpha channel value */
135
2.29M
#ifdef RGB_ALPHA
136
2.29M
      outptr[RGB_ALPHA] = 0xFF;
137
2.29M
#endif
138
2.29M
      outptr += RGB_PIXELSIZE;
139
2.29M
    }
140
41.9k
  }
141
41.9k
}
Unexecuted instantiation: jdcolor.c:rgb_extxbgr_convert_internal
Unexecuted instantiation: jdcolor.c:rgb_extxrgb_convert_internal
Unexecuted instantiation: jdcolor.c:rgb_rgb_convert_internal