diff options
author | qctecmdr <qctecmdr@localhost> | 2020-08-18 13:20:39 -0700 |
---|---|---|
committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2020-08-18 13:20:39 -0700 |
commit | 3a1c43feea822faba07778d108a8ea3d775db5d2 (patch) | |
tree | 7343084381243a8fab0af89efeebc42934d0dd07 | |
parent | b44967f9bcd5d1b5577fdfd594675115ed201baa (diff) | |
parent | 578098e9eed7a6981a612b060ee85bad32195174 (diff) |
Merge "mm-core: list codecs based on actual support"
-rw-r--r-- | mm-core/src/common/qc_omx_core.c | 230 | ||||
-rw-r--r-- | mm-core/src/registry_table.c | 13 | ||||
-rw-r--r-- | mm-core/src/registry_table_android.c | 13 |
3 files changed, 147 insertions, 109 deletions
diff --git a/mm-core/src/common/qc_omx_core.c b/mm-core/src/common/qc_omx_core.c index 341a44d3..f15d24b2 100644 --- a/mm-core/src/common/qc_omx_core.c +++ b/mm-core/src/common/qc_omx_core.c @@ -44,6 +44,7 @@ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include <string.h> #include <stdio.h> #include <pthread.h> +#include <stdlib.h> #include "qc_omx_core.h" #include "omx_core_cmp.h" @@ -56,6 +57,9 @@ extern const unsigned int SIZE_OF_CORE; static pthread_mutex_t lock_core = PTHREAD_MUTEX_INITIALIZER; static int number_of_adec_nt_session; +extern omx_core_cb_type component[]; +unsigned int num_components = 0; + #define MAX_AUDIO_NT_SESSION 2 /* ====================================================================== @@ -120,8 +124,37 @@ RETURN VALUE OMX_API OMX_ERRORTYPE OMX_APIENTRY OMX_Init() { + char platform_name[PROP_VALUE_MAX] = {0}; + char version[PROP_VALUE_MAX] = {0}; + property_get("ro.board.platform", platform_name, "0"); + DEBUG_PRINT("OMXCORE API - OMX_Init \n"); - /* Nothing to do here ; shared objects shall be loaded at the get handle method */ + + // Use below method to generate list of components actually supported + // on any given platform. Core list is considered as superset and does + // not determine the actual supported codecs on a particular target. + num_components = 0; + for (int i = 0; i < SIZE_OF_CORE; i++) { + if (!strcmp(platform_name, "sm6150")) { + if (!strcmp("OMX.qti.video.decoder.vc1sw", core[i].name) || !strcmp("OMX.qcom.video.encoder.heic", core[i].name)) { + //Talos (6150) both does not support vc1 and heic hence don't add them in list + if (property_get("vendor.media.target.version", version, "0") && (atoi(version) == 0)) + continue; + } else if (!strcmp("OMX.qcom.video.encoder.tme", core[i].name) || !strcmp("OMX.qcom.video.encoder.tme.secure", core[i].name)) + continue; + } else if (!strcmp(platform_name, "atoll") || !strcmp(platform_name, "trinket")) { + //Trinket and Atoll both does not support vc1 hence don't add them in list + if (!strcmp("OMX.qti.video.decoder.vc1sw", core[i].name)) + continue; + } else if (!strcmp(platform_name, "msmnile")) { + //Hana does not support tme,tme secure hence donot add to list + if (!strcmp("OMX.qcom.video.encoder.tme", core[i].name) || !strcmp("OMX.qcom.video.encoder.tme.secure", core[i].name)) + continue; + } + + memcpy(&component[num_components++], + &core[i], sizeof(omx_core_cb_type)); + } return OMX_ErrorNone; } @@ -143,11 +176,12 @@ static int get_cmp_index(char *cmp_name) int rc = -1,i=0; DEBUG_PRINT("before get_cmp_index **********%d\n", rc); - for(i=0; i< (int)SIZE_OF_CORE; i++) + for (i = 0; i < num_components; i++) { - DEBUG_PRINT("get_cmp_index: cmp_name = %s , core[i].name = %s ,count = %d \n",cmp_name,core[i].name,i); + DEBUG_PRINT("get_cmp_index: cmp_name = %s , core[i].name = %s ,count = %d \n", + cmp_name, component[i].name, i); - if(!strcmp(cmp_name, core[i].name)) + if (!strcmp(cmp_name, component[i].name)) { rc = i; break; @@ -177,13 +211,13 @@ static void clear_cmp_handle(OMX_HANDLETYPE inst) if(NULL == inst) return; - for(i=0; i< SIZE_OF_CORE; i++) + for (i = 0; i < num_components; i++) { for(j=0; j< OMX_COMP_MAX_INST; j++) { - if(inst == core[i].inst[j]) + if (inst == component[i].inst[j]) { - core[i].inst[j] = NULL; + component[i].inst[j] = NULL; return; } } @@ -213,11 +247,11 @@ static int is_cmp_handle_exists(OMX_HANDLETYPE inst) return rc; pthread_mutex_lock(&lock_core); - for(i=0; i< SIZE_OF_CORE; i++) + for (i = 0; i < num_components; i++) { for(j=0; j< OMX_COMP_MAX_INST; j++) { - if(inst == core[i].inst[j]) + if (inst == component[i].inst[j]) { rc = i; goto finish; @@ -246,13 +280,13 @@ static int get_comp_handle_index(char *cmp_name) { unsigned i=0,j=0; int rc = -1; - for(i=0; i< SIZE_OF_CORE; i++) + for (i = 0; i < num_components; i++) { - if(!strcmp(cmp_name, core[i].name)) + if (!strcmp(cmp_name, component[i].name)) { for(j=0; j< OMX_COMP_MAX_INST; j++) { - if(NULL == core[i].inst[j]) + if (NULL == component[i].inst[j]) { rc = j; DEBUG_PRINT("free handle slot exists %d\n", rc); @@ -286,7 +320,7 @@ static int check_lib_unload(int index) for(i=0; i< OMX_COMP_MAX_INST; i++) { - if(core[index].inst[i]) + if (component[index].inst[i]) { rc = 0; DEBUG_PRINT("Library Used \n"); @@ -314,16 +348,16 @@ void* get_cmp_handle(char *cmp_name) unsigned i =0,j=0; DEBUG_PRINT("get_cmp_handle \n"); - for(i=0; i< SIZE_OF_CORE; i++) + for (i = 0; i < num_components; i++) { - if(!strcmp(cmp_name, core[i].name)) + if (!strcmp(cmp_name, component[i].name)) { for(j=0; j< OMX_COMP_MAX_INST; j++) { - if(core[i].inst[j]) + if (component[i].inst[j]) { DEBUG_PRINT("get_cmp_handle match\n"); - return core[i].inst[j]; + return component[i].inst[j]; } } } @@ -432,8 +466,8 @@ OMX_GetHandle(OMX_OUT OMX_HANDLETYPE* handle, // Load VPP omx component for decoder if vpp property is enabled const char *hwDecLib = "libOmxVdec.so"; const char *swDecLib = "libOmxSwVdec.so"; - if (!strncmp(core[cmp_index].so_lib_name, hwDecLib, strlen(hwDecLib)) || - !strncmp(core[cmp_index].so_lib_name, swDecLib, strlen(swDecLib))) { + if (!strncmp(component[cmp_index].so_lib_name, hwDecLib, strlen(hwDecLib)) || + !strncmp(component[cmp_index].so_lib_name, swDecLib, strlen(swDecLib))) { bool isVppEnabled = false; if (isConfigStoreEnabled()) { getConfigStoreBool("vpp", "enable", &isVppEnabled, false); @@ -457,19 +491,19 @@ OMX_GetHandle(OMX_OUT OMX_HANDLETYPE* handle, } // dynamically load the so - core[cmp_index].fn_ptr = - omx_core_load_cmp_library(core[cmp_index].so_lib_name, - &core[cmp_index].so_lib_handle); + component[cmp_index].fn_ptr = + omx_core_load_cmp_library(component[cmp_index].so_lib_name, + &component[cmp_index].so_lib_handle); - if(core[cmp_index].fn_ptr) + if(component[cmp_index].fn_ptr) { //Do not allow more than MAX limit for DSP audio decoders - if((!strcmp(core[cmp_index].so_lib_name,"libOmxWmaDec.so") || - !strcmp(core[cmp_index].so_lib_name,"libOmxAacDec.so") || - !strcmp(core[cmp_index].so_lib_name,"libOmxG711Dec.so") || - !strcmp(core[cmp_index].so_lib_name,"libOmxAlacDec.so") || - !strcmp(core[cmp_index].so_lib_name,"libOmxApeDec.so")) && + if((!strcmp(component[cmp_index].so_lib_name,"libOmxWmaDec.so") || + !strcmp(component[cmp_index].so_lib_name,"libOmxAacDec.so") || + !strcmp(component[cmp_index].so_lib_name,"libOmxG711Dec.so") || + !strcmp(component[cmp_index].so_lib_name,"libOmxAlacDec.so") || + !strcmp(component[cmp_index].so_lib_name,"libOmxApeDec.so")) && (number_of_adec_nt_session+1 > MAX_AUDIO_NT_SESSION)) { DEBUG_PRINT_ERROR("Rejecting new session..Reached max limit for DSP audio decoder session"); pthread_mutex_unlock(&lock_core); @@ -477,7 +511,7 @@ OMX_GetHandle(OMX_OUT OMX_HANDLETYPE* handle, } // Construct the component requested // Function returns the opaque handle - void* pThis = (*(core[cmp_index].fn_ptr))(); + void* pThis = (*(component[cmp_index].fn_ptr))(); if(pThis) { void *hComp = NULL; @@ -503,7 +537,7 @@ OMX_GetHandle(OMX_OUT OMX_HANDLETYPE* handle, if(hnd_index >= 0) { - core[cmp_index].inst[hnd_index]= *handle = (OMX_HANDLETYPE) hComp; + component[cmp_index].inst[hnd_index]= *handle = (OMX_HANDLETYPE) hComp; } else { @@ -512,11 +546,11 @@ OMX_GetHandle(OMX_OUT OMX_HANDLETYPE* handle, return OMX_ErrorInsufficientResources; } DEBUG_PRINT("Component %p Successfully created\n",*handle); - if(!strcmp(core[cmp_index].so_lib_name,"libOmxWmaDec.so") || - !strcmp(core[cmp_index].so_lib_name,"libOmxAacDec.so") || - !strcmp(core[cmp_index].so_lib_name,"libOmxG711Dec.so") || - !strcmp(core[cmp_index].so_lib_name,"libOmxAlacDec.so") || - !strcmp(core[cmp_index].so_lib_name,"libOmxApeDec.so")) { + if(!strcmp(component[cmp_index].so_lib_name,"libOmxWmaDec.so") || + !strcmp(component[cmp_index].so_lib_name,"libOmxAacDec.so") || + !strcmp(component[cmp_index].so_lib_name,"libOmxG711Dec.so") || + !strcmp(component[cmp_index].so_lib_name,"libOmxAlacDec.so") || + !strcmp(component[cmp_index].so_lib_name,"libOmxApeDec.so")) { number_of_adec_nt_session++; DEBUG_PRINT("OMX_GetHandle: number_of_adec_nt_session : %d\n", @@ -579,24 +613,24 @@ OMX_FreeHandle(OMX_IN OMX_HANDLETYPE hComp) pthread_mutex_lock(&lock_core); clear_cmp_handle(hComp); /* Unload component library */ - if( (i < (int)SIZE_OF_CORE) && core[i].so_lib_handle) + if( (i < (int)num_components) && component[i].so_lib_handle) { if(check_lib_unload(i)) { DEBUG_PRINT_ERROR(" Unloading the dynamic library for %s\n", - core[i].name); - err = dlclose(core[i].so_lib_handle); + component[i].name); + err = dlclose(component[i].so_lib_handle); if(err) { DEBUG_PRINT_ERROR("Error %d in dlclose of lib %s\n", - err,core[i].name); + err,component[i].name); } - core[i].so_lib_handle = NULL; + component[i].so_lib_handle = NULL; } - if(!strcmp(core[i].so_lib_name,"libOmxWmaDec.so") || - !strcmp(core[i].so_lib_name,"libOmxAacDec.so") || - !strcmp(core[i].so_lib_name,"libOmxAlacDec.so") || - !strcmp(core[i].so_lib_name,"libOmxApeDec.so")) { + if(!strcmp(component[i].so_lib_name,"libOmxWmaDec.so") || + !strcmp(component[i].so_lib_name,"libOmxAacDec.so") || + !strcmp(component[i].so_lib_name,"libOmxAlacDec.so") || + !strcmp(component[i].so_lib_name,"libOmxApeDec.so")) { if(number_of_adec_nt_session>0) number_of_adec_nt_session--; DEBUG_PRINT_ERROR("OMX_FreeHandle: reduced number_of_adec_nt_session %d\n", @@ -683,16 +717,17 @@ OMX_ComponentNameEnum(OMX_OUT OMX_STRING componentName, OMX_IN OMX_U32 index) { OMX_ERRORTYPE eRet = OMX_ErrorNone; - DEBUG_PRINT("OMXCORE API - OMX_ComponentNameEnum %p %d %d\n", componentName - ,(unsigned)nameLen - ,(unsigned)index); - if((index < SIZE_OF_CORE) && strncmp(core[index].name, "OMX.QCOM.CUST.COMP.START",strlen("OMX.QCOM.CUST.COMP.START"))) + if (index < num_components && + strncmp(component[index].name, "OMX.QCOM.CUST.COMP.START", + strlen("OMX.QCOM.CUST.COMP.START"))) { #ifdef _ANDROID_ - strlcpy(componentName, core[index].name,nameLen); + strlcpy(componentName, component[index].name, nameLen); #else - strncpy(componentName, core[index].name,nameLen); + strlcpy(componentName, component[index].name, nameLen); #endif + DEBUG_PRINT("OMXCORE API - OMX_ComponentNameEnum [%d] %s\n", + (unsigned)index, componentName); } else { @@ -728,25 +763,25 @@ OMX_GetComponentsOfRole(OMX_IN OMX_STRING role, /*If CompNames is NULL then return*/ if (compNames == NULL) { - if (numComps == NULL) - { - eRet = OMX_ErrorBadParameter; - } - else - { - *numComps = 0; - for (i=0; i<SIZE_OF_CORE;i++) + if (numComps == NULL) { - for(j=0; j<OMX_CORE_MAX_CMP_ROLES && core[i].roles[j] ; j++) + eRet = OMX_ErrorBadParameter; + } + else + { + *numComps = 0; + for (i = 0; i < num_components; i++) { - if(!strcmp(role,core[i].roles[j])) + for (j = 0; j < OMX_CORE_MAX_CMP_ROLES && component[i].roles[j]; j++) { - (*numComps)++; - } - } + if (!strcmp(role,component[i].roles[j])) + { + (*numComps)++; } + } } - return eRet; + } + return eRet; } if(numComps) @@ -760,17 +795,17 @@ OMX_GetComponentsOfRole(OMX_IN OMX_STRING role, *numComps = 0; - for (i=0; i<SIZE_OF_CORE;i++) + for (i = 0; i < num_components;i++) { - for(j=0; j<OMX_CORE_MAX_CMP_ROLES && core[i].roles[j] ; j++) + for (j = 0; j < OMX_CORE_MAX_CMP_ROLES && component[i].roles[j]; j++) { - if(!strcmp(role,core[i].roles[j])) - { - #ifdef _ANDROID_ - strlcpy((char *)compNames[*numComps],core[i].name, OMX_MAX_STRINGNAME_SIZE); - #else - strncpy((char *)compNames[*numComps],core[i].name, OMX_MAX_STRINGNAME_SIZE); - #endif + if (!strcmp(role,component[i].roles[j])) + { + #ifdef _ANDROID_ + strlcpy((char *)compNames[*numComps],component[i].name, OMX_MAX_STRINGNAME_SIZE); + #else + strlcpy((char *)compNames[*numComps],component[i].name, OMX_MAX_STRINGNAME_SIZE); + #endif (*numComps)++; break; } @@ -814,27 +849,26 @@ OMX_GetRolesOfComponent(OMX_IN OMX_STRING compName, if (roles == NULL) { - if (numRoles == NULL) - { - eRet = OMX_ErrorBadParameter; - } - else + if (numRoles == NULL) + { + eRet = OMX_ErrorBadParameter; + } + else + { + *numRoles = 0; + for (i = 0; i < num_components; i++) { - *numRoles = 0; - for(i=0; i< SIZE_OF_CORE; i++) - { - if(!strcmp(compName,core[i].name)) - { - for(j=0; (j<OMX_CORE_MAX_CMP_ROLES) && core[i].roles[j];j++) - { - (*numRoles)++; - } - break; - } - } - + if (!strcmp(compName,component[i].name)) + { + for (j = 0; j < OMX_CORE_MAX_CMP_ROLES && component[i].roles[j]; j++) + { + (*numRoles)++; + } + break; + } } - return eRet; + } + return eRet; } if(numRoles) @@ -846,18 +880,20 @@ OMX_GetRolesOfComponent(OMX_IN OMX_STRING compName, numofroles = *numRoles; *numRoles = 0; - for(i=0; i< SIZE_OF_CORE; i++) + for (i = 0; i < num_components; i++) { - if(!strcmp(compName,core[i].name)) + if (!strcmp(compName, component[i].name)) { - for(j=0; (j<OMX_CORE_MAX_CMP_ROLES) && core[i].roles[j];j++) + for (j = 0; j < OMX_CORE_MAX_CMP_ROLES && component[i].roles[j]; j++) { if(roles && roles[*numRoles]) { #ifdef _ANDROID_ - strlcpy((char *)roles[*numRoles],core[i].roles[j],OMX_MAX_STRINGNAME_SIZE); + strlcpy((char *)roles[*numRoles], + component[i].roles[j], OMX_MAX_STRINGNAME_SIZE); #else - strncpy((char *)roles[*numRoles],core[i].roles[j],OMX_MAX_STRINGNAME_SIZE); + strlcpy((char *)roles[*numRoles], + component[i].roles[j], OMX_MAX_STRINGNAME_SIZE); #endif } (*numRoles)++; diff --git a/mm-core/src/registry_table.c b/mm-core/src/registry_table.c index f38aac7e..e6d88ed3 100644 --- a/mm-core/src/registry_table.c +++ b/mm-core/src/registry_table.c @@ -69,24 +69,25 @@ omx_core_cb_type core[] = OMX_REGISTRY_ENTRY("OMX.qcom.audio.decoder.aac", "libOmxAacDec.so", "audio_decoder.aac"), OMX_REGISTRY_ENTRY("OMX.qcom.audio.decoder.multiaac", "libOmxAacDec.so", "audio_decoder.aac"), -#ifdef _NILE_ +//#ifdef _NILE_ //Entries specific to msmnile OMX_REGISTRY_ENTRY("OMX.qti.vdec.vpp", "libOmxVpp.so", "video_decoder.vpp"), -#endif //_NILE_ +//#endif //_NILE_ -#if defined(_STEPPE_) || defined(_ATOLL_) +//#if defined(_STEPPE_) || defined(_ATOLL_) //Entries specific to msmsteppe OMX_REGISTRY_ENTRY("OMX.qcom.video.encoder.tme", "libOmxVenc.so", "video_encoder.tme"), OMX_REGISTRY_ENTRY("OMX.qcom.video.encoder.tme.secure", "libOmxVenc.so", "video_encoder.tme"), OMX_REGISTRY_ENTRY("OMX.qti.vdec.vpp", "libOmxVpp.so", "video_decoder.vpp"), -#endif //_STEPPE_ || _ATOLL_ +//#endif //_STEPPE_ || _ATOLL_ -#if !defined(_ATOLL_) && !defined(_TRINKET_) +//#if !defined(_ATOLL_) && !defined(_TRINKET_) OMX_REGISTRY_ENTRY("OMX.qti.video.decoder.vc1sw", "libOmxSwVdec.so", "video_decoder.vc1"), OMX_REGISTRY_ENTRY("OMX.qti.video.decoder.wmvsw", "libOmxSwVdec.so", "video_decoder.vc1"), -#endif //_ATOLL_ || _TRINKET_ +//#endif //_ATOLL_ || _TRINKET_ }; const unsigned int SIZE_OF_CORE = sizeof(core) / sizeof(omx_core_cb_type); +omx_core_cb_type component[SIZE_OF_CORE]; diff --git a/mm-core/src/registry_table_android.c b/mm-core/src/registry_table_android.c index d5176bbc..ecf0d0f7 100644 --- a/mm-core/src/registry_table_android.c +++ b/mm-core/src/registry_table_android.c @@ -76,21 +76,21 @@ omx_core_cb_type core[] = OMX_REGISTRY_ENTRY("OMX.qcom.audio.encoder.evrc", "libOmxEvrcEnc.so", "audio_encoder.evrc"), OMX_REGISTRY_ENTRY("OMX.qcom.audio.encoder.amrnb", "libOmxAmrEnc.so", "audio_encoder.amrnb"), OMX_REGISTRY_ENTRY("OMX.qcom.audio.decoder.multiaac", "libOmxAacDec.so", "audio_decoder.aac"), -#ifdef _NILE_ +//#ifdef _NILE_ //Entries specific to msmnile OMX_REGISTRY_ENTRY("OMX.qti.vdec.vpp", "libOmxVpp.so", "iv_processor.yuv"), -#endif +//#endif -#if defined(_STEPPE_) || defined(_ATOLL_) +//#if defined(_STEPPE_) || defined(_ATOLL_) //Entries specific to msmsteppe OMX_REGISTRY_ENTRY("OMX.qcom.video.encoder.tme", "libOmxVenc.so", "video_encoder.tme"), OMX_REGISTRY_ENTRY("OMX.qcom.video.encoder.tme.secure", "libOmxVenc.so", "video_encoder.tme"), OMX_REGISTRY_ENTRY("OMX.qti.vdec.vpp", "libOmxVpp.so", "iv_processor.yuv"), -#endif //_STEPPE_ +//#endif //_STEPPE_ -#if !defined(_ATOLL_) && !defined(_TRINKET_) +//#if !defined(_ATOLL_) && !defined(_TRINKET_) OMX_REGISTRY_ENTRY("OMX.qti.video.decoder.vc1sw", "libOmxSwVdec.so", "video_decoder.vc1"), -#endif //_ATOLL_ || _TRINKET_ +//#endif //_ATOLL_ || _TRINKET_ OMX_REGISTRY_ENTRY("OMX.QCOM.CUST.COMP.START", NULL, NULL), OMX_REGISTRY_ENTRY("OMX.qcom.file.muxer", "libOmxMux.so", "container_muxer.mp2"), @@ -99,3 +99,4 @@ omx_core_cb_type core[] = OMX_REGISTRY_ENTRY("OMX.qcom.video.decoder.avc.dsmode", "libOmxVideoDSMode.so", "video_decoder.avc"), }; const unsigned int SIZE_OF_CORE = sizeof(core) / sizeof(omx_core_cb_type); +omx_core_cb_type component[SIZE_OF_CORE];
\ No newline at end of file |