aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--videocodec/Android.mk114
-rw-r--r--videocodec/OMXVideoDecoderBase.cpp23
-rw-r--r--videocodec/OMXVideoDecoderBase.h4
-rw-r--r--videocodec/OMXVideoDecoderVP9HWR.cpp56
-rw-r--r--videocodec/OMXVideoDecoderVP9HWR.h21
-rw-r--r--videocodec/OMXVideoDecoderVP9Hybrid.cpp277
-rw-r--r--videocodec/OMXVideoDecoderVP9Hybrid.h30
7 files changed, 367 insertions, 158 deletions
diff --git a/videocodec/Android.mk b/videocodec/Android.mk
index d63b83b..d3b3366 100644
--- a/videocodec/Android.mk
+++ b/videocodec/Android.mk
@@ -9,8 +9,8 @@ endif
include $(CLEAR_VARS)
-ifeq ($(TARGET_HAS_VPP),true)
-LOCAL_CFLAGS += -DTARGET_HAS_VPP
+ifeq ($(TARGET_HAS_ISV),true)
+LOCAL_CFLAGS += -DTARGET_HAS_ISV
endif
LOCAL_SHARED_LIBRARIES := \
@@ -26,7 +26,8 @@ LOCAL_C_INCLUDES := \
$(TARGET_OUT_HEADERS)/libmix_videodecoder \
$(TARGET_OUT_HEADERS)/libva \
$(call include-path-for, frameworks-native)/media/hardware \
- $(call include-path-for, frameworks-native)/media/openmax
+ $(call include-path-for, frameworks-native)/media/openmax \
+ $(call include-path-for, libhardware)
PLATFORM_USE_GEN_HW := \
baytrail \
@@ -37,9 +38,10 @@ LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/ufo
endif
LOCAL_SRC_FILES := \
- OMXComponentCodecBase.cpp\
- OMXVideoDecoderBase.cpp\
+ OMXComponentCodecBase.cpp \
+ OMXVideoDecoderBase.cpp \
OMXVideoDecoderAVC.cpp
+
LOCAL_CFLAGS += -Werror
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := libOMXVideoDecoderAVC
@@ -77,8 +79,8 @@ PLATFORM_SUPPORT_VP8 := \
ifneq ($(filter $(TARGET_BOARD_PLATFORM),$(PLATFORM_SUPPORT_VP8)),)
include $(CLEAR_VARS)
-ifeq ($(TARGET_HAS_VPP),true)
-LOCAL_CFLAGS += -DTARGET_HAS_VPP
+ifeq ($(TARGET_HAS_ISV),true)
+LOCAL_CFLAGS += -DTARGET_HAS_ISV
endif
LOCAL_SHARED_LIBRARIES := \
@@ -94,12 +96,14 @@ LOCAL_C_INCLUDES := \
$(TARGET_OUT_HEADERS)/libmix_videodecoder \
$(TARGET_OUT_HEADERS)/libva \
$(call include-path-for, frameworks-native)/media/hardware \
- $(call include-path-for, frameworks-native)/media/openmax
+ $(call include-path-for, frameworks-native)/media/openmax \
+ $(call include-path-for, libhardware)
LOCAL_SRC_FILES := \
- OMXComponentCodecBase.cpp\
- OMXVideoDecoderBase.cpp\
+ OMXComponentCodecBase.cpp \
+ OMXVideoDecoderBase.cpp \
OMXVideoDecoderVP8.cpp
+
LOCAL_CFLAGS += -Werror
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := libOMXVideoDecoderVP8
@@ -136,12 +140,11 @@ endif
# VP9 with SW decode and HW Render
include $(CLEAR_VARS)
-ifeq ($(TARGET_HAS_VPP),true)
-LOCAL_CFLAGS += -DTARGET_HAS_VPP
+ifeq ($(TARGET_HAS_ISV),true)
+LOCAL_CFLAGS += -DTARGET_HAS_ISV
endif
LOCAL_SHARED_LIBRARIES := \
- libui \
libwrs_omxil_common \
libva_videodecoder \
liblog \
@@ -161,15 +164,16 @@ LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/libvpx_internal/libvpx/vpx_codec \
$(LOCAL_PATH)/libvpx_internal/libvpx/vpx_ports \
$(call include-path-for, frameworks-native)/media/hardware \
- $(call include-path-for, frameworks-native)/media/openmax
+ $(call include-path-for, frameworks-native)/media/openmax \
+ $(call include-path-for, libhardware)
ifeq ($(TARGET_BOARD_PLATFORM),baytrail)
LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/ufo
endif
LOCAL_SRC_FILES := \
- OMXComponentCodecBase.cpp\
- OMXVideoDecoderBase.cpp\
+ OMXComponentCodecBase.cpp \
+ OMXVideoDecoderBase.cpp \
OMXVideoDecoderVP9HWR.cpp
LOCAL_CFLAGS += -Werror
@@ -196,7 +200,6 @@ ifeq ($(TARGET_HAS_VPP),true)
LOCAL_CFLAGS += -DTARGET_HAS_VPP
endif
LOCAL_SHARED_LIBRARIES := \
- libui \
libwrs_omxil_common \
liblog \
libva_videodecoder \
@@ -208,15 +211,16 @@ LOCAL_C_INCLUDES := \
$(TARGET_OUT_HEADERS)/libmix_videodecoder \
$(TARGET_OUT_HEADERS)/libva \
$(call include-path-for, frameworks-native)/media/hardware \
- $(call include-path-for, frameworks-native)/media/openmax
+ $(call include-path-for, frameworks-native)/media/openmax \
+ $(call include-path-for, libhardware)
ifeq ($(TARGET_BOARD_PLATFORM),baytrail)
LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/ufo
endif
LOCAL_SRC_FILES := \
- OMXComponentCodecBase.cpp\
- OMXVideoDecoderBase.cpp\
+ OMXComponentCodecBase.cpp \
+ OMXVideoDecoderBase.cpp \
OMXVideoDecoderVP9Hybrid.cpp
LOCAL_CFLAGS += -Werror
@@ -238,8 +242,8 @@ include $(BUILD_SHARED_LIBRARY)
endif
include $(CLEAR_VARS)
-ifeq ($(TARGET_HAS_VPP),true)
-LOCAL_CFLAGS += -DTARGET_HAS_VPP
+ifeq ($(TARGET_HAS_ISV),true)
+LOCAL_CFLAGS += -DTARGET_HAS_ISV
endif
LOCAL_SHARED_LIBRARIES := \
@@ -255,7 +259,8 @@ LOCAL_C_INCLUDES := \
$(TARGET_OUT_HEADERS)/libmix_videodecoder \
$(TARGET_OUT_HEADERS)/libva \
$(call include-path-for, frameworks-native)/media/hardware \
- $(call include-path-for, frameworks-native)/media/openmax
+ $(call include-path-for, frameworks-native)/media/openmax \
+ $(call include-path-for, libhardware)
PLATFORM_USE_GEN_HW := \
baytrail \
@@ -266,9 +271,10 @@ LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/ufo
endif
LOCAL_SRC_FILES := \
- OMXComponentCodecBase.cpp\
- OMXVideoDecoderBase.cpp\
+ OMXComponentCodecBase.cpp \
+ OMXVideoDecoderBase.cpp \
OMXVideoDecoderMPEG4.cpp
+
LOCAL_CFLAGS += -Werror
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := libOMXVideoDecoderMPEG4
@@ -293,8 +299,8 @@ include $(BUILD_SHARED_LIBRARY)
################################################################################
include $(CLEAR_VARS)
-ifeq ($(TARGET_HAS_VPP),true)
-LOCAL_CFLAGS += -DTARGET_HAS_VPP
+ifeq ($(TARGET_HAS_ISV),true)
+LOCAL_CFLAGS += -DTARGET_HAS_ISV
endif
LOCAL_SHARED_LIBRARIES := \
@@ -310,7 +316,8 @@ LOCAL_C_INCLUDES := \
$(TARGET_OUT_HEADERS)/libmix_videodecoder \
$(TARGET_OUT_HEADERS)/libva \
$(call include-path-for, frameworks-native)/media/hardware \
- $(call include-path-for, frameworks-native)/media/openmax
+ $(call include-path-for, frameworks-native)/media/openmax \
+ $(call include-path-for, libhardware)
PLATFORM_USE_GEN_HW := \
baytrail \
@@ -321,9 +328,10 @@ LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/ufo
endif
LOCAL_SRC_FILES := \
- OMXComponentCodecBase.cpp\
- OMXVideoDecoderBase.cpp\
+ OMXComponentCodecBase.cpp \
+ OMXVideoDecoderBase.cpp \
OMXVideoDecoderH263.cpp
+
LOCAL_CFLAGS += -Werror
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := libOMXVideoDecoderH263
@@ -348,8 +356,8 @@ include $(BUILD_SHARED_LIBRARY)
################################################################################
include $(CLEAR_VARS)
-ifeq ($(TARGET_HAS_VPP),true)
-LOCAL_CFLAGS += -DTARGET_HAS_VPP
+ifeq ($(TARGET_HAS_ISV),true)
+LOCAL_CFLAGS += -DTARGET_HAS_ISV
endif
LOCAL_SHARED_LIBRARIES := \
@@ -365,7 +373,8 @@ LOCAL_C_INCLUDES := \
$(TARGET_OUT_HEADERS)/libmix_videodecoder \
$(TARGET_OUT_HEADERS)/libva \
$(call include-path-for, frameworks-native)/media/hardware \
- $(call include-path-for, frameworks-native)/media/openmax
+ $(call include-path-for, frameworks-native)/media/openmax \
+ $(call include-path-for, libhardware)
PLATFORM_USE_GEN_HW := \
baytrail \
@@ -376,9 +385,10 @@ LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/ufo
endif
LOCAL_SRC_FILES := \
- OMXComponentCodecBase.cpp\
- OMXVideoDecoderBase.cpp\
+ OMXComponentCodecBase.cpp \
+ OMXVideoDecoderBase.cpp \
OMXVideoDecoderWMV.cpp
+
LOCAL_CFLAGS += -Werror
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := libOMXVideoDecoderWMV
@@ -410,8 +420,8 @@ include $(BUILD_SHARED_LIBRARY)
ifeq ($(USE_INTEL_SECURE_AVC),true)
include $(CLEAR_VARS)
-ifeq ($(TARGET_HAS_VPP),true)
-LOCAL_CFLAGS += -DTARGET_HAS_VPP
+ifeq ($(TARGET_HAS_ISV),true)
+LOCAL_CFLAGS += -DTARGET_HAS_ISV
endif
LOCAL_SHARED_LIBRARIES := \
@@ -430,9 +440,10 @@ LOCAL_C_INCLUDES := \
$(TARGET_OUT_HEADERS)/libdrm \
$(call include-path-for, frameworks-native)/media/hardware \
$(call include-path-for, frameworks-native)/media/openmax \
+ $(call include-path-for, libhardware)
LOCAL_SRC_FILES := \
- OMXComponentCodecBase.cpp\
+ OMXComponentCodecBase.cpp \
OMXVideoDecoderBase.cpp
ifeq ($(TARGET_BOARD_PLATFORM),moorefield)
@@ -454,8 +465,8 @@ endif #USE_INTEL_SECURE_AVC
################################################################################
include $(CLEAR_VARS)
-ifeq ($(TARGET_HAS_VPP),true)
-LOCAL_CFLAGS += -DTARGET_HAS_VPP
+ifeq ($(TARGET_HAS_ISV),true)
+LOCAL_CFLAGS += -DTARGET_HAS_ISV
endif
LOCAL_SHARED_LIBRARIES := \
@@ -492,8 +503,8 @@ include $(BUILD_SHARED_LIBRARY)
################################################################################
include $(CLEAR_VARS)
-ifeq ($(TARGET_HAS_VPP),true)
-LOCAL_CFLAGS += -DTARGET_HAS_VPP
+ifeq ($(TARGET_HAS_ISV),true)
+LOCAL_CFLAGS += -DTARGET_HAS_ISV
endif
LOCAL_SHARED_LIBRARIES := \
@@ -534,8 +545,8 @@ include $(BUILD_SHARED_LIBRARY)
################################################################################
include $(CLEAR_VARS)
-ifeq ($(TARGET_HAS_VPP),true)
-LOCAL_CFLAGS += -DTARGET_HAS_VPP
+ifeq ($(TARGET_HAS_ISV),true)
+LOCAL_CFLAGS += -DTARGET_HAS_ISV
endif
LOCAL_SHARED_LIBRARIES := \
@@ -573,8 +584,8 @@ include $(BUILD_SHARED_LIBRARY)
################################################################################
include $(CLEAR_VARS)
-ifeq ($(TARGET_HAS_VPP),true)
-LOCAL_CFLAGS += -DTARGET_HAS_VPP
+ifeq ($(TARGET_HAS_ISV),true)
+LOCAL_CFLAGS += -DTARGET_HAS_ISV
endif
LOCAL_SHARED_LIBRARIES := \
@@ -590,11 +601,12 @@ LOCAL_C_INCLUDES := \
$(TARGET_OUT_HEADERS)/libmix_videodecoder \
$(TARGET_OUT_HEADERS)/libva \
$(call include-path-for, frameworks-native)/media/hardware \
- $(call include-path-for, frameworks-native)/media/openmax
+ $(call include-path-for, frameworks-native)/media/openmax \
+ $(call include-path-for, libhardware)
LOCAL_SRC_FILES := \
- OMXComponentCodecBase.cpp\
- OMXVideoDecoderBase.cpp\
+ OMXComponentCodecBase.cpp \
+ OMXVideoDecoderBase.cpp \
OMXVideoDecoderPAVC.cpp
LOCAL_CFLAGS += -Werror
@@ -617,8 +629,8 @@ include $(BUILD_SHARED_LIBRARY)
################################################################################
include $(CLEAR_VARS)
-ifeq ($(TARGET_HAS_VPP),true)
-LOCAL_CFLAGS += -DTARGET_HAS_VPP
+ifeq ($(TARGET_HAS_ISV),true)
+LOCAL_CFLAGS += -DTARGET_HAS_ISV
endif
LOCAL_SHARED_LIBRARIES := \
diff --git a/videocodec/OMXVideoDecoderBase.cpp b/videocodec/OMXVideoDecoderBase.cpp
index 7087cd4..cbbc9ae 100644
--- a/videocodec/OMXVideoDecoderBase.cpp
+++ b/videocodec/OMXVideoDecoderBase.cpp
@@ -17,19 +17,22 @@
//#define LOG_NDEBUG 0
#define LOG_TAG "OMXVideoDecoder"
#include <wrs_omxil_core/log.h>
-#include "OMXVideoDecoderBase.h"
+
+#include <hardware/gralloc.h>
#include <va/va_android.h>
+#include "OMXVideoDecoderBase.h"
+
static const char* VA_RAW_MIME_TYPE = "video/x-raw-va";
static const uint32_t VA_COLOR_FORMAT = 0x7FA00E00;
OMXVideoDecoderBase::OMXVideoDecoderBase()
: mRotationDegrees(0),
- mVideoDecoder(NULL),
- mNativeBufferCount(OUTPORT_NATIVE_BUFFER_COUNT),
-#ifdef TARGET_HAS_VPP
+#ifdef TARGET_HAS_ISV
mVppBufferNum(0),
#endif
+ mVideoDecoder(NULL),
+ mNativeBufferCount(OUTPORT_NATIVE_BUFFER_COUNT),
mWorkingMode(RAWDATA_MODE),
mErrorReportEnabled (false) {
mOMXBufferHeaderTypePtrNum = 0;
@@ -219,7 +222,7 @@ OMX_ERRORTYPE OMXVideoDecoderBase::ProcessorDeinit(void) {
mOMXBufferHeaderTypePtrNum = 0;
memset(&mGraphicBufferParam, 0, sizeof(mGraphicBufferParam));
mRotationDegrees = 0;
-#ifdef TARGET_HAS_VPP
+#ifdef TARGET_HAS_ISV
mVppBufferNum = 0;
#endif
return OMXComponentCodecBase::ProcessorDeinit();
@@ -474,7 +477,7 @@ OMX_ERRORTYPE OMXVideoDecoderBase::PrepareConfigBuffer(VideoConfigBuffer *p) {
}
p->rotationDegrees = mRotationDegrees;
-#ifdef TARGET_HAS_VPP
+#ifdef TARGET_HAS_ISV
p->vppBufferNum = mVppBufferNum;
#endif
p->width = paramPortDefinitionInput->format.video.nFrameWidth;
@@ -632,7 +635,7 @@ OMX_ERRORTYPE OMXVideoDecoderBase::HandleFormatChange(void) {
uint32_t sliceHeightCropped = heightCropped;
int force_realloc = 0;
-#ifdef TARGET_HAS_VPP
+#ifdef TARGET_HAS_ISV
LOGI("============== mVppBufferNum = %d\n", mVppBufferNum);
if (paramPortDefinitionOutput.nBufferCountActual - mVppBufferNum < formatInfo->actualBufferNeeded) {
#else
@@ -761,7 +764,7 @@ OMX_ERRORTYPE OMXVideoDecoderBase::BuildHandlerList(void) {
AddHandler(static_cast<OMX_INDEXTYPE>(OMX_IndexExtUseNativeBuffer), GetNativeBuffer, SetNativeBuffer);
AddHandler(static_cast<OMX_INDEXTYPE>(OMX_IndexExtEnableNativeBuffer), GetNativeBufferMode, SetNativeBufferMode);
AddHandler(static_cast<OMX_INDEXTYPE>(OMX_IndexExtRotationDegrees), GetDecoderRotation, SetDecoderRotation);
-#ifdef TARGET_HAS_VPP
+#ifdef TARGET_HAS_ISV
AddHandler(static_cast<OMX_INDEXTYPE>(OMX_IndexExtVppBufferNum), GetDecoderVppBufferNum, SetDecoderVppBufferNum);
#endif
AddHandler(OMX_IndexConfigCommonOutputCrop, GetDecoderOutputCrop, SetDecoderOutputCrop);
@@ -916,8 +919,8 @@ OMX_ERRORTYPE OMXVideoDecoderBase::SetDecoderRotation(OMX_PTR pStructure) {
}
}
-#ifdef TARGET_HAS_VPP
-OMX_ERRORTYPE OMXVideoDecoderBase::GetDecoderVppBufferNum(OMX_PTR pStructure) {
+#ifdef TARGET_HAS_ISV
+OMX_ERRORTYPE OMXVideoDecoderBase::GetDecoderVppBufferNum(OMX_PTR) {
return OMX_ErrorBadParameter;
}
OMX_ERRORTYPE OMXVideoDecoderBase::SetDecoderVppBufferNum(OMX_PTR pStructure) {
diff --git a/videocodec/OMXVideoDecoderBase.h b/videocodec/OMXVideoDecoderBase.h
index 556bc23..49610a7 100644
--- a/videocodec/OMXVideoDecoderBase.h
+++ b/videocodec/OMXVideoDecoderBase.h
@@ -80,7 +80,7 @@ protected:
DECLARE_HANDLER(OMXVideoDecoderBase, NativeBufferMode);
DECLARE_HANDLER(OMXVideoDecoderBase, DecoderRotation);
DECLARE_HANDLER(OMXVideoDecoderBase, DecoderOutputCrop);
-#ifdef TARGET_HAS_VPP
+#ifdef TARGET_HAS_ISV
DECLARE_HANDLER(OMXVideoDecoderBase, DecoderVppBufferNum);
#endif
DECLARE_HANDLER(OMXVideoDecoderBase, ErrorReportMode);
@@ -107,7 +107,7 @@ private:
uint32_t graphicBufferColorFormat;
};
uint32_t mRotationDegrees;
-#ifdef TARGET_HAS_VPP
+#ifdef TARGET_HAS_ISV
uint32_t mVppBufferNum;
#endif
diff --git a/videocodec/OMXVideoDecoderVP9HWR.cpp b/videocodec/OMXVideoDecoderVP9HWR.cpp
index ec97bac..2170fd0 100644
--- a/videocodec/OMXVideoDecoderVP9HWR.cpp
+++ b/videocodec/OMXVideoDecoderVP9HWR.cpp
@@ -21,8 +21,6 @@
#include "OMXVideoDecoderVP9HWR.h"
#include <system/window.h>
-#include <ui/GraphicBufferMapper.h>
-#include <ui/Rect.h>
#include <HardwareAPI.h>
#include <hardware/hardware.h>
#include <hardware/gralloc.h>
@@ -106,32 +104,32 @@ int getVP9FrameBuffer(void *user_priv,
unsigned int new_size,
vpx_codec_frame_buffer_t *fb)
{
- (void)user_priv;
+ OMXVideoDecoderVP9HWR * p = (OMXVideoDecoderVP9HWR *)user_priv;
if (fb == NULL) {
return -1;
}
// TODO: Adaptive playback case needs to reconsider
- if (extNativeBufferSize < new_size) {
+ if (p->extNativeBufferSize < new_size) {
LOGE("Provided frame buffer size < requesting min size.");
return -1;
}
int i;
- for (i = 0; i < extMappedNativeBufferCount; i++ ) {
- if ((extMIDs[i]->m_render_done == true) &&
- (extMIDs[i]->m_released == true)) {
- fb->data = extMIDs[i]->m_usrAddr;
- fb->size = extNativeBufferSize;
- fb->fb_stride = extActualBufferStride;
- fb->fb_height_stride = extActualBufferHeightStride;
+ for (i = 0; i < p->extMappedNativeBufferCount; i++ ) {
+ if ((p->extMIDs[i]->m_render_done == true) &&
+ (p->extMIDs[i]->m_released == true)) {
+ fb->data = p->extMIDs[i]->m_usrAddr;
+ fb->size = p->extNativeBufferSize;
+ fb->fb_stride = p->extActualBufferStride;
+ fb->fb_height_stride = p->extActualBufferHeightStride;
fb->fb_index = i;
- extMIDs[i]->m_released = false;
+ p->extMIDs[i]->m_released = false;
break;
}
}
- if (i == extMappedNativeBufferCount) {
+ if (i == p->extMappedNativeBufferCount) {
LOGE("No available frame buffer in pool.");
return -1;
}
@@ -143,18 +141,18 @@ int getVP9FrameBuffer(void *user_priv,
int releaseVP9FrameBuffer(void *user_priv, vpx_codec_frame_buffer_t *fb)
{
int i;
- user_priv = user_priv; // to remove warning
+ OMXVideoDecoderVP9HWR * p = (OMXVideoDecoderVP9HWR *)user_priv;
if (fb == NULL) {
return -1;
}
- for (i = 0; i < extMappedNativeBufferCount; i++ ) {
- if (fb->data == extMIDs[i]->m_usrAddr) {
- extMIDs[i]->m_released = true;
+ for (i = 0; i < p->extMappedNativeBufferCount; i++ ) {
+ if (fb->data == p->extMIDs[i]->m_usrAddr) {
+ p->extMIDs[i]->m_released = true;
break;
}
}
- if (i == extMappedNativeBufferCount) {
+ if (i == p->extMappedNativeBufferCount) {
LOGE("Not found matching frame buffer in pool, libvpx's wrong?");
return -1;
}
@@ -182,7 +180,7 @@ OMX_ERRORTYPE OMXVideoDecoderVP9HWR::initDecoder()
if (vpx_codec_set_frame_buffer_functions((vpx_codec_ctx_t *)mCtx,
getVP9FrameBuffer,
releaseVP9FrameBuffer,
- NULL)) {
+ this)) {
LOGE("Failed to configure external frame buffers");
return OMX_ErrorNotReady;
}
@@ -344,26 +342,13 @@ OMX_ERRORTYPE OMXVideoDecoderVP9HWR::ProcessorInit(void)
OMX_ERRORTYPE OMXVideoDecoderVP9HWR::ProcessorDeinit(void)
{
- mOMXBufferHeaderTypePtrNum = 0;
- memset(&mGraphicBufferParam, 0, sizeof(mGraphicBufferParam));
-
destroyDecoder();
unsigned int i = 0;
-
- for (i = 0; i < MAX_NATIVE_BUFFER_COUNT; i++) {
- delete extMIDs[i]->m_surface;
- free(extMIDs[i]);
- }
-
if (mWorkingMode == GRAPHICBUFFER_MODE) {
for (i = 0; i < mOMXBufferHeaderTypePtrNum; i++) {
if (extMIDs[i]->m_surface != NULL) {
vaDestroySurfaces(mVADisplay, extMIDs[i]->m_surface, 1);
}
- if (extMIDs[i]->m_usrAddr != NULL) {
- free(extMIDs[i]->m_usrAddr);
- extMIDs[i]->m_usrAddr = NULL;
- }
}
} else if (mWorkingMode == RAWDATA_MODE) {
@@ -374,7 +359,12 @@ OMX_ERRORTYPE OMXVideoDecoderVP9HWR::ProcessorDeinit(void)
}
}
}
-
+ mOMXBufferHeaderTypePtrNum = 0;
+ memset(&mGraphicBufferParam, 0, sizeof(mGraphicBufferParam));
+ for (i = 0; i < MAX_NATIVE_BUFFER_COUNT; i++) {
+ delete extMIDs[i]->m_surface;
+ free(extMIDs[i]);
+ }
return OMXComponentCodecBase::ProcessorDeinit();
}
diff --git a/videocodec/OMXVideoDecoderVP9HWR.h b/videocodec/OMXVideoDecoderVP9HWR.h
index 069b182..e55f54e 100644
--- a/videocodec/OMXVideoDecoderVP9HWR.h
+++ b/videocodec/OMXVideoDecoderVP9HWR.h
@@ -43,25 +43,19 @@ typedef unsigned int Display;
#define DECODE_WITH_GRALLOC_BUFFER
#define VPX_DECODE_BORDER 0
-// Make it global to be accessed by callback realloc func
#define MAX_NATIVE_BUFFER_COUNT 64
-vaapiMemId* extMIDs[MAX_NATIVE_BUFFER_COUNT];
-int extUtilBufferCount;
-int extMappedNativeBufferCount;
-unsigned int extNativeBufferSize;
-
-// These two strides are passed into libvpx to indicate the external buffer size
-// in case that video demension is smaller than these, libvpx inside should
-// ajust the start point of address of decoded y/v/u component.
-// This is especially for adaptive playback case. External buffer is always allocated
-// (or mapped from vaSurface) to a pre-set max size.
-int extActualBufferStride;
-int extActualBufferHeightStride;
class OMXVideoDecoderVP9HWR : public OMXVideoDecoderBase {
public:
OMXVideoDecoderVP9HWR();
virtual ~OMXVideoDecoderVP9HWR();
+ vaapiMemId* extMIDs[MAX_NATIVE_BUFFER_COUNT];
+ int extUtilBufferCount;
+ int extMappedNativeBufferCount;
+ unsigned int extNativeBufferSize;
+ // (or mapped from vaSurface) to a pre-set max size.
+ int extActualBufferStride;
+ int extActualBufferHeightStride;
protected:
virtual OMX_ERRORTYPE InitInputPortFormatSpecific(OMX_PARAM_PORTDEFINITIONTYPE *paramPortDefinitionInput);
@@ -98,7 +92,6 @@ protected:
friend int reallocVP9FrameBuffer(void *user_priv, unsigned int new_size, vpx_codec_frame_buffer_t *fb);
DECLARE_HANDLER(OMXVideoDecoderVP9HWR, ParamVideoVp9);
-
private:
OMX_ERRORTYPE initDecoder();
OMX_ERRORTYPE destroyDecoder();
diff --git a/videocodec/OMXVideoDecoderVP9Hybrid.cpp b/videocodec/OMXVideoDecoderVP9Hybrid.cpp
index e1ff00d..1246b7b 100644
--- a/videocodec/OMXVideoDecoderVP9Hybrid.cpp
+++ b/videocodec/OMXVideoDecoderVP9Hybrid.cpp
@@ -39,6 +39,15 @@ OMXVideoDecoderVP9Hybrid::OMXVideoDecoderVP9Hybrid() {
mDecoderDecode = NULL;
mCheckBufferAvailable = NULL;
mGetOutput = NULL;
+ mGetRawDataOutput = NULL;
+ mGetFrameResolution = NULL;
+ mDeinitDecoder = NULL;
+ mLastTimeStamp = 0;
+ mWorkingMode = RAWDATA_MODE;
+ mDecodedImageWidth = 0;
+ mDecodedImageHeight = 0;
+ mDecodedImageNewWidth = 0;
+ mDecodedImageNewHeight = 0;
}
OMXVideoDecoderVP9Hybrid::~OMXVideoDecoderVP9Hybrid() {
@@ -57,15 +66,26 @@ OMX_ERRORTYPE OMXVideoDecoderVP9Hybrid::InitInputPortFormatSpecific(
}
OMX_ERRORTYPE OMXVideoDecoderVP9Hybrid::ProcessorInit(void) {
- unsigned int buff[MAX_GRAPHIC_BUFFER_NUM];
- unsigned int i;
- int bufferSize = mGraphicBufferParam.graphicBufferStride *
+ uint32_t buff[MAX_GRAPHIC_BUFFER_NUM];
+ uint32_t i, bufferCount;
+ bool gralloc_mode = (mWorkingMode == GRAPHICBUFFER_MODE);
+ uint32_t bufferSize, bufferStride, bufferHeight;
+ if (!gralloc_mode) {
+ bufferSize = 1920 * 1088 * 1.5;
+ bufferStride = 1920;
+ bufferHeight = 1088;
+ bufferCount = 12;
+ } else {
+ bufferSize = mGraphicBufferParam.graphicBufferStride *
mGraphicBufferParam.graphicBufferHeight * 1.5;
- int bufferStride = mGraphicBufferParam.graphicBufferStride;
+ bufferStride = mGraphicBufferParam.graphicBufferStride;
+ bufferCount = mOMXBufferHeaderTypePtrNum;
+ bufferHeight = mGraphicBufferParam.graphicBufferHeight;
- for (i = 0; i < mOMXBufferHeaderTypePtrNum; i++ ) {
- OMX_BUFFERHEADERTYPE *buf_hdr = mOMXBufferHeaderTypePtrArray[i];
- buff[i] = (unsigned int)(buf_hdr->pBuffer);
+ for (i = 0; i < bufferCount; i++ ) {
+ OMX_BUFFERHEADERTYPE *buf_hdr = mOMXBufferHeaderTypePtrArray[i];
+ buff[i] = (uint32_t)(buf_hdr->pBuffer);
+ }
}
mLibHandle = dlopen("libDecoderVP9Hybrid.so", RTLD_NOW);
@@ -82,10 +102,14 @@ OMX_ERRORTYPE OMXVideoDecoderVP9Hybrid::ProcessorInit(void) {
mDecoderDecode = (DecodeFunc)dlsym(mLibHandle, "Decoder_Decode");
mCheckBufferAvailable = (IsBufferAvailableFunc)dlsym(mLibHandle, "Decoder_IsBufferAvailable");
mGetOutput = (GetOutputFunc)dlsym(mLibHandle, "Decoder_GetOutput");
+ mGetRawDataOutput = (GetRawDataOutputFunc)dlsym(mLibHandle, "Decoder_GetRawDataOutput");
+ mGetFrameResolution = (GetFrameResolutionFunc)dlsym(mLibHandle, "Decoder_GetFrameResolution");
+ mDeinitDecoder = (DeinitFunc)dlsym(mLibHandle, "Decoder_Deinit");
if (mOpenDecoder == NULL || mCloseDecoder == NULL
|| mInitDecoder == NULL || mSingalRenderDone == NULL
|| mDecoderDecode == NULL || mCheckBufferAvailable == NULL
- || mGetOutput == NULL) {
+ || mGetOutput == NULL || mGetRawDataOutput == NULL
+ || mGetFrameResolution == NULL || mDeinitDecoder == NULL) {
return OMX_ErrorBadParameter;
}
@@ -94,10 +118,58 @@ OMX_ERRORTYPE OMXVideoDecoderVP9Hybrid::ProcessorInit(void) {
return OMX_ErrorBadParameter;
}
- mInitDecoder(mHybridCtx,bufferSize,bufferStride,mOMXBufferHeaderTypePtrNum, buff);
+ mInitDecoder(mHybridCtx,bufferSize,bufferStride,bufferHeight,bufferCount,gralloc_mode, buff);
return OMX_ErrorNone;
}
+OMX_ERRORTYPE OMXVideoDecoderVP9Hybrid::ProcessorReset(void)
+{
+ uint32_t buff[MAX_GRAPHIC_BUFFER_NUM];
+ uint32_t i, bufferCount;
+ bool gralloc_mode = (mWorkingMode == GRAPHICBUFFER_MODE);
+ uint32_t bufferSize, bufferStride, bufferHeight;
+ if (!gralloc_mode) {
+ bufferSize = mDecodedImageWidth * mDecodedImageHeight * 1.5;
+ bufferStride = mDecodedImageWidth;
+ bufferHeight = mDecodedImageHeight;
+ bufferCount = 12;
+ } else {
+ bufferSize = mGraphicBufferParam.graphicBufferStride *
+ mGraphicBufferParam.graphicBufferHeight * 1.5;
+ bufferStride = mGraphicBufferParam.graphicBufferStride;
+ bufferCount = mOMXBufferHeaderTypePtrNum;
+ bufferHeight = mGraphicBufferParam.graphicBufferHeight;
+
+ for (i = 0; i < bufferCount; i++ ) {
+ OMX_BUFFERHEADERTYPE *buf_hdr = mOMXBufferHeaderTypePtrArray[i];
+ buff[i] = (uint32_t)(buf_hdr->pBuffer);
+ }
+ }
+ mInitDecoder(mHybridCtx,bufferSize,bufferStride,bufferHeight,bufferCount,gralloc_mode, buff);
+
+ return OMX_ErrorNone;
+}
+
+bool OMXVideoDecoderVP9Hybrid::isReallocateNeeded(const uint8_t * data,uint32_t data_sz)
+{
+ bool gralloc_mode = (mWorkingMode == GRAPHICBUFFER_MODE);
+ uint32_t width, height;
+ bool ret = true;
+ if (gralloc_mode) {
+ ret = mGetFrameResolution(data,data_sz, &width, &height);
+ if (ret) {
+ ret = width > mGraphicBufferParam.graphicBufferWidth
+ || height > mGraphicBufferParam.graphicBufferHeight;
+ if (ret) {
+ mDecodedImageNewWidth = width;
+ mDecodedImageNewHeight = height;
+ return true;
+ }
+ }
+ }
+ return ret;
+}
+
OMX_ERRORTYPE OMXVideoDecoderVP9Hybrid::ProcessorDeinit(void) {
mCloseDecoder(mCtx,mHybridCtx);
mOMXBufferHeaderTypePtrNum = 0;
@@ -112,7 +184,14 @@ OMX_ERRORTYPE OMXVideoDecoderVP9Hybrid::ProcessorStop(void) {
return OMXComponentCodecBase::ProcessorStop();
}
-OMX_ERRORTYPE OMXVideoDecoderVP9Hybrid::ProcessorFlush(OMX_U32) {
+OMX_ERRORTYPE OMXVideoDecoderVP9Hybrid::ProcessorFlush(OMX_U32 portIndex) {
+ if (portIndex == INPORT_INDEX || portIndex == OMX_ALL) {
+ // end the last frame
+ unsigned int width, height;
+ mDecoderDecode(mCtx,mHybridCtx,NULL,0,true);
+ mGetOutput(mCtx,mHybridCtx, &width, &height);
+ mLastTimeStamp = 0;
+ }
return OMX_ErrorNone;
}
@@ -121,7 +200,7 @@ OMX_ERRORTYPE OMXVideoDecoderVP9Hybrid::ProcessorPreFillBuffer(OMX_BUFFERHEADERT
unsigned int i = 0;
if (buffer->nOutputPortIndex == OUTPORT_INDEX){
- mSingalRenderDone(handle);
+ mSingalRenderDone(mHybridCtx,handle);
}
return OMX_ErrorNone;
}
@@ -134,6 +213,10 @@ OMX_ERRORTYPE OMXVideoDecoderVP9Hybrid::ProcessorProcess(
OMX_ERRORTYPE ret;
OMX_BUFFERHEADERTYPE *inBuffer = *pBuffers[INPORT_INDEX];
OMX_BUFFERHEADERTYPE *outBuffer = *pBuffers[OUTPORT_INDEX];
+ bool eos = (inBuffer->nFlags & OMX_BUFFERFLAG_EOS)? true:false;
+ OMX_BOOL isResolutionChange = OMX_FALSE;
+
+ eos = eos && (inBuffer->nFilledLen == 0);
if (inBuffer->pBuffer == NULL) {
LOGE("Buffer to decode is empty.");
@@ -148,22 +231,26 @@ OMX_ERRORTYPE OMXVideoDecoderVP9Hybrid::ProcessorProcess(
LOGW("Buffer has OMX_BUFFERFLAG_DECODEONLY flag.");
}
- if (inBuffer->nFlags & OMX_BUFFERFLAG_EOS) {
- if (inBuffer->nFilledLen == 0) {
- (*pBuffers[OUTPORT_INDEX])->nFilledLen = 0;
- (*pBuffers[OUTPORT_INDEX])->nFlags = OMX_BUFFERFLAG_EOS;
- return OMX_ErrorNone;
- }
- }
-
#if LOG_TIME == 1
struct timeval tv_start, tv_end;
int32_t time_ms;
gettimeofday(&tv_start,NULL);
#endif
- if (mDecoderDecode(mCtx,mHybridCtx,inBuffer->pBuffer + inBuffer->nOffset,inBuffer->nFilledLen) == false) {
- LOGE("on2 decoder failed to decode frame.");
- return OMX_ErrorBadParameter;
+ int res = mDecoderDecode(mCtx,mHybridCtx,inBuffer->pBuffer + inBuffer->nOffset,inBuffer->nFilledLen, eos);
+ if (res != 0) {
+ if (res == -2) {
+ if (isReallocateNeeded(inBuffer->pBuffer + inBuffer->nOffset,inBuffer->nFilledLen)) {
+ retains[INPORT_INDEX] = BUFFER_RETAIN_GETAGAIN;
+ HandleFormatChange();
+ return OMX_ErrorNone;
+ }
+ // drain the last frame, keep the current input buffer
+ res = mDecoderDecode(mCtx,mHybridCtx,NULL,0,true);
+ retains[INPORT_INDEX] = BUFFER_RETAIN_GETAGAIN;
+ } else {
+ LOGE("on2 decoder failed to decode frame.");
+ return OMX_ErrorBadParameter;
+ }
}
#if LOG_TIME == 1
@@ -174,12 +261,17 @@ OMX_ERRORTYPE OMXVideoDecoderVP9Hybrid::ProcessorProcess(
ret = FillRenderBuffer(pBuffers[OUTPORT_INDEX],
&retains[OUTPORT_INDEX],
- ((*pBuffers[INPORT_INDEX]))->nFlags);
+ eos? OMX_BUFFERFLAG_EOS:0,
+ &isResolutionChange);
if (ret == OMX_ErrorNone) {
- (*pBuffers[OUTPORT_INDEX])->nTimeStamp = inBuffer->nTimeStamp;
+ (*pBuffers[OUTPORT_INDEX])->nTimeStamp = mLastTimeStamp;
}
+ mLastTimeStamp = inBuffer->nTimeStamp;
+ if (isResolutionChange == OMX_TRUE) {
+ HandleFormatChange();
+ }
bool inputEoS = ((*pBuffers[INPORT_INDEX])->nFlags & OMX_BUFFERFLAG_EOS);
bool outputEoS = ((*pBuffers[OUTPORT_INDEX])->nFlags & OMX_BUFFERFLAG_EOS);
// if output port is not eos, retain the input buffer
@@ -206,29 +298,51 @@ static int ALIGN(int x, int y) {
OMX_ERRORTYPE OMXVideoDecoderVP9Hybrid::FillRenderBuffer(OMX_BUFFERHEADERTYPE **pBuffer,
buffer_retain_t *retain,
- OMX_U32 inportBufferFlags)
+ OMX_U32 inportBufferFlags,
+ OMX_BOOL *isResolutionChange)
{
OMX_BUFFERHEADERTYPE *buffer = *pBuffer;
OMX_BUFFERHEADERTYPE *buffer_orign = buffer;
OMX_ERRORTYPE ret = OMX_ErrorNone;
- if (mWorkingMode != GRAPHICBUFFER_MODE) {
- LOGE("Working Mode is not GRAPHICBUFFER_MODE");
- ret = OMX_ErrorBadParameter;
+ int fb_index;
+ if (mWorkingMode == RAWDATA_MODE) {
+ const OMX_PARAM_PORTDEFINITIONTYPE *paramPortDefinitionOutput
+ = this->ports[OUTPORT_INDEX]->GetPortDefinition();
+ int32_t stride = paramPortDefinitionOutput->format.video.nStride;
+ int32_t height = paramPortDefinitionOutput->format.video.nFrameHeight;
+ int32_t width = paramPortDefinitionOutput->format.video.nFrameWidth;
+ unsigned char *dst = buffer->pBuffer;
+ fb_index = mGetRawDataOutput(mCtx,mHybridCtx,dst,height,stride);
+ if (fb_index == -1) {
+ LOGV("vpx_codec_get_frame return NULL.");
+ return OMX_ErrorNotReady;
+ }
+ buffer->nOffset = 0;
+ buffer->nFilledLen = stride*height*3/2;
+ if (inportBufferFlags & OMX_BUFFERFLAG_EOS) {
+ buffer->nFlags = OMX_BUFFERFLAG_EOS;
+ }
+ return OMX_ErrorNone;
}
- int fb_index = mGetOutput(mCtx);
+
+ fb_index = mGetOutput(mCtx,mHybridCtx, &mDecodedImageNewWidth, &mDecodedImageNewHeight);
if (fb_index == -1) {
- LOGE("vpx_codec_get_frame return NULL.");
+ LOGV("vpx_codec_get_frame return NULL.");
return OMX_ErrorNotReady;
}
+ if (mDecodedImageHeight == 0 && mDecodedImageWidth == 0) {
+ mDecodedImageWidth = mDecodedImageNewWidth;
+ mDecodedImageHeight = mDecodedImageNewHeight;
+ *isResolutionChange = OMX_TRUE;
+ }
+ if ((mDecodedImageNewWidth != mDecodedImageWidth)
+ || (mDecodedImageNewHeight!= mDecodedImageHeight)) {
+ *isResolutionChange = OMX_TRUE;
+ }
buffer = *pBuffer = mOMXBufferHeaderTypePtrArray[fb_index];
-
- size_t dst_y_size = mGraphicBufferParam.graphicBufferStride *
- mGraphicBufferParam.graphicBufferHeight;
- size_t dst_c_stride = ALIGN(mGraphicBufferParam.graphicBufferStride / 2, 16);
- size_t dst_c_size = dst_c_stride * mGraphicBufferParam.graphicBufferHeight / 2;
buffer->nOffset = 0;
buffer->nFilledLen = sizeof(OMX_U8*);
if (inportBufferFlags & OMX_BUFFERFLAG_EOS) {
@@ -268,6 +382,88 @@ OMX_ERRORTYPE OMXVideoDecoderVP9Hybrid::SetParamVideoVp9(OMX_PTR) {
return OMX_ErrorNone;
}
+OMX_ERRORTYPE OMXVideoDecoderVP9Hybrid::HandleFormatChange(void)
+{
+ ALOGI("handle format change from %dx%d to %dx%d",
+ mDecodedImageWidth,mDecodedImageHeight,mDecodedImageNewWidth,mDecodedImageNewHeight);
+ mDecodedImageWidth = mDecodedImageNewWidth;
+ mDecodedImageHeight = mDecodedImageNewHeight;
+ // Sync port definition as it may change.
+ OMX_PARAM_PORTDEFINITIONTYPE paramPortDefinitionInput, paramPortDefinitionOutput;
+
+ memcpy(&paramPortDefinitionInput,
+ this->ports[INPORT_INDEX]->GetPortDefinition(),
+ sizeof(paramPortDefinitionInput));
+
+ memcpy(&paramPortDefinitionOutput,
+ this->ports[OUTPORT_INDEX]->GetPortDefinition(),
+ sizeof(paramPortDefinitionOutput));
+
+ unsigned int width = mDecodedImageWidth;
+ unsigned int height = mDecodedImageHeight;
+ unsigned int stride = mDecodedImageWidth;
+ unsigned int sliceHeight = mDecodedImageHeight;
+
+ unsigned int widthCropped = mDecodedImageWidth;
+ unsigned int heightCropped = mDecodedImageHeight;
+ unsigned int strideCropped = widthCropped;
+ unsigned int sliceHeightCropped = heightCropped;
+
+ if (widthCropped == paramPortDefinitionOutput.format.video.nFrameWidth &&
+ heightCropped == paramPortDefinitionOutput.format.video.nFrameHeight) {
+ if (mWorkingMode == RAWDATA_MODE) {
+ LOGW("Change of portsetting is not reported as size is not changed.");
+ return OMX_ErrorNone;
+ }
+ }
+
+ paramPortDefinitionInput.format.video.nFrameWidth = width;
+ paramPortDefinitionInput.format.video.nFrameHeight = height;
+ paramPortDefinitionInput.format.video.nStride = stride;
+ paramPortDefinitionInput.format.video.nSliceHeight = sliceHeight;
+
+ if (mWorkingMode == RAWDATA_MODE) {
+ paramPortDefinitionOutput.format.video.nFrameWidth = widthCropped;
+ paramPortDefinitionOutput.format.video.nFrameHeight = heightCropped;
+ paramPortDefinitionOutput.format.video.nStride = strideCropped;
+ paramPortDefinitionOutput.format.video.nSliceHeight = sliceHeightCropped;
+ } else if (mWorkingMode == GRAPHICBUFFER_MODE) {
+ // when the width and height ES parse are not larger than allocated graphic buffer in outport,
+ // there is no need to reallocate graphic buffer,just report the crop info to omx client
+ if (width <= mGraphicBufferParam.graphicBufferWidth &&
+ height <= mGraphicBufferParam.graphicBufferHeight) {
+ this->ports[INPORT_INDEX]->SetPortDefinition(&paramPortDefinitionInput, true);
+ this->ports[OUTPORT_INDEX]->ReportOutputCrop();
+ return OMX_ErrorNone;
+ }
+
+ if (width > mGraphicBufferParam.graphicBufferWidth ||
+ height > mGraphicBufferParam.graphicBufferHeight) {
+ // update the real decoded resolution to outport instead of display resolution
+ // for graphic buffer reallocation
+ // when the width and height parsed from ES are larger than allocated graphic buffer in outport,
+ paramPortDefinitionOutput.format.video.nFrameWidth = width;
+ paramPortDefinitionOutput.format.video.nFrameHeight = (height + 0x1f) & ~0x1f;
+ paramPortDefinitionOutput.format.video.eColorFormat = GetOutputColorFormat(
+ paramPortDefinitionOutput.format.video.nFrameWidth);
+ paramPortDefinitionOutput.format.video.nStride = stride;
+ paramPortDefinitionOutput.format.video.nSliceHeight = sliceHeight;
+ }
+ }
+
+ paramPortDefinitionOutput.bEnabled = (OMX_BOOL)false;
+ mOMXBufferHeaderTypePtrNum = 0;
+ memset(&mGraphicBufferParam, 0, sizeof(mGraphicBufferParam));
+ mDeinitDecoder(mHybridCtx);
+
+ this->ports[INPORT_INDEX]->SetPortDefinition(&paramPortDefinitionInput, true);
+ this->ports[OUTPORT_INDEX]->SetPortDefinition(&paramPortDefinitionOutput, true);
+
+ this->ports[OUTPORT_INDEX]->ReportPortSettingsChanged();
+ return OMX_ErrorNone;
+}
+
+
OMX_COLOR_FORMATTYPE OMXVideoDecoderVP9Hybrid::GetOutputColorFormat(int) {
LOGV("Output color format is HAL_PIXEL_FORMAT_YV12.");
return (OMX_COLOR_FORMATTYPE)HAL_PIXEL_FORMAT_YV12;
@@ -301,7 +497,7 @@ OMX_ERRORTYPE OMXVideoDecoderVP9Hybrid::GetNativeBufferUsageSpecific(OMX_PTR pSt
(android::GetAndroidNativeBufferUsageParams*)pStructure;
CHECK_TYPE_HEADER(param);
- param->nUsage |= (GRALLOC_USAGE_HW_TEXTURE | GRALLOC_USAGE_SW_READ_NEVER \
+ param->nUsage |= (GRALLOC_USAGE_HW_TEXTURE | GRALLOC_USAGE_SW_READ_OFTEN
| GRALLOC_USAGE_SW_WRITE_OFTEN | GRALLOC_USAGE_EXTERNAL_DISP);
return OMX_ErrorNone;
@@ -317,6 +513,7 @@ OMX_ERRORTYPE OMXVideoDecoderVP9Hybrid::SetNativeBufferModeSpecific(OMX_PTR pStr
if (!param->enable) {
mWorkingMode = RAWDATA_MODE;
+ LOGI("Raw data mode is used");
return OMX_ErrorNone;
}
mWorkingMode = GRAPHICBUFFER_MODE;
@@ -325,13 +522,13 @@ OMX_ERRORTYPE OMXVideoDecoderVP9Hybrid::SetNativeBufferModeSpecific(OMX_PTR pStr
OMX_PARAM_PORTDEFINITIONTYPE port_def;
memcpy(&port_def,port->GetPortDefinition(),sizeof(port_def));
- port_def.nBufferCountMin = mNativeBufferCount;
+ port_def.nBufferCountMin = mNativeBufferCount - 4;
port_def.nBufferCountActual = mNativeBufferCount;
port_def.format.video.cMIMEType = (OMX_STRING)VA_VED_RAW_MIME_TYPE;
- port_def.format.video.eColorFormat = (OMX_COLOR_FORMATTYPE)OMX_INTEL_COLOR_FormatYUV420PackedSemiPlanar;
// add borders for libvpx decode need.
- port_def.format.video.nFrameHeight += VPX_DECODE_BORDER * 2;
port_def.format.video.nFrameWidth += VPX_DECODE_BORDER * 2;
+ mDecodedImageWidth = port_def.format.video.nFrameWidth;
+ mDecodedImageHeight = port_def.format.video.nFrameHeight;
// make heigth 32bit align
port_def.format.video.nFrameHeight = (port_def.format.video.nFrameHeight + 0x1f) & ~0x1f;
port_def.format.video.eColorFormat = GetOutputColorFormat(port_def.format.video.nFrameWidth);
@@ -354,7 +551,7 @@ bool OMXVideoDecoderVP9Hybrid::IsAllBufferAvailable(void) {
if (!port_def->bEnabled) {
return false;
}
- return mCheckBufferAvailable();
+ return mCheckBufferAvailable(mHybridCtx);
}
DECLARE_OMX_COMPONENT("OMX.Intel.VideoDecoder.VP9.hybrid", "video_decoder.vp9", OMXVideoDecoderVP9Hybrid);
diff --git a/videocodec/OMXVideoDecoderVP9Hybrid.h b/videocodec/OMXVideoDecoderVP9Hybrid.h
index 68b06c1..2b11ae6 100644
--- a/videocodec/OMXVideoDecoderVP9Hybrid.h
+++ b/videocodec/OMXVideoDecoderVP9Hybrid.h
@@ -38,6 +38,7 @@ protected:
OMX_BUFFERHEADERTYPE ***pBuffers,
buffer_retain_t *retains,
OMX_U32 numberBuffers);
+ virtual OMX_ERRORTYPE ProcessorReset(void);
virtual OMX_ERRORTYPE ProcessorPreFillBuffer(OMX_BUFFERHEADERTYPE* buffer);
virtual bool IsAllBufferAvailable(void);
@@ -47,26 +48,35 @@ protected:
virtual OMX_ERRORTYPE BuildHandlerList(void);
- virtual OMX_ERRORTYPE FillRenderBuffer(OMX_BUFFERHEADERTYPE **pBuffer, buffer_retain_t *retain, OMX_U32 inportBufferFlags);
+ virtual OMX_ERRORTYPE FillRenderBuffer(OMX_BUFFERHEADERTYPE **pBuffer, buffer_retain_t *retain, OMX_U32 inportBufferFlags, OMX_BOOL *isResolutionChange);
virtual OMX_COLOR_FORMATTYPE GetOutputColorFormat(int width);
virtual OMX_ERRORTYPE GetDecoderOutputCropSpecific(OMX_PTR pStructure);
virtual OMX_ERRORTYPE GetNativeBufferUsageSpecific(OMX_PTR pStructure);
virtual OMX_ERRORTYPE SetNativeBufferModeSpecific(OMX_PTR pStructure);
-
+ virtual OMX_ERRORTYPE HandleFormatChange(void);
DECLARE_HANDLER(OMXVideoDecoderVP9Hybrid, ParamVideoVp9);
private:
+ bool isReallocateNeeded(const uint8_t *data, uint32_t data_sz);
void *mCtx;
void *mHybridCtx;
void *mLibHandle;
+ // These members are for Adaptive playback
+ uint32_t mDecodedImageWidth;
+ uint32_t mDecodedImageHeight;
+ uint32_t mDecodedImageNewWidth;
+ uint32_t mDecodedImageNewHeight;
typedef bool (*OpenFunc)(void ** , void **);
- typedef bool (*InitFunc)(void *,unsigned int, unsigned int, int, unsigned int *);
+ typedef bool (*InitFunc)(void *,uint32_t, uint32_t, uint32_t, uint32_t, bool, uint32_t *);
typedef bool (*CloseFunc)(void *, void *);
- typedef bool (*SingalRenderDoneFunc)(unsigned int);
- typedef bool (*DecodeFunc)(void *, void *, unsigned char *, unsigned int);
- typedef bool (*IsBufferAvailableFunc)();
- typedef int (*GetOutputFunc)(void *);
+ typedef bool (*SingalRenderDoneFunc)(void *, unsigned int);
+ typedef int (*DecodeFunc)(void *, void *, unsigned char *, unsigned int, bool);
+ typedef bool (*IsBufferAvailableFunc)(void *);
+ typedef int (*GetOutputFunc)(void*, void *, unsigned int *, unsigned int *);
+ typedef int (*GetRawDataOutputFunc)(void*, void *, unsigned char *, int, int);
+ typedef void (*DeinitFunc)(void *);
+ typedef bool (*GetFrameResolutionFunc)(const uint8_t *, uint32_t , uint32_t *, uint32_t *);
OpenFunc mOpenDecoder;
InitFunc mInitDecoder;
CloseFunc mCloseDecoder;
@@ -74,12 +84,16 @@ private:
DecodeFunc mDecoderDecode;
IsBufferAvailableFunc mCheckBufferAvailable;
GetOutputFunc mGetOutput;
+ GetRawDataOutputFunc mGetRawDataOutput;
+ GetFrameResolutionFunc mGetFrameResolution;
+ DeinitFunc mDeinitDecoder;
+ int64_t mLastTimeStamp;
enum {
// OMX_PARAM_PORTDEFINITIONTYPE
INPORT_MIN_BUFFER_COUNT = 1,
INPORT_ACTUAL_BUFFER_COUNT = 5,
INPORT_BUFFER_SIZE = 1382400,
- OUTPORT_NATIVE_BUFFER_COUNT = 12, // 8 reference + 1 current + 3 for asynchronized mode
+ OUTPORT_NATIVE_BUFFER_COUNT = 15, // 8 reference + 2 current + 4 for asynchronized mode + 1 free buffer
};
};