Skip to content
Snippets Groups Projects
Commit d2a2fd8b authored by John Lin's avatar John Lin Committed by Beatriz Rizental
Browse files

Bug 1924070 - modify H.264 extradata to match sample conversion code....

Bug 1924070 - modify H.264 extradata to match sample conversion code. r=media-playback-reviewers,alwu

In AVC stream, NAL unit is represented with the length of unit data
(NALUnitLength) followed by the actual unit data(NALUnit). The NALUnitLength
field can be 1-4 bytes long and the size can be derived from the
'lengthSizeMinusOne' value recorded in extradata.
H264ChangeMonitor.CheckForChange() reformats all input samples so that
NALUnitLength will always be 4 bytes long while the original extradata is
used during decoder creation earlier, so decoder won't be able to correctly
parse converted samples if extradata is not modified accordingly.

Differential Revision: https://phabricator.services.mozilla.com/D239547
parent 07fed9c6
No related branches found
No related tags found
1 merge request!1527Bug 43808: Rebase 128.10.1 onto 128.11
......@@ -42,6 +42,14 @@ class H264ChangeMonitor : public MediaChangeMonitor::CodecChangeMonitor {
: mCurrentConfig(aInfo), mFullParsing(aFullParsing) {
if (CanBeInstantiated()) {
UpdateConfigFromExtraData(aInfo.mExtraData);
auto avcc = AVCCConfig::Parse(mCurrentConfig.mExtraData);
if (avcc.isOk() && avcc.unwrap().NALUSize() != 4) {
// `CheckForChange()` will use `AnnexB::ConvertSampleToAVCC()` to change
// NAL units into 4-byte.
// `AVCDecoderConfigurationRecord.lengthSizeMinusOne` in the config
// should be modified too.
mCurrentConfig.mExtraData->ReplaceElementAt(4, 0xfc | 3);
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment