Fix compilation error after recent libmv change
- Tweaked typedefs in stdint so they match what we've got in BLI_sys_types (needed to explicitly tell sign to MSVC). Not so much harmful to be more explicit here, but we really better to have single stdint int blender. - Tweaked allocations macros so MSVC is happy with structures allocation.
This commit is contained in:
27
extern/libmv/libmv-capi.cc
vendored
27
extern/libmv/libmv-capi.cc
vendored
@@ -43,12 +43,17 @@
|
|||||||
# include <png.h>
|
# include <png.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
# define __func__ __FUNCTION__
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef WITH_LIBMV_GUARDED_ALLOC
|
#ifdef WITH_LIBMV_GUARDED_ALLOC
|
||||||
# include "MEM_guardedalloc.h"
|
# include "MEM_guardedalloc.h"
|
||||||
# define LIBMV_OBJECT_NEW OBJECT_GUARDED_NEW
|
# define LIBMV_OBJECT_NEW OBJECT_GUARDED_NEW
|
||||||
# define LIBMV_OBJECT_DELETE OBJECT_GUARDED_DELETE
|
# define LIBMV_OBJECT_DELETE OBJECT_GUARDED_DELETE
|
||||||
# define LIBMV_OBJECT_DELETE OBJECT_GUARDED_DELETE
|
# define LIBMV_OBJECT_DELETE OBJECT_GUARDED_DELETE
|
||||||
# define LIBMV_OBJECT_DELETE_ARRAY OBJECT_GUARDED_DELETE_ARRAY
|
# define LIBMV_STRUCT_NEW(type, count) (type*)MEM_mallocN(sizeof(type) * count, __func__)
|
||||||
|
# define LIBMV_STRUCT_DELETE(what) MEM_freeN(what)
|
||||||
#else
|
#else
|
||||||
// Need this to keep libmv-capi potentially standalone.
|
// Need this to keep libmv-capi potentially standalone.
|
||||||
# if defined __GNUC__ || defined __sun
|
# if defined __GNUC__ || defined __sun
|
||||||
@@ -63,11 +68,8 @@
|
|||||||
((type*)(what))->~type(); \
|
((type*)(what))->~type(); \
|
||||||
free(what); \
|
free(what); \
|
||||||
} } (void)0
|
} } (void)0
|
||||||
#define LIBMV_OBJECT_DELETE_ARRAY(what, type, count) \
|
# define LIBMV_STRUCT_NEW(type, count) (type*)malloc(sizeof(type) * count)
|
||||||
{ if(what) { \
|
# define LIBMV_STRUCT_DELETE(what) { if (what) free(what); } (void)0
|
||||||
for (int i = 0; i < count; i++) ((type*)(what))[i].~type(); \
|
|
||||||
free(what); \
|
|
||||||
} } (void)0
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "libmv/logging/logging.h"
|
#include "libmv/logging/logging.h"
|
||||||
@@ -875,7 +877,7 @@ struct libmv_Features *libmv_detectFeaturesFAST(const unsigned char *data,
|
|||||||
{
|
{
|
||||||
libmv::Feature *features = NULL;
|
libmv::Feature *features = NULL;
|
||||||
std::vector<libmv::Feature> v;
|
std::vector<libmv::Feature> v;
|
||||||
struct libmv_Features *libmv_features = LIBMV_OBJECT_NEW(libmv_Features);
|
struct libmv_Features *libmv_features = LIBMV_STRUCT_NEW(libmv_Features, 1);
|
||||||
int i = 0, count;
|
int i = 0, count;
|
||||||
|
|
||||||
if (margin) {
|
if (margin) {
|
||||||
@@ -889,7 +891,7 @@ struct libmv_Features *libmv_detectFeaturesFAST(const unsigned char *data,
|
|||||||
count = v.size();
|
count = v.size();
|
||||||
|
|
||||||
if (count) {
|
if (count) {
|
||||||
features = LIBMV_OBJECT_NEW(libmv::Feature[count]);
|
features = LIBMV_STRUCT_NEW(libmv::Feature, count);
|
||||||
|
|
||||||
for(std::vector<libmv::Feature>::iterator it = v.begin(); it != v.end(); it++) {
|
for(std::vector<libmv::Feature>::iterator it = v.begin(); it != v.end(); it++) {
|
||||||
features[i++] = *it;
|
features[i++] = *it;
|
||||||
@@ -908,7 +910,7 @@ struct libmv_Features *libmv_detectFeaturesMORAVEC(const unsigned char *data,
|
|||||||
int margin, int count, int min_distance)
|
int margin, int count, int min_distance)
|
||||||
{
|
{
|
||||||
libmv::Feature *features = NULL;
|
libmv::Feature *features = NULL;
|
||||||
struct libmv_Features *libmv_features = LIBMV_OBJECT_NEW(libmv_Features);
|
struct libmv_Features *libmv_features = LIBMV_STRUCT_NEW(libmv_Features, 1);
|
||||||
|
|
||||||
if (count) {
|
if (count) {
|
||||||
if (margin) {
|
if (margin) {
|
||||||
@@ -917,7 +919,7 @@ struct libmv_Features *libmv_detectFeaturesMORAVEC(const unsigned char *data,
|
|||||||
height -= 2 * margin;
|
height -= 2 * margin;
|
||||||
}
|
}
|
||||||
|
|
||||||
features = LIBMV_OBJECT_NEW(libmv::Feature[count]);
|
features = LIBMV_STRUCT_NEW(libmv::Feature, count);
|
||||||
libmv::DetectMORAVEC(data, stride, width, height, features, &count, min_distance, NULL);
|
libmv::DetectMORAVEC(data, stride, width, height, features, &count, min_distance, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -931,11 +933,10 @@ struct libmv_Features *libmv_detectFeaturesMORAVEC(const unsigned char *data,
|
|||||||
void libmv_featuresDestroy(struct libmv_Features *libmv_features)
|
void libmv_featuresDestroy(struct libmv_Features *libmv_features)
|
||||||
{
|
{
|
||||||
if (libmv_features->features) {
|
if (libmv_features->features) {
|
||||||
using libmv::Feature;
|
LIBMV_STRUCT_DELETE(libmv_features->features);
|
||||||
LIBMV_OBJECT_DELETE_ARRAY(libmv_features->features, Feature, libmv_features->count);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LIBMV_OBJECT_DELETE(libmv_features, libmv_Features);
|
LIBMV_STRUCT_DELETE(libmv_features);
|
||||||
}
|
}
|
||||||
|
|
||||||
int libmv_countFeatures(const struct libmv_Features *libmv_features)
|
int libmv_countFeatures(const struct libmv_Features *libmv_features)
|
||||||
|
12
extern/libmv/third_party/msinttypes/stdint.h
vendored
12
extern/libmv/third_party/msinttypes/stdint.h
vendored
@@ -72,16 +72,16 @@ extern "C" {
|
|||||||
// realize that, e.g. char has the same size as __int8
|
// realize that, e.g. char has the same size as __int8
|
||||||
// so we give up on __intX for them.
|
// so we give up on __intX for them.
|
||||||
#if (_MSC_VER < 1300)
|
#if (_MSC_VER < 1300)
|
||||||
typedef char int8_t;
|
typedef signed char int8_t;
|
||||||
typedef short int16_t;
|
typedef signed short int16_t;
|
||||||
typedef int int32_t;
|
typedef signed int int32_t;
|
||||||
typedef unsigned char uint8_t;
|
typedef unsigned char uint8_t;
|
||||||
typedef unsigned short uint16_t;
|
typedef unsigned short uint16_t;
|
||||||
typedef unsigned int uint32_t;
|
typedef unsigned int uint32_t;
|
||||||
#else
|
#else
|
||||||
typedef __int8 int8_t;
|
typedef signed __int8 int8_t;
|
||||||
typedef __int16 int16_t;
|
typedef signed __int16 int16_t;
|
||||||
typedef __int32 int32_t;
|
typedef signed __int32 int32_t;
|
||||||
typedef unsigned __int8 uint8_t;
|
typedef unsigned __int8 uint8_t;
|
||||||
typedef unsigned __int16 uint16_t;
|
typedef unsigned __int16 uint16_t;
|
||||||
typedef unsigned __int32 uint32_t;
|
typedef unsigned __int32 uint32_t;
|
||||||
|
@@ -256,12 +256,6 @@ public: \
|
|||||||
((type*)(what))->~type(); \
|
((type*)(what))->~type(); \
|
||||||
MEM_freeN(what); \
|
MEM_freeN(what); \
|
||||||
} } (void)0
|
} } (void)0
|
||||||
#define OBJECT_GUARDED_DELETE_ARRAY(what, type, count) \
|
|
||||||
{ if(what) { \
|
|
||||||
for (int i = 0; i < count; i++) ((type*)(what))[i].~type(); \
|
|
||||||
MEM_freeN(what); \
|
|
||||||
} } (void)0
|
|
||||||
|
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
Reference in New Issue
Block a user