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

Side by Side Diff: media/webm/webm_parser.cc

Issue 14299005: Add support for zero-padded strings to WebMParser. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix mac build Created 7 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | media/webm/webm_parser_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/webm/webm_parser.h" 5 #include "media/webm/webm_parser.h"
6 6
7 // This file contains code to parse WebM file elements. It was created 7 // This file contains code to parse WebM file elements. It was created
8 // from information in the Matroska spec. 8 // from information in the Matroska spec.
9 // http://www.matroska.org/technical/specs/index.html 9 // http://www.matroska.org/technical/specs/index.html
10 // This file contains code for encrypted WebM. Current WebM 10 // This file contains code for encrypted WebM. Current WebM
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 return size; 592 return size;
593 } 593 }
594 594
595 static int ParseBinary(const uint8* buf, int size, int id, 595 static int ParseBinary(const uint8* buf, int size, int id,
596 WebMParserClient* client) { 596 WebMParserClient* client) {
597 return client->OnBinary(id, buf, size) ? size : -1; 597 return client->OnBinary(id, buf, size) ? size : -1;
598 } 598 }
599 599
600 static int ParseString(const uint8* buf, int size, int id, 600 static int ParseString(const uint8* buf, int size, int id,
601 WebMParserClient* client) { 601 WebMParserClient* client) {
602 std::string str(reinterpret_cast<const char*>(buf), size); 602 const uint8* end = static_cast<const uint8*>(memchr(buf, '\0', size));
603 int length = (end != NULL) ? static_cast<int>(end - buf) : size;
604 std::string str(reinterpret_cast<const char*>(buf), length);
603 return client->OnString(id, str) ? size : -1; 605 return client->OnString(id, str) ? size : -1;
604 } 606 }
605 607
606 static int ParseNonListElement(ElementType type, int id, int64 element_size, 608 static int ParseNonListElement(ElementType type, int id, int64 element_size,
607 const uint8* buf, int size, 609 const uint8* buf, int size,
608 WebMParserClient* client) { 610 WebMParserClient* client) {
609 DCHECK_GE(size, element_size); 611 DCHECK_GE(size, element_size);
610 612
611 int result = -1; 613 int result = -1;
612 switch(type) { 614 switch(type) {
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
931 if (kSegmentIds[i].id_ == id_b) 933 if (kSegmentIds[i].id_ == id_b)
932 return true; 934 return true;
933 } 935 }
934 } 936 }
935 937
936 // kWebMIdSegment siblings. 938 // kWebMIdSegment siblings.
937 return ((id_b == kWebMIdSegment) || (id_b == kWebMIdEBMLHeader)); 939 return ((id_b == kWebMIdSegment) || (id_b == kWebMIdEBMLHeader));
938 } 940 }
939 941
940 } // namespace media 942 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | media/webm/webm_parser_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698