summaryrefslogtreecommitdiff
path: root/media-libs/mlt/files/mlt-6.16.0-bad-aspect-ratio-resulting-in-black.patch
blob: c2bc1946a81ca5eab246fd09e3c152f0aa85bcb6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
From f0628d1fe7f61a267f1adad8824b9a2083e3376a Mon Sep 17 00:00:00 2001
From: Dan Dennedy <dan@dennedy.org>
Date: Fri, 31 May 2019 19:03:32 -0700
Subject: [PATCH] Fix #453 bad aspect ratio computed resulting in black.

This occured when the s, width, or height properties are supplied with
no "aspect."
---
 src/modules/avformat/consumer_avformat.c | 34 +++++++++++++-----------
 1 file changed, 18 insertions(+), 16 deletions(-)

diff --git a/src/modules/avformat/consumer_avformat.c b/src/modules/avformat/consumer_avformat.c
index 738f5a972..dd2719997 100644
--- a/src/modules/avformat/consumer_avformat.c
+++ b/src/modules/avformat/consumer_avformat.c
@@ -271,22 +271,24 @@ mlt_consumer consumer_avformat_init( mlt_profile profile, char *arg )
 static void recompute_aspect_ratio( mlt_properties properties )
 {
 	double ar = mlt_properties_get_double( properties, "aspect" );
-	AVRational rational = av_d2q( ar, 255 );
-	int width = mlt_properties_get_int( properties, "width" );
-	int height = mlt_properties_get_int( properties, "height" );
-
-	// Update the profile and properties as well since this is an alias
-	// for mlt properties that correspond to profile settings
-	mlt_properties_set_int( properties, "display_aspect_num", rational.num );
-	mlt_properties_set_int( properties, "display_aspect_den", rational.den );
-
-	// Now compute the sample aspect ratio
-	rational = av_d2q( ar * height / FFMAX(width, 1), 255 );
-
-	// Update the profile and properties as well since this is an alias
-	// for mlt properties that correspond to profile settings
-	mlt_properties_set_int( properties, "sample_aspect_num", rational.num );
-	mlt_properties_set_int( properties, "sample_aspect_den", rational.den );
+	if (ar > 0.0) {
+		AVRational rational = av_d2q( ar, 255 );
+		int width = mlt_properties_get_int( properties, "width" );
+		int height = mlt_properties_get_int( properties, "height" );
+	
+		// Update the profile and properties as well since this is an alias
+		// for mlt properties that correspond to profile settings
+		mlt_properties_set_int( properties, "display_aspect_num", rational.num );
+		mlt_properties_set_int( properties, "display_aspect_den", rational.den );
+	
+		// Now compute the sample aspect ratio
+		rational = av_d2q( ar * height / FFMAX(width, 1), 255 );
+	
+		// Update the profile and properties as well since this is an alias
+		// for mlt properties that correspond to profile settings
+		mlt_properties_set_int( properties, "sample_aspect_num", rational.num );
+		mlt_properties_set_int( properties, "sample_aspect_den", rational.den );
+	}
 }
 
 static void color_trc_from_colorspace( mlt_properties properties )