Coverage Report

Created: 2019-07-03 22:50

/home/liu/buildslave/linux-x64-runtests/build/lib/io/_ccv_io_raw.inc
Line
Count
Source (jump to first uncovered line)
1
static void _ccv_read_rgb_raw(ccv_dense_matrix_t** x, const void* data, int type, int rows, int cols, int scanline)
2
2
{
3
2
  int ctype = (type & 0xF00) ? CCV_8U | ((type & 0xF00) >> 8) : 
CCV_8U | CCV_C30
;
4
2
  ccv_dense_matrix_t* dx = *x = ccv_dense_matrix_new(rows, cols, ctype, 0, 0);
5
2
  int i, j;
6
2
  switch (type & 0xF00)
7
2
  {
8
2
    case CCV_IO_GRAY:
9
1
    {
10
1
      unsigned char* g = dx->data.u8;
11
1
      unsigned char* rgb = (unsigned char*)data;
12
1
      int rgb_padding = scanline - cols * 3;
13
1
      assert(rgb_padding >= 0);
14
3
      
for (i = 0; 1
i < rows;
i++2
)
15
2
      {
16
6
        for (j = 0; j < cols; 
j++4
)
17
4
          g[j] = (unsigned char)((rgb[0] * 6969 + rgb[1] * 23434 + rgb[2] * 2365) >> 15), rgb += 3;
18
2
        rgb += rgb_padding;
19
2
        g += dx->step;
20
2
      }
21
1
      break;
22
1
    } 
23
1
    case CCV_IO_RGB_COLOR:
24
1
    default:
25
1
    {
26
1
      unsigned char* x_ptr = dx->data.u8;
27
1
      unsigned char* a_ptr = (unsigned char*)data;
28
1
      assert(scanline >= cols * 3);
29
3
      
for (i = 0; 1
i < rows;
i++2
)
30
2
      {
31
2
        memcpy(x_ptr, a_ptr, cols * 3);
32
2
        a_ptr += scanline;
33
2
        x_ptr += dx->step;
34
2
      }
35
1
      break;
36
1
    }
37
2
  }
38
2
}
39
40
static void _ccv_read_rgba_raw(ccv_dense_matrix_t** x, const void* data, int type, int rows, int cols, int scanline)
41
3
{
42
3
  int ctype = (type & 0xF00) ? 
CCV_8U | ((type & 0xF00) >> 8)2
:
CCV_8U | CCV_C31
;
43
3
  ccv_dense_matrix_t* dx = *x = ccv_dense_matrix_new(rows, cols, ctype, 0, 0);
44
3
  int i, j;
45
3
  switch (type & 0xF00)
46
3
  {
47
3
    case CCV_IO_GRAY:
48
1
    {
49
1
      unsigned char* g = dx->data.u8;
50
1
      unsigned char* rgba = (unsigned char*)data;
51
1
      int rgba_padding = scanline - cols * 4;
52
1
      assert(rgba_padding >= 0);
53
3
      
for (i = 0; 1
i < rows;
i++2
)
54
2
      {
55
6
        for (j = 0; j < cols; 
j++4
)
56
4
          g[j] = (unsigned char)((rgba[0] * 6969 + rgba[1] * 23434 + rgba[2] * 2365) >> 15), rgba += 4;
57
2
        rgba += rgba_padding;
58
2
        g += dx->step;
59
2
      }
60
1
      break;
61
1
    }
62
1
    case CCV_IO_RGB_COLOR:
63
1
    {
64
1
      unsigned char* rgb = dx->data.u8;
65
1
      int rgb_padding = dx->step - cols * 3;
66
1
      assert(rgb_padding >= 0);
67
1
      unsigned char* rgba = (unsigned char*)data;
68
1
      int rgba_padding = scanline - cols * 4;
69
1
      assert(rgba_padding >= 0);
70
3
      
for (i = 0; 1
i < rows;
i++2
)
71
2
      {
72
6
        for (j = 0; j < cols; 
j++4
)
73
4
          rgb[0] = rgba[0], rgb[1] = rgba[1], rgb[2] = rgba[2],
74
4
            rgb += 3, rgba += 4;
75
2
        rgba += rgba_padding;
76
2
        rgb += rgb_padding;
77
2
      }
78
1
      break;
79
1
    }
80
1
    default:
81
1
    {
82
1
      unsigned char* x_ptr = dx->data.u8;
83
1
      unsigned char* a_ptr = (unsigned char*)data;
84
1
      assert(scanline >= cols * 4);
85
3
      
for (i = 0; 1
i < rows;
i++2
)
86
2
      {
87
2
        memcpy(x_ptr, a_ptr, cols * 4);
88
2
        a_ptr += scanline;
89
2
        x_ptr += dx->step;
90
2
      }
91
1
      break;
92
1
    }
93
3
  }
94
3
}
95
96
static void _ccv_read_argb_raw(ccv_dense_matrix_t** x, const void* data, int type, int rows, int cols, int scanline)
97
3
{
98
3
  int ctype = (type & 0xF00) ? 
CCV_8U | ((type & 0xF00) >> 8)2
:
CCV_8U | CCV_C31
;
99
3
  ccv_dense_matrix_t* dx = *x = ccv_dense_matrix_new(rows, cols, ctype, 0, 0);
100
3
  int i, j;
101
3
  switch (type & 0xF00)
102
3
  {
103
3
    case CCV_IO_GRAY:
104
1
    {
105
1
      unsigned char* g = dx->data.u8;
106
1
      unsigned char* argb = (unsigned char*)data;
107
1
      int argb_padding = scanline - cols * 4;
108
1
      assert(argb_padding >= 0);
109
3
      
for (i = 0; 1
i < rows;
i++2
)
110
2
      {
111
6
        for (j = 0; j < cols; 
j++4
)
112
4
          g[j] = (unsigned char)((argb[1] * 6969 + argb[2] * 23434 + argb[3] * 2365) >> 15), argb += 4;
113
2
        argb += argb_padding;
114
2
        g += dx->step;
115
2
      }
116
1
      break;
117
1
    }
118
1
    case CCV_IO_RGB_COLOR:
119
1
    {
120
1
      unsigned char* rgb = dx->data.u8;
121
1
      int rgb_padding = dx->step - cols * 3;
122
1
      assert(rgb_padding >= 0);
123
1
      unsigned char* argb = (unsigned char*)data;
124
1
      int argb_padding = scanline - cols * 4;
125
1
      assert(argb_padding >= 0);
126
3
      
for (i = 0; 1
i < rows;
i++2
)
127
2
      {
128
6
        for (j = 0; j < cols; 
j++4
)
129
4
          rgb[0] = argb[1], rgb[1] = argb[2], rgb[2] = argb[3],
130
4
            rgb += 3, argb += 4;
131
2
        argb += argb_padding;
132
2
        rgb += rgb_padding;
133
2
      }
134
1
      break;
135
1
    }
136
1
    default:
137
1
    {
138
1
      unsigned char* x_ptr = dx->data.u8;
139
1
      unsigned char* a_ptr = (unsigned char*)data;
140
1
      assert(scanline >= cols * 4);
141
3
      
for (i = 0; 1
i < rows;
i++2
)
142
2
      {
143
2
        memcpy(x_ptr, a_ptr, cols * 4);
144
2
        a_ptr += scanline;
145
2
        x_ptr += dx->step;
146
2
      }
147
1
      break;
148
1
    }
149
3
  }
150
3
}
151
152
static void _ccv_read_bgr_raw(ccv_dense_matrix_t** x, const void* data, int type, int rows, int cols, int scanline)
153
3
{
154
3
  int ctype = (type & 0xF00) ? 
CCV_8U | ((type & 0xF00) >> 8)2
:
CCV_8U | CCV_C31
;
155
3
  ccv_dense_matrix_t* dx = *x = ccv_dense_matrix_new(rows, cols, ctype, 0, 0);
156
3
  int i, j;
157
3
  switch (type & 0xF00)
158
3
  {
159
3
    case CCV_IO_GRAY:
160
1
    {
161
1
      unsigned char* g = dx->data.u8;
162
1
      unsigned char* bgr = (unsigned char*)data;
163
1
      int bgr_padding = scanline - cols * 3;
164
1
      assert(bgr_padding >= 0);
165
3
      
for (i = 0; 1
i < rows;
i++2
)
166
2
      {
167
6
        for (j = 0; j < cols; 
j++4
)
168
4
          g[j] = (unsigned char)((bgr[2] * 6969 + bgr[1] * 23434 + bgr[0] * 2365) >> 15), bgr += 3;
169
2
        bgr += bgr_padding;
170
2
        g += dx->step;
171
2
      }
172
1
      break;
173
1
    }
174
1
    case CCV_IO_RGB_COLOR:
175
1
    {
176
1
      unsigned char* rgb = dx->data.u8;
177
1
      int rgb_padding = dx->step - cols * 3;
178
1
      assert(rgb_padding >= 0);
179
1
      unsigned char* bgr = (unsigned char*)data;
180
1
      int bgr_padding = scanline - cols * 3;
181
1
      assert(bgr_padding >= 0);
182
3
      
for (i = 0; 1
i < rows;
i++2
)
183
2
      {
184
6
        for (j = 0; j < cols; 
j++4
)
185
4
          rgb[0] = bgr[2], rgb[1] = bgr[1], rgb[2] = bgr[0],
186
4
            rgb += 3, bgr += 3;
187
2
        bgr += bgr_padding;
188
2
        rgb += rgb_padding;
189
2
      }
190
1
      break;
191
1
    }
192
1
    default:
193
1
    {
194
1
      unsigned char* x_ptr = dx->data.u8;
195
1
      unsigned char* a_ptr = (unsigned char*)data;
196
1
      assert(scanline >= cols * 3);
197
3
      
for (i = 0; 1
i < rows;
i++2
)
198
2
      {
199
2
        memcpy(x_ptr, a_ptr, cols * 3);
200
2
        a_ptr += scanline;
201
2
        x_ptr += dx->step;
202
2
      }
203
1
      break;
204
1
    }
205
3
  }
206
3
}
207
208
static void _ccv_read_bgra_raw(ccv_dense_matrix_t** x, const void* data, int type, int rows, int cols, int scanline)
209
3
{
210
3
  int ctype = (type & 0xF00) ? 
CCV_8U | ((type & 0xF00) >> 8)2
:
CCV_8U | CCV_C31
;
211
3
  ccv_dense_matrix_t* dx = *x = ccv_dense_matrix_new(rows, cols, ctype, 0, 0);
212
3
  int i, j;
213
3
  switch (type & 0xF00)
214
3
  {
215
3
    case CCV_IO_GRAY:
216
1
    {
217
1
      unsigned char* g = dx->data.u8;
218
1
      unsigned char* bgra = (unsigned char*)data;
219
1
      int bgra_padding = scanline - cols * 4;
220
1
      assert(bgra_padding >= 0);
221
3
      
for (i = 0; 1
i < rows;
i++2
)
222
2
      {
223
6
        for (j = 0; j < cols; 
j++4
)
224
4
          g[j] = (unsigned char)((bgra[2] * 6969 + bgra[1] * 23434 + bgra[0] * 2365) >> 15), bgra += 4;
225
2
        bgra += bgra_padding;
226
2
        g += dx->step;
227
2
      }
228
1
      break;
229
1
    }
230
1
    case CCV_IO_RGB_COLOR:
231
1
    {
232
1
      unsigned char* rgb = dx->data.u8;
233
1
      int rgb_padding = dx->step - cols * 3;
234
1
      assert(rgb_padding >= 0);
235
1
      unsigned char* bgra = (unsigned char*)data;
236
1
      int bgra_padding = scanline - cols * 4;
237
1
      assert(bgra_padding >= 0);
238
3
      
for (i = 0; 1
i < rows;
i++2
)
239
2
      {
240
6
        for (j = 0; j < cols; 
j++4
)
241
4
          rgb[0] = bgra[2], rgb[1] = bgra[1], rgb[2] = bgra[0],
242
4
            rgb += 3, bgra += 4;
243
2
        bgra += bgra_padding;
244
2
        rgb += rgb_padding;
245
2
      }
246
1
      break;
247
1
    }
248
1
    default:
249
1
    {
250
1
      unsigned char* x_ptr = dx->data.u8;
251
1
      unsigned char* a_ptr = (unsigned char*)data;
252
1
      assert(scanline >= cols * 4);
253
3
      
for (i = 0; 1
i < rows;
i++2
)
254
2
      {
255
2
        memcpy(x_ptr, a_ptr, cols * 4);
256
2
        a_ptr += scanline;
257
2
        x_ptr += dx->step;
258
2
      }
259
1
      break;
260
1
    }
261
3
  }
262
3
}
263
264
static void _ccv_read_abgr_raw(ccv_dense_matrix_t** x, const void* data, int type, int rows, int cols, int scanline)
265
3
{
266
3
  int ctype = (type & 0xF00) ? 
CCV_8U | ((type & 0xF00) >> 8)2
:
CCV_8U | CCV_C31
;
267
3
  ccv_dense_matrix_t* dx = *x = ccv_dense_matrix_new(rows, cols, ctype, 0, 0);
268
3
  int i, j;
269
3
  switch (type & 0xF00)
270
3
  {
271
3
    case CCV_IO_GRAY:
272
1
    {
273
1
      unsigned char* g = dx->data.u8;
274
1
      unsigned char* abgr = (unsigned char*)data;
275
1
      int abgr_padding = scanline - cols * 4;
276
1
      assert(abgr_padding >= 0);
277
3
      
for (i = 0; 1
i < rows;
i++2
)
278
2
      {
279
6
        for (j = 0; j < cols; 
j++4
)
280
4
          g[j] = (unsigned char)((abgr[3] * 6969 + abgr[2] * 23434 + abgr[1] * 2365) >> 15), abgr += 4;
281
2
        abgr += abgr_padding;
282
2
        g += dx->step;
283
2
      }
284
1
      break;
285
1
    }
286
1
    case CCV_IO_RGB_COLOR:
287
1
    {
288
1
      unsigned char* rgb = dx->data.u8;
289
1
      int rgb_padding = dx->step - cols * 3;
290
1
      assert(rgb_padding >= 0);
291
1
      unsigned char* abgr = (unsigned char*)data;
292
1
      int abgr_padding = scanline - cols * 4;
293
1
      assert(abgr_padding >= 0);
294
3
      
for (i = 0; 1
i < rows;
i++2
)
295
2
      {
296
6
        for (j = 0; j < cols; 
j++4
)
297
4
          rgb[0] = abgr[3], rgb[1] = abgr[2], rgb[2] = abgr[1],
298
4
            rgb += 3, abgr += 4;
299
2
        abgr += abgr_padding;
300
2
        rgb += rgb_padding;
301
2
      }
302
1
      break;
303
1
    }
304
1
    default:
305
1
    {
306
1
      unsigned char* x_ptr = dx->data.u8;
307
1
      unsigned char* a_ptr = (unsigned char*)data;
308
1
      assert(scanline >= cols * 4);
309
3
      
for (i = 0; 1
i < rows;
i++2
)
310
2
      {
311
2
        memcpy(x_ptr, a_ptr, cols * 4);
312
2
        a_ptr += scanline;
313
2
        x_ptr += dx->step;
314
2
      }
315
1
      break;
316
1
    }
317
3
  }
318
3
}
319
320
static void _ccv_read_gray_raw(ccv_dense_matrix_t** x, const void* data, int type, int rows, int cols, int scanline)
321
2
{
322
2
  int ctype = (type & 0xF00) ? CCV_8U | ((type & 0xF00) >> 8) : 
CCV_8U | CCV_C10
;
323
2
  ccv_dense_matrix_t* dx = *x = ccv_dense_matrix_new(rows, cols, ctype, 0, 0);
324
2
  int i, j;
325
2
  switch (type & 0xF00)
326
2
  {
327
2
    case CCV_IO_RGB_COLOR:
328
1
    {
329
1
      unsigned char* rgb = dx->data.u8;
330
1
      unsigned char* g = (unsigned char*)data;
331
1
      int rgb_padding = dx->step - cols * 3;
332
1
      assert(rgb_padding >= 0);
333
3
      
for (i = 0; 1
i < rows;
i++2
)
334
2
      {
335
6
        for (j = 0; j < cols; 
j++4
)
336
4
          rgb[0] = rgb[1] = rgb[2] = g[j], rgb += 3;
337
2
        g += scanline;
338
2
        rgb += rgb_padding;
339
2
      }
340
1
      break;
341
1
    }
342
1
    case CCV_IO_GRAY:
343
1
    default:
344
1
    {
345
1
      unsigned char* x_ptr = dx->data.u8;
346
1
      unsigned char* a_ptr = (unsigned char*)data;
347
1
      assert(scanline >= cols);
348
3
      
for (i = 0; 1
i < rows;
i++2
)
349
2
      {
350
2
        memcpy(x_ptr, a_ptr, cols);
351
2
        a_ptr += scanline;
352
2
        x_ptr += dx->step;
353
2
      }
354
1
      break;
355
1
    }
356
2
  }
357
2
}