| 744 | } |
| 745 | |
| 746 | basis_compressor::error_code basis_compressor::process() |
| 747 | { |
| 748 | debug_printf("basis_compressor::process\n"); |
| 749 | |
| 750 | if (!read_dds_source_images()) |
| 751 | return cECFailedReadingSourceImages; |
| 752 | |
| 753 | // Note: After here m_params.m_hdr, m_params.m_uastc and m_fmt_mode, m_fmt_mode_block_width/height cannot be changed. |
| 754 | if (!pick_format_mode()) |
| 755 | return cECFailedInvalidParameters; |
| 756 | |
| 757 | if (!read_source_images()) |
| 758 | return cECFailedReadingSourceImages; |
| 759 | |
| 760 | if (!validate_texture_type_constraints()) |
| 761 | return cECFailedValidating; |
| 762 | |
| 763 | if (m_params.m_create_ktx2_file) |
| 764 | { |
| 765 | if (!validate_ktx2_constraints()) |
| 766 | { |
| 767 | error_printf("Inputs do not satisfy .KTX2 texture constraints: all source images must be the same resolution and have the same number of mipmap levels.\n"); |
| 768 | return cECFailedValidating; |
| 769 | } |
| 770 | } |
| 771 | |
| 772 | // Some modes/codecs require extracting source blocks up front. |
| 773 | if (!extract_source_blocks()) |
| 774 | return cECFailedFrontEnd; |
| 775 | |
| 776 | if (m_params.m_hdr) |
| 777 | { |
| 778 | if (m_params.m_hdr_mode == hdr_modes::cUASTC_HDR_4X4) |
| 779 | { |
| 780 | // UASTC 4x4 HDR |
| 781 | if (m_params.m_status_output) |
| 782 | printf("Mode: UASTC 4x4 HDR Effort Level (0-4): %u\n", m_params.m_uastc_hdr_4x4_options.m_level); |
| 783 | |
| 784 | error_code ec = encode_slices_to_uastc_4x4_hdr(); |
| 785 | if (ec != cECSuccess) |
| 786 | return ec; |
| 787 | } |
| 788 | else |
| 789 | { |
| 790 | // ASTC 6x6 HDR/UASTC HDR 6x6i |
| 791 | assert((m_params.m_hdr_mode == hdr_modes::cASTC_HDR_6X6) || (m_params.m_hdr_mode == hdr_modes::cUASTC_HDR_6X6_INTERMEDIATE)); |
| 792 | |
| 793 | if (m_params.m_status_output) |
| 794 | { |
| 795 | fmt_printf("Mode: ASTC 6x6 HDR {}, Base Effort Level (0-4): {}, Highest Effort Level (0-4): {}, Lambda: {}, REC 2020: {}\n", |
| 796 | (m_params.m_hdr_mode == hdr_modes::cUASTC_HDR_6X6_INTERMEDIATE) ? "Intermediate" : "", |
| 797 | m_params.m_astc_hdr_6x6_options.m_master_comp_level, m_params.m_astc_hdr_6x6_options.m_highest_comp_level, |
| 798 | m_params.m_astc_hdr_6x6_options.m_lambda, m_params.m_astc_hdr_6x6_options.m_rec2020_bt2100_color_gamut); |
| 799 | |
| 800 | if (m_params.m_hdr_mode == hdr_modes::cUASTC_HDR_6X6_INTERMEDIATE) |
| 801 | { |
| 802 | fmt_printf("Writing v{} compatible UASTC HDR 6x6i bitstream\n", m_params.m_astc_hdr_6x6_options.m_write_basisu_1_6_compatible_files ? "1.60" : "2.00+"); |
| 803 | } |