Skip to content

Commit 1fa6b49

Browse files
committed
EBML: Parse segment.Info.TimecodeScale
Signed-off-by: Serial <69764315+Serial-ATA@users.noreply.github.com>
1 parent 41aa9e4 commit 1fa6b49

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/ebml/read/segment_info.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
use crate::ebml::element_reader::{ElementIdent, ElementReader, ElementReaderYield};
22
use crate::ebml::properties::EbmlProperties;
33
use crate::error::Result;
4+
use crate::macros::decode_err;
45
use crate::probe::ParseOptions;
56

67
use std::io::{Read, Seek};
78

89
pub(super) fn read_from<R>(
910
element_reader: &mut ElementReader<R>,
10-
_parse_options: ParseOptions,
11-
_properties: &mut EbmlProperties,
11+
parse_options: ParseOptions,
12+
properties: &mut EbmlProperties,
1213
) -> Result<()>
1314
where
1415
R: Read + Seek,
@@ -29,7 +30,17 @@ where
2930
},
3031
ElementReaderYield::Child((child, size)) => {
3132
match child.ident {
32-
ElementIdent::TimecodeScale => todo!("Support segment.Info.TimecodeScale"),
33+
ElementIdent::TimecodeScale => {
34+
properties.segment_info.timecode_scale =
35+
element_reader.read_unsigned_int(size)?;
36+
37+
if properties.segment_info.timecode_scale == 0 {
38+
log::warn!("Segment.Info.TimecodeScale is 0, which is invalid");
39+
if parse_options.parsing_mode == crate::probe::ParsingMode::Strict {
40+
decode_err!(@BAIL Ebml, "Segment.Info.TimecodeScale must be nonzero");
41+
}
42+
}
43+
},
3344
ElementIdent::MuxingApp => todo!("Support segment.Info.MuxingApp"),
3445
ElementIdent::WritingApp => todo!("Support segment.Info.WritingApp"),
3546
_ => {

0 commit comments

Comments
 (0)