forked from akioukun/Chaos-Zero-Nightmare-ASSet-Ripper
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSCTParser.h
More file actions
76 lines (54 loc) · 2.04 KB
/
SCTParser.h
File metadata and controls
76 lines (54 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#pragma once
#include <vector>
#include <cstdint>
#include <string>
#include <map>
#include <tuple>
#include <astcenc.h>
namespace SCTParser {
static constexpr int SCT2_SIGNATURE = 844383059;
static constexpr int SCT_SIGNATURE_WORD = 17235;
static constexpr uint8_t SCT_SIGNATURE_BYTE = 84;
enum class Format {
Unknown = -1,
SCT = 10001,
SCT2 = 10002
};
struct Header {
std::vector<uint8_t> signature;
int pixel_format = 0;
uint16_t width = 0;
uint16_t height = 0;
uint16_t texture_width = 0;
uint16_t texture_height = 0;
int data_offset = 0;
bool compressed = false;
int total_size = 0;
uint8_t flags = 0;
bool has_alpha = false;
bool crop_flag = false;
bool raw_data = false;
bool mipmap_flag2 = false;
};
struct PixelFormatInfo {
std::string format;
int channels;
std::string type;
};
Format DetectFormat(const std::vector<uint8_t>& data, bool debug = false);
Header ParseSCTHeader(const std::vector<uint8_t>& data);
Header ParseSCT2Header(const std::vector<uint8_t>& data);
std::vector<uint8_t> LZ4Decompress(const std::vector<uint8_t>& compressed_data);
std::vector<uint8_t> RGB565LEToRGB(const std::vector<uint8_t>& data);
std::vector<uint8_t> RGBToRGBA(const std::vector<uint8_t>& rgb_data);
void BGRASwapRB(std::vector<uint8_t>& buffer);
PixelFormatInfo GetPixelFormatInfo(int format_code);
bool ShouldDecompressIntelligently(const std::vector<uint8_t>& image_data,
int width, int height, int pixel_format,
bool verbose = false);
std::vector<uint8_t> ConvertToPNG(const std::vector<uint8_t>& data, bool verbose = false);
std::vector<uint8_t> DecodeASTC(const std::vector<uint8_t>& compressed_data,
int width, int height, int block_width, int block_height);
std::vector<uint8_t> DecodeETC2RGBA8(const std::vector<uint8_t>& compressed_data,
int width, int height, bool verbose = false);
}