-
Notifications
You must be signed in to change notification settings - Fork 141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mkv, mp4 track detection improvements #316
Conversation
47ee9b8
to
5afcb1a
Compare
if (header.atom_type != AtomType::VisualSampleEntryDvhe | ||
&& header.atom_type != AtomType::VisualSampleEntryDvh1 | ||
&& header.atom_type != AtomType::VisualSampleEntryHev1 | ||
&& header.atom_type != AtomType::VisualSampleEntryHvc1) || codec_specific.is_some() { | ||
return decode_error("isomp4: invalid hevc configuration sample entry"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it make sense to put this error in the _
match arm below?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just copied the pattern from above VisualSampleEntryAvc1, I think this check doesn't allow parsing known sample entry twice. To keep the same behavior decode error will need to be repeated for each known variant.
Is naming VisualSampleEntry better than VideoSampleEntry?
// Parse the HEVCDecoderConfigurationRecord to get the profile and level. Defined in | ||
// ISO/IEC 14496-15 section 8.3.3.1.2 | ||
let mut br = BitReaderLtr::new(&extra_data); | ||
|
||
// Configuration version is always 1. | ||
let configuration_version = br.read_bits_leq32(8)?; | ||
|
||
if configuration_version != 1 { | ||
return decode_error( | ||
"isomp4 (hvcC): unexpected hevc decoder configuration record version", | ||
); | ||
} | ||
|
||
// HEVC profile as defined in ISO/IEC 23008-2. | ||
let _general_profile_space = br.read_bits_leq32(2)?; | ||
let _general_tier_flag = br.read_bits_leq32(1)?; | ||
let general_profile_idc = br.read_bits_leq32(5)?; | ||
let _general_profile_compatibility_flags = br.read_bits_leq32(32)?; | ||
let _general_constraint_indicator_flags = br.read_bits_leq64(48)?; | ||
let general_level_idc = br.read_bits_leq32(8)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just parsing the HEVCDecoderConfigurationRecord, let me know what you think about my comment from your MKV PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will create separate crate to reuse the code.
5afcb1a
to
e52eede
Compare
Hopefully these changes will not introduce regressions with audio playback. |
8926144
to
c3a67d9
Compare
c3a67d9
to
cc9cbc5
Compare
rebased, fixed symphonia-check compilation. On a separate topic: There is a need to store multiple codec buffers per track Do you want me to convert extra_data property to a dictionary where keys will be an Enum: and values to be Box ? I would also add Hdr enumeration to understand if this file is a SDR, HDR10, HDR10+ or DolbyVision Do you like me to open a discussion on this topic, or I can create a PR with proposed changes and you will review. |
Hello, It's a holiday this weekend so I haven't gotten to doing a deep review, however, I've skimmed it over and have some thoughts. The MP4 changes look reasonable and are pretty low risk for regression. I think we can likely merge those as soon as I finish a more thorough review pass. The changes to If we are going to expand the scope of tests I'm also not enthusiastic about relying on a On the topic of struct VideoExtraDataType(u32);
struct VideoExtraData {
id: VideoExtraDataType,
data: Box<[u8]>,
}
struct VideoCodecParameters {
// ...
extra_data: Vec<VideoExtraData>,
}
mod well_known {
pub const EXTRA_DATA_TYPE_HEVC_DECODER_CONFIG_RECORD: VideoExtraDataId = VideoExtraDataId(0);
// ...
} Let's do this one in a separate PR as well since there will probably be some iteration on it. |
cc9cbc5
to
49baede
Compare
removed commit for check, will make separate PRs. |
Thanks, merged!
Hmm, if it's just for However, I did miss a couple things in my last message. In the code example I gave, the value of Option 1: struct VideoExtraDataType(u32);
pub const EXTRA_DATA_TYPE_DEFAULT: VideoExtraDataType = VideoExtraDataType(0x0);
mod well_known {
// ...
pub const EXTRA_DATA_TYPE_HEVC_DECODER_CONFIG_RECORD: VideoExtraDataType = VideoExtraDataType(0x1);
// ...
}
struct VideoExtraData {
data_type: VideoExtraDataType,
data: Box<[u8]>,
}
struct VideoCodecParameters {
// ...
extra_data: Vec<VideoExtraData>,
} Option 2: struct VideoExtraData {
data_type: Option<VideoExtraDataType>, // Can be `None` if codec only need one extra data buffer.
data: Box<[u8]>,
} |
I will try to create small PRs for easy review.
Dolby Vision HEVC files have more configuration atoms (side data) besides hvcC, for example dvcC
It might be useful if VideoCodecParameters.extra_data to be a map of buffers instead of a single buffer.