Skip to content

Commit e85fc7e

Browse files
committed
[what][feature] 实现 DeserializeAV1TileInfoSyntax
1 parent 72563fe commit e85fc7e

6 files changed

+476
-57
lines changed

AV1BinaryReader.cpp

+40
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,17 @@ static uint8_t kRightAndLookUp[8] = {0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE, 0
5656

5757
#define MMP_AV1_I_PRED_OPERATION(bits, value) MMP_AV1_U_PRED_OPERATION(bits, value)
5858

59+
static int64_t FllorLog2(uint64_t x)
60+
{
61+
int64_t s = 0;
62+
while (x != 0)
63+
{
64+
x = x >> 1;
65+
s ++;
66+
}
67+
return s - 1;
68+
}
69+
5970
AV1BinaryReader::AV1BinaryReader(AbstractAV1ByteReader::ptr reader)
6071
{
6172
_curBitPos = 8;
@@ -91,6 +102,30 @@ int64_t AV1BinaryReader::su(size_t n)
91102
return value;
92103
}
93104

105+
uint64_t AV1BinaryReader::le(size_t n)
106+
{
107+
uint64_t t = 0;
108+
for (size_t i=0; i<n; i++)
109+
{
110+
uint64_t byte = f(8);
111+
t += (byte << (i*8));
112+
}
113+
return t;
114+
}
115+
116+
uint64_t AV1BinaryReader::ns(size_t n)
117+
{
118+
uint64_t w = FllorLog2(n) + 1;
119+
uint64_t m = (1 << w) - n;
120+
uint64_t v = f((size_t)(w - 1));
121+
if (v < m)
122+
{
123+
return v;
124+
}
125+
uint64_t extra_bit = f(1);
126+
return (v << 1) - m + extra_bit;
127+
}
128+
94129
uint64_t AV1BinaryReader::uvlc()
95130
{
96131
uint32_t leadingZeros = 0;
@@ -144,6 +179,11 @@ void AV1BinaryReader::byte_alignment()
144179
}
145180
}
146181

182+
size_t AV1BinaryReader::get_position()
183+
{
184+
return _reader->Tell() + _curBitPos;
185+
}
186+
147187
bool AV1BinaryReader::ReadBytes(size_t byte, uint8_t* value)
148188
{
149189
size_t readByte = _reader->Read(value, byte);

AV1BinaryReader.h

+3
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,14 @@ class AV1BinaryReader
2626
public:
2727
uint64_t f(size_t n);
2828
int64_t su(size_t n);
29+
uint64_t le(size_t n);
30+
uint64_t ns(size_t n);
2931
uint64_t uvlc();
3032
uint64_t leb128();
3133
uint64_t read_delta_q();
3234
public:
3335
void byte_alignment();
36+
size_t get_position();
3437
private:
3538
bool ReadBytes(size_t byte, uint8_t* value);
3639
void ReadOneByteAuto(bool force = false);

AV1Common.cpp

+13
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ AV1ObuHeaderSyntax::AV1ObuHeaderSyntax()
7373
obu_reserved_1bit = 0;
7474
}
7575

76+
AV1GeneralMetadataOBUSyntax::AV1GeneralMetadataOBUSyntax()
77+
{
78+
metadata_type = 0;
79+
}
80+
7681
AV1SuperresParamsSyntax::AV1SuperresParamsSyntax()
7782
{
7883
use_superres = 0;
@@ -222,6 +227,7 @@ AV1GeneralTileGroupOBUSyntax::AV1GeneralTileGroupOBUSyntax()
222227
tile_start_and_end_present_flag = 0;
223228
tg_start = 0;
224229
tg_end = 0;
230+
tile_size_minus_1 = 0;
225231
}
226232

227233
AV1LoopRestorationParamsSyntax::AV1LoopRestorationParamsSyntax()
@@ -269,5 +275,12 @@ AV1LoopFilterParamsSyntax::AV1LoopFilterParamsSyntax()
269275
loop_filter_delta_update = 0;
270276
}
271277

278+
AV1TileInfoSyntax::AV1TileInfoSyntax()
279+
{
280+
uniform_tile_spacing_flag = 0;
281+
context_update_tile_id = 0;
282+
tile_size_bytes_minus_1 = 0;
283+
}
284+
272285
} // namespace Codec
273286
} // namespace Mmp

AV1Common.h

+97-48
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,18 @@ enum class AV1TxMode
405405
AV1_TX_MODE_SELECT = 2
406406
};
407407

