Преглед на файлове

omx-il: upgrade omx vpu dec/enc component to adapt to OMX-IL CTS Base Profile Conformance Tests

Signed-off-by: Som Qin <som.qin@starfivetech.com>
Som Qin преди 1 година
родител
ревизия
fec580f76e

+ 2 - 0
omx-il/Makefile

@@ -47,6 +47,8 @@ SOURCES_COMMON = SF_OMX_Core.c SF_OMX_video_common.c
 SOURCES_COMMON += SF_OMX_Vdec_decoder.c
 SOURCES_COMMON += SF_OMX_Wave420L_encoder.c
 SOURCES_COMMON += sf_queue.c
+SOURCES_COMMON += sf_thread.c
+SOURCES_COMMON += sf_semaphore.c
 #mjpeg
 SOURCES_COMMON += SF_OMX_mjpeg_common.c SF_OMX_Mjpeg_decoder.c
 #test

+ 103 - 0
omx-il/component/helper/sf_semaphore.c

@@ -0,0 +1,103 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2022 StarFive Technology Co., Ltd.
+ */
+#include "sf_semaphore.h"
+#include "SF_OMX_Core.h"
+
+OMX_ERRORTYPE SF_SemaphoreCreate(OMX_HANDLETYPE *semaphoreHandle)
+{
+    sem_t *sema;
+
+    sema = (sem_t *)malloc(sizeof(sem_t));
+    if (!sema)
+        return OMX_ErrorInsufficientResources;
+
+    if (sem_init(sema, 0, 0) != 0) {
+        free(sema);
+        return OMX_ErrorUndefined;
+    }
+
+    *semaphoreHandle = (OMX_HANDLETYPE)sema;
+
+    LOG(SF_LOG_INFO,"SF_SemaphoreCreate %p\r\n", sema);
+    return OMX_ErrorNone;
+}
+
+OMX_ERRORTYPE SF_SemaphoreTerminate(OMX_HANDLETYPE semaphoreHandle)
+{
+    sem_t *sema = (sem_t *)semaphoreHandle;
+
+    if (sema == NULL)
+        return OMX_ErrorBadParameter;
+
+    if (sem_destroy(sema) != 0)
+        return OMX_ErrorUndefined;
+
+    free(sema);
+    return OMX_ErrorNone;
+}
+
+OMX_ERRORTYPE SF_SemaphoreWait(OMX_HANDLETYPE semaphoreHandle)
+{
+    LOG(SF_LOG_INFO,"SF_SemaphoreWait %p\r\n", semaphoreHandle);
+    sem_t *sema = (sem_t *)semaphoreHandle;
+
+    FunctionIn();
+
+    if (sema == NULL)
+        return OMX_ErrorBadParameter;
+
+    if (sem_wait(sema) != 0)
+        return OMX_ErrorUndefined;
+
+    FunctionOut();
+
+    return OMX_ErrorNone;
+}
+
+OMX_ERRORTYPE SF_SemaphorePost(OMX_HANDLETYPE semaphoreHandle)
+{
+    sem_t *sema = (sem_t *)semaphoreHandle;
+
+    FunctionIn();
+
+    if (sema == NULL)
+        return OMX_ErrorBadParameter;
+
+    if (sem_post(sema) != 0)
+        return OMX_ErrorUndefined;
+
+    FunctionOut();
+
+    return OMX_ErrorNone;
+}
+
+OMX_ERRORTYPE SF_Set_SemaphoreCount(OMX_HANDLETYPE semaphoreHandle, OMX_S32 val)
+{
+    sem_t *sema = (sem_t *)semaphoreHandle;
+
+    if (sema == NULL)
+        return OMX_ErrorBadParameter;
+
+    if (sem_init(sema, 0, val) != 0)
+        return OMX_ErrorUndefined;
+
+    return OMX_ErrorNone;
+}
+
+OMX_ERRORTYPE SF_Get_SemaphoreCount(OMX_HANDLETYPE semaphoreHandle, OMX_S32 *val)
+{
+    sem_t *sema = (sem_t *)semaphoreHandle;
+    int semaVal = 0;
+
+    if (sema == NULL)
+        return OMX_ErrorBadParameter;
+
+    if (sem_getvalue(sema, &semaVal) != 0)
+        return OMX_ErrorUndefined;
+
+    *val = (OMX_S32)semaVal;
+
+    return OMX_ErrorNone;
+}

+ 23 - 0
omx-il/component/helper/sf_semaphore.h

@@ -0,0 +1,23 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2022 StarFive Technology Co., Ltd.
+ */
+#ifndef SF_SEMAPHORE_H
+#define SF_SEMAPHORE_H
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <pthread.h>
+#include <semaphore.h>
+#include "OMX_Types.h"
+#include "OMX_Core.h"
+
+OMX_ERRORTYPE SF_SemaphoreCreate(OMX_HANDLETYPE *semaphoreHandle);
+OMX_ERRORTYPE SF_SemaphoreTerminate(OMX_HANDLETYPE semaphoreHandle);
+OMX_ERRORTYPE SF_SemaphoreWait(OMX_HANDLETYPE semaphoreHandle);
+OMX_ERRORTYPE SF_SemaphorePost(OMX_HANDLETYPE semaphoreHandle);
+OMX_ERRORTYPE SF_Set_SemaphoreCount(OMX_HANDLETYPE semaphoreHandle, OMX_S32 val);
+OMX_ERRORTYPE SF_Get_SemaphoreCount(OMX_HANDLETYPE semaphoreHandle, OMX_S32 *val);
+
+#endif //SF_SEMAPHORE_H

+ 68 - 0
omx-il/component/helper/sf_thread.c

@@ -0,0 +1,68 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2022 StarFive Technology Co., Ltd.
+ */
+#include "sf_thread.h"
+#include "SF_OMX_Core.h"
+
+OMX_ERRORTYPE CreateThread(THREAD_HANDLE_TYPE **threadHandle, OMX_PTR function_name, OMX_PTR argument)
+{
+    FunctionIn();
+
+    int result = 0;
+    int detach_ret = 0;
+    THREAD_HANDLE_TYPE *thread;
+    OMX_ERRORTYPE ret = OMX_ErrorNone;
+
+    thread = malloc(sizeof(THREAD_HANDLE_TYPE));
+    memset(thread, 0, sizeof(THREAD_HANDLE_TYPE));
+
+    pthread_attr_init(&thread->attr);
+    if (thread->stack_size != 0)
+        pthread_attr_setstacksize(&thread->attr, thread->stack_size);
+
+    /* set priority */
+    if (thread->schedparam.sched_priority != 0)
+        pthread_attr_setschedparam(&thread->attr, &thread->schedparam);
+
+    detach_ret = pthread_attr_setdetachstate(&thread->attr, PTHREAD_CREATE_JOINABLE);
+    if (detach_ret != 0)
+    {
+        free(thread);
+        *threadHandle = NULL;
+        ret = OMX_ErrorUndefined;
+        goto EXIT;
+    }
+
+    result = pthread_create(&thread->pthread, &thread->attr, function_name, (void *)argument);
+    /* pthread_setschedparam(thread->pthread, SCHED_RR, &thread->schedparam); */
+
+    switch (result)
+    {
+    case 0:
+        *threadHandle = thread;
+        ret = OMX_ErrorNone;
+        break;
+    case EAGAIN:
+        free(thread);
+        *threadHandle = NULL;
+        ret = OMX_ErrorInsufficientResources;
+        break;
+    default:
+        free(thread);
+        *threadHandle = NULL;
+        ret = OMX_ErrorUndefined;
+        break;
+    }
+
+EXIT:
+    FunctionOut();
+
+    return ret;
+}
+
+void ThreadExit(void *value_ptr)
+{
+    pthread_exit(value_ptr);
+    return;
+}

+ 28 - 0
omx-il/component/helper/sf_thread.h

