mirror of
https://github.com/WerWolv/ImHex-Patterns.git
synced 2026-03-27 23:37:04 -05:00
patterns: Added new WebP and VGM patterns (#294)
* README: fix square bracket * patterns: add WebP pattern * patterns/dds: add x-dds mimetype * patterns: add vgm pattern * patterns/vgm: remove old pointer * patterns/protobuf: fix field number handling * patterns/protobuf: add .pb file extension * patterns/uf2: updating the family IDs again * patterns/png: add cHRM and tIME chunks * patterns/png: whoops, old description snuck back in * new quantized-mesh pattern * add quantized-mesh to README, implement oct16 decoding
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
#pragma author WerWolv
|
||||
#pragma description Google Protobuf
|
||||
#pragma description Google Protobuf wire encoding (.pb)
|
||||
|
||||
import std.core;
|
||||
import std.io;
|
||||
import std.mem;
|
||||
|
||||
import type.leb128;
|
||||
@@ -31,10 +32,19 @@ enum WireType : u8 {
|
||||
_32Bit = 5
|
||||
};
|
||||
|
||||
bitfield Key {
|
||||
field_number : 5;
|
||||
wire_type : 3;
|
||||
} [[bitfield_order(std::core::BitfieldOrder::MostToLeastSignificant, 8)]];
|
||||
WireType wire_type;
|
||||
u32 tag;
|
||||
u32 field_number;
|
||||
|
||||
struct Key {
|
||||
type::uLEB128 keyDec;
|
||||
field_number = u32(keyDec) >> 3;
|
||||
wire_type = u32(keyDec) & 7;
|
||||
}[[sealed, format("format_key")]];
|
||||
|
||||
fn format_key(Key keyObject) {
|
||||
return std::format("{} with field number {}", wire_type, field_number);
|
||||
};
|
||||
|
||||
union _64Bit {
|
||||
u64 fixed64;
|
||||
@@ -49,22 +59,22 @@ union _32Bit {
|
||||
};
|
||||
|
||||
struct LengthDelimited {
|
||||
type::LEB128 length;
|
||||
type::uLEB128 length;
|
||||
char data[length];
|
||||
};
|
||||
|
||||
|
||||
struct Entry {
|
||||
Key key;
|
||||
Key key;
|
||||
|
||||
if (key.wire_type == WireType::Varint)
|
||||
type::LEB128 value;
|
||||
else if (key.wire_type == WireType::_64Bit)
|
||||
if (wire_type == WireType::Varint)
|
||||
type::uLEB128 value;
|
||||
else if (wire_type == WireType::_64Bit)
|
||||
_64Bit value;
|
||||
else if (key.wire_type == WireType::LengthDelimited)
|
||||
else if (wire_type == WireType::LengthDelimited)
|
||||
LengthDelimited value;
|
||||
else if (key.wire_type == WireType::_32Bit)
|
||||
else if (wire_type == WireType::_32Bit)
|
||||
_32Bit value;
|
||||
};
|
||||
|
||||
Entry entries[while(!std::mem::eof())] @ 0x00;
|
||||
Entry entries[while(!std::mem::eof())] @ 0x00;
|
||||
Reference in New Issue
Block a user