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

Unified Diff: media/mp4/box_reader.h

Issue 10938034: Eliminate box reordering in media::mp4::BoxReader. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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
« no previous file with comments | « media/mp4/box_definitions.cc ('k') | media/mp4/box_reader.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/mp4/box_reader.h
diff --git a/media/mp4/box_reader.h b/media/mp4/box_reader.h
index 211d99ac6109cb2cb58bf904570343834f53a518..967bf93071695f8621b735c663fcbaa0c361af7c 100644
--- a/media/mp4/box_reader.h
+++ b/media/mp4/box_reader.h
@@ -118,6 +118,7 @@ class MEDIA_EXPORT BoxReader : public BufferReader {
// Read all children, regardless of FourCC. This is used from exactly one box,
// corresponding to a rather significant inconsistency in the BMFF spec.
+ // Note that this method is mutually exclusive with ScanChildren().
template<typename T> bool ReadAllChildren(
std::vector<T>* children) WARN_UNUSED_RESULT;
@@ -185,19 +186,20 @@ bool BoxReader::MaybeReadChildren(std::vector<T>* children) {
template<typename T>
bool BoxReader::ReadAllChildren(std::vector<T>* children) {
- DCHECK(scanned_);
- DCHECK(children->empty());
- RCHECK(!children_.empty());
-
- children->resize(children_.size());
- typename std::vector<T>::iterator child_itr = children->begin();
- for (ChildMap::iterator itr = children_.begin();
- itr != children_.end(); ++itr) {
- RCHECK(child_itr->Parse(&itr->second));
- ++child_itr;
+ DCHECK(!scanned_);
+ scanned_ = true;
+
+ bool err = false;
+ while (pos() < size()) {
+ BoxReader child_reader(&buf_[pos_], size_ - pos_);
+ if (!child_reader.ReadHeader(&err)) break;
+ T child;
+ RCHECK(child.Parse(&child_reader));
+ children->push_back(child);
+ pos_ += child_reader.size();
}
- children_.clear();
- return true;
+
+ return !err;
}
} // namespace mp4
« no previous file with comments | « media/mp4/box_definitions.cc ('k') | media/mp4/box_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698