| 157 | } |
| 158 | |
| 159 | bool basisu_frontend::compress() |
| 160 | { |
| 161 | debug_printf("basisu_frontend::compress\n"); |
| 162 | |
| 163 | m_total_blocks = m_params.m_num_source_blocks; |
| 164 | m_total_pixels = m_total_blocks * cPixelBlockTotalPixels; |
| 165 | |
| 166 | // Encode the initial high quality ETC1S texture |
| 167 | |
| 168 | init_etc1_images(); |
| 169 | |
| 170 | // First quantize the ETC1S endpoints |
| 171 | |
| 172 | if (m_params.m_pGlobal_codebooks) |
| 173 | { |
| 174 | init_global_codebooks(); |
| 175 | } |
| 176 | else |
| 177 | { |
| 178 | init_endpoint_training_vectors(); |
| 179 | |
| 180 | generate_endpoint_clusters(); |
| 181 | |
| 182 | for (uint32_t refine_endpoint_step = 0; refine_endpoint_step < m_num_endpoint_codebook_iterations; refine_endpoint_step++) |
| 183 | { |
| 184 | if (m_params.m_validate) |
| 185 | { |
| 186 | BASISU_FRONTEND_VERIFY(check_etc1s_constraints()); |
| 187 | |
| 188 | BASISU_FRONTEND_VERIFY(validate_endpoint_cluster_hierarchy(false)); |
| 189 | } |
| 190 | |
| 191 | if (refine_endpoint_step) |
| 192 | { |
| 193 | introduce_new_endpoint_clusters(); |
| 194 | } |
| 195 | |
| 196 | if (m_params.m_validate) |
| 197 | { |
| 198 | BASISU_FRONTEND_VERIFY(validate_endpoint_cluster_hierarchy(false)); |
| 199 | } |
| 200 | |
| 201 | generate_endpoint_codebook(refine_endpoint_step); |
| 202 | |
| 203 | if ((m_params.m_debug_images) && (m_params.m_dump_endpoint_clusterization)) |
| 204 | { |
| 205 | char buf[256]; |
| 206 | snprintf(buf, sizeof(buf), "endpoint_cluster_vis_pre_%u.png", refine_endpoint_step); |
| 207 | dump_endpoint_clusterization_visualization(buf, false); |
| 208 | } |
| 209 | |
| 210 | bool early_out = false; |
| 211 | |
| 212 | if (m_endpoint_refinement) |
| 213 | { |
| 214 | //dump_endpoint_clusterization_visualization("endpoint_clusters_before_refinement.png"); |
| 215 | |
| 216 | if (!refine_endpoint_clusterization()) |
no test coverage detected