Coverage Report

Created: 2023-06-07 06:03

/src/libjpeg-turbo.main/jccolext.c
Line
Count
Source
1
/*
2
 * jccolext.c
3
 *
4
 * This file was part of the Independent JPEG Group's software:
5
 * Copyright (C) 1991-1996, Thomas G. Lane.
6
 * libjpeg-turbo Modifications:
7
 * Copyright (C) 2009-2012, 2015, 2022, D. R. Commander.
8
 * For conditions of distribution and use, see the accompanying README.ijg
9
 * file.
10
 *
11
 * This file contains input colorspace conversion routines.
12
 */
13
14
15
/* This file is included by jccolor.c */
16
17
18
/*
19
 * Convert some rows of samples to the JPEG colorspace.
20
 *
21
 * Note that we change from the application's interleaved-pixel format
22
 * to our internal noninterleaved, one-plane-per-component format.
23
 * The input buffer is therefore three times as wide as the output buffer.
24
 *
25
 * A starting row offset is provided only for the output buffer.  The caller
26
 * can easily adjust the passed input_buf value to accommodate any row
27
 * offset required on that side.
28
 */
29
30
INLINE
31
LOCAL(void)
32
rgb_ycc_convert_internal(j_compress_ptr cinfo, _JSAMPARRAY input_buf,
33
                         _JSAMPIMAGE output_buf, JDIMENSION output_row,
34
                         int num_rows)
