FS-7500: fix calculation bug in switch_img_fit
This commit is contained in:
parent
b7fc2e047d
commit
6f379f43c1
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue