goto EXIT;
}
- if (req.count != nBufferCount)
- ALOGW("%s: asked for %d, got %d\n", __func__, nBufferCount, req.count);
+ if (req.count != nBufferCount) {
+ ALOGE("%s: asked for %d, got %d\n", __func__, nBufferCount, req.count);
+ ret = VIDEO_ERROR_NOMEM;
+ goto EXIT;
+ }
pCtx->nInbufs = (int)req.count;
goto EXIT;
}
+ if (req.count != nBufferCount) {
+ ALOGE("%s: asked for %d, got %d\n", __func__, nBufferCount, req.count);
+ ret = VIDEO_ERROR_NOMEM;
+ goto EXIT;
+ }
+
pCtx->nOutbufs = req.count;
pCtx->pOutbuf = malloc(sizeof(*pCtx->pOutbuf) * pCtx->nOutbufs);
{
ExynosVideoDecContext *pCtx = (ExynosVideoDecContext *)pHandle;
ExynosVideoErrorType ret = VIDEO_ERROR_NONE;
- int nIndex;
+ int nIndex, plane;
- if ((pCtx == NULL) || (planes == NULL) || (nPlanes != 1)) {
+ if ((pCtx == NULL) || (planes == NULL) || (nPlanes != VIDEO_DECODER_INBUF_PLANES)) {
ALOGE("%s: params must be supplied", __func__);
ret = VIDEO_ERROR_BADPARAM;
goto EXIT;
for (nIndex = 0; nIndex < pCtx->nInbufs; nIndex++) {
if (pCtx->pInbuf[nIndex].bRegistered == VIDEO_FALSE) {
- pCtx->pInbuf[nIndex].planes[0].addr = planes[0].addr;
- pCtx->pInbuf[nIndex].planes[0].allocSize = planes[0].allocSize;
- pCtx->pInbuf[nIndex].planes[0].fd = planes[0].fd;
+ for (plane = 0; plane < nPlanes; plane++) {
+ pCtx->pInbuf[nIndex].planes[plane].addr = planes[plane].addr;
+ pCtx->pInbuf[nIndex].planes[plane].allocSize = planes[plane].allocSize;
+ pCtx->pInbuf[nIndex].planes[plane].fd = planes[plane].fd;
+ ALOGV("%s: registered buf %d (addr=%p alloc_sz=%ld fd=%d)\n", __func__, nIndex,
+ planes[plane].addr, planes[plane].allocSize, planes[plane].fd);
+ }
pCtx->pInbuf[nIndex].bRegistered = VIDEO_TRUE;
- ALOGV("%s: registered buf %d (addr=%p alloc_sz=%ld fd=%d)\n", __func__, nIndex,
- planes[0].addr, planes[0].allocSize, planes[0].fd);
break;
}
}
{
ExynosVideoDecContext *pCtx = (ExynosVideoDecContext *)pHandle;
ExynosVideoErrorType ret = VIDEO_ERROR_NONE;
- int nIndex;
+ int nIndex, plane;
- if ((pCtx == NULL) || (planes == NULL) || (nPlanes != 2)) {
+ if ((pCtx == NULL) || (planes == NULL) || (nPlanes != VIDEO_DECODER_OUTBUF_PLANES)) {
ALOGE("%s: params must be supplied", __func__);
ret = VIDEO_ERROR_BADPARAM;
goto EXIT;
for (nIndex = 0; nIndex < pCtx->nOutbufs; nIndex++) {
if (pCtx->pOutbuf[nIndex].bRegistered == VIDEO_FALSE) {
- int plane;
- for (plane = 0; plane < 2; plane++) {
+ for (plane = 0; plane < nPlanes; plane++) {
pCtx->pOutbuf[nIndex].planes[plane].addr = planes[plane].addr;
pCtx->pOutbuf[nIndex].planes[plane].allocSize = planes[plane].allocSize;
pCtx->pOutbuf[nIndex].planes[plane].fd = planes[plane].fd;
goto EXIT;
}
- if (pBuffer == NULL) {
- for (nIndex = 0; nIndex < pCtx->nInbufs; nIndex++) {
- if (pCtx->pInbuf[nIndex].bQueued == VIDEO_FALSE)
- break;
- }
- } else {
- for (nIndex = 0; nIndex < pCtx->nInbufs; nIndex++) {
- if (pCtx->pInbuf[nIndex].planes[0].addr == pBuffer)
+ for (nIndex = 0; nIndex < pCtx->nInbufs; nIndex++) {
+ if (pCtx->pInbuf[nIndex].bQueued == VIDEO_FALSE) {
+ if ((pBuffer == NULL) ||
+ (pCtx->pInbuf[nIndex].planes[0].addr == pBuffer))
break;
}
}
- if (nIndex == pCtx->nInbufs) {
+ if (nIndex == pCtx->nInbufs)
nIndex = -1;
- }
EXIT:
return nIndex;
goto EXIT;
}
- if (pBuffer == NULL) {
- for (nIndex = 0; nIndex < pCtx->nOutbufs; nIndex++) {
- if (pCtx->pOutbuf[nIndex].bQueued == VIDEO_FALSE)
- break;
- }
- } else {
- for (nIndex = 0; nIndex < pCtx->nOutbufs; nIndex++) {
- if (pCtx->pOutbuf[nIndex].planes[0].addr == pBuffer)
+ for (nIndex = 0; nIndex < pCtx->nOutbufs; nIndex++) {
+ if (pCtx->pOutbuf[nIndex].bQueued == VIDEO_FALSE) {
+ if ((pBuffer == NULL) ||
+ (pCtx->pOutbuf[nIndex].planes[0].addr == pBuffer))
break;
}
}
- if (nIndex == pCtx->nOutbufs) {
+ if (nIndex == pCtx->nOutbufs)
nIndex = -1;
- }
EXIT:
return nIndex;
buf.m.planes = planes;
buf.length = VIDEO_DECODER_INBUF_PLANES;
+ pMutex = (pthread_mutex_t*)pCtx->pInMutex;
+ pthread_mutex_lock(pMutex);
index = MFC_Decoder_Find_Inbuf(pCtx, pBuffer[0]);
- if ((index == -1) &&
- (pCtx->bShareInbuf == VIDEO_TRUE) &&
- (pBuffer[0] != NULL))
- index = MFC_Decoder_Find_Inbuf(pCtx, NULL);
if (index == -1) {
+ pthread_mutex_unlock(pMutex);
+ ALOGE("%s: Failed to get index", __func__);
ret = VIDEO_ERROR_NOBUFFERS;
goto EXIT;
}
buf.index = index;
+ pCtx->pInbuf[buf.index].bQueued = VIDEO_TRUE;
+ pthread_mutex_unlock(pMutex);
if (pCtx->bShareInbuf == VIDEO_TRUE) {
buf.memory = pCtx->nMemoryType;
for (i = 0; i < nPlanes; i++) {
+ /* V4L2_MEMORY_USERPTR */
+ buf.m.planes[i].m.userptr = (unsigned long)pBuffer[i];
+ /* V4L2_MEMORY_DMABUF */
buf.m.planes[i].m.fd = pCtx->pInbuf[index].planes[i].fd;
buf.m.planes[i].length = pCtx->pInbuf[index].planes[i].allocSize;
buf.m.planes[i].bytesused = dataSize[i];
- pCtx->pInbuf[buf.index].planes[i].addr = pBuffer[i];
- ALOGV("%s: shared inbuf(%d) plane(%d) fd=%d len=%d used=%d\n", __func__,
+ ALOGV("%s: shared inbuf(%d) plane(%d) addr=%p fd=%d len=%d used=%d\n", __func__,
index, i,
+ buf.m.planes[i].m.userptr,
buf.m.planes[i].m.fd,
buf.m.planes[i].length,
buf.m.planes[i].bytesused);
buf.m.planes[i].bytesused = dataSize[i];
}
- pMutex = (pthread_mutex_t*)pCtx->pInMutex;
- pthread_mutex_lock(pMutex);
- if (pCtx->pInbuf[buf.index].bQueued == VIDEO_FALSE) {
- if (exynos_v4l2_qbuf(pCtx->hDec, &buf) != 0) {
- ALOGE("%s: Failed to enqueue input buffer", __func__);
- ret = VIDEO_ERROR_APIFAIL;
- goto EXIT;
- }
-
- pCtx->pInbuf[buf.index].pPrivate = pPrivate;
- pCtx->pInbuf[buf.index].bQueued = VIDEO_TRUE;
- } else {
- ALOGE("Lost Input Buffer");
- pthread_mutex_unlock(pMutex);
+ if (exynos_v4l2_qbuf(pCtx->hDec, &buf) != 0) {
+ ALOGE("%s: Failed to enqueue input buffer", __func__);
+ pCtx->pInbuf[buf.index].bQueued = VIDEO_FALSE;
ret = VIDEO_ERROR_APIFAIL;
goto EXIT;
}
- pthread_mutex_unlock(pMutex);
+
+ pCtx->pInbuf[buf.index].pPrivate = pPrivate;
EXIT:
return ret;
memset(&buf, 0, sizeof(buf));
buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
buf.m.planes = planes;
- buf.length = nPlanes;
+ buf.length = VIDEO_DECODER_OUTBUF_PLANES;
+ pMutex = (pthread_mutex_t*)pCtx->pOutMutex;
+ pthread_mutex_lock(pMutex);
index = MFC_Decoder_Find_Outbuf(pCtx, pBuffer[0]);
- if ((index == -1) &&
- (pCtx->bShareOutbuf == VIDEO_TRUE) &&
- (pBuffer[0] != NULL))
- index = MFC_Decoder_Find_Outbuf(pCtx, NULL);
if (index == -1) {
+ pthread_mutex_unlock(pMutex);
+ ALOGE("%s: Failed to get index", __func__);
ret = VIDEO_ERROR_NOBUFFERS;
- ALOGE("Can not Find Buffer Index");
goto EXIT;
}
buf.index = index;
+ pCtx->pOutbuf[buf.index].bQueued = VIDEO_TRUE;
+ pthread_mutex_unlock(pMutex);
if (pCtx->bShareOutbuf == VIDEO_TRUE) {
buf.memory = pCtx->nMemoryType;
for (i = 0; i < nPlanes; i++) {
+ /* V4L2_MEMORY_USERPTR */
+ buf.m.planes[i].m.userptr = (unsigned long)pBuffer[i];
+ /* V4L2_MEMORY_DMABUF */
buf.m.planes[i].m.fd = pCtx->pOutbuf[index].planes[i].fd;
buf.m.planes[i].length = pCtx->pOutbuf[index].planes[i].allocSize;
buf.m.planes[i].bytesused = dataSize[i];
-
ALOGV("%s: shared outbuf(%d) plane=%d addr=%p fd=%d len=%d used=%d\n", __func__,
index, i,
- pCtx->pOutbuf[index].planes[i].addr,
+ buf.m.planes[i].m.userptr,
buf.m.planes[i].m.fd,
buf.m.planes[i].length,
buf.m.planes[i].bytesused);
buf.memory = V4L2_MEMORY_MMAP;
}
- pMutex = (pthread_mutex_t*)pCtx->pOutMutex;
- pthread_mutex_lock(pMutex);
- if (pCtx->pOutbuf[buf.index].bQueued == VIDEO_FALSE) {
- if (exynos_v4l2_qbuf(pCtx->hDec, &buf) != 0) {
- ALOGE("%s: Failed to enqueue output buffer", __func__);
- ret = VIDEO_ERROR_APIFAIL;
- goto EXIT;
- }
-
- pCtx->pOutbuf[buf.index].pPrivate = pPrivate;
- pCtx->pOutbuf[buf.index].bQueued = VIDEO_TRUE;
- } else {
- ALOGE("Lost Output Buffer");
- pthread_mutex_unlock(pMutex);
+ if (exynos_v4l2_qbuf(pCtx->hDec, &buf) != 0) {
+ ALOGE("%s: Failed to enqueue output buffer", __func__);
+ pCtx->pOutbuf[buf.index].bQueued = VIDEO_FALSE;
ret = VIDEO_ERROR_APIFAIL;
goto EXIT;
}
- pthread_mutex_unlock(pMutex);
+
+ pCtx->pOutbuf[buf.index].pPrivate = pPrivate;
EXIT:
return ret;
{
ExynosVideoDecContext *pCtx = (ExynosVideoDecContext *)pHandle;
ExynosVideoBuffer *pInbuf = NULL;
- pthread_mutex_t *pMutex = NULL;
struct v4l2_buffer buf;
goto EXIT;
}
- pMutex = (pthread_mutex_t*)pCtx->pInMutex;
- pthread_mutex_lock(pMutex);
- pCtx->pInbuf[buf.index].bQueued = VIDEO_FALSE;
- pthread_mutex_unlock(pMutex);
pInbuf = &pCtx->pInbuf[buf.index];
+ pCtx->pInbuf[buf.index].bQueued = VIDEO_FALSE;
if (pCtx->bStreamonInbuf == VIDEO_FALSE)
pInbuf = NULL;
return pInbuf;
}
-/*
- * [Decoder Buffer OPS] Enqueue All (Output)
- */
-static ExynosVideoErrorType MFC_Decoder_Enqueue_All_Outbuf(void *pHandle)
-{
- ExynosVideoDecContext *pCtx = (ExynosVideoDecContext *)pHandle;
- ExynosVideoErrorType ret = VIDEO_ERROR_NONE;
-
- unsigned char *pBuffer[VIDEO_BUFFER_MAX_PLANES] = {NULL, };
- unsigned int dataSize[VIDEO_BUFFER_MAX_PLANES] = {0, };
- int i;
-
- if (pCtx == NULL) {
- ALOGE("%s: Video context info must be supplied", __func__);
- ret = VIDEO_ERROR_BADPARAM;
- goto EXIT;
- }
-
- for (i = 0; i < pCtx->nOutbufs; i++) {
- ret = MFC_Decoder_Enqueue_Outbuf(pCtx, pBuffer, dataSize, 0, NULL);
- if (ret != VIDEO_ERROR_NONE)
- goto EXIT;
- }
-
-EXIT:
- return ret;
-}
-
/*
* [Decoder Buffer OPS] Dequeue (Output)
*/
{
ExynosVideoDecContext *pCtx = (ExynosVideoDecContext *)pHandle;
ExynosVideoBuffer *pOutbuf = NULL;
- pthread_mutex_t *pMutex = NULL;
struct v4l2_buffer buf;
int value;
break;
};
- pMutex = (pthread_mutex_t*)pCtx->pOutMutex;
- pthread_mutex_lock(pMutex);
pOutbuf->bQueued = VIDEO_FALSE;
- pthread_mutex_unlock(pMutex);
EXIT:
return pOutbuf;
.Run = MFC_Decoder_Run_Outbuf,
.Stop = MFC_Decoder_Stop_Outbuf,
.Enqueue = MFC_Decoder_Enqueue_Outbuf,
- .Enqueue_All = MFC_Decoder_Enqueue_All_Outbuf,
+ .Enqueue_All = NULL,
.Dequeue = MFC_Decoder_Dequeue_Outbuf,
.Register = MFC_Decoder_Register_Outbuf,
.Clear_RegisteredBuffer = MFC_Decoder_Clear_RegisteredBuffer_Outbuf,
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
+#include <pthread.h>
#include <sys/poll.h>
static ExynosVideoErrorType MFC_Encoder_Register_Inbuf(
void *pHandle,
- unsigned char *pBuffer[],
- unsigned int allocSize[])
+ ExynosVideoPlane *planes,
+ int nPlanes)
{
ExynosVideoEncContext *pCtx = (ExynosVideoEncContext *)pHandle;
ExynosVideoErrorType ret = VIDEO_ERROR_NONE;
int nIndex;
- if ((pCtx == NULL) || (pBuffer == NULL) || (allocSize == NULL)) {
+ if ((pCtx == NULL) || (planes == NULL) || (nPlanes != VIDEO_ENCODER_INBUF_PLANES)) {
ALOGE("%s: input params must be supplied", __func__);
ret = VIDEO_ERROR_BADPARAM;
goto EXIT;
for (nIndex = 0; nIndex < pCtx->nInbufs; nIndex++) {
if (pCtx->pInbuf[nIndex].bRegistered == VIDEO_FALSE) {
- pCtx->pInbuf[nIndex].planes[0].addr = pBuffer[0];
- pCtx->pInbuf[nIndex].planes[1].addr = pBuffer[1];
- pCtx->pInbuf[nIndex].planes[0].allocSize = allocSize[0];
- pCtx->pInbuf[nIndex].planes[1].allocSize = allocSize[1];
+ int plane;
+ for (plane = 0; plane < nPlanes; plane++) {
+ pCtx->pInbuf[nIndex].planes[plane].addr = planes[plane].addr;
+ pCtx->pInbuf[nIndex].planes[plane].allocSize = planes[plane].allocSize;
+ pCtx->pInbuf[nIndex].planes[plane].fd = planes[plane].fd;
+ }
pCtx->pInbuf[nIndex].bRegistered = VIDEO_TRUE;
break;
}
static ExynosVideoErrorType MFC_Encoder_Register_Outbuf(
void *pHandle,
- unsigned char *pBuffer[],
- unsigned int allocSize[])
+ ExynosVideoPlane *planes,
+ int nPlanes)
{
ExynosVideoEncContext *pCtx = (ExynosVideoEncContext *)pHandle;
ExynosVideoErrorType ret = VIDEO_ERROR_NONE;
int nIndex;
- if ((pCtx == NULL) || (pBuffer == NULL) || (allocSize == NULL)) {
- ALOGE("%s: input params must be supplied", __func__);
+ if ((pCtx == NULL) || (planes == NULL) || (nPlanes != VIDEO_ENCODER_OUTBUF_PLANES)) {
+ ALOGE("%s: params must be supplied", __func__);
ret = VIDEO_ERROR_BADPARAM;
goto EXIT;
}
for (nIndex = 0; nIndex < pCtx->nOutbufs; nIndex++) {
if (pCtx->pOutbuf[nIndex].bRegistered == VIDEO_FALSE) {
- pCtx->pOutbuf[nIndex].planes[0].addr = pBuffer[0];
- pCtx->pOutbuf[nIndex].planes[0].allocSize = allocSize[0];
+ int plane;
+ for (plane = 0; plane < nPlanes; plane++) {
+ pCtx->pOutbuf[nIndex].planes[plane].addr = planes[plane].addr;
+ pCtx->pOutbuf[nIndex].planes[plane].allocSize = planes[plane].allocSize;
+ pCtx->pOutbuf[nIndex].planes[plane].fd = planes[plane].fd;
+ }
pCtx->pOutbuf[nIndex].bRegistered = VIDEO_TRUE;
break;
}
}
for (nIndex = 0; nIndex < pCtx->nInbufs; nIndex++) {
- pCtx->pInbuf[nIndex].planes[0].addr = NULL;
- pCtx->pInbuf[nIndex].bRegistered = VIDEO_FALSE;
+ pCtx->pInbuf[nIndex].planes[0].addr = NULL;
+ pCtx->pInbuf[nIndex].bRegistered = VIDEO_FALSE;
}
EXIT:
}
for (nIndex = 0; nIndex < pCtx->nOutbufs; nIndex++) {
- pCtx->pOutbuf[nIndex].planes[0].addr = NULL;
- pCtx->pOutbuf[nIndex].bRegistered = VIDEO_FALSE;
+ pCtx->pOutbuf[nIndex].planes[0].addr = NULL;
+ pCtx->pOutbuf[nIndex].bRegistered = VIDEO_FALSE;
}
EXIT:
}
/*
- * [Encoder Buffer OPS] Find (Src)
+ * [Encoder Buffer OPS] Find (Input)
*/
static int MFC_Encoder_Find_Inbuf(
void *pHandle,
goto EXIT;
}
- if (pBuffer == NULL) {
- for (nIndex = 0; nIndex < pCtx->nInbufs; nIndex++) {
- if (pCtx->pInbuf[nIndex].bQueued == VIDEO_FALSE)
- break;
- }
- } else {
- for (nIndex = 0; nIndex < pCtx->nInbufs; nIndex++) {
- if (pCtx->pInbuf[nIndex].planes[0].addr == pBuffer)
+ for (nIndex = 0; nIndex < pCtx->nInbufs; nIndex++) {
+ if (pCtx->pInbuf[nIndex].bQueued == VIDEO_FALSE) {
+ if ((pBuffer == NULL) ||
+ (pCtx->pInbuf[nIndex].planes[0].addr == pBuffer))
break;
}
}
- if (nIndex == pCtx->nInbufs) {
+ if (nIndex == pCtx->nInbufs)
nIndex = -1;
- }
EXIT:
return nIndex;
}
/*
- * [Encoder Buffer OPS] Find (Dst)
+ * [Encoder Buffer OPS] Find (Outnput)
*/
static int MFC_Encoder_Find_Outbuf(
void *pHandle,
goto EXIT;
}
- if (pBuffer == NULL) {
- for (nIndex = 0; nIndex < pCtx->nOutbufs; nIndex++) {
- if (pCtx->pOutbuf[nIndex].bQueued == VIDEO_FALSE)
- break;
- }
- } else {
- for (nIndex = 0; nIndex < pCtx->nOutbufs; nIndex++) {
- if (pCtx->pOutbuf[nIndex].planes[0].addr == pBuffer)
+ for (nIndex = 0; nIndex < pCtx->nOutbufs; nIndex++) {
+ if (pCtx->pOutbuf[nIndex].bQueued == VIDEO_FALSE) {
+ if ((pBuffer == NULL) ||
+ (pCtx->pOutbuf[nIndex].planes[0].addr == pBuffer))
break;
}
}
- if (nIndex == pCtx->nOutbufs) {
+ if (nIndex == pCtx->nOutbufs)
nIndex = -1;
- }
EXIT:
return nIndex;
}
/*
- * [Encoder Buffer OPS] Enqueue (Src)
+ * [Encoder Buffer OPS] Enqueue (Input)
*/
static ExynosVideoErrorType MFC_Encoder_Enqueue_Inbuf(
void *pHandle,
buf.m.planes = planes;
buf.length = VIDEO_ENCODER_INBUF_PLANES;
+ pMutex = (pthread_mutex_t*)pCtx->pInMutex;
+ pthread_mutex_lock(pMutex);
index = MFC_Encoder_Find_Inbuf(pCtx, pBuffer[0]);
- if ((index == -1) &&
- (pCtx->bShareInbuf == VIDEO_TRUE) &&
- (pBuffer[0] != NULL))
- index = MFC_Encoder_Find_Inbuf(pCtx, NULL);
if (index == -1) {
- ALOGE("%s: Failed to find input buffer", __func__);
+ pthread_mutex_unlock(pMutex);
+ ALOGE("%s: Failed to get index", __func__);
ret = VIDEO_ERROR_NOBUFFERS;
goto EXIT;
}
buf.index = index;
+ pCtx->pInbuf[buf.index].bQueued = VIDEO_TRUE;
+ pthread_mutex_unlock(pMutex);
if (pCtx->bShareInbuf == VIDEO_TRUE) {
buf.memory = pCtx->nMemoryType;
for (i = 0; i < nPlanes; i++) {
+ /* V4L2_MEMORY_USERPTR */
buf.m.planes[i].m.userptr = (unsigned long)pBuffer[i];
+ /* V4L2_MEMORY_DMABUF */
+ buf.m.planes[i].m.fd = pCtx->pInbuf[buf.index].planes[i].fd;
buf.m.planes[i].length = pCtx->pInbuf[index].planes[i].allocSize;
buf.m.planes[i].bytesused = dataSize[i];
- pCtx->pInbuf[buf.index].planes[i].addr = pBuffer[i];
}
} else {
buf.memory = V4L2_MEMORY_MMAP;
buf.m.planes[i].bytesused = dataSize[i];
}
- pMutex = (pthread_mutex_t*)pCtx->pInMutex;
- pthread_mutex_lock(pMutex);
- if (pCtx->pInbuf[buf.index].bQueued == VIDEO_FALSE) {
- if (exynos_v4l2_qbuf(pCtx->hEnc, &buf) != 0) {
- ALOGE("%s: Failed to enqueue input buffer", __func__);
- ret = VIDEO_ERROR_APIFAIL;
- goto EXIT;
- }
-
- pCtx->pInbuf[buf.index].pPrivate = pPrivate;
- pCtx->pInbuf[buf.index].bQueued = VIDEO_TRUE;
- } else {
- ALOGE("Lost Input Buffer");
- pthread_mutex_unlock(pMutex);
+ if (exynos_v4l2_qbuf(pCtx->hEnc, &buf) != 0) {
+ ALOGE("%s: Failed to enqueue input buffer", __func__);
+ pCtx->pInbuf[buf.index].bQueued = VIDEO_FALSE;
ret = VIDEO_ERROR_APIFAIL;
goto EXIT;
}
- pthread_mutex_unlock(pMutex);
+
+ pCtx->pInbuf[buf.index].pPrivate = pPrivate;
EXIT:
return ret;
}
/*
- * [Encoder Buffer OPS] Enqueue (Dst)
+ * [Encoder Buffer OPS] Enqueue (Output)
*/
static ExynosVideoErrorType MFC_Encoder_Enqueue_Outbuf(
void *pHandle,
}
memset(&buf, 0, sizeof(buf));
-
buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
buf.m.planes = planes;
buf.length = VIDEO_ENCODER_OUTBUF_PLANES;
+ pMutex = (pthread_mutex_t*)pCtx->pOutMutex;
+ pthread_mutex_lock(pMutex);
index = MFC_Encoder_Find_Outbuf(pCtx, pBuffer[0]);
- if ((index == -1) &&
- (pCtx->bShareOutbuf == VIDEO_TRUE) &&
- (pBuffer[0] != NULL))
- index = MFC_Encoder_Find_Outbuf(pCtx, NULL);
if (index == -1) {
+ pthread_mutex_unlock(pMutex);
ALOGE("%s: Failed to get index", __func__);
ret = VIDEO_ERROR_NOBUFFERS;
goto EXIT;
}
-
buf.index = index;
+ pCtx->pOutbuf[buf.index].bQueued = VIDEO_TRUE;
+ pthread_mutex_unlock(pMutex);
if (pCtx->bShareOutbuf == VIDEO_TRUE) {
buf.memory = pCtx->nMemoryType;
for (i = 0; i < nPlanes; i++) {
- buf.m.planes[i].m.userptr = pCtx->pOutbuf[index].planes[i].addr;
+ /* V4L2_MEMORY_USERPTR */
+ buf.m.planes[i].m.userptr = (unsigned long)pBuffer[i];
+ /* V4L2_MEMORY_DMABUF */
+ buf.m.planes[i].m.fd = pCtx->pOutbuf[index].planes[i].fd;
buf.m.planes[i].length = pCtx->pOutbuf[index].planes[i].allocSize;
buf.m.planes[i].bytesused = dataSize[i];
- pCtx->pOutbuf[buf.index].planes[i].addr = buf.m.planes[i].m.userptr;
}
} else {
buf.memory = V4L2_MEMORY_MMAP;
}
- pMutex = (pthread_mutex_t*)pCtx->pOutMutex;
- pthread_mutex_lock(pMutex);
- if (pCtx->pOutbuf[buf.index].bQueued == VIDEO_FALSE) {
- if (exynos_v4l2_qbuf(pCtx->hEnc, &buf) != 0) {
- ALOGE("%s: Failed to enqueue output buffer", __func__);
- ret = VIDEO_ERROR_APIFAIL;
- goto EXIT;
- }
-
- pCtx->pOutbuf[buf.index].pPrivate = pPrivate;
- pCtx->pOutbuf[buf.index].bQueued = VIDEO_TRUE;
- } else {
- ALOGE("Lost Output Buffer");
- pthread_mutex_unlock(pMutex);
+ if (exynos_v4l2_qbuf(pCtx->hEnc, &buf) != 0) {
+ ALOGE("%s: Failed to enqueue output buffer", __func__);
+ pCtx->pOutbuf[buf.index].bQueued = VIDEO_FALSE;
ret = VIDEO_ERROR_APIFAIL;
goto EXIT;
}
- pthread_mutex_unlock(pMutex);
+
+ pCtx->pOutbuf[buf.index].pPrivate = pPrivate;
EXIT:
return ret;
}
/*
- * [Encoder Buffer OPS] Enqueue All (Dst)
+ * [Encoder Buffer OPS] Enqueue All (Output)
*/
static ExynosVideoErrorType MFC_Encoder_Enqueue_All_Outbuf(void *pHandle)
{
}
/*
- * [Encoder Buffer OPS] Dequeue (Src)
+ * [Encoder Buffer OPS] Dequeue (Input)
*/
static ExynosVideoBuffer *MFC_Encoder_Dequeue_Inbuf(void *pHandle)
{
ExynosVideoEncContext *pCtx = (ExynosVideoEncContext *)pHandle;
ExynosVideoBuffer *pInbuf = NULL;
- pthread_mutex_t *pMutex = NULL;
struct v4l2_buffer buf;
}
if (pCtx->bStreamonInbuf == VIDEO_FALSE) {
+ pInbuf = NULL;
goto EXIT;
}
buf.memory = V4L2_MEMORY_MMAP;
if (exynos_v4l2_dqbuf(pCtx->hEnc, &buf) != 0) {
+ pInbuf = NULL;
goto EXIT;
}
- pMutex = (pthread_mutex_t *)pCtx->pInMutex;
- pthread_mutex_lock(pMutex);
- pCtx->pInbuf[buf.index].bQueued = VIDEO_FALSE;
- pthread_mutex_unlock(pMutex);
pInbuf = &pCtx->pInbuf[buf.index];
+ pCtx->pInbuf[buf.index].bQueued = VIDEO_FALSE;
EXIT:
return pInbuf;
}
/*
- * [Encoder Buffer OPS] Dequeue (Dst)
+ * [Encoder Buffer OPS] Dequeue (Output)
*/
static ExynosVideoBuffer *MFC_Encoder_Dequeue_Outbuf(void *pHandle)
{
ExynosVideoEncContext *pCtx = (ExynosVideoEncContext *)pHandle;
ExynosVideoBuffer *pOutbuf = NULL;
- pthread_mutex_t *pMutex = NULL;
struct v4l2_buffer buf;
struct v4l2_plane planes[VIDEO_ENCODER_OUTBUF_PLANES];
}
if (pCtx->bStreamonOutbuf == VIDEO_FALSE) {
+ pOutbuf = NULL;
goto EXIT;
}
break;
};
- pMutex = (pthread_mutex_t*)pCtx->pOutMutex;
- pthread_mutex_lock(pMutex);
pOutbuf->bQueued = VIDEO_FALSE;
- pthread_mutex_unlock(pMutex);
EXIT:
return pOutbuf;
goto EXIT;
}
- for (i = 0; i < pCtx->nInbufs; i++) {
+ for (i = 0; i < pCtx->nInbufs; i++) {
pCtx->pInbuf[i].bQueued = VIDEO_FALSE;
}
.Run = MFC_Encoder_Run_Outbuf,
.Stop = MFC_Encoder_Stop_Outbuf,
.Enqueue = MFC_Encoder_Enqueue_Outbuf,
- .Enqueue_All = MFC_Encoder_Enqueue_All_Outbuf,
+ .Enqueue_All = NULL,
.Dequeue = MFC_Encoder_Dequeue_Outbuf,
.Register = MFC_Encoder_Register_Outbuf,
.Clear_RegisteredBuffer = MFC_Encoder_Clear_RegisteredBuffer_Outbuf,