diff --git a/src/include/switch_core_video.h b/src/include/switch_core_video.h index 4a5be90cb4..11e0558153 100644 --- a/src/include/switch_core_video.h +++ b/src/include/switch_core_video.h @@ -314,6 +314,8 @@ SWITCH_DECLARE(switch_image_t *) switch_img_copy_rect(switch_image_t *img, uint3 */ SWITCH_DECLARE(void) switch_img_fill(switch_image_t *img, int x, int y, int w, int h, switch_rgb_color_t *color); +SWITCH_DECLARE(void) switch_img_fill_noalpha(switch_image_t *img, int x, int y, int w, int h, switch_rgb_color_t *color); + /*!\brief Set RGB color with a string * * Color string should be in #RRGGBB format diff --git a/src/mod/applications/mod_video_filter/mod_video_filter.c b/src/mod/applications/mod_video_filter/mod_video_filter.c index f7a9995c61..070f4add93 100644 --- a/src/mod/applications/mod_video_filter/mod_video_filter.c +++ b/src/mod/applications/mod_video_filter/mod_video_filter.c @@ -358,7 +358,7 @@ static switch_status_t video_thread_callback(switch_core_session_t *session, swi } else { - switch_img_fill(frame->img, 0, 0, img->d_w, img->d_h, &context->bgcolor); + switch_img_fill_noalpha(img, 0, 0, img->d_w, img->d_h, &context->bgcolor); } if (context->imgfg) { diff --git a/src/switch_core_video.c b/src/switch_core_video.c index 0f7cc4aa3b..fc2f03c709 100644 --- a/src/switch_core_video.c +++ b/src/switch_core_video.c @@ -1362,6 +1362,33 @@ static inline void switch_img_draw_pixel(switch_image_t *img, int x, int y, swit #endif } +SWITCH_DECLARE(void) switch_img_fill_noalpha(switch_image_t *img, int x, int y, int w, int h, switch_rgb_color_t *color) +{ +#ifdef SWITCH_HAVE_YUV + int i; + + if (img->fmt == SWITCH_IMG_FMT_ARGB) { + int max_w = img->d_w; + int max_h = img->d_h; + int j; + switch_rgb_color_t *rgb; + + for (i = 0; i < max_h; i++) { + for (j = 0; j < max_w; j++) { + rgb = (switch_rgb_color_t *)(img->planes[SWITCH_PLANE_PACKED] + i * img->stride[SWITCH_PLANE_PACKED] + j * 4); + + if (rgb->a != 0) { + continue; + } + + *rgb = *color; + } + } + } + +#endif +} + SWITCH_DECLARE(void) switch_img_fill(switch_image_t *img, int x, int y, int w, int h, switch_rgb_color_t *color) { #ifdef SWITCH_HAVE_YUV