Skip to content

Commit 3a4c8bd

Browse files
committed
Fix and enable OpenFX module with MSVC
Note that for OpenMP for loops the iteration variable has to be declared before the for statement. MSVC fails to compile it otherwise. See https://stackoverflow.com/questions/38941157/c3015-initialization-in-openmp-for-statement-has-improper-form
1 parent e2e8162 commit 3a4c8bd

5 files changed

Lines changed: 20 additions & 10 deletions

File tree

CMakePresets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"MOD_NORMALIZE": "ON",
2323
"MOD_OLDFILM": "ON",
2424
"MOD_OPENCV": "ON",
25-
"MOD_OPENFX": "OFF",
25+
"MOD_OPENFX": "ON",
2626
"MOD_MOVIT": "OFF",
2727
"MOD_PLUS": "ON",
2828
"MOD_PLUSGPL": "ON",

src/modules/openfx/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ add_library(mltopenfx MODULE
44
filter_openfx.c
55
)
66

7+
if(MSVC)
8+
target_link_libraries(mltopenfx PRIVATE dirent)
9+
endif()
10+
711
add_custom_target(Other_openfx_Files SOURCES
812
filter_openfx.yml
913
)

src/modules/openfx/factory.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,9 @@ static const char *getArchStr()
7171
#endif
7272
#define OFX_DIRSEP "\\"
7373

74-
#if defined(__MINGW32__) || defined(__MINGW64__)
75-
#include <dirent.h>
76-
#endif
77-
7874
#include "shlobj.h"
7975
#include "tchar.h"
76+
#include <dirent.h>
8077
#endif
8178

8279
extern mlt_filter filter_openfx_init(mlt_profile profile,
@@ -281,9 +278,13 @@ MLT_REPOSITORY
281278
char *openfx_path = getenv("OFX_PLUGIN_PATH");
282279
if (openfx_path) {
283280
char *path_copy = strdup(openfx_path);
284-
char *saveptr;
285281
for (char *strptr = path_copy;; strptr = NULL) {
282+
#ifdef _WIN32
283+
char *dir = strtok(strptr, MLT_DIRLIST_DELIMITER);
284+
#else
285+
char *saveptr;
286286
char *dir = strtok_r(strptr, MLT_DIRLIST_DELIMITER, &saveptr);
287+
#endif
287288
if (dir == NULL)
288289
break;
289290
scan_ofx_dir(repository, dir, &dli, 0);

src/modules/openfx/mlt_openfx.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,21 +75,23 @@ uint16_t *mltofx_rgba64_to_half(const uint16_t *src, int n_pixels)
7575
uint16_t *dst = malloc((size_t) count * sizeof(uint16_t));
7676
if (!dst)
7777
return NULL;
78+
int i;
7879
#ifdef _OPENMP
7980
#pragma omp parallel for schedule(static)
8081
#endif
81-
for (int i = 0; i < count; ++i)
82+
for (i = 0; i < count; ++i)
8283
dst[i] = f32_to_f16((float) src[i] * (1.0f / 65535.0f));
8384
return dst;
8485
}
8586

8687
void mltofx_half_to_rgba64(const uint16_t *src, uint16_t *dst, int n_pixels)
8788
{
8889
int count = n_pixels * 4;
90+
int i;
8991
#ifdef _OPENMP
9092
#pragma omp parallel for schedule(static)
9193
#endif
92-
for (int i = 0; i < count; ++i) {
94+
for (i = 0; i < count; ++i) {
9395
float v = f16_to_f32(src[i]);
9496
// This clamping using >= and <= handles NaN and +/-inf
9597
v = (v >= 0.0f) ? (v <= 1.0f ? v : 1.0f) : 0.0f;
@@ -103,21 +105,23 @@ float *mltofx_rgba64_to_float(const uint16_t *src, int n_pixels)
103105
float *dst = malloc((size_t) count * sizeof(float));
104106
if (!dst)
105107
return NULL;
108+
int i;
106109
#ifdef _OPENMP
107110
#pragma omp parallel for schedule(static)
108111
#endif
109-
for (int i = 0; i < count; ++i)
112+
for (i = 0; i < count; ++i)
110113
dst[i] = (float) src[i] * (1.0f / 65535.0f);
111114
return dst;
112115
}
113116

114117
void mltofx_float_to_rgba64(const float *src, uint16_t *dst, int n_pixels)
115118
{
116119
int count = n_pixels * 4;
120+
int i;
117121
#ifdef _OPENMP
118122
#pragma omp parallel for schedule(static)
119123
#endif
120-
for (int i = 0; i < count; ++i) {
124+
for (i = 0; i < count; ++i) {
121125
float v = src[i];
122126
// This clamping using >= and <= handles NaN and +/-inf
123127
v = (v >= 0.0f) ? (v <= 1.0f ? v : 1.0f) : 0.0f;

vcpkg.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"ffmpeg",
88
"fftw3",
99
"gdk-pixbuf",
10+
"glib",
1011
"libebur128",
1112
"libexif",
1213
"libiconv",

0 commit comments

Comments
 (0)