| 10195 | } |
| 10196 | |
| 10197 | bool basisu_transcoder::get_file_info(const void* pData, uint32_t data_size, basisu_file_info& file_info) const |
| 10198 | { |
| 10199 | if (!validate_file_checksums(pData, data_size, false)) |
| 10200 | { |
| 10201 | BASISU_DEVEL_ERROR("basisu_transcoder::get_file_info: validate_file_checksums failed\n"); |
| 10202 | return false; |
| 10203 | } |
| 10204 | |
| 10205 | const basis_file_header* pHeader = static_cast<const basis_file_header*>(pData); |
| 10206 | const basis_slice_desc* pSlice_descs = reinterpret_cast<const basis_slice_desc*>(static_cast<const uint8_t*>(pData) + pHeader->m_slice_desc_file_ofs); |
| 10207 | |
| 10208 | file_info.m_version = pHeader->m_ver; |
| 10209 | |
| 10210 | file_info.m_total_header_size = sizeof(basis_file_header) + pHeader->m_total_slices * sizeof(basis_slice_desc); |
| 10211 | |
| 10212 | file_info.m_total_selectors = pHeader->m_total_selectors; |
| 10213 | file_info.m_selector_codebook_ofs = pHeader->m_selector_cb_file_ofs; |
| 10214 | file_info.m_selector_codebook_size = pHeader->m_selector_cb_file_size; |
| 10215 | |
| 10216 | file_info.m_total_endpoints = pHeader->m_total_endpoints; |
| 10217 | file_info.m_endpoint_codebook_ofs = pHeader->m_endpoint_cb_file_ofs; |
| 10218 | file_info.m_endpoint_codebook_size = pHeader->m_endpoint_cb_file_size; |
| 10219 | |
| 10220 | file_info.m_tables_ofs = pHeader->m_tables_file_ofs; |
| 10221 | file_info.m_tables_size = pHeader->m_tables_file_size; |
| 10222 | |
| 10223 | file_info.m_tex_format = static_cast<basis_tex_format>(static_cast<int>(pHeader->m_tex_format)); |
| 10224 | |
| 10225 | file_info.m_etc1s = (pHeader->m_tex_format == (int)basis_tex_format::cETC1S); |
| 10226 | |
| 10227 | file_info.m_y_flipped = (pHeader->m_flags & cBASISHeaderFlagYFlipped) != 0; |
| 10228 | file_info.m_has_alpha_slices = (pHeader->m_flags & cBASISHeaderFlagHasAlphaSlices) != 0; |
| 10229 | |
| 10230 | const uint32_t total_slices = pHeader->m_total_slices; |
| 10231 | |
| 10232 | file_info.m_slice_info.resize(total_slices); |
| 10233 | |
| 10234 | file_info.m_slices_size = 0; |
| 10235 | |
| 10236 | file_info.m_tex_type = static_cast<basis_texture_type>(static_cast<uint8_t>(pHeader->m_tex_type)); |
| 10237 | |
| 10238 | if (file_info.m_tex_type > cBASISTexTypeTotal) |
| 10239 | { |
| 10240 | BASISU_DEVEL_ERROR("basisu_transcoder::get_file_info: invalid texture type, file is corrupted\n"); |
| 10241 | return false; |
| 10242 | } |
| 10243 | |
| 10244 | file_info.m_us_per_frame = pHeader->m_us_per_frame; |
| 10245 | file_info.m_userdata0 = pHeader->m_userdata0; |
| 10246 | file_info.m_userdata1 = pHeader->m_userdata1; |
| 10247 | |
| 10248 | file_info.m_image_mipmap_levels.resize(0); |
| 10249 | file_info.m_image_mipmap_levels.resize(pHeader->m_total_images); |
| 10250 | |
| 10251 | file_info.m_total_images = pHeader->m_total_images; |
| 10252 | |
| 10253 | for (uint32_t i = 0; i < total_slices; i++) |
| 10254 | { |
no test coverage detected