]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-7500: fix calculation bug in switch_img_fit
authorAnthony Minessale <anthm@freeswitch.org>
Fri, 6 Mar 2015 17:29:01 +0000 (11:29 -0600)
committerMichael Jerris <mike@jerris.com>
Thu, 28 May 2015 17:47:10 +0000 (12:47 -0500)
src/switch_core_media.c
src/switch_core_video.c

index 2464127f2b5ea4c8af3364541aff8f46f2adccbe..1ad8923b701e4c60a12cbd4713a8bf35eba2fd92 100644 (file)
@@ -10089,7 +10089,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_video_frame(switch_cor
        if (switch_channel_test_flag(session->channel, CF_VIDEO_READY) && smh->vid_params.width && 
                switch_channel_test_flag(session->channel, CF_VIDEO_MIRROR_INPUT) && 
                (smh->vid_params.width * smh->vid_params.height) < (img->d_w * img->d_h)) {
-               switch_img_scale(img, &dup_img, smh->vid_params.width, smh->vid_params.height);
+               
+               switch_img_copy(img, &dup_img);
+               switch_img_fit(&dup_img, smh->vid_params.width, smh->vid_params.height);
                img = dup_img;
        }
 
index 95941339114cfe44a63792cdded62c0e06f7ee57..487324783e4d3f8584ebf512f74c09ff05a25fe0 100644 (file)
@@ -1232,7 +1232,6 @@ SWITCH_DECLARE(switch_status_t) switch_img_fit(switch_image_t **srcP, int width,
 {
        switch_image_t *src, *tmp = NULL;
        int new_w = 0, new_h = 0;
-       double img_aspect;
 
        switch_assert(srcP);
        switch_assert(width && height);
@@ -1243,19 +1242,18 @@ SWITCH_DECLARE(switch_status_t) switch_img_fit(switch_image_t **srcP, int width,
                return SWITCH_STATUS_SUCCESS;
        }
 
-       img_aspect = (double) src->d_w / src->d_h;
        new_w = src->d_w;
        new_h = src->d_h;
        
        while(new_w > width || new_h > height) { 
-               if (new_w >= new_h) {
+               if (new_w > width) {
                        double m = (double) width / new_w;
                        new_w = width;
-                       new_h = (int) (new_h * m * img_aspect);
+                       new_h = (int) (new_h * m);
                } else {
                        double m = (double) height / new_h;
                        new_h = height;
-                       new_w = (int) (new_w * m * img_aspect);
+                       new_w = (int) (new_w * m);
                }
        }