| OLD | NEW |
| 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_cluster_parser.h" | 5 #include "media/webm/webm_cluster_parser.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "media/base/data_buffer.h" | 8 #include "media/base/data_buffer.h" |
| 9 #include "media/ffmpeg/ffmpeg_common.h" |
| 9 #include "media/webm/webm_constants.h" | 10 #include "media/webm/webm_constants.h" |
| 10 | 11 |
| 11 namespace media { | 12 namespace media { |
| 12 | 13 |
| 13 static Buffer* CreateBuffer(const uint8* data, size_t size) { | 14 static Buffer* CreateBuffer(const uint8* data, size_t size) { |
| 14 scoped_array<uint8> buf(new uint8[size]); | 15 // Why FF_INPUT_BUFFER_PADDING_SIZE? FFmpeg assumes all input buffers are |
| 16 // padded with this value. |
| 17 scoped_array<uint8> buf(new uint8[size + FF_INPUT_BUFFER_PADDING_SIZE]); |
| 15 memcpy(buf.get(), data, size); | 18 memcpy(buf.get(), data, size); |
| 19 memset(buf.get() + size, 0, FF_INPUT_BUFFER_PADDING_SIZE); |
| 16 return new DataBuffer(buf.Pass(), size); | 20 return new DataBuffer(buf.Pass(), size); |
| 17 } | 21 } |
| 18 | 22 |
| 19 WebMClusterParser::WebMClusterParser(int64 timecode_scale, | 23 WebMClusterParser::WebMClusterParser(int64 timecode_scale, |
| 20 int audio_track_num, | 24 int audio_track_num, |
| 21 base::TimeDelta audio_default_duration, | 25 base::TimeDelta audio_default_duration, |
| 22 int video_track_num, | 26 int video_track_num, |
| 23 base::TimeDelta video_default_duration) | 27 base::TimeDelta video_default_duration) |
| 24 : timecode_multiplier_(timecode_scale / 1000.0), | 28 : timecode_multiplier_(timecode_scale / 1000.0), |
| 25 audio_track_num_(audio_track_num), | 29 audio_track_num_(audio_track_num), |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 buffer->SetDuration(video_default_duration_); | 126 buffer->SetDuration(video_default_duration_); |
| 123 queue = &video_buffers_; | 127 queue = &video_buffers_; |
| 124 } else { | 128 } else { |
| 125 DVLOG(1) << "Unexpected track number " << track_num; | 129 DVLOG(1) << "Unexpected track number " << track_num; |
| 126 return false; | 130 return false; |
| 127 } | 131 } |
| 128 | 132 |
| 129 if (!queue->empty() && | 133 if (!queue->empty() && |
| 130 buffer->GetTimestamp() == queue->back()->GetTimestamp()) { | 134 buffer->GetTimestamp() == queue->back()->GetTimestamp()) { |
| 131 DVLOG(1) << "Got SimpleBlock timecode is not strictly monotonically " | 135 DVLOG(1) << "Got SimpleBlock timecode is not strictly monotonically " |
| 132 << "increasing for track " << track_num; | 136 << "increasing for track " << track_num; |
| 133 return false; | 137 return false; |
| 134 } | 138 } |
| 135 | 139 |
| 136 queue->push_back(buffer); | 140 queue->push_back(buffer); |
| 137 return true; | 141 return true; |
| 138 } | 142 } |
| 139 | 143 |
| 140 } // namespace media | 144 } // namespace media |
| OLD | NEW |