Skip to content

Commit 1e2dda6

Browse files
committed
Handle normalized default coordinate values
The OFX Crop plugin uses a normalized default but does not report it. This adds a work around to report it for that specific plugin.
1 parent 15f2090 commit 1e2dda6

2 files changed

Lines changed: 21 additions & 21 deletions

File tree

src/framework/metaschema.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,4 +184,6 @@ mapping:
184184
"normalized_coordinates": # For types that represent coordinates, whether values are normalized to 0..1
185185
type: bool
186186
default: no
187-
187+
"normalized_default": # Whether the default value is normalized to 0..1
188+
type: bool
189+
default: no

src/modules/openfx/mlt_openfx.c

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2419,14 +2419,6 @@ void mltofx_init_host_properties(OfxPropertySetHandle host_properties)
24192419
propSetInt(host_properties, kOfxParamHostPropPageRowColumnCount, 0, 0);
24202420
propSetInt(host_properties, kOfxParamHostPropPageRowColumnCount, 1, 0);
24212421
propSetInt(host_properties, kOfxParamHostPropSupportsParametricAnimation, 0, 0);
2422-
// Declare support for normalised default coordinate systems on Double2D/Double params.
2423-
// When present, plugins call setDefaultCoordinateSystem(eCoordinatesNormalised) on param
2424-
// descriptors whose defaults are expressed in normalized [0,1] coordinates, which our
2425-
// metadata loop then reads as normalized_coordinates="yes".
2426-
propSetString(host_properties,
2427-
kOfxParamPropDefaultCoordinateSystem,
2428-
0,
2429-
kOfxParamCoordinatesNormalised);
24302422
}
24312423

24322424
void mltofx_create_instance(OfxPlugin *plugin, mlt_properties image_effect)
@@ -3131,25 +3123,31 @@ void *mltofx_fetch_params(OfxPlugin *plugin, mlt_properties params, mlt_properti
31313123
mlt_properties_set(p, "type", "rect");
31323124

31333125
char *type = kOfxParamDoubleTypeXY;
3134-
char *coordinate_system = kOfxParamCoordinatesCanonical;
31353126
propGetString((OfxPropertySetHandle) ppp, kOfxParamPropDoubleType, 0, &type);
3136-
OfxStatus status = propGetString((OfxPropertySetHandle) ppp,
3137-
kOfxParamPropDefaultCoordinateSystem,
3138-
0,
3139-
&coordinate_system);
3140-
if (status != kOfxStatOK) {
3141-
coordinate_system = kOfxParamCoordinatesCanonical;
3142-
}
31433127
if (strcmp(type, kOfxParamDoubleTypeXYAbsolute) == 0) {
31443128
mlt_properties_set(p, "widget", "point");
3129+
mlt_properties_set(p, "normalized_coordinates", "no");
31453130
} else if (strcmp(type, kOfxParamDoubleTypeXY) == 0) {
31463131
mlt_properties_set(p, "widget", "size");
3132+
mlt_properties_set(p, "normalized_coordinates", "no");
31473133
}
31483134

3149-
if (strcmp(coordinate_system, kOfxParamCoordinatesCanonical) == 0) {
3150-
mlt_properties_set(p, "normalized_coordinates", "no");
3151-
} else if (strcmp(coordinate_system, kOfxParamCoordinatesNormalised) == 0) {
3152-
mlt_properties_set(p, "normalized_coordinates", "yes");
3135+
char *default_coords = "";
3136+
OfxStatus status = propGetString((OfxPropertySetHandle) ppp,
3137+
kOfxParamPropDefaultCoordinateSystem,
3138+
0,
3139+
&default_coords);
3140+
if (status == kOfxStatOK) {
3141+
if (!strcmp(default_coords, kOfxParamCoordinatesCanonical)) {
3142+
mlt_properties_set(p, "normalized_default", "no");
3143+
} else if (!strcmp(default_coords, kOfxParamCoordinatesNormalised)) {
3144+
mlt_properties_set(p, "normalized_default", "yes");
3145+
}
3146+
} else if (plugin && plugin->pluginIdentifier
3147+
&& !strcmp("net.sf.openfx.CropPlugin", plugin->pluginIdentifier)) {
3148+
// Workaround for the crop plugin which does not report
3149+
// default coordinates, but uses normalized.
3150+
mlt_properties_set(p, "normalized_default", "yes");
31533151
}
31543152
} else if (strcmp(param_type, kOfxParamTypeInteger2D) == 0) {
31553153
mlt_properties_set(p, "type", "rect");

0 commit comments

Comments
 (0)