Repository navigation
Expand file tree
/
Copy pathpyrowave_bitstream_header.hpp
More file actions
106 lines (91 loc) · 2.34 KB
/
Copy pathpyrowave_bitstream_header.hpp
File metadata and controls
106 lines (91 loc) · 2.34 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
// Copyright (c) 2025-2026 Hans-Kristian Arntzen and Foundation Sunshine contributors
// Copyright (c) 2026 AlkaidLab contributors
// SPDX-License-Identifier: MIT AND GPL-3.0-only
#pragma once
#include <stdint.h>
namespace PyroWave
{
struct BitstreamPacket
{
uint32_t offset_u32;
uint32_t num_words;
};
struct BitstreamHeader
{
uint16_t ballot;
uint16_t payload_words : 12;
uint16_t sequence : 3;
uint16_t extended : 1;
uint32_t quant_code : 8;
uint32_t block_index : 24;
};
static_assert(sizeof(BitstreamHeader) == 8, "BitstreamHeader is not 8 bytes.");
enum
{
BITSTREAM_EXTENDED_CODE_START_OF_FRAME = 0,
// Uses the legacy sequence-header layout but selects the negotiated
// color-metadata extension. In this first extension, code=1 represents HLG;
// all other color fields remain in their legacy one-bit positions.
BITSTREAM_EXTENDED_CODE_COLOR_METADATA = 1,
};
enum
{
CHROMA_RESOLUTION_420 = 0,
CHROMA_RESOLUTION_444 = 1
};
enum
{
CHROMA_SITING_CENTER = 0,
CHROMA_SITING_LEFT = 1
};
enum
{
YCBCR_RANGE_FULL = 0,
YCBCR_RANGE_LIMITED = 1
};
enum
{
COLOR_PRIMARIES_BT709 = 0,
COLOR_PRIMARIES_SRGB = COLOR_PRIMARIES_BT709,
COLOR_PRIMARIES_BT2020 = 1
};
enum
{
YCBCR_TRANSFORM_BT709 = 0,
YCBCR_TRANSFORM_BT2020 = 1
};
enum
{
TRANSFER_FUNCTION_BT709 = 0,
// Upstream's code=0 name; the alias preserves the wire value, not EOTF equivalence.
TRANSFER_FUNCTION_SRGB = TRANSFER_FUNCTION_BT709,
TRANSFER_FUNCTION_PQ = 1,
TRANSFER_FUNCTION_HLG = 2
};
static constexpr uint32_t SequenceCountMask = 0x7;
struct BitstreamSequenceHeader
{
uint32_t width_minus_1 : 14;
uint32_t height_minus_1 : 14;
uint32_t sequence : 3;
uint32_t extended : 1;
// Keep the code=0 layout identical to the upstream bitstream contract.
uint32_t total_blocks : 24;
uint32_t code : 2;
uint32_t chroma_resolution : 1;
uint32_t color_primaries : 1;
uint32_t transfer_function : 1;
uint32_t ycbcr_transform : 1;
uint32_t ycbcr_range : 1;
uint32_t chroma_siting : 1;
};
static_assert(sizeof(BitstreamSequenceHeader) == 8, "BitstreamSequenceHeader is not 8 bytes.");
struct BitstreamColorMetadata
{
uint32_t color_primaries = COLOR_PRIMARIES_BT709;
uint32_t transfer_function = TRANSFER_FUNCTION_BT709;
uint32_t ycbcr_transform = YCBCR_TRANSFORM_BT709;
uint32_t ycbcr_range = YCBCR_RANGE_FULL;
uint32_t chroma_siting = CHROMA_SITING_CENTER;
};
} // namespace PyroWave