35
50.9M
{
36
50.9M
#if BITS_IN_JSAMPLE != 16
37
50.9M
  my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
38
50.9M
  register int r, g, b;
39
50.9M
  register JLONG *ctab = cconvert->rgb_ycc_tab;
40
50.9M
  register _JSAMPROW inptr;
41
50.9M
  register _JSAMPROW outptr0, outptr1, outptr2;
42
50.9M
  register JDIMENSION col;
43
50.9M
  JDIMENSION num_cols = cinfo->image_width;
44
45
109M
  while (--num_rows >= 0) {
46
58.1M
    inptr = *input_buf++;
47
58.1M
    outptr0 = output_buf[0][output_row];
48
58.1M
    outptr1 = output_buf[1][output_row];
49
58.1M
    outptr2 = output_buf[2][output_row];
50
58.1M
    output_row++;
51
159M
    for (col = 0; col < num_cols; col++) {
52
101M
      r = RANGE_LIMIT(inptr[RGB_RED]);
53
101M
      g = RANGE_LIMIT(inptr[RGB_GREEN]);
54
101M
      b = RANGE_LIMIT(inptr[RGB_BLUE]);
55
101M
      inptr += RGB_PIXELSIZE;
56
      /* If the inputs are 0.._MAXJSAMPLE, the outputs of these equations
57
       * must be too; we do not need an explicit range-limiting operation.
58
       * Hence the value being shifted is never negative, and we don't
59
       * need the general RIGHT_SHIFT macro.
60
       */
61
      /* Y */
62
101M
      outptr0[col] = (_JSAMPLE)((ctab[r + R_Y_OFF] + ctab[g + G_Y_OFF] +
63
101M
                                 ctab[b + B_Y_OFF]) >> SCALEBITS);
64
      /* Cb */
65
101M
      outptr1[col] = (_JSAMPLE)((ctab[r + R_CB_OFF] + ctab[g + G_CB_OFF] +
66
101M
                                 ctab[b + B_CB_OFF]) >> SCALEBITS);
67
      /* Cr */
68
101M
      outptr2[col] = (_JSAMPLE)((ctab[r + R_CR_OFF] + ctab[g + G_CR_OFF] +
69
101M
                                 ctab[b + B_CR_OFF]) >> SCALEBITS);
70
101M
    }
71
58.1M
  }
72
#else
73
  ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
74
#endif
75
50.9M
}
jccolor.c:extrgb_ycc_convert_internal
Line
Count
Source
35
14.5M
{
36
14.5M
#if BITS_IN_JSAMPLE != 16
37
14.5M
  my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
38
14.5M
  register int r, g, b;
39
14.5M
  register JLONG *ctab = cconvert->rgb_ycc_tab;
40
14.5M
  register _JSAMPROW inptr;
41
14.5M
  register _JSAMPROW outptr0, outptr1, outptr2;
42
14.5M
  register JDIMENSION col;
43
14.5M
  JDIMENSION num_cols = cinfo->image_width;
44
45
29.0M
  while (--num_rows >= 0) {
46
14.5M
    inptr = *input_buf++;
47
14.5M
    outptr0 = output_buf[0][output_row];
48
14.5M
    outptr1 = output_buf[1][output_row];
49
14.5M
    outptr2 = output_buf[2][output_row];
50
14.5M
    output_row++;
51
39.8M
    for (col = 0; col < num_cols; col++) {
52
25.3M
      r = RANGE_LIMIT(inptr[RGB_RED]);
53
25.3M
      g = RANGE_LIMIT(inptr[RGB_GREEN]);
54
25.3M
      b = RANGE_LIMIT(inptr[RGB_BLUE]);
55
25.3M
      inptr += RGB_PIXELSIZE;
56
      /* If the inputs are 0.._MAXJSAMPLE, the outputs of these equations
57
       * must be too; we do not need an explicit range-limiting operation.
58
       * Hence the value being shifted is never negative, and we don't
59
       * need the general RIGHT_SHIFT macro.
60
       */
61
      /* Y */
62
25.3M
      outptr0[col] = (_JSAMPLE)((ctab[r + R_Y_OFF] + ctab[g + G_Y_OFF] +
63
25.3M
                                 ctab[b + B_Y_OFF]) >> SCALEBITS);
64
      /* Cb */
65
25.3M
      outptr1[col] = (_JSAMPLE)((ctab[r + R_CB_OFF] + ctab[g + G_CB_OFF] +
66
25.3M
                                 ctab[b + B_CB_OFF]) >> SCALEBITS);
67
      /* Cr */
68
25.3M
      outptr2[col] = (_JSAMPLE)((ctab[r + R_CR_OFF] + ctab[g + G_CR_OFF] +
69
25.3M
                                 ctab[b + B_CR_OFF]) >> SCALEBITS);
70
25.3M
    }
71
14.5M
  }
72
#else
73
  ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
74
#endif
75
14.5M
}
jccolor.c:extrgbx_ycc_convert_internal
Line
Count
Source
35
7.27M
{
36
7.27M
#if BITS_IN_JSAMPLE != 16
37
7.27M
  my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
38
7.27M
  register int r, g, b;
39
7.27M
  register JLONG *ctab = cconvert->rgb_ycc_tab;
40
7.27M
  register _JSAMPROW inptr;
41
7.27M
  register _JSAMPROW outptr0, outptr1, outptr2;
42
7.27M
  register JDIMENSION col;
43
7.27M
  JDIMENSION num_cols = cinfo->image_width;
44
45
21.8M
  while (--num_rows >= 0) {
46
14.5M
    inptr = *input_buf++;
47
14.5M
    outptr0 = output_buf[0][output_row];
48
14.5M
    outptr1 = output_buf[1][output_row];
49
14.5M
    outptr2 = output_buf[2][output_row];
50
14.5M
    output_row++;
51
39.8M
    for (col = 0; col < num_cols; col++) {
52
25.3M
      r = RANGE_LIMIT(inptr[RGB_RED]);
53
25.3M
      g = RANGE_LIMIT(inptr[RGB_GREEN]);
54
25.3M
      b = RANGE_LIMIT(inptr[RGB_BLUE]);
55
25.3M
      inptr += RGB_PIXELSIZE;
56
      /* If the inputs are 0.._MAXJSAMPLE, the outputs of these equations
57
       * must be too; we do not need an explicit range-limiting operation.
58
       * Hence the value being shifted is never negative, and we don't
59
       * need the general RIGHT_SHIFT macro.
60
       */
61
      /* Y */
62
25.3M
      outptr0[col] = (_JSAMPLE)((ctab[r + R_Y_OFF] + ctab[g + G_Y_OFF] +
63
25.3M
                                 ctab[b + B_Y_OFF]) >> SCALEBITS);
64
      /* Cb */
65
25.3M
      outptr1[col] = (_JSAMPLE)((ctab[r + R_CB_OFF] + ctab[g + G_CB_OFF] +
66
25.3M
                                 ctab[b + B_CB_OFF]) >> SCALEBITS);
67
      /* Cr */
68
25.3M
      outptr2[col] = (_JSAMPLE)((ctab[r + R_CR_OFF] + ctab[g + G_CR_OFF] +
69
25.3M
                                 ctab[b + B_CR_OFF]) >> SCALEBITS);
70
25.3M
    }
71
14.5M
  }
72
#else
73
  ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
74
#endif
75
7.27M
}
jccolor.c:extbgr_ycc_convert_internal
Line
Count
Source
35
14.5M
{
36
14.5M
#if BITS_IN_JSAMPLE != 16
37
14.5M
  my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
38
14.5M
  register int r, g, b;
39
14.5M
  register JLONG *ctab = cconvert->rgb_ycc_tab;
40
14.5M
  register _JSAMPROW inptr;
41
14.5M
  register _JSAMPROW outptr0, outptr1, outptr2;
42
14.5M
  register JDIMENSION col;
43
14.5M
  JDIMENSION num_cols = cinfo->image_width;
44
45
29.0M
  while (--num_rows >= 0) {
46
14.5M
    inptr = *input_buf++;
47
14.5M
    outptr0 = output_buf[0][output_row];
48
14.5M
    outptr1 = output_buf[1][output_row];
49
14.5M
    outptr2 = output_buf[2][output_row];
50
14.5M
    output_row++;
51
39.8M
    for (col = 0; col < num_cols; col++) {
52
25.3M
      r = RANGE_LIMIT(inptr[RGB_RED]);
53
25.3M
      g = RANGE_LIMIT(inptr[RGB_GREEN]);
54
25.3M
      b = RANGE_LIMIT(inptr[RGB_BLUE]);
55
25.3M
      inptr += RGB_PIXELSIZE;
56
      /* If the inputs are 0.._MAXJSAMPLE, the outputs of these equations
57
       * must be too; we do not need an explicit range-limiting operation.
58
       * Hence the value being shifted is never negative, and we don't
59
       * need the general RIGHT_SHIFT macro.
60
       */
61
      /* Y */
62
25.3M
      outptr0[col] = (_JSAMPLE)((ctab[r + R_Y_OFF] + ctab[g + G_Y_OFF] +
63
25.3M
                                 ctab[b + B_Y_OFF]) >> SCALEBITS);
64
      /* Cb */
65
25.3M
      outptr1[col] = (_JSAMPLE)((ctab[r + R_CB_OFF] + ctab[g + G_CB_OFF] +
66
25.3M
                                 ctab[b + B_CB_OFF]) >> SCALEBITS);
67
      /* Cr */
68
25.3M
      outptr2[col] = (_JSAMPLE)((ctab[r + R_CR_OFF] + ctab[g + G_CR_OFF] +
69
25.3M
                                 ctab[b + B_CR_OFF]) >> SCALEBITS);
70
25.3M
    }
71
14.5M
  }
72
#else
73
  ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
74
#endif
75
14.5M
}
jccolor.c:extbgrx_ycc_convert_internal
Line
Count
Source
35
14.5M
{
36
14.5M
#if BITS_IN_JSAMPLE != 16
37
14.5M
  my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
38
14.5M
  register int r, g, b;
39
14.5M
  register JLONG *ctab = cconvert->rgb_ycc_tab;
40
14.5M
  register _JSAMPROW inptr;
41
14.5M
  register _JSAMPROW outptr0, outptr1, outptr2;
42
14.5M
  register JDIMENSION col;
43
14.5M
  JDIMENSION num_cols = cinfo->image_width;
44
45
29.0M
  while (--num_rows >= 0) {
46
14.5M
    inptr = *input_buf++;
47
14.5M
    outptr0 = output_buf[0][output_row];
48
14.5M
    outptr1 = output_buf[1][output_row];
49
14.5M
    outptr2 = output_buf[2][output_row];
50
14.5M
    output_row++;
51
39.8M
    for (col = 0; col < num_cols; col++) {
52
25.3M
      r = RANGE_LIMIT(inptr[RGB_RED]);
53
25.3M
      g = RANGE_LIMIT(inptr[RGB_GREEN]);
54
25.3M
      b = RANGE_LIMIT(inptr[RGB_BLUE]);
55
25.3M
      inptr += RGB_PIXELSIZE;
56
      /* If the inputs are 0.._MAXJSAMPLE, the outputs of these equations
57
       * must be too; we do not need an explicit range-limiting operation.
58
       * Hence the value being shifted is never negative, and we don't
59
       * need the general RIGHT_SHIFT macro.
60
       */
61
      /* Y */
62
25.3M
      outptr0[col] = (_JSAMPLE)((ctab[r + R_Y_OFF] + ctab[g + G_Y_OFF] +
63
25.3M
                                 ctab[b + B_Y_OFF]) >> SCALEBITS);
64
      /* Cb */
65
25.3M
      outptr1[col] = (_JSAMPLE)((ctab[r + R_CB_OFF] + ctab[g + G_CB_OFF] +
66
25.3M
                                 ctab[b + B_CB_OFF]) >> SCALEBITS);
67
      /* Cr */
68
25.3M
      outptr2[col] = (_JSAMPLE)((ctab[r + R_CR_OFF] + ctab[g + G_CR_OFF] +
69
25.3M
                                 ctab[b + B_CR_OFF]) >> SCALEBITS);
70
25.3M
    }
71
14.5M
  }
72
#else
73
  ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
74
#endif
75
14.5M
}
Unexecuted instantiation: jccolor.c:extxbgr_ycc_convert_internal
Unexecuted instantiation: jccolor.c:extxrgb_ycc_convert_internal
Unexecuted instantiation: jccolor.c:rgb_ycc_convert_internal
76
77
78
/**************** Cases other than RGB -> YCbCr **************/
79
80
81
/*
82
 * Convert some rows of samples to the JPEG colorspace.
83
 * This version handles RGB->grayscale conversion, which is the same
84
 * as the RGB->Y portion of RGB->YCbCr.
85
 * We assume rgb_ycc_start has been called (we only use the Y tables).
86
 */
