summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorAndreas Huber <andih@google.com>2012-05-11 11:01:54 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-05-11 11:01:54 -0700
commit7d5805669dea851e70115c494154a2d26b8dc39e (patch)
tree0d1fa3fdb4933b35f8d720087b082bdc15bd8eb2 /media
parentc20f467d54f921730aa0b2fd087ad83496aeaf4b (diff)
parenteb61431af13741aa8b7e57a39f69bba5a6c190dc (diff)
downloadframeworks_av-7d5805669dea851e70115c494154a2d26b8dc39e.zip
frameworks_av-7d5805669dea851e70115c494154a2d26b8dc39e.tar.gz
frameworks_av-7d5805669dea851e70115c494154a2d26b8dc39e.tar.bz2
Merge "Increase AAC software decoder's buffer count. Refactor how clients" into jb-dev
Diffstat (limited to 'media')
-rw-r--r--media/libstagefright/ACodec.cpp33
-rw-r--r--media/libstagefright/MediaCodec.cpp18
-rw-r--r--media/libstagefright/codecs/aacdec/SoftAAC.cpp4
-rw-r--r--media/libstagefright/codecs/aacdec/SoftAAC.h3
-rw-r--r--media/libstagefright/codecs/aacdec/SoftAAC2.cpp4
-rw-r--r--media/libstagefright/codecs/aacdec/SoftAAC2.h3
6 files changed, 46 insertions, 19 deletions
diff --git a/media/libstagefright/ACodec.cpp b/media/libstagefright/ACodec.cpp
index 3fd6cef..7ac0f23 100644
--- a/media/libstagefright/ACodec.cpp
+++ b/media/libstagefright/ACodec.cpp
@@ -472,14 +472,16 @@ status_t ACodec::allocateBuffersOnPort(OMX_U32 portIndex) {
notify->setInt32("what", ACodec::kWhatBuffersAllocated);
notify->setInt32("portIndex", portIndex);
+
+ sp<PortDescription> desc = new PortDescription;
+
for (size_t i = 0; i < mBuffers[portIndex].size(); ++i) {
- AString name = StringPrintf("buffer-id_%d", i);
- notify->setPointer(name.c_str(), mBuffers[portIndex][i].mBufferID);
+ const BufferInfo &info = mBuffers[portIndex][i];
- name = StringPrintf("data_%d", i);
- notify->setBuffer(name.c_str(), mBuffers[portIndex][i].mData);
+ desc->addBuffer(info.mBufferID, info.mData);
}
+ notify->setObject("portDesc", desc);
notify->post();
return OK;
@@ -2110,6 +2112,29 @@ void ACodec::signalError(OMX_ERRORTYPE error, status_t internalError) {
////////////////////////////////////////////////////////////////////////////////
+ACodec::PortDescription::PortDescription() {
+}
+
+void ACodec::PortDescription::addBuffer(
+ IOMX::buffer_id id, const sp<ABuffer> &buffer) {
+ mBufferIDs.push_back(id);
+ mBuffers.push_back(buffer);
+}
+
+size_t ACodec::PortDescription::countBuffers() {
+ return mBufferIDs.size();
+}
+
+IOMX::buffer_id ACodec::PortDescription::bufferIDAt(size_t index) const {
+ return mBufferIDs.itemAt(index);
+}
+
+sp<ABuffer> ACodec::PortDescription::bufferAt(size_t index) const {
+ return mBuffers.itemAt(index);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
ACodec::BaseState::BaseState(ACodec *codec, const sp<AState> &parentState)
: AState(parentState),
mCodec(codec) {
diff --git a/media/libstagefright/MediaCodec.cpp b/media/libstagefright/MediaCodec.cpp
index 5b513a8..ff71170 100644
--- a/media/libstagefright/MediaCodec.cpp
+++ b/media/libstagefright/MediaCodec.cpp
@@ -562,20 +562,20 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) {
mPortBuffers[portIndex].clear();
Vector<BufferInfo> *buffers = &mPortBuffers[portIndex];
- for (size_t i = 0;; ++i) {
- AString name = StringPrintf("buffer-id_%d", i);
- void *bufferID;
- if (!msg->findPointer(name.c_str(), &bufferID)) {
- break;
- }
+ sp<RefBase> obj;
+ CHECK(msg->findObject("portDesc", &obj));
+
+ sp<ACodec::PortDescription> portDesc =
+ static_cast<ACodec::PortDescription *>(obj.get());
- name = StringPrintf("data_%d", i);
+ size_t numBuffers = portDesc->countBuffers();
+ for (size_t i = 0; i < numBuffers; ++i) {
BufferInfo info;
- info.mBufferID = bufferID;
+ info.mBufferID = portDesc->bufferIDAt(i);
info.mOwnedByClient = false;
- CHECK(msg->findBuffer(name.c_str(), &info.mData));
+ info.mData = portDesc->bufferAt(i);
if (portIndex == kPortIndexInput && mCrypto != NULL) {
info.mEncryptedData =
diff --git a/media/libstagefright/codecs/aacdec/SoftAAC.cpp b/media/libstagefright/codecs/aacdec/SoftAAC.cpp
index d509383..65aa2ad 100644
--- a/media/libstagefright/codecs/aacdec/SoftAAC.cpp
+++ b/media/libstagefright/codecs/aacdec/SoftAAC.cpp
@@ -69,7 +69,7 @@ void SoftAAC::initPorts() {
def.nPortIndex = 0;
def.eDir = OMX_DirInput;
- def.nBufferCountMin = kNumBuffers;
+ def.nBufferCountMin = kNumInputBuffers;
def.nBufferCountActual = def.nBufferCountMin;
def.nBufferSize = 8192;
def.bEnabled = OMX_TRUE;
@@ -87,7 +87,7 @@ void SoftAAC::initPorts() {
def.nPortIndex = 1;
def.eDir = OMX_DirOutput;
- def.nBufferCountMin = kNumBuffers;
+ def.nBufferCountMin = kNumOutputBuffers;
def.nBufferCountActual = def.nBufferCountMin;
def.nBufferSize = 8192;
def.bEnabled = OMX_TRUE;
diff --git a/media/libstagefright/codecs/aacdec/SoftAAC.h b/media/libstagefright/codecs/aacdec/SoftAAC.h
index da0b8ed..c0789ab 100644
--- a/media/libstagefright/codecs/aacdec/SoftAAC.h
+++ b/media/libstagefright/codecs/aacdec/SoftAAC.h
@@ -45,7 +45,8 @@ protected:
private:
enum {
- kNumBuffers = 4
+ kNumInputBuffers = 32,
+ kNumOutputBuffers = 4,
};
tPVMP4AudioDecoderExternal *mConfig;
diff --git a/media/libstagefright/codecs/aacdec/SoftAAC2.cpp b/media/libstagefright/codecs/aacdec/SoftAAC2.cpp
index e499a0b..303b8ef 100644
--- a/media/libstagefright/codecs/aacdec/SoftAAC2.cpp
+++ b/media/libstagefright/codecs/aacdec/SoftAAC2.cpp
@@ -64,7 +64,7 @@ void SoftAAC2::initPorts() {
def.nPortIndex = 0;
def.eDir = OMX_DirInput;
- def.nBufferCountMin = kNumBuffers;
+ def.nBufferCountMin = kNumInputBuffers;
def.nBufferCountActual = def.nBufferCountMin;
def.nBufferSize = 8192;
def.bEnabled = OMX_TRUE;
@@ -82,7 +82,7 @@ void SoftAAC2::initPorts() {
def.nPortIndex = 1;
def.eDir = OMX_DirOutput;
- def.nBufferCountMin = kNumBuffers;
+ def.nBufferCountMin = kNumOutputBuffers;
def.nBufferCountActual = def.nBufferCountMin;
def.nBufferSize = 8192 * 2;
def.bEnabled = OMX_TRUE;
diff --git a/media/libstagefright/codecs/aacdec/SoftAAC2.h b/media/libstagefright/codecs/aacdec/SoftAAC2.h
index e5a1e3e..57565ab 100644
--- a/media/libstagefright/codecs/aacdec/SoftAAC2.h
+++ b/media/libstagefright/codecs/aacdec/SoftAAC2.h
@@ -44,7 +44,8 @@ protected:
private:
enum {
- kNumBuffers = 4
+ kNumInputBuffers = 32,
+ kNumOutputBuffers = 4,
};
HANDLE_AACDECODER mAACDecoder;