Coverage Report

Created: 2025-06-16 07:00

/src/libjpeg-turbo/src/jccolext.c
Line
Count
Source (jump to first uncovered line)
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
2.69M
{
36
#if BITS_IN_JSAMPLE != 16
37
  my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
38
  register int r, g, b;
39
  register JLONG *ctab = cconvert->rgb_ycc_tab;
40
  register _JSAMPROW inptr;
41
  register _JSAMPROW outptr0, outptr1, outptr2;
42
  register JDIMENSION col;
43
  JDIMENSION num_cols = cinfo->image_width;
44
45
5.39M
  while (--num_rows >= 0) {
46
2.69M
    inptr = *input_buf++;
47
2.69M
    outptr0 = output_buf[0][output_row];
48
2.69M
    outptr1 = output_buf[1][output_row];
49
2.69M
    outptr2 = output_buf[2][output_row];
50
2.69M
    output_row++;
51
4.10G
    for (col = 0; col < num_cols; col++) {
52
4.10G
      r = RANGE_LIMIT(inptr[RGB_RED]);
53
4.10G
      g = RANGE_LIMIT(inptr[RGB_GREEN]);
54
4.10G
      b = RANGE_LIMIT(inptr[RGB_BLUE]);
55
4.10G
      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
4.10G
      outptr0[col] = (_JSAMPLE)((ctab[r + R_Y_OFF] + ctab[g + G_Y_OFF] +
63
4.10G
                                 ctab[b + B_Y_OFF]) >> SCALEBITS);
64
      /* Cb */
65
4.10G
      outptr1[col] = (_JSAMPLE)((ctab[r + R_CB_OFF] + ctab[g + G_CB_OFF] +
66
4.10G
                                 ctab[b + B_CB_OFF]) >> SCALEBITS);
67
      /* Cr */
68
4.10G
      outptr2[col] = (_JSAMPLE)((ctab[r + R_CR_OFF] + ctab[g + G_CR_OFF] +
69
4.10G
                                 ctab[b + B_CR_OFF]) >> SCALEBITS);
70
4.10G
    }
71
2.69M
  }
72
#else
73
0
  ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
74
#endif
75
2.69M
}
Unexecuted instantiation: jccolor-8.c:extrgb_ycc_convert_internal
Unexecuted instantiation: jccolor-8.c:extrgbx_ycc_convert_internal
Unexecuted instantiation: jccolor-8.c:extbgr_ycc_convert_internal
Unexecuted instantiation: jccolor-8.c:extbgrx_ycc_convert_internal
Unexecuted instantiation: jccolor-8.c:extxbgr_ycc_convert_internal
Unexecuted instantiation: jccolor-8.c:extxrgb_ycc_convert_internal
jccolor-8.c:rgb_ycc_convert_internal
Line
Count
Source
35
2.69M
{
36
2.69M
#if BITS_IN_JSAMPLE != 16
37
2.69M
  my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
38
2.69M
  register int r, g, b;
39
2.69M
  register JLONG *ctab = cconvert->rgb_ycc_tab;
40
2.69M
  register _JSAMPROW inptr;
41
2.69M
  register _JSAMPROW outptr0, outptr1, outptr2;
42
2.69M
  register JDIMENSION col;
43
2.69M
  JDIMENSION num_cols = cinfo->image_width;
44
45
5.39M
  while (--num_rows >= 0) {
46
2.69M
    inptr = *input_buf++;
47
2.69M
    outptr0 = output_buf[0][output_row];
48
2.69M
    outptr1 = output_buf[1][output_row];
49
2.69M
    outptr2 = output_buf[2][output_row];
50
2.69M
    output_row++;
51
4.10G
    for (col = 0; col < num_cols; col++) {
52
4.10G
      r = RANGE_LIMIT(inptr[RGB_RED]);
53
4.10G
      g = RANGE_LIMIT(inptr[RGB_GREEN]);
54
4.10G
      b = RANGE_LIMIT(inptr[RGB_BLUE]);
55
4.10G
      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
4.10G
      outptr0[col] = (_JSAMPLE)((ctab[r + R_Y_OFF] + ctab[g + G_Y_OFF] +
63
4.10G
                                 ctab[b + B_Y_OFF]) >> SCALEBITS);
64
      /* Cb */
65
4.10G
      outptr1[col] = (_JSAMPLE)((ctab[r + R_CB_OFF] + ctab[g + G_CB_OFF] +
66
4.10G
                                 ctab[b + B_CB_OFF]) >> SCALEBITS);
67
      /* Cr */
68
4.10G
      outptr2[col] = (_JSAMPLE)((ctab[r + R_CR_OFF] + ctab[g + G_CR_OFF] +
69
4.10G
                                 ctab[b + B_CR_OFF]) >> SCALEBITS);
70
4.10G
    }
71
2.69M
  }
72
#else
73
  ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
74
#endif
75
2.69M
}
Unexecuted instantiation: jccolor-12.c:extrgb_ycc_convert_internal
Unexecuted instantiation: jccolor-12.c:extrgbx_ycc_convert_internal
Unexecuted instantiation: jccolor-12.c:extbgr_ycc_convert_internal
Unexecuted instantiation: jccolor-12.c:extbgrx_ycc_convert_internal
Unexecuted instantiation: jccolor-12.c:extxbgr_ycc_convert_internal
Unexecuted instantiation: jccolor-12.c:extxrgb_ycc_convert_internal
Unexecuted instantiation: jccolor-12.c:rgb_ycc_convert_internal
Unexecuted instantiation: jccolor-16.c:extrgb_ycc_convert_internal
Unexecuted instantiation: jccolor-16.c:extrgbx_ycc_convert_internal
Unexecuted instantiation: jccolor-16.c:extbgr_ycc_convert_internal
Unexecuted instantiation: jccolor-16.c:extbgrx_ycc_convert_internal
Unexecuted instantiation: jccolor-16.c:extxbgr_ycc_convert_internal
Unexecuted instantiation: jccolor-16.c:extxrgb_ycc_convert_internal
Unexecuted instantiation: jccolor-16.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
0
{
94
#if BITS_IN_JSAMPLE != 16
95
  my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
96
  register int r, g, b;
97
  register JLONG *ctab = cconvert->rgb_ycc_tab;
98
  register _JSAMPROW inptr;
99
  register _JSAMPROW outptr;
100
  register JDIMENSION col;
101
  JDIMENSION num_cols = cinfo->image_width;
102
103
0
  while (--num_rows >= 0) {
104
0
    inptr = *input_buf++;
105
0
    outptr = output_buf[0][output_row];
106
0
    output_row++;
107
0
    for (col = 0; col < num_cols; col++) {
108
0
      r = RANGE_LIMIT(inptr[RGB_RED]);
109
0
      g = RANGE_LIMIT(inptr[RGB_GREEN]);
110
0
      b = RANGE_LIMIT(inptr[RGB_BLUE]);
111
0
      inptr += RGB_PIXELSIZE;
112
      /* Y */
113
0
      outptr[col] = (_JSAMPLE)((ctab[r + R_Y_OFF] + ctab[g + G_Y_OFF] +
114
0
                                ctab[b + B_Y_OFF]) >> SCALEBITS);
115
0
    }
116
0
  }
117
#else
118
0
  ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
119
#endif
120
0
}
Unexecuted instantiation: jccolor-8.c:extrgb_gray_convert_internal
Unexecuted instantiation: jccolor-8.c:extrgbx_gray_convert_internal
Unexecuted instantiation: jccolor-8.c:extbgr_gray_convert_internal
Unexecuted instantiation: jccolor-8.c:extbgrx_gray_convert_internal
Unexecuted instantiation: jccolor-8.c:extxbgr_gray_convert_internal
Unexecuted instantiation: jccolor-8.c:extxrgb_gray_convert_internal
Unexecuted instantiation: jccolor-8.c:rgb_gray_convert_internal
Unexecuted instantiation: jccolor-12.c:extrgb_gray_convert_internal
Unexecuted instantiation: jccolor-12.c:extrgbx_gray_convert_internal
Unexecuted instantiation: jccolor-12.c:extbgr_gray_convert_internal
Unexecuted instantiation: jccolor-12.c:extbgrx_gray_convert_internal
Unexecuted instantiation: jccolor-12.c:extxbgr_gray_convert_internal
Unexecuted instantiation: jccolor-12.c:extxrgb_gray_convert_internal
Unexecuted instantiation: jccolor-12.c:rgb_gray_convert_internal
Unexecuted instantiation: jccolor-16.c:extrgb_gray_convert_internal
Unexecuted instantiation: jccolor-16.c:extrgbx_gray_convert_internal
Unexecuted instantiation: jccolor-16.c:extbgr_gray_convert_internal
Unexecuted instantiation: jccolor-16.c:extbgrx_gray_convert_internal
Unexecuted instantiation: jccolor-16.c:extxbgr_gray_convert_internal
Unexecuted instantiation: jccolor-16.c:extxrgb_gray_convert_internal
Unexecuted instantiation: jccolor-16.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
0
{
134
0
  register _JSAMPROW inptr;
135
0
  register _JSAMPROW outptr0, outptr1, outptr2;
136
0
  register JDIMENSION col;
137
0
  JDIMENSION num_cols = cinfo->image_width;
138
139
0
  while (--num_rows >= 0) {
140
0
    inptr = *input_buf++;
141
0
    outptr0 = output_buf[0][output_row];
142
0
    outptr1 = output_buf[1][output_row];
143
0
    outptr2 = output_buf[2][output_row];
144
0
    output_row++;
145
0
    for (col = 0; col < num_cols; col++) {
146
0
      outptr0[col] = inptr[RGB_RED];
147
0
      outptr1[col] = inptr[RGB_GREEN];
148
0
      outptr2[col] = inptr[RGB_BLUE];
149
0
      inptr += RGB_PIXELSIZE;
150
0
    }
151
0
  }
152
0
}
Unexecuted instantiation: jccolor-8.c:extrgb_rgb_convert_internal
Unexecuted instantiation: jccolor-8.c:extrgbx_rgb_convert_internal
Unexecuted instantiation: jccolor-8.c:extbgr_rgb_convert_internal
Unexecuted instantiation: jccolor-8.c:extbgrx_rgb_convert_internal
Unexecuted instantiation: jccolor-8.c:extxbgr_rgb_convert_internal
Unexecuted instantiation: jccolor-8.c:extxrgb_rgb_convert_internal
Unexecuted instantiation: jccolor-8.c:rgb_rgb_convert_internal
Unexecuted instantiation: jccolor-12.c:extrgb_rgb_convert_internal
Unexecuted instantiation: jccolor-12.c:extrgbx_rgb_convert_internal
Unexecuted instantiation: jccolor-12.c:extbgr_rgb_convert_internal
Unexecuted instantiation: jccolor-12.c:extbgrx_rgb_convert_internal
Unexecuted instantiation: jccolor-12.c:extxbgr_rgb_convert_internal
Unexecuted instantiation: jccolor-12.c:extxrgb_rgb_convert_internal
Unexecuted instantiation: jccolor-12.c:rgb_rgb_convert_internal
Unexecuted instantiation: jccolor-16.c:extrgb_rgb_convert_internal
Unexecuted instantiation: jccolor-16.c:extrgbx_rgb_convert_internal
Unexecuted instantiation: jccolor-16.c:extbgr_rgb_convert_internal
Unexecuted instantiation: jccolor-16.c:extbgrx_rgb_convert_internal
Unexecuted instantiation: jccolor-16.c:extxbgr_rgb_convert_internal
Unexecuted instantiation: jccolor-16.c:extxrgb_rgb_convert_internal
Unexecuted instantiation: jccolor-16.c:rgb_rgb_convert_internal