mirror of
https://github.com/opencv/opencv.git
synced 2026-07-31 08:13:04 +04:00
Merge pull request #23055 from seanm:sprintf2
* Replaced most remaining sprintf with snprintf * Deprecated encodeFormat and introduced new method that takes the buffer length * Also increased buffer size at call sites to be a little bigger, in case int is 64 bit
This commit is contained in:
@@ -126,7 +126,7 @@ static bool ocl_accumulate( InputArray _src, InputArray _src2, InputOutputArray
|
||||
const char * const opMap[4] = { "ACCUMULATE", "ACCUMULATE_SQUARE", "ACCUMULATE_PRODUCT",
|
||||
"ACCUMULATE_WEIGHTED" };
|
||||
|
||||
char cvt[40];
|
||||
char cvt[50];
|
||||
ocl::Kernel k("accumulate", ocl::imgproc::accumulate_oclsrc,
|
||||
format("-D %s%s -D srcT1=%s -D cn=%d -D dstT1=%s%s -D rowsPerWI=%d -D convertToDT=%s",
|
||||
opMap[op_type], haveMask ? " -D HAVE_MASK" : "",
|
||||
|
||||
@@ -111,7 +111,7 @@ static bool ocl_bilateralFilter_8u(InputArray _src, OutputArray _dst, int d,
|
||||
space_ofs[maxk++] = (int)(i * temp.step + j * cn);
|
||||
}
|
||||
|
||||
char cvt[3][40];
|
||||
char cvt[3][50];
|
||||
String cnstr = cn > 1 ? format("%d", cn) : "";
|
||||
String kernelName("bilateral");
|
||||
size_t sizeDiv = 1;
|
||||
|
||||
@@ -350,7 +350,7 @@ static bool ocl_blendLinear( InputArray _src1, InputArray _src2, InputArray _wei
|
||||
{
|
||||
int type = _src1.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type);
|
||||
|
||||
char cvt[30];
|
||||
char cvt[50];
|
||||
ocl::Kernel k("blendLinear", ocl::imgproc::blend_linear_oclsrc,
|
||||
format("-D T=%s -D cn=%d -D convertToT=%s", ocl::typeToStr(depth),
|
||||
cn, ocl::convertTypeStr(CV_32F, depth, 1, cvt)));
|
||||
|
||||
@@ -195,7 +195,7 @@ static bool ocl_boxFilter( InputArray _src, OutputArray _dst, int ddepth,
|
||||
const int wgRound = 256;
|
||||
globalsize[0] = roundUp(globalsize[0], wgRound);
|
||||
|
||||
char build_options[1024], cvt[2][40];
|
||||
char build_options[1024], cvt[2][50];
|
||||
snprintf(build_options, sizeof(build_options), "-D cn=%d "
|
||||
"-D ANCHOR_X=%d -D ANCHOR_Y=%d -D KERNEL_SIZE_X=%d -D KERNEL_SIZE_Y=%d "
|
||||
"-D PX_LOAD_VEC_SIZE=%d -D PX_LOAD_NUM_PX=%d "
|
||||
|
||||
@@ -183,7 +183,7 @@ static bool ocl_Canny(InputArray _src, const UMat& dx_, const UMat& dy_, OutputA
|
||||
Non maxima suppression
|
||||
Double thresholding
|
||||
*/
|
||||
char cvt[40];
|
||||
char cvt[50];
|
||||
ocl::Kernel with_sobel("stage1_with_sobel", ocl::imgproc::canny_oclsrc,
|
||||
format("-D WITH_SOBEL -D cn=%d -D TYPE=%s -D convert_floatN=%s -D floatN=%s -D GRP_SIZEX=%d -D GRP_SIZEY=%d%s",
|
||||
cn, ocl::memopTypeToStr(_src.depth()),
|
||||
|
||||
@@ -578,7 +578,7 @@ static bool ocl_Laplacian5(InputArray _src, OutputArray _dst,
|
||||
size_t lt2[2] = { tileSizeX, tileSizeY};
|
||||
size_t gt2[2] = { lt2[0] * (1 + (size.width - 1) / lt2[0]), lt2[1] };
|
||||
|
||||
char cvt[2][40];
|
||||
char cvt[2][50];
|
||||
const char * const borderMap[] = { "BORDER_CONSTANT", "BORDER_REPLICATE", "BORDER_REFLECT", "BORDER_WRAP",
|
||||
"BORDER_REFLECT_101" };
|
||||
|
||||
@@ -624,7 +624,7 @@ static bool ocl_Laplacian5(InputArray _src, OutputArray _dst,
|
||||
if (!doubleSupport && wdepth == CV_64F)
|
||||
return false;
|
||||
|
||||
char cvt[2][40];
|
||||
char cvt[2][50];
|
||||
ocl::Kernel k("sumConvert", ocl::imgproc::laplacian5_oclsrc,
|
||||
format("-D ONLY_SUM_CONVERT "
|
||||
"-D srcT=%s -D WT=%s -D dstT=%s -D coeffT=%s -D wdepth=%d "
|
||||
|
||||
@@ -590,7 +590,7 @@ static bool ocl_filter2D( InputArray _src, OutputArray _dst, int ddepth,
|
||||
size_t tryWorkItems = device.maxWorkGroupSize();
|
||||
if (device.isIntel() && 128 < tryWorkItems)
|
||||
tryWorkItems = 128;
|
||||
char cvt[2][40];
|
||||
char cvt[2][50];
|
||||
|
||||
// For smaller filter kernels, there is a special kernel that is more
|
||||
// efficient than the general one.
|
||||
@@ -764,7 +764,7 @@ static bool ocl_sepRowFilter2D(const UMat & src, UMat & buf, const Mat & kernelX
|
||||
extra_extrapolation |= src.cols < (int)((-radiusX + globalsize[0] + 8 * localsize[0] + 3) >> 1) + 1;
|
||||
extra_extrapolation |= src.cols < radiusX;
|
||||
|
||||
char cvt[40];
|
||||
char cvt[50];
|
||||
cv::String build_options = cv::format("-D RADIUSX=%d -D LSIZE0=%d -D LSIZE1=%d -D CN=%d -D %s -D %s -D %s"
|
||||
" -D srcT=%s -D dstT=%s -D convertToDstT=%s -D srcT1=%s -D dstT1=%s%s%s",
|
||||
radiusX, (int)localsize[0], (int)localsize[1], cn, btype,
|
||||
@@ -825,7 +825,7 @@ static bool ocl_sepColFilter2D(const UMat & buf, UMat & dst, const Mat & kernelY
|
||||
globalsize[1] = DIVUP(sz.height, localsize[1]) * localsize[1];
|
||||
globalsize[0] = DIVUP(sz.width, localsize[0]) * localsize[0];
|
||||
|
||||
char cvt[2][40];
|
||||
char cvt[2][50];
|
||||
int floatT = std::max(CV_32F, bdepth);
|
||||
cv::String build_options = cv::format("-D RADIUSY=%d -D LSIZE0=%d -D LSIZE1=%d -D CN=%d"
|
||||
" -D srcT=%s -D dstT=%s -D convertToFloatT=%s -D floatT=%s -D convertToDstT=%s"
|
||||
@@ -891,7 +891,7 @@ static bool ocl_sepFilter2D_SinglePass(InputArray _src, OutputArray _dst,
|
||||
size_t lt2[2] = { optimizedSepFilterLocalWidth, optimizedSepFilterLocalHeight };
|
||||
size_t gt2[2] = { lt2[0] * (1 + (size.width - 1) / lt2[0]), lt2[1]};
|
||||
|
||||
char cvt[2][40];
|
||||
char cvt[2][50];
|
||||
const char * const borderMap[] = { "BORDER_CONSTANT", "BORDER_REPLICATE", "BORDER_REFLECT", "BORDER_WRAP",
|
||||
"BORDER_REFLECT_101" };
|
||||
|
||||
|
||||
@@ -1232,7 +1232,7 @@ static bool ocl_calcHist1(InputArray _src, OutputArray _hist, int ddepth = CV_32
|
||||
return false;
|
||||
|
||||
wgs = std::min<size_t>(ocl::Device::getDefault().maxWorkGroupSize(), BINS);
|
||||
char cvt[40];
|
||||
char cvt[50];
|
||||
ocl::Kernel k2("merge_histogram", ocl::imgproc::histogram_oclsrc,
|
||||
format("-D BINS=%d -D HISTS_COUNT=%d -D WGS=%d -D convertToHT=%s -D HT=%s",
|
||||
BINS, compunits, (int)wgs, ocl::convertTypeStr(CV_32S, ddepth, 1, cvt),
|
||||
|
||||
@@ -1340,7 +1340,7 @@ static bool ocl_remap(InputArray _src, OutputArray _dst, InputArray _map1, Input
|
||||
|
||||
if (interpolation != INTER_NEAREST)
|
||||
{
|
||||
char cvt[3][40];
|
||||
char cvt[3][50];
|
||||
int wdepth = std::max(CV_32F, depth);
|
||||
buildOptions = buildOptions
|
||||
+ format(" -D WT=%s -D convertToT=%s -D convertToWT=%s"
|
||||
|
||||
@@ -617,7 +617,7 @@ static bool ocl_morphSmall( InputArray _src, OutputArray _dst, InputArray _kerne
|
||||
wdepth = CV_32S;
|
||||
wtype = CV_MAKETYPE(wdepth, cn);
|
||||
}
|
||||
char cvt[2][40];
|
||||
char cvt[2][50];
|
||||
|
||||
const char * const borderMap[] = { "BORDER_CONSTANT", "BORDER_REPLICATE",
|
||||
"BORDER_REFLECT", 0, "BORDER_REFLECT_101" };
|
||||
|
||||
@@ -3305,7 +3305,7 @@ static bool ocl_resize( InputArray _src, OutputArray _dst, Size dsize,
|
||||
if (useSampler)
|
||||
{
|
||||
int wdepth = std::max(depth, CV_32S);
|
||||
char buf[2][32];
|
||||
char buf[2][50];
|
||||
cv::String compileOpts = format("-D USE_SAMPLER -D depth=%d -D T=%s -D T1=%s "
|
||||
"-D convertToDT=%s -D cn=%d",
|
||||
depth, ocl::typeToStr(type), ocl::typeToStr(depth),
|
||||
@@ -3327,7 +3327,7 @@ static bool ocl_resize( InputArray _src, OutputArray _dst, Size dsize,
|
||||
|
||||
if (interpolation == INTER_LINEAR && !useSampler)
|
||||
{
|
||||
char buf[2][32];
|
||||
char buf[2][50];
|
||||
|
||||
// integer path is slower because of CPU part, so it's disabled
|
||||
if (depth == CV_8U && ((void)0, 0))
|
||||
@@ -3419,7 +3419,7 @@ static bool ocl_resize( InputArray _src, OutputArray _dst, Size dsize,
|
||||
int wdepth = std::max(depth, is_area_fast ? CV_32S : CV_32F);
|
||||
int wtype = CV_MAKE_TYPE(wdepth, cn);
|
||||
|
||||
char cvt[2][40];
|
||||
char cvt[2][50];
|
||||
String buildOption = format("-D INTER_AREA -D T=%s -D T1=%s -D WTV=%s -D convertToWTV=%s -D cn=%d",
|
||||
ocl::typeToStr(type), ocl::typeToStr(depth), ocl::typeToStr(wtype),
|
||||
ocl::convertTypeStr(depth, wdepth, cn, cvt[0]), cn);
|
||||
|
||||
@@ -87,7 +87,7 @@ static bool sumTemplate(InputArray _src, UMat & result)
|
||||
wgs2_aligned <<= 1;
|
||||
wgs2_aligned >>= 1;
|
||||
|
||||
char cvt[40];
|
||||
char cvt[50];
|
||||
ocl::Kernel k("calcSum", ocl::imgproc::match_template_oclsrc,
|
||||
format("-D CALC_SUM -D T=%s -D T1=%s -D WT=%s -D cn=%d -D convertToWT=%s -D WGS=%d -D WGS2_ALIGNED=%d",
|
||||
ocl::typeToStr(type), ocl::typeToStr(depth), ocl::typeToStr(wtype), cn,
|
||||
@@ -268,8 +268,8 @@ static bool matchTemplateNaive_CCORR(InputArray _image, InputArray _templ, Outpu
|
||||
wtype1 = CV_MAKE_TYPE(wdepth, rated_cn);
|
||||
}
|
||||
|
||||
char cvt[40];
|
||||
char cvt1[40];
|
||||
char cvt[50];
|
||||
char cvt1[50];
|
||||
const char* convertToWT1 = ocl::convertTypeStr(depth, wdepth, cn, cvt);
|
||||
const char* convertToWT = ocl::convertTypeStr(depth, wdepth, rated_cn, cvt1);
|
||||
|
||||
@@ -349,7 +349,7 @@ static bool matchTemplateNaive_SQDIFF(InputArray _image, InputArray _templ, Outp
|
||||
int type = _image.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type);
|
||||
int wdepth = CV_32F, wtype = CV_MAKE_TYPE(wdepth, cn);
|
||||
|
||||
char cvt[40];
|
||||
char cvt[50];
|
||||
ocl::Kernel k("matchTemplate_Naive_SQDIFF", ocl::imgproc::match_template_oclsrc,
|
||||
format("-D SQDIFF -D T=%s -D T1=%s -D WT=%s -D convertToWT=%s -D cn=%d", ocl::typeToStr(type), ocl::typeToStr(depth),
|
||||
ocl::typeToStr(wtype), ocl::convertTypeStr(depth, wdepth, cn, cvt), cn));
|
||||
|
||||
Reference in New Issue
Block a user