Index: media/filters/opus_audio_decoder.cc |
diff --git a/media/filters/opus_audio_decoder.cc b/media/filters/opus_audio_decoder.cc |
index 6e5d9ed79a294e637f0b049e3ccdbae33e2c3f93..947e499d9e6e153a258c0cf4c85f33980bff4b25 100644 |
--- a/media/filters/opus_audio_decoder.cc |
+++ b/media/filters/opus_audio_decoder.cc |
@@ -36,7 +36,7 @@ static inline bool IsEndOfStream(int decoded_size, |
// Two conditions to meet to declare end of stream for this decoder: |
// 1. Opus didn't output anything. |
// 2. An end of stream buffer is received. |
- return decoded_size == 0 && input->IsEndOfStream(); |
+ return decoded_size == 0 && input->end_of_stream(); |
} |
// The Opus specification is part of IETF RFC 6716: |
@@ -90,33 +90,33 @@ static void RemapOpusChannelLayout(const uint8* opus_mapping, |
// These are the FFmpeg channel layouts expressed using the position of each |
// channel in the output stream from libopus. |
const uint8 kFFmpegChannelLayouts[num_layouts][num_layout_values] = { |
- { 0 }, |
+ {0}, |
// Stereo: No reorder. |
- { 0, 1 }, |
+ {0, 1}, |
// 3 Channels, from Vorbis order to: |
// L, R, Center |
- { 0, 2, 1 }, |
+ {0, 2, 1}, |
// 4 Channels: No reorder. |
- { 0, 1, 2, 3 }, |
+ {0, 1, 2, 3}, |
// 5 Channels, from Vorbis order to: |
// Front L, Front R, Center, Back L, Back R |
- { 0, 2, 1, 3, 4 }, |
+ {0, 2, 1, 3, 4}, |
// 6 Channels (5.1), from Vorbis order to: |
// Front L, Front R, Center, LFE, Back L, Back R |
- { 0, 2, 1, 5, 3, 4 }, |
+ {0, 2, 1, 5, 3, 4}, |
// 7 Channels (6.1), from Vorbis order to: |
// Front L, Front R, Front Center, LFE, Side L, Side R, Back Center |
- { 0, 2, 1, 6, 3, 4, 5 }, |
+ {0, 2, 1, 6, 3, 4, 5}, |
// 8 Channels (7.1), from Vorbis order to: |
// Front L, Front R, Center, LFE, Back L, Back R, Side L, Side R |
- { 0, 2, 1, 7, 5, 6, 3, 4 }, |
+ {0, 2, 1, 7, 5, 6, 3, 4}, |
}; |
// Reorder the channels to produce the same ordering as FFmpeg, which is |
@@ -155,7 +155,8 @@ static void RemapOpusChannelLayout(const uint8* opus_mapping, |
// stereo output: Opus streams with more than 2 channels require a stream map. |
static const int kMaxChannelsWithDefaultLayout = 2; |
static const uint8 kDefaultOpusChannelLayout[kMaxChannelsWithDefaultLayout] = { |
- 0, 1 }; |
+ 0, 1 |
+}; |
// Size of the Opus header excluding optional mapping information. |
static const int kOpusHeaderSize = 19; |
@@ -186,9 +187,8 @@ struct OpusHeader { |
channel_mapping(0), |
num_streams(0), |
num_coupled(0) { |
- memcpy(stream_map, |
- kDefaultOpusChannelLayout, |
- kMaxChannelsWithDefaultLayout); |
+ memcpy( |
+ stream_map, kDefaultOpusChannelLayout, kMaxChannelsWithDefaultLayout); |
} |
int channels; |
int skip_samples; |
@@ -201,7 +201,8 @@ struct OpusHeader { |
// Returns true when able to successfully parse and store Opus header data in |
// data parsed in |header|. Based on opus header parsing code in libopusdec |
// from FFmpeg, and opus_header from Xiph's opus-tools project. |
-static void ParseOpusHeader(const uint8* data, int data_size, |
+static void ParseOpusHeader(const uint8* data, |
+ int data_size, |
const AudioDecoderConfig& config, |
OpusHeader* header) { |
CHECK_GE(data_size, kOpusHeaderSize); |
@@ -251,13 +252,11 @@ OpusAudioDecoder::OpusAudioDecoder( |
samples_per_second_(0), |
last_input_timestamp_(kNoTimestamp()), |
output_bytes_to_drop_(0), |
- skip_samples_(0) { |
-} |
+ skip_samples_(0) {} |
-void OpusAudioDecoder::Initialize( |
- DemuxerStream* stream, |
- const PipelineStatusCB& status_cb, |
- const StatisticsCB& statistics_cb) { |
+void OpusAudioDecoder::Initialize(DemuxerStream* stream, |
+ const PipelineStatusCB& status_cb, |
+ const StatisticsCB& statistics_cb) { |
DCHECK(message_loop_->BelongsToCurrentThread()); |
PipelineStatusCB initialize_cb = BindToCurrentLoop(status_cb); |
@@ -324,9 +323,8 @@ void OpusAudioDecoder::ReadFromDemuxerStream() { |
demuxer_stream_->Read(base::Bind(&OpusAudioDecoder::BufferReady, weak_this_)); |
} |
-void OpusAudioDecoder::BufferReady( |
- DemuxerStream::Status status, |
- const scoped_refptr<DecoderBuffer>& input) { |
+void OpusAudioDecoder::BufferReady(DemuxerStream::Status status, |
+ const scoped_refptr<DecoderBuffer>& input) { |
DCHECK(message_loop_->BelongsToCurrentThread()); |
DCHECK(!read_cb_.is_null()); |
DCHECK_EQ(status != DemuxerStream::kOk, !input.get()) << status; |
@@ -356,14 +354,14 @@ void OpusAudioDecoder::BufferReady( |
// Libopus does not buffer output. Decoding is complete when an end of stream |
// input buffer is received. |
- if (input->IsEndOfStream()) { |
+ if (input->end_of_stream()) { |
base::ResetAndReturn(&read_cb_).Run(kOk, DataBuffer::CreateEOSBuffer()); |
return; |
} |
// Make sure we are notified if http://crbug.com/49709 returns. Issue also |
// occurs with some damaged files. |
- if (input->GetTimestamp() == kNoTimestamp() && |
+ if (input->timestamp() == kNoTimestamp() && |
output_timestamp_helper_->base_timestamp() == kNoTimestamp()) { |
DVLOG(1) << "Received a buffer without timestamps!"; |
base::ResetAndReturn(&read_cb_).Run(kDecodeError, NULL); |
@@ -371,17 +369,17 @@ void OpusAudioDecoder::BufferReady( |
} |
if (last_input_timestamp_ != kNoTimestamp() && |
- input->GetTimestamp() != kNoTimestamp() && |
- input->GetTimestamp() < last_input_timestamp_) { |
- base::TimeDelta diff = input->GetTimestamp() - last_input_timestamp_; |
+ input->timestamp() != kNoTimestamp() && |
+ input->timestamp() < last_input_timestamp_) { |
+ base::TimeDelta diff = input->timestamp() - last_input_timestamp_; |
DVLOG(1) << "Input timestamps are not monotonically increasing! " |
- << " ts " << input->GetTimestamp().InMicroseconds() << " us" |
- << " diff " << diff.InMicroseconds() << " us"; |
+ << " ts " << input->timestamp().InMicroseconds() << " us" |
+ << " diff " << diff.InMicroseconds() << " us"; |
base::ResetAndReturn(&read_cb_).Run(kDecodeError, NULL); |
return; |
} |
- last_input_timestamp_ = input->GetTimestamp(); |
+ last_input_timestamp_ = input->timestamp(); |
scoped_refptr<DataBuffer> output_buffer; |
@@ -430,17 +428,16 @@ bool OpusAudioDecoder::ConfigureDecoder() { |
return false; |
} |
- if (opus_decoder_ && |
- (bits_per_channel_ != config.bits_per_channel() || |
- channel_layout_ != config.channel_layout() || |
- samples_per_second_ != config.samples_per_second())) { |
+ if (opus_decoder_ && (bits_per_channel_ != config.bits_per_channel() || |
+ channel_layout_ != config.channel_layout() || |
+ samples_per_second_ != config.samples_per_second())) { |
DVLOG(1) << "Unsupported config change :"; |
- DVLOG(1) << "\tbits_per_channel : " << bits_per_channel_ |
- << " -> " << config.bits_per_channel(); |
- DVLOG(1) << "\tchannel_layout : " << channel_layout_ |
- << " -> " << config.channel_layout(); |
- DVLOG(1) << "\tsample_rate : " << samples_per_second_ |
- << " -> " << config.samples_per_second(); |
+ DVLOG(1) << "\tbits_per_channel : " << bits_per_channel_ << " -> " |
+ << config.bits_per_channel(); |
+ DVLOG(1) << "\tchannel_layout : " << channel_layout_ << " -> " |
+ << config.channel_layout(); |
+ DVLOG(1) << "\tsample_rate : " << samples_per_second_ << " -> " |
+ << config.samples_per_second(); |
return false; |
} |
@@ -453,9 +450,8 @@ bool OpusAudioDecoder::ConfigureDecoder() { |
// Parse the Opus header. |
OpusHeader opus_header; |
- ParseOpusHeader(config.extra_data(), config.extra_data_size(), |
- config, |
- &opus_header); |
+ ParseOpusHeader( |
+ config.extra_data(), config.extra_data_size(), config, &opus_header); |
skip_samples_ = opus_header.skip_samples; |
@@ -468,9 +464,8 @@ bool OpusAudioDecoder::ConfigureDecoder() { |
kMaxChannelsWithDefaultLayout); |
if (channel_count > kMaxChannelsWithDefaultLayout) { |
- RemapOpusChannelLayout(opus_header.stream_map, |
- channel_count, |
- channel_mapping); |
+ RemapOpusChannelLayout( |
+ opus_header.stream_map, channel_count, channel_mapping); |
} |
// Init Opus. |
@@ -515,28 +510,30 @@ bool OpusAudioDecoder::Decode(const scoped_refptr<DecoderBuffer>& input, |
scoped_refptr<DataBuffer>* output_buffer) { |
const int samples_decoded = |
opus_multistream_decode(opus_decoder_, |
- input->GetData(), input->GetDataSize(), |
+ input->data(), |
+ input->data_size(), |
&output_buffer_[0], |
kMaxOpusOutputPacketSizeSamples, |
0); |
if (samples_decoded < 0) { |
LOG(ERROR) << "opus_multistream_decode failed for" |
- << " timestamp: " << input->GetTimestamp().InMicroseconds() |
- << " us, duration: " << input->GetDuration().InMicroseconds() |
- << " us, packet size: " << input->GetDataSize() << " bytes with" |
+ << " timestamp: " << input->timestamp().InMicroseconds() |
+ << " us, duration: " << input->duration().InMicroseconds() |
+ << " us, packet size: " << input->data_size() << " bytes with" |
<< " status: " << opus_strerror(samples_decoded); |
return false; |
} |
uint8* decoded_audio_data = reinterpret_cast<uint8*>(&output_buffer_[0]); |
- int decoded_audio_size = samples_decoded * |
+ int decoded_audio_size = |
+ samples_decoded * |
demuxer_stream_->audio_decoder_config().bytes_per_frame(); |
DCHECK_LE(decoded_audio_size, kMaxOpusOutputPacketSizeBytes); |
if (output_timestamp_helper_->base_timestamp() == kNoTimestamp() && |
- !input->IsEndOfStream()) { |
- DCHECK(input->GetTimestamp() != kNoTimestamp()); |
- output_timestamp_helper_->SetBaseTimestamp(input->GetTimestamp()); |
+ !input->end_of_stream()) { |
+ DCHECK(input->timestamp() != kNoTimestamp()); |
+ output_timestamp_helper_->SetBaseTimestamp(input->timestamp()); |
} |
if (decoded_audio_size > 0 && output_bytes_to_drop_ > 0) { |
@@ -549,8 +546,8 @@ bool OpusAudioDecoder::Decode(const scoped_refptr<DecoderBuffer>& input, |
if (decoded_audio_size > 0) { |
// Copy the audio samples into an output buffer. |
- *output_buffer = DataBuffer::CopyFrom( |
- decoded_audio_data, decoded_audio_size); |
+ *output_buffer = |
+ DataBuffer::CopyFrom(decoded_audio_data, decoded_audio_size); |
(*output_buffer)->set_timestamp(output_timestamp_helper_->GetTimestamp()); |
(*output_buffer)->set_duration( |
output_timestamp_helper_->GetDuration(decoded_audio_size)); |