1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 15:53:03 +04:00

Merge pull request #26871 from MaximSmolskiy:fix-filestorage_io_test-test_base64-for-64-bit-integer-types

Support 64-bit integer types for FileStorage Base64 #26871

### Pull Request Readiness Checklist

Related to https://github.com/opencv/opencv/pull/26846#issuecomment-2618159277
OpenCV extra: https://github.com/opencv/opencv_extra/pull/1232

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
- [x] There is a reference to the original bug report and related work
- [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [x] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
Maxim Smolskiy
2025-02-06 18:47:07 +03:00
committed by GitHub
parent 603b1cafdf
commit 8badff598e
4 changed files with 104 additions and 18 deletions
+15
View File
@@ -1818,6 +1818,15 @@ int FileStorage::Impl::Base64Decoder::getInt32() {
return ival;
}
int64_t FileStorage::Impl::Base64Decoder::getInt64() {
size_t sz = decoded.size();
if (ofs + 8 > sz && !readMore(8))
return 0;
int64_t ival = readLong(&decoded[ofs]);
ofs += 8;
return ival;
}
double FileStorage::Impl::Base64Decoder::getFloat64() {
size_t sz = decoded.size();
if (ofs + 8 > sz && !readMore(8))
@@ -1876,6 +1885,12 @@ char *FileStorage::Impl::parseBase64(char *ptr, int indent, FileNode &collection
case CV_32S:
ival = base64decoder.getInt32();
break;
case CV_64U:
ival = base64decoder.getInt64();
break;
case CV_64S:
ival = base64decoder.getInt64();
break;
case CV_32F: {
Cv32suf v;
v.i = base64decoder.getInt32();
@@ -208,6 +208,8 @@ int base64::icvCalcStructSize(const char *dt, int initial_size) {
case 'i': { elem_max_size = std::max( elem_max_size, sizeof(int ) ); break; }
case 'f': { elem_max_size = std::max( elem_max_size, sizeof(float ) ); break; }
case 'd': { elem_max_size = std::max( elem_max_size, sizeof(double) ); break; }
case 'I': { elem_max_size = std::max( elem_max_size, sizeof(int64_t)); break; }
case 'U': { elem_max_size = std::max( elem_max_size, sizeof(uint64_t)); break; }
default: break;
}
}
@@ -347,6 +349,11 @@ size_t base64::RawDataToBinaryConvertor::make_to_binary_funcs(const std::string
size = sizeof(double);
pack.func = to_binary<double>;
break;
case 'I':
case 'U':
size = sizeof(uint64_t);
pack.func = to_binary<uint64_t>;
break;
case 'r':
default:
CV_Error(cv::Error::StsError, "type is not supported");
+2
View File
@@ -151,6 +151,8 @@ public:
int getInt32();
int64_t getInt64();
double getFloat64();
bool endOfStream() const;