Skip to content

Commit a69d582

Browse files
committed
Correctly set pixel aspect ratio
This fixes a crash with the Mirror plugin
1 parent 6e586f6 commit a69d582

File tree

3 files changed

+28
-8
lines changed

3 files changed

+28
-8
lines changed

src/modules/openfx/filter_openfx.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ static int filter_get_image(mlt_frame frame,
6060
int error = mlt_frame_get_image(frame, image, format, width, height, 1);
6161

6262
if (error == 0) {
63+
double pixel_aspect_ratio = mlt_frame_get_aspect_ratio(frame);
64+
if (pixel_aspect_ratio <= 0.0)
65+
pixel_aspect_ratio = 1.0;
66+
6367
mlt_position position = mlt_filter_get_position(filter, frame);
6468
mlt_position length = mlt_filter_get_length2(filter, frame);
6569
int params_count = mlt_properties_count(params);
@@ -147,8 +151,20 @@ static int filter_get_image(mlt_frame frame,
147151
uint8_t *src_copy = src_img_copy.data;
148152

149153
memcpy(src_copy, *image, mlt_image_calculate_size(&src_img));
150-
mltofx_set_source_clip_data(plugin, image_effect, src_copy, *width, *height, *format);
151-
mltofx_set_output_clip_data(plugin, image_effect, *image, *width, *height, *format);
154+
mltofx_set_source_clip_data(plugin,
155+
image_effect,
156+
src_copy,
157+
*width,
158+
*height,
159+
*format,
160+
pixel_aspect_ratio);
161+
mltofx_set_output_clip_data(plugin,
162+
image_effect,
163+
*image,
164+
*width,
165+
*height,
166+
*format,
167+
pixel_aspect_ratio);
152168

153169
mlt_service_lock(MLT_FILTER_SERVICE(filter));
154170
mltofx_action_render(plugin, image_effect, *width, *height);

src/modules/openfx/mlt_openfx.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1583,7 +1583,8 @@ void mltofx_set_source_clip_data(OfxPlugin *plugin,
15831583
uint8_t *image,
15841584
int width,
15851585
int height,
1586-
mlt_image_format format)
1586+
mlt_image_format format,
1587+
double pixel_aspect_ratio)
15871588
{
15881589
mlt_properties clip;
15891590
mlt_properties clip_prop;
@@ -1662,7 +1663,7 @@ void mltofx_set_source_clip_data(OfxPlugin *plugin,
16621663
propSetDouble((OfxPropertySetHandle) clip_prop,
16631664
kOfxImagePropPixelAspectRatio,
16641665
0,
1665-
(double) width / (double) height);
1666+
pixel_aspect_ratio);
16661667

16671668
propSetString((OfxPropertySetHandle) clip_prop,
16681669
kOfxImageEffectPropPreMultiplication,
@@ -1696,7 +1697,8 @@ void mltofx_set_output_clip_data(OfxPlugin *plugin,
16961697
uint8_t *image,
16971698
int width,
16981699
int height,
1699-
mlt_image_format format)
1700+
mlt_image_format format,
1701+
double pixel_aspect_ratio)
17001702
{
17011703
mlt_properties clip;
17021704
mlt_properties clip_prop;
@@ -1798,7 +1800,7 @@ void mltofx_set_output_clip_data(OfxPlugin *plugin,
17981800
propSetDouble((OfxPropertySetHandle) clip_prop,
17991801
kOfxImagePropPixelAspectRatio,
18001802
0,
1801-
(double) width / (double) height);
1803+
pixel_aspect_ratio);
18021804
}
18031805

18041806
int mltofx_detect_plugin(OfxPlugin *plugin)

src/modules/openfx/mlt_openfx.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,16 @@ void mltofx_set_source_clip_data(OfxPlugin *plugin,
6565
uint8_t *image,
6666
int width,
6767
int height,
68-
mlt_image_format format);
68+
mlt_image_format format,
69+
double pixel_aspect_ratio);
6970

7071
void mltofx_set_output_clip_data(OfxPlugin *plugin,
7172
mlt_properties image_effect,
7273
uint8_t *image,
7374
int width,
7475
int height,
75-
mlt_image_format format);
76+
mlt_image_format format,
77+
double pixel_aspect_ratio);
7678

7779
int mltofx_detect_plugin(OfxPlugin *plugin);
7880

0 commit comments

Comments
 (0)