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

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

Issue 2361903002: mp4: skip 0 size trun samples (Closed)
Patch Set: replace DVLOG with LIMITED_MEDIA_LOG Created 4 years, 3 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/mp4_stream_parser.cc
diff --git a/media/formats/mp4/mp4_stream_parser.cc b/media/formats/mp4/mp4_stream_parser.cc
index 23f2d2401636e4634fbbe9afec29c335848f6d02..60a8e7eb04dd493aa3ca35f578bc5817fdadad35 100644
--- a/media/formats/mp4/mp4_stream_parser.cc
+++ b/media/formats/mp4/mp4_stream_parser.cc
@@ -33,6 +33,10 @@
namespace media {
namespace mp4 {
+namespace {
+const int kMaxEmptySampleLogs = 20;
+}
wolenetz 2016/09/23 19:14:54 nit: // namespace
+
MP4StreamParser::MP4StreamParser(const std::set<int>& audio_object_types,
bool has_sbr)
: state_(kWaitingForInit),
@@ -43,8 +47,8 @@ MP4StreamParser::MP4StreamParser(const std::set<int>& audio_object_types,
has_video_(false),
audio_object_types_(audio_object_types),
has_sbr_(has_sbr),
- num_top_level_box_skipped_(0) {
-}
+ num_top_level_box_skipped_(0),
wolenetz 2016/09/23 19:14:54 aside: this other counter is no longer used. we sh
+ num_emtpy_samples_skipped_(0) {}
MP4StreamParser::~MP4StreamParser() {}
@@ -557,6 +561,16 @@ bool MP4StreamParser::EnqueueSample(BufferQueueMap* buffers, bool* err) {
queue_.PeekAt(runs_->sample_offset() + moof_head_, &buf, &buf_size);
if (buf_size < runs_->sample_size()) return false;
+ if (runs_->sample_size() == 0) {
+ // Generally not expected, but spec allows it. Code below this block assumes
+ // the current sample is not empty.
+ LIMITED_MEDIA_LOG(DEBUG, media_log_, num_emtpy_samples_skipped_,
+ kMaxEmptySampleLogs)
+ << " Skipping 'trun' sample with size of 0.";
+ runs_->AdvanceSample();
+ return true;
+ }
+
std::unique_ptr<DecryptConfig> decrypt_config;
std::vector<SubsampleEntry> subsamples;
if (runs_->is_encrypted()) {
« media/formats/mp4/mp4_stream_parser.h ('K') | « media/formats/mp4/mp4_stream_parser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698