exynos_omx: multi_thread: Add nMemoryType variable in struct ExynosVideoDecContext.
authorSeungBeom Kim <sbcrux.kim@samsung.com>
Tue, 3 Jul 2012 06:45:57 +0000 (15:45 +0900)
committerJames Dong <jdong@google.com>
Sat, 21 Jul 2012 01:53:36 +0000 (18:53 -0700)
for the V4L2_MEMORY_DMABUF support &  manage.

Change-Id: If68c0963d7debaf2306fcefcad97cd8a933c2cef
Signed-off-by: SeungBeom Kim <sbcrux.kim@samsung.com>
exynos_omx/codecs/exynos_codecs/video/exynos5/mfc_v4l2/dec/src/ExynosVideoDecoder.c
exynos_omx/codecs/exynos_codecs/video/exynos5/mfc_v4l2/enc/src/ExynosVideoEncoder.c
exynos_omx/codecs/exynos_codecs/video/exynos5/mfc_v4l2/include/ExynosVideoDec.h
exynos_omx/codecs/exynos_codecs/video/exynos5/mfc_v4l2/include/ExynosVideoEnc.h

index b020641d5c5ba644bea0bd312c001c0b26372442..c48e43dcca0955aed5d76ae0194ac358a6f4356b 100644 (file)
@@ -137,12 +137,13 @@ static void *MFC_Decoder_Init(void)
     pCtx->bStreamonInbuf = VIDEO_FALSE;
     pCtx->bStreamonOutbuf = VIDEO_FALSE;
 
+    pCtx->nMemoryType = V4L2_MEMORY_DMABUF;
+
     pMutex = (pthread_mutex_t *)malloc(sizeof(pthread_mutex_t));
     if (pMutex == NULL) {
         ALOGE("%s: Failed to allocate mutex about input buffer", __func__);
         goto EXIT_QUERYCAP_FAIL;
     }
-
     if (pthread_mutex_init(pMutex, NULL) != 0) {
         free(pMutex);
         goto EXIT_QUERYCAP_FAIL;
@@ -154,7 +155,6 @@ static void *MFC_Decoder_Init(void)
         ALOGE("%s: Failed to allocate mutex about output buffer", __func__);
         goto EXIT_QUERYCAP_FAIL;
     }