@@ -0,0 +1,28 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2022 StarFive Technology Co., Ltd.
+ */
+#ifndef SF_THREAD_H
+#define SF_THREAD_H
+
+#include <stdint.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <time.h>
+#include <pthread.h>
+#include "OMX_Types.h"
+#include "OMX_Core.h"
+
+typedef struct _THREAD_HANDLE_TYPE
+{
+    pthread_t          pthread;
+    pthread_attr_t     attr;
+    struct sched_param schedparam;
+    int                stack_size;
+} THREAD_HANDLE_TYPE;
+
+
+OMX_ERRORTYPE CreateThread(THREAD_HANDLE_TYPE **threadHandle, OMX_PTR function_name, OMX_PTR argument);
+void ThreadExit(void *value_ptr);
+
+#endif //SF_THREAD_H

+ 1 - 63
omx-il/component/image/common/SF_OMX_mjpeg_common.c

@@ -82,7 +82,7 @@ OMX_ERRORTYPE InitMjpegStructorCommon(SF_OMX_COMPONENT *pSfOMXComponent)
         }
     }
 
-    if (strstr(pSfOMXComponent->componentName, "sf.dec") != NULL)
+    if (strstr(pSfOMXComponent->componentName, "OMX.sf.video_decoder") != NULL)
     {
         pSfCodaj12Implement->config = malloc(sizeof(DecConfigParam));
         if (pSfCodaj12Implement->config == NULL)
@@ -523,68 +523,6 @@ OMX_U8 *AllocateOutputBuffer(SF_OMX_COMPONENT *pSfOMXComponent, OMX_U32 nSizeByt
     return virtAddr;
 }
 
-OMX_ERRORTYPE CreateThread(OMX_HANDLETYPE *threadHandle, OMX_PTR function_name, OMX_PTR argument)
-{
-    FunctionIn();
-
-    int result = 0;
-    int detach_ret = 0;
-    THREAD_HANDLE_TYPE *thread;
-    OMX_ERRORTYPE ret = OMX_ErrorNone;
-
-    thread = malloc(sizeof(THREAD_HANDLE_TYPE));
-    memset(thread, 0, sizeof(THREAD_HANDLE_TYPE));
-
-    pthread_attr_init(&thread->attr);
-    if (thread->stack_size != 0)
-        pthread_attr_setstacksize(&thread->attr, thread->stack_size);
-
-    /* set priority */
-    if (thread->schedparam.sched_priority != 0)
-        pthread_attr_setschedparam(&thread->attr, &thread->schedparam);
-
-    detach_ret = pthread_attr_setdetachstate(&thread->attr, PTHREAD_CREATE_JOINABLE);
-    if (detach_ret != 0)
-    {
-        free(thread);
-        *threadHandle = NULL;
-        ret = OMX_ErrorUndefined;
-        goto EXIT;
-    }
-
-    result = pthread_create(&thread->pthread, &thread->attr, function_name, (void *)argument);
-    /* pthread_setschedparam(thread->pthread, SCHED_RR, &thread->schedparam); */
-
-    switch (result)
-    {
-    case 0:
-        *threadHandle = (OMX_HANDLETYPE)thread;
-        ret = OMX_ErrorNone;
-        break;
-    case EAGAIN:
-        free(thread);
-        *threadHandle = NULL;
-        ret = OMX_ErrorInsufficientResources;
-        break;
-    default:
-        free(thread);
-        *threadHandle = NULL;
-        ret = OMX_ErrorUndefined;
-        break;
-    }
-
-EXIT:
-    FunctionOut();
-
-    return ret;
-}
-
-void ThreadExit(void *value_ptr)
-{
-    pthread_exit(value_ptr);
-    return;
-}
-
 void CodaJ12FlushBuffer(SF_OMX_COMPONENT *pSfOMXComponent, OMX_U32 nPortNumber)
 {
     SF_CODAJ12_IMPLEMEMT *pSfCodaj12Implement = pSfOMXComponent->componentImpl;

+ 2 - 9
omx-il/component/image/common/SF_OMX_mjpeg_common.h

@@ -10,6 +10,7 @@
 #include "OMX_Index.h"
 #include "OMX_IndexExt.h"
 #include "SF_OMX_Core.h"
+#include "sf_thread.h"
 #include "codaj12/jpuapi/jpuapi.h"
 #include "codaj12/jpuapi/jpuapifunc.h"
 #include "codaj12/sample/main_helper.h"
@@ -86,13 +87,6 @@ typedef struct _SF_CODAJ12_FUNCTIONS
     void (*SetMaxLogLevel)(int level);
 } SF_CODAJ12_FUNCTIONS;
 
-typedef struct _THREAD_HANDLE_TYPE {
-    pthread_t          pthread;
-    pthread_attr_t     attr;
-    struct sched_param schedparam;
-    int                stack_size;
-} THREAD_HANDLE_TYPE;
-
 typedef struct Message
 {
     long msg_type;
@@ -116,7 +110,7 @@ typedef struct _SF_CODAJ12_IMPLEMEMT
     OMX_S32 sOutputMessageQueue;
     OMX_S32 sBufferDoneQueue;
     Message mesCacheArr[MCA_MAX_INDEX];
-    OMX_HANDLETYPE pProcessThread;
+    THREAD_HANDLE_TYPE *pProcessThread;
     OMX_BOOL bThreadRunning;
     OMX_STATETYPE currentState;
     FrameFormat frameFormat;
@@ -139,7 +133,6 @@ OMX_ERRORTYPE GetStateMjpegCommon(OMX_IN OMX_HANDLETYPE hComponent, OMX_OUT OMX_
 OMX_ERRORTYPE InitMjpegStructorCommon(SF_OMX_COMPONENT *hComponent);
 OMX_BOOL AttachOutputBuffer(SF_OMX_COMPONENT *pSfOMXComponent, OMX_U8* pBuffer, OMX_U32 nSizeBytes);
 OMX_U8* AllocateOutputBuffer(SF_OMX_COMPONENT *pSfOMXComponent, OMX_U32 nSizeBytes);
-OMX_ERRORTYPE CreateThread(OMX_HANDLETYPE *threadHandle, OMX_PTR function_name, OMX_PTR argument);
 void ThreadExit(void *value_ptr);
 void CodaJ12FlushBuffer(SF_OMX_COMPONENT *pSfOMXComponent, OMX_U32 nPortNumber);
 

+ 5 - 3
omx-il/component/image/dec/SF_OMX_Mjpeg_decoder.c

@@ -353,7 +353,7 @@ static OMX_ERRORTYPE SF_OMX_GetParameter(
     }
     default:
     {
-        ret = OMX_ErrorNotImplemented;
+        ret = OMX_ErrorUnsupportedIndex;
         break;
     }
     }
@@ -617,6 +617,7 @@ static OMX_ERRORTYPE SF_OMX_SetParameter(
             pPort->format.video.eColorFormat = portFormat->eColorFormat;
         break;
     }
+    case OMX_IndexParamImageInit:
     case OMX_IndexParamVideoInit:
     {
         OMX_PORT_PARAM_TYPE *portParam = (OMX_PORT_PARAM_TYPE *)ComponentParameterStructure;
@@ -629,6 +630,7 @@ static OMX_ERRORTYPE SF_OMX_SetParameter(
         break;
 
     default:
+        ret = OMX_ErrorUnsupportedIndex;
         break;
     }
 
@@ -1411,7 +1413,7 @@ static OMX_ERRORTYPE SF_OMX_SendCommand(
     switch (Cmd)
     {
     case OMX_CommandStateSet:
-        pSfOMXComponent->nextState = nParam;
+        pSfOMXComponent->state = nParam;
         LOG(SF_LOG_INFO, "OMX dest state = %X, current state = %X\r\n", nParam, pSfCodaj12Implement->currentState);
         switch (nParam)
         {
@@ -1593,7 +1595,7 @@ static OMX_ERRORTYPE SF_OMX_ComponentClear(SF_OMX_COMPONENT *pSfOMXComponent)
 
 //TODO happer
 SF_OMX_COMPONENT sf_dec_decoder_mjpeg = {
-    .componentName = "sf.dec.decoder.mjpeg",
+    .componentName = "OMX.sf.video_decoder.mjpeg",
     .libName = "libcodadec.so",
     .pOMXComponent = NULL,
     .SF_OMX_ComponentConstructor = SF_OMX_ComponentConstructor,

Файловите разлики са ограничени, защото са твърде много
+ 582 - 143
omx-il/component/video/wave4/SF_OMX_Wave420L_encoder.c


+ 9 - 9
omx-il/component/video/wave4/SF_OMX_Wave420L_encoder.h

@@ -18,6 +18,8 @@
 #include <errno.h>
 
 #include "sf_queue.h"
+#include "sf_thread.h"
+#include "sf_semaphore.h"
 #include "wave420l/sample/helper/main_helper.h"
 #include "wave420l/vpuapi/vpuapi.h"
 
@@ -35,8 +37,8 @@
 
 #define NUM_OF_PORTS 2
 
-#define DEFAULT_FRAME_WIDTH 3840
-#define DEFAULT_FRAME_HEIGHT 2160
+#define DEFAULT_FRAME_WIDTH 1920
+#define DEFAULT_FRAME_HEIGHT 1080
 #define DEFAULT_MJPEG_INPUT_BUFFER_SIZE (DEFAULT_FRAME_WIDTH * DEFAULT_FRAME_HEIGHT * 3)
 #define DEFAULT_MJPEG_OUTPUT_BUFFER_SIZE (DEFAULT_FRAME_WIDTH * DEFAULT_FRAME_HEIGHT * 3)
 #define DEFAULT_FRAMERATE 30
@@ -93,13 +95,6 @@ typedef struct _SF_W420L_FUNCTIONS
     void (*PrintVpuStatus)(Uint32 coreIdx, Uint32 productId);
 }SF_W420L_FUNCTIONS;
 
-typedef struct _THREAD_HANDLE_TYPE
-{
-    pthread_t          pthread;
-    pthread_attr_t     attr;
-    struct sched_param schedparam;
-    int                stack_size;
-} THREAD_HANDLE_TYPE;
 
 typedef struct Message
 {
@@ -140,15 +135,20 @@ typedef struct _SF_WAVE420L_IMPLEMEMT
     EncOutputInfo       outputInfo;
     Int32               instIdx;
     Int32               coreIdx;
+    Uint32              tmpFramerate;
+    Uint64              tmpCounter;
     SF_Queue            *EmptyQueue;
     SF_Queue            *FillQueue;
     SF_Queue            *CmdQueue;
+    SF_Queue            *pauseQ;
+    OMX_HANDLETYPE      pauseSemaphore;
     OMX_VIDEO_PARAM_HEVCTYPE HEVCComponent[2];
 
     THREAD_HANDLE_TYPE *pProcessThread;
     THREAD_HANDLE_TYPE *pCmdThread;
     OMX_BOOL bThreadRunning;
     OMX_BOOL bCmdRunning;
+    OMX_BOOL bPause;
     OMX_STATETYPE currentState;
 } SF_WAVE420L_IMPLEMEMT;
 

+ 77 - 34
omx-il/component/video/wave5/common/SF_OMX_video_common.c

@@ -13,7 +13,7 @@ OMX_ERRORTYPE GetStateCommon(OMX_IN OMX_HANDLETYPE hComponent, OMX_OUT OMX_STATE
     OMX_COMPONENTTYPE *pOMXComponent = NULL;
     SF_OMX_COMPONENT *pSfOMXComponent = NULL;
     ComponentState state;
-    OMX_STATETYPE nextState;
+    OMX_STATETYPE comState;
     SF_WAVE5_IMPLEMEMT *pSfVideoImplement = NULL;
     FunctionIn();
     if (hComponent == NULL)
@@ -24,14 +24,19 @@ OMX_ERRORTYPE GetStateCommon(OMX_IN OMX_HANDLETYPE hComponent, OMX_OUT OMX_STATE
     pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
     pSfOMXComponent = pOMXComponent->pComponentPrivate;
     pSfVideoImplement = (SF_WAVE5_IMPLEMEMT *)pSfOMXComponent->componentImpl;
-    nextState = pSfOMXComponent->nextState;
+    comState = pSfOMXComponent->state;
     state = pSfVideoImplement->functions->ComponentGetState(pSfVideoImplement->hSFComponentExecoder);
     LOG(SF_LOG_INFO, "state = %d\r\n", state);
 
     switch (state)
     {
     case COMPONENT_STATE_CREATED:
-        *pState = OMX_StateIdle;
+        if (comState == OMX_StateLoaded)
+        {
+            *pState = OMX_StateLoaded;
+        }else{
+            *pState = OMX_StateIdle;
+        }
         break;
     case COMPONENT_STATE_NONE:
     case COMPONENT_STATE_TERMINATED:
@@ -39,9 +44,9 @@ OMX_ERRORTYPE GetStateCommon(OMX_IN OMX_HANDLETYPE hComponent, OMX_OUT OMX_STATE
         break;
     case COMPONENT_STATE_PREPARED:
     case COMPONENT_STATE_EXECUTED:
-        if (nextState == OMX_StateIdle || nextState == OMX_StateExecuting || nextState == OMX_StatePause)
+        if (comState == OMX_StateIdle || comState == OMX_StateExecuting || comState == OMX_StatePause)
         {
-            *pState = nextState;
+            *pState = comState;
         }
         break;
     default:
@@ -194,7 +199,7 @@ OMX_ERRORTYPE InitComponentStructorCommon(SF_OMX_COMPONENT *pSfOMXComponent)
         }
     }
 
-    if (strstr(pSfOMXComponent->componentName, "sf.enc") != NULL)
+    if (strstr(pSfOMXComponent->componentName, "sf.video_encoder") != NULL)
     {
         pSfVideoImplement->testConfig = malloc(sizeof(TestEncConfig));
         if (pSfVideoImplement->testConfig == NULL)
@@ -214,7 +219,7 @@ OMX_ERRORTYPE InitComponentStructorCommon(SF_OMX_COMPONENT *pSfOMXComponent)
         memset(pSfVideoImplement->lsnCtx, 0, sizeof(EncListenerContext));
         pSfVideoImplement->functions->SetDefaultEncTestConfig(pSfVideoImplement->testConfig);
     }
-    else if (strstr(pSfOMXComponent->componentName, "sf.dec") != NULL)
+    else if (strstr(pSfOMXComponent->componentName, "sf.video_decoder") != NULL)
     {
         pSfVideoImplement->testConfig = malloc(sizeof(TestDecConfig));
         if (pSfVideoImplement->testConfig == NULL)
@@ -241,11 +246,11 @@ OMX_ERRORTYPE InitComponentStructorCommon(SF_OMX_COMPONENT *pSfOMXComponent)
         goto ERROR;
     }
 
-    if (strstr(pSfOMXComponent->componentName, "264") != NULL)
+    if (strstr(pSfOMXComponent->componentName, "avc") != NULL)
     {
         pSfVideoImplement->bitFormat = STD_AVC;
     }
-    else if (strstr(pSfOMXComponent->componentName, "265") != NULL)
+    else if (strstr(pSfOMXComponent->componentName, "hevc") != NULL)
     {
         pSfVideoImplement->bitFormat = STD_HEVC;
     }
@@ -306,6 +311,7 @@ OMX_ERRORTYPE InitComponentStructorCommon(SF_OMX_COMPONENT *pSfOMXComponent)
         pHEVCComponent->nPortIndex = i;
         pHEVCComponent->nKeyFrameInterval = 30;
         pHEVCComponent->eProfile = OMX_VIDEO_HEVCProfileMain;
+        pSfOMXComponent->assignedBufferNum[i] = 0;
     }
 
     pSfOMXComponent->portDefinition[0].eDir = OMX_DirInput;
@@ -320,13 +326,44 @@ OMX_ERRORTYPE InitComponentStructorCommon(SF_OMX_COMPONENT *pSfOMXComponent)
     pSfOMXComponent->portDefinition[1].nBufferCountActual = VPU_OUTPUT_BUF_NUMBER;
     pSfOMXComponent->portDefinition[1].nBufferCountMin = VPU_OUTPUT_BUF_NUMBER;
 
+    /* Set componentVersion */
+    pSfOMXComponent->componentVersion.s.nVersionMajor = VERSIONMAJOR_NUMBER;
+    pSfOMXComponent->componentVersion.s.nVersionMinor = VERSIONMINOR_NUMBER;
+    pSfOMXComponent->componentVersion.s.nRevision     = REVISION_NUMBER;
+    pSfOMXComponent->componentVersion.s.nStep         = STEP_NUMBER;
+    /* Set specVersion */
+    pSfOMXComponent->specVersion.s.nVersionMajor = VERSIONMAJOR_NUMBER;
+    pSfOMXComponent->specVersion.s.nVersionMinor = VERSIONMINOR_NUMBER;
+    pSfOMXComponent->specVersion.s.nRevision     = REVISION_NUMBER;
+    pSfOMXComponent->specVersion.s.nStep         = STEP_NUMBER;
+    /* Input port */
+
     memset(pSfOMXComponent->pBufferArray, 0, sizeof(pSfOMXComponent->pBufferArray));
-    pSfOMXComponent->memory_optimization = OMX_TRUE;
+    pSfOMXComponent->memory_optimization = OMX_FALSE;
+
+    memset(pSfOMXComponent->markType, 0, sizeof(pSfOMXComponent->markType));
+    pSfOMXComponent->propagateMarkType.hMarkTargetComponent = NULL;
+    pSfOMXComponent->propagateMarkType.pMarkData = NULL;
+
+    for (int i = 0; i < 2; i++)
+    {
+        ret = SF_SemaphoreCreate(&pSfOMXComponent->portSemaphore[i]);
+        if (ret)
+            goto ERROR;
+        ret = SF_SemaphoreCreate(&pSfOMXComponent->portUnloadSemaphore[i]);
+        if (ret)
+            goto ERROR;
+    }
 
     FunctionOut();
 EXIT:
     return ret;
 ERROR:
+    for (int i = 0; i < 2; i++)
+    {
+        SF_SemaphoreTerminate(pSfOMXComponent->portSemaphore[i]);
+        SF_SemaphoreTerminate(pSfOMXComponent->portUnloadSemaphore[i]);
+    }
     if (pSfOMXComponent->pOMXComponent)
     {
         free(pSfOMXComponent->pOMXComponent);
@@ -368,20 +405,23 @@ OMX_ERRORTYPE FlushBuffer(SF_OMX_COMPONENT *pSfOMXComponent, OMX_U32 nPort)
     if (nPort == 0)
     {
         ComponentImpl *pFeederComponent = (ComponentImpl *)(pSfVideoImplement->hSFComponentFeeder);
-        OMX_U32 inputQueueCount = pSfVideoImplement->functions->Queue_Get_Cnt(pFeederComponent->srcPort.inputQ);
-        LOG(SF_LOG_PERF, "Flush %d buffers on inputPort\r\n", inputQueueCount);
-        if (inputQueueCount > 0)
+        if (pFeederComponent)
         {
-            PortContainerExternal *input = NULL;
-            while ((input = (PortContainerExternal*)pSfVideoImplement->functions->ComponentPortGetData(&pFeederComponent->srcPort)) != NULL)
+            OMX_U32 inputQueueCount = pSfVideoImplement->functions->Queue_Get_Cnt(pFeederComponent->srcPort.inputQ);
+            LOG(SF_LOG_PERF, "Flush %d buffers on inputPort\r\n", inputQueueCount);
+            if (inputQueueCount > 0)
             {
-                if (strstr(pSfOMXComponent->componentName, "sf.dec") != NULL)
+                PortContainerExternal *input = NULL;
+                while ((input = (PortContainerExternal*)pSfVideoImplement->functions->ComponentPortGetData(&pFeederComponent->srcPort)) != NULL)
                 {
-                    pSfVideoImplement->functions->ComponentNotifyListeners(pFeederComponent, COMPONENT_EVENT_DEC_EMPTY_BUFFER_DONE, (void *)input);
-                }
-                else if (strstr(pSfOMXComponent->componentName, "sf.enc") != NULL)
-                {
-                    pSfVideoImplement->functions->ComponentNotifyListeners(pFeederComponent, COMPONENT_EVENT_ENC_EMPTY_BUFFER_DONE, (void *)input);
+                    if (strstr(pSfOMXComponent->componentName, "sf.video_decoder") != NULL)
+                    {
+                        pSfVideoImplement->functions->ComponentNotifyListeners(pFeederComponent, COMPONENT_EVENT_DEC_EMPTY_BUFFER_DONE, (void *)input);
+                    }
+                    else if (strstr(pSfOMXComponent->componentName, "sf.video_encoder") != NULL)
+                    {
+                        pSfVideoImplement->functions->ComponentNotifyListeners(pFeederComponent, COMPONENT_EVENT_ENC_EMPTY_BUFFER_DONE, (void *)input);
+                    }
                 }
             }
         }
@@ -389,22 +429,25 @@ OMX_ERRORTYPE FlushBuffer(SF_OMX_COMPONENT *pSfOMXComponent, OMX_U32 nPort)
     else if (nPort == 1)
     {
         ComponentImpl *pRendererComponent = (ComponentImpl *)(pSfVideoImplement->hSFComponentRender);
-        OMX_U32 OutputQueueCount = pSfVideoImplement->functions->Queue_Get_Cnt(pRendererComponent->sinkPort.inputQ);
-        LOG(SF_LOG_PERF, "Flush %d buffers on outputPort\r\n", OutputQueueCount);
-        if (OutputQueueCount > 0)
+        if (pRendererComponent)
         {
-            PortContainerExternal *output = NULL;
-            while ((output = (PortContainerExternal*)pSfVideoImplement->functions->ComponentPortGetData(&pRendererComponent->sinkPort)) != NULL)
+            OMX_U32 OutputQueueCount = pSfVideoImplement->functions->Queue_Get_Cnt(pRendererComponent->sinkPort.inputQ);
+            LOG(SF_LOG_PERF, "Flush %d buffers on outputPort\r\n", OutputQueueCount);
+            if (OutputQueueCount > 0)
             {
-                output->nFlags = 0x1;
-                output->nFilledLen = 0;
-                if (strstr(pSfOMXComponent->componentName, "sf.dec") != NULL)
-                {
-                    pSfVideoImplement->functions->ComponentNotifyListeners(pRendererComponent, COMPONENT_EVENT_DEC_FILL_BUFFER_DONE, (void *)output);
-                }
-                else if (strstr(pSfOMXComponent->componentName, "sf.enc") != NULL)
+                PortContainerExternal *output = NULL;
+                while ((output = (PortContainerExternal*)pSfVideoImplement->functions->ComponentPortGetData(&pRendererComponent->sinkPort)) != NULL)
                 {
-                    pSfVideoImplement->functions->ComponentNotifyListeners(pRendererComponent, COMPONENT_EVENT_ENC_FILL_BUFFER_DONE, (void *)output);
+                    output->nFlags = 0x1;
+                    output->nFilledLen = 0;
+                    if (strstr(pSfOMXComponent->componentName, "sf.video_decoder") != NULL)
+                    {
+                        pSfVideoImplement->functions->ComponentNotifyListeners(pRendererComponent, COMPONENT_EVENT_DEC_FILL_BUFFER_DONE, (void *)output);
+                    }
+                    else if (strstr(pSfOMXComponent->componentName, "sf.video_encoder") != NULL)
+                    {
+                        pSfVideoImplement->functions->ComponentNotifyListeners(pRendererComponent, COMPONENT_EVENT_ENC_FILL_BUFFER_DONE, (void *)output);
+                    }
                 }
             }
         }

+ 11 - 0
omx-il/component/video/wave5/common/SF_OMX_video_common.h

@@ -11,6 +11,9 @@
 #include "OMX_Index.h"
 #include "OMX_IndexExt.h"
 #include "SF_OMX_Core.h"
+#include "sf_queue.h"
+#include "sf_thread.h"
+#include "sf_semaphore.h"
 #include "wave511/sample_v2/component/component.h"
 #include "wave511/sample_v2/component_encoder/encoder_listener.h"
 #include "wave511/sample_v2/component_decoder/decoder_listener.h"
@@ -30,6 +33,7 @@
 #define DEFAULT_FRAME_HEIGHT 2160
 #define DEFAULT_VIDEO_INPUT_BUFFER_SIZE (DEFAULT_FRAME_WIDTH * DEFAULT_FRAME_HEIGHT) / 2
 #define DEFAULT_VIDEO_OUTPUT_BUFFER_SIZE (DEFAULT_FRAME_WIDTH * DEFAULT_FRAME_HEIGHT * 3) / 2
+#define MAX_INDEX 1
 
 typedef struct _SF_COMPONENT_FUNCTIONS
 {
@@ -109,6 +113,13 @@ typedef struct _SF_WAVE5_IMPLEMEMT
     void *lsnCtx;
     Uint16 *pusBitCode;
     CodStd bitFormat;
+    OMX_BOOL rev_eos;
+    SF_Queue *CmdQueue;
+    SF_Queue *pauseQ;
+    THREAD_HANDLE_TYPE *pCmdThread;
+    OMX_BOOL bCmdRunning;
+    OMX_U64 frame_array[MAX_INDEX];
+    OMX_U32 frame_array_index;
     OMX_VIDEO_PARAM_AVCTYPE AVCComponent[2];
     OMX_VIDEO_PARAM_HEVCTYPE HEVCComponent[2];
 }SF_WAVE5_IMPLEMEMT;

Файловите разлики са ограничени, защото са твърде много
+ 919 - 224
omx-il/component/video/wave5/dec/SF_OMX_Vdec_decoder.c


+ 3 - 3
omx-il/component/video/wave5/enc/SF_OMX_Venc_encoder.c

@@ -499,7 +499,7 @@ static OMX_ERRORTYPE SF_OMX_GetParameter(
         // ret = OMX_ErrorNotImplemented;
         break;
     default:
-
+        ret = OMX_ErrorUnsupportedIndex;
         break;
     }
 
@@ -720,7 +720,7 @@ static OMX_ERRORTYPE SF_OMX_SetParameter(
     case OMX_IndexParamVideoQuantization:
     case OMX_IndexParamVideoIntraRefresh:
     default:
-
+        ret = OMX_ErrorUnsupportedIndex;
         break;
     }
 
@@ -965,7 +965,7 @@ static OMX_ERRORTYPE SF_OMX_SendCommand(
     switch (Cmd)
     {
     case OMX_CommandStateSet:
-        pSfOMXComponent->nextState = nParam;
+        pSfOMXComponent->state = nParam;
         LOG(SF_LOG_INFO, "OMX dest state = %X\r\n", nParam);
         switch (nParam)
         {

+ 27 - 76
omx-il/core/SF_OMX_Core.c

@@ -122,22 +122,29 @@ OMX_API OMX_ERRORTYPE OMX_APIENTRY OMX_GetHandle(
 
     for (i = 0; i < SF_OMX_COMPONENT_NUM; i++)
     {
-        pSf_omx_component = sf_omx_component_list[i];
-        if (pSf_omx_component == NULL)
+        if (sf_omx_component_list[i] == NULL)
         {
             ret = OMX_ErrorBadParameter;
             goto EXIT;
         }
-        if (strcmp(cComponentName, pSf_omx_component->componentName) == 0)
+        if (strcmp(cComponentName, sf_omx_component_list[i]->componentName) == 0)
         {
+            pSf_omx_component = malloc(sizeof(SF_OMX_COMPONENT));
+            if (!pSf_omx_component)
+            {
+                goto EXIT;
+            }
+            memcpy(pSf_omx_component, sf_omx_component_list[i], sizeof(SF_OMX_COMPONENT));
             ret = pSf_omx_component->SF_OMX_ComponentConstructor(pSf_omx_component);
             if (ret != OMX_ErrorNone)
             {
+                free(pSf_omx_component);
                 goto EXIT;
             }
             *pHandle = pSf_omx_component->pOMXComponent;
             pSf_omx_component->callbacks = pCallBacks;
             pSf_omx_component->pAppData = pAppData;
+            pSf_omx_component->state = OMX_StateLoaded;
             break;
         }
     }
@@ -153,6 +160,10 @@ OMX_API OMX_ERRORTYPE OMX_APIENTRY OMX_FreeHandle(OMX_IN OMX_HANDLETYPE hCompone
     SF_OMX_COMPONENT *pSfOMXComponent = (SF_OMX_COMPONENT *)pOMXComponent->pComponentPrivate;
     FunctionIn();
     ret = pSfOMXComponent->SF_OMX_ComponentClear(pSfOMXComponent);
+    if (!ret)
+    {
+        free(pSfOMXComponent);
+    }
 
     FunctionOut();
     return ret;
@@ -223,88 +234,28 @@ OMX_API OMX_ERRORTYPE OMX_GetRolesOfComponent(
     OMX_ERRORTYPE ret = OMX_ErrorNone;
     FunctionIn();
 
-    FunctionOut();
-    return ret;
-}
-
-OMX_ERRORTYPE ClearOMXBuffer(SF_OMX_COMPONENT *pSfOMXComponent, OMX_BUFFERHEADERTYPE *pBuffer)
-{
-    OMX_U32 i = 0;
-    for (i = 0; i < sizeof(pSfOMXComponent->pBufferArray) / sizeof(pSfOMXComponent->pBufferArray[0]); i++)
-    {
-        if (pSfOMXComponent->pBufferArray[i] == pBuffer)
-        {
-            pSfOMXComponent->pBufferArray[i] = NULL;
-            LOG(SF_LOG_DEBUG, "Clear OMX buffer %p at index %d\r\n", pBuffer, i);
-            return OMX_ErrorNone;
-        }
-    }
-    if (i == sizeof(pSfOMXComponent->pBufferArray) / sizeof(pSfOMXComponent->pBufferArray[0]))
-    {
-        LOG(SF_LOG_ERR, "Could Not found omx buffer!\r\n");
-    }
-    return OMX_ErrorBadParameter;
-}
-
-OMX_U32 GetOMXBufferCount(SF_OMX_COMPONENT *pSfOMXComponent)
-{
-    OMX_U32 i = 0;
-    OMX_U32 count = 0;
-    for (i = 0; i < sizeof(pSfOMXComponent->pBufferArray) / sizeof(pSfOMXComponent->pBufferArray[0]); i++)
-    {
-        if (pSfOMXComponent->pBufferArray[i] != NULL)
-        {
-            LOG(SF_LOG_DEBUG, "find OMX buffer %p at index %d\r\n", pSfOMXComponent->pBufferArray[i], i);
-            count++;
-        }
-    }
-
-    return count;
-}
-
-OMX_ERRORTYPE StoreOMXBuffer(SF_OMX_COMPONENT *pSfOMXComponent, OMX_BUFFERHEADERTYPE *pBuffer)
-{
-    OMX_U32 i = 0;
-    for (i = 0; i < sizeof(pSfOMXComponent->pBufferArray) / sizeof(pSfOMXComponent->pBufferArray[0]); i++)
-    {
-        if (pSfOMXComponent->pBufferArray[i] == NULL)
-        {
-            pSfOMXComponent->pBufferArray[i] = pBuffer;
-            LOG(SF_LOG_DEBUG, "Store OMX buffer %p at index %d\r\n", pBuffer, i);
-            return OMX_ErrorNone;
-        }
-    }
-    if (i == sizeof(pSfOMXComponent->pBufferArray))
-    {
-        LOG(SF_LOG_ERR, "Buffer arrary full!\r\n");
-    }
-    return OMX_ErrorInsufficientResources;
-}
-
-OMX_BUFFERHEADERTYPE *GetOMXBufferByAddr(SF_OMX_COMPONENT *pSfOMXComponent, OMX_U8 *pAddr)
-{
-    OMX_U32 i = 0;
-    OMX_BUFFERHEADERTYPE *pOMXBuffer;
-    FunctionIn();
-    LOG(SF_LOG_INFO, "ADDR=%p\r\n", pAddr);
-    for (i = 0; i < sizeof(pSfOMXComponent->pBufferArray) / sizeof(pSfOMXComponent->pBufferArray[0]); i++)
+#if 0 //todo
+    for (int i = 0; i < SF_OMX_COMPONENT_NUM; i ++)
     {
-        pOMXBuffer = pSfOMXComponent->pBufferArray[i];
-        LOG(SF_LOG_DEBUG, "Compare OMX buffer %p at index %d with addr %p\r\n", pOMXBuffer, i, pAddr);
-        if (pOMXBuffer == NULL)
+        if (sf_omx_component_list[i] == NULL)
         {
-            continue;
+            break;
         }
-        if (pOMXBuffer->pBuffer == pAddr)
+        if (strcmp(sf_omx_component_list[i]->componentName, compName) == 0)
         {
-            return pOMXBuffer;
+            *pNumRoles = 1;
+            if (roles != NULL) {
+                strcpy((OMX_STRING)roles[0], sf_omx_component_list[i]->componentRule);
+            }
+            LOG(SF_LOG_INFO,"Get component %s, Role = %s\r\n", sf_omx_component_list[i]->componentName, sf_omx_component_list[i]->componentRule)
         }
     }
-    LOG(SF_LOG_ERR, "could not find buffer!\r\n");
+#endif
 
     FunctionOut();
-    return NULL;
+    return ret;
 }
+
 void SF_LogMsgAppend(int level, const char *format, ...)
 {
     va_list ptr;

+ 34 - 8
omx-il/core/SF_OMX_Core.h

@@ -36,8 +36,14 @@ void SF_LogMsgAppend(int level, const char *format, ...);
 #define FunctionIn()
 #define FunctionOut()
 #endif
-#define VPU_OUTPUT_BUF_NUMBER 10
-#define VPU_INPUT_BUF_NUMBER 5
+#define VPU_OUTPUT_BUF_NUMBER              10
+#define VPU_INPUT_BUF_NUMBER               5
+#define MAX_BUFF_NUM                       32
+
+#define VERSIONMAJOR_NUMBER                1
+#define VERSIONMINOR_NUMBER                0
+#define REVISION_NUMBER                    0
+#define STEP_NUMBER                        0
 
 typedef enum SF_BUFFER_TYPE
 {
@@ -49,17 +55,34 @@ typedef enum SF_BUFFER_TYPE
     SF_BUFFER_ALL,
 }SF_BUFFER_TYPE;
 
+/** This enum defines the transition states of the Component*/
+typedef enum OMX_TRANS_STATETYPE {
+    OMX_TransStateInvalid,
+    OMX_TransStateLoadedToIdle,
+    OMX_TransStateIdleToPause,
+    OMX_TransStatePauseToExecuting,
+    OMX_TransStateIdleToExecuting,
+    OMX_TransStateExecutingToIdle,
+    OMX_TransStateExecutingToPause,
+    OMX_TransStatePauseToIdle,
+    OMX_TransStateIdleToLoaded,
+    OMX_TransStateMax = 0X7FFFFFFF
+} OMX_TRANS_STATETYPE;
+
 typedef struct _SF_OMX_BUF_INFO
 {
     SF_BUFFER_TYPE type;
     OMX_U64 PhysicalAddress;
     OMX_S32 fd;
+    OMX_U32 index;
 }SF_OMX_BUF_INFO;
 
 typedef struct _SF_OMX_COMPONENT
 {
     OMX_STRING componentName;
     OMX_STRING libName;
+    OMX_VERSIONTYPE componentVersion;
+    OMX_VERSIONTYPE specVersion;
     OMX_COMPONENTTYPE *pOMXComponent;
     OMX_ERRORTYPE (*SF_OMX_ComponentConstructor)(struct _SF_OMX_COMPONENT *hComponent);
     OMX_ERRORTYPE (*SF_OMX_ComponentClear)(struct _SF_OMX_COMPONENT *hComponent);
@@ -82,10 +105,17 @@ typedef struct _SF_OMX_COMPONENT
     OMX_CALLBACKTYPE *callbacks;
     OMX_PTR pAppData;
     OMX_PARAM_PORTDEFINITIONTYPE portDefinition[2];
-    OMX_BUFFERHEADERTYPE *pBufferArray[64];
+    OMX_HANDLETYPE portSemaphore[2];
+    OMX_HANDLETYPE portUnloadSemaphore[2];
+    OMX_BUFFERHEADERTYPE *pBufferArray[2][MAX_BUFF_NUM];
+    OMX_U32 assignedBufferNum[2];
     OMX_STRING fwPath;
     OMX_STRING componentRule;
-    OMX_STATETYPE nextState;
+    OMX_STATETYPE state;
+    OMX_STATETYPE stateBeforePause;
+    OMX_TRANS_STATETYPE traningState;
+    OMX_MARKTYPE markType[2];
+    OMX_MARKTYPE propagateMarkType;
     OMX_BOOL memory_optimization;
 } SF_OMX_COMPONENT;
 
@@ -118,10 +148,6 @@ extern "C"
 #endif
 
 int GetNumberOfComponent();
-OMX_BUFFERHEADERTYPE *GetOMXBufferByAddr(SF_OMX_COMPONENT *pSfOMXComponent, OMX_U8 *pAddr);
-OMX_ERRORTYPE StoreOMXBuffer(SF_OMX_COMPONENT *pSfOMXComponent, OMX_BUFFERHEADERTYPE *pBuffer);
-OMX_ERRORTYPE ClearOMXBuffer(SF_OMX_COMPONENT *pSfOMXComponent, OMX_BUFFERHEADERTYPE *pBuffer);
-OMX_U32 GetOMXBufferCount(SF_OMX_COMPONENT *pSfOMXComponent);
 
 #ifdef __cplusplus
 }

+ 61 - 0
omx-il/include/khronos/OMX_ComponentExt.h

@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2016 The Khronos Group Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject
+ * to the following conditions:
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+/** OMX_ComponentExt.h - OpenMax IL version 1.1.2
+ * The OMX_ComponentExt header file contains extensions to the definitions used
+ * by both the application and the component to access common items.
+ */
+
+#ifndef OMX_ComponentExt_h
+#define OMX_ComponentExt_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/* Each OMX header must include all required header files to allow the
+ * header to compile without errors.  The includes below are required
+ * for this header file to compile successfully 
+ */
+#include <OMX_Types.h>
+
+
+/** Set/query the commit mode */
+typedef struct OMX_CONFIG_COMMITMODETYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_BOOL bDeferred;
+} OMX_CONFIG_COMMITMODETYPE;
+
+/** Explicit commit */
+typedef struct OMX_CONFIG_COMMITTYPE {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+} OMX_CONFIG_COMMITTYPE;
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* OMX_ComponentExt_h */

+ 73 - 0
omx-il/include/khronos/OMX_CoreExt.h

@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2016 The Khronos Group Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject
+ * to the following conditions:
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+/** OMX_CoreExt.h - OpenMax IL version 1.1.2
+ * The OMX_CoreExt header file contains extensions to the definitions used
+ * by both the application and the component to access common items.
+ */
+
+#ifndef OMX_CoreExt_h
+#define OMX_CoreExt_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/* Each OMX header shall include all required header files to allow the
+ * header to compile without errors.  The includes below are required
+ * for this header file to compile successfully
+ */
+#include <OMX_Core.h>
+
+/** Extensions to the standard IL errors. */ 
+typedef enum OMX_ERROREXTTYPE 
+{
+    OMX_ErrorInvalidMode = (OMX_S32) (OMX_ErrorKhronosExtensions + 0x00000001),
+    OMX_ErrorExtMax = 0x7FFFFFFF
+} OMX_ERROREXTTYPE;
+
+
+/** Event type extensions. */
+typedef enum OMX_EVENTEXTTYPE
+{
+    OMX_EventIndexSettingChanged = OMX_EventKhronosExtensions, /**< component signals the IL client of a change
+                                                                    in a param, config, or extension */
+    OMX_EventExtMax = 0x7FFFFFFF
+} OMX_EVENTEXTTYPE;
+
+
+/** Enable or disable a callback event. */
+typedef struct OMX_CONFIG_CALLBACKREQUESTTYPE {
+    OMX_U32 nSize;              /**< size of the structure in bytes */
+    OMX_VERSIONTYPE nVersion;   /**< OMX specification version information */
+    OMX_U32 nPortIndex;         /**< port that this structure applies to */
+    OMX_INDEXTYPE nIndex;       /**< the index the callback is requested for */
+    OMX_BOOL bEnable;           /**< enable (OMX_TRUE) or disable (OMX_FALSE) the callback */
+} OMX_CONFIG_CALLBACKREQUESTTYPE;
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* OMX_CoreExt_h */
+/* File EOF */

+ 55 - 0
omx-il/include/khronos/OMX_ImageExt.h

@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2016 The Khronos Group Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject
+ * to the following conditions:
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+/** OMX_ImageExt.h - OpenMax IL version 1.1.2
+ * The OMX_ImageExt header file contains extensions to the
+ * definitions used by both the application and the component to
+ * access image items.
+ */
+
+#ifndef OMX_ImageExt_h
+#define OMX_ImageExt_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/* Each OMX header shall include all required header files to allow the
+ * header to compile without errors.  The includes below are required
+ * for this header file to compile successfully
+ */
+#include <OMX_Core.h>
+
+/** Enum for standard image codingtype extensions */
+typedef enum OMX_IMAGE_CODINGEXTTYPE {
+    OMX_IMAGE_CodingExtUnused = OMX_IMAGE_CodingKhronosExtensions,
+    OMX_IMAGE_CodingWEBP,         /**< WebP image format */
+} OMX_IMAGE_CODINGEXTTYPE;
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* OMX_ImageExt_h */
+/* File EOF */

+ 44 - 4
omx-il/tests/dec_test.c

@@ -44,11 +44,14 @@ typedef struct DecodeTestContext
     OMX_BUFFERHEADERTYPE *pInputBufferArray[64];
     OMX_BUFFERHEADERTYPE *pOutputBufferArray[64];
     AVFormatContext *avContext;
+    OMX_STATETYPE comState;
     int msgid;
 } DecodeTestContext;
 DecodeTestContext *decodeTestContext;
 static OMX_S32 FillInputBuffer(DecodeTestContext *decodeTestContext, OMX_BUFFERHEADERTYPE *pInputBuffer);
 
+static OMX_BOOL disableEVnt;
+
 static OMX_ERRORTYPE event_handler(
     OMX_HANDLETYPE hComponent,
     OMX_PTR pAppData,
@@ -69,6 +72,10 @@ static OMX_ERRORTYPE event_handler(
         OMX_GetParameter(pDecodeTestContext->hComponentDecoder, OMX_IndexParamPortDefinition, &pOutputPortDefinition);
         OMX_U32 nOutputBufferSize = pOutputPortDefinition.nBufferSize;
         OMX_U32 nOutputBufferCount = pOutputPortDefinition.nBufferCountMin;
+
+        printf("enable output port and alloc buffer\n");
+        OMX_SendCommand(pDecodeTestContext->hComponentDecoder, OMX_CommandPortEnable, 1, NULL);
+
         for (int i = 0; i < nOutputBufferCount; i++)
         {
             OMX_BUFFERHEADERTYPE *pBuffer = NULL;
@@ -89,6 +96,25 @@ static OMX_ERRORTYPE event_handler(
         }
     }
     break;
+    case OMX_EventCmdComplete:
+    {
+        switch ((OMX_COMMANDTYPE)(nData1))
+        {
+        case OMX_CommandStateSet:
+        {
+            pDecodeTestContext->comState = (OMX_STATETYPE)(nData2);
+        }
+        case OMX_CommandPortDisable:
+        {
+            if (nData2 == 1)
+                disableEVnt = OMX_TRUE;
+        }
+        break;
+        default:
+        break;
+        }
+    }
+    break;
     default:
         break;
     }
@@ -333,11 +359,11 @@ int main(int argc, char **argv)
     printf("get handle\r\n");
     if (codecParameters->codec_id == AV_CODEC_ID_H264)
     {
-        OMX_GetHandle(&hComponentDecoder, "sf.dec.decoder.h264", decodeTestContext, &callbacks);
+        OMX_GetHandle(&hComponentDecoder, "OMX.sf.video_decoder.avc", decodeTestContext, &callbacks);
     }
     else if (codecParameters->codec_id == AV_CODEC_ID_HEVC)
     {
-        OMX_GetHandle(&hComponentDecoder, "sf.dec.decoder.h265", decodeTestContext, &callbacks);
+        OMX_GetHandle(&hComponentDecoder, "OMX.sf.video_decoder.hevc", decodeTestContext, &callbacks);
     }
     if (hComponentDecoder == NULL)
     {
@@ -373,6 +399,12 @@ int main(int argc, char **argv)
     }
     OMX_SetParameter(hComponentDecoder, OMX_IndexParamPortDefinition, &pOutputPortDefinition);
 
+    disableEVnt = OMX_FALSE;
+    OMX_SendCommand(hComponentDecoder, OMX_CommandPortDisable, 1, NULL);
+    printf("wait for output port disable\r\n");
+    while (!disableEVnt);
+    printf("output port disabled\r\n");
+
     OMX_SendCommand(hComponentDecoder, OMX_CommandStateSet, OMX_StateIdle, NULL);
 
     OMX_PARAM_PORTDEFINITIONTYPE pInputPortDefinition;
@@ -392,9 +424,17 @@ int main(int argc, char **argv)
         OMX_BUFFERHEADERTYPE *pBuffer = NULL;
         OMX_AllocateBuffer(hComponentDecoder, &pBuffer, 0, NULL, nInputBufferSize);
         decodeTestContext->pInputBufferArray[i] = pBuffer;
+    }
+
+    printf("wait for Component idle\r\n");
+    while (decodeTestContext->comState != OMX_StateIdle);
+    printf("Component in idle\r\n");
+
+    for (int i = 0; i < nInputBufferCount; i++)
+    {
         /*Fill Input Buffer*/
-        FillInputBuffer(decodeTestContext, pBuffer);
-        OMX_EmptyThisBuffer(hComponentDecoder, pBuffer);
+        FillInputBuffer(decodeTestContext, decodeTestContext->pInputBufferArray[i]);
+        OMX_EmptyThisBuffer(hComponentDecoder, decodeTestContext->pInputBufferArray[i]);
     }
 
     fb = fopen(decodeTestContext->sOutputFilePath, "wb+");

+ 45 - 4
omx-il/tests/enc_test.c

@@ -47,6 +47,7 @@ typedef struct EncodeTestContext
     OMX_U32 nBitrate;
     OMX_U32 nFrameRate;
     OMX_U32 nNumPFrame;
+    OMX_STATETYPE comState;
     OMX_BUFFERHEADERTYPE *pInputBufferArray[64];
     OMX_BUFFERHEADERTYPE *pOutputBufferArray[64];
     int msgid;
@@ -54,6 +55,8 @@ typedef struct EncodeTestContext
 EncodeTestContext *encodeTestContext;
 static OMX_S32 FillInputBuffer(EncodeTestContext *encodeTestContext, OMX_BUFFERHEADERTYPE *pInputBuffer);
 
+static OMX_BOOL disableEVnt;
+
 static OMX_ERRORTYPE event_handler(
     OMX_HANDLETYPE hComponent,
     OMX_PTR pAppData,
@@ -74,6 +77,10 @@ static OMX_ERRORTYPE event_handler(
         OMX_GetParameter(pEncodeTestContext->hComponentEncoder, OMX_IndexParamPortDefinition, &pOutputPortDefinition);
         OMX_U32 nOutputBufferSize = pOutputPortDefinition.nBufferSize;
         OMX_U32 nOutputBufferCount = pOutputPortDefinition.nBufferCountMin;
+
+        printf("enable output port and alloc buffer\n");
+        OMX_SendCommand(pEncodeTestContext->hComponentEncoder, OMX_CommandPortEnable, 1, NULL);
+
         for (int i = 0; i < nOutputBufferCount; i++)
         {
             OMX_BUFFERHEADERTYPE *pBuffer = NULL;
@@ -94,6 +101,25 @@ static OMX_ERRORTYPE event_handler(
         }
     }
     break;
+    case OMX_EventCmdComplete:
+    {
+        switch ((OMX_COMMANDTYPE)(nData1))
+        {
+        case OMX_CommandStateSet:
+        {
+            pEncodeTestContext->comState = (OMX_STATETYPE)(nData2);
+        }
+        case OMX_CommandPortDisable:
+        {
+            if (nData2 == 1)
+                disableEVnt = OMX_TRUE;
+        }
+        break;
+        default:
+        break;
+        }
+    }
+    break;
     default:
         break;
     }
@@ -329,11 +355,11 @@ int main(int argc, char **argv)
     printf("get handle %s\r\n", encodeTestContext->sOutputFormat);
     if (strstr(encodeTestContext->sOutputFormat, "h264") != NULL)
     {
-        OMX_GetHandle(&hComponentEncoder, "sf.enc.encoder.h264", encodeTestContext, &callbacks);
+        OMX_GetHandle(&hComponentEncoder, "OMX.sf.video_encoder.avc", encodeTestContext, &callbacks);
     }
     else if (strstr(encodeTestContext->sOutputFormat, "h265") != NULL)
     {
-        OMX_GetHandle(&hComponentEncoder, "sf.enc.encoder.h265", encodeTestContext, &callbacks);
+        OMX_GetHandle(&hComponentEncoder, "OMX.sf.video_encoder.hevc", encodeTestContext, &callbacks);
     }
     if (hComponentEncoder == NULL)
     {
@@ -393,6 +419,12 @@ int main(int argc, char **argv)
     OMX_U32 nInputBufferSize = pInputPortDefinition.nBufferSize;
     OMX_U32 nInputBufferCount = pInputPortDefinition.nBufferCountActual;
 
+    disableEVnt = OMX_FALSE;
+    OMX_SendCommand(hComponentEncoder, OMX_CommandPortDisable, 1, NULL);
+    printf("wait for output port disable\r\n");
+    while (!disableEVnt);
+    printf("output port disabled\r\n");
+
     OMX_SendCommand(hComponentEncoder, OMX_CommandStateSet, OMX_StateIdle, NULL);
 
     for (int i = 0; i < nInputBufferCount; i++)
@@ -400,10 +432,19 @@ int main(int argc, char **argv)
         OMX_BUFFERHEADERTYPE *pBuffer = NULL;
         OMX_AllocateBuffer(hComponentEncoder, &pBuffer, 0, NULL, nInputBufferSize);
         encodeTestContext->pInputBufferArray[i] = pBuffer;
+    }
+
+    printf("wait for Component idle\r\n");
+    while (encodeTestContext->comState != OMX_StateIdle);
+    printf("Component in idle\r\n");
+
+    for (int i = 0; i < nInputBufferCount; i++)
+    {
         /*Fill Input Buffer*/
-        FillInputBuffer(encodeTestContext, pBuffer);
-        OMX_EmptyThisBuffer(hComponentEncoder, pBuffer);
+        FillInputBuffer(encodeTestContext, encodeTestContext->pInputBufferArray[i]);
+        OMX_EmptyThisBuffer(hComponentEncoder, encodeTestContext->pInputBufferArray[i]);
     }
+
     fb = fopen(encodeTestContext->sOutputFilePath, "wb+");
 
     OMX_SendCommand(hComponentEncoder, OMX_CommandStateSet, OMX_StateExecuting, NULL);

+ 1 - 1
omx-il/tests/mjpeg_dec_test.c

@@ -391,7 +391,7 @@ int main(int argc, char **argv)
     printf("get handle by codec id = %d\r\n", codecParameters->codec_id);
     if (codecParameters->codec_id == AV_CODEC_ID_MJPEG)
     {
-        OMX_GetHandle(&hComponentDecoder, "sf.dec.decoder.mjpeg", decodeTestContext, &callbacks);
+        OMX_GetHandle(&hComponentDecoder, "OMX.sf.video_decoder.mjpeg", decodeTestContext, &callbacks);
     }
 
     if (hComponentDecoder == NULL)

+ 2 - 0
wave511/code/sample_v2/component/component.c

@@ -368,6 +368,7 @@ static void DoYourJob(ComponentImpl* com)
     /* Check if connected components are terminated */
     sinkComponent = (ComponentImpl*)com->sinkPort.connectedComponent;
     if (sinkComponent && sinkComponent->terminate == TRUE) {
+        printf("%s skin terminate\r\n",com->name);
         com->terminate = TRUE;
     }
 
@@ -384,6 +385,7 @@ static void DoThreadWork(void* arg)
         DoYourJob(com);
         osal_msleep(2); // To yield schedule
     }
+    ComponentNotifyListeners(com, COMPONENT_EVENT_TERMINATED, NULL);
 
     com->state = COMPONENT_STATE_TERMINATED;
 }

+ 4 - 0
wave511/code/sample_v2/component/component.h

@@ -155,6 +155,8 @@ typedef struct PortContainerExternal
                                      buffer */
     Uint32 nOffset;            /**< start offset of valid data in bytes from
                                      the start of the buffer */
+    void*  pAppPrivate;        /**< pointer to any data the application
+                                     wants to associate with this buffer */
     Uint32 nBufferIndex;
     Uint32 nTickCount;         /**< Optional entry that the component and
                                      application can update with a tick count
@@ -173,6 +175,7 @@ typedef struct PortContainerExternal
                                      of the preceding buffer to the timestamp
                                      of the preceding buffer.*/
     Uint32  nFlags;           /**< buffer specific flags */
+    Uint32  index;
 } PortContainerExternal;
 
 typedef struct PortContainerES {
@@ -336,6 +339,7 @@ typedef struct {
 /* ------------------------------------------------ */
 #define COMPONENT_EVENT_SLEEP                   (1ULL<<0)       /*!<< The third parameter of listener is NULL. */
 #define COMPONENT_EVENT_WAKEUP                  (1ULL<<1)       /*!<< The third parameter of listener is NULL. */
+#define COMPONENT_EVENT_TERMINATED              (1ULL<<2)
 #define COMPONENT_EVENT_COMMON_ALL              0xffffULL
 /* ------------------------------------------------ */
 /* ---------------- DECODER EVENTS ---------------- */

+ 7 - 2
wave511/code/sample_v2/component_decoder/component_dec_renderer.c

@@ -516,7 +516,11 @@ static BOOL ExecuteRenderer(ComponentImpl* com, PortContainer* in, PortContainer
             }
         }
         output->nFilledLen = sizeYuv;
-        output->nFlags = srcData->decInfo.indexFrameDisplay;
+        output->index = srcData->decInfo.indexFrameDisplay;
+
+        if(srcData->last)
+            output->nFlags |= 0x1;
+
         if(ComponentPortGetData(&com->sinkPort))
         {
             ComponentNotifyListeners(com, COMPONENT_EVENT_DEC_FILL_BUFFER_DONE, (void *)output);
@@ -546,6 +550,7 @@ static BOOL ExecuteRenderer(ComponentImpl* com, PortContainer* in, PortContainer
     srcData->reuse    = FALSE;
 
     if (srcData->last == TRUE) {
+        ComponentNotifyListeners(com, COMPONENT_EVENT_DEC_DECODED_ALL, NULL);
         while ((output = (PortContainerExternal*)ComponentPortGetData(&com->sinkPort)) != NULL)
         {
             output->nFlags = 0x1;
@@ -634,7 +639,7 @@ static Component CreateRenderer(ComponentImpl* com, CNMComponentConfig* componen
     ctx->seqMemQ           = Queue_Create(10, sizeof(SequenceMemInfo));
     ctx->lock              = osal_mutex_create();
     ctx->ppuQ              = Queue_Create(MAX_REG_FRAME, sizeof(FrameBuffer));
-    ctx->MemoryOptimization = TRUE;
+    ctx->MemoryOptimization = FALSE;
     ctx->totalBufferNumber = 10;
     ctx->currentBufferNumber = 0;
     return (Component)com;

Някои файлове не бяха показани, защото твърде много файлове са промени