Coverage Report

Created: 2023-06-07 06:03

/src/libjpeg-turbo.2.1.x/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
  my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
37
50.9M
  register int r, g, b;
38
50.9M
  register JLONG *ctab = cconvert->rgb_ycc_tab;
39
50.9M
  register JSAMPROW inptr;
40
50.9M
  register JSAMPROW outptr0, outptr1, outptr2;
41
50.9M
  register JDIMENSION col;
42
50.9M
  JDIMENSION num_cols = cinfo->image_width;
43
44
109M
  while (--num_rows >= 0) {
45
58.1M
    inptr = *input_buf++;
46
58.1M
    outptr0 = output_buf[0][output_row];
47
58.1M
    outptr1 = output_buf[1][output_row];
48
58.1M
    outptr2 = output_buf[2][output_row];
49
58.1M
    output_row++;
50
159M
    for (col = 0; col < num_cols; col++) {
51
101M
      r = RANGE_LIMIT(inptr[RGB_RED]);
52
101M
      g = RANGE_LIMIT(inptr[RGB_GREEN]);
53
101M
      b = RANGE_LIMIT(inptr[RGB_BLUE]);
54
101M
      inptr += RGB_PIXELSIZE;
55
      /* If the inputs are 0..MAXJSAMPLE, the outputs of these equations
56
       * must be too; we do not need an explicit range-limiting operation.
57
       * Hence the value being shifted is never negative, and we don't
58
       * need the general RIGHT_SHIFT macro.
59
       */
60
      /* Y */
61
101M
      outptr0[col] = (JSAMPLE)((ctab[r + R_Y_OFF] + ctab[g + G_Y_OFF] +
62
101M
                                ctab[b + B_Y_OFF]) >> SCALEBITS);
63
      /* Cb */
64
101M
      outptr1[col] = (JSAMPLE)((ctab[r + R_CB_OFF] + ctab[g + G_CB_OFF] +
65
101M
                                ctab[b + B_CB_OFF]) >> SCALEBITS);
66
      /* Cr */
67
101M
      outptr2[col] = (JSAMPLE)((ctab[r + R_CR_OFF] + ctab[g + G_CR_OFF] +
68
101M
                                ctab[b + B_CR_OFF]) >> SCALEBITS);
69
101M
    }
70
58.1M
  }
