summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarco Nelissen <marcone@google.com>2015-03-20 09:15:11 -0700
committerMarco Nelissen <marcone@google.com>2015-03-20 09:15:11 -0700
commit17c39e708ed657b8fa66f8acce5128e51696915c (patch)
treeec0f96c66e44c39e83800bb7a02792ab57781e99
parent340cebdaa2875ba2ab9725b81218ebc59d84164b (diff)
downloadframeworks_av-17c39e708ed657b8fa66f8acce5128e51696915c.zip
frameworks_av-17c39e708ed657b8fa66f8acce5128e51696915c.tar.gz
frameworks_av-17c39e708ed657b8fa66f8acce5128e51696915c.tar.bz2
ulaw and alaw aren't limited to 8kHz
Bug: https://code.google.com/p/android/issues/detail?id=158490 Change-Id: Ib30e156c99a997db861bb85e17244a5effdd55cf
-rw-r--r--include/media/stagefright/ACodec.h2
-rw-r--r--include/media/stagefright/OMXCodec.h2
-rw-r--r--media/libstagefright/ACodec.cpp10
-rw-r--r--media/libstagefright/OMXCodec.cpp10
-rw-r--r--media/libstagefright/codecs/g711/dec/SoftG711.cpp7
-rw-r--r--media/libstagefright/codecs/g711/dec/SoftG711.h3
-rw-r--r--media/libstagefright/data/media_codecs_google_audio.xml4
7 files changed, 25 insertions, 13 deletions
diff --git a/include/media/stagefright/ACodec.h b/include/media/stagefright/ACodec.h
index 595ace8..cd2bd27 100644
--- a/include/media/stagefright/ACodec.h
+++ b/include/media/stagefright/ACodec.h
@@ -290,7 +290,7 @@ private:
OMX_U32 portIndex, OMX_AUDIO_CODINGTYPE desiredFormat);
status_t setupAMRCodec(bool encoder, bool isWAMR, int32_t bitRate);
- status_t setupG711Codec(bool encoder, int32_t numChannels);
+ status_t setupG711Codec(bool encoder, int32_t sampleRate, int32_t numChannels);
status_t setupFlacCodec(
bool encoder, int32_t numChannels, int32_t sampleRate, int32_t compressionLevel);
diff --git a/include/media/stagefright/OMXCodec.h b/include/media/stagefright/OMXCodec.h
index e341160..84b1b1a 100644
--- a/include/media/stagefright/OMXCodec.h
+++ b/include/media/stagefright/OMXCodec.h
@@ -250,7 +250,7 @@ private:
status_t setAC3Format(int32_t numChannels, int32_t sampleRate);
- void setG711Format(int32_t numChannels);
+ void setG711Format(int32_t sampleRate, int32_t numChannels);
status_t setVideoPortFormatType(
OMX_U32 portIndex,
diff --git a/media/libstagefright/ACodec.cpp b/media/libstagefright/ACodec.cpp
index c8806ae..d298cb1 100644
--- a/media/libstagefright/ACodec.cpp
+++ b/media/libstagefright/ACodec.cpp
@@ -1586,7 +1586,11 @@ status_t ACodec::configureCodec(
if (!msg->findInt32("channel-count", &numChannels)) {
err = INVALID_OPERATION;
} else {
- err = setupG711Codec(encoder, numChannels);
+ int32_t sampleRate;
+ if (!msg->findInt32("sample-rate", &sampleRate)) {
+ sampleRate = 8000;
+ }
+ err = setupG711Codec(encoder, sampleRate, numChannels);
}
} else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_FLAC)) {
int32_t numChannels, sampleRate, compressionLevel = -1;
@@ -2040,11 +2044,11 @@ status_t ACodec::setupAMRCodec(bool encoder, bool isWAMR, int32_t bitrate) {
1 /* numChannels */);
}
-status_t ACodec::setupG711Codec(bool encoder, int32_t numChannels) {
+status_t ACodec::setupG711Codec(bool encoder, int32_t sampleRate, int32_t numChannels) {
CHECK(!encoder); // XXX TODO
return setupRawAudioFormat(
- kPortIndexInput, 8000 /* sampleRate */, numChannels);
+ kPortIndexInput, sampleRate, numChannels);
}
status_t ACodec::setupFlacCodec(
diff --git a/media/libstagefright/OMXCodec.cpp b/media/libstagefright/OMXCodec.cpp
index ea19ab2..4d30069 100644
--- a/media/libstagefright/OMXCodec.cpp
+++ b/media/libstagefright/OMXCodec.cpp
@@ -629,10 +629,14 @@ status_t OMXCodec::configureCodec(const sp<MetaData> &meta) {
// These are PCM-like formats with a fixed sample rate but
// a variable number of channels.
+ int32_t sampleRate;
int32_t numChannels;
CHECK(meta->findInt32(kKeyChannelCount, &numChannels));
+ if (!meta->findInt32(kKeySampleRate, &sampleRate)) {
+ sampleRate = 8000;
+ }
- setG711Format(numChannels);
+ setG711Format(sampleRate, numChannels);
} else if (!strcasecmp(MEDIA_MIMETYPE_AUDIO_RAW, mMIME)) {
CHECK(!mIsEncoder);
@@ -3616,9 +3620,9 @@ status_t OMXCodec::setAC3Format(int32_t numChannels, int32_t sampleRate) {
sizeof(def));
}
-void OMXCodec::setG711Format(int32_t numChannels) {
+void OMXCodec::setG711Format(int32_t sampleRate, int32_t numChannels) {
CHECK(!mIsEncoder);
- setRawAudioFormat(kPortIndexInput, 8000, numChannels);
+ setRawAudioFormat(kPortIndexInput, sampleRate, numChannels);
}
void OMXCodec::setImageOutputFormat(
diff --git a/media/libstagefright/codecs/g711/dec/SoftG711.cpp b/media/libstagefright/codecs/g711/dec/SoftG711.cpp
index 3a69095..015515e 100644
--- a/media/libstagefright/codecs/g711/dec/SoftG711.cpp
+++ b/media/libstagefright/codecs/g711/dec/SoftG711.cpp
@@ -41,8 +41,9 @@ SoftG711::SoftG711(
OMX_COMPONENTTYPE **component)
: SimpleSoftOMXComponent(name, callbacks, appData, component),
mIsMLaw(true),
+ mSignalledError(false),
mNumChannels(1),
- mSignalledError(false) {
+ mSamplingRate(8000) {
if (!strcmp(name, "OMX.google.g711.alaw.decoder")) {
mIsMLaw = false;
} else {
@@ -129,7 +130,7 @@ OMX_ERRORTYPE SoftG711::internalGetParameter(
pcmParams->eChannelMapping[1] = OMX_AUDIO_ChannelRF;
pcmParams->nChannels = mNumChannels;
- pcmParams->nSamplingRate = 8000;
+ pcmParams->nSamplingRate = mSamplingRate;
return OMX_ErrorNone;
}
@@ -159,6 +160,8 @@ OMX_ERRORTYPE SoftG711::internalSetParameter(
mNumChannels = pcmParams->nChannels;
}
+ mSamplingRate = pcmParams->nSamplingRate;
+
return OMX_ErrorNone;
}
diff --git a/media/libstagefright/codecs/g711/dec/SoftG711.h b/media/libstagefright/codecs/g711/dec/SoftG711.h
index bff0c68..16b6340 100644
--- a/media/libstagefright/codecs/g711/dec/SoftG711.h
+++ b/media/libstagefright/codecs/g711/dec/SoftG711.h
@@ -46,8 +46,9 @@ private:
};
bool mIsMLaw;
- OMX_U32 mNumChannels;
bool mSignalledError;
+ OMX_U32 mNumChannels;
+ int32_t mSamplingRate;
void initPorts();
diff --git a/media/libstagefright/data/media_codecs_google_audio.xml b/media/libstagefright/data/media_codecs_google_audio.xml
index a06684b..b957b0c 100644
--- a/media/libstagefright/data/media_codecs_google_audio.xml
+++ b/media/libstagefright/data/media_codecs_google_audio.xml
@@ -38,12 +38,12 @@
</MediaCodec>
<MediaCodec name="OMX.google.g711.alaw.decoder" type="audio/g711-alaw">
<Limit name="channel-count" max="1" />
- <Limit name="sample-rate" ranges="8000" />
+ <Limit name="sample-rate" ranges="8000-48000" />
<Limit name="bitrate" range="64000" />
</MediaCodec>
<MediaCodec name="OMX.google.g711.mlaw.decoder" type="audio/g711-mlaw">
<Limit name="channel-count" max="1" />
- <Limit name="sample-rate" ranges="8000" />
+ <Limit name="sample-rate" ranges="8000-48000" />
<Limit name="bitrate" range="64000" />
</MediaCodec>
<MediaCodec name="OMX.google.vorbis.decoder" type="audio/vorbis">