-
     if (pthread_mutex_init(pMutex, NULL) != 0) {
         free(pMutex);
         goto EXIT_QUERYCAP_FAIL;
@@ -826,7 +826,7 @@ static ExynosVideoErrorType MFC_Decoder_Setup_Inbuf(
     req.count = nBufferCount;
 
     if (pCtx->bShareInbuf == VIDEO_TRUE)
-        req.memory = V4L2_MEMORY_DMABUF;
+        req.memory = pCtx->nMemoryType;
     else
         req.memory = V4L2_MEMORY_MMAP;
 
@@ -942,7 +942,7 @@ static ExynosVideoErrorType MFC_Decoder_Setup_Outbuf(
     req.count = nBufferCount;
 
     if (pCtx->bShareOutbuf == VIDEO_TRUE)
-        req.memory = V4L2_MEMORY_DMABUF;
+        req.memory = pCtx->nMemoryType;
     else
         req.memory = V4L2_MEMORY_MMAP;
 
@@ -1419,7 +1419,7 @@ static ExynosVideoErrorType MFC_Decoder_Enqueue_Inbuf(
     buf.index = index;
 
     if (pCtx->bShareInbuf == VIDEO_TRUE) {
-        buf.memory = V4L2_MEMORY_DMABUF;
+        buf.memory = pCtx->nMemoryType;
         for (i = 0; i < nPlanes; i++) {
             buf.m.planes[i].m.fd = pCtx->pInbuf[index].planes[i].fd;
             buf.m.planes[i].length = pCtx->pInbuf[index].planes[i].allocSize;
@@ -1509,7 +1509,7 @@ static ExynosVideoErrorType MFC_Decoder_Enqueue_Outbuf(
     buf.index = index;
 
     if (pCtx->bShareOutbuf == VIDEO_TRUE) {
-        buf.memory = V4L2_MEMORY_DMABUF;
+        buf.memory = pCtx->nMemoryType;
         for (i = 0; i < nPlanes; i++) {
             buf.m.planes[i].m.fd = pCtx->pOutbuf[index].planes[i].fd;
             buf.m.planes[i].length = pCtx->pOutbuf[index].planes[i].allocSize;
@@ -1576,7 +1576,7 @@ static ExynosVideoBuffer *MFC_Decoder_Dequeue_Inbuf(void *pHandle)
     buf.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
 
     if (pCtx->bShareInbuf == VIDEO_TRUE)
-        buf.memory = V4L2_MEMORY_DMABUF;
+        buf.memory = pCtx->nMemoryType;
     else
         buf.memory = V4L2_MEMORY_MMAP;
 
@@ -1649,11 +1649,10 @@ static ExynosVideoBuffer *MFC_Decoder_Dequeue_Outbuf(void *pHandle)
     }
 
     memset(&buf, 0, sizeof(buf));
-
     buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
 
     if (pCtx->bShareOutbuf == VIDEO_TRUE)
-        buf.memory = V4L2_MEMORY_DMABUF;
+        buf.memory = pCtx->nMemoryType;
     else
         buf.memory = V4L2_MEMORY_MMAP;
 
index ee3e0d1066221948510e3232687e276edf1ef640..dce0963e86d52cc4e627064c81e41f6865af9431 100644 (file)
@@ -119,7 +119,6 @@ static void *MFC_Encoder_Init(void)
 {
     ExynosVideoEncContext *pCtx     = NULL;
     pthread_mutex_t       *pMutex   = NULL;
-
     int needCaps = (V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_STREAMING);
 
     pCtx = (ExynosVideoEncContext *)malloc(sizeof(*pCtx));
@@ -144,6 +143,8 @@ static void *MFC_Encoder_Init(void)
     pCtx->bStreamonInbuf = VIDEO_FALSE;
     pCtx->bStreamonOutbuf = VIDEO_FALSE;
 
+    pCtx->nMemoryType = V4L2_MEMORY_DMABUF;
+
     pMutex = (pthread_mutex_t *)malloc(sizeof(pthread_mutex_t));
     if (pMutex == NULL) {
         ALOGE("%s: Failed to allocate mutex about input buffer", __func__);
@@ -1169,7 +1170,7 @@ static ExynosVideoErrorType MFC_Encoder_Setup_Inbuf(
     req.count = nBufferCount;
 
     if (pCtx->bShareInbuf == VIDEO_TRUE)
-        req.memory = V4L2_MEMORY_USERPTR;
+        req.memory = pCtx->nMemoryType;
     else
         req.memory = V4L2_MEMORY_MMAP;
 
@@ -1292,7 +1293,7 @@ static ExynosVideoErrorType MFC_Encoder_Setup_Outbuf(
     req.count = nBufferCount;
 
     if (pCtx->bShareOutbuf == VIDEO_TRUE)
-        req.memory = V4L2_MEMORY_USERPTR;
+        req.memory = pCtx->nMemoryType;
     else
         req.memory = V4L2_MEMORY_MMAP;
 
@@ -1816,7 +1817,7 @@ static ExynosVideoErrorType MFC_Encoder_Enqueue_Inbuf(
     buf.index = index;
 
     if (pCtx->bShareInbuf == VIDEO_TRUE) {
-        buf.memory = V4L2_MEMORY_USERPTR;
+        buf.memory = pCtx->nMemoryType;
         for (i = 0; i < nPlanes; i++) {
             buf.m.planes[i].m.userptr = (unsigned long)pBuffer[i];
             buf.m.planes[i].length = pCtx->pInbuf[index].planes[i].allocSize;
@@ -1903,7 +1904,7 @@ static ExynosVideoErrorType MFC_Encoder_Enqueue_Outbuf(
     buf.index = index;
 
     if (pCtx->bShareOutbuf == VIDEO_TRUE) {
-        buf.memory = V4L2_MEMORY_USERPTR;
+        buf.memory = pCtx->nMemoryType;
         for (i = 0; i < nPlanes; i++) {
             buf.m.planes[i].m.userptr = pCtx->pOutbuf[index].planes[i].addr;
             buf.m.planes[i].length = pCtx->pOutbuf[index].planes[i].allocSize;
@@ -1991,7 +1992,7 @@ static ExynosVideoBuffer *MFC_Encoder_Dequeue_Inbuf(void *pHandle)
     buf.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
 
     if (pCtx->bShareInbuf == VIDEO_TRUE)
-        buf.memory = V4L2_MEMORY_USERPTR;
+        buf.memory = pCtx->nMemoryType;
     else
         buf.memory = V4L2_MEMORY_MMAP;
 
@@ -2037,7 +2038,7 @@ static ExynosVideoBuffer *MFC_Encoder_Dequeue_Outbuf(void *pHandle)
     buf.length = 1;
 
     if (pCtx->bShareOutbuf == VIDEO_TRUE)
-        buf.memory = V4L2_MEMORY_USERPTR;
+        buf.memory = pCtx->nMemoryType;
     else
         buf.memory = V4L2_MEMORY_MMAP;
 
index 26f259823ce42b421d7656f7e3245b7c35e0d193..45287b045d3066b7634c7ad0a2eb83fb8d2e23ff 100644 (file)
@@ -44,6 +44,7 @@ typedef struct _ExynosVideoDecContext {
     void                *pPrivate;
     void                *pInMutex;
     void                *pOutMutex;
+    int                  nMemoryType;
 } ExynosVideoDecContext;
 
 #endif /* _EXYNOS_VIDEO_DEC_H_ */
index 399220c1184c30ae96c3d3013df51bd1b61abf42..5a70fb1b36e8523f17bab0ae1f23b9975042606a 100644 (file)
@@ -41,6 +41,7 @@ typedef struct _ExynosVideoEncContext {
     void                *pPrivate;
     void                *pInMutex;
     void                *pOutMutex;
+    int                  nMemoryType;
 } ExynosVideoEncContext;
 
 #endif /* _EXYNOS_VIDEO_ENC_H_ */