1 | // basisu_basis_file.h |
2 | // Copyright (C) 2019 Binomial LLC. All Rights Reserved. |
3 | // |
4 | // Licensed under the Apache License, Version 2.0 (the "License"); |
5 | // you may not use this file except in compliance with the License. |
6 | // You may obtain a copy of the License at |
7 | // |
8 | // http://www.apache.org/licenses/LICENSE-2.0 |
9 | // |
10 | // Unless required by applicable law or agreed to in writing, software |
11 | // distributed under the License is distributed on an "AS IS" BASIS, |
12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | // See the License for the specific language governing permissions and |
14 | // limitations under the License. |
15 | #pragma once |
16 | #include "../transcoder/basisu_file_headers.h" |
17 | #include "basisu_backend.h" |
18 | |
19 | namespace basisu |
20 | { |
21 | class basisu_file |
22 | { |
23 | BASISU_NO_EQUALS_OR_COPY_CONSTRUCT(basisu_file); |
24 | |
25 | public: |
26 | basisu_file() |
27 | { |
28 | } |
29 | |
30 | void clear() |
31 | { |
32 | m_comp_data.clear(); |
33 | |
34 | clear_obj(m_header); |
35 | m_images_descs.clear(); |
36 | |
37 | m_header_file_ofs = 0; |
38 | m_slice_descs_file_ofs = 0; |
39 | m_endpoint_cb_file_ofs = 0; |
40 | m_selector_cb_file_ofs = 0; |
41 | m_tables_file_ofs = 0; |
42 | m_first_image_file_ofs = 0; |
43 | m_total_file_size = 0; |
44 | } |
45 | |
46 | bool init(const basisu_backend_output& encoder_output, basist::basis_texture_type tex_type, uint32_t userdata0, uint32_t userdata1, bool y_flipped, uint32_t us_per_frame); |
47 | |
48 | const uint8_vec &get_compressed_data() const { return m_comp_data; } |
49 | |
50 | private: |
51 | basist::basis_file_header ; |
52 | basisu::vector<basist::basis_slice_desc> m_images_descs; |
53 | |
54 | uint8_vec m_comp_data; |
55 | |
56 | uint32_t ; |
57 | uint32_t m_slice_descs_file_ofs; |
58 | uint32_t m_endpoint_cb_file_ofs; |
59 | uint32_t m_selector_cb_file_ofs; |
60 | uint32_t m_tables_file_ofs; |
61 | uint32_t m_first_image_file_ofs; |
62 | uint32_t m_total_file_size; |
63 | |
64 | void (const basisu_backend_output& encoder_output, basist::basis_texture_type tex_type, uint32_t userdata0, uint32_t userdata1, bool y_flipped, uint32_t us_per_frame); |
65 | bool create_image_descs(const basisu_backend_output& encoder_output); |
66 | void create_comp_data(const basisu_backend_output& encoder_output); |
67 | void fixup_crcs(); |
68 | }; |
69 | |
70 | } // namespace basisu |
71 | |