@ -18,13 +18,18 @@ namespace cv {
namespace hal {
// 8u, 16u, 32f
void cvtBGRtoYUV ( const uchar * src_data , size_t src_step ,
static void cvtBGRtoYUV ( const uchar * src_data , size_t src_step ,
uchar * dst_data , size_t dst_step ,
int width , int height ,
int depth , int scn , bool swapBlue , bool isCbCr )
int depth , int scn , bool swapBlue , bool isCbCr , AlgorithmHint hint )
{
CV_INSTRUMENT_REGION ( ) ;
if ( hint = = ALGO_HINT_APPROX )
{
CALL_HAL ( cvtBGRtoYUV , cv_hal_cvtBGRtoYUVApprox , src_data , src_step , dst_data , dst_step , width , height , depth , scn , swapBlue , isCbCr ) ;
}
CALL_HAL ( cvtBGRtoYUV , cv_hal_cvtBGRtoYUV , src_data , src_step , dst_data , dst_step , width , height , depth , scn , swapBlue , isCbCr ) ;
# if defined(HAVE_IPP)
@ -66,13 +71,18 @@ void cvtBGRtoYUV(const uchar * src_data, size_t src_step,
CV_CPU_DISPATCH_MODES_ALL ) ;
}
void cvtYUVtoBGR ( const uchar * src_data , size_t src_step ,
static void cvtYUVtoBGR ( const uchar * src_data , size_t src_step ,
uchar * dst_data , size_t dst_step ,
int width , int height ,
int depth , int dcn , bool swapBlue , bool isCbCr )
int depth , int dcn , bool swapBlue , bool isCbCr , AlgorithmHint hint )
{
CV_INSTRUMENT_REGION ( ) ;
if ( hint = = ALGO_HINT_APPROX )
{
CALL_HAL ( cvtYUVtoBGR , cv_hal_cvtYUVtoBGRApprox , src_data , src_step , dst_data , dst_step , width , height , depth , dcn , swapBlue , isCbCr ) ;
}
CALL_HAL ( cvtYUVtoBGR , cv_hal_cvtYUVtoBGR , src_data , src_step , dst_data , dst_step , width , height , depth , dcn , swapBlue , isCbCr ) ;
@ -115,63 +125,79 @@ void cvtYUVtoBGR(const uchar * src_data, size_t src_step,
CV_CPU_DISPATCH_MODES_ALL ) ;
}
// 4:2:0, two planes in one array : Y, UV interleaved
// 4:2:0, two planes: Y, UV interleaved
// Y : [16, 235]; Cb, Cr: [16, 240] centered at 128
// 20-bit fixed-point arithmetics
void cvtTwoPlaneYUVtoBGR ( const uchar * s rc _data, size_t src _step,
static void cvtTwoPlaneYUVtoBGR ( const uchar * y_data , size_t y_step , const ucha r * uv _data , size_t uv _step,
uchar * dst_data , size_t dst_step ,
int dst_width , int dst_height ,
int dcn , bool swapBlue , int uIdx )
int dcn , bool swapBlue , int uIdx , AlgorithmHint hint )
{
CV_INSTRUMENT_REGION ( ) ;
CALL_HAL ( cvtTwoPlaneYUVtoBGR , cv_hal_cvtTwoPlaneYUVtoBGR , src_data , src_step , dst_data , dst_step , dst_width , dst_height , dcn , swapBlue , uIdx ) ;
if ( hint = = ALGO_HINT_APPROX )
{
CALL_HAL ( cvtTwoPlaneYUVtoBGREx , cv_hal_cvtTwoPlaneYUVtoBGRExApprox ,
y_data , y_step , uv_data , uv_step , dst_data , dst_step , dst_width , dst_height , dcn , swapBlue , uIdx ) ;
}
cvtTwoPlaneYUVtoBGR (
src_data , src_step , src_data + src_step * dst_height , src_step , dst_data , dst_step ,
dst_width , dst_height , dcn , swapBlue , uIdx ) ;
CALL_HAL ( cvtTwoPlaneYUVtoBGREx , cv_hal_cvtTwoPlaneYUVtoBGREx ,
y_data , y_step , uv_data , uv_step , dst_data , dst_step , dst_width , dst_height , dcn , swapBlue , uIdx ) ;
CV_CPU_DISPATCH ( cvtTwoPlaneYUVtoBGR , ( y_data , y_step , uv_data , uv_step , dst_data , dst_step , dst_width , dst_height , dcn , swapBlue , uIdx ) ,
CV_CPU_DISPATCH_MODES_ALL ) ;
}
// 4:2:0, two planes: Y, UV interleaved
// 4:2:0, two planes in one array : Y, UV interleaved
// Y : [16, 235]; Cb, Cr: [16, 240] centered at 128
// 20-bit fixed-point arithmetics
void cvtTwoPlaneYUVtoBGR ( const uchar * y_data , const ucha r * uv _data , size_t src_step ,
static void cvtTwoPlaneYUVtoBGR ( const uchar * s rc _data, size_t src_step ,
uchar * dst_data , size_t dst_step ,
int dst_width , int dst_height ,
int dcn , bool swapBlue , int uIdx )
int dcn , bool swapBlue , int uIdx , AlgorithmHint hint )
{
CV_INSTRUMENT_REGION ( ) ;
cvtTwoPlaneYUVtoBGR ( y_data , src_step , uv_data , src_step , dst_data , dst_step , dst_width , dst_height , dcn , swapBlue , uIdx ) ;
if ( hint = = ALGO_HINT_APPROX )
{
CALL_HAL ( cvtTwoPlaneYUVtoBGR , cv_hal_cvtTwoPlaneYUVtoBGRApprox , src_data , src_step , dst_data , dst_step , dst_width , dst_height , dcn , swapBlue , uIdx ) ;
}
CALL_HAL ( cvtTwoPlaneYUVtoBGR , cv_hal_cvtTwoPlaneYUVtoBGR , src_data , src_step , dst_data , dst_step , dst_width , dst_height , dcn , swapBlue , uIdx ) ;
cvtTwoPlaneYUVtoBGR (
src_data , src_step , src_data + src_step * dst_height , src_step , dst_data , dst_step ,
dst_width , dst_height , dcn , swapBlue , uIdx , hint ) ;
}
// 4:2:0, two planes: Y, UV interleaved
// Y : [16, 235]; Cb, Cr: [16, 240] centered at 128
// 20-bit fixed-point arithmetics
void cvtTwoPlaneYUVtoBGR ( const uchar * y_data , size_t y_step , const uchar * uv_data , size_t uv_step ,
static void cvtTwoPlaneYUVtoBGR ( const uchar * y_data , const uchar * uv_data , size_t src _step,
uchar * dst_data , size_t dst_step ,
int dst_width , int dst_height ,
int dcn , bool swapBlue , int uIdx )
int dcn , bool swapBlue , int uIdx , AlgorithmHint hint )
{
CV_INSTRUMENT_REGION ( ) ;
CALL_HAL ( cvtTwoPlaneYUVtoBGREx , cv_hal_cvtTwoPlaneYUVtoBGREx ,
y_data , y_step , uv_data , uv_step , dst_data , dst_step , dst_width , dst_height , dcn , swapBlue , uIdx ) ;
CV_CPU_DISPATCH ( cvtTwoPlaneYUVtoBGR , ( y_data , y_step , uv_data , uv_step , dst_data , dst_step , dst_width , dst_height , dcn , swapBlue , uIdx ) ,
CV_CPU_DISPATCH_MODES_ALL ) ;
cvtTwoPlaneYUVtoBGR ( y_data , src_step , uv_data , src_step , dst_data , dst_step , dst_width , dst_height , dcn , swapBlue , uIdx , hint ) ;
}
// 4:2:0, three planes in one array: Y, U, V
// Y : [16, 235]; Cb, Cr: [16, 240] centered at 128
// 20-bit fixed-point arithmetics
void cvtThreePlaneYUVtoBGR ( const uchar * src_data , size_t src_step ,
static void cvtThreePlaneYUVtoBGR ( const uchar * src_data , size_t src_step ,
uchar * dst_data , size_t dst_step ,
int dst_width , int dst_height ,
int dcn , bool swapBlue , int uIdx )
int dcn , bool swapBlue , int uIdx , AlgorithmHint hint )
{
CV_INSTRUMENT_REGION ( ) ;
if ( hint = = ALGO_HINT_APPROX )
{
CALL_HAL ( cvtThreePlaneYUVtoBGR , cv_hal_cvtThreePlaneYUVtoBGRApprox , src_data , src_step , dst_data , dst_step , dst_width , dst_height , dcn , swapBlue , uIdx ) ;
}
CALL_HAL ( cvtThreePlaneYUVtoBGR , cv_hal_cvtThreePlaneYUVtoBGR , src_data , src_step , dst_data , dst_step , dst_width , dst_height , dcn , swapBlue , uIdx ) ;
CV_CPU_DISPATCH ( cvtThreePlaneYUVtoBGR , ( src_data , src_step , dst_data , dst_step , dst_width , dst_height , dcn , swapBlue , uIdx ) ,
@ -181,46 +207,39 @@ void cvtThreePlaneYUVtoBGR(const uchar * src_data, size_t src_step,
// 4:2:0, three planes in one array: Y, U, V
// Y : [16, 235]; Cb, Cr: [16, 240] centered at 128
// 20-bit fixed-point arithmetics
void cvtBGRtoThreePlaneYUV ( const uchar * src_data , size_t src_step ,
static void cvtBGRtoThreePlaneYUV ( const uchar * src_data , size_t src_step ,
uchar * dst_data , size_t dst_step ,
int width , int height ,
int scn , bool swapBlue , int uIdx )
int scn , bool swapBlue , int uIdx , AlgorithmHint hint )
{
CV_INSTRUMENT_REGION ( ) ;
if ( hint = = ALGO_HINT_APPROX )
{
CALL_HAL ( cvtBGRtoThreePlaneYUV , cv_hal_cvtBGRtoThreePlaneYUVApprox , src_data , src_step , dst_data , dst_step , width , height , scn , swapBlue , uIdx ) ;
}
CALL_HAL ( cvtBGRtoThreePlaneYUV , cv_hal_cvtBGRtoThreePlaneYUV , src_data , src_step , dst_data , dst_step , width , height , scn , swapBlue , uIdx ) ;
CV_CPU_DISPATCH ( cvtBGRtoThreePlaneYUV , ( src_data , src_step , dst_data , dst_step , width , height , scn , swapBlue , uIdx ) ,
CV_CPU_DISPATCH_MODES_ALL ) ;
}
// 4:2:0, two planes: Y, UV interleaved
// Y : [16, 235]; Cb, Cr: [16, 240] centered at 128
// 20-bit fixed-point arithmetics
void cvtBGRtoTwoPlaneYUV ( const uchar * src_data , size_t src_step ,
uchar * y_data , uchar * uv_data , size_t dst_step ,
int width , int height ,
int scn , bool swapBlue , int uIdx )
{
CV_INSTRUMENT_REGION ( ) ;
CALL_HAL ( cvtBGRtoTwoPlaneYUV , cv_hal_cvtBGRtoTwoPlaneYUV ,
src_data , src_step , y_data , dst_step , uv_data , dst_step , width , height , scn , swapBlue , uIdx ) ;
CV_CPU_DISPATCH ( cvtBGRtoTwoPlaneYUV , ( src_data , src_step , y_data , uv_data , dst_step , width , height , scn , swapBlue , uIdx ) ,
CV_CPU_DISPATCH_MODES_ALL ) ;
}
// 4:2:2 interleaved
// Y : [16, 235]; Cb, Cr: [16, 240] centered at 128
// 20-bit fixed-point arithmetics
void cvtOnePlaneYUVtoBGR ( const uchar * src_data , size_t src_step ,
static void cvtOnePlaneYUVtoBGR ( const uchar * src_data , size_t src_step ,
uchar * dst_data , size_t dst_step ,
int width , int height ,
int dcn , bool swapBlue , int uIdx , int ycn )
int dcn , bool swapBlue , int uIdx , int ycn , AlgorithmHint hint )
{
CV_INSTRUMENT_REGION ( ) ;
if ( hint = = ALGO_HINT_APPROX )
{
CALL_HAL ( cvtOnePlaneYUVtoBGR , cv_hal_cvtOnePlaneYUVtoBGRApprox , src_data , src_step , dst_data , dst_step , width , height , dcn , swapBlue , uIdx , ycn ) ;
}
CALL_HAL ( cvtOnePlaneYUVtoBGR , cv_hal_cvtOnePlaneYUVtoBGR , src_data , src_step , dst_data , dst_step , width , height , dcn , swapBlue , uIdx , ycn ) ;
CV_CPU_DISPATCH ( cvtOnePlaneYUVtoBGR , ( src_data , src_step , dst_data , dst_step , width , height , dcn , swapBlue , uIdx , ycn ) ,
@ -230,13 +249,18 @@ void cvtOnePlaneYUVtoBGR(const uchar * src_data, size_t src_step,
// 4:2:2 interleaved
// Y : [16, 235]; Cb, Cr: [16, 240] centered at 128
// 14-bit fixed-point arithmetics is used
void cvtOnePlaneBGRtoYUV ( const uchar * src_data , size_t src_step ,
static void cvtOnePlaneBGRtoYUV ( const uchar * src_data , size_t src_step ,
uchar * dst_data , size_t dst_step ,
int width , int height ,
int scn , bool swapBlue , int uIdx , int ycn )
int scn , bool swapBlue , int uIdx , int ycn , AlgorithmHint hint )
{
CV_INSTRUMENT_REGION ( ) ;
if ( hint = = ALGO_HINT_APPROX )
{
CALL_HAL ( cvtOnePlaneBGRtoYUV , cv_hal_cvtOnePlaneBGRtoYUVApprox , src_data , src_step , dst_data , dst_step , width , height , scn , swapBlue , uIdx , ycn ) ;
}
CALL_HAL ( cvtOnePlaneBGRtoYUV , cv_hal_cvtOnePlaneBGRtoYUV , src_data , src_step , dst_data , dst_step , width , height , scn , swapBlue , uIdx , ycn ) ;
CV_CPU_DISPATCH ( cvtOnePlaneBGRtoYUV , ( src_data , src_step , dst_data , dst_step , width , height , scn , swapBlue , uIdx , ycn ) ,
@ -386,43 +410,43 @@ bool oclCvtColorBGR2ThreePlaneYUV( InputArray _src, OutputArray _dst, int bidx,
// HAL calls
//
void cvtColorBGR2YUV ( InputArray _src , OutputArray _dst , bool swapb , bool crcb )
void cvtColorBGR2YUV ( InputArray _src , OutputArray _dst , AlgorithmHint hint , bool swapb , bool crcb )
{
CvtHelper < Set < 3 , 4 > , Set < 3 > , Set < CV_8U , CV_16U , CV_32F > > h ( _src , _dst , 3 ) ;
hal : : cvtBGRtoYUV ( h . src . data , h . src . step , h . dst . data , h . dst . step , h . src . cols , h . src . rows ,
h . depth , h . scn , swapb , crcb ) ;
h . depth , h . scn , swapb , crcb , hint ) ;
}
void cvtColorYUV2BGR ( InputArray _src , OutputArray _dst , int dcn , bool swapb , bool crcb )
void cvtColorYUV2BGR ( InputArray _src , OutputArray _dst , AlgorithmHint hint , int dcn , bool swapb , bool crcb )
{
if ( dcn < = 0 ) dcn = 3 ;
CvtHelper < Set < 3 > , Set < 3 , 4 > , Set < CV_8U , CV_16U , CV_32F > > h ( _src , _dst , dcn ) ;
hal : : cvtYUVtoBGR ( h . src . data , h . src . step , h . dst . data , h . dst . step , h . src . cols , h . src . rows ,
h . depth , dcn , swapb , crcb ) ;
h . depth , dcn , swapb , crcb , hint ) ;
}
// 4:2:2 interleaved
// Y : [16, 235]; Cb, Cr: [16, 240] centered at 128
// 20-bit fixed-point arithmetics
void cvtColorOnePlaneYUV2BGR ( InputArray _src , OutputArray _dst , int dcn , bool swapb , int uidx , int ycn )
void cvtColorOnePlaneYUV2BGR ( InputArray _src , OutputArray _dst , AlgorithmHint hint , int dcn , bool swapb , int uidx , int ycn )
{
CvtHelper < Set < 2 > , Set < 3 , 4 > , Set < CV_8U > , FROM_UYVY > h ( _src , _dst , dcn ) ;
hal : : cvtOnePlaneYUVtoBGR ( h . src . data , h . src . step , h . dst . data , h . dst . step , h . src . cols , h . src . rows ,
dcn , swapb , uidx , ycn ) ;
dcn , swapb , uidx , ycn , hint ) ;
}
// 4:2:2 interleaved
// Y : [16, 235]; Cb, Cr: [16, 240] centered at 128
// 14-bit fixed-point arithmetics is used
void cvtColorOnePlaneBGR2YUV ( InputArray _src , OutputArray _dst , bool swapb , int uidx , int ycn )
void cvtColorOnePlaneBGR2YUV ( InputArray _src , OutputArray _dst , AlgorithmHint hint , bool swapb , int uidx , int ycn )
{
CvtHelper < Set < 3 , 4 > , Set < 2 > , Set < CV_8U > , TO_UYVY > h ( _src , _dst , 2 ) ;
hal : : cvtOnePlaneBGRtoYUV ( h . src . data , h . src . step , h . dst . data , h . dst . step , h . src . cols , h . src . rows ,
h . scn , swapb , uidx , ycn ) ;
h . scn , swapb , uidx , ycn , hint ) ;
}
void cvtColorYUV2Gray_ch ( InputArray _src , OutputArray _dst , int coi )
@ -435,12 +459,12 @@ void cvtColorYUV2Gray_ch( InputArray _src, OutputArray _dst, int coi )
// 4:2:0, three planes in one array: Y, U, V
// Y : [16, 235]; Cb, Cr: [16, 240] centered at 128
// 20-bit fixed-point arithmetics
void cvtColorBGR2ThreePlaneYUV ( InputArray _src , OutputArray _dst , bool swapb , int uidx )
void cvtColorBGR2ThreePlaneYUV ( InputArray _src , OutputArray _dst , AlgorithmHint hint , bool swapb , int uidx )
{
CvtHelper < Set < 3 , 4 > , Set < 1 > , Set < CV_8U > , TO_YUV > h ( _src , _dst , 1 ) ;
hal : : cvtBGRtoThreePlaneYUV ( h . src . data , h . src . step , h . dst . data , h . dst . step , h . src . cols , h . src . rows ,
h . scn , swapb , uidx ) ;
h . scn , swapb , uidx , hint ) ;
}
void cvtColorYUV2Gray_420 ( InputArray _src , OutputArray _dst )
@ -460,32 +484,32 @@ void cvtColorYUV2Gray_420( InputArray _src, OutputArray _dst )
// 4:2:0, three planes in one array: Y, U, V
// Y : [16, 235]; Cb, Cr: [16, 240] centered at 128
// 20-bit fixed-point arithmetics
void cvtColorThreePlaneYUV2BGR ( InputArray _src , OutputArray _dst , int dcn , bool swapb , int uidx )
void cvtColorThreePlaneYUV2BGR ( InputArray _src , OutputArray _dst , AlgorithmHint hint , int dcn , bool swapb , int uidx )
{
if ( dcn < = 0 ) dcn = 3 ;
CvtHelper < Set < 1 > , Set < 3 , 4 > , Set < CV_8U > , FROM_YUV > h ( _src , _dst , dcn ) ;
hal : : cvtThreePlaneYUVtoBGR ( h . src . data , h . src . step , h . dst . data , h . dst . step , h . dst . cols , h . dst . rows ,
dcn , swapb , uidx ) ;
dcn , swapb , uidx , hint ) ;
}
// 4:2:0, two planes in one array: Y, UV interleaved
// Y : [16, 235]; Cb, Cr: [16, 240] centered at 128
// 20-bit fixed-point arithmetics
// see also: http://www.fourcc.org/yuv.php#NV21, http://www.fourcc.org/yuv.php#NV12
void cvtColorTwoPlaneYUV2BGR ( InputArray _src , OutputArray _dst , int dcn , bool swapb , int uidx )
void cvtColorTwoPlaneYUV2BGR ( InputArray _src , OutputArray _dst , AlgorithmHint hint , int dcn , bool swapb , int uidx )
{
if ( dcn < = 0 ) dcn = 3 ;
CvtHelper < Set < 1 > , Set < 3 , 4 > , Set < CV_8U > , FROM_YUV > h ( _src , _dst , dcn ) ;
hal : : cvtTwoPlaneYUVtoBGR ( h . src . data , h . src . step , h . dst . data , h . dst . step , h . dst . cols , h . dst . rows ,
dcn , swapb , uidx ) ;
dcn , swapb , uidx , hint ) ;
}
// 4:2:0, two planes: Y, UV interleaved
// Y : [16, 235]; Cb, Cr: [16, 240] centered at 128
// 20-bit fixed-point arithmetics
void cvtColorTwoPlaneYUV2BGRpair ( InputArray _ysrc , InputArray _uvsrc , OutputArray _dst , int dcn , bool swapb , int uidx )
void cvtColorTwoPlaneYUV2BGRpair ( InputArray _ysrc , InputArray _uvsrc , OutputArray _dst , AlgorithmHint hint , int dcn , bool swapb , int uidx )
{
int stype = _ysrc . type ( ) ;
int depth = CV_MAT_DEPTH ( stype ) ;
@ -503,13 +527,13 @@ void cvtColorTwoPlaneYUV2BGRpair( InputArray _ysrc, InputArray _uvsrc, OutputArr
{
hal : : cvtTwoPlaneYUVtoBGR ( ysrc . data , uvsrc . data , ysrc . step ,
dst . data , dst . step , dst . cols , dst . rows ,
dcn , swapb , uidx ) ;
dcn , swapb , uidx , hint ) ;
}
else
{
hal : : cvtTwoPlaneYUVtoBGR ( ysrc . data , ysrc . step , uvsrc . data , uvsrc . step ,
dst . data , dst . step , dst . cols , dst . rows ,
dcn , swapb , uidx ) ;
dcn , swapb , uidx , hint ) ;
}
}