408+
/**
409+
* @sa 6.7.1. General metadata OBU semantics
410+
*/
411+
enum class AV1MetadataType
412+
{
413+
METADATA_TYPE_HDR_CLL = 1,
414+
METADATA_TYPE_HDR_MDCV = 2,
415+
METADATA_TYPE_SCALABILITY = 3,
416+
METADATA_TYPE_ITUT_T35 = 4,
417+
METADATA_TYPE_TIMECODE = 5
418+
};
419+
408420
class AV1ColorConfigSyntax
409421
{
410422
public:
@@ -480,7 +492,7 @@ class AV1TemporalDelimiterObuSyntax
480492
class AV1PaddingOBUSyntax
481493
{
482494
public:
483-
using ptr = std::shared_ptr<AV1OperatingParametersInfoSyntax>;
495+
using ptr = std::shared_ptr<AV1PaddingOBUSyntax>;
484496
public:
485497
AV1PaddingOBUSyntax();
486498
~AV1PaddingOBUSyntax();
@@ -691,9 +703,14 @@ class AV1GeneralMetadataOBUSyntax
691703
using ptr = std::shared_ptr<AV1GeneralMetadataOBUSyntax>;
692704
public:
693705
AV1GeneralMetadataOBUSyntax();
694-
~AV1GeneralMetadataOBUSyntax();
706+
~AV1GeneralMetadataOBUSyntax() = default;
695707
public:
696708
uint32_t metadata_type;
709+
AV1MetadataITUT_T35Syntax::ptr metadata_itut_t35;
710+
AV1MetadataHighDynamicRangeContentLightLevelSyntax::ptr metadata_hdr_cll;
711+
AV1MetadataHighDynamicRangeMasteringDisplayColorVolumeSyntax::ptr metadata_hdr_mdcv;
712+
AV1MetadataScalabilitySyntax::ptr metadata_scalability;
713+
AV1MetadataTimecodeSyntax::ptr metadata_timecode;
697714
};
698715

699716
class AV1SuperresParamsSyntax
@@ -802,6 +819,45 @@ class AV1QuantizationParamsSyntax
802819
uint8_t qm_v;
803820
};
804821

822+
class AV1FilmGrainParamsSyntax
823+
{
824+
public:
825+
using ptr = std::shared_ptr<AV1FilmGrainParamsSyntax>;
826+
public:
827+
AV1FilmGrainParamsSyntax();
828+
~AV1FilmGrainParamsSyntax() = default;
829+
public:
830+
uint8_t apply_grain;
831+
uint16_t grain_seed;
832+
uint8_t update_grain;
833+
uint8_t film_grain_params_ref_idx;
834+
uint8_t num_y_points;
835+
std::vector<uint8_t> point_y_value;
836+
std::vector<uint8_t> point_y_scaling;
837+
uint8_t chroma_scaling_from_luma;
838+
uint8_t num_cb_points;
839+
std::vector<uint8_t> point_cb_value;
840+
std::vector<uint8_t> point_cb_scaling;
841+
uint8_t num_cr_points;
842+
std::vector<uint8_t> point_cr_value;
843+
std::vector<uint8_t> point_cr_scaling;
844+
uint8_t grain_scaling_minus_8;
845+
uint8_t ar_coeff_lag;
846+
std::vector<uint8_t> ar_coeffs_y_plus_128;
847+
std::vector<uint8_t> ar_coeffs_cb_plus_128;
848+
std::vector<uint8_t> ar_coeffs_cr_plus_128;
849+
uint8_t ar_coeff_shift_minus_6;
850+
uint8_t grain_scale_shift;
851+
uint8_t cb_mult;
852+
uint8_t cb_luma_mult;
853+
uint16_t cb_offset;
854+
uint8_t cr_mult;
855+
uint8_t cr_luma_mult;
856+
uint16_t cr_offset;
857+
uint8_t overlap_flag;
858+
uint8_t clip_to_restricted_range;
859+
};
860+
805861
class AV1UncompressedHeaderSyntax
806862
{
807863
public:
@@ -820,8 +876,16 @@ class AV1UncompressedHeaderSyntax
820876
uint8_t frame_size_override_flag;
821877
uint8_t allow_intrabc;
822878
uint8_t primary_ref_frame;
879+
uint8_t error_resilient_mode;
880+
uint8_t disable_cdf_update;
881+
uint8_t allow_screen_content_tools;
882+
uint8_t force_integer_mv;
883+
uint64_t current_frame_id;
884+
uint8_t buffer_removal_time_present_flag;
885+
std::vector<uint64_t> buffer_removal_time;
823886
public:
824887
AV1TemporalPointInfoSyntax::ptr temporal_point_info;
888+
AV1FilmGrainParamsSyntax::ptr load_grain_params;
825889
};
826890

827891
class AV1TxModeSyntax
@@ -846,45 +910,6 @@ class AV1FrameReferenceModeSyntax
846910
uint8_t reference_select;
847911
};
848912

