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

Side by Side Diff: media/filters/opus_audio_decoder.cc

Issue 212103013: Add channel_count parameter back to AudioBuffer creation methods. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mstr
Patch Set: fix unit test Created 6 years, 9 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
« no previous file with comments | « media/filters/ffmpeg_audio_decoder.cc ('k') | no next file » | 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/filters/opus_audio_decoder.h" 5 #include "media/filters/opus_audio_decoder.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "base/sys_byteorder.h" 10 #include "base/sys_byteorder.h"
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 void OpusAudioDecoder::ResetTimestampState() { 457 void OpusAudioDecoder::ResetTimestampState() {
458 output_timestamp_helper_->SetBaseTimestamp(kNoTimestamp()); 458 output_timestamp_helper_->SetBaseTimestamp(kNoTimestamp());
459 last_input_timestamp_ = kNoTimestamp(); 459 last_input_timestamp_ = kNoTimestamp();
460 frames_to_discard_ = TimeDeltaToAudioFrames(config_.seek_preroll(), 460 frames_to_discard_ = TimeDeltaToAudioFrames(config_.seek_preroll(),
461 config_.samples_per_second()); 461 config_.samples_per_second());
462 } 462 }
463 463
464 bool OpusAudioDecoder::Decode(const scoped_refptr<DecoderBuffer>& input, 464 bool OpusAudioDecoder::Decode(const scoped_refptr<DecoderBuffer>& input,
465 scoped_refptr<AudioBuffer>* output_buffer) { 465 scoped_refptr<AudioBuffer>* output_buffer) {
466 // Allocate a buffer for the output samples. 466 // Allocate a buffer for the output samples.
467 *output_buffer = AudioBuffer::CreateBuffer(config_.sample_format(), 467 *output_buffer = AudioBuffer::CreateBuffer(
468 config_.channel_layout(), 468 config_.sample_format(),
469 config_.samples_per_second(), 469 config_.channel_layout(),
470 kMaxOpusOutputPacketSizeSamples); 470 ChannelLayoutToChannelCount(config_.channel_layout()),
471 config_.samples_per_second(),
472 kMaxOpusOutputPacketSizeSamples);
471 const int buffer_size = 473 const int buffer_size =
472 output_buffer->get()->channel_count() * 474 output_buffer->get()->channel_count() *
473 output_buffer->get()->frame_count() * 475 output_buffer->get()->frame_count() *
474 SampleFormatToBytesPerChannel(config_.sample_format()); 476 SampleFormatToBytesPerChannel(config_.sample_format());
475 477
476 float* float_output_buffer = reinterpret_cast<float*>( 478 float* float_output_buffer = reinterpret_cast<float*>(
477 output_buffer->get()->channel_data()[0]); 479 output_buffer->get()->channel_data()[0]);
478 const int frames_decoded = 480 const int frames_decoded =
479 opus_multistream_decode_float(opus_decoder_, 481 opus_multistream_decode_float(opus_decoder_,
480 input->data(), 482 input->data(),
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 output_timestamp_helper_->AddFrames(frames_decoded); 537 output_timestamp_helper_->AddFrames(frames_decoded);
536 538
537 // Discard the buffer to indicate we need more data. 539 // Discard the buffer to indicate we need more data.
538 if (!frames_to_output) 540 if (!frames_to_output)
539 *output_buffer = NULL; 541 *output_buffer = NULL;
540 542
541 return true; 543 return true;
542 } 544 }
543 545
544 } // namespace media 546 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/ffmpeg_audio_decoder.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698