diff options
author | dalecurtis@chromium.org <dalecurtis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-25 05:24:27 +0000 |
---|---|---|
committer | dalecurtis@chromium.org <dalecurtis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-25 05:24:27 +0000 |
commit | 8f57af342d33b77c51baa017832b25f4a431a53b (patch) | |
tree | dfc613277970e31e8f923c2e8fed65a6a52d29e0 | |
parent | a656bc3cc399d064028fe4e8a6fb60c04288cc08 (diff) | |
download | chromium_src-8f57af342d33b77c51baa017832b25f4a431a53b.zip chromium_src-8f57af342d33b77c51baa017832b25f4a431a53b.tar.gz chromium_src-8f57af342d33b77c51baa017832b25f4a431a53b.tar.bz2 |
Add mp3 end padding skip for the WebAudio decoder.
Only works for MP3s with a XING header.
BUG=135291
TEST=updated hash in unittest.
Review URL: https://codereview.chromium.org/350653004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@279608 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | DEPS | 2 | ||||
-rw-r--r-- | media/ffmpeg/ffmpeg_common.h | 6 | ||||
-rw-r--r-- | media/filters/audio_file_reader.cc | 24 | ||||
-rw-r--r-- | media/filters/audio_file_reader.h | 1 | ||||
-rw-r--r-- | media/filters/audio_file_reader_unittest.cc | 4 |
5 files changed, 28 insertions, 9 deletions
@@ -215,7 +215,7 @@ deps = { "src/third_party/ffmpeg": Var("chromium_git") + - "/chromium/third_party/ffmpeg.git@5c3de8094903dd2162232b8f1be916c46acdd8f5", + "/chromium/third_party/ffmpeg.git@f620cda6d1661f1b2f3214d17b9a254f5c89225f", "src/third_party/libjingle/source/talk": (Var("googlecode_url") % "webrtc") + "/trunk/talk@" + diff --git a/media/ffmpeg/ffmpeg_common.h b/media/ffmpeg/ffmpeg_common.h index ef1a7b6..d4e85c8 100644 --- a/media/ffmpeg/ffmpeg_common.h +++ b/media/ffmpeg/ffmpeg_common.h @@ -33,11 +33,11 @@ MSVC_PUSH_DISABLE_WARNING(4244); #include <libavcodec/avcodec.h> #include <libavformat/avformat.h> #include <libavformat/avio.h> -#include <libavutil/audioconvert.h> #include <libavutil/avutil.h> -#include <libavutil/mathematics.h> -#include <libavutil/log.h> #include <libavutil/imgutils.h> +#include <libavutil/log.h> +#include <libavutil/mathematics.h> +#include <libavutil/opt.h> MSVC_POP_WARNING(); } // extern "C" diff --git a/media/filters/audio_file_reader.cc b/media/filters/audio_file_reader.cc index cb8188e..3b14355 100644 --- a/media/filters/audio_file_reader.cc +++ b/media/filters/audio_file_reader.cc @@ -20,6 +20,7 @@ AudioFileReader::AudioFileReader(FFmpegURLProtocol* protocol) protocol_(protocol), channels_(0), sample_rate_(0), + end_padding_(0), av_sample_format_(0) { } @@ -59,9 +60,20 @@ bool AudioFileReader::OpenDemuxer() { return false; const int result = avformat_find_stream_info(format_context, NULL); - DLOG_IF(WARNING, result < 0) - << "AudioFileReader::Open() : error in avformat_find_stream_info()"; - return result >= 0; + if (result < 0) { + DLOG(WARNING) + << "AudioFileReader::Open() : error in avformat_find_stream_info()"; + return false; + } + + // Attempt to extract end padding for mp3 files. + if (strcmp(format_context->iformat->name, "mp3") == 0 && + (av_opt_get_int(format_context->priv_data, "end_pad", 0, &end_padding_) < + 0 || + end_padding_ < 0)) { + end_padding_ = 0; + } + return true; } bool AudioFileReader::OpenDecoder() { @@ -221,6 +233,12 @@ int AudioFileReader::Read(AudioBus* audio_bus) { av_free_packet(&packet); } + // If decoding completed successfully try to strip end padding. + if (continue_decoding && end_padding_ <= current_frame) { + DCHECK_GE(end_padding_, 0); + current_frame -= end_padding_; + } + // Zero any remaining frames. audio_bus->ZeroFramesPartial( current_frame, audio_bus->frames() - current_frame); diff --git a/media/filters/audio_file_reader.h b/media/filters/audio_file_reader.h index c700b32..963baa7 100644 --- a/media/filters/audio_file_reader.h +++ b/media/filters/audio_file_reader.h @@ -87,6 +87,7 @@ class MEDIA_EXPORT AudioFileReader { FFmpegURLProtocol* protocol_; int channels_; int sample_rate_; + int64_t end_padding_; // AVSampleFormat initially requested; not Chrome's SampleFormat. int av_sample_format_; diff --git a/media/filters/audio_file_reader_unittest.cc b/media/filters/audio_file_reader_unittest.cc index 4ce2ab6..ba264d6 100644 --- a/media/filters/audio_file_reader_unittest.cc +++ b/media/filters/audio_file_reader_unittest.cc @@ -195,12 +195,12 @@ TEST_F(AudioFileReaderTest, WaveF32LE) { #if defined(USE_PROPRIETARY_CODECS) TEST_F(AudioFileReaderTest, MP3) { RunTest("sfx.mp3", - "3.05,2.87,3.00,3.32,3.58,4.08,", + "5.59,7.11,6.63,6.23,5.58,5.22,", 1, 44100, base::TimeDelta::FromMicroseconds(313470), 13825, - 12719); + 10496); } TEST_F(AudioFileReaderTest, CorruptMP3) { |