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

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

Issue 251893002: Support start trimming post-decoding. Use it with FFmpegDemuxer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments. 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
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 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 } 411 }
412 412
413 status = opus_multistream_decoder_ctl( 413 status = opus_multistream_decoder_ctl(
414 opus_decoder_, OPUS_SET_GAIN(opus_extra_data.gain_db)); 414 opus_decoder_, OPUS_SET_GAIN(opus_extra_data.gain_db));
415 if (status != OPUS_OK) { 415 if (status != OPUS_OK) {
416 DLOG(ERROR) << "Failed to set OPUS header gain; status=" 416 DLOG(ERROR) << "Failed to set OPUS header gain; status="
417 << opus_strerror(status); 417 << opus_strerror(status);
418 return false; 418 return false;
419 } 419 }
420 420
421 discard_helper_.reset(new AudioDiscardHelper(config_.samples_per_second())); 421 discard_helper_.reset(
422 new AudioDiscardHelper(config_.samples_per_second(), 0));
422 start_input_timestamp_ = kNoTimestamp(); 423 start_input_timestamp_ = kNoTimestamp();
423 return true; 424 return true;
424 } 425 }
425 426
426 void OpusAudioDecoder::CloseDecoder() { 427 void OpusAudioDecoder::CloseDecoder() {
427 if (opus_decoder_) { 428 if (opus_decoder_) {
428 opus_multistream_decoder_destroy(opus_decoder_); 429 opus_multistream_decoder_destroy(opus_decoder_);
429 opus_decoder_ = NULL; 430 opus_decoder_ = NULL;
430 } 431 }
431 } 432 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 output_buffer->get()->TrimEnd(trim_frames); 476 output_buffer->get()->TrimEnd(trim_frames);
476 477
477 // Handles discards and timestamping. Discard the buffer if more data needed. 478 // Handles discards and timestamping. Discard the buffer if more data needed.
478 if (!discard_helper_->ProcessBuffers(input, *output_buffer)) 479 if (!discard_helper_->ProcessBuffers(input, *output_buffer))
479 *output_buffer = NULL; 480 *output_buffer = NULL;
480 481
481 return true; 482 return true;
482 } 483 }
483 484
484 } // namespace media 485 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698