Debian Codegraph @

tests/uncompressed_decode_rgb16.cc

raw
1 /*
2 libheif integration tests for uncompressed decoder
3
4 MIT License
5
6 Copyright (c) 2023 Brad Hards <[email protected]>
7
8 Permission is hereby granted, free of charge, to any person obtaining a copy
9 of this software and associated documentation files (the "Software"), to deal
10 in the Software without restriction, including without limitation the rights
11 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 copies of the Software, and to permit persons to whom the Software is
13 furnished to do so, subject to the following conditions:
14
15 The above copyright notice and this permission notice shall be included in all
16 copies or substantial portions of the Software.
17
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 SOFTWARE.
25 */
26
27 #include "catch_amalgamated.hpp"
28 #include "libheif/heif.h"
29 #include "api_structs.h"
30 #include <cstdint>
31 #include <stdio.h>
32 #include "test_utils.h"
33 #include <string.h>
34
35 #include "uncompressed_decode.h"
36
37 void check_image_size_rgb16(heif_context *&context, int expect_alpha) {
38 heif_image_handle *handle = get_primary_image_handle(context);
39 heif_image *img = get_primary_image(handle);
40
41 REQUIRE(heif_image_has_channel(img, heif_channel_Y) == 0);
42 REQUIRE(heif_image_has_channel(img, heif_channel_Cb) == 0);
43 REQUIRE(heif_image_has_channel(img, heif_channel_Cr) == 0);
44 REQUIRE(heif_image_has_channel(img, heif_channel_R) == 1);
45 REQUIRE(heif_image_has_channel(img, heif_channel_G) == 1);
46 REQUIRE(heif_image_has_channel(img, heif_channel_B) == 1);
47 REQUIRE(heif_image_has_channel(img, heif_channel_Alpha) == expect_alpha);
48 REQUIRE(heif_image_has_channel(img, heif_channel_interleaved) == 0);
49 int width = heif_image_get_primary_width(img);
50 REQUIRE(width == 30);
51 int height = heif_image_get_primary_height(img);
52 REQUIRE(height == 20);
53 width = heif_image_get_width(img, heif_channel_R);
54 REQUIRE(width == 30);
55 height = heif_image_get_height(img, heif_channel_R);
56 REQUIRE(height == 20);
57 width = heif_image_get_width(img, heif_channel_G);
58 REQUIRE(width == 30);
59 height = heif_image_get_height(img, heif_channel_G);
60 REQUIRE(height == 20);
61 width = heif_image_get_width(img, heif_channel_B);
62 REQUIRE(width == 30);
63 height = heif_image_get_height(img, heif_channel_B);
64 REQUIRE(height == 20);
65 if (expect_alpha == 1) {
66 width = heif_image_get_width(img, heif_channel_Alpha);
67 REQUIRE(width == 30);
68 height = heif_image_get_height(img, heif_channel_Alpha);
69 REQUIRE(height == 20);
70 }
71
72 int pixel_depth = heif_image_get_bits_per_pixel(img, heif_channel_R);
73 REQUIRE(pixel_depth == 16);
74 pixel_depth = heif_image_get_bits_per_pixel(img, heif_channel_G);
75 REQUIRE(pixel_depth == 16);
76 pixel_depth = heif_image_get_bits_per_pixel(img, heif_channel_B);
77 REQUIRE(pixel_depth == 16);
78
79 int pixel_range = heif_image_get_bits_per_pixel_range(img, heif_channel_R);
80 REQUIRE(pixel_range == 16);
81 pixel_range = heif_image_get_bits_per_pixel_range(img, heif_channel_G);
82 REQUIRE(pixel_range == 16);
83 pixel_range = heif_image_get_bits_per_pixel_range(img, heif_channel_B);
84 REQUIRE(pixel_range == 16);
85
86 heif_image_release(img);
87 heif_image_handle_release(handle);
88 }
89
90 TEST_CASE("check image size 16 bit RGB") {
91 auto file = GENERATE(FILES_16BIT_RGB);
92 auto context = get_context_for_test_file(file);
93 INFO("file name: " << file);
94 int expect_alpha = (strchr(file, 'A') == NULL) ? 0 : 1;
95 check_image_size_rgb16(context, expect_alpha);
96 heif_context_free(context);
97 }
98
99 void check_image_content_rgb16(heif_context *&context) {
100 heif_image_handle *handle = get_primary_image_handle(context);
101 heif_image *img = get_primary_image(handle);
102
103 int stride;
104 const uint8_t *img_plane =
105 heif_image_get_plane_readonly(img, heif_channel_R, &stride);
106 REQUIRE(stride == 128);
107 for (int row = 0; row < 4; row++) {
108 INFO("row: " << row);
109 REQUIRE(((int)(img_plane[stride * row + 0])) == 255);
110 REQUIRE(((int)(img_plane[stride * row + 7])) == 255);
111 REQUIRE(((int)(img_plane[stride * row + 8])) == 0);
112 REQUIRE(((int)(img_plane[stride * row + 15])) == 0);
113 REQUIRE(((int)(img_plane[stride * row + 16])) == 0);
114 REQUIRE(((int)(img_plane[stride * row + 23])) == 0);
115 REQUIRE(((int)(img_plane[stride * row + 24])) == 255);
116 REQUIRE(((int)(img_plane[stride * row + 31])) == 255);
117 REQUIRE(((int)(img_plane[stride * row + 32])) == 0);
118 REQUIRE(((int)(img_plane[stride * row + 39])) == 0);
119 REQUIRE(((int)(img_plane[stride * row + 40])) == 255);
120 REQUIRE(((int)(img_plane[stride * row + 47])) == 255);
121 REQUIRE(((int)(img_plane[stride * row + 48])) == 0);
122 REQUIRE(((int)(img_plane[stride * row + 55])) == 0);
123 REQUIRE(((int)(img_plane[stride * row + 56])) == 128);
124 REQUIRE(((int)(img_plane[stride * row + 59])) == 128);
125 }
126 for (int row = 4; row < 8; row++) {
127 INFO("row: " << row);
128 REQUIRE(((int)(img_plane[stride * row + 0])) == 0);
129 REQUIRE(((int)(img_plane[stride * row + 7])) == 0);
130 REQUIRE(((int)(img_plane[stride * row + 8])) == 0);
131 REQUIRE(((int)(img_plane[stride * row + 15])) == 0);
132 REQUIRE(((int)(img_plane[stride * row + 16])) == 255);
133 REQUIRE(((int)(img_plane[stride * row + 23])) == 255);
134 REQUIRE(((int)(img_plane[stride * row + 24])) == 0);
135 REQUIRE(((int)(img_plane[stride * row + 31])) == 0);
136 REQUIRE(((int)(img_plane[stride * row + 32])) == 255);
137 REQUIRE(((int)(img_plane[stride * row + 39])) == 255);
138 REQUIRE(((int)(img_plane[stride * row + 40])) == 0);
139 REQUIRE(((int)(img_plane[stride * row + 47])) == 0);
140 REQUIRE(((int)(img_plane[stride * row + 48])) == 128);
141 REQUIRE(((int)(img_plane[stride * row + 55])) == 128);
142 REQUIRE(((int)(img_plane[stride * row + 56])) == 255);
143 REQUIRE(((int)(img_plane[stride * row + 59])) == 255);
144 }
145 for (int row = 8; row < 12; row++) {
146 INFO("row: " << row);
147 REQUIRE(((int)(img_plane[stride * row + 0])) == 0);
148 REQUIRE(((int)(img_plane[stride * row + 3])) == 0);
149 REQUIRE(((int)(img_plane[stride * row + 4])) == 0);
150 REQUIRE(((int)(img_plane[stride * row + 7])) == 0);
151 REQUIRE(((int)(img_plane[stride * row + 8])) == 255);
152 REQUIRE(((int)(img_plane[stride * row + 11])) == 255);
153 REQUIRE(((int)(img_plane[stride * row + 12])) == 255);
154 REQUIRE(((int)(img_plane[stride * row + 15])) == 255);
155 REQUIRE(((int)(img_plane[stride * row + 16])) == 0);
156 REQUIRE(((int)(img_plane[stride * row + 19])) == 0);
157 REQUIRE(((int)(img_plane[stride * row + 20])) == 0);
158 REQUIRE(((int)(img_plane[stride * row + 23])) == 0);
159 REQUIRE(((int)(img_plane[stride * row + 24])) == 255);
160 REQUIRE(((int)(img_plane[stride * row + 27])) == 255);
161 REQUIRE(((int)(img_plane[stride * row + 28])) == 255);
162 REQUIRE(((int)(img_plane[stride * row + 31])) == 255);
163 REQUIRE(((int)(img_plane[stride * row + 32])) == 0);
164 REQUIRE(((int)(img_plane[stride * row + 35])) == 0);
165 REQUIRE(((int)(img_plane[stride * row + 36])) == 0);
166 REQUIRE(((int)(img_plane[stride * row + 39])) == 0);
167 REQUIRE(((int)(img_plane[stride * row + 40])) == 128);
168 REQUIRE(((int)(img_plane[stride * row + 43])) == 128);
169 REQUIRE(((int)(img_plane[stride * row + 44])) == 128);
170 REQUIRE(((int)(img_plane[stride * row + 47])) == 128);
171 REQUIRE(((int)(img_plane[stride * row + 48])) == 255);
172 REQUIRE(((int)(img_plane[stride * row + 51])) == 255);
173 REQUIRE(((int)(img_plane[stride * row + 52])) == 255);
174 REQUIRE(((int)(img_plane[stride * row + 55])) == 255);
175 REQUIRE(((int)(img_plane[stride * row + 56])) == 238);
176 REQUIRE(((int)(img_plane[stride * row + 59])) == 238);
177 }
178 for (int row = 12; row < 16; row++) {
179 INFO("row: " << row);
180 REQUIRE(((int)(img_plane[stride * row + 0])) == 255);
181 REQUIRE(((int)(img_plane[stride * row + 7])) == 255);
182 REQUIRE(((int)(img_plane[stride * row + 8])) == 0);
183 REQUIRE(((int)(img_plane[stride * row + 15])) == 0);
184 REQUIRE(((int)(img_plane[stride * row + 16])) == 255);
185 REQUIRE(((int)(img_plane[stride * row + 23])) == 255);
186 REQUIRE(((int)(img_plane[stride * row + 24])) == 0);
187 REQUIRE(((int)(img_plane[stride * row + 31])) == 0);
188 REQUIRE(((int)(img_plane[stride * row + 32])) == 128);
189 REQUIRE(((int)(img_plane[stride * row + 39])) == 128);
190 REQUIRE(((int)(img_plane[stride * row + 40])) == 255);
191 REQUIRE(((int)(img_plane[stride * row + 47])) == 255);
192 REQUIRE(((int)(img_plane[stride * row + 48])) == 238);
193 REQUIRE(((int)(img_plane[stride * row + 55])) == 238);
194 REQUIRE(((int)(img_plane[stride * row + 56])) == 255);
195 REQUIRE(((int)(img_plane[stride * row + 59])) == 255);
196 }
197 for (int row = 16; row < 20; row++) {
198 INFO("row: " << row);
199 REQUIRE(((int)(img_plane[stride * row + 0])) == 0);
200 REQUIRE(((int)(img_plane[stride * row + 7])) == 0);
201 REQUIRE(((int)(img_plane[stride * row + 8])) == 255);
202 REQUIRE(((int)(img_plane[stride * row + 15])) == 255);
203 REQUIRE(((int)(img_plane[stride * row + 16])) == 0);
204 REQUIRE(((int)(img_plane[stride * row + 23])) == 0);
205 REQUIRE(((int)(img_plane[stride * row + 24])) == 128);
206 REQUIRE(((int)(img_plane[stride * row + 31])) == 128);
207 REQUIRE(((int)(img_plane[stride * row + 32])) == 255);
208 REQUIRE(((int)(img_plane[stride * row + 39])) == 255);
209 REQUIRE(((int)(img_plane[stride * row + 40])) == 238);
210 REQUIRE(((int)(img_plane[stride * row + 47])) == 238);
211 REQUIRE(((int)(img_plane[stride * row + 48])) == 255);
212 REQUIRE(((int)(img_plane[stride * row + 55])) == 255);
213 REQUIRE(((int)(img_plane[stride * row + 56])) == 0);
214 REQUIRE(((int)(img_plane[stride * row + 59])) == 0);
215 }
216 img_plane = heif_image_get_plane_readonly(img, heif_channel_G, &stride);
217 REQUIRE(stride == 128);
218 for (int row = 0; row < 4; row++) {
219 INFO("row: " << row);
220 REQUIRE(((int)(img_plane[stride * row + 0])) == 0);
221 REQUIRE(((int)(img_plane[stride * row + 7])) == 0);
222 REQUIRE(((int)(img_plane[stride * row + 8])) == 128);
223 REQUIRE(((int)(img_plane[stride * row + 15])) == 128);
224 REQUIRE(((int)(img_plane[stride * row + 16])) == 0);
225 REQUIRE(((int)(img_plane[stride * row + 23])) == 0);
226 REQUIRE(((int)(img_plane[stride * row + 24])) == 255);
227 REQUIRE(((int)(img_plane[stride * row + 31])) == 255);
228 REQUIRE(((int)(img_plane[stride * row + 32])) == 0);
229 REQUIRE(((int)(img_plane[stride * row + 39])) == 0);
230 REQUIRE(((int)(img_plane[stride * row + 40])) == 255);
231 REQUIRE(((int)(img_plane[stride * row + 47])) == 255);
232 REQUIRE(((int)(img_plane[stride * row + 48])) == 255);
233 REQUIRE(((int)(img_plane[stride * row + 55])) == 255);
234 REQUIRE(((int)(img_plane[stride * row + 56])) == 128);
235 REQUIRE(((int)(img_plane[stride * row + 59])) == 128);
236 }
237 for (int row = 4; row < 8; row++) {
238 INFO("row: " << row);
239 REQUIRE(((int)(img_plane[stride * row + 0])) == 128);
240 REQUIRE(((int)(img_plane[stride * row + 7])) == 128);
241 REQUIRE(((int)(img_plane[stride * row + 8])) == 0);
242 REQUIRE(((int)(img_plane[stride * row + 15])) == 0);
243 REQUIRE(((int)(img_plane[stride * row + 16])) == 255);
244 REQUIRE(((int)(img_plane[stride * row + 23])) == 255);
245 REQUIRE(((int)(img_plane[stride * row + 24])) == 0);
246 REQUIRE(((int)(img_plane[stride * row + 27])) == 0);
247 REQUIRE(((int)(img_plane[stride * row + 28])) == 0);
248 REQUIRE(((int)(img_plane[stride * row + 31])) == 0);
249 REQUIRE(((int)(img_plane[stride * row + 32])) == 255);
250 REQUIRE(((int)(img_plane[stride * row + 39])) == 255);
251 REQUIRE(((int)(img_plane[stride * row + 40])) == 255);
252 REQUIRE(((int)(img_plane[stride * row + 47])) == 255);
253 REQUIRE(((int)(img_plane[stride * row + 48])) == 128);
254 REQUIRE(((int)(img_plane[stride * row + 55])) == 128);
255 REQUIRE(((int)(img_plane[stride * row + 56])) == 165);
256 REQUIRE(((int)(img_plane[stride * row + 59])) == 165);
257 }
258 for (int row = 8; row < 12; row++) {
259 INFO("row: " << row);
260 REQUIRE(((int)(img_plane[stride * row + 0])) == 0);
261 REQUIRE(((int)(img_plane[stride * row + 3])) == 0);
262 REQUIRE(((int)(img_plane[stride * row + 4])) == 0);
263 REQUIRE(((int)(img_plane[stride * row + 7])) == 0);
264 REQUIRE(((int)(img_plane[stride * row + 8])) == 255);
265 REQUIRE(((int)(img_plane[stride * row + 11])) == 255);
266 REQUIRE(((int)(img_plane[stride * row + 12])) == 255);
267 REQUIRE(((int)(img_plane[stride * row + 15])) == 255);
268 REQUIRE(((int)(img_plane[stride * row + 16])) == 0);
269 REQUIRE(((int)(img_plane[stride * row + 19])) == 0);
270 REQUIRE(((int)(img_plane[stride * row + 20])) == 0);
271 REQUIRE(((int)(img_plane[stride * row + 23])) == 0);
272 REQUIRE(((int)(img_plane[stride * row + 24])) == 255);
273 REQUIRE(((int)(img_plane[stride * row + 27])) == 255);
274 REQUIRE(((int)(img_plane[stride * row + 28])) == 255);
275 REQUIRE(((int)(img_plane[stride * row + 31])) == 255);
276 REQUIRE(((int)(img_plane[stride * row + 32])) == 255);
277 REQUIRE(((int)(img_plane[stride * row + 35])) == 255);
278 REQUIRE(((int)(img_plane[stride * row + 36])) == 255);
279 REQUIRE(((int)(img_plane[stride * row + 39])) == 255);
280 REQUIRE(((int)(img_plane[stride * row + 40])) == 128);
281 REQUIRE(((int)(img_plane[stride * row + 43])) == 128);
282 REQUIRE(((int)(img_plane[stride * row + 44])) == 128);
283 REQUIRE(((int)(img_plane[stride * row + 47])) == 128);
284 REQUIRE(((int)(img_plane[stride * row + 48])) == 165);
285 REQUIRE(((int)(img_plane[stride * row + 51])) == 165);
286 REQUIRE(((int)(img_plane[stride * row + 52])) == 165);
287 REQUIRE(((int)(img_plane[stride * row + 55])) == 165);
288 REQUIRE(((int)(img_plane[stride * row + 56])) == 130);
289 REQUIRE(((int)(img_plane[stride * row + 59])) == 130);
290 }
291 for (int row = 12; row < 16; row++) {
292 INFO("row: " << row);
293 REQUIRE(((int)(img_plane[stride * row + 0])) == 255);
294 REQUIRE(((int)(img_plane[stride * row + 7])) == 255);
295 REQUIRE(((int)(img_plane[stride * row + 8])) == 0);
296 REQUIRE(((int)(img_plane[stride * row + 15])) == 0);
297 REQUIRE(((int)(img_plane[stride * row + 16])) == 255);
298 REQUIRE(((int)(img_plane[stride * row + 23])) == 255);
299 REQUIRE(((int)(img_plane[stride * row + 24])) == 255);
300 REQUIRE(((int)(img_plane[stride * row + 31])) == 255);
301 REQUIRE(((int)(img_plane[stride * row + 32])) == 128);
302 REQUIRE(((int)(img_plane[stride * row + 39])) == 128);
303 REQUIRE(((int)(img_plane[stride * row + 40])) == 165);
304 REQUIRE(((int)(img_plane[stride * row + 47])) == 165);
305 REQUIRE(((int)(img_plane[stride * row + 48])) == 130);
306 REQUIRE(((int)(img_plane[stride * row + 55])) == 130);
307 REQUIRE(((int)(img_plane[stride * row + 56])) == 0);
308 REQUIRE(((int)(img_plane[stride * row + 59])) == 0);
309 }
310 for (int row = 16; row < 20; row++) {
311 INFO("row: " << row);
312 REQUIRE(((int)(img_plane[stride * row + 0])) == 0);
313 REQUIRE(((int)(img_plane[stride * row + 7])) == 0);
314 REQUIRE(((int)(img_plane[stride * row + 8])) == 255);
315 REQUIRE(((int)(img_plane[stride * row + 15])) == 255);
316 REQUIRE(((int)(img_plane[stride * row + 16])) == 255);
317 REQUIRE(((int)(img_plane[stride * row + 23])) == 255);
318 REQUIRE(((int)(img_plane[stride * row + 24])) == 128);
319 REQUIRE(((int)(img_plane[stride * row + 31])) == 128);
320 REQUIRE(((int)(img_plane[stride * row + 32])) == 165);
321 REQUIRE(((int)(img_plane[stride * row + 39])) == 165);
322 REQUIRE(((int)(img_plane[stride * row + 40])) == 130);
323 REQUIRE(((int)(img_plane[stride * row + 47])) == 130);
324 REQUIRE(((int)(img_plane[stride * row + 48])) == 0);
325 REQUIRE(((int)(img_plane[stride * row + 55])) == 0);
326 REQUIRE(((int)(img_plane[stride * row + 56])) == 128);
327 REQUIRE(((int)(img_plane[stride * row + 59])) == 128);
328 }
329 img_plane = heif_image_get_plane_readonly(img, heif_channel_B, &stride);
330 REQUIRE(stride == 128);
331 for (int row = 0; row < 4; row++) {
332 INFO("row: " << row);
333 REQUIRE(((int)(img_plane[stride * row + 0])) == 0);
334 REQUIRE(((int)(img_plane[stride * row + 7])) == 0);
335 REQUIRE(((int)(img_plane[stride * row + 8])) == 0);
336 REQUIRE(((int)(img_plane[stride * row + 15])) == 0);
337 REQUIRE(((int)(img_plane[stride * row + 16])) == 255);
338 REQUIRE(((int)(img_plane[stride * row + 23])) == 255);
339 REQUIRE(((int)(img_plane[stride * row + 24])) == 255);
340 REQUIRE(((int)(img_plane[stride * row + 31])) == 255);
341 REQUIRE(((int)(img_plane[stride * row + 32])) == 0);
342 REQUIRE(((int)(img_plane[stride * row + 39])) == 0);
343 REQUIRE(((int)(img_plane[stride * row + 40])) == 0);
344 REQUIRE(((int)(img_plane[stride * row + 47])) == 0);
345 REQUIRE(((int)(img_plane[stride * row + 48])) == 255);
346 REQUIRE(((int)(img_plane[stride * row + 55])) == 255);
347 REQUIRE(((int)(img_plane[stride * row + 56])) == 128);
348 REQUIRE(((int)(img_plane[stride * row + 59])) == 128);
349 }
350 for (int row = 4; row < 8; row++) {
351 INFO("row: " << row);
352 REQUIRE(((int)(img_plane[stride * row + 0])) == 0);
353 REQUIRE(((int)(img_plane[stride * row + 7])) == 0);
354 REQUIRE(((int)(img_plane[stride * row + 8])) == 255);
355 REQUIRE(((int)(img_plane[stride * row + 15])) == 255);
356 REQUIRE(((int)(img_plane[stride * row + 16])) == 255);
357 REQUIRE(((int)(img_plane[stride * row + 23])) == 255);
358 REQUIRE(((int)(img_plane[stride * row + 24])) == 0);
359 REQUIRE(((int)(img_plane[stride * row + 31])) == 0);
360 REQUIRE(((int)(img_plane[stride * row + 32])) == 0);
361 REQUIRE(((int)(img_plane[stride * row + 39])) == 0);
362 REQUIRE(((int)(img_plane[stride * row + 40])) == 255);
363 REQUIRE(((int)(img_plane[stride * row + 47])) == 255);
364 REQUIRE(((int)(img_plane[stride * row + 48])) == 128);
365 REQUIRE(((int)(img_plane[stride * row + 55])) == 128);
366 REQUIRE(((int)(img_plane[stride * row + 56])) == 0);
367 REQUIRE(((int)(img_plane[stride * row + 59])) == 0);
368 }
369 for (int row = 8; row < 12; row++) {
370 INFO("row: " << row);
371 REQUIRE(((int)(img_plane[stride * row + 0])) == 255);
372 REQUIRE(((int)(img_plane[stride * row + 3])) == 255);
373 REQUIRE(((int)(img_plane[stride * row + 4])) == 255);
374 REQUIRE(((int)(img_plane[stride * row + 7])) == 255);
375 REQUIRE(((int)(img_plane[stride * row + 8])) == 255);
376 REQUIRE(((int)(img_plane[stride * row + 11])) == 255);
377 REQUIRE(((int)(img_plane[stride * row + 12])) == 255);
378 REQUIRE(((int)(img_plane[stride * row + 15])) == 255);
379 REQUIRE(((int)(img_plane[stride * row + 16])) == 0);
380 REQUIRE(((int)(img_plane[stride * row + 19])) == 0);
381 REQUIRE(((int)(img_plane[stride * row + 20])) == 0);
382 REQUIRE(((int)(img_plane[stride * row + 23])) == 0);
383 REQUIRE(((int)(img_plane[stride * row + 24])) == 0);
384 REQUIRE(((int)(img_plane[stride * row + 27])) == 0);
385 REQUIRE(((int)(img_plane[stride * row + 28])) == 0);
386 REQUIRE(((int)(img_plane[stride * row + 31])) == 0);
387 REQUIRE(((int)(img_plane[stride * row + 32])) == 255);
388 REQUIRE(((int)(img_plane[stride * row + 35])) == 255);
389 REQUIRE(((int)(img_plane[stride * row + 36])) == 255);
390 REQUIRE(((int)(img_plane[stride * row + 39])) == 255);
391 REQUIRE(((int)(img_plane[stride * row + 40])) == 128);
392 REQUIRE(((int)(img_plane[stride * row + 43])) == 128);
393 REQUIRE(((int)(img_plane[stride * row + 44])) == 128);
394 REQUIRE(((int)(img_plane[stride * row + 47])) == 128);
395 REQUIRE(((int)(img_plane[stride * row + 48])) == 0);
396 REQUIRE(((int)(img_plane[stride * row + 51])) == 0);
397 REQUIRE(((int)(img_plane[stride * row + 52])) == 0);
398 REQUIRE(((int)(img_plane[stride * row + 55])) == 0);
399 REQUIRE(((int)(img_plane[stride * row + 56])) == 238);
400 REQUIRE(((int)(img_plane[stride * row + 59])) == 238);
401 }
402 for (int row = 12; row < 16; row++) {
403 INFO("row: " << row);
404 REQUIRE(((int)(img_plane[stride * row + 0])) == 255);
405 REQUIRE(((int)(img_plane[stride * row + 7])) == 255);
406 REQUIRE(((int)(img_plane[stride * row + 8])) == 0);
407 REQUIRE(((int)(img_plane[stride * row + 11])) == 0);
408 REQUIRE(((int)(img_plane[stride * row + 12])) == 0);
409 REQUIRE(((int)(img_plane[stride * row + 19])) == 0);
410 REQUIRE(((int)(img_plane[stride * row + 20])) == 0);
411 REQUIRE(((int)(img_plane[stride * row + 23])) == 0);
412 REQUIRE(((int)(img_plane[stride * row + 24])) == 255);
413 REQUIRE(((int)(img_plane[stride * row + 31])) == 255);
414 REQUIRE(((int)(img_plane[stride * row + 32])) == 128);
415 REQUIRE(((int)(img_plane[stride * row + 39])) == 128);
416 REQUIRE(((int)(img_plane[stride * row + 40])) == 0);
417 REQUIRE(((int)(img_plane[stride * row + 47])) == 0);
418 REQUIRE(((int)(img_plane[stride * row + 48])) == 238);
419 REQUIRE(((int)(img_plane[stride * row + 55])) == 238);
420 REQUIRE(((int)(img_plane[stride * row + 56])) == 0);
421 REQUIRE(((int)(img_plane[stride * row + 59])) == 0);
422 }
423 for (int row = 16; row < 20; row++) {
424 INFO("row: " << row);
425 REQUIRE(((int)(img_plane[stride * row + 0])) == 0);
426 REQUIRE(((int)(img_plane[stride * row + 7])) == 0);
427 REQUIRE(((int)(img_plane[stride * row + 8])) == 0);
428 REQUIRE(((int)(img_plane[stride * row + 15])) == 0);
429 REQUIRE(((int)(img_plane[stride * row + 16])) == 255);
430 REQUIRE(((int)(img_plane[stride * row + 23])) == 255);
431 REQUIRE(((int)(img_plane[stride * row + 24])) == 128);
432 REQUIRE(((int)(img_plane[stride * row + 31])) == 128);
433 REQUIRE(((int)(img_plane[stride * row + 32])) == 0);
434 REQUIRE(((int)(img_plane[stride * row + 39])) == 0);
435 REQUIRE(((int)(img_plane[stride * row + 40])) == 238);
436 REQUIRE(((int)(img_plane[stride * row + 47])) == 238);
437 REQUIRE(((int)(img_plane[stride * row + 48])) == 0);
438 REQUIRE(((int)(img_plane[stride * row + 55])) == 0);
439 REQUIRE(((int)(img_plane[stride * row + 56])) == 0);
440 REQUIRE(((int)(img_plane[stride * row + 59])) == 0);
441 }
442
443 heif_image_release(img);
444 heif_image_handle_release(handle);
445 }
446
447 TEST_CASE("check image content 16 bit RGB") {
448 auto file = GENERATE(FILES_16BIT_RGB);
449 auto context = get_context_for_test_file(file);
450 INFO("file name: " << file);
451 check_image_content_rgb16(context);
452 heif_context_free(context);
453 }