summaryrefslogtreecommitdiffstats
path: root/media/libstagefright
diff options
context:
space:
mode:
authorDavid Smith <davidas@google.com>2014-09-02 11:13:09 -0700
committerDavid Smith <davidas@google.com>2014-09-05 16:02:04 -0700
commit6dad9ad21ff547fab7f192956e4a3732fd78488b (patch)
tree41e1571cbc241861fde9e9136aceb50715d10782 /media/libstagefright
parente7f4e676bb88b17241d71731f9ea50c18cfcb039 (diff)
downloadframeworks_av-6dad9ad21ff547fab7f192956e4a3732fd78488b.zip
frameworks_av-6dad9ad21ff547fab7f192956e4a3732fd78488b.tar.gz
frameworks_av-6dad9ad21ff547fab7f192956e4a3732fd78488b.tar.bz2
stagefright: SimpleFilter config params via msg
Bug: 17203044 Change-Id: I659da31bddb51dd0e5246827c57234364a4c479b
Diffstat (limited to 'media/libstagefright')
-rw-r--r--media/libstagefright/filters/Android.mk1
-rw-r--r--media/libstagefright/filters/IntrinsicBlurFilter.cpp14
-rw-r--r--media/libstagefright/filters/IntrinsicBlurFilter.h2
-rw-r--r--media/libstagefright/filters/MediaFilter.cpp6
-rw-r--r--media/libstagefright/filters/SaturationFilter.cpp14
-rw-r--r--media/libstagefright/filters/SaturationFilter.h2
-rw-r--r--media/libstagefright/filters/SimpleFilter.cpp39
-rw-r--r--media/libstagefright/filters/SimpleFilter.h18
8 files changed, 76 insertions, 20 deletions
diff --git a/media/libstagefright/filters/Android.mk b/media/libstagefright/filters/Android.mk
index 08d349d..90f9e75 100644
--- a/media/libstagefright/filters/Android.mk
+++ b/media/libstagefright/filters/Android.mk
@@ -10,6 +10,7 @@ LOCAL_SRC_FILES := \
MediaFilter.cpp \
SaturationFilter.cpp \
saturationARGB.rs \
+ SimpleFilter.cpp \
ZeroFilter.cpp
LOCAL_C_INCLUDES := \
diff --git a/media/libstagefright/filters/IntrinsicBlurFilter.cpp b/media/libstagefright/filters/IntrinsicBlurFilter.cpp
index 2bae4d7..cbcf699 100644
--- a/media/libstagefright/filters/IntrinsicBlurFilter.cpp
+++ b/media/libstagefright/filters/IntrinsicBlurFilter.cpp
@@ -27,6 +27,20 @@
namespace android {
+status_t IntrinsicBlurFilter::configure(const sp<AMessage> &msg) {
+ status_t err = SimpleFilter::configure(msg);
+ if (err != OK) {
+ return err;
+ }
+
+ if (!msg->findString("cacheDir", &mCacheDir)) {
+ ALOGE("Failed to find cache directory in config message.");
+ return NAME_NOT_FOUND;
+ }
+
+ return OK;
+}
+
status_t IntrinsicBlurFilter::start() {
// TODO: use a single RS context object for entire application
mRS = new RSC::RS();
diff --git a/media/libstagefright/filters/IntrinsicBlurFilter.h b/media/libstagefright/filters/IntrinsicBlurFilter.h
index b88e2c2..4707ab7 100644
--- a/media/libstagefright/filters/IntrinsicBlurFilter.h
+++ b/media/libstagefright/filters/IntrinsicBlurFilter.h
@@ -26,6 +26,7 @@ struct IntrinsicBlurFilter : public SimpleFilter {
public:
IntrinsicBlurFilter() : mBlurRadius(1.f) {};
+ virtual status_t configure(const sp<AMessage> &msg);
virtual status_t start();
virtual void reset();
virtual status_t setParameters(const sp<AMessage> &msg);
@@ -36,6 +37,7 @@ protected:
virtual ~IntrinsicBlurFilter() {};
private:
+ AString mCacheDir;
RSC::sp<RSC::RS> mRS;
RSC::sp<RSC::Allocation> mAllocIn;
RSC::sp<RSC::Allocation> mAllocOut;
diff --git a/media/libstagefright/filters/MediaFilter.cpp b/media/libstagefright/filters/MediaFilter.cpp
index 3f9aa19..59cc057 100644
--- a/media/libstagefright/filters/MediaFilter.cpp
+++ b/media/libstagefright/filters/MediaFilter.cpp
@@ -489,6 +489,7 @@ void MediaFilter::onConfigureComponent(const sp<AMessage> &msg) {
if (!msg->findInt32("color-format", &mColorFormatIn)) {
// default to OMX_COLOR_Format32bitARGB8888
mColorFormatIn = OMX_COLOR_Format32bitARGB8888;
+ msg->setInt32("color-format", mColorFormatIn);
}
mColorFormatOut = mColorFormatIn;
@@ -502,8 +503,7 @@ void MediaFilter::onConfigureComponent(const sp<AMessage> &msg) {
}
status_t err;
- err = mFilter->configure(
- mWidth, mHeight, mStride, mSliceHeight, mColorFormatIn, cacheDir);
+ err = mFilter->configure(msg);
if (err != (status_t)OK) {
ALOGE("Failed to configure filter component, err %d", err);
signalError(err);
@@ -631,7 +631,7 @@ void MediaFilter::onInputBufferFilled(const sp<AMessage> &msg) {
void MediaFilter::onOutputBufferDrained(const sp<AMessage> &msg) {
IOMX::buffer_id bufferID;
- CHECK(msg->findInt32("buffer-id",(int32_t*) &bufferID));
+ CHECK(msg->findInt32("buffer-id", (int32_t*)&bufferID));
BufferInfo *info = findBufferByID(kPortIndexOutput, bufferID);
if (mState != STARTED) {
diff --git a/media/libstagefright/filters/SaturationFilter.cpp b/media/libstagefright/filters/SaturationFilter.cpp
index 24aa083..ba5f75a 100644
--- a/media/libstagefright/filters/SaturationFilter.cpp
+++ b/media/libstagefright/filters/SaturationFilter.cpp
@@ -27,6 +27,20 @@
namespace android {
+status_t SaturationFilter::configure(const sp<AMessage> &msg) {
+ status_t err = SimpleFilter::configure(msg);
+ if (err != OK) {
+ return err;
+ }
+
+ if (!msg->findString("cacheDir", &mCacheDir)) {
+ ALOGE("Failed to find cache directory in config message.");
+ return NAME_NOT_FOUND;
+ }
+
+ return OK;
+}
+
status_t SaturationFilter::start() {
// TODO: use a single RS context object for entire application
mRS = new RSC::RS();
diff --git a/media/libstagefright/filters/SaturationFilter.h b/media/libstagefright/filters/SaturationFilter.h
index fe1c35f..0545021 100644
--- a/media/libstagefright/filters/SaturationFilter.h
+++ b/media/libstagefright/filters/SaturationFilter.h
@@ -28,6 +28,7 @@ struct SaturationFilter : public SimpleFilter {
public:
SaturationFilter() : mSaturation(1.f) {};
+ virtual status_t configure(const sp<AMessage> &msg);
virtual status_t start();
virtual void reset();
virtual status_t setParameters(const sp<AMessage> &msg);
@@ -38,6 +39,7 @@ protected:
virtual ~SaturationFilter() {};
private:
+ AString mCacheDir;
RSC::sp<RSC::RS> mRS;
RSC::sp<RSC::Allocation> mAllocIn;
RSC::sp<RSC::Allocation> mAllocOut;
diff --git a/media/libstagefright/filters/SimpleFilter.cpp b/media/libstagefright/filters/SimpleFilter.cpp
new file mode 100644
index 0000000..6c1ca2c
--- /dev/null
+++ b/media/libstagefright/filters/SimpleFilter.cpp
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <media/stagefright/foundation/ADebug.h>
+#include <media/stagefright/foundation/AMessage.h>
+
+#include "SimpleFilter.h"
+
+namespace android {
+
+status_t SimpleFilter::configure(const sp<AMessage> &msg) {
+ CHECK(msg->findInt32("width", &mWidth));
+ CHECK(msg->findInt32("height", &mHeight));
+ if (!msg->findInt32("stride", &mStride)) {
+ mStride = mWidth;
+ }
+ if (!msg->findInt32("slice-height", &mSliceHeight)) {
+ mSliceHeight = mHeight;
+ }
+ CHECK(msg->findInt32("color-format", &mColorFormatIn));
+ mColorFormatOut = mColorFormatIn;
+
+ return OK;
+}
+
+} // namespace android
diff --git a/media/libstagefright/filters/SimpleFilter.h b/media/libstagefright/filters/SimpleFilter.h
index 26be742..4cd37ef 100644
--- a/media/libstagefright/filters/SimpleFilter.h
+++ b/media/libstagefright/filters/SimpleFilter.h
@@ -31,22 +31,7 @@ public:
SimpleFilter() : mWidth(0), mHeight(0), mStride(0), mSliceHeight(0),
mColorFormatIn(0), mColorFormatOut(0) {};
- // TODO: change this to take the configure AMessage so that parameters
- // aren't hardcoded for all filters
- virtual status_t configure(
- int32_t srcWidth, int32_t srcHeight,
- int32_t srcStride, int32_t srcSliceHeight,
- int32_t srcColorFormat, AString cacheDir) {
- mWidth = srcWidth;
- mHeight = srcHeight;
- mStride = srcStride;
- mSliceHeight = srcSliceHeight;
- mColorFormatIn = srcColorFormat;
- mColorFormatOut = mColorFormatIn;
- mCacheDir = cacheDir;
-
- return OK;
- }
+ virtual status_t configure(const sp<AMessage> &msg);
virtual status_t start() = 0;
virtual void reset() = 0;
@@ -58,7 +43,6 @@ protected:
int32_t mWidth, mHeight;
int32_t mStride, mSliceHeight;
int32_t mColorFormatIn, mColorFormatOut;
- AString mCacheDir;
virtual ~SimpleFilter() {};
};