From 613a69abe8f0dae39ffb64f4d8472c9ae4ae22ef Mon Sep 17 00:00:00 2001 From: Andrey Kamaev Date: Thu, 19 May 2011 06:36:44 +0000 Subject: [PATCH] Tegra optimization for yuv420i to rgb conversion --- modules/highgui/src/cap_android.cpp | 8 ++++++++ modules/highgui/src/precomp.hpp | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/modules/highgui/src/cap_android.cpp b/modules/highgui/src/cap_android.cpp index 8f82e39..4a0fb77 100644 --- a/modules/highgui/src/cap_android.cpp +++ b/modules/highgui/src/cap_android.cpp @@ -48,10 +48,12 @@ #include #include "camera_activity.h" +#if !defined(LOGD) && !defined(LOGI) && !defined(LOGE) #define LOG_TAG "CV_CAP" #define LOGD(...) ((void)__android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)) #define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)) #define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)) +#endif class HighguiAndroidCameraActivity; @@ -457,6 +459,7 @@ bool CvCapture_Android::convertYUV420i2Grey(int width, int height, const unsigne return !resmat.empty(); } +#ifndef HAVE_TEGRA_OPTIMIZATION template struct YUV420i2BGR888Invoker { @@ -513,6 +516,7 @@ struct YUV420i2BGR888Invoker } } }; +#endif bool CvCapture_Android::convertYUV420i2BGR888(int width, int height, const unsigned char* yuv, cv::Mat& resmat, bool inRGBorder) { @@ -524,10 +528,14 @@ bool CvCapture_Android::convertYUV420i2BGR888(int width, int height, const unsig unsigned char* y1 = (unsigned char*)yuv; unsigned char* uv = y1 + width * height; +#ifdef HAVE_TEGRA_OPTIMIZATION + cv::parallel_for(cv::BlockedRange(0, height, 2), tegra::YUV420i2BGR888Invoker(resmat, width, y1, uv, inRGBorder)); +#else if (inRGBorder) cv::parallel_for(cv::BlockedRange(0, height, 2), YUV420i2BGR888Invoker<2>(resmat, width, y1, uv)); else cv::parallel_for(cv::BlockedRange(0, height, 2), YUV420i2BGR888Invoker<0>(resmat, width, y1, uv)); +#endif return !resmat.empty(); } diff --git a/modules/highgui/src/precomp.hpp b/modules/highgui/src/precomp.hpp index 2c58838..1a96b41 100644 --- a/modules/highgui/src/precomp.hpp +++ b/modules/highgui/src/precomp.hpp @@ -60,6 +60,10 @@ #include #include +#ifdef HAVE_TEGRA_OPTIMIZATION +#include "opencv2/highgui/highgui_tegra.hpp" +#endif + #if defined WIN32 || defined _WIN32 #define WIN32_LEAN_AND_MEAN -- 2.7.4