The main point of this test is to exercise lots of internal code paths.
| 662 | |
| 663 | // The main point of this test is to exercise lots of internal code paths. |
| 664 | bool random_compress_test() |
| 665 | { |
| 666 | printf("Random XUASTC/ASTC LDR 4x4-12x12 compression test:\n"); |
| 667 | |
| 668 | const uint32_t num_images = 18; |
| 669 | image test_images[num_images + 1]; |
| 670 | |
| 671 | for (uint32_t i = 0; i < num_images; i++) |
| 672 | load_png(fmt_string("../test_files/kodim{02}.png", 1 + i).c_str(), test_images[i]); |
| 673 | |
| 674 | const uint32_t N = 16; |
| 675 | //const uint32_t N = 5000; |
| 676 | const uint32_t MAX_WIDTH = 1024, MAX_HEIGHT = 1024; |
| 677 | |
| 678 | basisu::rand rnd; |
| 679 | |
| 680 | float lowest_psnr1 = BIG_FLOAT_VAL, lowest_psnr2 = BIG_FLOAT_VAL; |
| 681 | |
| 682 | struct result |
| 683 | { |
| 684 | uint32_t m_seed; |
| 685 | basist::basis_tex_format m_fmt; |
| 686 | float m_psnr1; |
| 687 | float m_psnr2; |
| 688 | }; |
| 689 | basisu::vector<result> results; |
| 690 | |
| 691 | for (uint32_t i = 0; i < N; i++) |
| 692 | { |
| 693 | uint32_t seed = 166136844 + i; |
| 694 | |
| 695 | //seed = 23082246; // etc1s 1-bit SSE overflow |
| 696 | //seed = 56636601; // UASTC HDR 4x4 assert tol |
| 697 | //seed = 56636744; // HDR 6x6 float overflow |
| 698 | |
| 699 | fmt_printf("------------------------------ Seed: {}\n", seed); |
| 700 | rnd.seed(seed); |
| 701 | |
| 702 | const uint32_t w = rnd.irand(1, MAX_WIDTH); |
| 703 | const uint32_t h = rnd.irand(1, MAX_HEIGHT); |
| 704 | const bool mips = rnd.bit(); |
| 705 | const bool use_a = rnd.bit(); |
| 706 | |
| 707 | fmt_printf("Trying {}x{}, mips: {}, use_a: {}\n", w, h, mips, use_a); |
| 708 | |
| 709 | // Chose a random codec/block size to test |
| 710 | basist::basis_tex_format tex_mode = basist::basis_tex_format::cETC1S; |
| 711 | |
| 712 | bool is_hdr = false; |
| 713 | |
| 714 | uint32_t rnd_codec_class = rnd.irand(0, (uint32_t)codec_class::cTOTAL - 1); |
| 715 | |
| 716 | // TODO - make this a command line |
| 717 | //rnd_codec_class = rnd.bit() ? (uint32_t)codec_class::cXUASTC_LDR : (uint32_t)codec_class::cASTC_LDR; |
| 718 | //rnd_codec_class = (uint32_t)codec_class::cXUASTC_LDR; |
| 719 | //rnd_codec_class = (uint32_t)codec_class::cETC1S; |
| 720 | |
| 721 | switch (rnd_codec_class) |
no test coverage detected