mirror of
https://github.com/opencv/opencv.git
synced 2025-07-20 11:06:38 +08:00
Merge pull request #27315 from fengyuentau:4x/hal/riscv-rvv/refactor_functab_elemsize
python3 "/opencv/platforms/android/build_sdk.py" --build_doc --config "/opencv/platforms/android/default.config.py" --sdk_path "$ANDROID_HOME" --ndk_path "$ANDROID_NDK_HOME" /build | tee /build/build-log.txt python3 "/opencv/platforms/android/build_java_shared_aar.py" --offline --ndk_location="$ANDROID_NDK_HOME" --cmake_location=$(dirname $(dirname $(which cmake))) /build/OpenCV-android-sdk hal/riscv-rvv: make use of function tab in copyToMasked and CV_ELEM_SIZE1 in place of elem_size_tab #27315 ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [ ] There is a reference to the original bug report and related work - [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
parent
8ceddbff68
commit
f016c728f5
@ -105,62 +105,25 @@ int copyToMasked(const uchar *src_data, size_t src_step, uchar *dst_data, size_t
|
||||
return CV_HAL_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
CopyToMaskedFunc func = nullptr;
|
||||
switch (depth) {
|
||||
case CV_8U: {}
|
||||
case CV_8S: switch (cn) {
|
||||
case 1: func = copyToMasked_e8c1; break;
|
||||
case 2: func = copyToMasked_e16c1; break;
|
||||
case 3: func = copyToMasked_e8c3; break;
|
||||
case 4: func = copyToMasked_e32c1; break;
|
||||
case 6: func = copyToMasked_e16c3; break;
|
||||
case 8: func = copyToMasked_e64c1; break;
|
||||
default: func = nullptr;
|
||||
}; break;
|
||||
case CV_16U: {}
|
||||
case CV_16S: switch (cn) {
|
||||
case 1: func = copyToMasked_e16c1; break;
|
||||
case 2: func = copyToMasked_e32c1; break;
|
||||
case 3: func = copyToMasked_e16c3; break;
|
||||
case 4: func = copyToMasked_e64c1; break;
|
||||
case 6: func = copyToMasked_e32c3; break;
|
||||
case 8: func = copyToMasked_e64c2; break;
|
||||
default: func = nullptr; break;
|
||||
}; break;
|
||||
case CV_32S: {}
|
||||
case CV_32F: switch (cn) {
|
||||
case 1: func = copyToMasked_e32c1; break;
|
||||
case 2: func = copyToMasked_e64c1; break;
|
||||
case 3: func = copyToMasked_e32c3; break;
|
||||
case 4: func = copyToMasked_e64c2; break;
|
||||
case 6: func = copyToMasked_e64c3; break;
|
||||
case 8: func = copyToMasked_e64c4; break;
|
||||
default: func = nullptr; break;
|
||||
}; break;
|
||||
case CV_64F: switch (cn) {
|
||||
case 1: func = copyToMasked_e64c1; break;
|
||||
case 2: func = copyToMasked_e64c2; break;
|
||||
case 3: func = copyToMasked_e64c3; break;
|
||||
case 4: func = copyToMasked_e64c4; break;
|
||||
default: func = nullptr; break;
|
||||
}; break;
|
||||
default: func = nullptr;
|
||||
}
|
||||
|
||||
static CopyToMaskedFunc tab[] = {
|
||||
0, copyToMasked_e8c1, copyToMasked_e16c1, copyToMasked_e8c3,
|
||||
copyToMasked_e32c1, 0, copyToMasked_e16c3, 0,
|
||||
copyToMasked_e64c1, 0, 0, 0,
|
||||
copyToMasked_e32c3, 0, 0, 0,
|
||||
copyToMasked_e64c2, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
copyToMasked_e64c3, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
copyToMasked_e64c4
|
||||
};
|
||||
CopyToMaskedFunc func = tab[CV_ELEM_SIZE(type)];
|
||||
if (func == nullptr) {
|
||||
return CV_HAL_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static const size_t elem_size_tab[CV_DEPTH_MAX] = {
|
||||
sizeof(uchar), sizeof(schar),
|
||||
sizeof(ushort), sizeof(short),
|
||||
sizeof(int), sizeof(float),
|
||||
sizeof(int64_t), 0,
|
||||
};
|
||||
CV_Assert(elem_size_tab[depth]);
|
||||
|
||||
bool src_continuous = (src_step == width * elem_size_tab[depth] * cn || (src_step != width * elem_size_tab[depth] * cn && height == 1));
|
||||
bool dst_continuous = (dst_step == width * elem_size_tab[depth] * cn || (dst_step != width * elem_size_tab[depth] * cn && height == 1));
|
||||
int elem_size1 = CV_ELEM_SIZE1(type);
|
||||
bool src_continuous = (src_step == width * elem_size1 * cn || (src_step != width * elem_size1 * cn && height == 1));
|
||||
bool dst_continuous = (dst_step == width * elem_size1 * cn || (dst_step != width * elem_size1 * cn && height == 1));
|
||||
bool mask_continuous = (mask_step == static_cast<size_t>(width));
|
||||
size_t nplanes = 1;
|
||||
int _width = width, _height = height;
|
||||
|
@ -190,16 +190,9 @@ int dotprod(const uchar *a_data, size_t a_step, const uchar *b_data, size_t b_st
|
||||
return CV_HAL_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static const size_t elem_size_tab[CV_DEPTH_MAX] = {
|
||||
sizeof(uchar), sizeof(schar),
|
||||
sizeof(ushort), sizeof(short),
|
||||
sizeof(int), sizeof(float),
|
||||
sizeof(int64_t), 0,
|
||||
};
|
||||
CV_Assert(elem_size_tab[depth]);
|
||||
|
||||
bool a_continuous = (a_step == width * elem_size_tab[depth] * cn);
|
||||
bool b_continuous = (b_step == width * elem_size_tab[depth] * cn);
|
||||
int elem_size1 = CV_ELEM_SIZE1(type);
|
||||
bool a_continuous = (a_step == width * elem_size1 * cn);
|
||||
bool b_continuous = (b_step == width * elem_size1 * cn);
|
||||
size_t nplanes = 1;
|
||||
size_t len = width * height;
|
||||
if (!a_continuous || !b_continuous) {
|
||||
|
@ -999,15 +999,8 @@ int norm(const uchar* src, size_t src_step, const uchar* mask, size_t mask_step,
|
||||
},
|
||||
};
|
||||
|
||||
static const size_t elem_size_tab[CV_DEPTH_MAX] = {
|
||||
sizeof(uchar), sizeof(schar),
|
||||
sizeof(ushort), sizeof(short),
|
||||
sizeof(int), sizeof(float),
|
||||
sizeof(int64_t), 0,
|
||||
};
|
||||
CV_Assert(elem_size_tab[depth]);
|
||||
|
||||
bool src_continuous = (src_step == width * elem_size_tab[depth] * cn || (src_step != width * elem_size_tab[depth] * cn && height == 1));
|
||||
int elem_size1 = CV_ELEM_SIZE1(type);
|
||||
bool src_continuous = (src_step == width * elem_size1 * cn || (src_step != width * elem_size1 * cn && height == 1));
|
||||
bool mask_continuous = (mask_step == static_cast<size_t>(width));
|
||||
size_t nplanes = 1;
|
||||
size_t size = width * height;
|
||||
@ -1030,7 +1023,7 @@ int norm(const uchar* src, size_t src_step, const uchar* mask, size_t mask_step,
|
||||
res.d = 0;
|
||||
if ((norm_type == NORM_L1 && depth <= CV_16S) ||
|
||||
((norm_type == NORM_L2 || norm_type == NORM_L2SQR) && depth <= CV_8S)) {
|
||||
const size_t esz = elem_size_tab[depth] * cn;
|
||||
const size_t esz = elem_size1 * cn;
|
||||
const int total = (int)size;
|
||||
const int intSumBlockSize = (norm_type == NORM_L1 && depth <= CV_8S ? (1 << 23) : (1 << 15))/cn;
|
||||
const int blockSize = std::min(total, intSumBlockSize);
|
||||
|
@ -1111,16 +1111,9 @@ int normDiff(const uchar* src1, size_t src1_step, const uchar* src2, size_t src2
|
||||
},
|
||||
};
|
||||
|
||||
static const size_t elem_size_tab[CV_DEPTH_MAX] = {
|
||||
sizeof(uchar), sizeof(schar),
|
||||
sizeof(ushort), sizeof(short),
|
||||
sizeof(int), sizeof(float),
|
||||
sizeof(int64_t), 0,
|
||||
};
|
||||
CV_Assert(elem_size_tab[depth]);
|
||||
|
||||
bool src_continuous = (src1_step == width * elem_size_tab[depth] * cn || (src1_step != width * elem_size_tab[depth] * cn && height == 1));
|
||||
src_continuous &= (src2_step == width * elem_size_tab[depth] * cn || (src2_step != width * elem_size_tab[depth] * cn && height == 1));
|
||||
int elem_size1 = CV_ELEM_SIZE1(type);
|
||||
bool src_continuous = (src1_step == width * elem_size1 * cn || (src1_step != width * elem_size1 * cn && height == 1));
|
||||
src_continuous &= (src2_step == width * elem_size1 * cn || (src2_step != width * elem_size1 * cn && height == 1));
|
||||
bool mask_continuous = (mask_step == static_cast<size_t>(width));
|
||||
size_t nplanes = 1;
|
||||
size_t size = width * height;
|
||||
@ -1143,7 +1136,7 @@ int normDiff(const uchar* src1, size_t src1_step, const uchar* src2, size_t src2
|
||||
res.d = 0;
|
||||
if ((norm_type == NORM_L1 && depth <= CV_16S) ||
|
||||
((norm_type == NORM_L2 || norm_type == NORM_L2SQR) && depth <= CV_8S)) {
|
||||
const size_t esz = elem_size_tab[depth] * cn;
|
||||
const size_t esz = elem_size1 * cn;
|
||||
const int total = (int)size;
|
||||
const int intSumBlockSize = (norm_type == NORM_L1 && depth <= CV_8S ? (1 << 23) : (1 << 15))/cn;
|
||||
const int blockSize = std::min(total, intSumBlockSize);
|
||||
|
Loading…
Reference in New Issue
Block a user