unsigned int w,
unsigned int h);
+/*!\brief Copy image to a new image
+*
+* if new_img is NULL, a new image is allocated
+* if new_img is not NULL but not the same size as img,
+* new_img is destroyed and a new new_img is allocated
+* else, copy the img data to the new_img
+*
+* \param[in] img Image descriptor
+*/
+
+SWITCH_DECLARE(void) switch_img_copy(switch_image_t *img, switch_image_t **new_img);
+
/*!\brief Flip the image vertically (top for bottom)
*
*img = NULL;
}
+SWITCH_DECLARE(void) switch_img_copy(switch_image_t *img, switch_image_t **new_img)
+{
+ switch_assert(img);
+
+ if (!img->fmt == SWITCH_IMG_FMT_I420) return;
+
+ if (img->d_w != (*new_img)->d_w || img->d_h != (*new_img)->d_w) {
+ vpx_img_free((vpx_image_t *)*new_img);
+ }
+
+ if (*new_img == NULL) {
+ *new_img = switch_img_alloc(NULL, SWITCH_IMG_FMT_I420, img->d_w, img->d_h, 0);
+ }
+
+ switch_assert(*new_img);
+ memcpy((*new_img)->img_data, img->img_data, img->d_w * img->d_h * 3 / 2);
+}
+
/* For Emacs:
* Local Variables:
* mode:c