summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Huber <andih@google.com>2012-05-10 16:43:19 -0700
committerAndreas Huber <andih@google.com>2012-05-11 10:12:45 -0700
commiteb61431af13741aa8b7e57a39f69bba5a6c190dc (patch)
tree160d4951d23a4ee5cb7d7880df3afb923dad4eb6
parent240d8a84dec9f9482257a8037457a1d63193b7ff (diff)
downloadframeworks_av-eb61431af13741aa8b7e57a39f69bba5a6c190dc.zip
frameworks_av-eb61431af13741aa8b7e57a39f69bba5a6c190dc.tar.gz
frameworks_av-eb61431af13741aa8b7e57a39f69bba5a6c190dc.tar.bz2
Increase AAC software decoder's buffer count. Refactor how clients
of ACodec get notified about codec buffers and buffer ids. Change-Id: I962f873262dae7aa7b43f5f68a6d60268282f91e related-to-bug: 6478823
-rw-r--r--include/media/stagefright/ACodec.h17
-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
7 files changed, 63 insertions, 19 deletions
diff --git a/include/media/stagefright/ACodec.h b/include/media/stagefright/ACodec.h
index dd18e95..23e3110 100644
--- a/include/media/stagefright/ACodec.h
+++ b/include/media/stagefright/ACodec.h
@@ -56,6 +56,23 @@ struct ACodec : public AHierarchicalStateMachine {
void initiateConfigureComponent(const sp<AMessage> &msg);
void initiateStart();
+ struct PortDescription : public RefBase {
+ size_t countBuffers();
+ IOMX::buffer_id bufferIDAt(size_t index) const;
+ sp<ABuffer> bufferAt(size_t index) const;
+
+ private:
+ friend struct ACodec;
+
+ Vector<IOMX::buffer_id> mBufferIDs;
+ Vector<sp<ABuffer> > mBuffers;
+
+ PortDescription();
+ void addBuffer(IOMX::buffer_id id, const sp<ABuffer> &buffer);
+
+ DISALLOW_EVIL_CONSTRUCTORS(PortDescription);
+ };
+
protected:
virtual ~ACodec();
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;