]> git.sesse.net Git - mlt/commitdiff
Add center_bias property to crop filter.
authorDan Dennedy <dan@dennedy.org>
Fri, 11 Dec 2009 04:31:46 +0000 (20:31 -0800)
committerDan Dennedy <dan@dennedy.org>
Fri, 11 Dec 2009 04:31:46 +0000 (20:31 -0800)
src/modules/core/filter_crop.c

index a24c41c2dd13962d54ce996a25df0fd3406959c8..8edad23ca7327bb6f880932c7df844a2b104edc1 100644 (file)
@@ -172,11 +172,24 @@ static mlt_frame filter_process( mlt_filter this, mlt_frame frame )
                                aspect_ratio = mlt_properties_get_double( frame_props, "consumer_aspect_ratio" );
                        double input_ar = aspect_ratio * width / height;
                        double output_ar = mlt_profile_dar( mlt_service_profile( MLT_FILTER_SERVICE(this) ) );
+                       int bias = mlt_properties_get_int( filter_props, "center_bias" );
                        
                        if ( input_ar > output_ar )
+                       {
                                left = right = ( width - rint( output_ar * height / aspect_ratio ) ) / 2;
+                               if ( abs(bias) > left )
+                                       bias = bias < 0 ? -left : left;
+                               left -= bias;
+                               right += bias;
+                       }
                        else
+                       {
                                top = bottom = ( height - rint( aspect_ratio * width / output_ar ) ) / 2;
+                               if ( abs(bias) > top )
+                                       bias = bias < 0 ? -top : top;
+                               top -= bias;
+                               bottom += bias;
+                       }
                }               
 
                left  -= left % 2;