Переглянути джерело

Merge branch 'CR_6788_OMX_Som.Qin' into 'jh7110-devel'

CR 6788 merge omx patch from debian repository to sdk

See merge request sdk/soft_3rdpart!66
andy.hu 9 місяців тому
батько
коміт
cd9d964196

+ 1 - 1
codaj12/jdi/linux/jdi.c

@@ -645,7 +645,7 @@ int jdi_allocate_dma_memory(jpu_buffer_t *vb)
     vb->base = (unsigned long)jdb.base;
     vb->base = (unsigned long)jdb.base;
 
 
     //map to virtual address
     //map to virtual address
-    jdb.virt_addr = (unsigned long)mmap(NULL, jdb.size, PROT_READ | PROT_WRITE, MAP_SHARED, jdi->jpu_fd, MEM2SYS(jdb.phys_addr));
+    jdb.virt_addr = (unsigned long)mmap(NULL, jdb.size, PROT_READ | PROT_WRITE, MAP_SHARED, jdi->jpu_fd, jdb.phys_addr);
     if (jdb.virt_addr == (unsigned long)MAP_FAILED) {
     if (jdb.virt_addr == (unsigned long)MAP_FAILED) {
         memset(vb, 0x00, sizeof(jpu_buffer_t));
         memset(vb, 0x00, sizeof(jpu_buffer_t));
         return -1;
         return -1;

+ 17 - 5
codaj12/sample/helper/jpuhelper.c

@@ -1416,7 +1416,7 @@ BOOL AttachOneFrameBuffer(Uint32 instIdx, FrameFormat subsample, CbCrInterLeave
 }
 }
 
 
 void *AllocateOneFrameBuffer(Uint32 instIdx, FrameFormat subsample, CbCrInterLeave cbcrIntlv, PackedFormat packed,
 void *AllocateOneFrameBuffer(Uint32 instIdx, FrameFormat subsample, CbCrInterLeave cbcrIntlv, PackedFormat packed,
-                         Uint32 rotation, BOOL scalerOn, Uint32 width, Uint32 height, Uint32 bitDepth, Uint32 *bufferIndex)
+                         Uint32 rotation, BOOL scalerOn, Uint32 width, Uint32 height, Uint32 bitDepth, Uint32 bufferIndex)
 {
 {
     fb_context *fb;
     fb_context *fb;
     Uint32  fbLumaStride, fbLumaHeight, fbChromaStride, fbChromaHeight;
     Uint32  fbLumaStride, fbLumaHeight, fbChromaStride, fbChromaHeight;
@@ -1471,9 +1471,10 @@ void *AllocateOneFrameBuffer(Uint32 instIdx, FrameFormat subsample, CbCrInterLea
         JLOG(ERR, "Fail to allocate frame buffer size=%d\n", fb->vb_base.size);
         JLOG(ERR, "Fail to allocate frame buffer size=%d\n", fb->vb_base.size);
         return NULL;
         return NULL;
     }
     }
+    fb->vb[bufferIndex] = fb->vb_base;
     fb->last_addr = fb->vb_base.phys_addr;
     fb->last_addr = fb->vb_base.phys_addr;
 
 
-    i = fb->last_num;
+    i = bufferIndex;
     JLOG(INFO, "%s: store on index %d\r\n", __FUNCTION__, i);
     JLOG(INFO, "%s: store on index %d\r\n", __FUNCTION__, i);
     fb->frameBuf[i].Format = subsample;
     fb->frameBuf[i].Format = subsample;
     fb->frameBuf[i].Index  = i;
     fb->frameBuf[i].Index  = i;
@@ -1502,10 +1503,8 @@ void *AllocateOneFrameBuffer(Uint32 instIdx, FrameFormat subsample, CbCrInterLea
     fb->frameBuf[i].strideY = fbLumaStride;
     fb->frameBuf[i].strideY = fbLumaStride;
     fb->frameBuf[i].strideC = fbChromaStride;
     fb->frameBuf[i].strideC = fbChromaStride;
 
 
-    *bufferIndex = fb->last_num;
-    fb->last_num += 1;
-
     virt_addr = (void *)fb->vb_base.virt_addr;
     virt_addr = (void *)fb->vb_base.virt_addr;
+    fb->last_num = bufferIndex + 1;
 
 
     JLOG(INFO, "%s function OUT, number = %d, return = %p\r\n", __FUNCTION__, fb->last_num, virt_addr);
     JLOG(INFO, "%s function OUT, number = %d, return = %p\r\n", __FUNCTION__, fb->last_num, virt_addr);
     return virt_addr;
     return virt_addr;
@@ -1934,6 +1933,19 @@ FRAME_BUF* FindFrameBuffer(int instIdx, PhysicalAddress addrY)
     return NULL;
     return NULL;
 }
 }
 
 
+void FreeOneFrameBuffer(int instIdx, unsigned int bufferIndex)
+{
+    fb_context *fb;
+
+    fb = &s_fb[instIdx];
+
+    if(fb->vb[bufferIndex].base)
+    {
+        jdi_free_dma_memory(&fb->vb[bufferIndex]);
+        fb->vb[bufferIndex].base = 0;
+    }
+}
+
 void FreeFrameBuffer(int instIdx)
 void FreeFrameBuffer(int instIdx)
 {
 {
     fb_context *fb;
     fb_context *fb;

+ 2 - 0
codaj12/sample/main_helper.h

@@ -53,6 +53,7 @@ typedef struct {
 
 
 typedef struct {
 typedef struct {
     FRAME_BUF frameBuf[MAX_FRAME];
     FRAME_BUF frameBuf[MAX_FRAME];
+    jpu_buffer_t vb[MAX_FRAME];
     jpu_buffer_t vb_base;
     jpu_buffer_t vb_base;
     int instIndex;
     int instIndex;
     int last_num;
     int last_num;
@@ -247,6 +248,7 @@ extern BOOL ParseMultiLongOptions(TestMultiConfig* config, const char* argName,
 extern BOOL AllocateFrameBuffer(Uint32 instIdx, FrameFormat subsample, CbCrInterLeave cbcrIntlv, PackedFormat packed,
 extern BOOL AllocateFrameBuffer(Uint32 instIdx, FrameFormat subsample, CbCrInterLeave cbcrIntlv, PackedFormat packed,
                                 Uint32 rotation, BOOL scalerOn, Uint32 width, Uint32 height, Uint32 bitDepth, Uint32 num);
                                 Uint32 rotation, BOOL scalerOn, Uint32 width, Uint32 height, Uint32 bitDepth, Uint32 num);
 extern void FreeFrameBuffer(int instIdx);
 extern void FreeFrameBuffer(int instIdx);
+extern void FreeOneFrameBuffer(int instIdx, unsigned int bufferIndex);
 extern FRAME_BUF *GetFrameBuffer(int instIdx, int index);
 extern FRAME_BUF *GetFrameBuffer(int instIdx, int index);
 extern int GetFrameBufBase(int instIdx);
 extern int GetFrameBufBase(int instIdx);
 extern int GetFrameBufAllocSize(int instIdx);
 extern int GetFrameBufAllocSize(int instIdx);

+ 15 - 15
omx-il/component/image/common/SF_OMX_mjpeg_common.c

@@ -280,6 +280,7 @@ static void sf_get_component_functions(SF_CODAJ12_FUNCTIONS *funcs, OMX_PTR *soh
     funcs->AllocateOneFrameBuffer = dlsym(sohandle, "AllocateOneFrameBuffer");
     funcs->AllocateOneFrameBuffer = dlsym(sohandle, "AllocateOneFrameBuffer");
     funcs->AllocateFrameBuffer = dlsym(sohandle, "AllocateFrameBuffer");
     funcs->AllocateFrameBuffer = dlsym(sohandle, "AllocateFrameBuffer");
     funcs->FreeFrameBuffer = dlsym(sohandle, "FreeFrameBuffer");
     funcs->FreeFrameBuffer = dlsym(sohandle, "FreeFrameBuffer");
+    funcs->FreeOneFrameBuffer = dlsym(sohandle, "FreeOneFrameBuffer");
     funcs->GetFrameBuffer = dlsym(sohandle, "GetFrameBuffer");
     funcs->GetFrameBuffer = dlsym(sohandle, "GetFrameBuffer");
     funcs->GetFrameBufferCount = dlsym(sohandle, "GetFrameBufferCount");
     funcs->GetFrameBufferCount = dlsym(sohandle, "GetFrameBufferCount");
     funcs->UpdateFrameBuffers = dlsym(sohandle, "UpdateFrameBuffers");
     funcs->UpdateFrameBuffers = dlsym(sohandle, "UpdateFrameBuffers");
@@ -427,7 +428,7 @@ OMX_BOOL AttachOutputBuffer(SF_OMX_COMPONENT *pSfOMXComponent, OMX_U8* pBuffer,
 
 
 }
 }
 
 
-OMX_U8 *AllocateOutputBuffer(SF_OMX_COMPONENT *pSfOMXComponent, OMX_U32 nSizeBytes)
+OMX_U8 *AllocateOutputBuffer(SF_OMX_COMPONENT *pSfOMXComponent, OMX_U32 nBufferIndex, OMX_U32 nSizeBytes)
 {
 {
     SF_CODAJ12_IMPLEMEMT *pSfCodaj12Implement = pSfOMXComponent->componentImpl;
     SF_CODAJ12_IMPLEMEMT *pSfCodaj12Implement = pSfOMXComponent->componentImpl;
     Int32 instIdx = pSfCodaj12Implement->instIdx;
     Int32 instIdx = pSfCodaj12Implement->instIdx;
@@ -444,7 +445,6 @@ OMX_U8 *AllocateOutputBuffer(SF_OMX_COMPONENT *pSfOMXComponent, OMX_U32 nSizeByt
     FrameFormat subsample;
     FrameFormat subsample;
     Uint32 temp;
     Uint32 temp;
     OMX_U8 *virtAddr;
     OMX_U8 *virtAddr;
-    Uint32 bufferIndex;
     JpgRet jpgret;
     JpgRet jpgret;
 
 
     CbCrInterLeave chromaInterleave;
     CbCrInterLeave chromaInterleave;
@@ -552,29 +552,29 @@ OMX_U8 *AllocateOutputBuffer(SF_OMX_COMPONENT *pSfOMXComponent, OMX_U32 nSizeByt
                 scalerOn, decodingWidth, decodingHeight, bitDepth);
                 scalerOn, decodingWidth, decodingHeight, bitDepth);
     virtAddr = (OMX_U8 *)pSfCodaj12Implement->functions->AllocateOneFrameBuffer
     virtAddr = (OMX_U8 *)pSfCodaj12Implement->functions->AllocateOneFrameBuffer
         (instIdx, subsample, chromaInterleave, packedFormat, decConfig->rotation,
         (instIdx, subsample, chromaInterleave, packedFormat, decConfig->rotation,
-        scalerOn, decodingWidth, decodingHeight, bitDepth, &bufferIndex);
+        scalerOn, decodingWidth, decodingHeight, bitDepth, nBufferIndex);
     if (virtAddr == NULL)
     if (virtAddr == NULL)
     {
     {
         LOG(SF_LOG_ERR, "Failed to AllocateOneFrameBuffer()\n");
         LOG(SF_LOG_ERR, "Failed to AllocateOneFrameBuffer()\n");
         return NULL;
         return NULL;
     }
     }
-    LOG(SF_LOG_INFO, "Allocate frame buffer %p, index = %d\r\n", virtAddr, bufferIndex);
+    LOG(SF_LOG_INFO, "Allocate frame buffer %p, index = %d\r\n", virtAddr, nBufferIndex);
 
 
     //Register frame buffer
     //Register frame buffer
-    FRAME_BUF *pFrame = pSfCodaj12Implement->functions->GetFrameBuffer(instIdx, bufferIndex);
-    memcpy(&pSfCodaj12Implement->frame[bufferIndex], pFrame, sizeof(FRAME_BUF));
-    pFrameBuf[bufferIndex].bufY = pFrame->vbY.phys_addr;
-    pFrameBuf[bufferIndex].bufCb = pFrame->vbCb.phys_addr;
+    FRAME_BUF *pFrame = pSfCodaj12Implement->functions->GetFrameBuffer(instIdx, nBufferIndex);
+    memcpy(&pSfCodaj12Implement->frame[nBufferIndex], pFrame, sizeof(FRAME_BUF));
+    pFrameBuf[nBufferIndex].bufY = pFrame->vbY.phys_addr;
+    pFrameBuf[nBufferIndex].bufCb = pFrame->vbCb.phys_addr;
     if (decOP->chromaInterleave == CBCR_SEPARATED)
     if (decOP->chromaInterleave == CBCR_SEPARATED)
-        pFrameBuf[bufferIndex].bufCr = pFrame->vbCr.phys_addr;
-    pFrameBuf[bufferIndex].stride = pFrame->strideY;
-    pFrameBuf[bufferIndex].strideC = pFrame->strideC;
-    pFrameBuf[bufferIndex].endian = decOP->frameEndian;
-    pFrameBuf[bufferIndex].format = (FrameFormat)pFrame->Format;
-    framebufStride = pFrameBuf[bufferIndex].stride;
+        pFrameBuf[nBufferIndex].bufCr = pFrame->vbCr.phys_addr;
+    pFrameBuf[nBufferIndex].stride = pFrame->strideY;
+    pFrameBuf[nBufferIndex].strideC = pFrame->strideC;
+    pFrameBuf[nBufferIndex].endian = decOP->frameEndian;
+    pFrameBuf[nBufferIndex].format = (FrameFormat)pFrame->Format;
+    framebufStride = pFrameBuf[nBufferIndex].stride;
 
 
     // may be handle == NULL on ffmpeg case
     // may be handle == NULL on ffmpeg case
-    jpgret = pSfCodaj12Implement->functions->JPU_DecRegisterFrameBuffer2(handle, &pFrameBuf[bufferIndex], framebufStride);
+    jpgret = pSfCodaj12Implement->functions->JPU_DecRegisterFrameBuffer2(handle, &pFrameBuf[nBufferIndex], framebufStride);
     LOG(SF_LOG_DEBUG, "JPU_DecRegisterFrameBuffer2 ret = %d\r\n", jpgret);
     LOG(SF_LOG_DEBUG, "JPU_DecRegisterFrameBuffer2 ret = %d\r\n", jpgret);
     FunctionOut();
     FunctionOut();
     return virtAddr;
     return virtAddr;

+ 3 - 3
omx-il/component/image/common/SF_OMX_mjpeg_common.h

@@ -79,13 +79,13 @@ typedef struct _SF_CODAJ12_FUNCTIONS
     void *(*AllocateOneFrameBuffer)
     void *(*AllocateOneFrameBuffer)
     // (Uint32 instIdx, Uint32 size, Uint32 *bufferIndex);
     // (Uint32 instIdx, Uint32 size, Uint32 *bufferIndex);
     (Uint32 instIdx, FrameFormat subsample, CbCrInterLeave cbcrIntlv,
     (Uint32 instIdx, FrameFormat subsample, CbCrInterLeave cbcrIntlv,
-     PackedFormat packed, Uint32 rotation, BOOL scalerOn, Uint32 width, Uint32 height, Uint32 bitDepth, Uint32 *bufferIndex);
+     PackedFormat packed, Uint32 rotation, BOOL scalerOn, Uint32 width, Uint32 height, Uint32 bitDepth, Uint32 bufferIndex);
     int (*SaveYuvImageHelper)(Uint8* pYuv, FrameBuffer* fb, CbCrInterLeave interLeave, PackedFormat packed,
     int (*SaveYuvImageHelper)(Uint8* pYuv, FrameBuffer* fb, CbCrInterLeave interLeave, PackedFormat packed,
                         Uint32 picWidth, Uint32 picHeight, Uint32 bitDepth);
                         Uint32 picWidth, Uint32 picHeight, Uint32 bitDepth);
     int (*SaveYuvImageHelperDma)(Uint8* pYuv, FrameBuffer* fb, CbCrInterLeave interLeave, PackedFormat packed,
     int (*SaveYuvImageHelperDma)(Uint8* pYuv, FrameBuffer* fb, CbCrInterLeave interLeave, PackedFormat packed,
                         Uint32 picWidth, Uint32 picHeight, Uint32 bitDepth);
                         Uint32 picWidth, Uint32 picHeight, Uint32 bitDepth);
-    int (*FreeOneFrameBuffer)(Uint32 instIdx, void* virt_addr);
     void (*FreeFrameBuffer)(int instIdx);
     void (*FreeFrameBuffer)(int instIdx);
+    void (*FreeOneFrameBuffer)(int instIdx, unsigned int bufferIndex);
     FRAME_BUF *(*GetFrameBuffer)(int instIdx, int idx);
     FRAME_BUF *(*GetFrameBuffer)(int instIdx, int idx);
     Uint32 (*GetFrameBufferCount)(int instIdx);
     Uint32 (*GetFrameBufferCount)(int instIdx);
     BOOL (*AttachOneFrameBuffer)(Uint32 instIdx, FrameFormat subsample, CbCrInterLeave cbcrIntlv, PackedFormat packed,
     BOOL (*AttachOneFrameBuffer)(Uint32 instIdx, FrameFormat subsample, CbCrInterLeave cbcrIntlv, PackedFormat packed,
@@ -152,7 +152,7 @@ extern "C"
 OMX_ERRORTYPE GetStateMjpegCommon(OMX_IN OMX_HANDLETYPE hComponent, OMX_OUT OMX_STATETYPE *pState);
 OMX_ERRORTYPE GetStateMjpegCommon(OMX_IN OMX_HANDLETYPE hComponent, OMX_OUT OMX_STATETYPE *pState);
 OMX_ERRORTYPE InitMjpegStructorCommon(SF_OMX_COMPONENT *hComponent);
 OMX_ERRORTYPE InitMjpegStructorCommon(SF_OMX_COMPONENT *hComponent);
 OMX_BOOL AttachOutputBuffer(SF_OMX_COMPONENT *pSfOMXComponent, OMX_U8* pBuffer, OMX_U32 nSizeBytes);
 OMX_BOOL AttachOutputBuffer(SF_OMX_COMPONENT *pSfOMXComponent, OMX_U8* pBuffer, OMX_U32 nSizeBytes);
-OMX_U8* AllocateOutputBuffer(SF_OMX_COMPONENT *pSfOMXComponent, OMX_U32 nSizeBytes);
+OMX_U8* AllocateOutputBuffer(SF_OMX_COMPONENT *pSfOMXComponent, OMX_U32 nBufferIndex, OMX_U32 nSizeBytes);
 void ThreadExit(void *value_ptr);
 void ThreadExit(void *value_ptr);
 void CodaJ12FlushBuffer(SF_OMX_COMPONENT *pSfOMXComponent, OMX_U32 nPortNumber);
 void CodaJ12FlushBuffer(SF_OMX_COMPONENT *pSfOMXComponent, OMX_U32 nPortNumber);
 
 

+ 6 - 1
omx-il/component/image/dec/SF_OMX_Mjpeg_decoder.c

@@ -278,7 +278,7 @@ static OMX_ERRORTYPE SF_OMX_AllocateBuffer(
             {
             {
                 if (pSfOMXComponent->memory_optimization)
                 if (pSfOMXComponent->memory_optimization)
                 {
                 {
-                    temp_bufferHeader->pBuffer = AllocateOutputBuffer(pSfOMXComponent, nSizeBytes);
+                    temp_bufferHeader->pBuffer = AllocateOutputBuffer(pSfOMXComponent, i, nSizeBytes);
                 }
                 }
 
 
                 if (temp_bufferHeader->pBuffer == NULL)
                 if (temp_bufferHeader->pBuffer == NULL)
@@ -2135,6 +2135,11 @@ static OMX_ERRORTYPE SF_OMX_FreeBuffer(
         if(pBufferHdr->pBuffer)
         if(pBufferHdr->pBuffer)
             free(pBufferHdr->pBuffer);
             free(pBufferHdr->pBuffer);
     }
     }
+    else if (pBufInfo->type == SF_BUFFER_DMA)
+    {
+        SF_CODAJ12_IMPLEMEMT *pSfCodaj12Implement = pSfOMXComponent->componentImpl;
+        pSfCodaj12Implement->functions->FreeOneFrameBuffer(pSfCodaj12Implement->instIdx, pBufInfo->index);
+    }
 
 
     pSfOMXComponent->pBufferArray[nPortIndex][pBufInfo->index] = NULL;
     pSfOMXComponent->pBufferArray[nPortIndex][pBufInfo->index] = NULL;
     pSfOMXComponent->assignedBufferNum[nPortIndex]--;
     pSfOMXComponent->assignedBufferNum[nPortIndex]--;

+ 7 - 6
omx-il/component/video/wave5/common/SF_OMX_video_common.c

@@ -69,18 +69,18 @@ OMX_ERRORTYPE ComponentClearCommon(SF_OMX_COMPONENT *pSfOMXComponent)
         pSfVideoImplement->functions->ComponentDestroy(pSfVideoImplement->hSFComponentFeeder, NULL);
         pSfVideoImplement->functions->ComponentDestroy(pSfVideoImplement->hSFComponentFeeder, NULL);
     }
     }
 
 
-    if (pSfVideoImplement->hSFComponentExecoder)
-    {
-        pSfVideoImplement->functions->ComponentRelease(pSfVideoImplement->hSFComponentExecoder);
-        pSfVideoImplement->functions->ComponentDestroy(pSfVideoImplement->hSFComponentExecoder, NULL);
-    }
-
     if (pSfVideoImplement->hSFComponentRender)
     if (pSfVideoImplement->hSFComponentRender)
     {
     {
         pSfVideoImplement->functions->ComponentRelease(pSfVideoImplement->hSFComponentRender);
         pSfVideoImplement->functions->ComponentRelease(pSfVideoImplement->hSFComponentRender);
         pSfVideoImplement->functions->ComponentDestroy(pSfVideoImplement->hSFComponentRender, NULL);
         pSfVideoImplement->functions->ComponentDestroy(pSfVideoImplement->hSFComponentRender, NULL);
     }
     }
 
 
+    if (pSfVideoImplement->hSFComponentExecoder)
+    {
+        pSfVideoImplement->functions->ComponentRelease(pSfVideoImplement->hSFComponentExecoder);
+        pSfVideoImplement->functions->ComponentDestroy(pSfVideoImplement->hSFComponentExecoder, NULL);
+    }
+
     pSfVideoImplement->functions->DeInitLog();
     pSfVideoImplement->functions->DeInitLog();
     dlclose(pSfOMXComponent->soHandle);
     dlclose(pSfOMXComponent->soHandle);
     free(pSfVideoImplement->functions);
     free(pSfVideoImplement->functions);
@@ -553,6 +553,7 @@ static void sf_get_component_functions(SF_COMPONENT_FUNCTIONS *funcs, OMX_PTR *s
 
 
     //Renderer
     //Renderer
     funcs->AllocateFrameBuffer2 = dlsym(sohandle, "AllocateFrameBuffer2");
     funcs->AllocateFrameBuffer2 = dlsym(sohandle, "AllocateFrameBuffer2");
+    funcs->FreeFrameBuffer2 = dlsym(sohandle, "FreeFrameBuffer2");
     funcs->AttachDMABuffer = dlsym(sohandle, "AttachDMABuffer");
     funcs->AttachDMABuffer = dlsym(sohandle, "AttachDMABuffer");
     funcs->SetRenderTotalBufferNumber = dlsym(sohandle, "SetRenderTotalBufferNumber");
     funcs->SetRenderTotalBufferNumber = dlsym(sohandle, "SetRenderTotalBufferNumber");
     funcs->GetRenderTotalBufferNumber = dlsym(sohandle, "GetRenderTotalBufferNumber");
     funcs->GetRenderTotalBufferNumber = dlsym(sohandle, "GetRenderTotalBufferNumber");

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

@@ -97,6 +97,7 @@ typedef struct _SF_COMPONENT_FUNCTIONS
     int (*GetMaxLogLevel)(void);
     int (*GetMaxLogLevel)(void);
     // FrameBuffer
     // FrameBuffer
     void* (*AllocateFrameBuffer2)(ComponentImpl* com, Uint32 size);
     void* (*AllocateFrameBuffer2)(ComponentImpl* com, Uint32 size);
+    void (*FreeFrameBuffer2)(ComponentImpl* com, void* pBuffer);
     BOOL (*AttachDMABuffer)(ComponentImpl* com, Uint64 virtAddress, Uint32 size);
     BOOL (*AttachDMABuffer)(ComponentImpl* com, Uint64 virtAddress, Uint32 size);
     void (*SetRenderTotalBufferNumber)(ComponentImpl* com, Uint32 number);
     void (*SetRenderTotalBufferNumber)(ComponentImpl* com, Uint32 number);
     Uint32 (*GetRenderTotalBufferNumber)(ComponentImpl* com);
     Uint32 (*GetRenderTotalBufferNumber)(ComponentImpl* com);
@@ -126,6 +127,9 @@ typedef struct _SF_WAVE5_IMPLEMEMT
     OMX_BOOL bCmdRunning;
     OMX_BOOL bCmdRunning;
     OMX_U64 frame_array[MAX_INDEX];
     OMX_U64 frame_array[MAX_INDEX];
     OMX_U32 frame_array_index;
     OMX_U32 frame_array_index;
+    OMX_TICKS initTimeStamp;
+    OMX_U32 fpsCnt;
+    struct timeval fpsStarTime;
     OMX_VIDEO_PARAM_AVCTYPE AVCComponent[2];
     OMX_VIDEO_PARAM_AVCTYPE AVCComponent[2];
     OMX_VIDEO_PARAM_HEVCTYPE HEVCComponent[2];
     OMX_VIDEO_PARAM_HEVCTYPE HEVCComponent[2];
 }SF_WAVE5_IMPLEMEMT;
 }SF_WAVE5_IMPLEMEMT;

+ 55 - 15
omx-il/component/video/wave5/dec/SF_OMX_Vdec_decoder.c

@@ -14,7 +14,6 @@
 
 
 #define DEC_StopThread OMX_CommandMax
 #define DEC_StopThread OMX_CommandMax
 
 
-extern OMX_TICKS gInitTimeStamp;
 
 
 typedef struct DEC_CMD
 typedef struct DEC_CMD
 {
 {
@@ -81,8 +80,6 @@ static void OnEventArrived(Component com, unsigned long event, void *data, void
     OMX_BUFFERHEADERTYPE **ppBuffer;
     OMX_BUFFERHEADERTYPE **ppBuffer;
     OMX_BUFFERHEADERTYPE *pBuffer;
     OMX_BUFFERHEADERTYPE *pBuffer;
     SF_OMX_BUF_INFO *pBufInfo;
     SF_OMX_BUF_INFO *pBufInfo;
-    static OMX_U32 dec_cnt = 0;
-    static struct timeval tv_old = {0};
     OMX_U32 fps = 0;
     OMX_U32 fps = 0;
     OMX_U64 diff_time = 0; // ms
     OMX_U64 diff_time = 0; // ms
     FunctionIn();
     FunctionIn();
@@ -195,23 +192,23 @@ static void OnEventArrived(Component com, unsigned long event, void *data, void
         }
         }
 
 
         gettimeofday(&tv, NULL);
         gettimeofday(&tv, NULL);
-        if (gInitTimeStamp == 0)
+	if (pSfVideoImplement->initTimeStamp == 0)
         {
         {
-            gInitTimeStamp = tv.tv_sec * 1000000 + tv.tv_usec;
+            pSfVideoImplement->initTimeStamp = tv.tv_sec * 1000000 + tv.tv_usec;
         }
         }
         pOMXBuffer->nFilledLen = pPortContainerExternal->nFilledLen;
         pOMXBuffer->nFilledLen = pPortContainerExternal->nFilledLen;
-        pOMXBuffer->nTimeStamp = tv.tv_sec * 1000000 + tv.tv_usec - gInitTimeStamp;
+        pOMXBuffer->nTimeStamp = tv.tv_sec * 1000000 + tv.tv_usec - pSfVideoImplement->initTimeStamp;
 
 
         pBufInfo = pOMXBuffer->pOutputPortPrivate;
         pBufInfo = pOMXBuffer->pOutputPortPrivate;
 
 
         // Following is to print the decoding fps
         // Following is to print the decoding fps
-        if (dec_cnt == 0) {
-            tv_old = tv;
+        if (pSfVideoImplement->fpsCnt == 0) {
+            pSfVideoImplement->fpsStarTime = tv;
         }
         }
-        if (dec_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;
+        if (pSfVideoImplement->fpsCnt++ >= 50) {
+            diff_time = (tv.tv_sec - pSfVideoImplement->fpsStarTime.tv_sec) * 1000 + (tv.tv_usec - pSfVideoImplement->fpsStarTime.tv_usec) / 1000;
+            fps = 1000  * (pSfVideoImplement->fpsCnt - 1) / diff_time;
+            pSfVideoImplement->fpsCnt = 0;
             LOG(SF_LOG_WARN, "Decoding fps: %d \r\n", fps);
             LOG(SF_LOG_WARN, "Decoding fps: %d \r\n", fps);
         }
         }
         if (pPortContainerExternal->nFlags & 0x1)
         if (pPortContainerExternal->nFlags & 0x1)
@@ -470,7 +467,7 @@ static OMX_ERRORTYPE SF_OMX_FillThisBuffer(
     pPortContainerExternal->nFilledLen = pBuffer->nAllocLen;
     pPortContainerExternal->nFilledLen = pBuffer->nAllocLen;
     pPortContainerExternal->pAppPrivate = (void*)pBuffer;
     pPortContainerExternal->pAppPrivate = (void*)pBuffer;
 
 
-    if (gInitTimeStamp != 0 && pSfOMXComponent->memory_optimization)
+    if (pSfVideoImplement->initTimeStamp != 0 && pSfOMXComponent->memory_optimization)
     {
     {
         int clear = pSfVideoImplement->frame_array[pSfVideoImplement->frame_array_index];
         int clear = pSfVideoImplement->frame_array[pSfVideoImplement->frame_array_index];
         pSfVideoImplement->functions->Render_DecClrDispFlag(pRendererComponent->context, clear);
         pSfVideoImplement->functions->Render_DecClrDispFlag(pRendererComponent->context, clear);
@@ -761,6 +758,7 @@ static OMX_ERRORTYPE SF_OMX_GetParameter(
     OMX_ERRORTYPE ret = OMX_ErrorNone;
     OMX_ERRORTYPE ret = OMX_ErrorNone;
     OMX_COMPONENTTYPE *pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
     OMX_COMPONENTTYPE *pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
     SF_OMX_COMPONENT *pSfOMXComponent = pOMXComponent->pComponentPrivate;
     SF_OMX_COMPONENT *pSfOMXComponent = pOMXComponent->pComponentPrivate;
+    SF_WAVE5_IMPLEMEMT *pSfVideoImplement = (SF_WAVE5_IMPLEMEMT *)pSfOMXComponent->componentImpl;
     FunctionIn();
     FunctionIn();
     LOG(SF_LOG_INFO, "Get parameter on index %X\r\n", nParamIndex);
     LOG(SF_LOG_INFO, "Get parameter on index %X\r\n", nParamIndex);
     if (hComponent == NULL || ComponentParameterStructure == NULL)
     if (hComponent == NULL || ComponentParameterStructure == NULL)
@@ -890,6 +888,18 @@ static OMX_ERRORTYPE SF_OMX_GetParameter(
             ret = OMX_ErrorBadPortIndex;
             ret = OMX_ErrorBadPortIndex;
     }
     }
         break;
         break;
+    case OMX_IndexParamVideoProfileLevelCurrent:
+    {
+        OMX_VIDEO_PARAM_PROFILELEVELTYPE *pSrcProfileLevel = (OMX_VIDEO_PARAM_PROFILELEVELTYPE *)ComponentParameterStructure;
+        OMX_U32 portIndex = pSrcProfileLevel->nPortIndex;
+        OMX_VIDEO_PARAM_AVCTYPE *pAVCComponent = NULL;
+        if (portIndex >= 2)
+            ret = OMX_ErrorBadPortIndex;
+        pAVCComponent = &pSfVideoImplement->AVCComponent[portIndex];
+        pSrcProfileLevel->eProfile = pAVCComponent->eProfile;
+        pSrcProfileLevel->eLevel = pAVCComponent->eLevel;
+    }
+        break;
 
 
     default:
     default:
         ret = OMX_ErrorUnsupportedIndex;
         ret = OMX_ErrorUnsupportedIndex;
@@ -1015,7 +1025,17 @@ static OMX_ERRORTYPE SF_OMX_SetParameter(
 
 
             pInputPort->format.video.nStride = width;
             pInputPort->format.video.nStride = width;
             pInputPort->format.video.nSliceHeight = height;
             pInputPort->format.video.nSliceHeight = height;
-            pInputPort->nBufferSize = width * height * 2;
+            pInputPort->nBufferSize = width * height / 2;
+
+            pOutputPort->format.video.nFrameWidth = width;
+            pOutputPort->format.video.nFrameHeight = height;
+            pOutputPort->format.video.nStride = width;
+            pOutputPort->format.video.nSliceHeight = height;
+            pTestDecConfig->scaleDownWidth = VPU_CEIL(width, 2);
+            pTestDecConfig->scaleDownHeight = VPU_CEIL(height, 2);
+            if (width && height)
+                    pOutputPort->nBufferSize = (width * height * 3) / 2;
+            LOG(SF_LOG_INFO, "Set scale = %d, %d\r\n", pTestDecConfig->scaleDownWidth , pTestDecConfig->scaleDownHeight);
         }
         }
         else if (portIndex == 1)
         else if (portIndex == 1)
         {
         {
@@ -1133,6 +1153,18 @@ static OMX_ERRORTYPE SF_OMX_SetParameter(
             ret = OMX_ErrorBadPortIndex;
             ret = OMX_ErrorBadPortIndex;
     }
     }
         break;
         break;
+    case OMX_IndexParamVideoProfileLevelCurrent:
+    {
+        OMX_VIDEO_PARAM_PROFILELEVELTYPE *pSrcProfileLevel = (OMX_VIDEO_PARAM_PROFILELEVELTYPE *)ComponentParameterStructure;
+        OMX_U32 portIndex = pSrcProfileLevel->nPortIndex;
+        OMX_VIDEO_PARAM_AVCTYPE *pAVCComponent = NULL;
+        if (portIndex >= 2)
+            ret = OMX_ErrorBadPortIndex;
+        pAVCComponent = &pSfVideoImplement->AVCComponent[portIndex];
+        pAVCComponent->eProfile = pSrcProfileLevel->eProfile;
+        pAVCComponent->eLevel = pSrcProfileLevel->eLevel;
+    }
+        break;
 
 
     default:
     default:
         ret = OMX_ErrorUnsupportedIndex;
         ret = OMX_ErrorUnsupportedIndex;
@@ -1524,6 +1556,12 @@ static OMX_ERRORTYPE SF_OMX_FreeBuffer(
         if(pBufferHdr->pBuffer)
         if(pBufferHdr->pBuffer)
             free(pBufferHdr->pBuffer);
             free(pBufferHdr->pBuffer);
     }
     }
+    else if(pBufInfo->type == SF_BUFFER_DMA)
+    {
+        SF_WAVE5_IMPLEMEMT *pSfVideoImplement = (SF_WAVE5_IMPLEMEMT *)pSfOMXComponent->componentImpl;
+        ComponentImpl *pComponentRender = (ComponentImpl *)pSfVideoImplement->hSFComponentRender;
+        pSfVideoImplement->functions->FreeFrameBuffer2(pComponentRender, pBufferHdr->pBuffer);
+    }
 
 
     pSfOMXComponent->pBufferArray[nPortIndex][pBufInfo->index] = NULL;
     pSfOMXComponent->pBufferArray[nPortIndex][pBufInfo->index] = NULL;
     pSfOMXComponent->assignedBufferNum[nPortIndex]--;
     pSfOMXComponent->assignedBufferNum[nPortIndex]--;
@@ -2041,7 +2079,7 @@ static OMX_ERRORTYPE SF_OMX_ComponentConstructor(SF_OMX_COMPONENT *pSfOMXCompone
     OMX_ERRORTYPE ret = OMX_ErrorNone;
     OMX_ERRORTYPE ret = OMX_ErrorNone;
     FunctionIn();
     FunctionIn();
 
 
-    if (nInstance >= 1)
+    if (nInstance >= 4)
     {
     {
         ret = OMX_ErrorInsufficientResources;
         ret = OMX_ErrorInsufficientResources;
         goto EXIT;
         goto EXIT;
@@ -2091,6 +2129,8 @@ static OMX_ERRORTYPE SF_OMX_ComponentConstructor(SF_OMX_COMPONENT *pSfOMXCompone
         pSfVideoImplement->frame_array[i] = -1;
         pSfVideoImplement->frame_array[i] = -1;
     }
     }
     pSfVideoImplement->frame_array_index = 0;
     pSfVideoImplement->frame_array_index = 0;
+    pSfVideoImplement->fpsCnt = 0;
+    pSfVideoImplement->initTimeStamp = 0;
 
 
     pSfVideoImplement->CmdQueue = SF_Queue_Create(20, sizeof(DEC_CMD));
     pSfVideoImplement->CmdQueue = SF_Queue_Create(20, sizeof(DEC_CMD));
     if (NULL == pSfVideoImplement->CmdQueue)
     if (NULL == pSfVideoImplement->CmdQueue)

+ 33 - 5
wave511/code/sample_v2/component_decoder/component_dec_renderer.c

@@ -287,6 +287,27 @@ void* AllocateFrameBuffer2(ComponentImpl* com, Uint32 size)
     return ret;
     return ret;
 }
 }
 
 
+void FreeFrameBuffer2(ComponentImpl* com, void* pBuffer)
+{
+    RendererContext*     ctx            = (RendererContext*)com->context;
+    int i = 0;
+
+    if (ctx->handle == NULL) {
+        ctx->MemoryOptimization = FALSE;
+        return;
+    }
+
+    for (i = 0;i < MAX_REG_FRAME; i ++){
+        if (ctx->pLinearFbMem[i].virt_addr == (unsigned long)pBuffer)
+        {
+            VLOG(INFO, "free dmabuffer at index %d\r\n", i);
+            vdi_free_dma_memory(ctx->testDecConfig.coreIdx, &ctx->pLinearFbMem[i], DEC_FB_LINEAR, ctx->handle->instIndex);
+            return;
+        }
+    }
+    VLOG(ERR, "FreeFrameBuffer2 can not find buffer %p\r\n", pBuffer);
+}
+
 Uint64 RemapDMABuffer(ComponentImpl* com, Uint64 virtAddress, Uint32 size)
 Uint64 RemapDMABuffer(ComponentImpl* com, Uint64 virtAddress, Uint32 size)
 {
 {
     RendererContext*     ctx;
     RendererContext*     ctx;
@@ -657,9 +678,18 @@ static void ReleaseRenderer(ComponentImpl* com)
     Uint32           i;
     Uint32           i;
 
 
 #ifdef USE_FEEDING_METHOD_BUFFER
 #ifdef USE_FEEDING_METHOD_BUFFER
-    if (!ctx->useBufferExternal)
-    {
-#endif
+    for (i=0; i<MAX_REG_FRAME; i++) {
+        if (ctx->pFbMem[i].size) {
+            if (i < ctx->fbCount.nonLinearNum)
+            {
+                vdi_free_dma_memory(coreIdx, &ctx->pFbMem[i], DEC_FBC, ctx->handle->instIndex);
+            }else{
+                if(!ctx->MemoryOptimization)
+                    vdi_free_dma_memory(coreIdx, &ctx->pFbMem[i], DEC_FB_LINEAR, ctx->handle->instIndex);
+            }
+        }
+    }
+#else
     for (i=0; i<MAX_REG_FRAME; i++) {
     for (i=0; i<MAX_REG_FRAME; i++) {
         if (ctx->pFbMem[i].size) {
         if (ctx->pFbMem[i].size) {
             if (i < ctx->fbCount.linearNum)
             if (i < ctx->fbCount.linearNum)
@@ -668,8 +698,6 @@ static void ReleaseRenderer(ComponentImpl* com)
                 vdi_free_dma_memory(coreIdx, &ctx->pFbMem[i], DEC_FB_LINEAR, ctx->handle->instIndex);
                 vdi_free_dma_memory(coreIdx, &ctx->pFbMem[i], DEC_FB_LINEAR, ctx->handle->instIndex);
         }
         }
     }
     }
-#ifdef USE_FEEDING_METHOD_BUFFER
-    }
 #endif
 #endif
 
 
     for (i=0; i<MAX_REG_FRAME; i++) {
     for (i=0; i<MAX_REG_FRAME; i++) {

+ 3 - 3
wave511/code/vdi/linux/vdi.c

@@ -478,7 +478,7 @@ int vdi_allocate_common_memory(unsigned long core_idx)
         return -1;
         return -1;
     }
     }
 
 
-    vdb.virt_addr = (unsigned long)mmap(NULL, vdb.size, PROT_READ | PROT_WRITE, MAP_SHARED, vdi->vpu_fd, DRAM_MEM2SYS(vdb.phys_addr));
+    vdb.virt_addr = (unsigned long)mmap(NULL, vdb.size, PROT_READ | PROT_WRITE, MAP_SHARED, vdi->vpu_fd, vdb.phys_addr);
     if ((void *)vdb.virt_addr == MAP_FAILED)
     if ((void *)vdb.virt_addr == MAP_FAILED)
     {
     {
         VLOG(ERR, "[VDI] fail to map common memory phyaddr=%#lx, size = %d\n", vdb.phys_addr, vdb.size);
         VLOG(ERR, "[VDI] fail to map common memory phyaddr=%#lx, size = %d\n", vdb.phys_addr, vdb.size);
@@ -1124,7 +1124,7 @@ void* vdi_remap_vaddr(unsigned long coreIndex, unsigned long virtAddress, unsign
     vdi_virt_to_phys(coreIndex, &vb);
     vdi_virt_to_phys(coreIndex, &vb);
 
 
     vaddr = (void *)mmap(NULL, vb.size, PROT_READ | PROT_WRITE,
     vaddr = (void *)mmap(NULL, vb.size, PROT_READ | PROT_WRITE,
-        MAP_SHARED, vdi->vpu_fd, DRAM_MEM2SYS(vb.phys_addr));
+        MAP_SHARED, vdi->vpu_fd, vb.phys_addr);
 
 
     return vaddr;
     return vaddr;
 }
 }
@@ -1159,7 +1159,7 @@ int vdi_allocate_dma_memory(unsigned long core_idx, vpu_buffer_t *vb, int memTyp
 
 
     //map to virtual address
     //map to virtual address
     vdb.virt_addr = (unsigned long)mmap(NULL, vdb.size, PROT_READ | PROT_WRITE,
     vdb.virt_addr = (unsigned long)mmap(NULL, vdb.size, PROT_READ | PROT_WRITE,
-        MAP_SHARED, vdi->vpu_fd, DRAM_MEM2SYS(vdb.phys_addr));
+        MAP_SHARED, vdi->vpu_fd, vdb.phys_addr);
     if ((void *)vdb.virt_addr == MAP_FAILED)
     if ((void *)vdb.virt_addr == MAP_FAILED)
     {
     {
         memset(vb, 0x00, sizeof(vpu_buffer_t));
         memset(vb, 0x00, sizeof(vpu_buffer_t));