Haio
0.2.X
Homebrew Asset IO/CDN
Toggle main menu visibility
Loading...
Searching...
No Matches
detect.cpp
Go to the documentation of this file.
1
#include <
haio_codec.hpp
>
2
#include <
haio_util.hpp
>
3
4
#include <
haio_util.hpp
>
5
6
namespace
{
7
8
/** the container is only half the answer: the header also says which colour it holds */
9
bool
isContainer(
Haio::Bytes
data) {
10
11
12
constexpr
std::array<uint8_t, 4> magic = {
'P'
,
'V'
,
'R'
, 0x03};
13
return
Haio::Util::matches
(data, magic);
14
}
15
16
}
17
18
namespace
Haio::Codecs
{
19
20
/**
21
* @addtogroup detect
22
* @{
23
*/
24
template
<>
25
bool
Detect<Format::PVR, Color::ETC1>
(
Bytes
data) {
26
if
(!isContainer(data))
return
false
;
27
const
auto
colour =
Util::GPU::colorFromPVR
(
Util::readU64LE
(data, 8));
28
return
colour && *colour ==
Color::ETC1
;
29
}
30
/** @} */
31
32
/**
33
* @addtogroup detect
34
* @{
35
*/
36
template
<>
37
bool
Detect<Format::PVR, Color::RGB565>
(
Bytes
data) {
38
if
(!isContainer(data))
return
false
;
39
const
auto
colour =
Util::GPU::colorFromPVR
(
Util::readU64LE
(data, 8));
40
return
colour && *colour ==
Color::RGB565
;
41
}
42
/** @} */
43
44
/**
45
* @addtogroup detect
46
* @{
47
*/
48
template
<>
49
bool
Detect<Format::PVR, Color::RGBA8888>
(
Bytes
data) {
50
if
(!isContainer(data))
return
false
;
51
const
auto
colour =
Util::GPU::colorFromPVR
(
Util::readU64LE
(data, 8));
52
return
colour && *colour ==
Color::RGBA8888
;
53
}
54
/** @} */
55
56
}
Haio::Codecs::Detect< Format::PVR, Color::RGB565 >
bool Detect< Format::PVR, Color::RGB565 >(Bytes data)
Definition
detect.cpp:37
Haio::Codecs::Detect< Format::PVR, Color::ETC1 >
bool Detect< Format::PVR, Color::ETC1 >(Bytes data)
Definition
detect.cpp:25
Haio::Codecs::Detect< Format::PVR, Color::RGBA8888 >
bool Detect< Format::PVR, Color::RGBA8888 >(Bytes data)
Definition
detect.cpp:49
haio_codec.hpp
haio_util.hpp
Haio::Codecs
Definition
haio_codec.hpp:136
Haio::Util::GPU::colorFromPVR
Result< Color > colorFromPVR(uint64_t format)
Definition
gpu.cpp:52
Haio::Util::readU64LE
uint64_t readU64LE(Bytes data, size_t off)
Definition
bytes.cpp:37
Haio::Util::matches
bool matches(Bytes data, Bytes magic)
Definition
matches.cpp:7
Haio::Color::RGBA8888
@ RGBA8888
Definition
haio_formats.hpp:107
Haio::Color::RGB565
@ RGB565
Definition
haio_formats.hpp:109
Haio::Color::ETC1
@ ETC1
Definition
haio_formats.hpp:138
Haio::Bytes
std::span< const uint8_t > Bytes
Definition
haio_codec.hpp:14
library
backend
codecs
container
pvr
detect.cpp
Generated by
1.18.0