71
50.9M
}
jccolor.c:extrgb_ycc_convert_internal
Line
Count
Source
35
14.5M
{
36
14.5M
  my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
37
14.5M
  register int r, g, b;
38
14.5M
  register JLONG *ctab = cconvert->rgb_ycc_tab;
39
14.5M
  register JSAMPROW inptr;
40
14.5M
  register JSAMPROW outptr0, outptr1, outptr2;
41
14.5M
  register JDIMENSION col;
42
14.5M
  JDIMENSION num_cols = cinfo->image_width;
43
44
29.0M
  while (--num_rows >= 0) {
45
14.5M
    inptr = *input_buf++;
46
14.5M
    outptr0 = output_buf[0][output_row];
47
14.5M
    outptr1 = output_buf[1][output_row];
48
14.5M
    outptr2 = output_buf[2][output_row];
49
14.5M
    output_row++;
50
39.8M
    for (col = 0; col < num_cols; col++) {
51
25.3M
      r = RANGE_LIMIT(inptr[RGB_RED]);
52
25.3M
      g = RANGE_LIMIT(inptr[RGB_GREEN]);
53
25.3M
      b = RANGE_LIMIT(inptr[RGB_BLUE]);
54
25.3M
      inptr += RGB_PIXELSIZE;
55
      /* If the inputs are 0..MAXJSAMPLE, the outputs of these equations
56
       * must be too; we do not need an explicit range-limiting operation.
57
       * Hence the value being shifted is never negative, and we don't
58
       * need the general RIGHT_SHIFT macro.
59
       */
60
      /* Y */
61
25.3M
      outptr0[col] = (JSAMPLE)((ctab[r + R_Y_OFF] + ctab[g + G_Y_OFF] +
62
25.3M
                                ctab[b + B_Y_OFF]) >> SCALEBITS);
63
      /* Cb */
64
25.3M
      outptr1[col] = (JSAMPLE)((ctab[r + R_CB_OFF] + ctab[g + G_CB_OFF] +
65
25.3M
                                ctab[b + B_CB_OFF]) >> SCALEBITS);
66
      /* Cr */
67
25.3M
      outptr2[col] = (JSAMPLE)((ctab[r + R_CR_OFF] + ctab[g + G_CR_OFF] +
68
25.3M
                                ctab[b + B_CR_OFF]) >> SCALEBITS);
69
25.3M
    }
70
14.5M
  }
71
14.5M
}
jccolor.c:extrgbx_ycc_convert_internal
Line
Count
Source
35
7.27M
{
36
7.27M
  my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
37
7.27M
  register int r, g, b;
38
7.27M
  register JLONG *ctab = cconvert->rgb_ycc_tab;
39
7.27M
  register JSAMPROW inptr;
40
7.27M
  register JSAMPROW outptr0, outptr1, outptr2;
41
7.27M
  register JDIMENSION col;
42
7.27M
  JDIMENSION num_cols = cinfo->image_width;
43
44
21.8M
  while (--num_rows >= 0) {
45
14.5M
    inptr = *input_buf++;
46
14.5M
    outptr0 = output_buf[0][output_row];
47
14.5M
    outptr1 = output_buf[1][output_row];
48
14.5M
    outptr2 = output_buf[2][output_row];
49
14.5M
    output_row++;
50
39.8M
    for (col = 0; col < num_cols; col++) {
51
25.3M
      r = RANGE_LIMIT(inptr[RGB_RED]);
52
25.3M
      g = RANGE_LIMIT(inptr[RGB_GREEN]);
53
25.3M
      b = RANGE_LIMIT(inptr[RGB_BLUE]);
54
25.3M
      inptr += RGB_PIXELSIZE;
55
      /* If the inputs are 0..MAXJSAMPLE, the outputs of these equations
56
       * must be too; we do not need an explicit range-limiting operation.
57
       * Hence the value being shifted is never negative, and we don't
58
       * need the general RIGHT_SHIFT macro.
59
       */
60
      /* Y */
61
25.3M
      outptr0[col] = (JSAMPLE)((ctab[r + R_Y_OFF] + ctab[g + G_Y_OFF] +
62
25.3M
                                ctab[b + B_Y_OFF]) >> SCALEBITS);
63
      /* Cb */
64
25.3M
      outptr1[col] = (JSAMPLE)((ctab[r + R_CB_OFF] + ctab[g + G_CB_OFF] +
65
25.3M
                                ctab[b + B_CB_OFF]) >> SCALEBITS);
66
      /* Cr */
67
25.3M
      outptr2[col] = (JSAMPLE)((ctab[r + R_CR_OFF] + ctab[g + G_CR_OFF] +
68
25.3M
                                ctab[b + B_CR_OFF]) >> SCALEBITS);
69
25.3M
    }
70
14.5M
  }
71
7.27M
}
jccolor.c:extbgr_ycc_convert_internal
Line
Count
Source
35
14.5M
{
36
14.5M
  my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
37
14.5M
  register int r, g, b;
38
14.5M
  register JLONG *ctab = cconvert->rgb_ycc_tab;
39
14.5M
  register JSAMPROW inptr;
40
14.5M
  register JSAMPROW outptr0, outptr1, outptr2;
41
14.5M
  register JDIMENSION col;
42
14.5M
  JDIMENSION num_cols = cinfo->image_width;
43
44
29.0M
  while (--num_rows >= 0) {
45
14.5M
    inptr = *input_buf++;
46
14.5M
    outptr0 = output_buf[0][output_row];
47
14.5M
    outptr1 = output_buf[1][output_row];
48
14.5M
    outptr2 = output_buf[2][output_row];
49
14.5M
    output_row++;
50
39.8M
    for (col = 0; col < num_cols; col++) {
51
25.3M
      r = RANGE_LIMIT(inptr[RGB_RED]);
52
25.3M
      g = RANGE_LIMIT(inptr[RGB_GREEN]);
53
25.3M
      b = RANGE_LIMIT(inptr[RGB_BLUE]);
54
25.3M
      inptr += RGB_PIXELSIZE;
55
      /* If the inputs are 0..MAXJSAMPLE, the outputs of these equations
56
       * must be too; we do not need an explicit range-limiting operation.
57
       * Hence the value being shifted is never negative, and we don't
58
       * need the general RIGHT_SHIFT macro.
59
       */
60
      /* Y */
61
25.3M
      outptr0[col] = (JSAMPLE)((ctab[r + R_Y_OFF] + ctab[g + G_Y_OFF] +
62
25.3M
                                ctab[b + B_Y_OFF]) >> SCALEBITS);
63
      /* Cb */
64
25.3M
      outptr1[col] = (JSAMPLE)((ctab[r + R_CB_OFF] + ctab[g + G_CB_OFF] +
65
25.3M
                                ctab[b + B_CB_OFF]) >> SCALEBITS);
66
      /* Cr */
67
25.3M
      outptr2[col] = (JSAMPLE)((ctab[r + R_CR_OFF] + ctab[g + G_CR_OFF] +
68
25.3M
                                ctab[b + B_CR_OFF]) >> SCALEBITS);
69
25.3M
    }
70
14.5M
  }
71
14.5M
}
jccolor.c:extbgrx_ycc_convert_internal
Line
Count
Source
35
14.5M
{
36
14.5M
  my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
37
14.5M
  register int r, g, b;
38
14.5M
  register JLONG *ctab = cconvert->rgb_ycc_tab;
39
14.5M
  register JSAMPROW inptr;
40
14.5M
  register JSAMPROW outptr0, outptr1, outptr2;
41
14.5M
  register JDIMENSION col;
42
14.5M
  JDIMENSION num_cols = cinfo->image_width;
43
44
29.0M
  while (--num_rows >= 0) {
45
14.5M
    inptr = *input_buf++;
46
14.5M
    outptr0 = output_buf[0][output_row];
47
14.5M
    outptr1 = output_buf[1][output_row];
48
14.5M
    outptr2 = output_buf[2][output_row];
49
14.5M
    output_row++;
50
39.8M
    for (col = 0; col < num_cols; col++) {
51
25.3M
      r = RANGE_LIMIT(inptr[RGB_RED]);
52
25.3M
      g = RANGE_LIMIT(inptr[RGB_GREEN]);
53
25.3M
      b = RANGE_LIMIT(inptr[RGB_BLUE]);
54
25.3M
      inptr += RGB_PIXELSIZE;
55
      /* If the inputs are 0..MAXJSAMPLE, the outputs of these equations
56
       * must be too; we do not need an explicit range-limiting operation.
57
       * Hence the value being shifted is never negative, and we don't
58
       * need the general RIGHT_SHIFT macro.
59
       */
60
      /* Y */
61
25.3M
      outptr0[col] = (JSAMPLE)((ctab[r + R_Y_OFF] + ctab[g + G_Y_OFF] +
62
25.3M
                                ctab[b + B_Y_OFF]) >> SCALEBITS);
63
      /* Cb */
64
25.3M
      outptr1[col] = (JSAMPLE)((ctab[r + R_CB_OFF] + ctab[g + G_CB_OFF] +
65
25.3M
                                ctab[b + B_CB_OFF]) >> SCALEBITS);
66
      /* Cr */
67
25.3M
      outptr2[col] = (JSAMPLE)((ctab[r + R_CR_OFF] + ctab[g + G_CR_OFF] +
68
25.3M
                                ctab[b + B_CR_OFF]) >> SCALEBITS);
69
25.3M
    }
70
14.5M
  }
71
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
72
73
74
/**************** Cases other than RGB -> YCbCr **************/
75
76
77
/*
78
 * Convert some rows of samples to the JPEG colorspace.
79
 * This version handles RGB->grayscale conversion, which is the same
80
 * as the RGB->Y portion of RGB->YCbCr.
81
 * We assume rgb_ycc_start has been called (we only use the Y tables).
82
 */
83
84
INLINE
85
LOCAL(void)
86
rgb_gray_convert_internal(j_compress_ptr cinfo, JSAMPARRAY input_buf,
87
                          JSAMPIMAGE output_buf, JDIMENSION output_row,
88
                          int num_rows)
89
14.5M
{
90
14.5M
  my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
91
14.5M
  register int r, g, b;
92
14.5M
  register JLONG *ctab = cconvert->rgb_ycc_tab;
93
14.5M
  register JSAMPROW inptr;
94
14.5M
  register JSAMPROW outptr;
95
14.5M
  register JDIMENSION col;
96
14.5M
  JDIMENSION num_cols = cinfo->image_width;
97
98
29.0M
  while (--num_rows >= 0) {
99
14.5M
    inptr = *input_buf++;
100
14.5M
    outptr = output_buf[0][output_row];
101
14.5M
    output_row++;
102
39.8M
    for (col = 0; col < num_cols; col++) {
103
25.3M
      r = RANGE_LIMIT(inptr[RGB_RED]);
104
25.3M
      g = RANGE_LIMIT(inptr[RGB_GREEN]);
105
25.3M
      b = RANGE_LIMIT(inptr[RGB_BLUE]);
106
25.3M
      inptr += RGB_PIXELSIZE;
107
      /* Y */
108
25.3M
      outptr[col] = (JSAMPLE)((ctab[r + R_Y_OFF] + ctab[g + G_Y_OFF] +
109
25.3M
                               ctab[b + B_Y_OFF]) >> SCALEBITS);
110
25.3M
    }
111
14.5M
  }
112
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
89
14.5M
{
90
14.5M
  my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
91
14.5M
  register int r, g, b;
92
14.5M
  register JLONG *ctab = cconvert->rgb_ycc_tab;
93
14.5M
  register JSAMPROW inptr;
94
14.5M
  register JSAMPROW outptr;
95
14.5M
  register JDIMENSION col;
96
14.5M
  JDIMENSION num_cols = cinfo->image_width;
97
98
29.0M
  while (--num_rows >= 0) {
99
14.5M
    inptr = *input_buf++;
100
14.5M
    outptr = output_buf[0][output_row];
101
14.5M
    output_row++;
102
39.8M
    for (col = 0; col < num_cols; col++) {
103
25.3M
      r = RANGE_LIMIT(inptr[RGB_RED]);
104
25.3M
      g = RANGE_LIMIT(inptr[RGB_GREEN]);
105
25.3M
      b = RANGE_LIMIT(inptr[RGB_BLUE]);
106
25.3M
      inptr += RGB_PIXELSIZE;
107
      /* Y */
108
25.3M
      outptr[col] = (JSAMPLE)((ctab[r + R_Y_OFF] + ctab[g + G_Y_OFF] +
109
25.3M
                               ctab[b + B_Y_OFF]) >> SCALEBITS);
110
25.3M
    }
111
14.5M
  }
112
14.5M
}
Unexecuted instantiation: jccolor.c:rgb_gray_convert_internal
113
114
115
/*
116
 * Convert some rows of samples to the JPEG colorspace.
117
 * This version handles extended RGB->plain RGB conversion
118
 */
119
120
INLINE
121
LOCAL(void)
122
rgb_rgb_convert_internal(j_compress_ptr cinfo, JSAMPARRAY input_buf,
123
                         JSAMPIMAGE output_buf, JDIMENSION output_row,
124
                         int num_rows)
125
16.3M
{
126
16.3M
  register JSAMPROW inptr;
127
16.3M
  register JSAMPROW outptr0, outptr1, outptr2;
128
16.3M
  register JDIMENSION col;
129
16.3M
  JDIMENSION num_cols = cinfo->image_width;
130
131
32.6M
  while (--num_rows >= 0) {
132
16.3M
    inptr = *input_buf++;
133
16.3M
    outptr0 = output_buf[0][output_row];
134
16.3M
    outptr1 = output_buf[1][output_row];
135
16.3M
    outptr2 = output_buf[2][output_row];
136
16.3M
    output_row++;
137
102M
    for (col = 0; col < num_cols; col++) {
138
86.4M
      outptr0[col] = inptr[RGB_RED];
139
86.4M
      outptr1[col] = inptr[RGB_GREEN];
140
86.4M
      outptr2[col] = inptr[RGB_BLUE];
141
86.4M
      inptr += RGB_PIXELSIZE;
142
86.4M
    }
143
16.3M
  }
144
16.3M
}
Unexecuted instantiation: jccolor.c:extrgb_rgb_convert_internal
jccolor.c:extrgbx_rgb_convert_internal
Line
Count
Source
125
4.07M
{
126
4.07M
  register JSAMPROW inptr;
127
4.07M
  register JSAMPROW outptr0, outptr1, outptr2;
128
4.07M
  register JDIMENSION col;
129
4.07M
  JDIMENSION num_cols = cinfo->image_width;
130
131
8.15M
  while (--num_rows >= 0) {
132
4.07M
    inptr = *input_buf++;
133
4.07M
    outptr0 = output_buf[0][output_row];
134
4.07M
    outptr1 = output_buf[1][output_row];
135
4.07M
    outptr2 = output_buf[2][output_row];
136
4.07M
    output_row++;
137
25.6M
    for (col = 0; col < num_cols; col++) {
138
21.6M
      outptr0[col] = inptr[RGB_RED];
139
21.6M
      outptr1[col] = inptr[RGB_GREEN];
140
21.6M
      outptr2[col] = inptr[RGB_BLUE];
141
21.6M
      inptr += RGB_PIXELSIZE;
142
21.6M
    }
143
4.07M
  }
144
4.07M
}
jccolor.c:extbgr_rgb_convert_internal
Line
Count
Source
125
4.07M
{
126
4.07M
  register JSAMPROW inptr;
127
4.07M
  register JSAMPROW outptr0, outptr1, outptr2;
128
4.07M
  register JDIMENSION col;
129
4.07M
  JDIMENSION num_cols = cinfo->image_width;
130
131
8.15M
  while (--num_rows >= 0) {
132
4.07M
    inptr = *input_buf++;
133
4.07M
    outptr0 = output_buf[0][output_row];
134
4.07M
    outptr1 = output_buf[1][output_row];
135
4.07M
    outptr2 = output_buf[2][output_row];
136
4.07M
    output_row++;
137
25.6M
    for (col = 0; col < num_cols; col++) {
138
21.6M
      outptr0[col] = inptr[RGB_RED];
139
21.6M
      outptr1[col] = inptr[RGB_GREEN];
140
21.6M
      outptr2[col] = inptr[RGB_BLUE];
141
21.6M
      inptr += RGB_PIXELSIZE;
142
21.6M
    }
143
4.07M
  }
144
4.07M
}
jccolor.c:extbgrx_rgb_convert_internal
Line
Count
Source
125
4.07M
{
126
4.07M
  register JSAMPROW inptr;
127
4.07M
  register JSAMPROW outptr0, outptr1, outptr2;
128
4.07M
  register JDIMENSION col;
129
4.07M
  JDIMENSION num_cols = cinfo->image_width;
130
131
8.15M
  while (--num_rows >= 0) {
132
4.07M
    inptr = *input_buf++;
133
4.07M
    outptr0 = output_buf[0][output_row];
134
4.07M
    outptr1 = output_buf[1][output_row];
135
4.07M
    outptr2 = output_buf[2][output_row];
136
4.07M
    output_row++;
137
25.6M
    for (col = 0; col < num_cols; col++) {
138
21.6M
      outptr0[col] = inptr[RGB_RED];
139
21.6M
      outptr1[col] = inptr[RGB_GREEN];
140
21.6M
      outptr2[col] = inptr[RGB_BLUE];
141
21.6M
      inptr += RGB_PIXELSIZE;
142
21.6M
    }
143
4.07M
  }
144
4.07M
}
Unexecuted instantiation: jccolor.c:extxbgr_rgb_convert_internal
jccolor.c:extxrgb_rgb_convert_internal
Line
Count
Source
125
4.07M
{
126
4.07M
  register JSAMPROW inptr;
127
4.07M
  register JSAMPROW outptr0, outptr1, outptr2;
128
4.07M
  register JDIMENSION col;
129
4.07M
  JDIMENSION num_cols = cinfo->image_width;
130
131
8.15M
  while (--num_rows >= 0) {
132
4.07M
    inptr = *input_buf++;
133
4.07M
    outptr0 = output_buf[0][output_row];
134
4.07M
    outptr1 = output_buf[1][output_row];
135
4.07M
    outptr2 = output_buf[2][output_row];
136
4.07M
    output_row++;
137
25.6M
    for (col = 0; col < num_cols; col++) {
138
21.6M
      outptr0[col] = inptr[RGB_RED];
139
21.6M
      outptr1[col] = inptr[RGB_GREEN];
140
21.6M
      outptr2[col] = inptr[RGB_BLUE];
141
21.6M
      inptr += RGB_PIXELSIZE;
142
21.6M
    }
143
4.07M
  }
144
4.07M
}
Unexecuted instantiation: jccolor.c:rgb_rgb_convert_internal