SCV_FILTER_GRAY_FG = (1 << 0),
SCV_FILTER_GRAY_BG = (1 << 1),
SCV_FILTER_SEPIA_FG = (1 << 2),
- SCV_FILTER_SEPIA_BG = (1 << 3)
+ SCV_FILTER_SEPIA_BG = (1 << 3),
+ SCV_FILTER_8BIT_FG = (1 << 4)
} switch_core_video_filter_t;
* \param[in] color RGB color
*/
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_8bit(switch_image_t *img);
SWITCH_DECLARE(void) switch_img_gray(switch_image_t *img, int x, int y, int w, int h);
SWITCH_DECLARE(void) switch_img_sepia(switch_image_t *img, int x, int y, int w, int h);
if (member->video_filters & SCV_FILTER_SEPIA_FG) {
switch_img_sepia(img, 0, 0, img->d_w, img->d_h);
}
+
+ if (member->video_filters & SCV_FILTER_8BIT_FG) {
+ switch_image_t *tmp = NULL;
+ int w = img->d_w, h = img->d_h;
+
+ switch_img_scale(img, &tmp, w/8 ,h/8);
+ switch_img_scale(tmp, &img, w,h);
+ switch_img_8bit(img);
+ }
}
*imgP = img;
patch_data = context->data;
+ if (context->video_filters & SCV_FILTER_8BIT_FG) {
+ switch_image_t *tmp = NULL;
+ int w = frame->img->d_w, h = frame->img->d_h;
+
+ switch_img_scale(frame->img, &tmp, w/8 ,h/8);
+ switch_img_scale(tmp, &frame->img, w,h);
+ switch_img_8bit(frame->img);
+ }
+
+
switch_img_to_raw(frame->img, context->data, frame->img->d_w * 4, SWITCH_IMG_FMT_ARGB);
img = switch_img_wrap(NULL, SWITCH_IMG_FMT_ARGB, frame->img->d_w, frame->img->d_h, 1, context->data);
switch_img_sepia(img, 0, 0, img->d_w, img->d_h);
}
+
if (context->bgimg) {
switch_image_t *tmp = NULL;
#endif
}
+SWITCH_DECLARE(void) switch_img_8bit(switch_image_t *img)
+{
+#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;
+ uint32_t *bytes;
+
+ 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);
+
+
+ if (!rgb->a) continue;;
+
+ //rgb->r = rgb->r & 0xE0, rgb->g = rgb->g & 0xE0, rgb->b = rgb->b & 0xC0;
+ bytes = (uint32_t *) rgb;
+
+#if SWITCH_BYTE_ORDER == __BIG_ENDIAN
+ *bytes = *bytes & 0xE0E0C0FF;
+#else
+ *bytes = *bytes & 0xFFC0E0E0;
+#endif
+
+ }
+ }
+ } else if (img->fmt == SWITCH_IMG_FMT_I420) {
+ switch_image_t *tmp_img = switch_img_alloc(NULL, SWITCH_IMG_FMT_ARGB, img->d_w, img->d_h, 1);
+
+ I420ToARGB(img->planes[SWITCH_PLANE_Y], img->stride[SWITCH_PLANE_Y],
+ img->planes[SWITCH_PLANE_U], img->stride[SWITCH_PLANE_U],
+ img->planes[SWITCH_PLANE_V], img->stride[SWITCH_PLANE_V],
+ tmp_img->planes[SWITCH_PLANE_PACKED], tmp_img->stride[SWITCH_PLANE_PACKED],
+ img->d_w, img->d_h);
+
+ switch_img_8bit(tmp_img);
+
+ ARGBToI420(tmp_img->planes[SWITCH_PLANE_PACKED], tmp_img->stride[SWITCH_PLANE_PACKED],
+ img->planes[SWITCH_PLANE_Y], img->stride[SWITCH_PLANE_Y],
+ img->planes[SWITCH_PLANE_U], img->stride[SWITCH_PLANE_U],
+ img->planes[SWITCH_PLANE_V], img->stride[SWITCH_PLANE_V],
+ tmp_img->d_w, tmp_img->d_h);
+
+ switch_img_free(&tmp_img);
+ }
+#endif
+}
+
SWITCH_DECLARE(void) switch_img_sepia(switch_image_t *img, int x, int y, int w, int h)
{
#ifdef SWITCH_HAVE_YUV
if (switch_stristr("bg-sepia", filter_str)) {
*filters |= SCV_FILTER_SEPIA_BG;
}
+
+ if (switch_stristr("fg-8bit", filter_str)) {
+ *filters |= SCV_FILTER_8BIT_FG;
+ }
}