Skip to content

Commit 0488449

Browse files
committed
✨ AV1 box parsing
1 parent e0bf854 commit 0488449

File tree

2 files changed

+37
-3
lines changed

2 files changed

+37
-3
lines changed

boxes.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,32 @@ def parse_hvcC_box(ps: Parser):
424424
ps.print(f' - NALU {n}')
425425
print_hex_dump(ps.read(ps.int(2)), ps.prefix + ' ')
426426

427-
# FIXME: implement av1C
427+
def parse_av1C_box(ps: Parser):
428+
with ps.bits(4) as br:
429+
ps.reserved('marker', br.bit(), 1)
430+
if (version := br.read(7)) != 1:
431+
raise AssertionError(f'invalid configuration version: {version}')
432+
ps.field('seq_profile', br.read(3))
433+
ps.field('seq_level_idx_0', br.read(5))
434+
ps.field('seq_tier_0', br.bit())
435+
ps.field('high_bitdepth', br.bit())
436+
ps.field('twelve_bit', br.bit())
437+
ps.field('monochrome', br.bit())
438+
ps.field('chroma_subsampling_x', br.bit())
439+
ps.field('chroma_subsampling_y', br.bit())
440+
ps.field('chroma_sample_position', br.read(2))
441+
ps.reserved('reserved', br.read(3))
442+
443+
if br.bit():
444+
ps.field('initial_presentation_delay_minus_one', br.read(4))
445+
else:
446+
ps.reserved('reserved', br.read(4))
447+
448+
ps.print('configOBUs =')
449+
print_hex_dump(ps.read(), ps.prefix + ' ')
450+
451+
def parse_av1f_box(ps: Parser):
452+
ps.field('fwd_distance', ps.int(1))
428453

429454
def parse_esds_box(ps: Parser):
430455
parse_fullbox(ps)

tests/lavf-av1.mp4.txt

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,17 @@
5252
size = 320 × 240
5353
compressorname = 'Lavc60.31.102 libaom-av1'
5454
[av1C] AV1CodecConfiguration @ 0x295a, 0x2962 - 0x2975 (19)
55-
81 20 00 00 0a 0d 20 00 00 04 3c ff bc ff f9 a0 . .... ...<.....
56-
21 a0 04 !..
55+
seq_profile = 1
56+
seq_level_idx_0 = 0
57+
seq_tier_0 = False
58+
high_bitdepth = False
59+
twelve_bit = False
60+
monochrome = False
61+
chroma_subsampling_x = False
62+
chroma_subsampling_y = False
63+
chroma_sample_position = 0
64+
configOBUs =
65+
0a 0d 20 00 00 04 3c ff bc ff f9 a0 21 a0 04 .. ...<.....!..
5766
[fiel] @ 0x2975, 0x297d - 0x297f (2)
5867
01 00 ..
5968
[pasp] PixelAspectRatio @ 0x297f, 0x2987 - 0x298f (8)

0 commit comments

Comments
 (0)