Browse Source

wave511,wave521,omx-il: refactor code and fix some issues

1. for encoding work flow:
  return error when set I frame interval to 1
  return error when set Framerate to 0
  return error when alloc size is 0
2. for decoding work flow:
  don't terminate thread on error
  get output size when buffer ready, the strategy is get scale size
     first, if not then use the size got from VPU which will align to 16
  when output size > input size, use the input size instead of return error
3. refator buffer management and Apply decoder features to encoder
4. refator the VPU log system
5. don't try to open outpu file on buffer mode
6. remove outdated test

Signed-off-by: sw.multimedia <sw.multimedia@starfivetech.com>
Andy Hu 2 years ago
parent
commit
a0696e22c6

+ 1 - 13
soft_3rdpart/omx-il/Makefile

@@ -42,9 +42,6 @@ MKDIR=mkdir -p
 SOURCES_COMMON = SF_OMX_Core.c SF_OMX_video_common.c 
 SOURCES_COMMON += SF_OMX_Vdec_decoder.c SF_OMX_Venc_encoder.c
 
-SOURCES_TESTS_WAVE521 = wave521test.c
-SOURCES_TESTS_WAVE511 = wave511test.c
-
 VPATH  = component/video/common:
 VPATH += component/video/enc:
 VPATH += component/video/dec:
@@ -53,20 +50,11 @@ VPATH += tests:
 
 OBJECTNAMES_COMMON=$(patsubst %.c,%.o,$(SOURCES_COMMON))
 OBJECTPATHS_COMMON=$(addprefix $(OBJDIR)/,$(notdir $(OBJECTNAMES_COMMON)))
-OBJECTNAMES_WAVE521=$(patsubst %.c,%.o,$(SOURCES_TESTS_WAVE521))
-OBJECTPATHS_WAVE521=$(addprefix $(OBJDIR)/,$(notdir $(OBJECTNAMES_WAVE521)))
-OBJECTNAMES_WAVE511=$(patsubst %.c,%.o,$(SOURCES_TESTS_WAVE511))
-OBJECTPATHS_WAVE511=$(addprefix $(OBJDIR)/,$(notdir $(OBJECTNAMES_WAVE511)))
+
 
 all: CREATE_DIR $(OBJECTPATHS_COMMON)
 	$(CC) -fPIC -shared -o libsf-omx-il.so $(LDFLAGS) $(OBJECTPATHS_COMMON)
 
-wave521-test: CREATE_DIR $(OBJECTPATHS_WAVE521)
-	$(CC) -o wave521test $(LDFLAGS) $(OBJECTPATHS_WAVE521) -lsf-omx-il -L./
-
-wave511-test: CREATE_DIR $(OBJECTPATHS_WAVE511)
-	$(CC) -o wave511test $(LDFLAGS) $(OBJECTPATHS_WAVE511) -lsf-omx-il -L./
-
 clean:
 
 CREATE_DIR:

+ 50 - 0
soft_3rdpart/omx-il/component/video/common/SF_OMX_video_common.c

@@ -322,3 +322,53 @@ ERROR:
     }
     return ret;
 }
+
+OMX_ERRORTYPE FlushBuffer(SF_OMX_COMPONENT *pSfOMXComponent, OMX_U32 nPort)
+{
+    FunctionIn();
+    if (nPort == 0)
+    {
+        ComponentImpl *pFeederComponent = pSfOMXComponent->hSFComponentFeeder;
+        OMX_U32 inputQueueCount = pSfOMXComponent->functions->Queue_Get_Cnt(pFeederComponent->srcPort.inputQ);
+        LOG(SF_LOG_PERF, "Flush %d buffers on inputPort\r\n", inputQueueCount);
+        if (inputQueueCount > 0)
+        {
+            PortContainerExternal *input = NULL;
+            while ((input = (PortContainerExternal*)pSfOMXComponent->functions->ComponentPortGetData(&pFeederComponent->srcPort)) != NULL)
+            {
+                if (strstr(pSfOMXComponent->componentName, "sf.dec") != NULL)
+                {
+                    pSfOMXComponent->functions->ComponentNotifyListeners(pFeederComponent, COMPONENT_EVENT_DEC_EMPTY_BUFFER_DONE, (void *)input);
+                }
+                else if (strstr(pSfOMXComponent->componentName, "sf.enc") != NULL)
+                {
+                    pSfOMXComponent->functions->ComponentNotifyListeners(pFeederComponent, COMPONENT_EVENT_ENC_EMPTY_BUFFER_DONE, (void *)input);
+                }
+            }
+        }
+    }
+    else if (nPort == 1)
+    {
+        ComponentImpl *pRendererComponent = pSfOMXComponent->hSFComponentRender;
+        OMX_U32 OutputQueueCount = pSfOMXComponent->functions->Queue_Get_Cnt(pRendererComponent->sinkPort.inputQ);
+        LOG(SF_LOG_PERF, "Flush %d buffers on outputPort\r\n", OutputQueueCount);
+        if (OutputQueueCount > 0)
+        {
+            PortContainerExternal *output = NULL;
+            while ((output = (PortContainerExternal*)pSfOMXComponent->functions->ComponentPortGetData(&pRendererComponent->sinkPort)) != NULL)
+            {
+                output->nFlags = 0x1;
+                output->nFilledLen = 0;
+                if (strstr(pSfOMXComponent->componentName, "sf.dec") != NULL)
+                {
+                    pSfOMXComponent->functions->ComponentNotifyListeners(pRendererComponent, COMPONENT_EVENT_DEC_FILL_BUFFER_DONE, (void *)output);
+                }
+                else if (strstr(pSfOMXComponent->componentName, "sf.enc") != NULL)
+                {
+                    pSfOMXComponent->functions->ComponentNotifyListeners(pRendererComponent, COMPONENT_EVENT_ENC_FILL_BUFFER_DONE, (void *)output);
+                }
+            }
+        }
+    }
+    FunctionOut();
+}

+ 1 - 0
soft_3rdpart/omx-il/component/video/common/SF_OMX_video_common.h

@@ -39,6 +39,7 @@ extern "C"
     OMX_ERRORTYPE GetStateCommon(OMX_IN OMX_HANDLETYPE hComponent, OMX_OUT OMX_STATETYPE *pState);
     OMX_ERRORTYPE InitComponentStructorCommon(SF_OMX_COMPONENT *hComponent);
     OMX_ERRORTYPE ComponentClearCommon(SF_OMX_COMPONENT *hComponent);
+    OMX_ERRORTYPE FlushBuffer(SF_OMX_COMPONENT *pSfOMXComponent, OMX_U32 nPort);
 
 #ifdef __cplusplus
 }

+ 52 - 40
soft_3rdpart/omx-il/component/video/dec/SF_OMX_Vdec_decoder.c

