summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authormikhal <mikhal@chromium.org>2015-01-28 18:50:48 -0800
committerCommit bot <commit-bot@chromium.org>2015-01-29 02:52:09 +0000
commit3e0fe16bc2c849c91530b0864b944bc5d736f9c7 (patch)
tree3717b43307fe76a935964a79cb73c8a1a312b068 /media
parent97bf67f3ea0e4bea0f15a37e487b3bbb511de138 (diff)
downloadchromium_src-3e0fe16bc2c849c91530b0864b944bc5d736f9c7.zip
chromium_src-3e0fe16bc2c849c91530b0864b944bc5d736f9c7.tar.gz
chromium_src-3e0fe16bc2c849c91530b0864b944bc5d736f9c7.tar.bz2
Adding an ALAC enum to AudioDecoderConfig
This CL enables using the ALAC codec within the media pipeline. This does not add ALAC support, as the ALAC codec is not part of the current build. BUG=441343 Review URL: https://codereview.chromium.org/881603002 Cr-Commit-Position: refs/heads/master@{#313654}
Diffstat (limited to 'media')
-rw-r--r--media/base/audio_buffer.cc18
-rw-r--r--media/base/audio_buffer_unittest.cc10
-rw-r--r--media/base/audio_decoder_config.cc2
-rw-r--r--media/base/audio_decoder_config.h3
-rw-r--r--media/base/sample_format.cc3
-rw-r--r--media/base/sample_format.h3
-rw-r--r--media/ffmpeg/ffmpeg_common.cc6
-rw-r--r--media/mojo/interfaces/media_types.mojom6
-rw-r--r--media/mojo/services/media_type_converters.cc1
9 files changed, 47 insertions, 5 deletions
diff --git a/media/base/audio_buffer.cc b/media/base/audio_buffer.cc
index 762e884..f118914 100644
--- a/media/base/audio_buffer.cc
+++ b/media/base/audio_buffer.cc
@@ -51,7 +51,8 @@ AudioBuffer::AudioBuffer(SampleFormat sample_format,
return;
if (sample_format == kSampleFormatPlanarF32 ||
- sample_format == kSampleFormatPlanarS16) {
+ sample_format == kSampleFormatPlanarS16 ||
+ sample_format == kSampleFormatPlanarS32) {
// Planar data, so need to allocate buffer for each channel.
// Determine per channel data size, taking into account alignment.
int block_size_per_channel =
@@ -254,6 +255,12 @@ static inline int32 ConvertF32ToS32(float value) {
: value * std::numeric_limits<int32>::max());
}
+// No need for conversion. Return value as is. Keeping function to align with
+// code structure.
+static inline int32 ConvertS32ToS32(int32 value) {
+ return value;
+}
+
template <class Target, typename Converter>
void InterleaveToS32(const std::vector<uint8*>& channel_data,
size_t frames_to_copy,
@@ -322,6 +329,14 @@ void AudioBuffer::ReadFramesInterleavedS32(int frames_to_copy,
dest_data,
ConvertF32ToS32);
break;
+ case kSampleFormatPlanarS32:
+ // Format is planar signed 32 bit. Convert each value into int32 and
+ // insert into output channel data.
+ InterleaveToS32<int32>(channel_data_,
+ frames_to_copy,
+ trim_start_,
+ dest_data,
+ ConvertS32ToS32);
case kUnknownSampleFormat:
NOTREACHED();
break;
@@ -365,6 +380,7 @@ void AudioBuffer::TrimRange(int start, int end) {
switch (sample_format_) {
case kSampleFormatPlanarS16:
case kSampleFormatPlanarF32:
+ case kSampleFormatPlanarS32:
// Planar data must be shifted per channel.
for (int ch = 0; ch < channel_count_; ++ch) {
memmove(channel_data_[ch] + (trim_start_ + start) * bytes_per_channel,
diff --git a/media/base/audio_buffer_unittest.cc b/media/base/audio_buffer_unittest.cc
index 165161a..168445a 100644
--- a/media/base/audio_buffer_unittest.cc
+++ b/media/base/audio_buffer_unittest.cc
@@ -488,6 +488,16 @@ static scoped_refptr<AudioBuffer> MakeReadFramesInterleavedTestBuffer(
65536.0f / std::numeric_limits<int32>::max(),
frames,
base::TimeDelta::FromSeconds(0));
+ case kSampleFormatPlanarS32:
+ return MakeAudioBuffer<int32>(
+ sample_format,
+ channel_layout,
+ channel_count,
+ sample_rate,
+ 0.0f,
+ 65536.0f / std::numeric_limits<int32>::max(),
+ frames,
+ base::TimeDelta::FromSeconds(0));
case kSampleFormatU8:
case kUnknownSampleFormat:
EXPECT_FALSE(true);
diff --git a/media/base/audio_decoder_config.cc b/media/base/audio_decoder_config.cc
index d77d8da..4526859 100644
--- a/media/base/audio_decoder_config.cc
+++ b/media/base/audio_decoder_config.cc
@@ -150,6 +150,8 @@ std::string AudioDecoderConfig::GetHumanReadableCodecName() const {
return "pcm_mulaw";
case kCodecOpus:
return "opus";
+ case kCodecALAC:
+ return "alac";
}
NOTREACHED();
return "";
diff --git a/media/base/audio_decoder_config.h b/media/base/audio_decoder_config.h
index 199da84..9b2fe96 100644
--- a/media/base/audio_decoder_config.h
+++ b/media/base/audio_decoder_config.h
@@ -36,13 +36,14 @@ enum AudioCodec {
kCodecOpus = 12,
// kCodecEAC3 = 13,
kCodecPCM_ALAW = 14,
+ kCodecALAC = 15,
// DO NOT ADD RANDOM AUDIO CODECS!
//
// The only acceptable time to add a new codec is if there is production code
// that uses said codec in the same CL.
// Must always be equal to the largest entry ever logged.
- kAudioCodecMax = kCodecPCM_ALAW,
+ kAudioCodecMax = kCodecALAC,
};
// TODO(dalecurtis): FFmpeg API uses |bytes_per_channel| instead of
diff --git a/media/base/sample_format.cc b/media/base/sample_format.cc
index cf8f20f..464fc1b 100644
--- a/media/base/sample_format.cc
+++ b/media/base/sample_format.cc
@@ -20,6 +20,7 @@ int SampleFormatToBytesPerChannel(SampleFormat sample_format) {
case kSampleFormatS32:
case kSampleFormatF32:
case kSampleFormatPlanarF32:
+ case kSampleFormatPlanarS32:
return 4;
}
@@ -43,6 +44,8 @@ const char* SampleFormatToString(SampleFormat sample_format) {
return "Signed 16-bit planar";
case kSampleFormatPlanarF32:
return "Float 32-bit planar";
+ case kSampleFormatPlanarS32:
+ return "Signed 32-bit planar";
}
NOTREACHED() << "Invalid sample format provided: " << sample_format;
return "";
diff --git a/media/base/sample_format.h b/media/base/sample_format.h
index 7c3df70..7a48843 100644
--- a/media/base/sample_format.h
+++ b/media/base/sample_format.h
@@ -21,9 +21,10 @@ enum SampleFormat {
kSampleFormatF32, // Float 32-bit.
kSampleFormatPlanarS16, // Signed 16-bit planar.
kSampleFormatPlanarF32, // Float 32-bit planar.
+ kSampleFormatPlanarS32, // Signed 32-bit planar.
// Must always be equal to largest value ever logged.
- kSampleFormatMax = kSampleFormatPlanarF32,
+ kSampleFormatMax = kSampleFormatPlanarS32,
};
// Returns the number of bytes used per channel for the specified
diff --git a/media/ffmpeg/ffmpeg_common.cc b/media/ffmpeg/ffmpeg_common.cc
index 2c99e7e..36d0e79 100644
--- a/media/ffmpeg/ffmpeg_common.cc
+++ b/media/ffmpeg/ffmpeg_common.cc
@@ -92,6 +92,8 @@ static AudioCodec CodecIDToAudioCodec(AVCodecID codec_id) {
return kCodecPCM_MULAW;
case AV_CODEC_ID_OPUS:
return kCodecOpus;
+ case AV_CODEC_ID_ALAC:
+ return kCodecALAC;
default:
DVLOG(1) << "Unknown audio CodecID: " << codec_id;
}
@@ -103,6 +105,8 @@ static AVCodecID AudioCodecToCodecID(AudioCodec audio_codec,
switch (audio_codec) {
case kCodecAAC:
return AV_CODEC_ID_AAC;
+ case kCodecALAC:
+ return AV_CODEC_ID_ALAC;
case kCodecMP3:
return AV_CODEC_ID_MP3;
case kCodecPCM:
@@ -242,6 +246,8 @@ SampleFormat AVSampleFormatToSampleFormat(AVSampleFormat sample_format) {
return kSampleFormatF32;
case AV_SAMPLE_FMT_S16P:
return kSampleFormatPlanarS16;
+ case AV_SAMPLE_FMT_S32P:
+ return kSampleFormatPlanarS32;
case AV_SAMPLE_FMT_FLTP:
return kSampleFormatPlanarF32;
default:
diff --git a/media/mojo/interfaces/media_types.mojom b/media/mojo/interfaces/media_types.mojom
index 032cb39..43db2b5 100644
--- a/media/mojo/interfaces/media_types.mojom
+++ b/media/mojo/interfaces/media_types.mojom
@@ -31,7 +31,8 @@ enum AudioCodec {
Opus = 12,
// EAC3 = 13,
PCM_ALAW = 14,
- MAX = PCM_ALAW,
+ ALAC = 15,
+ MAX = ALAC,
};
// See media/base/channel_layout.h for descriptions.
@@ -84,7 +85,8 @@ enum SampleFormat {
F32,
PlanarS16,
PlanarF32,
- Max = PlanarF32,
+ PlanarS32,
+ Max = PlanarS32,
};
// See media/base/video_frame.h for descriptions.
diff --git a/media/mojo/services/media_type_converters.cc b/media/mojo/services/media_type_converters.cc
index 51b9fda..a930716d 100644
--- a/media/mojo/services/media_type_converters.cc
+++ b/media/mojo/services/media_type_converters.cc
@@ -47,6 +47,7 @@ ASSERT_ENUM_EQ(AudioCodec, kCodec, AUDIO_CODEC_, PCM_S16BE);
ASSERT_ENUM_EQ(AudioCodec, kCodec, AUDIO_CODEC_, PCM_S24BE);
ASSERT_ENUM_EQ(AudioCodec, kCodec, AUDIO_CODEC_, Opus);
ASSERT_ENUM_EQ(AudioCodec, kCodec, AUDIO_CODEC_, PCM_ALAW);
+ASSERT_ENUM_EQ(AudioCodec, kCodec, AUDIO_CODEC_, ALAC);
ASSERT_ENUM_EQ_RAW(AudioCodec, kAudioCodecMax, AUDIO_CODEC_MAX);
// ChannelLayout.