diff options
author | Eino-Ville Talvala <etalvala@google.com> | 2013-05-10 23:59:04 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2013-05-10 23:59:04 +0000 |
commit | 5fd5b268201e2fc21aaeba4fbac11195ee430c71 (patch) | |
tree | 53225bcc7cc77645f830c63f5aff5e12d97ac353 /services/camera | |
parent | 6d0cf90b6b28cbb7e3e1b3ae32017aa4b44b6452 (diff) | |
parent | fcbf94b9407b28d5a5f1a14e822e8b9ee264b7d8 (diff) | |
download | frameworks_av-5fd5b268201e2fc21aaeba4fbac11195ee430c71.zip frameworks_av-5fd5b268201e2fc21aaeba4fbac11195ee430c71.tar.gz frameworks_av-5fd5b268201e2fc21aaeba4fbac11195ee430c71.tar.bz2 |
Merge "Camera2/3: Optimize a few YCbCr_420_888 copy paths" into jb-mr2-dev
Diffstat (limited to 'services/camera')
-rw-r--r-- | services/camera/libcameraservice/camera2/CallbackProcessor.cpp | 66 |
1 files changed, 46 insertions, 20 deletions
diff --git a/services/camera/libcameraservice/camera2/CallbackProcessor.cpp b/services/camera/libcameraservice/camera2/CallbackProcessor.cpp index a3d6cb2..5e88102 100644 --- a/services/camera/libcameraservice/camera2/CallbackProcessor.cpp +++ b/services/camera/libcameraservice/camera2/CallbackProcessor.cpp @@ -411,35 +411,61 @@ status_t CallbackProcessor::convertFromFlexibleYuv(int32_t previewFormat, size_t dstChromaGap = dstCStride - chromaWidth; if (previewFormat == HAL_PIXEL_FORMAT_YCrCb_420_SP) { - // NV21 + // Flexible YUV chroma to NV21 chroma uint8_t *vuDst = yDst; - for (size_t row = 0; row < chromaHeight; row++) { - for (size_t col = 0; col < chromaWidth; col++) { - *(vuDst++) = *vSrc; - *(vuDst++) = *uSrc; - vSrc += src.chromaStep; - uSrc += src.chromaStep; + // Check for shortcuts + if (uSrc == vSrc + 1 && src.chromaStep == 2) { + // Source has semiplanar CrCb chroma layout, can copy by rows + for (size_t row = 0; row < chromaHeight; row++) { + memcpy(vuDst, uSrc, src.width); + vuDst += src.width; + uSrc += src.chromaStride; + } + } else { + // Generic copy, always works but not very efficient + for (size_t row = 0; row < chromaHeight; row++) { + for (size_t col = 0; col < chromaWidth; col++) { + *(vuDst++) = *vSrc; + *(vuDst++) = *uSrc; + vSrc += src.chromaStep; + uSrc += src.chromaStep; + } + vSrc += chromaGap; + uSrc += chromaGap; } - vSrc += chromaGap; - uSrc += chromaGap; } } else { - // YV12 + // flexible YUV chroma to YV12 chroma ALOG_ASSERT(previewFormat == HAL_PIXEL_FORMAT_YV12, "Unexpected preview format 0x%x", previewFormat); uint8_t *vDst = yDst; uint8_t *uDst = yDst + chromaHeight * dstCStride; - for (size_t row = 0; row < chromaHeight; row++) { - for (size_t col = 0; col < chromaWidth; col++) { - *(vDst++) = *vSrc; - *(uDst++) = *uSrc; - vSrc += src.chromaStep; - uSrc += src.chromaStep; + if (src.chromaStep == 1) { + // Source has planar chroma layout, can copy by row + for (size_t row = 0; row < chromaHeight; row++) { + memcpy(vDst, vSrc, chromaWidth); + vDst += dstCStride; + vSrc += src.chromaStride; + } + for (size_t row = 0; row < chromaHeight; row++) { + memcpy(uDst, uSrc, chromaWidth); + uDst += dstCStride; + uSrc += src.chromaStride; + } + } else { + // Generic copy, always works but not very efficient + for (size_t row = 0; row < chromaHeight; row++) { + for (size_t col = 0; col < chromaWidth; col++) { + *(vDst++) = *vSrc; + *(uDst++) = *uSrc; + vSrc += src.chromaStep; + uSrc += src.chromaStep; + } + vSrc += chromaGap; + uSrc += chromaGap; + vDst += dstChromaGap; + uDst += dstChromaGap; } - vSrc += chromaGap; - uSrc += chromaGap; - vDst += dstChromaGap; - uDst += dstChromaGap; } } |