@@ -130,10 +130,39 @@ static void OnEventArrived(Component com, unsigned long event, void *data, void
     break;
     case COMPONENT_EVENT_DEC_REGISTER_FB:
     {
-        FrameBuffer *frameBuffer = (FrameBuffer *)data;
-        LOG(SF_LOG_INFO, "Get Output width = %d, height = %d\r\n", frameBuffer->width, frameBuffer->height);
-        // pSfOMXComponent->portDefinition[1].format.video.nFrameWidth = frameBuffer->width;
-        // pSfOMXComponent->portDefinition[1].format.video.nFrameHeight = frameBuffer->height;
+        /*The width and height vpu return will align to 16, eg: 1080 will be 1088. so check scale value at first.*/
+        TestDecConfig *testConfig = (TestDecConfig *)pSfOMXComponent->testConfig;
+        OMX_U32 nWidth = testConfig->scaleDownWidth;
+        OMX_U32 nHeight = testConfig->scaleDownHeight;
+        if (nWidth <= 0 || nHeight <= 0)
+        {
+            /*If scale value not set, then get value from vpu*/
+            FrameBuffer *frameBuffer = (FrameBuffer *)data;
+            nWidth = frameBuffer->width;
+            nHeight = frameBuffer->height;
+        }
+
+        LOG(SF_LOG_INFO, "Get Output width = %d, height = %d\r\n", nWidth, nHeight);
+        pSfOMXComponent->portDefinition[1].format.video.nFrameWidth = nWidth;
+        pSfOMXComponent->portDefinition[1].format.video.nFrameHeight = nHeight;
+        pSfOMXComponent->portDefinition[1].format.video.nStride = nWidth;
+        pSfOMXComponent->portDefinition[1].format.video.nSliceHeight = nHeight;
+
+        /*Caculate buffer size by eColorFormat*/
+        switch (pSfOMXComponent->portDefinition[1].format.video.eColorFormat)
+        {
+        case OMX_COLOR_FormatYUV420Planar:
+        case OMX_COLOR_FormatYUV420SemiPlanar:
+            if (nWidth && nHeight) {
+                pSfOMXComponent->portDefinition[1].nBufferSize = (nWidth * nHeight * 3) / 2;
+            }
+            break;
+        default:
+            if (nWidth && nHeight) {
+                pSfOMXComponent->portDefinition[1].nBufferSize = nWidth * nHeight * 2;
+            }
+            break;
+        }
         pSfOMXComponent->callbacks->EventHandler(pSfOMXComponent->pOMXComponent, pSfOMXComponent->pAppData, OMX_EventPortSettingsChanged,
                                                  1, OMX_IndexParamPortDefinition, NULL);
     }
@@ -314,6 +343,12 @@ static OMX_ERRORTYPE SF_OMX_AllocateBuffer(
     SF_OMX_COMPONENT *pSfOMXComponent = pOMXComponent->pComponentPrivate;
     ComponentImpl *pComponentRender = (ComponentImpl *)pSfOMXComponent->hSFComponentRender;
 
+    FunctionIn();
+    if (nSizeBytes == 0)
+    {
+        LOG(SF_LOG_ERR, "nSizeBytes = %d\r\n", nSizeBytes);
+        return OMX_ErrorBadParameter;
+    }
     OMX_BUFFERHEADERTYPE *temp_bufferHeader = (OMX_BUFFERHEADERTYPE *)malloc(sizeof(OMX_BUFFERHEADERTYPE));
     if (temp_bufferHeader == NULL)
     {
@@ -548,9 +583,12 @@ static OMX_ERRORTYPE SF_OMX_SetParameter(
                 int scaleh = pInputPort->format.video.nFrameHeight / height;
                 if (scalew > 8 || scaleh > 8 || scalew < 1 || scaleh < 1)
                 {
-                    LOG(SF_LOG_ERR, "Scaling should be 1 to 1/8 (down-scaling only)!\r\n");
-                    ret = OMX_ErrorBadParameter;
-                    goto EXIT;
+                    int nInputWidth = pInputPort->format.video.nFrameWidth;
+                    int nInputHeight = pInputPort->format.video.nFrameHeight;
+                    LOG(SF_LOG_WARN, "Scaling should be 1 to 1/8 (down-scaling only)! Use input parameter. "
+                        "OutPut[%d, %d]. Input[%d, %d]\r\n", width, height, nInputWidth, nInputHeight);
+                    width = nInputWidth;
+                    height = nInputHeight;
                 }
             }
             pOutputPort->format.video.nFrameWidth = width;
@@ -789,36 +827,6 @@ static OMX_ERRORTYPE InitDecoder(SF_OMX_COMPONENT *pSfOMXComponent)
     return OMX_ErrorNone;
 }
 
-static OMX_ERRORTYPE FlushBuffer(SF_OMX_COMPONENT *pSfOMXComponent)
-{
-    ComponentImpl *pRendererComponent = pSfOMXComponent->hSFComponentRender;
-    ComponentImpl *pFeederComponent = pSfOMXComponent->hSFComponentFeeder;
-    OMX_U32 inputQueueCount = pSfOMXComponent->functions->Queue_Get_Cnt(pFeederComponent->srcPort.inputQ);
-    OMX_U32 OutputQueueCount = pSfOMXComponent->functions->Queue_Get_Cnt(pRendererComponent->sinkPort.inputQ);
-
-    FunctionIn();
-    LOG(SF_LOG_PERF, "Flush %d-%d buffers on inputPort-outputPort\r\n", inputQueueCount, OutputQueueCount);
-    if (inputQueueCount > 0)
-    {
-        PortContainerExternal *input = NULL;
-        while ((input = (PortContainerExternal*)pSfOMXComponent->functions->ComponentPortGetData(&pFeederComponent->srcPort)) != NULL)
-        {
-            pSfOMXComponent->functions->ComponentNotifyListeners(pFeederComponent, COMPONENT_EVENT_DEC_EMPTY_BUFFER_DONE, (void *)input);
-        }
-    }
-    if (OutputQueueCount > 0)
-    {
-        PortContainerExternal *output = NULL;
-        while ((output = (PortContainerExternal*)pSfOMXComponent->functions->ComponentPortGetData(&pRendererComponent->sinkPort)) != NULL)
-        {
-            output->nFlags = 0x1;
-            output->nFilledLen = 0;
-            pSfOMXComponent->functions->ComponentNotifyListeners(pRendererComponent, COMPONENT_EVENT_DEC_FILL_BUFFER_DONE, (void *)output);
-        }
-    }
-    FunctionOut();
-}
-
 static OMX_ERRORTYPE SF_OMX_SendCommand(
     OMX_IN OMX_HANDLETYPE hComponent,
     OMX_IN OMX_COMMANDTYPE Cmd,
@@ -912,7 +920,8 @@ static OMX_ERRORTYPE SF_OMX_SendCommand(
                     pSFComponentDecoder->pause = OMX_TRUE;
                     pSFComponentFeeder->pause = OMX_TRUE;
                     pSFComponentRender->pause = OMX_TRUE;
-                    FlushBuffer(pSfOMXComponent);
+                    FlushBuffer(pSfOMXComponent, 0);
+                    FlushBuffer(pSfOMXComponent, 1);
                 }
                 break;
             }
@@ -975,10 +984,13 @@ static OMX_ERRORTYPE SF_OMX_SendCommand(
                                                  OMX_EventCmdComplete, OMX_CommandStateSet, nParam, NULL);
         break;
     case OMX_CommandFlush:
-        FlushBuffer(pSfOMXComponent);
+    {
+        OMX_U32 nPort = nParam;
+        FlushBuffer(pSfOMXComponent, nPort);
         pSfOMXComponent->callbacks->EventHandler(pSfOMXComponent->pOMXComponent, pSfOMXComponent->pAppData,
                                                  OMX_EventCmdComplete, OMX_CommandFlush, nParam, NULL);
-        break;
+    }
+    break;
     case OMX_CommandPortDisable:
         pSfOMXComponent->callbacks->EventHandler(pSfOMXComponent->pOMXComponent, pSfOMXComponent->pAppData,
                                                  OMX_EventCmdComplete, OMX_CommandPortDisable, nParam, NULL);

+ 121 - 45
soft_3rdpart/omx-il/component/video/enc/SF_OMX_Venc_encoder.c

@@ -11,19 +11,65 @@
 #define WAVE521_CONFIG_FILE "/lib/firmware/encoder_defconfig.cfg"
 extern OMX_TICKS gInitTimeStamp;
 
+static char* Event2Str(unsigned long event)
+{
+    char *event_str = NULL;
+    switch (event)
+    {
+    case COMPONENT_EVENT_ENC_OPEN:
+        event_str = "COMPONENT_EVENT_ENC_OPEN";
+        break;
+    case COMPONENT_EVENT_ENC_ISSUE_SEQ:
+        event_str = "COMPONENT_EVENT_ENC_ISSUE_SEQ";
+        break;
+    case COMPONENT_EVENT_ENC_COMPLETE_SEQ:
+        event_str = "COMPONENT_EVENT_ENC_COMPLETE_SEQ";
+        break;
+    case COMPONENT_EVENT_ENC_REGISTER_FB:
+        event_str = "COMPONENT_EVENT_ENC_REGISTER_FB";
+        break;
+    case COMPONENT_EVENT_ENC_READY_ONE_FRAME:
+        event_str = "COMPONENT_EVENT_ENC_READY_ONE_FRAME";
+        break;
+    case COMPONENT_EVENT_ENC_START_ONE_FRAME:
+        event_str = "COMPONENT_EVENT_ENC_START_ONE_FRAME";
+        break;
+    case COMPONENT_EVENT_ENC_GET_OUTPUT_INFO:
+        event_str = "COMPONENT_EVENT_ENC_GET_OUTPUT_INFO";
+        break;
+    case COMPONENT_EVENT_ENC_ENCODED_ALL:
+        event_str = "COMPONENT_EVENT_ENC_ENCODED_ALL";
+        break;
+    case COMPONENT_EVENT_ENC_CLOSE:
+        event_str = "COMPONENT_EVENT_ENC_CLOSE";
+        break;
+    case COMPONENT_EVENT_ENC_EMPTY_BUFFER_DONE:
+        event_str = "COMPONENT_EVENT_ENC_EMPTY_BUFFER_DONE";
+        break;
+    case COMPONENT_EVENT_ENC_FILL_BUFFER_DONE:
+        event_str = "COMPONENT_EVENT_ENC_FILL_BUFFER_DONE";
+        break;
+    case COMPONENT_EVENT_ENC_ALL:
+        event_str = "COMPONENT_EVENT_ENC_ALL";
+        break;
+    }
+    return event_str;
+}
+
 static void OnEventArrived(Component com, unsigned long event, void *data, void *context)
 {
     FunctionIn();
     SF_OMX_COMPONENT *pSfOMXComponent = GetSFOMXComponrntByComponent(com);
     ComponentImpl *pSFComponent = (ComponentImpl *)com;
-    static OMX_U32 dec_cnt = 0;
+    static OMX_U32 enc_cnt = 0;
     static struct timeval tv_old = {0};
     OMX_U32 fps = 0;
     OMX_U64 diff_time = 0; // ms
     PortContainerExternal *pPortContainerExternal = (PortContainerExternal *)data;
     OMX_BUFFERHEADERTYPE *pOMXBuffer;
+    char *event_str = Event2Str(event);
 
-    LOG(SF_LOG_INFO, "event=%lX\r\n", event);
+    LOG(SF_LOG_INFO, "event=%lX %s\r\n", event, event_str);
     switch (event)
     {
     case COMPONENT_EVENT_ENC_EMPTY_BUFFER_DONE:
@@ -54,17 +100,20 @@ static void OnEventArrived(Component com, unsigned long event, void *data, void
                 fclose(fb);
             }
 #endif
-        if (dec_cnt == 0) {
+        if (enc_cnt == 0) {
             tv_old = tv;
         }
-        if (dec_cnt++ >= 50) {
+        if (enc_cnt++ >= 50) {
             diff_time = (tv.tv_sec - tv_old.tv_sec) * 1000 + (tv.tv_usec - tv_old.tv_usec) / 1000;
-            fps = 1000  * (dec_cnt - 1) / diff_time;
-            dec_cnt = 0;
-            LOG(SF_LOG_WARN, "Decoding fps: %d \r\n", fps);
+            fps = 1000  * (enc_cnt - 1) / diff_time;
+            enc_cnt = 0;
+            LOG(SF_LOG_WARN, "Encoding fps: %d \r\n", fps);
         }
         LOG(SF_LOG_PERF, "OMX finish one buffer, address = %p, size = %d, nTimeStamp = %d, nFlags = %X\r\n", pOMXBuffer->pBuffer, pOMXBuffer->nFilledLen, pOMXBuffer->nTimeStamp, pOMXBuffer->nFlags);
         pSfOMXComponent->callbacks->FillBufferDone(pSfOMXComponent->pOMXComponent, pSfOMXComponent->pAppData, pOMXBuffer);
+        ComponentImpl *pRendererComponent = (ComponentImpl *)pSfOMXComponent->hSFComponentRender;
+        LOG(SF_LOG_PERF, "output queue count=%d/%d\r\n", pSfOMXComponent->functions->Queue_Get_Cnt(pRendererComponent->sinkPort.inputQ),
+                                                    pSfOMXComponent->portDefinition[1].nBufferCountActual);
     }
     break;
     case COMPONENT_EVENT_ENC_REGISTER_FB:
@@ -156,7 +205,7 @@ static OMX_ERRORTYPE SF_OMX_FillThisBuffer(
     memset(pPortContainerExternal, 0, sizeof(PortContainerExternal));
     pPortContainerExternal->pBuffer = pBuffer->pBuffer;
     pPortContainerExternal->nFilledLen = pBuffer->nAllocLen;
-    if (pSfOMXComponent->functions->Queue_Enqueue(pRendererComponent->sinkPort.inputQ, (void *)pPortContainerExternal) == FALSE)
+    if (pSfOMXComponent->functions->Queue_Enqueue(pRendererComponent->sinkPort.inputQ, (void *)pPortContainerExternal) == -1)
     {
         LOG(SF_LOG_ERR, "%p:%p FAIL\r\n", pRendererComponent->sinkPort.inputQ, pPortContainerExternal);
         free(pPortContainerExternal);
@@ -225,8 +274,13 @@ static OMX_ERRORTYPE SF_OMX_AllocateBuffer(
     SF_OMX_COMPONENT *pSfOMXComponent = pOMXComponent->pComponentPrivate;
     ComponentImpl *pComponentFeeder = (ComponentImpl *)pSfOMXComponent->hSFComponentFeeder;
     OMX_U32 i = 0;
-    FunctionIn();
 
+    FunctionIn();
+    if (nSizeBytes == 0)
+    {
+        LOG(SF_LOG_ERR, "nSizeBytes = %d\r\n", nSizeBytes);
+        return OMX_ErrorBadParameter;
+    }
     OMX_BUFFERHEADERTYPE *temp_bufferHeader = (OMX_BUFFERHEADERTYPE *)malloc(sizeof(OMX_BUFFERHEADERTYPE));
     if (temp_bufferHeader == NULL)
     {
@@ -402,6 +456,7 @@ static OMX_ERRORTYPE SF_OMX_GetParameter(
         LOG(SF_LOG_INFO, "Get ProfileLevel on port %d\r\n", pParam->nPortIndex);
         if (pParam->nPortIndex == 1)
         {
+            //TODO
             pParam->eProfile = OMX_VIDEO_HEVCProfileMain;
             pParam->eLevel = OMX_VIDEO_HEVCMainTierLevel5;
             LOG(SF_LOG_INFO, "eProfile = OMX_VIDEO_HEVCProfileMain\r\n");
@@ -455,16 +510,31 @@ static OMX_ERRORTYPE SF_OMX_SetParameter(
         OMX_U32 height = pPortDefinition->format.video.nFrameHeight;
         OMX_U32 nBitrate = pPortDefinition->format.video.nBitrate;
         OMX_U32 xFramerate = pPortDefinition->format.video.xFramerate;
-        LOG(SF_LOG_INFO, "Set width = %d, height = %d xFramerate = %d, nBitrate = %d on port %d\r\n",
-            width, height, xFramerate, nBitrate, pPortDefinition->nPortIndex);
-        memcpy(&pSfOMXComponent->portDefinition[portIndex], pPortDefinition, pPortDefinition->nSize);
+        OMX_U32 nBufferCountActual = pPortDefinition->nBufferCountActual;
+        LOG(SF_LOG_INFO, "Set width = %d, height = %d, xFramerate = %d, nBitrate = %d, nBufferCountActual = %d on port %d\r\n",
+            width, height, xFramerate, nBitrate, nBufferCountActual, portIndex);
         OMX_COLOR_FORMATTYPE eColorFormat = pPortDefinition->format.video.eColorFormat;
         TestEncConfig *pTestEncConfig = (TestEncConfig *)pSfOMXComponent->testConfig;
         CNMComponentConfig *config = pSfOMXComponent->config;
         EncOpenParam *encOpenParam = &config->encOpenParam;
 
+        if (xFramerate == 0)
+        {
+            LOG(SF_LOG_ERR, "Fail to set xFramerate = %d\r\n", xFramerate);
+            return OMX_ErrorBadParameter;
+        }
         if (portIndex == 0)
         {
+            if (nBufferCountActual != pInputPort->nBufferCountActual)
+            {
+                LOG(SF_LOG_INFO, "Set input buffer count = %d\r\n", nBufferCountActual);
+                ComponentImpl *pFeederComponent = (ComponentImpl *)pSfOMXComponent->hSFComponentFeeder;
+                pSfOMXComponent->functions->ComponentPortDestroy(&pFeederComponent->srcPort);
+                pSfOMXComponent->functions->ComponentPortCreate(&pFeederComponent->srcPort, pSfOMXComponent->hSFComponentFeeder,
+                                                                nBufferCountActual, sizeof(PortContainerExternal));
+            }
+
+            memcpy(&pSfOMXComponent->portDefinition[portIndex], pPortDefinition, pPortDefinition->nSize);
             pInputPort->format.video.nStride = width;
             pInputPort->format.video.nSliceHeight = height;
             pInputPort->nBufferSize = width * height * 2;
@@ -485,6 +555,17 @@ static OMX_ERRORTYPE SF_OMX_SetParameter(
         }
         else if (portIndex == 1)
         {
+            LOG(SF_LOG_INFO, "Current output buffer count = %d\r\n", pOutputPort->nBufferCountActual);
+            if (nBufferCountActual != pOutputPort->nBufferCountActual)
+            {
+                ComponentImpl *pRenderComponent = (ComponentImpl *)pSfOMXComponent->hSFComponentRender;
+                LOG(SF_LOG_INFO, "Set output buffer count = %d\r\n", nBufferCountActual);
+                pSfOMXComponent->functions->ComponentPortDestroy(&pRenderComponent->sinkPort);
+                pSfOMXComponent->functions->ComponentPortCreate(&pRenderComponent->sinkPort, pSfOMXComponent->hSFComponentRender,
+                                                                nBufferCountActual, sizeof(PortContainerExternal));
+            }
+
+            memcpy(&pSfOMXComponent->portDefinition[portIndex], pPortDefinition, pPortDefinition->nSize);
             width = pInputPort->format.video.nFrameWidth;
             height = pInputPort->format.video.nFrameHeight;
             pOutputPort->format.video.nFrameWidth = width;
@@ -567,8 +648,15 @@ static OMX_ERRORTYPE SF_OMX_SetParameter(
         OMX_VIDEO_PARAM_AVCTYPE *pSrcAVCComponent= (OMX_VIDEO_PARAM_AVCTYPE *)ComponentParameterStructure;
         OMX_U32 nPortIndex = pSrcAVCComponent->nPortIndex;
         OMX_VIDEO_PARAM_AVCTYPE *pDstAVCComponent = &pSfOMXComponent->AVCComponent[nPortIndex];
+        OMX_U32 nPFrames = pSrcAVCComponent->nPFrames;
 
-        LOG(SF_LOG_INFO, "Set nPFrames = %d on port %d\r\n", pSrcAVCComponent->nRefFrames, nPortIndex);
+        LOG(SF_LOG_INFO, "Set nPFrames = %d on port %d\r\n", nPFrames, nPortIndex);
+        if (nPFrames == 1)
+        {
+            LOG(SF_LOG_ERR, "Set nPFrames = %d not supported!\r\n", nPFrames);
+            ret = OMX_ErrorBadPortIndex;
+            goto EXIT;
+        }
         memcpy(pDstAVCComponent, pSrcAVCComponent, sizeof(OMX_VIDEO_PARAM_AVCTYPE));
     }
     break;
@@ -577,8 +665,15 @@ static OMX_ERRORTYPE SF_OMX_SetParameter(
         OMX_VIDEO_PARAM_HEVCTYPE *pSrcHEVCComponent= (OMX_VIDEO_PARAM_HEVCTYPE *)ComponentParameterStructure;
         OMX_U32 nPortIndex = pSrcHEVCComponent->nPortIndex;
         OMX_VIDEO_PARAM_HEVCTYPE *pDstHEVCComponent = &pSfOMXComponent->HEVCComponent[nPortIndex];
+        OMX_U32 nKeyFrameInterval = pSrcHEVCComponent->nKeyFrameInterval;
 
-        LOG(SF_LOG_INFO, "Set nKeyFrameInterval = %d on port %d\r\n", pSrcHEVCComponent->nKeyFrameInterval, nPortIndex);
+        LOG(SF_LOG_INFO, "Set nKeyFrameInterval = %d on port %d\r\n", nKeyFrameInterval, nPortIndex);
+        if (nKeyFrameInterval == 1)
+        {
+            LOG(SF_LOG_ERR, "Set nKeyFrameInterval = %d not supported!\r\n", nKeyFrameInterval);
+            ret = OMX_ErrorBadPortIndex;
+            goto EXIT;
+        }
         memcpy(pDstHEVCComponent, pSrcHEVCComponent, sizeof(OMX_VIDEO_PARAM_HEVCTYPE));
     }
     break;
@@ -696,33 +791,7 @@ EXIT:
     FunctionOut();
     return ret;
 }
-static OMX_ERRORTYPE FlushBuffer(SF_OMX_COMPONENT *pSfOMXComponent)
-{
-    ComponentImpl *pRendererComponent = pSfOMXComponent->hSFComponentRender;
-    ComponentImpl *pFeederComponent = pSfOMXComponent->hSFComponentFeeder;
-    OMX_U32 inputQueueCount = pSfOMXComponent->functions->Queue_Get_Cnt(pFeederComponent->srcPort.inputQ);
-    OMX_U32 OutputQueueCount = pSfOMXComponent->functions->Queue_Get_Cnt(pRendererComponent->sinkPort.inputQ);
 
-    FunctionIn();
-    LOG(SF_LOG_PERF, "Flush %d-%d buffers on inputPort-outputPort\r\n", inputQueueCount, OutputQueueCount);
-    if (inputQueueCount > 0)
-    {
-        PortContainerExternal *input = NULL;
-        while ((input = (PortContainerExternal*)pSfOMXComponent->functions->ComponentPortGetData(&pFeederComponent->srcPort)) != NULL)
-        {
-            pSfOMXComponent->functions->ComponentNotifyListeners(pFeederComponent, COMPONENT_EVENT_ENC_EMPTY_BUFFER_DONE, (void *)input);
-        }
-    }
-    if (OutputQueueCount > 0)
-    {
-        PortContainerExternal *output = NULL;
-        while ((output = (PortContainerExternal*)pSfOMXComponent->functions->ComponentPortGetData(&pRendererComponent->sinkPort)) != NULL)
-        {
-            pSfOMXComponent->functions->ComponentNotifyListeners(pRendererComponent, COMPONENT_EVENT_ENC_FILL_BUFFER_DONE, (void *)output);
-        }
-    }
-    FunctionOut();
-}
 static OMX_ERRORTYPE InitEncoder(SF_OMX_COMPONENT *pSfOMXComponent)
 {
     TestEncConfig *testConfig = NULL;
@@ -802,11 +871,13 @@ static OMX_ERRORTYPE InitEncoder(SF_OMX_COMPONENT *pSfOMXComponent)
     pSfOMXComponent->hSFComponentRender = pSfOMXComponent->functions->ComponentCreate("reader", config);
 
     ComponentImpl *pFeederComponent = (ComponentImpl *)pSfOMXComponent->hSFComponentFeeder;
-    pSfOMXComponent->functions->ComponentPortCreate(&pFeederComponent->srcPort, pSfOMXComponent->hSFComponentFeeder, 10, sizeof(PortContainerExternal));
+    pSfOMXComponent->functions->ComponentPortCreate(&pFeederComponent->srcPort, pSfOMXComponent->hSFComponentFeeder,
+                    pSfOMXComponent->portDefinition[0].nBufferCountActual, sizeof(PortContainerExternal));
 
     ComponentImpl *pRenderComponent = (ComponentImpl *)pSfOMXComponent->hSFComponentRender;
     pSfOMXComponent->functions->ComponentPortDestroy(&pRenderComponent->sinkPort);
-    pSfOMXComponent->functions->ComponentPortCreate(&pRenderComponent->sinkPort, pSfOMXComponent->hSFComponentRender, 10, sizeof(PortContainerExternal));
+    pSfOMXComponent->functions->ComponentPortCreate(&pRenderComponent->sinkPort, pSfOMXComponent->hSFComponentRender,
+                    pSfOMXComponent->portDefinition[1].nBufferCountActual, sizeof(PortContainerExternal));
 
     if (pSfOMXComponent->functions->SetupEncListenerContext(pSfOMXComponent->lsnCtx, config) == TRUE)
     {
@@ -883,8 +954,8 @@ static OMX_ERRORTYPE SF_OMX_SendCommand(
                 {
                     LOG(SF_LOG_ERR, "Buffer not flush!\r\n")
                     // ret = OMX_ErrorIncorrectStateTransition;
-                    break;
                 }
+                break;
                 pSFComponentEncoder->terminate = OMX_TRUE;
                 pSFComponentFeeder->terminate = OMX_TRUE;
                 pSFComponentRender->terminate = OMX_TRUE;
@@ -944,7 +1015,8 @@ static OMX_ERRORTYPE SF_OMX_SendCommand(
                     pSFComponentEncoder->pause = OMX_TRUE;
                     pSFComponentFeeder->pause = OMX_TRUE;
                     pSFComponentRender->pause = OMX_TRUE;
-                    FlushBuffer(pSfOMXComponent);
+                    FlushBuffer(pSfOMXComponent, 0);
+                    FlushBuffer(pSfOMXComponent, 1);
                 }
                 break;
             }
@@ -982,9 +1054,13 @@ static OMX_ERRORTYPE SF_OMX_SendCommand(
                                                  OMX_EventCmdComplete, OMX_CommandStateSet, nParam, NULL);
         break;
     case OMX_CommandFlush:
+    {
+        OMX_U32 nPort = nParam;
+        FlushBuffer(pSfOMXComponent, nPort);
         pSfOMXComponent->callbacks->EventHandler(pSfOMXComponent->pOMXComponent, pSfOMXComponent->pAppData,
                                                  OMX_EventCmdComplete, OMX_CommandFlush, nParam, NULL);
-        break;
+    }
+    break;
     case OMX_CommandPortDisable:
         pSfOMXComponent->callbacks->EventHandler(pSfOMXComponent->pOMXComponent, pSfOMXComponent->pAppData,
                                                  OMX_EventCmdComplete, OMX_CommandPortDisable, nParam, NULL);

+ 0 - 146
soft_3rdpart/omx-il/tests/wave511test.c

@@ -1,146 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Copyright (C) 2021 StarFive Technology Co., Ltd.
- */
-#include <stdio.h>
-#include <signal.h>
-#include <OMX_Core.h>
-#include <OMX_Component.h>
-#include <OMX_Video.h>
-#include <OMX_IndexExt.h>
-#include <sys/time.h>
-
-#define OMX_INIT_STRUCTURE(a)         \
-    memset(&(a), 0, sizeof(a));       \
-    (a).nSize = sizeof(a);            \
-    (a).nVersion.nVersion = 1;        \
-    (a).nVersion.s.nVersionMajor = 1; \
-    (a).nVersion.s.nVersionMinor = 1; \
-    (a).nVersion.s.nRevision = 1;     \
-    (a).nVersion.s.nStep = 1
-
-OMX_BUFFERHEADERTYPE *pInputBuffer, *pOutputBuffer;
-static int g_is_run  = 0;
-static int numBuffer = 0;
-static OMX_ERRORTYPE event_handler(
-    OMX_HANDLETYPE hComponent,
-    OMX_PTR pAppData,
-    OMX_EVENTTYPE eEvent,
-    OMX_U32 nData1,
-    OMX_U32 nData2,
-    OMX_PTR pEventData)
-{
-
-    return OMX_ErrorNone;
-}
-
-static OMX_ERRORTYPE fill_output_buffer_done_handler(
-    OMX_HANDLETYPE hComponent,
-    OMX_PTR pAppData,
-    OMX_BUFFERHEADERTYPE *pBuffer)
-{
-    struct timeval tv;
-    gettimeofday(&tv,NULL);
-    printf("[%ld], frame = %d\n",tv.tv_sec*1000000 + tv.tv_usec, numBuffer);  //微秒
-    numBuffer ++;
-    //write to file
-    FILE *fb = fopen("./out.dat", "ab+");
-    fwrite(pBuffer->pBuffer, 1, pBuffer->nFilledLen, fb);
-    fclose(fb);
-    OMX_FillThisBuffer(hComponent, pOutputBuffer);
-    return OMX_ErrorNone;
-}
-
-static OMX_ERRORTYPE empty_buffer_done_handler(
-    OMX_HANDLETYPE hComponent,
-    OMX_PTR pAppData,
-    OMX_BUFFERHEADERTYPE *pBuffer)
-{
-    printf("%s:%d:!!!!!!!!!!!!!!!!!!\r\n",__FUNCTION__, __LINE__);
-    //write to file
-    return OMX_ErrorNone;
-}
-
-static void block_until_state_changed(OMX_HANDLETYPE hComponent, OMX_STATETYPE wanted_eState)
-{
-    OMX_STATETYPE eState;
-    while (eState != wanted_eState && g_is_run)
-    {
-        OMX_GetState(hComponent, &eState);
-        if (eState != wanted_eState)
-        {
-            printf("state = %d\r\n", eState);
-            usleep(10000 * 1000);
-        }
-    }
-}
-
-static void signal_handle(int sig)
-{ 
-    printf("[%s,%d]: receive sig=%d \n", __FUNCTION__, __LINE__, sig);
-    if (g_is_run) {
-        OMX_Deinit();
-        g_is_run = 0;
-    }
-}
-
-//TODO: callback, parameter, buffer
-int main(void)
-{
-    printf("=============================\r\n");
-    OMX_HANDLETYPE hComponentDecoder;
-
-    OMX_CALLBACKTYPE callbacks;
-    int ret = OMX_ErrorNone;
-
-    signal(SIGINT, signal_handle);
-
-    ret = OMX_Init();
-    if (ret != OMX_ErrorNone) {
-        printf("[%s,%d]: run OMX_Init failed. ret is %d \n", __FUNCTION__, __LINE__, ret);
-        return 1;
-    }
-    g_is_run = 1;
-
-    callbacks.EventHandler = event_handler;
-    callbacks.FillBufferDone = fill_output_buffer_done_handler;
-    callbacks.EmptyBufferDone = empty_buffer_done_handler;
-    OMX_GetHandle(&hComponentDecoder, "sf.dec.decoder", NULL, &callbacks);
-
-    if (hComponentDecoder == NULL)
-    {
-        printf("could not get handle\r\n");
-        return 0;
-    }
-
-    OMX_SetParameter(hComponentDecoder, OMX_IndexParamVideoHevc, NULL);
-
-    OMX_SendCommand(hComponentDecoder, OMX_CommandStateSet, OMX_StateIdle, NULL);
-
-    FILE *fb = fopen("./stream/hevc/akiyo.cfg_ramain_tv0.cfg.265", "r");
-    if (fb == NULL)
-    {
-        printf("%s:%d can not open file\r\n", __FUNCTION__, __LINE__);
-    }
-    int curpos = ftell(fb);
-    fseek(fb,0L,SEEK_END);
-    int size = ftell(fb);
-    fseek(fb,curpos,SEEK_SET);
-    printf("%s:%d size = %d\r\n", __FUNCTION__, __LINE__, size);
-    
-    OMX_AllocateBuffer(hComponentDecoder, &pInputBuffer, 0, NULL, size);
-    OMX_AllocateBuffer(hComponentDecoder, &pOutputBuffer, 0, NULL, 0x20000);
-
-    int len = fread(pInputBuffer->pBuffer, 1, size, fb);
-    printf("%s:%d:size = %d\r\n",__FUNCTION__, __LINE__, len);
-    
-    OMX_SendCommand(hComponentDecoder, OMX_CommandStateSet, OMX_StateExecuting, NULL);
-    OMX_EmptyThisBuffer(hComponentDecoder, pInputBuffer);
-    OMX_FillThisBuffer(hComponentDecoder, pOutputBuffer);
-    // OMX_FillThisBuffer(hComponentDecoder, pOutputBuffer);
-
-    block_until_state_changed(hComponentDecoder, OMX_StateIdle);
-
-    OMX_FreeHandle(hComponentDecoder);
-    return 0;
-}

+ 0 - 123
soft_3rdpart/omx-il/tests/wave521test.c

@@ -1,123 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Copyright (C) 2021 StarFive Technology Co., Ltd.
- */
-#include <stdio.h>
-#include <signal.h>
-#include <OMX_Core.h>
-#include <OMX_Component.h>
-#include <OMX_Video.h>
-
-#define OMX_INIT_STRUCTURE(a)         \
-    memset(&(a), 0, sizeof(a));       \
-    (a).nSize = sizeof(a);            \
-    (a).nVersion.nVersion = 1;        \
-    (a).nVersion.s.nVersionMajor = 1; \
-    (a).nVersion.s.nVersionMinor = 1; \
-    (a).nVersion.s.nRevision = 1;     \
-    (a).nVersion.s.nStep = 1
-
-static OMX_ERRORTYPE event_handler(
-    OMX_HANDLETYPE hComponent,
-    OMX_PTR pAppData,
-    OMX_EVENTTYPE eEvent,
-    OMX_U32 nData1,
-    OMX_U32 nData2,
-    OMX_PTR pEventData)
-{
-
-    return OMX_ErrorNone;
-}
-
-static OMX_ERRORTYPE fill_output_buffer_done_handler(
-    OMX_HANDLETYPE hComponent,
-    OMX_PTR pAppData,
-    OMX_BUFFERHEADERTYPE *pBuffer)
-{
-
-    return OMX_ErrorNone;
-}
-
-static void block_until_state_changed(OMX_HANDLETYPE hComponent, OMX_STATETYPE wanted_eState)
-{
-    OMX_STATETYPE eState;
-    while (eState != wanted_eState)
-    {
-        OMX_GetState(hComponent, &eState);
-        if (eState != wanted_eState)
-        {
-            printf("state = %d\r\n", eState);
-            usleep(1000 * 1000);
-        }
-    }
-}
-
-static int g_is_run  = 0;
-static void signal_handle(int sig)
-{ 
-    printf("[%s,%d]: receive sig=%d \n", __FUNCTION__, __LINE__, sig);
-    if (g_is_run) {
-        OMX_Deinit();
-        g_is_run = 0;
-    }
-}
-
-//TODO: callback, parameter, buffer
-int main(void)
-{
-    printf("=============================\r\n");
-    OMX_HANDLETYPE hComponentEncoder;
-    OMX_HANDLETYPE hComponentFeeder;
-    OMX_HANDLETYPE hComponentReader;
-    OMX_CALLBACKTYPE callbacks;
-    int ret = OMX_ErrorNone;
-
-    signal(SIGINT, signal_handle);
-
-    ret = OMX_Init();
-    if (ret != OMX_ErrorNone) {
-        printf("[%s,%d]: run OMX_Init failed. ret is %d \n", __FUNCTION__, __LINE__, ret);
-        return 1;
-    }
-    g_is_run = 1;
-
-    callbacks.EventHandler = event_handler;
-    callbacks.FillBufferDone = fill_output_buffer_done_handler;
-    OMX_GetHandle(&hComponentEncoder, "sf.enc.encoder", NULL, &callbacks);
-    OMX_GetHandle(&hComponentFeeder, "sf.enc.feeder", NULL, &callbacks);
-    OMX_GetHandle(&hComponentReader, "sf.enc.reader", NULL, &callbacks);
-    if (hComponentEncoder == NULL || hComponentFeeder == NULL || hComponentReader == NULL)
-    {
-        printf("could not get handle\r\n");
-        return 0;
-    }
-
-    OMX_SetParameter(hComponentFeeder, OMX_IndexConfigCommonInputCrop, "./yuv/mix_1920x1080_8b_9frm.yuv");
-
-    OMX_SetParameter(hComponentReader, OMX_IndexConfigCommonOutputCrop, "./output/inter_8b_11.cfg.265");
-
-    OMX_SetParameter(hComponentEncoder, OMX_IndexParamOtherPortFormat, "./cfg/hevc_fhd_inter_8b_11.cfg");
-    OMX_SetParameter(hComponentFeeder, OMX_IndexParamOtherPortFormat, "./cfg/hevc_fhd_inter_8b_11.cfg");
-    OMX_SetParameter(hComponentReader, OMX_IndexParamOtherPortFormat, "./cfg/hevc_fhd_inter_8b_11.cfg");
-
-    OMX_SendCommand(hComponentEncoder, OMX_CommandStateSet, OMX_StateIdle, NULL);
-    OMX_SendCommand(hComponentFeeder, OMX_CommandStateSet, OMX_StateIdle, NULL);
-    OMX_SendCommand(hComponentReader, OMX_CommandStateSet, OMX_StateIdle, NULL);
-
-    OMX_SetupTunnel(hComponentFeeder, 0, hComponentEncoder, 0);
-    OMX_SetupTunnel(hComponentEncoder, 0, hComponentReader, 0);
-
-    OMX_SendCommand(hComponentFeeder, OMX_CommandStateSet, OMX_StateExecuting, NULL);
-    OMX_SendCommand(hComponentEncoder, OMX_CommandStateSet, OMX_StateExecuting, NULL);
-    OMX_SendCommand(hComponentReader, OMX_CommandStateSet, OMX_StateExecuting, NULL);
-
-    block_until_state_changed(hComponentFeeder, OMX_StateIdle);
-    block_until_state_changed(hComponentEncoder, OMX_StateIdle);
-    block_until_state_changed(hComponentReader, OMX_StateIdle);
-
-    OMX_FreeHandle(hComponentFeeder);
-    OMX_FreeHandle(hComponentEncoder);
-    OMX_FreeHandle(hComponentReader);
-    OMX_Deinit();
-    return 0;
-}

+ 5 - 4
soft_3rdpart/wave511/code/sample_v2/component_decoder/component_dec_renderer.c

@@ -494,6 +494,7 @@ static BOOL ExecuteRenderer(ComponentImpl* com, PortContainer* in, PortContainer
             if (FALSE ==GetYUVFromFrameBuffer2(NULL, &dmaBuffer, output->nFilledLen, ctx->handle, &srcData->decInfo.dispFrame, rcDisplay, &width, &height, &bpp, &sizeYuv)) {
                 VLOG(ERR, "GetYUVFromFrameBuffer2 FAIL!\n");
             }
+            output->nFilledLen = sizeYuv;
             total_count = Queue_Get_Cnt(com->sinkPort.inputQ);
             while (output->pBuffer != dmaBuffer)
             {
@@ -501,10 +502,11 @@ static BOOL ExecuteRenderer(ComponentImpl* com, PortContainer* in, PortContainer
                 Queue_Enqueue(com->sinkPort.inputQ, (void *)output);
                 output = (PortContainerExternal*)ComponentPortPeekData(&com->sinkPort);
                 VLOG(INFO, "pBuffer = %p, dmaBuffer = %p, index = %d/%d\n", output->pBuffer, dmaBuffer, count, total_count);
-                if (count > total_count)
+                if (count >= total_count)
                 {
-                    com->terminate = TRUE;
-                    return FALSE;
+                    VLOG(ERR, "A wrong Frame Found\n");
+                    output->nFilledLen = 0;
+                    break;
                 }
                 count ++;
             }
@@ -513,7 +515,6 @@ static BOOL ExecuteRenderer(ComponentImpl* com, PortContainer* in, PortContainer
                 VLOG(ERR, "GetYUVFromFrameBuffer2 FAIL!\n");
             }
         }
-        output->nFilledLen = sizeYuv;
         output->nFlags = srcData->decInfo.indexFrameDisplay;
         ComponentPortGetData(&com->sinkPort);
         ComponentNotifyListeners(com, COMPONENT_EVENT_DEC_FILL_BUFFER_DONE, (void *)output);

+ 2 - 3
soft_3rdpart/wave511/code/sample_v2/helper/main_helper.c

@@ -1144,7 +1144,7 @@ void *AllocateDecFrameBuffer2(DecHandle decHandle, TestDecConfig* config, Uint32
     frameBufferAllocInfo.num = 1;
 
     vdi_allocate_dma_memory(coreIndex, vb, DEC_FB_LINEAR, decHandle->instIndex);
-    VLOG(ERR, "%lx %lx %lx\r\n", vb->base, vb->virt_addr, vb->phys_addr);
+    VLOG(INFO, "base = %lx virt_addr = %lx phys_addr = %lx\r\n", vb->base, vb->virt_addr, vb->phys_addr);
     retFbArray->bufY  = vb->phys_addr;
     retFbArray->bufCb = (PhysicalAddress)-1;
     retFbArray->bufCr = (PhysicalAddress)-1;
@@ -1175,7 +1175,7 @@ BOOL AttachDecDMABuffer(DecHandle decHandle, TestDecConfig* config, Uint64 virtA
     vdi_virt_to_phys(coreIndex, vb);
 
     vdi_attach_dma_memory(coreIndex, vb);
-    VLOG(ERR, "%lx %lx %x\r\n", vb->base, vb->virt_addr, vb->phys_addr);
+    VLOG(INFO, "base addr = %lx virt addr= %lx phys addr = %x\r\n", vb->base, vb->virt_addr, vb->phys_addr);
 
     retFbArray->bufY  = vb->phys_addr;
     retFbArray->bufCb = (PhysicalAddress)-1;
@@ -1262,7 +1262,6 @@ BOOL AllocateDecFrameBuffer(
     *retStride     = seqInfo.picWidth;
     framebufStride = CalcStride(seqInfo.picWidth, seqInfo.picHeight, format, config->cbcrInterleave, config->mapType, FALSE);
     framebufHeight = seqInfo.picHeight;
-    VLOG(ERR, "height = %d\r\n", framebufHeight);
     framebufSize   = VPU_GetFrameBufSize(decHandle, decHandle->coreIdx, framebufStride, framebufHeight,
                                             config->mapType, format, config->cbcrInterleave, pDramCfg);
 #else

+ 5 - 3
soft_3rdpart/wave511/code/sample_v2/helper/misc/cnm_video_helper.c

@@ -2123,10 +2123,11 @@ void LoadSrcYUV2(
     //base address
     baseY  = fbSrc->bufY;
 
-    VLOG(INFO, "%s %d %x %x %x \r\n", __FUNCTION__, __LINE__, fbSrc->bufY, fbSrc->bufCb, fbSrc->bufCr);
+    VLOG(INFO, "%s %d baseY = %x stride = %d srcHeightY = %d endian = %d\r\n",
+        __FUNCTION__, __LINE__, baseY, stride, srcHeightY, endian);
     
 
-    vdi_read_memory2(coreIdx, fbSrc->bufY, &pY, stride * srcHeightY, endian);
+    int ret = vdi_read_memory2(coreIdx, fbSrc->bufY, &pY, stride * srcHeightY, endian);
 
 #if defined(SAVE_YUV)
 #else
@@ -2139,7 +2140,8 @@ void LoadSrcYUV2(
 
     pix_addr = fbSrc->bufY + 0xffffffff00000000;
     rowBufferY = pY + (pix_addr - baseY);
-    VLOG(INFO, "%s %d %x %p %p %p\n", __FUNCTION__, __LINE__, pix_addr, rowBufferY, pSrc, pSrc2);
+    VLOG(INFO, "%s %d ret = %d, pix_addr = %lx,  pY = %p, rowBufferY = %p pSrc = %p pSrc2 = %p\n",
+        __FUNCTION__, __LINE__, ret, pix_addr, pY, rowBufferY, pSrc, pSrc2);
     if (pSrc) {
         osal_memcpy(pSrc, rowBufferY, srcHeightY*srcWidthY*3/2);
     }

+ 2 - 2
soft_3rdpart/wave511/code/vdi/linux/vdi_osal.c

@@ -52,7 +52,7 @@ static int peek_character = -1;
 static unsigned log_decor = LOG_HAS_TIME | LOG_HAS_FILE | LOG_HAS_MICRO_SEC |
 			    LOG_HAS_NEWLINE |
 			    LOG_HAS_SPACE | LOG_HAS_COLOR;
-static int max_log_level = NONE; //MAX_LOG_LEVEL;
+static int max_log_level = ERR;
 static FILE *fpLog  = NULL;
 
 #if defined(SUPPORT_SW_UART) || defined(SUPPORT_SW_UART_V2)
@@ -61,7 +61,7 @@ static pthread_mutex_t s_log_mutex;
 
 int InitLog()
 {
-	fpLog = osal_fopen("/tmp/VPU_ErrorLog.txt", "w");
+	fpLog = osal_fopen("/tmp/DecoderErrorLog.txt", "w");
 #if defined(SUPPORT_SW_UART) || defined(SUPPORT_SW_UART_V2)
 	pthread_mutex_init(&s_log_mutex, NULL);
 #endif

+ 9 - 1
soft_3rdpart/wave511/code/vdi/vdi_osal.h

@@ -31,7 +31,15 @@
 #include <ctype.h>
 #include "vputypes.h"
 
-enum {NONE=0, INFO, WARN, ERR, TRACE, MAX_LOG_LEVEL};
+enum
+{
+    ERR=0,
+    WARN,
+    TRACE,
+    INFO,
+    MAX_LOG_LEVEL
+};
+
 enum
 {
     LOG_HAS_DAY_NAME   =    1, /**< Include day name [default: no] 	      */

+ 1 - 1
soft_3rdpart/wave521/code/sample_v2/component_encoder/component_enc_feeder.c

@@ -484,8 +484,8 @@ static BOOL ExecuteYuvFeeder(ComponentImpl* com, PortContainer* in, PortContaine
     }
 #ifdef USE_FEEDING_METHOD_BUFFER
     if (input != NULL) {
-        ComponentNotifyListeners(com, COMPONENT_EVENT_ENC_EMPTY_BUFFER_DONE, (void *)input);
         ComponentPortGetData(&com->srcPort);
+        ComponentNotifyListeners(com, COMPONENT_EVENT_ENC_EMPTY_BUFFER_DONE, (void *)input);
     }
     if ((input->nFlags & 0x1) == 0x1)
     {

+ 3 - 3
soft_3rdpart/wave521/code/sample_v2/component_encoder/component_enc_reader.c

@@ -170,8 +170,8 @@ static BOOL ExecuteReader(ComponentImpl* com, PortContainer* in, PortContainer*
                     else {
                         output->nFlags = 0x10;
                     }
-                    ComponentNotifyListeners(com, COMPONENT_EVENT_ENC_FILL_BUFFER_DONE, (void *)output);
                     ComponentPortGetData(&com->sinkPort);
+                    ComponentNotifyListeners(com, COMPONENT_EVENT_ENC_FILL_BUFFER_DONE, (void *)output);
 #else
                     if (ctx->fp) {
                         osal_fwrite(buf, readSize, 1, ctx->fp);
@@ -193,8 +193,8 @@ static BOOL ExecuteReader(ComponentImpl* com, PortContainer* in, PortContainer*
                         else {
                             output->nFlags = 0x10;
                         }
-                        ComponentNotifyListeners(com, COMPONENT_EVENT_ENC_FILL_BUFFER_DONE, (void *)output);
                         ComponentPortGetData(&com->sinkPort);
+                        ComponentNotifyListeners(com, COMPONENT_EVENT_ENC_FILL_BUFFER_DONE, (void *)output);
 #else
                         if (ctx->fp) {
                             osal_fwrite(buf, readSize, 1, ctx->fp);
@@ -232,8 +232,8 @@ static BOOL ExecuteReader(ComponentImpl* com, PortContainer* in, PortContainer*
                     output->nFlags = 0x10;
                 }
 
-                ComponentNotifyListeners(com, COMPONENT_EVENT_ENC_FILL_BUFFER_DONE, (void *)output);
                 ComponentPortGetData(&com->sinkPort);
+                ComponentNotifyListeners(com, COMPONENT_EVENT_ENC_FILL_BUFFER_DONE, (void *)output);
 #else
                 Uint8* buf = (Uint8*)osal_malloc(srcData->size);
                 if (ctx->bsReader != 0) {

+ 3 - 1
soft_3rdpart/wave521/code/sample_v2/helper/bitstream/bitstreamreader.c

@@ -43,7 +43,9 @@ BitstreamReader BitstreamReader_Create(
 {
     AbstractBitstreamReader* reader;
     osal_file_t *fp=NULL;
+#ifdef USE_FEEDING_METHOD_BUFFER
 
+#else
     if ( path[0] != 0) {
         if ((fp=osal_fopen(path, "wb")) == NULL) {
             VLOG(ERR, "%s:%d failed to open bin file: %s\n", __FUNCTION__, __LINE__, path);
@@ -53,7 +55,7 @@ BitstreamReader BitstreamReader_Create(
     }
     else
         VLOG(ERR, "%s:%d Bitstream File path is NULL : no save\n", __FUNCTION__, __LINE__);
-
+#endif
     reader = (AbstractBitstreamReader*)osal_malloc(sizeof(AbstractBitstreamReader));
 
     reader->fp      = fp;

+ 2 - 2
soft_3rdpart/wave521/code/vdi/linux/vdi_osal.c

@@ -52,7 +52,7 @@ static int peek_character = -1;
 static unsigned log_decor = LOG_HAS_TIME | LOG_HAS_FILE | LOG_HAS_MICRO_SEC |
 			    LOG_HAS_NEWLINE |
 			    LOG_HAS_SPACE | LOG_HAS_COLOR;
-static int max_log_level = NONE;
+static int max_log_level = ERR;
 static FILE *fpLog  = NULL;
 
 #if defined(SUPPORT_SW_UART) || defined(SUPPORT_SW_UART_V2)
@@ -61,7 +61,7 @@ static pthread_mutex_t s_log_mutex;
 
 int InitLog()
 {
-	fpLog = osal_fopen("ErrorLog.txt", "w");
+	fpLog = osal_fopen("/tmp/EncoderErrorLog.txt", "w");
 #if defined(SUPPORT_SW_UART) || defined(SUPPORT_SW_UART_V2)
 	pthread_mutex_init(&s_log_mutex, NULL);
 #endif

+ 9 - 1
soft_3rdpart/wave521/code/vdi/vdi_osal.h

@@ -31,7 +31,15 @@
 #include <ctype.h>
 #include "vputypes.h"
 
-enum {NONE=0, INFO, WARN, ERR, TRACE, MAX_LOG_LEVEL};
+enum
+{
+    ERR=0,
+    WARN,
+    TRACE,
+    INFO,
+    MAX_LOG_LEVEL
+};
+
 enum
 {
     LOG_HAS_DAY_NAME   =    1, /**< Include day name [default: no] 	      */