Debian Codegraph @

tests/uncompressed_encode.cc

raw
1 /*
2 libheif integration tests for uncompressed encoder
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 "api_structs.h"
29 #include "libheif/heif.h"
30 #include <cstdint>
31 #include <string.h>
32 #include "test_utils.h"
33
34 TEST_CASE("check have uncompressed")
35 {
36 heif_error err;
37 heif_context *ctx = heif_context_alloc();
38 heif_encoder *enc;
39 err = heif_context_get_encoder_for_format(ctx, heif_compression_uncompressed,
40 &enc);
41 REQUIRE(err.code == heif_error_Ok);
42
43 const char *name = heif_encoder_get_name(enc);
44 REQUIRE(strcmp(name, "builtin") == 0);
45
46 heif_encoder_release(enc);
47
48 heif_context_free(ctx);
49 }
50
51
52 heif_image *createImage_Mono()
53 {
54 heif_image *image;
55 heif_error err;
56 int w = 1024;
57 int h = 768;
58 err = heif_image_create(w, h, heif_colorspace_monochrome,
59 heif_chroma_monochrome, &image);
60 if (err.code) {
61 return nullptr;
62 }
63
64 err = heif_image_add_plane(image, heif_channel_Y, w, h, 8);
65 REQUIRE(err.code == heif_error_Ok);
66
67 int stride;
68 uint8_t *p = heif_image_get_plane(image, heif_channel_Y, &stride);
69
70 int y = 0;
71 for (; y < h / 2; y++) {
72 int x = 0;
73 for (; x < w / 3; x++) {
74 p[y * stride + x] = 255;
75 }
76 for (; x < 2 * w / 3; x++) {
77 p[y * stride + x] = 127;
78 }
79 for (; x < w; x++) {
80 p[y * stride + x] = 1;
81 }
82 }
83 for (; y < h; y++) {
84 int x = 0;
85 for (; x < w / 3; x++) {
86 p[y * stride + x] = (uint8_t) (x % 256);
87 }
88 for (; x < 2 * w / 3; x++) {
89 p[y * stride + x] = (uint8_t) ((255 - x) % 256);
90 }
91 for (; x < w; x++) {
92 p[y * stride + x] = (uint8_t) ((x + y) % 256);
93 }
94 }
95 if (err.code) {
96 heif_image_release(image);
97 return nullptr;
98 }
99
100 return image;
101 }
102
103
104 heif_image *createImage_YCbCr()
105 {
106 heif_image *image;
107 heif_error err;
108 int w = 1024;
109 int h = 768;
110 err = heif_image_create(w, h, heif_colorspace_YCbCr,
111 heif_chroma_444, &image);
112 if (err.code) {
113 return nullptr;
114 }
115
116 err = heif_image_add_plane(image, heif_channel_Y, w, h, 8);
117 REQUIRE(err.code == heif_error_Ok);
118 err = heif_image_add_plane(image, heif_channel_Cb, w, h, 8);
119 REQUIRE(err.code == heif_error_Ok);
120 err = heif_image_add_plane(image, heif_channel_Cr, w, h, 8);
121 REQUIRE(err.code == heif_error_Ok);
122
123 int stride;
124 uint8_t *p = heif_image_get_plane(image, heif_channel_Y, &stride);
125 uint8_t *cb = heif_image_get_plane(image, heif_channel_Cb, &stride);
126 uint8_t *cr = heif_image_get_plane(image, heif_channel_Cr, &stride);
127
128 int y = 0;
129 for (; y < h / 2; y++)
130 {
131 int x = 0;
132 for (; x < w / 3; x++) {
133 p[y * stride + x] = 255;
134 cb[y * stride + x] = 0;
135 cr[y * stride + x] = 0;
136 }
137 for (; x < 2 * w / 3; x++) {
138 p[y * stride + x] = 127;
139 cb[y * stride + x] = 0;
140 cr[y * stride + x] = 0;
141 }
142 for (; x < w; x++) {
143 p[y * stride + x] = 1;
144 cb[y * stride + x] = 0;
145 cr[y * stride + x] = 0;
146 }
147 }
148 for (; y < h; y++) {
149 int x = 0;
150 for (; x < w / 3; x++) {
151 p[y * stride + x] = 255;
152 cb[y * stride + x] = 255;
153 cr[y * stride + x] = 0;
154 }
155 for (; x < 2 * w / 3; x++) {
156 p[y * stride + x] = 255;
157 cb[y * stride + x] = 255;
158 cr[y * stride + x] = 255;
159 }
160 for (; x < w; x++) {
161 p[y * stride + x] = 255;
162 cb[y * stride + x] = 0;
163 cr[y * stride + x] = 255;
164 }
165 }
166 if (err.code) {
167 heif_image_release(image);
168 return nullptr;
169 }
170
171 return image;
172 }
173
174 heif_image* createImage_Mono_plus_alpha()
175 {
176 heif_image *image;
177 heif_error err;
178 int w = 1024;
179 int h = 768;
180 err = heif_image_create(w, h, heif_colorspace_monochrome,
181 heif_chroma_monochrome, &image);
182 if (err.code) {
183 return nullptr;
184 }
185
186 err = heif_image_add_plane(image, heif_channel_Y, w, h, 8);
187 REQUIRE(err.code == heif_error_Ok);
188 err = heif_image_add_plane(image, heif_channel_Alpha, w, h, 8);
189 REQUIRE(err.code == heif_error_Ok);
190
191 int stride;
192 uint8_t *p = heif_image_get_plane(image, heif_channel_Y, &stride);
193 uint8_t *a = heif_image_get_plane(image, heif_channel_Alpha, &stride);
194 int y = 0;
195 for (; y < h / 2; y++) {
196 int x = 0;
197 for (; x < w / 3; x++) {
198 p[y * stride + x] = 255;
199 a[y * stride + x] = 250;
200 }
201 for (; x < 2 * w / 3; x++) {
202 p[y * stride + x] = 127;
203 a[y * stride + x] = 25;
204 }
205 for (; x < w; x++) {
206 p[y * stride + x] = 1;
207 a[y * stride + x] = 252;
208 }
209 }
210 for (; y < h; y++) {
211 int x = 0;
212 for (; x < w / 3; x++) {
213 p[y * stride + x] = (uint8_t) (x % 256);
214 a[y * stride + x] = 253;
215 }
216 for (; x < 2 * w / 3; x++) {
217 p[y * stride + x] = (uint8_t) ((255 - x) % 256);
218 a[y * stride + x] = 254;
219 }
220 for (; x < w; x++) {
221 p[y * stride + x] = (uint8_t) ((x + y) % 256);
222 a[y * stride + x] = 255;
223 }
224 }
225 if (err.code) {
226 heif_image_release(image);
227 return nullptr;
228 }
229
230 return image;
231 }
232
233 heif_image *createImage_RGB_interleaved()
234 {
235 heif_image *image;
236 heif_error err;
237 int w = 1024;
238 int h = 768;
239 err = heif_image_create(w, h, heif_colorspace_RGB,
240 heif_chroma_interleaved_RGB, &image);
241 if (err.code) {
242 return nullptr;
243 }
244
245 err = heif_image_add_plane(image, heif_channel_interleaved, w, h, 8);
246 REQUIRE(err.code == heif_error_Ok);
247
248 int stride;
249 uint8_t *p = heif_image_get_plane(image, heif_channel_interleaved, &stride);
250
251 int y = 0;
252 for (; y < h / 2; y++) {
253 int x = 0;
254 for (; x < w / 3; x++) {
255 p[y * stride + 3 * x] = 1;
256 p[y * stride + 3 * x + 1] = 255;
257 p[y * stride + 3 * x + 2] = 2;
258 }
259 for (; x < 2 * w / 3; x++) {
260 p[y * stride + 3 * x] = 4;
261 p[y * stride + 3 * x + 1] = 5;
262 p[y * stride + 3 * x + 2] = 255;
263 }
264 for (; x < w; x++) {
265 p[y * stride + 3 * x] = 255;
266 p[y * stride + 3 * x + 1] = 6;
267 p[y * stride + 3 * x + 2] = 7;
268 }
269 }
270 for (; y < h; y++) {
271 int x = 0;
272 for (; x < w / 3; x++) {
273 p[y * stride + 3 * x] = 8;
274 p[y * stride + 3 * x + 1] = 9;
275 p[y * stride + 3 * x + 2] = 255;
276 }
277 for (; x < 2 * w / 3; x++) {
278 p[y * stride + 3 * x] = 253;
279 p[y * stride + 3 * x + 1] = 10;
280 p[y * stride + 3 * x + 2] = 11;
281 }
282 for (; x < w; x++) {
283 p[y * stride + 3 * x] = 13;
284 p[y * stride + 3 * x + 1] = 252;
285 p[y * stride + 3 * x + 2] = 12;
286 }
287 }
288 if (err.code) {
289 heif_image_release(image);
290 return nullptr;
291 }
292
293 return image;
294 }
295
296
297 void set_pixel_on_48bpp(uint8_t* p, int y, int stride, int x, int red, int green, int blue, bool little_endian, int alpha)
298 {
299 uint8_t red_low_byte = (uint8_t)(red & 0xFF);
300 uint8_t red_high_byte = (uint8_t)(red >> 8);
301 uint8_t green_low_byte = (uint8_t)(green & 0xFF);
302 uint8_t green_high_byte = (uint8_t)(green >> 8);
303 uint8_t blue_low_byte = (uint8_t)(blue & 0xFF);
304 uint8_t blue_high_byte = (uint8_t)(blue >> 8);
305 uint8_t alpha_low_byte = (uint8_t)(alpha & 0xFF);
306 uint8_t alpha_high_byte = (uint8_t)(alpha >> 8);
307 int bytes_per_pixel = 6;
308 if (alpha != 0)
309 {
310 bytes_per_pixel = 8;
311 }
312 if (little_endian)
313 {
314 p[y * stride + x * bytes_per_pixel + 0] = red_low_byte;
315 p[y * stride + x * bytes_per_pixel + 1] = red_high_byte;
316 p[y * stride + x * bytes_per_pixel + 2] = green_low_byte;
317 p[y * stride + x * bytes_per_pixel + 3] = green_high_byte;
318 p[y * stride + x * bytes_per_pixel + 4] = blue_low_byte;
319 p[y * stride + x * bytes_per_pixel + 5] = blue_high_byte;
320 if (alpha != 0)
321 {
322 p[y * stride + x * bytes_per_pixel + 6] = alpha_low_byte;
323 p[y * stride + x * bytes_per_pixel + 7] = alpha_high_byte;
324 }
325 }
326 else
327 {
328 p[y * stride + x * bytes_per_pixel + 0] = red_high_byte;
329 p[y * stride + x * bytes_per_pixel + 1] = red_low_byte;
330 p[y * stride + x * bytes_per_pixel + 2] = green_high_byte;
331 p[y * stride + x * bytes_per_pixel + 3] = green_low_byte;
332 p[y * stride + x * bytes_per_pixel + 4] = blue_high_byte;
333 p[y * stride + x * bytes_per_pixel + 5] = blue_low_byte;
334 if (alpha != 0)
335 {
336 p[y * stride + x * bytes_per_pixel + 6] = alpha_high_byte;
337 p[y * stride + x * bytes_per_pixel + 7] = alpha_low_byte;
338 }
339 }
340 }
341
342 heif_image *createImage_RRGGBB_interleaved(heif_chroma chroma, int bit_depth, bool little_endian, bool with_alpha)
343 {
344 heif_image *image;
345 heif_error err;
346 int w = 1024;
347 int h = 768;
348 err = heif_image_create(w, h, heif_colorspace_RGB, chroma, &image);
349 if (err.code) {
350 return nullptr;
351 }
352
353 int max_value = 0;
354 for (int i = 0; i < bit_depth; i++)
355 {
356 max_value |= (1 << i);
357 }
358 int mid_value = max_value / 2;
359 int alpha = 0;
360 int alpha_mid = 0;
361 if (with_alpha)
362 {
363 alpha = max_value;
364 alpha_mid = mid_value;
365 }
366
367 err = heif_image_add_plane(image, heif_channel_interleaved, w, h, bit_depth);
368 REQUIRE(err.code == heif_error_Ok);
369
370 int stride;
371 uint8_t *p = heif_image_get_plane(image, heif_channel_interleaved, &stride);
372
373 int y = 0;
374 for (; y < h / 2; y++) {
375 int x = 0;
376 for (; x < w / 4; x++)
377 {
378 set_pixel_on_48bpp(p, y, stride, x, 0x0000, 0x0000, max_value, little_endian, alpha);
379 }
380 for (; x < 2 * w / 4; x++)
381 {
382 set_pixel_on_48bpp(p, y, stride, x, 0x0000, max_value, 0x0000, little_endian, alpha);
383 }
384 for (; x < 3 * w / 4; x++)
385 {
386 set_pixel_on_48bpp(p, y, stride, x, max_value, 0x0000, 0x0000, little_endian, alpha);
387 }
388 for (; x < w; x++)
389 {
390 set_pixel_on_48bpp(p, y, stride, x, max_value - 2, max_value - 1, max_value, little_endian, alpha);
391 }
392 }
393 for (; y < h; y++) {
394 int x = 0;
395 for (; x < w / 4; x++)
396 {
397 set_pixel_on_48bpp(p, y, stride, x, 0x0000, max_value, 0x0000, little_endian, alpha_mid);
398 }
399 for (; x < 2 * w / 4; x++)
400 {
401 set_pixel_on_48bpp(p, y, stride, x, max_value, 0x0000, 0x0000, little_endian, alpha_mid);
402 }
403 for (; x < 3 * w / 4; x++)
404 {
405 set_pixel_on_48bpp(p, y, stride, x, 0x0000, 0x0000, max_value, little_endian, alpha_mid);
406 }
407 for (; x < w; x++)
408 {
409 set_pixel_on_48bpp(p, y, stride, x, mid_value - 2, mid_value -1, mid_value, little_endian, alpha_mid);
410 }
411 }
412 if (err.code) {
413 heif_image_release(image);
414 return nullptr;
415 }
416
417 return image;
418 }
419
420 heif_image *createImage_RGBA_interleaved()
421 {
422 heif_image *image;
423 heif_error err;
424 int w = 1024;
425 int h = 768;
426 err = heif_image_create(w, h, heif_colorspace_RGB,
427 heif_chroma_interleaved_RGBA, &image);
428 if (err.code) {
429 return nullptr;
430 }
431
432 err = heif_image_add_plane(image, heif_channel_interleaved, w, h, 8);
433 REQUIRE(err.code == heif_error_Ok);
434
435 int stride;
436 uint8_t *p = heif_image_get_plane(image, heif_channel_interleaved, &stride);
437
438 int y = 0;
439 for (; y < h / 2; y++) {
440 int x = 0;
441 for (; x < w / 3; x++) {
442 p[y * stride + 4 * x] = 1;
443 p[y * stride + 4 * x + 1] = 255;
444 p[y * stride + 4 * x + 2] = 2;
445 p[y * stride + 4 * x + 3] = 255;
446 }
447 for (; x < 2 * w / 3; x++) {
448 p[y * stride + 4 * x] = 4;
449 p[y * stride + 4 * x + 1] = 5;
450 p[y * stride + 4 * x + 2] = 255;
451 p[y * stride + 4 * x + 3] = 128;
452 }
453 for (; x < w; x++) {
454 p[y * stride + 4 * x] = 255;
455 p[y * stride + 4 * x + 1] = 6;
456 p[y * stride + 4 * x + 2] = 7;
457 p[y * stride + 4 * x + 3] = 200;
458 }
459 }
460 for (; y < h; y++) {
461 int x = 0;
462 for (; x < w / 3; x++) {
463 p[y * stride + 4 * x] = 8;
464 p[y * stride + 4 * x + 1] = 9;
465 p[y * stride + 4 * x + 2] = 255;
466 p[y * stride + 4 * x + 3] = 254;
467 }
468 for (; x < 2 * w / 3; x++) {
469 p[y * stride + 4 * x] = 253;
470 p[y * stride + 4 * x + 1] = 10;
471 p[y * stride + 4 * x + 2] = 11;
472 p[y * stride + 4 * x + 3] = 253;
473 }
474 for (; x < w; x++) {
475 p[y * stride + 4 * x] = 13;
476 p[y * stride + 4 * x + 1] = 252;
477 p[y * stride + 4 * x + 2] = 12;
478 p[y * stride + 4 * x + 3] = 250;
479 }
480 }
481 if (err.code) {
482 heif_image_release(image);
483 return nullptr;
484 }
485
486 return image;
487 }
488
489 heif_image *createImage_RGBA_planar()
490 {
491 heif_image *image;
492 heif_error err;
493 int w = 1024;
494 int h = 768;
495 err = heif_image_create(w, h, heif_colorspace_RGB,
496 heif_chroma_444, &image);
497 if (err.code) {
498 return nullptr;
499 }
500
501 err = heif_image_add_plane(image, heif_channel_R, w, h, 8);
502 REQUIRE(err.code == heif_error_Ok);
503 err = heif_image_add_plane(image, heif_channel_G, w, h, 8);
504 REQUIRE(err.code == heif_error_Ok);
505 err = heif_image_add_plane(image, heif_channel_B, w, h, 8);
506 REQUIRE(err.code == heif_error_Ok);
507 err = heif_image_add_plane(image, heif_channel_Alpha, w, h, 8);
508 REQUIRE(err.code == heif_error_Ok);
509
510
511 int stride;
512 uint8_t *r = heif_image_get_plane(image, heif_channel_R, &stride);
513 uint8_t *g = heif_image_get_plane(image, heif_channel_G, &stride);
514 uint8_t *b = heif_image_get_plane(image, heif_channel_B, &stride);
515 uint8_t *a = heif_image_get_plane(image, heif_channel_Alpha, &stride);
516
517 int y = 0;
518 for (; y < h / 2; y++) {
519 int x = 0;
520 for (; x < w / 3; x++) {
521 r[y * stride + x] = 1;
522 g[y * stride + x] = 255;
523 b[y * stride + x] = 2;
524 a[y * stride + x] = 240;
525 }
526 for (; x < 2 * w / 3; x++) {
527 r[y * stride + x] = 4;
528 g[y * stride + x] = 5;
529 b[y * stride + x] = 255;
530 a[y * stride + x] = 128;
531 }
532 for (; x < w; x++) {
533 r[y * stride + x] = 255;
534 g[y * stride + x] = 6;
535 b[y * stride + x] = 7;
536 a[y * stride + x] = 241;
537 }
538 }
539 for (; y < h; y++) {
540 int x = 0;
541 for (; x < w / 3; x++) {
542 r[y * stride + x]= 8;
543 g[y * stride + x] = 9;
544 b[y * stride + x] = 255;
545 a[y * stride + x] = 242;
546 }
547 for (; x < 2 * w / 3; x++) {
548 r[y * stride + x] = 253;
549 g[y * stride + x] = 10;
550 b[y * stride + x] = 11;
551 a[y * stride + x] = 243;
552 }
553 for (; x < w; x++) {
554 r[y * stride + x] = 13;
555 g[y * stride + x] = 252;
556 b[y * stride + x] = 12;
557 a[y * stride + x] = 244;
558 }
559 }
560 if (err.code) {
561 heif_image_release(image);
562 return nullptr;
563 }
564
565 return image;
566 }
567
568 static void do_encode(heif_image* input_image, const char* filename, bool check_decode, uint8_t prefer_uncC_short_form = 0)
569 {
570 REQUIRE(input_image != nullptr);
571
572 heif_context *ctx = heif_context_alloc();
573 heif_encoder *encoder;
574 heif_error err;
575 err = heif_context_get_encoder_for_format(ctx, heif_compression_uncompressed, &encoder);
576 REQUIRE(err.code == heif_error_Ok);
577
578 heif_encoding_options *options;
579 options = heif_encoding_options_alloc();
580 options->macOS_compatibility_workaround = false;
581 options->macOS_compatibility_workaround_no_nclx_profile = true;
582 options->image_orientation = heif_orientation_normal;
583 options->prefer_uncC_short_form = prefer_uncC_short_form;
584 heif_image_handle *output_image_handle;
585
586 err = heif_context_encode_image(ctx, input_image, encoder, options, &output_image_handle);
587 REQUIRE(err.code == heif_error_Ok);
588 err = heif_context_write_to_file(ctx, filename);
589 REQUIRE(err.code == heif_error_Ok);
590
591 if (check_decode)
592 {
593 // read file back in
594 heif_context* decode_context;
595 decode_context = heif_context_alloc();
596 err = heif_context_read_from_file(decode_context, filename, NULL);
597 REQUIRE(err.code == heif_error_Ok);
598 heif_image_handle *decode_image_handle = get_primary_image_handle(decode_context);
599 int ispe_width = heif_image_handle_get_ispe_width(decode_image_handle);
600 // TODO: check against input_image ispe width and height if we can
601 REQUIRE(ispe_width == 1024);
602 int ispe_height = heif_image_handle_get_ispe_height(decode_image_handle);
603 REQUIRE(ispe_height == 768);
604 int width = heif_image_handle_get_width(decode_image_handle);
605 REQUIRE(width == heif_image_get_primary_width(input_image));
606 int height = heif_image_handle_get_height(decode_image_handle);
607 REQUIRE(height == heif_image_get_primary_height(input_image));
608 heif_image* decode_image;
609 err = heif_decode_image(decode_image_handle, &decode_image, heif_colorspace_undefined, heif_chroma_undefined, NULL);
610 REQUIRE(err.code == heif_error_Ok);
611 // REQUIRE(heif_image_has_channel(input_image, heif_channel_Y) == heif_image_has_channel(decode_image, heif_channel_Y));
612 REQUIRE(heif_image_has_channel(input_image, heif_channel_Cb) == heif_image_has_channel(decode_image, heif_channel_Cb));
613 REQUIRE(heif_image_has_channel(input_image, heif_channel_Cr) == heif_image_has_channel(decode_image, heif_channel_Cr));
614 // REQUIRE(heif_image_has_channel(input_image, heif_channel_R) == heif_image_has_channel(decode_image, heif_channel_R));
615 // REQUIRE(heif_image_has_channel(input_image, heif_channel_G) == heif_image_has_channel(decode_image, heif_channel_G));
616 // REQUIRE(heif_image_has_channel(input_image, heif_channel_B) == heif_image_has_channel(decode_image, heif_channel_B));
617 // REQUIRE(heif_image_has_channel(input_image, heif_channel_Alpha) == heif_image_has_channel(decode_image, heif_channel_Alpha));
618 // REQUIRE(heif_image_has_channel(input_image, heif_channel_interleaved) == heif_image_has_channel(decode_image, heif_channel_interleaved));
619 // TODO: make proper test for interleave to component translation
620
621 // TODO: compare values
622 heif_image_release(decode_image);
623 heif_image_handle_release(decode_image_handle);
624 heif_context_free(decode_context);
625 }
626
627 heif_image_handle_release(output_image_handle);
628 heif_encoding_options_free(options);
629 heif_encoder_release(encoder);
630 heif_image_release(input_image);
631
632 heif_context_free(ctx);
633 }
634
635
636 TEST_CASE("Encode RGB")
637 {
638 heif_image *input_image = createImage_RGB_interleaved();
639 do_encode(input_image, "encode_rgb.heif", true);
640 }
641
642
643 TEST_CASE("Encode Mono")
644 {
645 heif_image* input_image = createImage_Mono();
646 do_encode(input_image, "encode_mono.heif", true);
647 }
648
649 TEST_CASE("Encode RGB Version1")
650 {
651 heif_image *input_image = createImage_RGB_interleaved();
652 do_encode(input_image, "encode_rgb_version1.heif", true, true);
653 }
654
655 TEST_CASE("Encode Mono with alpha")
656 {
657 heif_image* input_image = createImage_Mono_plus_alpha();
658 do_encode(input_image, "encode_mono_plus_alpha.heif", true);
659 }
660
661
662 TEST_CASE("Encode YCBCr")
663 {
664 // TODO: 422 and 420
665 heif_image *input_image = createImage_YCbCr();
666 do_encode(input_image, "encode_YCbCr.heif", true);
667 }
668
669
670 TEST_CASE("Encode RRRGGBB_LE 10 bit")
671 {
672 heif_image *input_image = createImage_RRGGBB_interleaved(heif_chroma_interleaved_RRGGBB_LE, 10, true, false);
673 do_encode(input_image, "encode_rrggbb_10_le.heif", false);
674 }
675
676
677 TEST_CASE("Encode RRRGGBB_BE 10 bit ")
678 {
679 heif_image *input_image = createImage_RRGGBB_interleaved(heif_chroma_interleaved_RRGGBB_BE, 10, false, false);
680 do_encode(input_image, "encode_rrggbb_10_be.heif", false);
681 }
682
683
684 TEST_CASE("Encode RRRGGBB_LE 12 bit")
685 {
686 heif_image *input_image = createImage_RRGGBB_interleaved(heif_chroma_interleaved_RRGGBB_LE, 12, true, false);
687 do_encode(input_image, "encode_rrggbb_12_le.heif", false);
688 }
689
690
691 TEST_CASE("Encode RRRGGBB_BE 12 bit ")
692 {
693 heif_image *input_image = createImage_RRGGBB_interleaved(heif_chroma_interleaved_RRGGBB_BE, 12, false, false);
694 do_encode(input_image, "encode_rrggbb_12_be.heif", false);
695 }
696
697
698 TEST_CASE("Encode RRRGGBB_LE 16 bit")
699 {
700 heif_image *input_image = createImage_RRGGBB_interleaved(heif_chroma_interleaved_RRGGBB_LE, 16, true, false);
701 do_encode(input_image, "encode_rrggbb_16_le.heif", false);
702 }
703
704
705 TEST_CASE("Encode RRRGGBB_BE 16 bit ")
706 {
707 heif_image *input_image = createImage_RRGGBB_interleaved(heif_chroma_interleaved_RRGGBB_BE, 16, false, false);
708 do_encode(input_image, "encode_rrggbb_16_be.heif", false);
709 }
710
711
712 TEST_CASE("Encode RGBA")
713 {
714 heif_image *input_image = createImage_RGBA_interleaved();
715 do_encode(input_image, "encode_rgba.heif", true);
716 }
717
718 TEST_CASE("Encode RGBA Version 1")
719 {
720 heif_image *input_image = createImage_RGBA_interleaved();
721 do_encode(input_image, "encode_rgba_version1.heif", true, true);
722 }
723
724
725 TEST_CASE("Encode RRRGGBBAA_LE 10 bit")
726 {
727 heif_image *input_image = createImage_RRGGBB_interleaved(heif_chroma_interleaved_RRGGBBAA_LE, 10, true, true);
728 do_encode(input_image, "encode_rrggbbaa_10_le.heif", false);
729 }
730
731
732 TEST_CASE("Encode RRRGGBBAA_BE 10 bit ")
733 {
734 heif_image *input_image = createImage_RRGGBB_interleaved(heif_chroma_interleaved_RRGGBBAA_BE, 10, false, true);
735 do_encode(input_image, "encode_rrggbbaa_10_be.heif", false);
736 }
737
738
739 TEST_CASE("Encode RRRGGBBAA_LE 12 bit")
740 {
741 heif_image *input_image = createImage_RRGGBB_interleaved(heif_chroma_interleaved_RRGGBBAA_LE, 12, true, true);
742 do_encode(input_image, "encode_rrggbbaa_12_le.heif", false);
743 }
744
745
746 TEST_CASE("Encode RRRGGBBAA_BE 12 bit ")
747 {
748 heif_image *input_image = createImage_RRGGBB_interleaved(heif_chroma_interleaved_RRGGBBAA_BE, 12, false, true);
749 do_encode(input_image, "encode_rrggbbaa_12_be.heif", false);
750 }
751
752
753 TEST_CASE("Encode RRRGGBBAA_LE 16 bit")
754 {
755 heif_image *input_image = createImage_RRGGBB_interleaved(heif_chroma_interleaved_RRGGBBAA_LE, 16, true, true);
756 do_encode(input_image, "encode_rrggbbaa_16_le.heif", false);
757 }
758
759
760 TEST_CASE("Encode RRRGGBBAA_BE 16 bit ")
761 {
762 heif_image *input_image = createImage_RRGGBB_interleaved(heif_chroma_interleaved_RRGGBBAA_BE, 16, false, true);
763 do_encode(input_image, "encode_rrggbbaa_16_be.heif", false);
764 }
765
766
767 TEST_CASE("Encode RGB planar")
768 {
769 heif_image *input_image = createImage_RGB_planar();
770 do_encode(input_image, "encode_rgb_planar.heif", true);
771 }
772
773
774 TEST_CASE("Encode RGBA planar")
775 {
776 heif_image *input_image = createImage_RGBA_planar();
777 do_encode(input_image, "encode_rgba_planar.heif", true);
778 }