@@ -63,8 +63,8 @@ static int filter_get_image(mlt_frame frame,
6363 // Destination rect
6464 mlt_rect rect = {0 ,
6565 0 ,
66- normalized_width * mlt_profile_scale_width (profile, *width) ,
67- normalized_height * mlt_profile_scale_height (profile, *height) ,
66+ normalized_width,
67+ normalized_height,
6868 1.0 };
6969 int b_width = mlt_properties_get_int (frame_properties, " meta.media.width" );
7070 int b_height = mlt_properties_get_int (frame_properties, " meta.media.height" );
@@ -92,82 +92,83 @@ static int filter_get_image(mlt_frame frame,
9292 rect.w *= normalized_width;
9393 rect.h *= normalized_height;
9494 }
95- if (qtblendRescaled) {
96- // Another qtblend filter was already applied
97- // In this case, the *width and *height are set to the source resolution to ensure we don't lose too much details on multiple scaling operations
98- // We requested a image with full media resolution, adjust rect to profile
99- // Check if we have consumer scaling enabled since we cannot use *width and *height
100- double consumerScale = mlt_properties_get_double (frame_properties,
101- " qtblend_preview_scaling" );
102- // Consumer scaling was already applied to b_width/b_height
103- // Always request an image that follows the consumer aspect ratio
104- double consumer_dar = normalized_width * consumer_ar / normalized_height;
105- int tmpWidth = b_width;
106- int tmpHeight = b_height;
107- double scaleFactor = qMax (*width / rect.w , *height / rect.h );
108- if (scaleFactor > 1 .) {
109- // Use the highest necessary resolution image
110- tmpWidth *= scaleFactor;
111- tmpHeight *= scaleFactor;
112- }
113- if (consumer_dar > b_dar) {
114- *width = qBound (qRound (normalized_width * consumerScale),
115- tmpWidth,
116- MLT_QTBLEND_MAX_DIMENSION);
117- *height = qRound (*width * consumer_ar * normalized_height / normalized_width);
118- } else {
119- *height = qBound (qRound (normalized_height * consumerScale),
120- tmpHeight,
121- MLT_QTBLEND_MAX_DIMENSION);
122- *width = qRound (*height * normalized_width / normalized_height / consumer_ar);
123- }
124- // Adjust rect to new scaling
125- double scale = (double ) *width / normalized_width;
126- if (scale != 1.0 ) {
127- rect.x *= scale;
128- rect.w *= scale;
129- }
130- scale = (double ) *height / normalized_height;
131- if (scale != 1.0 ) {
132- rect.y *= scale;
133- rect.h *= scale;
134- }
95+ }
96+ if (qtblendRescaled) {
97+ // Another qtblend filter was already applied
98+ // In this case, the *width and *height are set to the source resolution to ensure we don't lose too much details on multiple scaling operations
99+ // We requested a image with full media resolution, adjust rect to profile
100+ // Check if we have consumer scaling enabled since we cannot use *width and *height
101+ double consumerScaleX = MIN (1 ., mlt_properties_get_double (frame_properties,
102+ " qtblend_preview_scalingx" ));
103+ double consumerScaleY = MIN (1 ., mlt_properties_get_double (frame_properties,
104+ " qtblend_preview_scalingy" ));
105+ // Consumer scaling was already applied to b_width/b_height
106+ // Always request an image that follows the consumer aspect ratio
107+ double consumer_dar = normalized_width * consumer_ar / normalized_height;
108+ int tmpWidth = b_width;
109+ int tmpHeight = b_height;
110+ double scaleFactor = qMax (*width / rect.w , *height / rect.h );
111+ if (scaleFactor > 1 .) {
112+ // Use the highest necessary resolution image
113+ tmpWidth *= scaleFactor;
114+ tmpHeight *= scaleFactor;
115+ }
116+ if (consumer_dar > b_dar) {
117+ *width = qBound (qRound (normalized_width * MIN (1 ., consumerScaleX)),
118+ tmpWidth,
119+ MLT_QTBLEND_MAX_DIMENSION);
120+ *height = qRound (*width * consumer_ar * normalized_height / normalized_width);
135121 } else {
136- // First instance of a qtblend filter
137- double scale = mlt_profile_scale_width (profile, *width);
138- // Store consumer scaling for further uses
139- mlt_properties_set_int (frame_properties, " qtblend_scaled" , 1 );
140- mlt_properties_set_double (frame_properties, " qtblend_preview_scaling" , scale);
141- // Apply scaling
142- if (scale != 1.0 ) {
143- rect.x *= scale;
144- rect.w *= scale;
145- if (b_width < normalized_width) {
146- // Adjust scale so that we don't request too small images
147- scale = qBound (scale, normalized_width * scale / b_width, 1 .);
148- }
149- // Apply consumer scaling to the source image
150- b_width *= scale;
151- b_height *= scale;
122+ *height = qBound (qRound (normalized_height * MIN (1 ., consumerScaleY)),
123+ tmpHeight,
124+ MLT_QTBLEND_MAX_DIMENSION);
125+ *width = qRound (*height * normalized_width / normalized_height / consumer_ar);
126+ }
127+ // Adjust rect to new scaling
128+ double scale = (double ) *width / normalized_width;
129+ if (scale != 1.0 ) {
130+ rect.x *= scale;
131+ rect.w *= scale;
132+ }
133+ scale = (double ) *height / normalized_height;
134+ if (scale != 1.0 ) {
135+ rect.y *= scale;
136+ rect.h *= scale;
137+ }
138+ } else {
139+ // First instance of a qtblend filter
140+ // Check if frame size is scaled)
141+ double scalex = mlt_profile_scale_width (profile, *width);
142+ double scaley = mlt_profile_scale_height (profile, *height);
143+
144+ // Store consumer scaling for further uses
145+ mlt_properties_set_int (frame_properties, " qtblend_scaled" , 1 );
146+ mlt_properties_set_double (frame_properties, " qtblend_preview_scalingx" , scalex);
147+ mlt_properties_set_double (frame_properties, " qtblend_preview_scalingy" , scaley);
148+ // Apply scaling
149+ if (scalex != 1.0 ) {
150+ rect.x *= scalex;
151+ rect.w *= scalex;
152+ if (b_width < normalized_width) {
153+ // Adjust scale so that we don't request too small images
154+ scalex = qBound (scalex, normalized_width * scalex / b_width, 1 .);
152155 }
153- scale = mlt_profile_scale_height (profile, *height);
154- if (scale != 1.0 ) {
155- rect. y *= scale ;
156- rect. h *= scale ;
156+ // Apply consumer scaling to the source image
157+ if (scalex < 1 .) {
158+ b_width *= scalex ;
159+ b_height *= scalex ;
157160 }
158161 }
159- transform.translate (rect.x , rect.y );
160- opacity = rect.o ;
161- hasAlpha = rect.o < 1 || rect.x != 0 || rect.y != 0 || rect.w != *width || rect.h != *height
162- || rect.w / b_dar < *height || rect.h * b_dar < *width || b_width < *width
163- || b_height < *height;
164- } else {
165- b_width = *width;
166- b_height = *height;
167- if (b_width < normalized_width || b_height < normalized_height) {
168- hasAlpha = true ;
162+ if (scaley != 1.0 ) {
163+ rect.y *= scaley;
164+ rect.h *= scaley;
169165 }
170166 }
167+ transform.translate (rect.x , rect.y );
168+ opacity = rect.o ;
169+ hasAlpha = rect.o < 1 || rect.x != 0 || rect.y != 0 || rect.w != *width || rect.h != *height
170+ || rect.w / b_dar < *height || rect.h * b_dar < *width || b_width < *width
171+ || b_height < *height;
171172
172173 if (mlt_properties_get (properties, " rotation" )) {
173174 double angle = mlt_properties_anim_get_double (properties, " rotation" , position, length);
0 commit comments