diff options
-rw-r--r-- | camera/V4LCameraAdapter/V4LCameraAdapter.cpp | 22 | ||||
-rw-r--r-- | camera/inc/V4LCameraAdapter/V4LCameraAdapter.h | 4 |
2 files changed, 19 insertions, 7 deletions
diff --git a/camera/V4LCameraAdapter/V4LCameraAdapter.cpp b/camera/V4LCameraAdapter/V4LCameraAdapter.cpp index 006b8df..b4798f9 100644 --- a/camera/V4LCameraAdapter/V4LCameraAdapter.cpp +++ b/camera/V4LCameraAdapter/V4LCameraAdapter.cpp @@ -157,8 +157,8 @@ status_t V4LCameraAdapter::v4lStartStreaming () { // for such cameras can be dynamically set frame count that will be // skipped after frame on. for (int i = 0; i < mSkipFramesCount; i++) { - int id = 0, length = 0; - if (GetFrame(id, length) != NULL) { + int id = 0, field = 0; + if (GetFrame(id, field) != NULL) { returnBufferToV4L(id); } } @@ -644,6 +644,8 @@ status_t V4LCameraAdapter::startPreview() goto EXIT; } + mLastField = V4L2_FIELD_TOP; + startM2MDevice(); for (int i = 0; i < mPreviewBufferCountQueueable; i++) { @@ -758,7 +760,7 @@ void saveFile(unsigned char* buff, int buff_size) { LOG_FUNCTION_NAME_EXIT; } -char * V4LCameraAdapter::GetFrame(int &index, int &filledLen) +char * V4LCameraAdapter::GetFrame(int &index, int &field) { int ret = NO_ERROR; LOG_FUNCTION_NAME; @@ -799,6 +801,7 @@ char * V4LCameraAdapter::GetFrame(int &index, int &filledLen) return NULL; } + field = buf.field; mCameraBuffers[index].actual_size = buf.bytesused; debugShowFPS(); @@ -1038,7 +1041,7 @@ int V4LCameraAdapter::previewThread() CameraFrame frame; void *y_uv[2]; int index = 0; - int filledLen = 0; + int field = 0; int stride = 4096; char *fp = NULL; int in_index =-1, out_index = -1; @@ -1063,19 +1066,26 @@ int V4LCameraAdapter::previewThread() } { - fp = GetFrame(index, filledLen); + fp = GetFrame(index, field); if(!fp) { ret = BAD_VALUE; goto EXIT; } - CAMHAL_LOGEA("CHECK field=%d", ((v4l2_buffer*)(mCameraBuffers[index].opaque))->field); CAMHAL_LOGD("GOT IN frame with ID=%d",index); CameraBuffer *buffer = mPreviewBufs[index]; int retVal = 0; if (mPixelFormat == V4L2_PIX_FMT_YUYV) { if (mDeinterlaceEnabled) { + if(mLastField == field) + { + CAMHAL_LOGEA("CHECK LASTFIELD=field"); + returnBufferToV4L(index); + return 0; + } + mLastField = field; + CAMHAL_LOGEA("CHECK NEW FIELD=%d", field); alignedWidth = ALIGN(width, HW_ALIGN); retVal = processFrame(&mCameraBuffers[index], width, height, width, "yuyv", (void*)(*(buffer_handle_t*)(buffer->opaque)), alignedWidth, height, PAGE_SIZE, "nv12", mDeinterlaceEnabled, 1, index, &in_index, &out_index); } else { diff --git a/camera/inc/V4LCameraAdapter/V4LCameraAdapter.h b/camera/inc/V4LCameraAdapter/V4LCameraAdapter.h index 538fec2..80629f3 100644 --- a/camera/inc/V4LCameraAdapter/V4LCameraAdapter.h +++ b/camera/inc/V4LCameraAdapter/V4LCameraAdapter.h @@ -164,7 +164,7 @@ private: //Used for calculation of the average frame rate during preview status_t recalculateFPS(); - char * GetFrame(int &index, int &filledLen); + char * GetFrame(int &index, int &field); int previewThread(); @@ -233,6 +233,8 @@ private: struct VideoInfo *mVideoInfo; int mCameraHandle; + int mLastField; + int nQueued; int nDequeued; int mQueuedOutputBuffers; |