849-
class AV1FilmGrainParamsSyntax
850-
{
851-
public:
852-
using ptr = std::shared_ptr<AV1FilmGrainParamsSyntax>;
853-
public:
854-
AV1FilmGrainParamsSyntax();
855-
~AV1FilmGrainParamsSyntax() = default;
856-
public:
857-
uint8_t apply_grain;
858-
uint16_t grain_seed;
859-
uint8_t update_grain;
860-
uint8_t film_grain_params_ref_idx;
861-
uint8_t num_y_points;
862-
std::vector<uint8_t> point_y_value;
863-
std::vector<uint8_t> point_y_scaling;
864-
uint8_t chroma_scaling_from_luma;
865-
uint8_t num_cb_points;
866-
std::vector<uint8_t> point_cb_value;
867-
std::vector<uint8_t> point_cb_scaling;
868-
uint8_t num_cr_points;
869-
std::vector<uint8_t> point_cr_value;
870-
std::vector<uint8_t> point_cr_scaling;
871-
uint8_t grain_scaling_minus_8;
872-
uint8_t ar_coeff_lag;
873-
std::vector<uint8_t> ar_coeffs_y_plus_128;
874-
std::vector<uint8_t> ar_coeffs_cb_plus_128;
875-
std::vector<uint8_t> ar_coeffs_cr_plus_128;
876-
uint8_t ar_coeff_shift_minus_6;
877-
uint8_t grain_scale_shift;
878-
uint8_t cb_mult;
879-
uint8_t cb_luma_mult;
880-
uint16_t cb_offset;
881-
uint8_t cr_mult;
882-
uint8_t cr_luma_mult;
883-
uint16_t cr_offset;
884-
uint8_t overlap_flag;
885-
uint8_t clip_to_restricted_range;
886-
};
887-
888913
class AV1GeneralTileGroupOBUSyntax
889914
{
890915
public:
@@ -894,8 +919,9 @@ class AV1GeneralTileGroupOBUSyntax
894919
~AV1GeneralTileGroupOBUSyntax() = default;
895920
public:
896921
uint8_t tile_start_and_end_present_flag;
897-
uint32_t tg_start;
898-
uint32_t tg_end;
922+
uint64_t tg_start;
923+
uint64_t tg_end;
924+
uint64_t tile_size_minus_1;
899925
};
900926

901927
class AV1LoopRestorationParamsSyntax
@@ -1000,6 +1026,23 @@ class AV1LoopFilterParamsSyntax
10001026
uint32_t loop_filter_mode_deltas[2] = {0};
10011027
};
10021028

1029+
class AV1TileInfoSyntax
1030+
{
1031+
public:
1032+
using ptr = std::shared_ptr<AV1TileInfoSyntax>;
1033+
public:
1034+
AV1TileInfoSyntax();
1035+
~AV1TileInfoSyntax() = default;
1036+
public:
1037+
uint8_t uniform_tile_spacing_flag;
1038+
std::vector<uint8_t> increment_tile_cols_log2;
1039+
std::vector<uint8_t> increment_tile_rows_log2;
1040+
std::vector<uint64_t> width_in_sbs_minus_1;
1041+
std::vector<uint64_t> height_in_sbs_minus_1;
1042+
uint64_t context_update_tile_id;
1043+
uint8_t tile_size_bytes_minus_1;
1044+
};
1045+
10031046
/**
10041047
* @sa 7.20. Reference frame update process
10051048
*/
@@ -1045,18 +1088,24 @@ class AV1ReferenceFrameContext
10451088
uint8_t LoopRestorationSize[4];
10461089
uint8_t AllLossless;
10471090
uint8_t TxMode;
1048-
uint32_t NumTiles;
1049-
uint16_t TileCols;
1050-
uint16_t TileRows;
1051-
uint16_t TileColsLog2;
1052-
uint16_t TileRowsLog2;
1091+
uint64_t NumTiles;
1092+
uint64_t TileCols;
1093+
uint64_t TileRows;
1094+
uint64_t TileColsLog2;
1095+
uint64_t TileRowsLog2;
10531096
uint8_t FeatureEnabled[AV1_SYMBOL(MAX_SEGMENTS)][AV1_SYMBOL(SEG_LVL_MAX)] = {0};
10541097
uint8_t Segmentation_Feature_Bits[AV1_SYMBOL(SEG_LVL_MAX)] = {0};
10551098
uint8_t Segmentation_Feature_Max[AV1_SYMBOL(SEG_LVL_MAX)] = {0};
10561099
uint8_t Segmentation_Feature_Signed[AV1_SYMBOL(SEG_LVL_MAX)] = {0};
10571100
int64_t FeatureData[AV1_SYMBOL(MAX_SEGMENTS)][AV1_SYMBOL(SEG_LVL_MAX)] = {0};
10581101
uint8_t SegIdPreSkip;
10591102
uint8_t LastActiveSegId;
1103+
uint8_t RefValid[AV1_SYMBOL(NUM_REF_FRAMES)] = {0};
1104+
uint8_t RefOrderHint[AV1_SYMBOL(NUM_REF_FRAMES)] = {0};
1105+
uint8_t OrderHints[AV1_REF(LAST_FRAME) + AV1_SYMBOL(REFS_PER_FRAME)] = {0};
1106+
uint64_t TileSizeBytes;
1107+
uint64_t MiColStarts[AV1_SYMBOL(MAX_TILE_COLS)] = {0};
1108+
uint64_t MiRowStarts[AV1_SYMBOL(MAX_TILE_COLS)] = {0};
10601109
};
10611110

10621111
} // namespace Codec

0 commit comments

Comments
 (0)