aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorywan171 <yi.a.wang@intel.com>2013-12-02 10:04:21 +0800
committerPatrick Tjin <pattjin@google.com>2014-07-21 22:03:42 -0700
commitc87a1a8f47c29d4eddf1ea0093c32b8eee04a239 (patch)
treefafeb231bde680fb828a0f6e5ba2e11cc37232d6
parenta081918af785d476df2da1342eabe245eab468d0 (diff)
downloadwrs_omxil_core-c87a1a8f47c29d4eddf1ea0093c32b8eee04a239.tar.gz
wrs_core: add support for adaptive playback in kitkat
BZ: 154291 add DRC support in video decoder middleware to integrate with kitkat AOSP Change-Id: I826678d8f2da7c475180d8055786d6b07d7e449d Signed-off-by: ywan171 <yi.a.wang@intel.com>
-rw-r--r--base/inc/componentbase.h5
-rw-r--r--base/src/Android.mk1
-rw-r--r--base/src/componentbase.cpp56
-rw-r--r--core/inc/khronos/openmax/include/OMX_IntelIndexExt.h1
4 files changed, 61 insertions, 2 deletions
diff --git a/base/inc/componentbase.h b/base/inc/componentbase.h
index 77a2381..2ba98d7 100644
--- a/base/inc/componentbase.h
+++ b/base/inc/componentbase.h
@@ -435,6 +435,11 @@ private:
/* state lock */
pthread_mutex_t state_block;
+ /* adaptive playback param */
+ OMX_BOOL mEnableAdaptivePlayback;
+ OMX_U32 mMaxFrameWidth;
+ OMX_U32 mMaxFrameHeight;
+
/* omx specification version */
#ifndef ANDROID
const static OMX_U8 OMX_SPEC_VERSION_MAJOR = 1;
diff --git a/base/src/Android.mk b/base/src/Android.mk
index 85483a5..564a7a8 100644
--- a/base/src/Android.mk
+++ b/base/src/Android.mk
@@ -33,6 +33,7 @@ LOCAL_C_INCLUDES := \
$(WRS_OMXIL_CORE_ROOT)/utils/inc \
$(WRS_OMXIL_CORE_ROOT)/base/inc \
$(WRS_OMXIL_CORE_ROOT)/core/inc/khronos/openmax/include \
+ $(call include-path-for, frameworks-native)/media/hardware \
$(TOP)/frameworks/native/include/media/openmax
include $(BUILD_STATIC_LIBRARY)
diff --git a/base/src/componentbase.cpp b/base/src/componentbase.cpp
index d2e57f3..c6639ca 100644
--- a/base/src/componentbase.cpp
+++ b/base/src/componentbase.cpp
@@ -29,12 +29,15 @@
#include <queue.h>
#include <workqueue.h>
#include <OMX_IndexExt.h>
+#include <HardwareAPI.h>
//#define LOG_NDEBUG 0
#define LOG_TAG "componentbase"
#include <log.h>
+static const OMX_U32 kMaxAdaptiveStreamingWidth = 1920;
+static const OMX_U32 kMaxAdaptiveStreamingHeight = 1088;
/*
* CmdProcessWork
*/
@@ -127,6 +130,7 @@ void ComponentBase::__ComponentBase(void)
ports = NULL;
nr_ports = 0;
+ mEnableAdaptivePlayback = OMX_FALSE;
memset(&portparam, 0, sizeof(portparam));
state = OMX_StateUnloaded;
@@ -466,7 +470,6 @@ OMX_ERRORTYPE ComponentBase::CBaseGetParameter(
if (hComponent != handle)
return OMX_ErrorBadParameter;
-
switch (nParamIndex) {
case OMX_IndexParamAudioInit:
case OMX_IndexParamVideoInit:
@@ -574,6 +577,13 @@ OMX_ERRORTYPE ComponentBase::CBaseSetParameter(
return OMX_ErrorIncorrectStateOperation;
}
+ if (index == 1 && mEnableAdaptivePlayback == OMX_TRUE) {
+ if (p->format.video.nFrameWidth < mMaxFrameWidth)
+ p->format.video.nFrameWidth = mMaxFrameWidth;
+ if (p->format.video.nFrameHeight < mMaxFrameHeight)
+ p->format.video.nFrameHeight = mMaxFrameHeight;
+ }
+
ret = port->SetPortDefinition(p, false);
if (ret != OMX_ErrorNone) {
return ret;
@@ -612,6 +622,43 @@ OMX_ERRORTYPE ComponentBase::CBaseSetParameter(
}
break;
}
+ case OMX_IndexExtPrepareForAdaptivePlayback: {
+ android::PrepareForAdaptivePlaybackParams* p =
+ (android::PrepareForAdaptivePlaybackParams *)pComponentParameterStructure;
+
+ ret = CheckTypeHeader(p, sizeof(*p));
+ if (ret != OMX_ErrorNone)
+ return ret;
+
+ if (p->nPortIndex != 1)
+ return OMX_ErrorBadPortIndex;
+
+ if (!(working_role != NULL && !strncmp((char*)working_role, "video_decoder", 13)))
+ return OMX_ErrorBadParameter;
+
+ if (p->nMaxFrameWidth > kMaxAdaptiveStreamingWidth
+ || p->nMaxFrameHeight > kMaxAdaptiveStreamingHeight) {
+ LOGE("resolution %d x %d exceed max driver support %d x %d\n",p->nMaxFrameWidth, p->nMaxFrameHeight,
+ kMaxAdaptiveStreamingWidth, kMaxAdaptiveStreamingHeight);
+ return OMX_ErrorBadParameter;
+ }
+ mEnableAdaptivePlayback = p->bEnable;
+ if (mEnableAdaptivePlayback != OMX_TRUE)
+ return OMX_ErrorBadParameter;
+
+ mMaxFrameWidth = p->nMaxFrameWidth;
+ mMaxFrameHeight = p->nMaxFrameHeight;
+ /* update output port definition */
+ OMX_PARAM_PORTDEFINITIONTYPE paramPortDefinitionOutput;
+ if (nr_ports > p->nPortIndex && ports[p->nPortIndex]) {
+ memcpy(&paramPortDefinitionOutput,ports[p->nPortIndex]->GetPortDefinition(),
+ sizeof(paramPortDefinitionOutput));
+ paramPortDefinitionOutput.format.video.nFrameWidth = mMaxFrameWidth;
+ paramPortDefinitionOutput.format.video.nFrameHeight = mMaxFrameHeight;
+ ports[p->nPortIndex]->SetPortDefinition(&paramPortDefinitionOutput, true);
+ }
+ break;
+ }
default:
ret = ComponentSetParameter(nIndex, pComponentParameterStructure);
@@ -768,11 +815,16 @@ OMX_ERRORTYPE ComponentBase::CBaseGetExtensionIndex(
}
#endif
- if (!strcmp(cParameterName, "OMX.Intel.index.enableErrorReport")) {
+ if (!strcmp(cParameterName, "OMX.Intel.index.enableErrorReport")) {
*pIndexType = static_cast<OMX_INDEXTYPE>(OMX_IndexExtEnableErrorReport);
return OMX_ErrorNone;
}
+ if (!strcmp(cParameterName, "OMX.google.android.index.prepareForAdaptivePlayback")) {
+ *pIndexType = static_cast<OMX_INDEXTYPE>(OMX_IndexExtPrepareForAdaptivePlayback);
+ return OMX_ErrorNone;
+ }
+
if (!strcmp(cParameterName, "OMX.Intel.index.vp8ForceKFrame")) {
*pIndexType = static_cast<OMX_INDEXTYPE>(OMX_IndexExtVP8ForceKFrame);
return OMX_ErrorNone;
diff --git a/core/inc/khronos/openmax/include/OMX_IntelIndexExt.h b/core/inc/khronos/openmax/include/OMX_IntelIndexExt.h
index d210bc8..22862be 100644
--- a/core/inc/khronos/openmax/include/OMX_IntelIndexExt.h
+++ b/core/inc/khronos/openmax/include/OMX_IntelIndexExt.h
@@ -65,6 +65,7 @@ typedef enum OMX_INTELINDEXEXTTYPE {
OMX_IndexExtPrependSPSPPS,
/* Error report by WebRTC */
OMX_IndexExtEnableErrorReport, /**<reference: EnableErrorReport for decoder */
+ OMX_IndexExtPrepareForAdaptivePlayback, /**<reference: Prepare for AdaptivePlayback*/
OMX_IndexExtVP8ForceKFrame,
// Index for VPP must always be put at the end
#ifdef TARGET_HAS_VPP