summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Kondik <shade@chemlab.org>2014-10-24 09:09:56 -0700
committerSteve Kondik <shade@chemlab.org>2014-11-02 00:53:44 -0700
commit1d37d70fd08b3d4412e38a44d52e161e6d767b61 (patch)
treeb580d96816841d01a7d720dde57e8e5860acb9c9
parentb34bb8b5f1c391a9b84ba45fa67841cbf6d0f0eb (diff)
downloadframeworks_av-1d37d70fd08b3d4412e38a44d52e161e6d767b61.tar.gz
frameworks_av-1d37d70fd08b3d4412e38a44d52e161e6d767b61.tar.bz2
frameworks_av-1d37d70fd08b3d4412e38a44d52e161e6d767b61.zip
stagefright: Query PCM output format and fix bugs
* Ask the decoder about it's PCM output format instead of hardcoding exceptions. * Google's AAC codec fails on main profile, skip it. * Don't crash on unsupported Windows Media files. Change-Id: I2bfe19993e8b0cf7ff78b6d4b63465be093ae1d0
-rw-r--r--include/media/stagefright/OMXCodec.h2
-rw-r--r--media/libstagefright/OMXCodec.cpp54
2 files changed, 41 insertions, 15 deletions
diff --git a/include/media/stagefright/OMXCodec.h b/include/media/stagefright/OMXCodec.h
index b392042451..9b7a656841 100644
--- a/include/media/stagefright/OMXCodec.h
+++ b/include/media/stagefright/OMXCodec.h
@@ -320,6 +320,8 @@ private:
status_t setDTSFormat(const sp<MetaData> &inputFormat);
status_t setFFmpegAudioFormat(const sp<MetaData> &inputFormat);
+ status_t getPCMOutputFormat(const sp<MetaData> &meta);
+
status_t allocateBuffers();
status_t allocateBuffersOnPort(OMX_U32 portIndex);
#ifdef USE_SAMSUNG_COLORFORMAT
diff --git a/media/libstagefright/OMXCodec.cpp b/media/libstagefright/OMXCodec.cpp
index 8aeeed378c..269028a88d 100644
--- a/media/libstagefright/OMXCodec.cpp
+++ b/media/libstagefright/OMXCodec.cpp
@@ -798,10 +798,16 @@ status_t OMXCodec::configureCodec(const sp<MetaData> &meta) {
CHECK(meta->findInt32(kKeyChannelCount, &numChannels));
CHECK(meta->findInt32(kKeySampleRate, &sampleRate));
- if (!meta->findInt32(kKeyAACProfile, &aacProfile)) {
+ if (!meta->findInt32(kKeyAACAOT, &aacProfile)) {
aacProfile = OMX_AUDIO_AACObjectNull;
}
+ // Google's AAC decoder can't handle MAIN profile
+ if (!strncmp(mComponentName, "OMX.google.", 11) &&
+ aacProfile == OMX_AUDIO_AACObjectMain) {
+ return ERROR_UNSUPPORTED;
+ }
+
int32_t isADTS;
if (!meta->findInt32(kKeyIsADTS, &isADTS)) {
isADTS = false;
@@ -887,12 +893,6 @@ status_t OMXCodec::configureCodec(const sp<MetaData> &meta) {
CODEC_LOGE("setAC3Format() failed (err = %d)", err);
return err;
}
-#ifdef ENABLE_AV_ENHANCEMENTS
- // FFMPEG will convert floating point to 24-bit PCM
- if (ExtendedUtils::isHiresAudioEnabled()) {
- meta->setInt32(kKeySampleBits, 24);
- }
-#endif
} else if (!strcasecmp(MEDIA_MIMETYPE_AUDIO_APE, mMIME)) {
status_t err = setAPEFormat(meta);
if (err != OK) {
@@ -905,12 +905,6 @@ status_t OMXCodec::configureCodec(const sp<MetaData> &meta) {
CODEC_LOGE("setDTSFormat() failed (err = %d)", err);
return err;
}
-#ifdef ENABLE_AV_ENHANCEMENTS
- // FFMPEG will convert DTS floating point to 24-bit PCM
- if (ExtendedUtils::isHiresAudioEnabled()) {
- meta->setInt32(kKeySampleBits, 24);
- }
-#endif
} else if (!strcasecmp(MEDIA_MIMETYPE_AUDIO_FFMPEG, mMIME)) {
status_t err = setFFmpegAudioFormat(meta);
if (err != OK) {
@@ -918,6 +912,8 @@ status_t OMXCodec::configureCodec(const sp<MetaData> &meta) {
return err;
}
}
+ getPCMOutputFormat(meta);
+ meta->dumpToLog();
#ifdef QCOM_HARDWARE
} else {
if (!mIsVideo && mIsEncoder) {
@@ -4398,6 +4394,28 @@ status_t OMXCodec::setFFmpegVideoFormat(const sp<MetaData> &meta)
return err;
}
+status_t OMXCodec::getPCMOutputFormat(const sp<MetaData> &meta)
+{
+ int32_t bitsPerSample = 16;
+ status_t err = OK;
+
+ OMX_AUDIO_PARAM_PCMMODETYPE params;
+ InitOMXParams(&params);
+ params.nPortIndex = kPortIndexOutput;
+
+ err = mOMX->getParameter(
+ mNode, OMX_IndexParamAudioPcm, &params, sizeof(params));
+
+ if (err == OK) {
+ ALOGI(" nSamplingRate = %ld\n", params.nSamplingRate);
+ ALOGI(" nChannels = %ld\n", params.nChannels);
+ ALOGI(" nBitPerSample = %ld\n", params.nBitPerSample);
+
+ meta->setInt32(kKeySampleBits, params.nBitPerSample);
+ }
+ return err;
+}
+
//audio
status_t OMXCodec::setMP3Format(const sp<MetaData> &meta)
{
@@ -4465,7 +4483,13 @@ status_t OMXCodec::setWMAFormat(const sp<MetaData> &meta)
CHECK(meta->findInt32(kKeyChannelCount, &numChannels));
CHECK(meta->findInt32(kKeySampleRate, &sampleRate));
CHECK(meta->findInt32(kKeyBitRate, &bitRate));
- CHECK(meta->findInt32(kKeyBlockAlign, &blockAlign));
+ if (!meta->findInt32(kKeyBlockAlign, &blockAlign)) {
+ // we should be last on the codec list, but another sniffer may
+ // have handled it and there is no hardware codec.
+ if (!meta->findInt32(kKeyWMABlockAlign, &blockAlign)) {
+ return ERROR_UNSUPPORTED;
+ }
+ }
CODEC_LOGV("Channels: %d, SampleRate: %d, BitRate: %d, blockAlign: %d",
numChannels, sampleRate, bitRate, blockAlign);
@@ -5854,7 +5878,7 @@ void OMXCodec::initOutputFormat(const sp<MetaData> &inputFormat) {
CHECK_EQ(err, (status_t)OK);
CHECK_EQ((int)params.eNumData, (int)OMX_NumericalDataSigned);
- CHECK_EQ(params.nBitPerSample, 16u);
+ //CHECK_EQ(params.nBitPerSample, 16u);
CHECK_EQ((int)params.ePCMMode, (int)OMX_AUDIO_PCMModeLinear);
int32_t numChannels, sampleRate;