Make CENC behavior of VP8/9 in ISO-BMFF the same as in WebM
- Disable subsample encryption for VP8 in ISO-BMFF - Apply block alignment to all subsamples for VP9 in ISO-BMFF, instead of just superframes. Change-Id: I8dd31cc16e87abc4d538330eaff9acb0509497df
This commit is contained in:
parent
95ef816740
commit
b891e0271e
Binary file not shown.
Binary file not shown.
|
@ -7,7 +7,7 @@
|
||||||
<ContentProtection schemeIdUri="urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b">
|
<ContentProtection schemeIdUri="urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b">
|
||||||
<cenc:pssh>AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA==</cenc:pssh>
|
<cenc:pssh>AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA==</cenc:pssh>
|
||||||
</ContentProtection>
|
</ContentProtection>
|
||||||
<Representation id="0" bandwidth="342199" codecs="vp08.00.00.08.01.01.00.00" mimeType="video/mp4" sar="1:1">
|
<Representation id="0" bandwidth="340983" codecs="vp08.00.00.08.01.01.00.00" mimeType="video/mp4" sar="1:1">
|
||||||
<BaseURL>output_video.mp4</BaseURL>
|
<BaseURL>output_video.mp4</BaseURL>
|
||||||
<SegmentBase indexRange="1019-1086" timescale="1000000">
|
<SegmentBase indexRange="1019-1086" timescale="1000000">
|
||||||
<Initialization range="0-1018"/>
|
<Initialization range="0-1018"/>
|
||||||
|
|
|
@ -141,9 +141,6 @@ Status EncryptionHandler::ProcessStreamInfo(StreamInfo* stream_info) {
|
||||||
*stream_info, encryption_options_.max_sd_pixels,
|
*stream_info, encryption_options_.max_sd_pixels,
|
||||||
encryption_options_.max_hd_pixels, encryption_options_.max_uhd1_pixels);
|
encryption_options_.max_hd_pixels, encryption_options_.max_uhd1_pixels);
|
||||||
switch (video_codec_) {
|
switch (video_codec_) {
|
||||||
case kCodecVP8:
|
|
||||||
vpx_parser_.reset(new VP8Parser);
|
|
||||||
break;
|
|
||||||
case kCodecVP9:
|
case kCodecVP9:
|
||||||
vpx_parser_.reset(new VP9Parser);
|
vpx_parser_.reset(new VP9Parser);
|
||||||
break;
|
break;
|
||||||
|
@ -156,7 +153,7 @@ Status EncryptionHandler::ProcessStreamInfo(StreamInfo* stream_info) {
|
||||||
header_parser_.reset(new H265VideoSliceHeaderParser);
|
header_parser_.reset(new H265VideoSliceHeaderParser);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// Expect an audio codec with nalu length size == 0.
|
// Other codecs should have nalu length size == 0.
|
||||||
if (nalu_length_size_ > 0) {
|
if (nalu_length_size_ > 0) {
|
||||||
LOG(WARNING) << "Unknown video codec '" << video_codec_ << "'";
|
LOG(WARNING) << "Unknown video codec '" << video_codec_ << "'";
|
||||||
return Status(error::ENCRYPTION_FAILURE, "Unknown video codec.");
|
return Status(error::ENCRYPTION_FAILURE, "Unknown video codec.");
|
||||||
|
@ -299,9 +296,10 @@ bool EncryptionHandler::CreateEncryptor(EncryptionKey* encryption_key) {
|
||||||
return initialized;
|
return initialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EncryptionHandler::EncryptVpxFrame(const std::vector<VPxFrameInfo>& vpx_frames,
|
bool EncryptionHandler::EncryptVpxFrame(
|
||||||
MediaSample* sample,
|
const std::vector<VPxFrameInfo>& vpx_frames,
|
||||||
DecryptConfig* decrypt_config) {
|
MediaSample* sample,
|
||||||
|
DecryptConfig* decrypt_config) {
|
||||||
uint8_t* data = sample->writable_data();
|
uint8_t* data = sample->writable_data();
|
||||||
const bool is_superframe = vpx_frames.size() > 1;
|
const bool is_superframe = vpx_frames.size() > 1;
|
||||||
for (const VPxFrameInfo& frame : vpx_frames) {
|
for (const VPxFrameInfo& frame : vpx_frames) {
|
||||||
|
@ -317,12 +315,10 @@ bool EncryptionHandler::EncryptVpxFrame(const std::vector<VPxFrameInfo>& vpx_fra
|
||||||
// ISO/IEC 23001-7:2016 10.2 'cbc1' 10.3 'cens'
|
// ISO/IEC 23001-7:2016 10.2 'cbc1' 10.3 'cens'
|
||||||
// The BytesOfProtectedData size SHALL be a multiple of 16 bytes to
|
// The BytesOfProtectedData size SHALL be a multiple of 16 bytes to
|
||||||
// avoid partial blocks in Subsamples.
|
// avoid partial blocks in Subsamples.
|
||||||
if (is_superframe || encryption_options_.protection_scheme == FOURCC_cbc1 ||
|
// For consistency, apply block alignment to all frames.
|
||||||
encryption_options_.protection_scheme == FOURCC_cens) {
|
const uint16_t misalign_bytes = cipher_bytes % kCencBlockSize;
|
||||||
const uint16_t misalign_bytes = cipher_bytes % kCencBlockSize;
|
clear_bytes += misalign_bytes;
|
||||||
clear_bytes += misalign_bytes;
|
cipher_bytes -= misalign_bytes;
|
||||||
cipher_bytes -= misalign_bytes;
|
|
||||||
}
|
|
||||||
|
|
||||||
decrypt_config->AddSubsample(clear_bytes, cipher_bytes);
|
decrypt_config->AddSubsample(clear_bytes, cipher_bytes);
|
||||||
if (cipher_bytes > 0)
|
if (cipher_bytes > 0)
|
||||||
|
|
|
@ -79,9 +79,6 @@ EncryptingFragmenter::EncryptingFragmenter(
|
||||||
listener_(listener) {
|
listener_(listener) {
|
||||||
DCHECK(encryption_key_);
|
DCHECK(encryption_key_);
|
||||||
switch (video_codec_) {
|
switch (video_codec_) {
|
||||||
case kCodecVP8:
|
|
||||||
vpx_parser_.reset(new VP8Parser);
|
|
||||||
break;
|
|
||||||
case kCodecVP9:
|
case kCodecVP9:
|
||||||
vpx_parser_.reset(new VP9Parser);
|
vpx_parser_.reset(new VP9Parser);
|
||||||
break;
|
break;
|
||||||
|
@ -280,13 +277,10 @@ Status EncryptingFragmenter::EncryptSample(
|
||||||
// ISO/IEC 23001-7:2016 10.2 'cbc1' 10.3 'cens'
|
// ISO/IEC 23001-7:2016 10.2 'cbc1' 10.3 'cens'
|
||||||
// The BytesOfProtectedData size SHALL be a multiple of 16 bytes to
|
// The BytesOfProtectedData size SHALL be a multiple of 16 bytes to
|
||||||
// avoid partial blocks in Subsamples.
|
// avoid partial blocks in Subsamples.
|
||||||
if (is_superframe || protection_scheme_ == FOURCC_cbc1 ||
|
// For consistency, apply block alignment to all frames.
|
||||||
protection_scheme_ == FOURCC_cens) {
|
const uint16_t misalign_bytes = subsample.cipher_bytes % kCencBlockSize;
|
||||||
const uint16_t misalign_bytes =
|
subsample.clear_bytes += misalign_bytes;
|
||||||
subsample.cipher_bytes % kCencBlockSize;
|
subsample.cipher_bytes -= misalign_bytes;
|
||||||
subsample.clear_bytes += misalign_bytes;
|
|
||||||
subsample.cipher_bytes -= misalign_bytes;
|
|
||||||
}
|
|
||||||
|
|
||||||
sample_encryption_entry.subsamples.push_back(subsample);
|
sample_encryption_entry.subsamples.push_back(subsample);
|
||||||
if (subsample.cipher_bytes > 0)
|
if (subsample.cipher_bytes > 0)
|
||||||
|
|
Loading…
Reference in New Issue