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

Side by Side Diff: media/formats/webm/webm_cluster_parser.cc

Issue 251583003: Ensure DiscardPadding is parsed as a signed integer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove bad rebase. Created 6 years, 7 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 | « media/filters/pipeline_integration_test.cc ('k') | media/formats/webm/webm_parser.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/formats/webm/webm_cluster_parser.h" 5 #include "media/formats/webm/webm_cluster_parser.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/sys_byteorder.h" 10 #include "base/sys_byteorder.h"
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 switch (id) { 184 switch (id) {
185 case kWebMIdTimecode: 185 case kWebMIdTimecode:
186 dst = &cluster_timecode_; 186 dst = &cluster_timecode_;
187 break; 187 break;
188 case kWebMIdBlockDuration: 188 case kWebMIdBlockDuration:
189 dst = &block_duration_; 189 dst = &block_duration_;
190 break; 190 break;
191 case kWebMIdBlockAddID: 191 case kWebMIdBlockAddID:
192 dst = &block_add_id_; 192 dst = &block_add_id_;
193 break; 193 break;
194 case kWebMIdDiscardPadding:
195 if (discard_padding_set_)
196 return false;
197 discard_padding_set_ = true;
198 discard_padding_ = val;
199 return true;
200 default: 194 default:
201 return true; 195 return true;
202 } 196 }
203 if (*dst != -1) 197 if (*dst != -1)
204 return false; 198 return false;
205 *dst = val; 199 *dst = val;
206 return true; 200 return true;
207 } 201 }
208 202
209 bool WebMClusterParser::ParseBlock(bool is_simple_block, const uint8* buf, 203 bool WebMClusterParser::ParseBlock(bool is_simple_block, const uint8* buf,
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 // First 8 bytes of side_data in DecoderBuffer is the BlockAddID 265 // First 8 bytes of side_data in DecoderBuffer is the BlockAddID
272 // element's value in Big Endian format. This is done to mimic ffmpeg 266 // element's value in Big Endian format. This is done to mimic ffmpeg
273 // demuxer's behavior. 267 // demuxer's behavior.
274 block_additional_data_size_ = size + sizeof(block_add_id); 268 block_additional_data_size_ = size + sizeof(block_add_id);
275 block_additional_data_.reset(new uint8[block_additional_data_size_]); 269 block_additional_data_.reset(new uint8[block_additional_data_size_]);
276 memcpy(block_additional_data_.get(), &block_add_id, 270 memcpy(block_additional_data_.get(), &block_add_id,
277 sizeof(block_add_id)); 271 sizeof(block_add_id));
278 memcpy(block_additional_data_.get() + 8, data, size); 272 memcpy(block_additional_data_.get() + 8, data, size);
279 return true; 273 return true;
280 } 274 }
275 case kWebMIdDiscardPadding: {
276 if (discard_padding_set_ || size <= 0 || size > 8)
277 return false;
278 discard_padding_set_ = true;
281 279
280 // Read in the big-endian integer.
281 discard_padding_ = static_cast<int8>(data[0]);
282 for (int i = 1; i < size; ++i)
283 discard_padding_ = (discard_padding_ << 8) | data[i];
284
285 return true;
286 }
282 default: 287 default:
283 return true; 288 return true;
284 } 289 }
285 } 290 }
286 291
287 bool WebMClusterParser::OnBlock(bool is_simple_block, int track_num, 292 bool WebMClusterParser::OnBlock(bool is_simple_block, int track_num,
288 int timecode, 293 int timecode,
289 int block_duration, 294 int block_duration,
290 int flags, 295 int flags,
291 const uint8* data, int size, 296 const uint8* data, int size,
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 WebMClusterParser::FindTextTrack(int track_num) { 579 WebMClusterParser::FindTextTrack(int track_num) {
575 const TextTrackMap::iterator it = text_track_map_.find(track_num); 580 const TextTrackMap::iterator it = text_track_map_.find(track_num);
576 581
577 if (it == text_track_map_.end()) 582 if (it == text_track_map_.end())
578 return NULL; 583 return NULL;
579 584
580 return &it->second; 585 return &it->second;
581 } 586 }
582 587
583 } // namespace media 588 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/pipeline_integration_test.cc ('k') | media/formats/webm/webm_parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698