From 7c0237c142c43352e7f08f2543d9824553785a15 Mon Sep 17 00:00:00 2001 From: Seven Du Date: Wed, 28 Jan 2015 16:41:36 +0800 Subject: [PATCH] FS-7500: really fix image copy --- src/switch_core_video.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/switch_core_video.c b/src/switch_core_video.c index 7695d748d9..00b0a94bb9 100644 --- a/src/switch_core_video.c +++ b/src/switch_core_video.c @@ -91,12 +91,16 @@ SWITCH_DECLARE(void) switch_img_copy(switch_image_t *img, switch_image_t **new_i if (*new_img == NULL) { *new_img = switch_img_alloc(NULL, SWITCH_IMG_FMT_I420, img->d_w, img->d_h, 1); } - + switch_assert(*new_img); - for (i = 0; i < 3; i++) { - (*new_img)->stride[i] = img->stride[i]; - (*new_img)->planes[i] = img->planes[i]; + for (i = 0; i < (*new_img)->h; i++) { + memcpy((*new_img)->planes[SWITCH_PLANE_Y] + (*new_img)->stride[SWITCH_PLANE_Y] * i, img->planes[SWITCH_PLANE_Y] + img->stride[SWITCH_PLANE_Y] * i, img->d_w); + } + + for (i = 0; i < (*new_img)->h / 2; i++) { + memcpy((*new_img)->planes[SWITCH_PLANE_U] + (*new_img)->stride[SWITCH_PLANE_U] * i, img->planes[SWITCH_PLANE_U] + img->stride[SWITCH_PLANE_U] * i, img->d_w); + memcpy((*new_img)->planes[SWITCH_PLANE_V] + (*new_img)->stride[SWITCH_PLANE_V] * i, img->planes[SWITCH_PLANE_V] + img->stride[SWITCH_PLANE_V] * i, img->d_w); } }