Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(112)

Unified Diff: media/formats/mp4/avc.cc

Issue 379983002: Fix AnnexB validation logic to work with encrypted content. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Change method name and fix crash Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: media/formats/mp4/avc.cc
diff --git a/media/formats/mp4/avc.cc b/media/formats/mp4/avc.cc
index 6c2bc2a6fcabab937df14a2fdf78f9bdc43ce90b..8599e8990461b20d097fc3094498ba28e23286e7 100644
--- a/media/formats/mp4/avc.cc
+++ b/media/formats/mp4/avc.cc
@@ -76,11 +76,11 @@ bool AVC::ConvertFrameToAnnexB(int length_size, std::vector<uint8>* buffer) {
bool AVC::InsertParamSetsAnnexB(const AVCDecoderConfigurationRecord& avc_config,
std::vector<uint8>* buffer,
std::vector<SubsampleEntry>* subsamples) {
- DCHECK(AVC::IsValidAnnexB(*buffer));
+ DCHECK(AVC::IsValidAnnexB(*buffer, *subsamples));
scoped_ptr<H264Parser> parser(new H264Parser());
const uint8* start = &(*buffer)[0];
- parser->SetStream(start, buffer->size());
+ parser->SetEncryptedStream(start, buffer->size(), *subsamples);
H264NALU nalu;
if (parser->AdvanceToNextNALU(&nalu) != H264Parser::kOk)
@@ -126,7 +126,7 @@ bool AVC::InsertParamSetsAnnexB(const AVCDecoderConfigurationRecord& avc_config,
buffer->insert(config_insert_point,
param_sets.begin(), param_sets.end());
- DCHECK(AVC::IsValidAnnexB(*buffer));
+ DCHECK(AVC::IsValidAnnexB(*buffer, *subsamples));
return true;
}
@@ -171,11 +171,13 @@ bool AVC::ConvertConfigToAnnexB(
}
// Verifies AnnexB NALU order according to ISO/IEC 14496-10 Section 7.4.1.2.3
-bool AVC::IsValidAnnexB(const std::vector<uint8>& buffer) {
- return IsValidAnnexB(&buffer[0], buffer.size());
+bool AVC::IsValidAnnexB(const std::vector<uint8>& buffer,
+ const std::vector<SubsampleEntry>& subsamples) {
+ return IsValidAnnexB(&buffer[0], buffer.size(), subsamples);
}
-bool AVC::IsValidAnnexB(const uint8* buffer, size_t size) {
+bool AVC::IsValidAnnexB(const uint8* buffer, size_t size,
+ const std::vector<SubsampleEntry>& subsamples) {
DVLOG(1) << __FUNCTION__;
DCHECK(buffer);
@@ -183,7 +185,7 @@ bool AVC::IsValidAnnexB(const uint8* buffer, size_t size) {
return true;
H264Parser parser;
- parser.SetStream(buffer, size);
+ parser.SetEncryptedStream(buffer, size, subsamples);
typedef enum {
kAUDAllowed,
@@ -222,6 +224,7 @@ bool AVC::IsValidAnnexB(const uint8* buffer, size_t size) {
if (order_state > kBeforeFirstVCL) {
DVLOG(1) << "Unexpected NALU type " << nalu.nal_unit_type
<< " in order_state " << order_state;
+
return false;
}
order_state = kBeforeFirstVCL;
@@ -305,6 +308,5 @@ bool AVC::IsValidAnnexB(const uint8* buffer, size_t size) {
return order_state >= kAfterFirstVCL;
}
-
} // namespace mp4
} // namespace media

Powered by Google App Engine
This is Rietveld 408576698