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

Unified Diff: media/ffmpeg/ffmpeg_common_unittest.cc

Issue 390543002: Always use 48kHz for OPUS decoding. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Test all teh things. Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/ffmpeg/ffmpeg_common.cc ('k') | media/filters/pipeline_integration_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/ffmpeg/ffmpeg_common_unittest.cc
diff --git a/media/ffmpeg/ffmpeg_common_unittest.cc b/media/ffmpeg/ffmpeg_common_unittest.cc
index 31397df7facea454e9496645d2936ddeea3615e2..6b168eee45552e5398a6950718585df8fa9850e9 100644
--- a/media/ffmpeg/ffmpeg_common_unittest.cc
+++ b/media/ffmpeg/ffmpeg_common_unittest.cc
@@ -2,64 +2,37 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/files/file_path.h"
#include "base/logging.h"
-#include "base/path_service.h"
-#include "media/base/media.h"
#include "media/ffmpeg/ffmpeg_common.h"
+#include "media/filters/ffmpeg_glue.h"
#include "testing/gtest/include/gtest/gtest.h"
-using base::TimeDelta;
-
namespace media {
-static AVIndexEntry kIndexEntries[] = {
- // pos, timestamp, flags, size, min_distance
- { 0, 0, AVINDEX_KEYFRAME, 0, 0 },
- { 2000, 1000, AVINDEX_KEYFRAME, 0, 0 },
- { 3000, 2000, 0, 0, 0 },
- { 5000, 3000, AVINDEX_KEYFRAME, 0, 0 },
- { 6000, 4000, 0, 0, 0 },
- { 8000, 5000, AVINDEX_KEYFRAME, 0, 0 },
- { 9000, 6000, AVINDEX_KEYFRAME, 0, 0 },
- { 11500, 7000, AVINDEX_KEYFRAME, 0, 0 },
-};
-
-static const AVRational kTimeBase = { 1, 1000 };
-
class FFmpegCommonTest : public testing::Test {
public:
- FFmpegCommonTest();
- virtual ~FFmpegCommonTest();
-
- protected:
- AVStream stream_;
-
- DISALLOW_COPY_AND_ASSIGN(FFmpegCommonTest);
+ FFmpegCommonTest() { FFmpegGlue::InitializeFFmpeg(); }
+ virtual ~FFmpegCommonTest() {};
};
-static bool InitFFmpeg() {
- static bool initialized = false;
- if (initialized) {
- return true;
- }
- base::FilePath path;
- PathService::Get(base::DIR_MODULE, &path);
- return media::InitializeMediaLibrary(path);
-}
+TEST_F(FFmpegCommonTest, OpusAudioDecoderConfig) {
+ AVCodecContext context = {0};
+ context.codec_type = AVMEDIA_TYPE_AUDIO;
+ context.codec_id = AV_CODEC_ID_OPUS;
+ context.channel_layout = CHANNEL_LAYOUT_STEREO;
+ context.channels = 2;
+ context.sample_fmt = AV_SAMPLE_FMT_FLT;
-FFmpegCommonTest::FFmpegCommonTest() {
- CHECK(InitFFmpeg());
- stream_.time_base = kTimeBase;
- stream_.index_entries = kIndexEntries;
- stream_.index_entries_allocated_size = sizeof(kIndexEntries);
- stream_.nb_index_entries = arraysize(kIndexEntries);
-}
+ // During conversion this sample rate should be changed to 48kHz.
+ context.sample_rate = 44100;
-FFmpegCommonTest::~FFmpegCommonTest() {}
+ AudioDecoderConfig decoder_config;
+ AVCodecContextToAudioDecoderConfig(&context, false, &decoder_config, false);
+ EXPECT_EQ(48000, decoder_config.samples_per_second());
+}
TEST_F(FFmpegCommonTest, TimeBaseConversions) {
- int64 test_data[][5] = {
+ const int64 test_data[][5] = {
{1, 2, 1, 500000, 1 },
{1, 3, 1, 333333, 1 },
{1, 3, 2, 666667, 2 },
@@ -72,7 +45,8 @@ TEST_F(FFmpegCommonTest, TimeBaseConversions) {
time_base.num = static_cast<int>(test_data[i][0]);
time_base.den = static_cast<int>(test_data[i][1]);
- TimeDelta time_delta = ConvertFromTimeBase(time_base, test_data[i][2]);
+ base::TimeDelta time_delta =
+ ConvertFromTimeBase(time_base, test_data[i][2]);
EXPECT_EQ(time_delta.InMicroseconds(), test_data[i][3]);
EXPECT_EQ(ConvertToTimeBase(time_base, time_delta), test_data[i][4]);
@@ -150,5 +124,4 @@ TEST_F(FFmpegCommonTest, UTCDateToTime_Invalid) {
}
}
-
} // namespace media
« no previous file with comments | « media/ffmpeg/ffmpeg_common.cc ('k') | media/filters/pipeline_integration_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698