diff options
author | Ronghua Wu <ronghuawu@google.com> | 2015-06-01 21:23:20 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-06-01 21:23:21 +0000 |
commit | 14b1d41f778fe86cacdb91a929f658cecae83d49 (patch) | |
tree | fc51f08b98224031083aad783fe5ddf4faebf1c4 | |
parent | 315fcbb35ef1f355db2f761408c0a22e47ca8222 (diff) | |
parent | f832fbe64172f3dcde2bf8d7f960375efd8a30d9 (diff) | |
download | android_hardware_intel_common_omx-components-14b1d41f778fe86cacdb91a929f658cecae83d49.tar.gz android_hardware_intel_common_omx-components-14b1d41f778fe86cacdb91a929f658cecae83d49.tar.bz2 android_hardware_intel_common_omx-components-14b1d41f778fe86cacdb91a929f658cecae83d49.zip |
Merge "omx-component: Adding media resource management support for each codec." into mnc-dev
-rw-r--r-- | videocodec/OMXVideoDecoderAVC.cpp | 26 | ||||
-rw-r--r-- | videocodec/OMXVideoDecoderVP8.cpp | 27 | ||||
-rw-r--r-- | videocodec/OMXVideoDecoderVP9Hybrid.cpp | 27 | ||||
-rw-r--r-- | videocodec/OMXVideoEncoderAVC.cpp | 28 | ||||
-rw-r--r-- | videocodec/OMXVideoEncoderVP8.cpp | 28 |
5 files changed, 131 insertions, 5 deletions
diff --git a/videocodec/OMXVideoDecoderAVC.cpp b/videocodec/OMXVideoDecoderAVC.cpp index 87b74a4..df3b4d2 100644 --- a/videocodec/OMXVideoDecoderAVC.cpp +++ b/videocodec/OMXVideoDecoderAVC.cpp @@ -25,6 +25,9 @@ static const char* AVC_MIME_TYPE = "video/h264"; #define INVALID_PTS (OMX_S64)-1 +// codec number limitation +#define INSTANCE_LIMITATION 4 +static int gInstanceNumber = 0; OMXVideoDecoderAVC::OMXVideoDecoderAVC() : mAccumulateBuffer(NULL), @@ -42,6 +45,7 @@ OMXVideoDecoderAVC::OMXVideoDecoderAVC() } OMXVideoDecoderAVC::~OMXVideoDecoderAVC() { + gInstanceNumber --; LOGV("OMXVideoDecoderAVC is destructed."); } @@ -329,4 +333,24 @@ OMX_ERRORTYPE OMXVideoDecoderAVC::SetMaxOutputBufferCount(OMX_PARAM_PORTDEFINITI return OMXVideoDecoderBase::SetMaxOutputBufferCount(p); } -DECLARE_OMX_COMPONENT("OMX.Intel.VideoDecoder.AVC", "video_decoder.avc", OMXVideoDecoderAVC); +#define DECLARE_OMX_COMPONENT_AVC(NAME, ROLE, CLASS) \ + static const char *gName = (const char *)(NAME);\ + static const char *gRole = (const char *)(ROLE);\ + OMX_ERRORTYPE CreateInstance(OMX_PTR *instance) {\ + *instance = NULL;\ + if (gInstanceNumber + 1 > INSTANCE_LIMITATION) {\ + return OMX_ErrorInsufficientResources;\ + } else {\ + gInstanceNumber ++;\ + }\ + ComponentBase *inst = new CLASS;\ + if (!inst) {\ + return OMX_ErrorInsufficientResources;\ + }\ + *instance = inst;\ + return OMX_ErrorNone;\ + }\ + struct wrs_omxil_cmodule_ops_s gOps = {CreateInstance};\ + struct wrs_omxil_cmodule_s WRS_OMXIL_CMODULE_SYMBOL = {gName, &gRole, 1, &gOps}; + +DECLARE_OMX_COMPONENT_AVC("OMX.Intel.VideoDecoder.AVC", "video_decoder.avc", OMXVideoDecoderAVC); diff --git a/videocodec/OMXVideoDecoderVP8.cpp b/videocodec/OMXVideoDecoderVP8.cpp index 013bf8b..1dad3ae 100644 --- a/videocodec/OMXVideoDecoderVP8.cpp +++ b/videocodec/OMXVideoDecoderVP8.cpp @@ -22,6 +22,10 @@ // Be sure to have an equal string in VideoDecoderHost.cpp (libmix) static const char* VP8_MIME_TYPE = "video/x-vnd.on2.vp8"; +// codec number limitation +#define INSTANCE_LIMITATION 4 +static int gInstanceNumber = 0; + OMXVideoDecoderVP8::OMXVideoDecoderVP8() { LOGV("OMXVideoDecoderVP8 is constructed."); mVideoDecoder = createVideoDecoder(VP8_MIME_TYPE); @@ -34,6 +38,7 @@ OMXVideoDecoderVP8::OMXVideoDecoderVP8() { } OMXVideoDecoderVP8::~OMXVideoDecoderVP8() { + gInstanceNumber --; LOGV("OMXVideoDecoderVP8 is destructed."); } @@ -128,6 +133,26 @@ OMX_ERRORTYPE OMXVideoDecoderVP8::SetMaxOutputBufferCount(OMX_PARAM_PORTDEFINITI p->nBufferCountActual = OUTPORT_NATIVE_BUFFER_COUNT; return OMXVideoDecoderBase::SetMaxOutputBufferCount(p); } -DECLARE_OMX_COMPONENT("OMX.Intel.VideoDecoder.VP8", "video_decoder.vp8", OMXVideoDecoderVP8); +#define DECLARE_OMX_COMPONENT_VP8(NAME, ROLE, CLASS) \ + static const char *gName = (const char *)(NAME);\ + static const char *gRole = (const char *)(ROLE);\ + OMX_ERRORTYPE CreateInstance(OMX_PTR *instance) {\ + *instance = NULL;\ + if (gInstanceNumber + 1 > INSTANCE_LIMITATION) {\ + return OMX_ErrorInsufficientResources;\ + } else {\ + gInstanceNumber ++;\ + }\ + ComponentBase *inst = new CLASS;\ + if (!inst) {\ + return OMX_ErrorInsufficientResources;\ + }\ + *instance = inst;\ + return OMX_ErrorNone;\ + }\ + struct wrs_omxil_cmodule_ops_s gOps = {CreateInstance};\ + struct wrs_omxil_cmodule_s WRS_OMXIL_CMODULE_SYMBOL = {gName, &gRole, 1, &gOps}; + +DECLARE_OMX_COMPONENT_VP8("OMX.Intel.VideoDecoder.VP8", "video_decoder.vp8", OMXVideoDecoderVP8); diff --git a/videocodec/OMXVideoDecoderVP9Hybrid.cpp b/videocodec/OMXVideoDecoderVP9Hybrid.cpp index 55d481a..db400ca 100644 --- a/videocodec/OMXVideoDecoderVP9Hybrid.cpp +++ b/videocodec/OMXVideoDecoderVP9Hybrid.cpp @@ -25,6 +25,10 @@ #include <hardware/gralloc.h> #include <system/graphics.h> +// codec number limitation +#define INSTANCE_LIMITATION 4 +static int gInstanceNumber = 0; + static const char* VP9_MIME_TYPE = "video/x-vnd.on2.vp9"; OMXVideoDecoderVP9Hybrid::OMXVideoDecoderVP9Hybrid() { @@ -51,6 +55,7 @@ OMXVideoDecoderVP9Hybrid::OMXVideoDecoderVP9Hybrid() { } OMXVideoDecoderVP9Hybrid::~OMXVideoDecoderVP9Hybrid() { + gInstanceNumber --; LOGV("OMXVideoDecoderVP9Hybrid is destructed."); } @@ -566,4 +571,24 @@ bool OMXVideoDecoderVP9Hybrid::IsAllBufferAvailable(void) { return mCheckBufferAvailable(mHybridCtx); } -DECLARE_OMX_COMPONENT("OMX.Intel.VideoDecoder.VP9.hybrid", "video_decoder.vp9", OMXVideoDecoderVP9Hybrid); +#define DECLARE_OMX_COMPONENT_VP9(NAME, ROLE, CLASS) \ + static const char *gName = (const char *)(NAME);\ + static const char *gRole = (const char *)(ROLE);\ + OMX_ERRORTYPE CreateInstance(OMX_PTR *instance) {\ + *instance = NULL;\ + if (gInstanceNumber + 1 > INSTANCE_LIMITATION) {\ + return OMX_ErrorInsufficientResources;\ + } else {\ + gInstanceNumber ++;\ + }\ + ComponentBase *inst = new CLASS;\ + if (!inst) {\ + return OMX_ErrorInsufficientResources;\ + }\ + *instance = inst;\ + return OMX_ErrorNone;\ + }\ + struct wrs_omxil_cmodule_ops_s gOps = {CreateInstance};\ + struct wrs_omxil_cmodule_s WRS_OMXIL_CMODULE_SYMBOL = {gName, &gRole, 1, &gOps}; + +DECLARE_OMX_COMPONENT_VP9("OMX.Intel.VideoDecoder.VP9.hybrid", "video_decoder.vp9", OMXVideoDecoderVP9Hybrid); diff --git a/videocodec/OMXVideoEncoderAVC.cpp b/videocodec/OMXVideoEncoderAVC.cpp index 36390e2..220ca26 100644 --- a/videocodec/OMXVideoEncoderAVC.cpp +++ b/videocodec/OMXVideoEncoderAVC.cpp @@ -20,6 +20,10 @@ static const char *AVC_MIME_TYPE = "video/h264"; +// AVC encoder instance limitation +#define INSTANCE_LIMITATION 3 +static int gInstanceNumber = 0; + struct ProfileMap { OMX_VIDEO_AVCPROFILETYPE key; VAProfile value; @@ -119,6 +123,7 @@ OMXVideoEncoderAVC::~OMXVideoEncoderAVC() { delete mAVCParams; mAVCParams = NULL; } + gInstanceNumber --; } OMX_ERRORTYPE OMXVideoEncoderAVC::InitOutputPortFormatSpecific(OMX_PARAM_PORTDEFINITIONTYPE *paramPortDefinitionOutput) { @@ -1060,4 +1065,25 @@ OMX_ERRORTYPE OMXVideoEncoderAVC::SetParamVideoBytestream(OMX_PTR pStructure) { } -DECLARE_OMX_COMPONENT("OMX.Intel.VideoEncoder.AVC", "video_encoder.avc", OMXVideoEncoderAVC); +#define DECLARE_OMX_COMPONENT_AVC(NAME, ROLE, CLASS) \ + static const char *gName = (const char *)(NAME);\ + static const char *gRole = (const char *)(ROLE);\ + OMX_ERRORTYPE CreateInstance(OMX_PTR *instance) {\ + *instance = NULL;\ + if (gInstanceNumber + 1 > INSTANCE_LIMITATION) {\ + return OMX_ErrorInsufficientResources;\ + } else {\ + gInstanceNumber ++;\ + }\ + ComponentBase *inst = new CLASS;\ + if (!inst) {\ + return OMX_ErrorInsufficientResources;\ + }\ + *instance = inst;\ + return OMX_ErrorNone;\ + }\ + struct wrs_omxil_cmodule_ops_s gOps = {CreateInstance};\ + struct wrs_omxil_cmodule_s WRS_OMXIL_CMODULE_SYMBOL = {gName, &gRole, 1, &gOps}; + + +DECLARE_OMX_COMPONENT_AVC("OMX.Intel.VideoEncoder.AVC", "video_encoder.avc", OMXVideoEncoderAVC); diff --git a/videocodec/OMXVideoEncoderVP8.cpp b/videocodec/OMXVideoEncoderVP8.cpp index ec1062d..c78a0ad 100644 --- a/videocodec/OMXVideoEncoderVP8.cpp +++ b/videocodec/OMXVideoEncoderVP8.cpp @@ -4,6 +4,10 @@ static const char *VP8_MIME_TYPE = "video/x-vnd.on2.vp8"; +// VP8 encoder instance limitation +#define INSTANCE_LIMITATION 3 +static int gInstanceNumber = 0; + OMXVideoEncoderVP8::OMXVideoEncoderVP8() { LOGV("OMXVideoEncoderVP8 is constructed."); mLastTimestamp = 0x7FFFFFFFFFFFFFFFLL; @@ -14,6 +18,7 @@ OMXVideoEncoderVP8::OMXVideoEncoderVP8() { OMXVideoEncoderVP8::~OMXVideoEncoderVP8() { LOGV("OMXVideoEncoderVP8 is destructed."); + gInstanceNumber --; } OMX_ERRORTYPE OMXVideoEncoderVP8::InitOutputPortFormatSpecific(OMX_PARAM_PORTDEFINITIONTYPE *paramPortDefinitionOutput) { @@ -321,4 +326,25 @@ OMX_ERRORTYPE OMXVideoEncoderVP8::SetConfigVp8MaxFrameSizeRatio(OMX_PTR pStructu return OMX_ErrorNone; } -DECLARE_OMX_COMPONENT("OMX.Intel.VideoEncoder.VP8", "video_encoder.vp8", OMXVideoEncoderVP8); +#define DECLARE_OMX_COMPONENT_VP8(NAME, ROLE, CLASS) \ + static const char *gName = (const char *)(NAME);\ + static const char *gRole = (const char *)(ROLE);\ + OMX_ERRORTYPE CreateInstance(OMX_PTR *instance) {\ + *instance = NULL;\ + if (gInstanceNumber + 1 > INSTANCE_LIMITATION) {\ + return OMX_ErrorInsufficientResources;\ + } else {\ + gInstanceNumber ++;\ + }\ + ComponentBase *inst = new CLASS;\ + if (!inst) {\ + return OMX_ErrorInsufficientResources;\ + }\ + *instance = inst;\ + return OMX_ErrorNone;\ + }\ + struct wrs_omxil_cmodule_ops_s gOps = {CreateInstance};\ + struct wrs_omxil_cmodule_s WRS_OMXIL_CMODULE_SYMBOL = {gName, &gRole, 1, &gOps}; + + +DECLARE_OMX_COMPONENT_VP8("OMX.Intel.VideoEncoder.VP8", "video_encoder.vp8", OMXVideoEncoderVP8); |