87
88
INLINE
89
LOCAL(void)
90
rgb_gray_convert_internal(j_compress_ptr cinfo, _JSAMPARRAY input_buf,
91
                          _JSAMPIMAGE output_buf, JDIMENSION output_row,
92
                          int num_rows)
93
14.5M
{
94
14.5M
#if BITS_IN_JSAMPLE != 16
95
14.5M
  my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
96
14.5M
  register int r, g, b;
97
14.5M
  register JLONG *ctab = cconvert->rgb_ycc_tab;
98
14.5M
  register _JSAMPROW inptr;
99
14.5M
  register _JSAMPROW outptr;
100
14.5M
  register JDIMENSION col;
101
14.5M
  JDIMENSION num_cols = cinfo->image_width;
102
103
29.0M
  while (--num_rows >= 0) {
104
14.5M
    inptr = *input_buf++;
105
14.5M
    outptr = output_buf[0][output_row];
106
14.5M
    output_row++;
107
39.8M
    for (col = 0; col < num_cols; col++) {
108
25.3M
      r = RANGE_LIMIT(inptr[RGB_RED]);
109
25.3M
      g = RANGE_LIMIT(inptr[RGB_GREEN]);
110
25.3M
      b = RANGE_LIMIT(inptr[RGB_BLUE]);
111
25.3M
      inptr += RGB_PIXELSIZE;
112
      /* Y */
113
25.3M
      outptr[col] = (_JSAMPLE)((ctab[r + R_Y_OFF] + ctab[g + G_Y_OFF] +
114
25.3M
                                ctab[b + B_Y_OFF]) >> SCALEBITS);
115
25.3M
    }
116
14.5M
  }
117
#else
118
  ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
119
#endif
120
14.5M
}
Unexecuted instantiation: jccolor.c:extrgb_gray_convert_internal
Unexecuted instantiation: jccolor.c:extrgbx_gray_convert_internal
Unexecuted instantiation: jccolor.c:extbgr_gray_convert_internal
Unexecuted instantiation: jccolor.c:extbgrx_gray_convert_internal
Unexecuted instantiation: jccolor.c:extxbgr_gray_convert_internal
jccolor.c:extxrgb_gray_convert_internal
Line
Count
Source
93
14.5M
{
94
14.5M
#if BITS_IN_JSAMPLE != 16
95
14.5M
  my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
96
14.5M
  register int r, g, b;
97
14.5M
  register JLONG *ctab = cconvert->rgb_ycc_tab;
98
14.5M
  register _JSAMPROW inptr;
99
14.5M
  register _JSAMPROW outptr;
100
14.5M
  register JDIMENSION col;
101
14.5M
  JDIMENSION num_cols = cinfo->image_width;
102
103
29.0M
  while (--num_rows >= 0) {
104
14.5M
    inptr = *input_buf++;
105
14.5M
    outptr = output_buf[0][output_row];
106
14.5M
    output_row++;
107
39.8M
    for (col = 0; col < num_cols; col++) {
108
25.3M
      r = RANGE_LIMIT(inptr[RGB_RED]);
109
25.3M
      g = RANGE_LIMIT(inptr[RGB_GREEN]);
110
25.3M
      b = RANGE_LIMIT(inptr[RGB_BLUE]);
111
25.3M
      inptr += RGB_PIXELSIZE;
112
      /* Y */
113
25.3M
      outptr[col] = (_JSAMPLE)((ctab[r + R_Y_OFF] + ctab[g + G_Y_OFF] +
114
25.3M
                                ctab[b + B_Y_OFF]) >> SCALEBITS);
115
25.3M
    }
116
14.5M
  }
117
#else
118
  ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
119
#endif
120
14.5M
}
Unexecuted instantiation: jccolor.c:rgb_gray_convert_internal
121
122
123
/*
124
 * Convert some rows of samples to the JPEG colorspace.
125
 * This version handles extended RGB->plain RGB conversion
126
 */
127
128
INLINE
129
LOCAL(void)
130
rgb_rgb_convert_internal(j_compress_ptr cinfo, _JSAMPARRAY input_buf,
131
                         _JSAMPIMAGE output_buf, JDIMENSION output_row,
132
                         int num_rows)
133
16.3M
{
134
16.3M
  register _JSAMPROW inptr;
135
16.3M
  register _JSAMPROW outptr0, outptr1, outptr2;
136
16.3M
  register JDIMENSION col;
137
16.3M
  JDIMENSION num_cols = cinfo->image_width;
138
139
32.6M
  while (--num_rows >= 0) {
140
16.3M
    inptr = *input_buf++;
141
16.3M
    outptr0 = output_buf[0][output_row];
142
16.3M
    outptr1 = output_buf[1][output_row];
143
16.3M
    outptr2 = output_buf[2][output_row];
144
16.3M
    output_row++;
145
102M
    for (col = 0; col < num_cols; col++) {
146
86.4M
      outptr0[col] = inptr[RGB_RED];
147
86.4M
      outptr1[col] = inptr[RGB_GREEN];
148
86.4M
      outptr2[col] = inptr[RGB_BLUE];
149
86.4M
      inptr += RGB_PIXELSIZE;
150
86.4M
    }
151
16.3M
  }
152
16.3M
}
Unexecuted instantiation: jccolor.c:extrgb_rgb_convert_internal
jccolor.c:extrgbx_rgb_convert_internal
Line
Count
Source
133
4.07M
{
134
4.07M
  register _JSAMPROW inptr;
135
4.07M
  register _JSAMPROW outptr0, outptr1, outptr2;
136
4.07M
  register JDIMENSION col;
137
4.07M
  JDIMENSION num_cols = cinfo->image_width;
138
139
8.15M
  while (--num_rows >= 0) {
140
4.07M
    inptr = *input_buf++;
141
4.07M
    outptr0 = output_buf[0][output_row];
142
4.07M
    outptr1 = output_buf[1][output_row];
143
4.07M
    outptr2 = output_buf[2][output_row];
144
4.07M
    output_row++;
145
25.6M
    for (col = 0; col < num_cols; col++) {
146
21.6M
      outptr0[col] = inptr[RGB_RED];
147
21.6M
      outptr1[col] = inptr[RGB_GREEN];
148
21.6M
      outptr2[col] = inptr[RGB_BLUE];
149
21.6M
      inptr += RGB_PIXELSIZE;
150
21.6M
    }
151
4.07M
  }
152
4.07M
}
jccolor.c:extbgr_rgb_convert_internal
Line
Count
Source
133
4.07M
{
134
4.07M
  register _JSAMPROW inptr;
135
4.07M
  register _JSAMPROW outptr0, outptr1, outptr2;
136
4.07M
  register JDIMENSION col;
137
4.07M
  JDIMENSION num_cols = cinfo->image_width;
138
139
8.15M
  while (--num_rows >= 0) {
140
4.07M
    inptr = *input_buf++;
141
4.07M
    outptr0 = output_buf[0][output_row];
142
4.07M
    outptr1 = output_buf[1][output_row];
143
4.07M
    outptr2 = output_buf[2][output_row];
144
4.07M
    output_row++;
145
25.6M
    for (col = 0; col < num_cols; col++) {
146
21.6M
      outptr0[col] = inptr[RGB_RED];
147
21.6M
      outptr1[col] = inptr[RGB_GREEN];
148
21.6M
      outptr2[col] = inptr[RGB_BLUE];
149
21.6M
      inptr += RGB_PIXELSIZE;
150
21.6M
    }
151
4.07M
  }
152
4.07M
}
jccolor.c:extbgrx_rgb_convert_internal
Line
Count
Source
133
4.07M
{
134
4.07M
  register _JSAMPROW inptr;
135
4.07M
  register _JSAMPROW outptr0, outptr1, outptr2;
136
4.07M
  register JDIMENSION col;
137
4.07M
  JDIMENSION num_cols = cinfo->image_width;
138
139
8.15M
  while (--num_rows >= 0) {
140
4.07M
    inptr = *input_buf++;
141
4.07M
    outptr0 = output_buf[0][output_row];
142
4.07M
    outptr1 = output_buf[1][output_row];
143
4.07M
    outptr2 = output_buf[2][output_row];
144
4.07M
    output_row++;
145
25.6M
    for (col = 0; col < num_cols; col++) {
146
21.6M
      outptr0[col] = inptr[RGB_RED];
147
21.6M
      outptr1[col] = inptr[RGB_GREEN];
148
21.6M
      outptr2[col] = inptr[RGB_BLUE];
149
21.6M
      inptr += RGB_PIXELSIZE;
150
21.6M
    }
151
4.07M
  }
152
4.07M
}
Unexecuted instantiation: jccolor.c:extxbgr_rgb_convert_internal
jccolor.c:extxrgb_rgb_convert_internal
Line
Count
Source
133
4.07M
{
134
4.07M
  register _JSAMPROW inptr;
135
4.07M
  register _JSAMPROW outptr0, outptr1, outptr2;
136
4.07M
  register JDIMENSION col;
137
4.07M
  JDIMENSION num_cols = cinfo->image_width;
138
139
8.15M
  while (--num_rows >= 0) {
140
4.07M
    inptr = *input_buf++;
141
4.07M
    outptr0 = output_buf[0][output_row];
142
4.07M
    outptr1 = output_buf[1][output_row];
143
4.07M
    outptr2 = output_buf[2][output_row];
144
4.07M
    output_row++;
145
25.6M
    for (col = 0; col < num_cols; col++) {
146
21.6M
      outptr0[col] = inptr[RGB_RED];
147
21.6M
      outptr1[col] = inptr[RGB_GREEN];
148
21.6M
      outptr2[col] = inptr[RGB_BLUE];
149
21.6M
      inptr += RGB_PIXELSIZE;
150
21.6M
    }
151
4.07M
  }
152
4.07M
}
Unexecuted instantiation: jccolor.c:rgb_rgb_convert_internal