From 7b2c15eb020861b459746f5830a3a612d0a693bc Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 21 Jun 2001 11:42:18 +0000 Subject: [PATCH] Removed old unused libs. Original commit message from CVS: Removed old unused libs. --- libs/Makefile.am | 4 +- libs/colorspace/.gitignore | 7 - libs/colorspace/Makefile.am | 19 - libs/colorspace/gstcolorspace.c | 78 --- libs/colorspace/gstcolorspace.h | 81 --- libs/colorspace/rgb2rgb.c | 284 ---------- libs/colorspace/yuv2rgb.c | 811 ----------------------------- libs/colorspace/yuv2rgb.h | 68 --- libs/colorspace/yuv2rgb_mmx16.s | 188 ------- libs/videoscale/.gitignore | 7 - libs/videoscale/Makefile.am | 19 - libs/videoscale/gstscale_x86.c | 80 --- libs/videoscale/gstscale_x86.h | 30 -- libs/videoscale/gstscale_x86_asm.s | 53 -- libs/videoscale/gstvideoscale.c | 393 -------------- libs/videoscale/gstvideoscale.h | 57 -- 16 files changed, 2 insertions(+), 2177 deletions(-) delete mode 100644 libs/colorspace/.gitignore delete mode 100644 libs/colorspace/Makefile.am delete mode 100644 libs/colorspace/gstcolorspace.c delete mode 100644 libs/colorspace/gstcolorspace.h delete mode 100644 libs/colorspace/rgb2rgb.c delete mode 100644 libs/colorspace/yuv2rgb.c delete mode 100644 libs/colorspace/yuv2rgb.h delete mode 100644 libs/colorspace/yuv2rgb_mmx16.s delete mode 100644 libs/videoscale/.gitignore delete mode 100644 libs/videoscale/Makefile.am delete mode 100644 libs/videoscale/gstscale_x86.c delete mode 100644 libs/videoscale/gstscale_x86.h delete mode 100644 libs/videoscale/gstscale_x86_asm.s delete mode 100644 libs/videoscale/gstvideoscale.c delete mode 100644 libs/videoscale/gstvideoscale.h diff --git a/libs/Makefile.am b/libs/Makefile.am index 527ee6405a..1233ad863f 100644 --- a/libs/Makefile.am +++ b/libs/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = riff colorspace getbits putbits idct videoscale audio +SUBDIRS = riff getbits putbits idct audio -DIST_SUBDIRS = riff colorspace getbits putbits videoscale audio idct +DIST_SUBDIRS = riff getbits putbits audio idct diff --git a/libs/colorspace/.gitignore b/libs/colorspace/.gitignore deleted file mode 100644 index 08f5ed37d8..0000000000 --- a/libs/colorspace/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -Makefile -Makefile.in -*.o -*.lo -*.la -.deps -.libs diff --git a/libs/colorspace/Makefile.am b/libs/colorspace/Makefile.am deleted file mode 100644 index b4e67ac358..0000000000 --- a/libs/colorspace/Makefile.am +++ /dev/null @@ -1,19 +0,0 @@ -filterdir = $(libdir)/gst - -filter_LTLIBRARIES = libgstcolorspace.la - -if HAVE_CPU_I386 -ARCHSRCS = yuv2rgb_mmx16.s -else -ARCHSRCS = -endif - -libgstcolorspace_la_SOURCES = gstcolorspace.c rgb2rgb.c yuv2rgb.c $(ARCHSRCS) - -libgstcolorspaceincludedir = $(includedir)/gst/libs/gstcolorspace -libgstcolorspaceinclude_HEADERS = gstcolorspace.h - -noinst_HEADERS = yuv2rgb.h - -# FIXME is this needed? -CFLAGS += -O2 $(FOMIT_FRAME_POINTER) -finline-functions -ffast-math diff --git a/libs/colorspace/gstcolorspace.c b/libs/colorspace/gstcolorspace.c deleted file mode 100644 index e36ae37cba..0000000000 --- a/libs/colorspace/gstcolorspace.c +++ /dev/null @@ -1,78 +0,0 @@ -/* Gnome-Streamer - * Copyright (C) <1999> Erik Walthinsen - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -//#define DEBUG_ENABLED -#include - -#include - - -extern GstColorSpaceConvertFunction gst_colorspace_rgb2rgb_get_converter(GstColorSpaceConverter *space, GstColorSpaceType srcspace, - GstColorSpaceType destspace); -extern GstColorSpaceConvertFunction gst_colorspace_yuv2rgb_get_converter(GstColorSpaceConverter *space, GstColorSpaceType srcspace, - GstColorSpaceType destspace); -extern GstColorSpaceConvertFunction gst_colorspace_rgb2yuv_get_converter(GstColorSpaceConverter *space, GstColorSpaceType srcspace, - GstColorSpaceType destspace); -extern GstColorSpaceConvertFunction gst_colorspace_yuv2yuv_get_converter(GstColorSpaceConverter *space, GstColorSpaceType srcspace, - GstColorSpaceType destspace); - -GstColorSpaceConverter *gst_colorspace_converter_new(gint width, gint height, GstColorSpaceType srcspace, - GstColorSpaceType destspace, GdkVisual *destvisual) -{ - - GstColorSpaceConverter *new = g_malloc(sizeof(GstColorSpaceConverter)); - - new->width = width; - new->height = height; - new->srcspace = srcspace; - new->destspace = destspace; - new->visual = destvisual; - new->color_tables = NULL; - new->convert = NULL; - - GST_DEBUG (0,"gst_colorspace: new\n"); - if (GST_COLORSPACE_IS_RGB_TYPE(srcspace)) { - if (GST_COLORSPACE_IS_RGB_TYPE(destspace)) { - new->convert = gst_colorspace_rgb2rgb_get_converter(new, srcspace, destspace); - } - else { - //return gst_colorspace_rgb2yuv_get_converter(srcspace, destspace); - } - } - else if (GST_COLORSPACE_IS_YUV_TYPE(srcspace)) { - if (GST_COLORSPACE_IS_RGB_TYPE(destspace)) { - new->convert = gst_colorspace_yuv2rgb_get_converter(new, srcspace, destspace); - } - else { - //return gst_colorspace_yuv2yuv_get_converter(srcspace, destspace); - } - } - if (new->convert == NULL) { - g_print("gst_colorspace: conversion not implemented\n"); - g_free(new); - new = NULL; - } - return new; -} - -void gst_colorspace_destroy(GstColorSpaceConverter *space) -{ - if (space->color_tables) g_free(space->color_tables); - g_free(space); -} diff --git a/libs/colorspace/gstcolorspace.h b/libs/colorspace/gstcolorspace.h deleted file mode 100644 index e5210df909..0000000000 --- a/libs/colorspace/gstcolorspace.h +++ /dev/null @@ -1,81 +0,0 @@ -/* Gnome-Streamer - * Copyright (C) <1999> Erik Walthinsen - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - - -#ifndef __GST_COLORSPACE_H__ -#define __GST_COLORSPACE_H__ - -#include -#include - -#include "yuv2rgb.h" - -typedef enum { - GST_COLORSPACE_RGB555, - GST_COLORSPACE_BGR555, - GST_COLORSPACE_RGB565, - GST_COLORSPACE_BGR565, - GST_COLORSPACE_RGB24, - GST_COLORSPACE_BGR24, - GST_COLORSPACE_RGB32, - GST_COLORSPACE_BGR32, - - GST_COLORSPACE_YUV420, - GST_COLORSPACE_YUV420P, - GST_COLORSPACE_YUV422, - GST_COLORSPACE_YUV422P - -} GstColorSpaceType; - -#define GST_COLORSPACE_RGB_FIRST GST_COLORSPACE_RGB555 -#define GST_COLORSPACE_RGB_LAST GST_COLORSPACE_BGR32 - -#define GST_COLORSPACE_YUV_FIRST GST_COLORSPACE_YUV420 -#define GST_COLORSPACE_YUV_LAST GST_COLORSPACE_YUV422P - -typedef struct _GstColorSpaceConverter GstColorSpaceConverter; -typedef void (*GstColorSpaceConvertFunction) (GstColorSpaceConverter *space, guchar *src, guchar *dest); - -struct _GstColorSpaceConverter { - guint width; - guint height; - GstColorSpaceType srcspace; - GstColorSpaceType destspace; - GdkVisual *visual; - guint insize; - guint outsize; - /* private */ - GstColorSpaceYUVTables *color_tables; - GstColorSpaceConvertFunction convert; -}; - - -#define GST_COLORSPACE_IS_RGB_TYPE(type) ((type)>=GST_COLORSPACE_RGB_FIRST && \ - (type)<=GST_COLORSPACE_RGB_LAST) - -#define GST_COLORSPACE_IS_YUV_TYPE(type) ((type)>=GST_COLORSPACE_YUV_FIRST && \ - (type)<=GST_COLORSPACE_YUV_LAST) - -GstColorSpaceConverter *gst_colorspace_converter_new(gint width, gint height, GstColorSpaceType srcspace, - GstColorSpaceType destspace, GdkVisual *destvisual); -#define gst_colorspace_convert(converter, src, dest) \ - (converter)->convert((converter), (src), (dest)) -void gst_colorspace_destroy(GstColorSpaceConverter *space); - -#endif /* __GST_COLORSPACE_H__ */ diff --git a/libs/colorspace/rgb2rgb.c b/libs/colorspace/rgb2rgb.c deleted file mode 100644 index 09f7f8aff5..0000000000 --- a/libs/colorspace/rgb2rgb.c +++ /dev/null @@ -1,284 +0,0 @@ -/* Gnome-Streamer - * Copyright (C) <1999> Erik Walthinsen - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include - -//#define DEBUG_ENABLED -#include "gstcolorspace.h" - -static void gst_colorspace_rgb_to_rgb_identity(GstColorSpaceConverter *space, unsigned char *src, unsigned char *dest); -static void gst_colorspace_rgb24_to_bgr24(GstColorSpaceConverter *space, unsigned char *src, unsigned char *dest); -static void gst_colorspace_rgb24_to_rgb32(GstColorSpaceConverter *space, unsigned char *src, unsigned char *dest); -static void gst_colorspace_rgb32_to_bgr32(GstColorSpaceConverter *space, unsigned char *src, unsigned char *dest); -static void gst_colorspace_rgb555_to_rgb565(GstColorSpaceConverter *space, unsigned char *src, unsigned char *dest); -static void gst_colorspace_bgr565_to_rgb32(GstColorSpaceConverter *space, unsigned char *src, unsigned char *dest); -static void gst_colorspace_bgr24_to_bgr565(GstColorSpaceConverter *space, unsigned char *src, unsigned char *dest); -static void gst_colorspace_bgr32_to_bgr565(GstColorSpaceConverter *space, unsigned char *src, unsigned char *dest); - -GstColorSpaceConvertFunction gst_colorspace_rgb2rgb_get_converter(GstColorSpaceConverter *space, GstColorSpaceType src, GstColorSpaceType dest) { - switch(src) { - case GST_COLORSPACE_RGB24: - space->insize = space->width*space->height*3; - switch(dest) { - case GST_COLORSPACE_RGB24: - space->outsize = space->width*space->height*3; - return gst_colorspace_rgb_to_rgb_identity; - case GST_COLORSPACE_BGR24: - space->outsize = space->width*space->height*3; - return gst_colorspace_rgb24_to_bgr24; - case GST_COLORSPACE_RGB32: - space->outsize = space->width*space->height*4; - return gst_colorspace_rgb24_to_rgb32; - default: - break; - } - break; - case GST_COLORSPACE_BGR24: - space->insize = space->width*space->height*3; - switch(dest) { - case GST_COLORSPACE_RGB24: - space->outsize = space->width*space->height*3; - return gst_colorspace_rgb24_to_bgr24; - case GST_COLORSPACE_BGR24: - space->outsize = space->width*space->height*3; - return gst_colorspace_rgb_to_rgb_identity; - case GST_COLORSPACE_BGR565: - space->outsize = space->width*space->height*2; - return gst_colorspace_bgr24_to_bgr565; - default: - break; - } - break; - case GST_COLORSPACE_RGB32: - space->insize = space->width*space->height*4; - switch(dest) { - case GST_COLORSPACE_BGR32: - space->outsize = space->width*space->height*4; - return gst_colorspace_rgb32_to_bgr32; - case GST_COLORSPACE_RGB32: - space->outsize = space->width*space->height*4; - return gst_colorspace_rgb_to_rgb_identity; - default: - break; - } - break; - case GST_COLORSPACE_BGR32: - space->insize = space->width*space->height*4; - switch(dest) { - case GST_COLORSPACE_RGB32: - space->outsize = space->width*space->height*4; - return gst_colorspace_rgb32_to_bgr32; - case GST_COLORSPACE_BGR32: - space->outsize = space->width*space->height*4; - return gst_colorspace_rgb_to_rgb_identity; - case GST_COLORSPACE_BGR565: - space->outsize = space->width*space->height*2; - return gst_colorspace_bgr32_to_bgr565; - case GST_COLORSPACE_RGB565: - space->outsize = space->width*space->height*2; - return gst_colorspace_bgr32_to_bgr565; - default: - break; - } - break; - case GST_COLORSPACE_BGR555: - space->insize = space->width*space->height*2; - switch(dest) { - case GST_COLORSPACE_RGB555: - space->outsize = space->width*space->height*2; - return gst_colorspace_rgb32_to_bgr32; - case GST_COLORSPACE_BGR565: - space->outsize = space->width*space->height*2; - return gst_colorspace_rgb555_to_rgb565; - default: - break; - } - break; - case GST_COLORSPACE_BGR565: - space->insize = space->width*space->height*2; - switch(dest) { - case GST_COLORSPACE_RGB32 : - space->outsize = space->width*space->height*4; - return gst_colorspace_bgr565_to_rgb32; - default: - break; - }; - break; - default: - break; - } - g_print("gst_colorspace: conversion not supported %d %d\n", src, dest); - return NULL; -} - -static void gst_colorspace_rgb_to_rgb_identity(GstColorSpaceConverter *space, unsigned char *src, unsigned char *dest) -{ - memcpy(dest, src, space->outsize); -} - -static void gst_colorspace_rgb24_to_bgr24(GstColorSpaceConverter *space, unsigned char *src, unsigned char *dest) -{ - gint size; - gchar temp; - - GST_DEBUG (0,"gst_colorspace_rgb24_to_bgr24 %p %p %d %d %d\n", src, dest, space->outsize, space->width, space->height); - - size = space->outsize/3; - - if (src == dest) { - while (size--) { - temp = src[0]; - src[0] = src[2]; - src[2] = temp; - src+=3; - } - } - else { - while (size--) { - *dest++ = src[2]; - *dest++ = src[1]; - *dest++ = src[0]; - src+=3; - } - } - GST_DEBUG (0,"gst_colorspace_rgb24_to_bgr24 end\n"); -} - -static void gst_colorspace_bgr24_to_bgr565(GstColorSpaceConverter *space, unsigned char *src, unsigned char *dest) -{ - gint size; - guint16 *destptr = (guint16 *)dest; - - GST_DEBUG (0,"gst_colorspace_bgr24_to_bgr565 %p %p %d %d %d\n", src, dest, space->outsize, space->width, space->height); - - size = space->outsize/2; - - while (size--) { - *destptr++ = ((src[2]&0xF8)<<8)|((src[1]&0xFC)<<3)|((src[0]&0xF8)>>3); - src+=3; - } - GST_DEBUG (0,"gst_colorspace_bgr24_to_bgr565 end\n"); -} - -static void gst_colorspace_bgr32_to_bgr565(GstColorSpaceConverter *space, unsigned char *src, unsigned char *dest) -{ - gint size; - guint16 *destptr = (guint16 *)dest; - - GST_DEBUG (0,"gst_colorspace_bgr32_to_bgr565 %p %p %d %d %d\n", src, dest, space->outsize, space->width, space->height); - - size = space->outsize/2; - - while (size--) { - *destptr++ = ((src[2]&0xF8)<<8)|((src[1]&0xFC)<<3)|((src[0]&0xF8)>>3); - src+=4; - } - GST_DEBUG (0,"gst_colorspace_bgr32_to_bgr565 end\n"); -} - -static void gst_colorspace_rgb24_to_rgb32(GstColorSpaceConverter *space, unsigned char *src, unsigned char *dest) -{ - gint size; - guint32 *destptr = (guint32 *)dest; - - GST_DEBUG (0,"gst_colorspace_rgb24_to_rgb32 %p %p %d\n", src, dest, space->outsize); - - size = space->outsize/4; - - while (size--) { - *destptr++ = (src[0]<<16)|(src[1]<<8)|src[2]; - src+=3; - } - GST_DEBUG (0,"gst_colorspace_rgb24_to_rgb32 end\n"); -} - -static void gst_colorspace_rgb32_to_bgr32(GstColorSpaceConverter *space, unsigned char *src, unsigned char *dest) -{ - gint size; - gchar temp; - - GST_DEBUG (0,"gst_colorspace_rgb32_to_bgr32 %p %p %d\n", src, dest, space->outsize); - - size = space->outsize/4; - - if (src == dest) { - while (size--) { - temp = src[0]; - src[0] = src[2]; - src[2] = temp; - src+=4; - } - } - else { - while (size--) { - *dest++ = src[2]; - *dest++ = src[1]; - *dest++ = src[0]; - dest++; - src+=4; - } - } - GST_DEBUG (0,"gst_colorspace_rgb32_to_bgr32 end\n"); -} - -static void gst_colorspace_rgb555_to_rgb565(GstColorSpaceConverter *space, unsigned char *src, unsigned char *dest) -{ - gint size; - guint32 *srcptr = (guint32 *) src; - guint32 *destptr = (guint32 *) dest; - - GST_DEBUG (0,"gst_colorspace_rgb555_to_rgb565 %p %p %d\n", src, dest, space->outsize); - - size = space->outsize/4; - - if (src == dest) { - while (size--) { - *srcptr += (*srcptr++)&0xFFE0FFE0; - } - } - else { - while (size--) { - *destptr++ = *srcptr + ((*srcptr++)&0xFFE0FFE0); - } - } -} - -static void gst_colorspace_bgr565_to_rgb32(GstColorSpaceConverter *space, unsigned char *src, unsigned char *dest) -{ - gint size; - guint16 *srcptr = (guint16 *)src; - guint32 *destptr = (guint32 *)dest; - size = space->outsize >> 2; - - g_assert (src != dest); /* todo */ - while (size--) { - /* in detail I do this - red=(unsigned char)(*srcptr)&0x1f; - green=(unsigned char)(((*srcptr)&0x07E0)>>5); - blue=(unsigned char)(((*srcptr)&0xf800)>>11); - *destptr++ = (((guint32)blue) << 3) - | (((guint32)green) << (8+2)) - | (((guint32)red) << (16+3)); - */ - *destptr++ = (((*srcptr)&0xf800)>>8)|(((*srcptr)&0x07E0)<<5)|(((*srcptr)&0x1f)<<19); - srcptr++; - } -} - - diff --git a/libs/colorspace/yuv2rgb.c b/libs/colorspace/yuv2rgb.c deleted file mode 100644 index 7350e34a9b..0000000000 --- a/libs/colorspace/yuv2rgb.c +++ /dev/null @@ -1,811 +0,0 @@ -/* Gnome-Streamer - * Copyright (C) <1999> Erik Walthinsen - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include "config.h" - -#include -#include - -//#define DEBUG_ENABLED -#include -#include - -//#undef HAVE_LIBMMX - -#ifdef HAVE_LIBMMX -#include "mmx.h" -#endif - -#include "yuv2rgb.h" - - -static void gst_colorspace_yuv420P_to_bgr16_mmx(GstColorSpaceConverter *space, unsigned char *src, unsigned char *dest); -static void gst_colorspace_yuv420P_to_rgb32(GstColorSpaceConverter *space, unsigned char *src, unsigned char *dest); -static void gst_colorspace_yuv420P_to_bgr32(GstColorSpaceConverter *space, unsigned char *src, unsigned char *dest); -static void gst_colorspace_yuv420P_to_bgr32_mmx(GstColorSpaceConverter *space, unsigned char *src, unsigned char *dest); -static void gst_colorspace_yuv420P_to_rgb24(GstColorSpaceConverter *space, unsigned char *src, unsigned char *dest); -static void gst_colorspace_yuv420P_to_bgr24(GstColorSpaceConverter *space, unsigned char *src, unsigned char *dest); -static void gst_colorspace_yuv420P_to_rgb16(GstColorSpaceConverter *space, unsigned char *src, unsigned char *dest); -static void gst_colorspace_yuv420P_to_bgr16_mmx(GstColorSpaceConverter *space, unsigned char *src, unsigned char *dest); - -static void gst_colorspace_yuv_to_rgb16(GstColorSpaceYUVTables *tables, - unsigned char *lum, - unsigned char *cr, - unsigned char *cb, - unsigned char *out, - int cols, int rows); -static void gst_colorspace_yuv_to_rgb24(GstColorSpaceYUVTables *tables, - unsigned char *lum, - unsigned char *cr, - unsigned char *cb, - unsigned char *out, - int cols, int rows); -static void gst_colorspace_yuv_to_rgb32(GstColorSpaceYUVTables *tables, - unsigned char *lum, - unsigned char *cr, - unsigned char *cb, - unsigned char *out, - int cols, int rows); -#ifdef HAVE_LIBMMX -static void gst_colorspace_yuv_to_bgr32_mmx(GstColorSpaceYUVTables *tables, - unsigned char *lum, - unsigned char *cr, - unsigned char *cb, - unsigned char *out, - int cols, int rows); -extern void gst_colorspace_yuv_to_bgr16_mmx(GstColorSpaceYUVTables *tables, - unsigned char *lum, - unsigned char *cr, - unsigned char *cb, - unsigned char *out, - int cols, int rows); -#endif - -static GstColorSpaceYUVTables * gst_colorspace_init_yuv(long depth, - long red_mask, long green_mask, long blue_mask); - -GstColorSpaceConvertFunction gst_colorspace_yuv2rgb_get_converter(GstColorSpaceConverter *space, GstColorSpaceType src, GstColorSpaceType dest) { - GST_DEBUG (0,"gst_colorspace_yuv2rgb_get_converter %d %d\n", src, dest); - switch(src) { - case GST_COLORSPACE_YUV420P: - space->insize = space->width*space->height+space->width*space->height/2; - switch(dest) { - case GST_COLORSPACE_BGR32: - space->color_tables = gst_colorspace_init_yuv(32, 0xFF0000, 0x00FF00, 0x0000FF); - space->outsize = space->width*space->height*4; -#ifdef HAVE_LIBMMX - return gst_colorspace_yuv420P_to_bgr32_mmx; -#else - return gst_colorspace_yuv420P_to_bgr32; -#endif - case GST_COLORSPACE_RGB32: - space->color_tables = gst_colorspace_init_yuv(32, 0x0000FF, 0x00FF00, 0xFF0000); - space->outsize = space->width*space->height*4; - return gst_colorspace_yuv420P_to_rgb32; - case GST_COLORSPACE_RGB24: - space->color_tables = gst_colorspace_init_yuv(24, 0x0000FF, 0x00FF00, 0xFF0000); - space->outsize = space->width*space->height*3; - return gst_colorspace_yuv420P_to_rgb24; - case GST_COLORSPACE_BGR24: - space->color_tables = gst_colorspace_init_yuv(24, 0xFF0000, 0x00FF00, 0x0000FF); - space->outsize = space->width*space->height*3; - return gst_colorspace_yuv420P_to_bgr24; - case GST_COLORSPACE_RGB555: - case GST_COLORSPACE_RGB565: - case GST_COLORSPACE_BGR555: - g_return_val_if_fail(space->visual != NULL, NULL); - space->color_tables = gst_colorspace_init_yuv(16, space->visual->red_mask, space->visual->green_mask, space->visual->blue_mask); - space->outsize = space->width*space->height*2; - return gst_colorspace_yuv420P_to_rgb16; - case GST_COLORSPACE_BGR565: - g_return_val_if_fail(space->visual != NULL, NULL); - space->color_tables = gst_colorspace_init_yuv(16, space->visual->red_mask, space->visual->green_mask, space->visual->blue_mask); - space->outsize = space->width*space->height*2; -#ifdef HAVE_LIBMMX - return gst_colorspace_yuv420P_to_bgr16_mmx; -#else - return gst_colorspace_yuv420P_to_rgb16; -#endif - default: - break; - } - break; - default: - break; - } - g_print("gst_colorspace_yuv2rgb not implemented\n"); - return NULL; -} - -static void gst_colorspace_yuv420P_to_bgr32(GstColorSpaceConverter *space, unsigned char *src, unsigned char *dest) -{ - int size; - GST_DEBUG (0,"gst_colorspace_yuv420P_to_bgr32\n"); - - size = space->width * space->height; - - gst_colorspace_yuv_to_rgb32(space->color_tables, - src, // Y component - src+size, // cr component - src+size+(size>>2), // cb component - dest, - space->height, - space->width); - -} - -static void gst_colorspace_yuv420P_to_rgb32(GstColorSpaceConverter *space, unsigned char *src, unsigned char *dest) -{ - int size; - GST_DEBUG (0,"gst_colorspace_yuv420P_to_rgb32\n"); - - size = space->width * space->height; - - gst_colorspace_yuv_to_rgb32(space->color_tables, - src, // Y component - src+size, // cr component - src+size+(size>>2), // cb component - dest, - space->height, - space->width); - -} - -static void gst_colorspace_yuv420P_to_bgr24(GstColorSpaceConverter *space, unsigned char *src, unsigned char *dest) { - int size; - GST_DEBUG (0,"gst_colorspace_yuv420P_to_bgr24\n"); - - size = space->width * space->height; - - gst_colorspace_yuv_to_rgb24(space->color_tables, - src, // Y component - src+size, // cr component - src+size+(size>>2), // cb component - dest, - space->height, - space->width); -} - -static void gst_colorspace_yuv420P_to_rgb24(GstColorSpaceConverter *space, unsigned char *src, unsigned char *dest) { - int size; - GST_DEBUG (0,"gst_colorspace_yuv420P_to_rgb24\n"); - - size = space->width * space->height; - - gst_colorspace_yuv_to_rgb24(space->color_tables, - src, // Y component - src+size, // cr component - src+size+(size>>2), // cb component - dest, - space->height, - space->width); - -} - -static void gst_colorspace_yuv420P_to_rgb16(GstColorSpaceConverter *space, unsigned char *src, unsigned char *dest) { - int size; - GST_DEBUG (0,"gst_colorspace_yuv420P_to_rgb16\n"); - - size = space->width * space->height; - - gst_colorspace_yuv_to_rgb16(space->color_tables, - src, // Y component - src+size, // cr component - src+size+(size>>2), // cb component - dest, - space->height, - space->width); - -} - -#ifdef HAVE_LIBMMX - -static void gst_colorspace_yuv420P_to_bgr32_mmx(GstColorSpaceConverter *space, unsigned char *src, unsigned char *dest) { - int size; - GST_DEBUG (0,"gst_colorspace_yuv420P_to_rgb32_mmx\n"); - - size = space->width * space->height; - - gst_colorspace_yuv_to_bgr32_mmx(NULL, - src, // Y component - src+size, // cr component - src+size+(size>>2), // cb component - dest, - space->height, - space->width); - -} -static void gst_colorspace_yuv420P_to_bgr16_mmx(GstColorSpaceConverter *space, unsigned char *src, unsigned char *dest) { - int size; - GST_DEBUG (0,"gst_colorspace_yuv420P_to_bgr16_mmx \n"); - - size = space->width * space->height; - - gst_colorspace_yuv_to_bgr16_mmx(NULL, - src, // Y component - src+size, // cr component - src+size+(size>>2), // cb component - dest, - space->height, - space->width); - GST_DEBUG (0,"gst_colorspace_yuv420P_to_bgr16_mmx done\n"); - -} -#endif - -/* - * How many 1 bits are there in the longword. - * Low performance, do not call often. - */ - -static int -number_of_bits_set(a) -unsigned long a; -{ - if(!a) return 0; - if(a & 1) return 1 + number_of_bits_set(a >> 1); - return(number_of_bits_set(a >> 1)); -} - -/* - * Shift the 0s in the least significant end out of the longword. - * Low performance, do not call often. - */ -static unsigned long -shifted_down(a) -unsigned long a; -{ - if(!a) return 0; - if(a & 1) return a; - return a >> 1; -} - -/* - * How many 0 bits are there at most significant end of longword. - * Low performance, do not call often. - */ -static int -free_bits_at_top(a) -unsigned long a; -{ - /* assume char is 8 bits */ - if(!a) return sizeof(unsigned long) * 8; - /* assume twos complement */ - if(((long)a) < 0l) return 0; - return 1 + free_bits_at_top ( a << 1); -} - -/* - * How many 0 bits are there at least significant end of longword. - * Low performance, do not call often. - */ -static int -free_bits_at_bottom(a) -unsigned long a; -{ - /* assume char is 8 bits */ - if(!a) return sizeof(unsigned long) * 8; - if(((long)a) & 1l) return 0; - return 1 + free_bits_at_bottom ( a >> 1); -} - -/* - *-------------------------------------------------------------- - * - * InitColor16Dither -- - * - * To get rid of the multiply and other conversions in color - * dither, we use a lookup table. - * - * Results: - * None. - * - * Side effects: - * The lookup tables are initialized. - * - *-------------------------------------------------------------- - */ - -static GstColorSpaceYUVTables * -gst_colorspace_init_yuv(long depth, long red_mask, long green_mask, long blue_mask) -{ - int CR, CB, i; - int *L_tab, *Cr_r_tab, *Cr_g_tab, *Cb_g_tab, *Cb_b_tab; - long *r_2_pix_alloc; - long *g_2_pix_alloc; - long *b_2_pix_alloc; - GstColorSpaceYUVTables *tables = g_malloc(sizeof(GstColorSpaceYUVTables)); - - L_tab = tables->L_tab = (int *)malloc(256*sizeof(int)); - Cr_r_tab = tables->Cr_r_tab = (int *)malloc(256*sizeof(int)); - Cr_g_tab = tables->Cr_g_tab = (int *)malloc(256*sizeof(int)); - Cb_g_tab = tables->Cb_g_tab = (int *)malloc(256*sizeof(int)); - Cb_b_tab = tables->Cb_b_tab = (int *)malloc(256*sizeof(int)); - - r_2_pix_alloc = (long *)malloc(768*sizeof(long)); - g_2_pix_alloc = (long *)malloc(768*sizeof(long)); - b_2_pix_alloc = (long *)malloc(768*sizeof(long)); - - if (L_tab == NULL || - Cr_r_tab == NULL || - Cr_g_tab == NULL || - Cb_g_tab == NULL || - Cb_b_tab == NULL || - r_2_pix_alloc == NULL || - g_2_pix_alloc == NULL || - b_2_pix_alloc == NULL) { - fprintf(stderr, "Could not get enough memory in InitColorDither\n"); - exit(1); - } - - for (i=0; i<256; i++) { - L_tab[i] = i; - /* - if (gammaCorrectFlag) { - L_tab[i] = GAMMA_CORRECTION(i); - } - */ - - CB = CR = i; - /* - if (chromaCorrectFlag) { - CB -= 128; - CB = CHROMA_CORRECTION128(CB); - CR -= 128; - CR = CHROMA_CORRECTION128(CR); - } - else - */ - { - CB -= 128; CR -= 128; - } - Cr_r_tab[i] = (0.419/0.299) * CR; - Cr_g_tab[i] = -(0.299/0.419) * CR; - Cb_g_tab[i] = -(0.114/0.331) * CB; - Cb_b_tab[i] = (0.587/0.331) * CB; - - } - - /* - * Set up entries 0-255 in rgb-to-pixel value tables. - */ - for (i = 0; i < 256; i++) { - r_2_pix_alloc[i + 256] = i >> (8 - number_of_bits_set(red_mask)); - r_2_pix_alloc[i + 256] <<= free_bits_at_bottom(red_mask); - g_2_pix_alloc[i + 256] = i >> (8 - number_of_bits_set(green_mask)); - g_2_pix_alloc[i + 256] <<= free_bits_at_bottom(green_mask); - b_2_pix_alloc[i + 256] = i >> (8 - number_of_bits_set(blue_mask)); - b_2_pix_alloc[i + 256] <<= free_bits_at_bottom(blue_mask); - /* - * If we have 16-bit output depth, then we double the value - * in the top word. This means that we can write out both - * pixels in the pixel doubling mode with one op. It is - * harmless in the normal case as storing a 32-bit value - * through a short pointer will lose the top bits anyway. - * A similar optimisation for Alpha for 64 bit has been - * prepared for, but is not yet implemented. - */ - if(!(depth == 32) && !(depth == 24)) { - - r_2_pix_alloc[i + 256] |= (r_2_pix_alloc[i + 256]) << 16; - g_2_pix_alloc[i + 256] |= (g_2_pix_alloc[i + 256]) << 16; - b_2_pix_alloc[i + 256] |= (b_2_pix_alloc[i + 256]) << 16; - - } -#ifdef SIXTYFOUR_BIT - if(depth == 32) { - - r_2_pix_alloc[i + 256] |= (r_2_pix_alloc[i + 256]) << 32; - g_2_pix_alloc[i + 256] |= (g_2_pix_alloc[i + 256]) << 32; - b_2_pix_alloc[i + 256] |= (b_2_pix_alloc[i + 256]) << 32; - - } -#endif - } - - /* - * Spread out the values we have to the rest of the array so that - * we do not need to check for overflow. - */ - for (i = 0; i < 256; i++) { - r_2_pix_alloc[i] = r_2_pix_alloc[256]; - r_2_pix_alloc[i+ 512] = r_2_pix_alloc[511]; - g_2_pix_alloc[i] = g_2_pix_alloc[256]; - g_2_pix_alloc[i+ 512] = g_2_pix_alloc[511]; - b_2_pix_alloc[i] = b_2_pix_alloc[256]; - b_2_pix_alloc[i+ 512] = b_2_pix_alloc[511]; - } - - tables->r_2_pix = r_2_pix_alloc + 256; - tables->g_2_pix = g_2_pix_alloc + 256; - tables->b_2_pix = b_2_pix_alloc + 256; - - return tables; - -} - -/* - *-------------------------------------------------------------- - * - * Color16DitherImage -- - * - * Converts image into 16 bit color. - * - * Results: - * None. - * - * Side effects: - * None. - * - *-------------------------------------------------------------- - */ - -static void -gst_colorspace_yuv_to_rgb16(tables, lum, cb, cr, out, rows, cols) - GstColorSpaceYUVTables *tables; - unsigned char *lum; - unsigned char *cr; - unsigned char *cb; - unsigned char *out; - int cols, rows; - -{ - int L, CR, CB; - unsigned short *row1, *row2; - unsigned char *lum2; - int x, y; - int cr_r; - int crb_g; - int cb_b; - int cols_2 = cols>>1; - - row1 = (unsigned short *)out; - row2 = row1 + cols; - lum2 = lum + cols; - - for (y=rows>>1; y; y--) { - for (x=cols_2; x; x--) { - - CR = *cr++; - CB = *cb++; - cr_r = tables->Cr_r_tab[CR]; - crb_g = tables->Cr_g_tab[CR] + tables->Cb_g_tab[CB]; - cb_b = tables->Cb_b_tab[CB]; - - L = tables->L_tab[(int) *lum++]; - - *row1++ = (tables->r_2_pix[L+cr_r] | tables->g_2_pix[L+crb_g] | tables->b_2_pix[L+cb_b]); - - L = tables->L_tab[(int) *lum++]; - - *row1++ = (tables->r_2_pix[L+cr_r] | tables->g_2_pix[L+crb_g] | tables->b_2_pix[L+cb_b]); - - /* - * Now, do second row. - */ - L = tables->L_tab[(int) *lum2++]; - - *row2++ = (tables->r_2_pix[L+cr_r] | tables->g_2_pix[L+crb_g] | tables->b_2_pix[L+cb_b]); - - L = tables->L_tab[(int) *lum2++]; - - *row2++ = (tables->r_2_pix[L+cr_r] | tables->g_2_pix[L+crb_g] | tables->b_2_pix[L+cb_b]); - } - /* - * These values are at the start of the next line, (due - * to the ++'s above),but they need to be at the start - * of the line after that. - */ - lum = lum2; - row1 = row2; - lum2 += cols; - row2 += cols; - } -} - -static void -gst_colorspace_yuv_to_rgb24(tables, lum, cb, cr, out, rows, cols) - GstColorSpaceYUVTables *tables; - unsigned char *lum; - unsigned char *cr; - unsigned char *cb; - unsigned char *out; - int cols, rows; - -{ - int L, CR, CB; - unsigned char *row1, *row2; - unsigned char *lum2; - int x, y; - int cr_r; - int crb_g; - int cb_b; - int cols_2 = cols>>1; - int cols_3 = cols*3; - unsigned char pixels[4]; - - row1 = out; - row2 = row1 + cols_3; - lum2 = lum + cols; - for (y=rows>>1; y; y--) { - for (x=cols_2; x; x--) { - - CR = *cr++; - CB = *cb++; - cr_r = tables->Cr_r_tab[CR]; - crb_g = tables->Cr_g_tab[CR] + tables->Cb_g_tab[CB]; - cb_b = tables->Cb_b_tab[CB]; - - L = tables->L_tab[(int) *lum++]; - - ((int *)pixels)[0] = (tables->r_2_pix[L+cr_r] | tables->g_2_pix[L+crb_g] | tables->b_2_pix[L+cb_b]); - *row1++ = pixels[0]; *row1++ = pixels[1]; *row1++ = pixels[2]; - - L = tables->L_tab[(int) *lum++]; - - ((int *)pixels)[0] = (tables->r_2_pix[L+cr_r] | tables->g_2_pix[L+crb_g] | tables->b_2_pix[L+cb_b]); - *row1++ = pixels[0]; *row1++ = pixels[1]; *row1++ = pixels[2]; - - /* - * Now, do second row. - */ - - L = tables->L_tab [(int) *lum2++]; - - ((int *)pixels)[0] = (tables->r_2_pix[L+cr_r] | tables->g_2_pix[L+crb_g] | tables->b_2_pix[L+cb_b]); - *row2++ = pixels[0]; *row2++ = pixels[1]; *row2++ = pixels[2]; - - L = tables->L_tab [(int) *lum2++]; - - ((int *)pixels)[0] = (tables->r_2_pix[L+cr_r] | tables->g_2_pix[L+crb_g] | tables->b_2_pix[L+cb_b]); - *row2++ = pixels[0]; *row2++ = pixels[1]; *row2++ = pixels[2]; - } - lum = lum2; - row1 = row2; - lum2 += cols; - row2 += cols_3; - } -} - -/* - *-------------------------------------------------------------- - * - * Color32DitherImage -- - * - * Converts image into 32 bit color (or 24-bit non-packed). - * - * Results: - * None. - * - * Side effects: - * None. - * - *-------------------------------------------------------------- - */ - -/* - * This is a copysoft version of the function above with ints instead - * of shorts to cause a 4-byte pixel size - */ - -static void -gst_colorspace_yuv_to_rgb32(tables, lum, cb, cr, out, rows, cols) - GstColorSpaceYUVTables *tables; - unsigned char *lum; - unsigned char *cr; - unsigned char *cb; - unsigned char *out; - int cols, rows; - -{ - int L, CR, CB; - unsigned int *row1, *row2; - unsigned char *lum2; - int x, y; - int cr_r; - int crb_g; - int cb_b; - int cols_2 = cols>>1; - - row1 = (guint32 *)out; - row2 = row1 + cols; - lum2 = lum + cols; - for (y=rows>>1; y; y--) { - for (x=cols_2; x; x--) { - - CR = *cr++; - CB = *cb++; - cr_r = tables->Cr_r_tab[CR]; - crb_g = tables->Cr_g_tab[CR] + tables->Cb_g_tab[CB]; - cb_b = tables->Cb_b_tab[CB]; - - L = tables->L_tab[(int) *lum++]; - - *row1++ = (tables->r_2_pix[L+cr_r] | tables->g_2_pix[L+crb_g] | tables->b_2_pix[L+cb_b]); - - L = tables->L_tab[(int) *lum++]; - - *row1++ = (tables->r_2_pix[L+cr_r] | tables->g_2_pix[L+crb_g] | tables->b_2_pix[L+cb_b]); - - /* - * Now, do second row. - */ - - L = tables->L_tab [(int) *lum2++]; - - *row2++ = (tables->r_2_pix[L+cr_r] | tables->g_2_pix[L+crb_g] | tables->b_2_pix[L+cb_b]); - - L = tables->L_tab [(int) *lum2++]; - - *row2++ = (tables->r_2_pix[L+cr_r] | tables->g_2_pix[L+crb_g] | tables->b_2_pix[L+cb_b]); - } - lum = lum2; - row1 = row2; - lum2 += cols; - row2 += cols; - } -} - -#ifdef HAVE_LIBMMX -static mmx_t MMX_80w = (mmx_t)(long long)0x0080008000800080LL; //dd 00080 0080h, 000800080h - -static mmx_t MMX_00FFw = (mmx_t)(long long)0x00ff00ff00ff00ffLL; //dd 000FF 00FFh, 000FF00FFh -static mmx_t MMX_FF00w = (mmx_t)(long long)0xff00ff00ff00ff00LL; //dd 000FF 00FFh, 000FF00FFh - -static mmx_t MMX32_Vredcoeff = (mmx_t)(long long)0x0059005900590059LL; -static mmx_t MMX32_Ubluecoeff = (mmx_t)(long long)0x0072007200720072LL; -static mmx_t MMX32_Ugrncoeff = (mmx_t)(long long)0xffeaffeaffeaffeaLL; -static mmx_t MMX32_Vgrncoeff = (mmx_t)(long long)0xffd2ffd2ffd2ffd2LL; - -static void -gst_colorspace_yuv_to_bgr32_mmx(tables, lum, cr, cb, out, rows, cols) - GstColorSpaceYUVTables *tables; - unsigned char *lum; - unsigned char *cr; - unsigned char *cb; - unsigned char *out; - int cols, rows; - -{ - guint32 *row1 = (guint32 *)out; // 32 bit target - int cols4 = cols>>2; - - int y, x; - - for (y=rows>>1; y; y--) { - for (x=cols4; x; x--) { - - // create Cr (result in mm1) - movd_m2r(*(mmx_t *)cb, mm1); // 0 0 0 0 v3 v2 v1 v0 - pxor_r2r(mm7, mm7); // 00 00 00 00 00 00 00 00 - movd_m2r(*(mmx_t *)lum, mm2); // 0 0 0 0 l3 l2 l1 l0 - punpcklbw_r2r(mm7, mm1); // 0 v3 0 v2 00 v1 00 v0 - punpckldq_r2r(mm1, mm1); // 00 v1 00 v0 00 v1 00 v0 - psubw_m2r(MMX_80w, mm1); // mm1-128:r1 r1 r0 r0 r1 r1 r0 r0 - - // create Cr_g (result in mm0) - movq_r2r(mm1, mm0); // r1 r1 r0 r0 r1 r1 r0 r0 - pmullw_m2r(MMX32_Vgrncoeff, mm0); // red*-46dec=0.7136*64 - pmullw_m2r(MMX32_Vredcoeff, mm1); // red*89dec=1.4013*64 - psraw_i2r(6, mm0); // red=red/64 - psraw_i2r(6, mm1); // red=red/64 - - // create L1 L2 (result in mm2,mm4) - // L2=lum+cols - movq_m2r(*(mmx_t *)(lum+cols),mm3); // 0 0 0 0 L3 L2 L1 L0 - punpckldq_r2r(mm3, mm2); // L3 L2 L1 L0 l3 l2 l1 l0 - movq_r2r(mm2, mm4); // L3 L2 L1 L0 l3 l2 l1 l0 - pand_m2r(MMX_FF00w, mm2); // L3 0 L1 0 l3 0 l1 0 - pand_m2r(MMX_00FFw, mm4); // 0 L2 0 L0 0 l2 0 l0 - psrlw_i2r(8, mm2); // 0 L3 0 L1 0 l3 0 l1 - - // create R (result in mm6) - movq_r2r(mm2, mm5); // 0 L3 0 L1 0 l3 0 l1 - movq_r2r(mm4, mm6); // 0 L2 0 L0 0 l2 0 l0 - paddsw_r2r(mm1, mm5); // lum1+red:x R3 x R1 x r3 x r1 - paddsw_r2r(mm1, mm6); // lum1+red:x R2 x R0 x r2 x r0 - packuswb_r2r(mm5, mm5); // R3 R1 r3 r1 R3 R1 r3 r1 - packuswb_r2r(mm6, mm6); // R2 R0 r2 r0 R2 R0 r2 r0 - pxor_r2r(mm7, mm7); // 00 00 00 00 00 00 00 00 - punpcklbw_r2r(mm5, mm6); // R3 R2 R1 R0 r3 r2 r1 r0 - - // create Cb (result in mm1) - movd_m2r(*(mmx_t *)cr, mm1); // 0 0 0 0 u3 u2 u1 u0 - punpcklbw_r2r(mm7, mm1); // 0 u3 0 u2 00 u1 00 u0 - punpckldq_r2r(mm1, mm1); // 00 u1 00 u0 00 u1 00 u0 - psubw_m2r(MMX_80w, mm1); // mm1-128:u1 u1 u0 u0 u1 u1 u0 u0 - // create Cb_g (result in mm5) - movq_r2r(mm1, mm5); // u1 u1 u0 u0 u1 u1 u0 u0 - pmullw_m2r(MMX32_Ugrncoeff, mm5); // blue*-109dec=1.7129*64 - pmullw_m2r(MMX32_Ubluecoeff, mm1); // blue*114dec=1.78125*64 - psraw_i2r(6, mm5); // blue=red/64 - psraw_i2r(6, mm1); // blue=blue/64 - - // create G (result in mm7) - movq_r2r(mm2, mm3); // 0 L3 0 L1 0 l3 0 l1 - movq_r2r(mm4, mm7); // 0 L2 0 L0 0 l2 0 l1 - paddsw_r2r(mm5, mm3); // lum1+Cb_g:x G3t x G1t x g3t x g1t - paddsw_r2r(mm5, mm7); // lum1+Cb_g:x G2t x G0t x g2t x g0t - paddsw_r2r(mm0, mm3); // lum1+Cr_g:x G3 x G1 x g3 x g1 - paddsw_r2r(mm0, mm7); // lum1+blue:x G2 x G0 x g2 x g0 - packuswb_r2r(mm3, mm3); // G3 G1 g3 g1 G3 G1 g3 g1 - packuswb_r2r(mm7, mm7); // G2 G0 g2 g0 G2 G0 g2 g0 - punpcklbw_r2r(mm3, mm7); // G3 G2 G1 G0 g3 g2 g1 g0 - - // create B (result in mm5) - movq_r2r(mm2, mm3); // 0 L3 0 L1 0 l3 0 l1 - movq_r2r(mm4, mm5); // 0 L2 0 L0 0 l2 0 l1 - paddsw_r2r(mm1, mm3); // lum1+blue:x B3 x B1 x b3 x b1 - paddsw_r2r(mm1, mm5); // lum1+blue:x B2 x B0 x b2 x b0 - packuswb_r2r(mm3, mm3); // B3 B1 b3 b1 B3 B1 b3 b1 - packuswb_r2r(mm5, mm5); // B2 B0 b2 b0 B2 B0 b2 b0 - punpcklbw_r2r(mm3, mm5); // B3 B2 B1 B0 b3 b2 b1 b0 - - // fill destination row1 (needed are mm6=Rr,mm7=Gg,mm5=Bb) - - pxor_r2r(mm2, mm2); // 0 0 0 0 0 0 0 0 - pxor_r2r(mm4, mm4); // 0 0 0 0 0 0 0 0 - movq_r2r(mm6, mm1); // R3 R2 R1 R0 r3 r2 r1 r0 - movq_r2r(mm5, mm3); // B3 B2 B1 B0 b3 b2 b1 b0 - // process lower lum - punpcklbw_r2r(mm4, mm1); // 0 r3 0 r2 0 r1 0 r0 - punpcklbw_r2r(mm4, mm3); // 0 b3 0 b2 0 b1 0 b0 - movq_r2r(mm1, mm2); // 0 r3 0 r2 0 r1 0 r0 - movq_r2r(mm3, mm0); // 0 b3 0 b2 0 b1 0 b0 - punpcklwd_r2r(mm1, mm3); // 0 r1 0 b1 0 r0 0 b0 - punpckhwd_r2r(mm2, mm0); // 0 r3 0 b3 0 r2 0 b2 - - pxor_r2r(mm2, mm2); // 0 0 0 0 0 0 0 0 - movq_r2r(mm7, mm1); // G3 G2 G1 G0 g3 g2 g1 g0 - punpcklbw_r2r(mm1, mm2); // g3 0 g2 0 g1 0 g0 0 - punpcklwd_r2r(mm4, mm2); // 0 0 g1 0 0 0 g0 0 - por_r2r(mm3, mm2); // 0 r1 g1 b1 0 r0 g0 b0 - movq_r2m(mm2, *(mmx_t *)row1); // wrote out ! row1 - - pxor_r2r(mm2, mm2); // 0 0 0 0 0 0 0 0 - punpcklbw_r2r(mm1, mm4); // g3 0 g2 0 g1 0 g0 0 - punpckhwd_r2r(mm2, mm4); // 0 0 g3 0 0 0 g2 0 - por_r2r(mm0, mm4); // 0 r3 g3 b3 0 r2 g2 b2 - movq_r2m(mm4, *(mmx_t *)(row1+2)); // wrote out ! row1 - - // fill destination row2 (needed are mm6=Rr,mm7=Gg,mm5=Bb) - // this can be done "destructive" - pxor_r2r(mm2, mm2); // 0 0 0 0 0 0 0 0 - punpckhbw_r2r(mm2, mm6); // 0 R3 0 R2 0 R1 0 R0 - punpckhbw_r2r(mm1, mm5); // G3 B3 G2 B2 G1 B1 G0 B0 - movq_r2r(mm5, mm1); // G3 B3 G2 B2 G1 B1 G0 B0 - punpcklwd_r2r(mm6, mm1); // 0 R1 G1 B1 0 R0 G0 B0 - movq_r2m(mm1, *(mmx_t *)(row1+cols)); // wrote out ! row2 - punpckhwd_r2r(mm6, mm5); // 0 R3 G3 B3 0 R2 G2 B2 - movq_r2m(mm5, *(mmx_t *)(row1+cols+2)); // wrote out ! row2 - - lum+=4; - cr+=2; - cb+=2; - row1 +=4; - } - lum += cols; - row1 += cols; - } - - emms(); - -} -#endif - diff --git a/libs/colorspace/yuv2rgb.h b/libs/colorspace/yuv2rgb.h deleted file mode 100644 index e0e8772701..0000000000 --- a/libs/colorspace/yuv2rgb.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 1995 The Regents of the University of California. - * All rights reserved. - * - * Permission to use, copy, modify, and distribute this software and its - * documentation for any purpose, without fee, and without written agreement is - * hereby granted, provided that the above copyright notice and the following - * two paragraphs appear in all copies of this software. - * - * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT - * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF - * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO - * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - */ - -#ifndef __YUV2RGB_H__ -#define __YUV2RGB_H__ - -typedef struct _GstColorSpaceYUVTables GstColorSpaceYUVTables; - -struct _GstColorSpaceYUVTables { - int gammaCorrectFlag; - double gammaCorrect; - int chromaCorrectFlag; - double chromaCorrect; - - int *L_tab, *Cr_r_tab, *Cr_g_tab, *Cb_g_tab, *Cb_b_tab; - - /* - * We define tables that convert a color value between -256 and 512 - * into the R, G and B parts of the pixel. The normal range is 0-255. - **/ - - long *r_2_pix; - long *g_2_pix; - long *b_2_pix; -}; - - -#define CB_BASE 1 -#define CR_BASE (CB_BASE*CB_RANGE) -#define LUM_BASE (CR_BASE*CR_RANGE) - -#define Min(x,y) (((x) < (y)) ? (x) : (y)) -#define Max(x,y) (((x) > (y)) ? (x) : (y)) - -#define GAMMA_CORRECTION(x) ((int)(pow((x) / 255.0, 1.0 / gammaCorrect) * 255.0)) -#define CHROMA_CORRECTION256(x) ((x) >= 128 \ - ? 128 + Min(127, (int)(((x) - 128.0) * chromaCorrect)) \ - : 128 - Min(128, (int)((128.0 - (x)) * chromaCorrect))) -#define CHROMA_CORRECTION128(x) ((x) >= 0 \ - ? Min(127, (int)(((x) * chromaCorrect))) \ - : Max(-128, (int)(((x) * chromaCorrect)))) -#define CHROMA_CORRECTION256D(x) ((x) >= 128 \ - ? 128.0 + Min(127.0, (((x) - 128.0) * chromaCorrect)) \ - : 128.0 - Min(128.0, (((128.0 - (x)) * chromaCorrect)))) -#define CHROMA_CORRECTION128D(x) ((x) >= 0 \ - ? Min(127.0, ((x) * chromaCorrect)) \ - : Max(-128.0, ((x) * chromaCorrect))) - -#endif - diff --git a/libs/colorspace/yuv2rgb_mmx16.s b/libs/colorspace/yuv2rgb_mmx16.s deleted file mode 100644 index 8f7b1f77e4..0000000000 --- a/libs/colorspace/yuv2rgb_mmx16.s +++ /dev/null @@ -1,188 +0,0 @@ -.globl mmx_80w -.data - .align 4 - .type mmx_80w,@object - .size mmx_80w,8 -mmx_80w: - .long 8388736 - .long 8388736 -.globl mmx_10w - .align 4 - .type mmx_10w,@object - .size mmx_10w,8 -mmx_10w: - .long 269488144 - .long 269488144 -.globl mmx_00ffw - .align 4 - .type mmx_00ffw,@object - .size mmx_00ffw,8 -mmx_00ffw: - .long 16711935 - .long 16711935 -.globl mmx_Y_coeff - .align 4 - .type mmx_Y_coeff,@object - .size mmx_Y_coeff,8 -mmx_Y_coeff: - .long 624895295 - .long 624895295 -.globl mmx_U_green - .align 4 - .type mmx_U_green,@object - .size mmx_U_green,8 -mmx_U_green: - .long -209849475 - .long -209849475 -.globl mmx_U_blue - .align 4 - .type mmx_U_blue,@object - .size mmx_U_blue,8 -mmx_U_blue: - .long 1083392147 - .long 1083392147 -.globl mmx_V_red - .align 4 - .type mmx_V_red,@object - .size mmx_V_red,8 -mmx_V_red: - .long 856830738 - .long 856830738 -.globl mmx_V_green - .align 4 - .type mmx_V_green,@object - .size mmx_V_green,8 -mmx_V_green: - .long -436410884 - .long -436410884 -.globl mmx_redmask - .align 4 - .type mmx_redmask,@object - .size mmx_redmask,8 -mmx_redmask: - .long -117901064 - .long -117901064 -.globl mmx_grnmask - .align 4 - .type mmx_grnmask,@object - .size mmx_grnmask,8 -mmx_grnmask: - .long -50529028 - .long -50529028 -.text - .align 4 -.globl gst_colorspace_yuv_to_bgr16_mmx - .type gst_colorspace_yuv_to_bgr16_mmx,@function -gst_colorspace_yuv_to_bgr16_mmx: - subl $8,%esp - pushl %ebp - pushl %edi - pushl %esi - movl 28(%esp),%edi - movl 32(%esp),%ecx - movl 36(%esp),%edx - movl $1,%ebp - movl 48(%esp),%esi - sarl $1,%esi - movl %esi,16(%esp) - - pxor %mm4, %mm4 # zero mm4 - - movl %esi,12(%esp) - sarl $2,12(%esp) - - movl 40(%esp),%esi - - .p2align 4,,7 -.L68: - - movd (%ecx), %mm0 # Load 4 Cb 00 00 00 00 00 u3 u2 u1 u0 - movd (%edx), %mm1 # Load 4 Cr 00 00 00 00 00 v2 v1 v0 - movq (%edi), %mm6 # Load 8 Y Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 - - movl 12(%esp),%eax - - .p2align 4,,7 -.L74: - punpcklbw %mm4, %mm0 # scatter 4 Cb 00 u3 00 u2 00 u1 00 u0 - punpcklbw %mm4, %mm1 # scatter 4 Cr 00 v3 00 v2 00 v1 00 v0 - psubsw mmx_80w, %mm0 # Cb -= 128 - psubsw mmx_80w, %mm1 # Cr -= 128 - psllw $3, %mm0 # Promote precision - psllw $3, %mm1 # Promote precision - movq %mm0, %mm2 # Copy 4 Cb 00 u3 00 u2 00 u1 00 u0 - movq %mm1, %mm3 # Copy 4 Cr 00 v3 00 v2 00 v1 00 v0 - pmulhw mmx_U_green, %mm2 # Mul Cb with green coeff -> Cb green - pmulhw mmx_V_green, %mm3 # Mul Cr with green coeff -> Cr green - pmulhw mmx_U_blue, %mm0 # Mul Cb -> Cblue 00 b3 00 b2 00 b1 00 b0 - pmulhw mmx_V_red, %mm1 # Mul Cr -> Cred 00 r3 00 r2 00 r1 00 r0 - paddsw %mm3, %mm2 # Cb green + Cr green -> Cgreen - psubusb mmx_10w, %mm6 # Y -= 16 - movq %mm6, %mm7 # Copy 8 Y Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 - pand mmx_00ffw, %mm6 # get Y even 00 Y6 00 Y4 00 Y2 00 Y0 - psrlw $8, %mm7 # get Y odd 00 Y7 00 Y5 00 Y3 00 Y1 - psllw $3, %mm6 # Promote precision - psllw $3, %mm7 # Promote precision - pmulhw mmx_Y_coeff, %mm6 # Mul 4 Y even 00 y6 00 y4 00 y2 00 y0 - pmulhw mmx_Y_coeff, %mm7 # Mul 4 Y odd 00 y7 00 y5 00 y3 00 y1 - movq %mm0, %mm3 # Copy Cblue - movq %mm1, %mm4 # Copy Cred - movq %mm2, %mm5 # Copy Cgreen - paddsw %mm6, %mm0 # Y even + Cblue 00 B6 00 B4 00 B2 00 B0 - paddsw %mm7, %mm3 # Y odd + Cblue 00 B7 00 B5 00 B3 00 B1 - paddsw %mm6, %mm1 # Y even + Cred 00 R6 00 R4 00 R2 00 R0 - paddsw %mm7, %mm4 # Y odd + Cred 00 R7 00 R5 00 R3 00 R1 - paddsw %mm6, %mm2 # Y even + Cgreen 00 G6 00 G4 00 G2 00 G0 - paddsw %mm7, %mm5 # Y odd + Cgreen 00 G7 00 G5 00 G3 00 G1 - packuswb %mm0, %mm0 # B6 B4 B2 B0 | B6 B4 B2 B0 - packuswb %mm1, %mm1 # R6 R4 R2 R0 | R6 R4 R2 R0 - packuswb %mm2, %mm2 # G6 G4 G2 G0 | G6 G4 G2 G0 - packuswb %mm3, %mm3 # B7 B5 B3 B1 | B7 B5 B3 B1 - packuswb %mm4, %mm4 # R7 R5 R3 R1 | R7 R5 R3 R1 - packuswb %mm5, %mm5 # G7 G5 G3 G1 | G7 G5 G3 G1 - punpcklbw %mm3, %mm0 # B7 B6 B5 B4 B3 B2 B1 B0 - punpcklbw %mm4, %mm1 # R7 R6 R5 R4 R3 R2 R1 R0 - punpcklbw %mm5, %mm2 # G7 G6 G5 G4 G3 G2 G1 G0 - pand mmx_redmask, %mm0 # b7b6b5b4 b3_0_0_0 b7b6b5b4 b3_0_0_0 - pand mmx_grnmask, %mm2 # g7g6g5g4 g3g2_0_0 g7g6g5g4 g3g2_0_0 - pand mmx_redmask, %mm1 # r7r6r5r4 r3_0_0_0 r7r6r5r4 r3_0_0_0 - psrlw $3,%mm0 #0_0_0_b7 b6b5b4b3 0_0_0_b7 b6b5b4b3 - pxor %mm4, %mm4 # zero mm4 - movq %mm0, %mm5 # Copy B7-B0 - movq %mm2, %mm7 # Copy G7-G0 - punpcklbw %mm4, %mm2 # 0_0_0_0 0_0_0_0 g7g6g5g4 g3g2_0_0 - punpcklbw %mm1, %mm0 # r7r6r5r4 r3_0_0_0 0_0_0_b7 b6b5b4b3 - psllw $3,%mm2 # 0_0_0_0 0_g7g6g5 g4g3g2_0 0_0_0_0 - por %mm2, %mm0 # r7r6r5r4 r3g7g6g5 g4g3g2b7 b6b5b4b3 - movq 8(%edi), %mm6 # Load 8 Y Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 - movq %mm0, (%esi) # store pixel 0-3 - punpckhbw %mm4, %mm7 # 0_0_0_0 0_0_0_0 g7g6g5g4 g3g2_0_0 - punpckhbw %mm1, %mm5 # r7r6r5r4 r3_0_0_0 0_0_0_b7 b6b5b4b3 - psllw $3,%mm7 # 0_0_0_0 0_g7g6g5 g4g3g2_0 0_0_0_0 - movd 4(%ecx), %mm0 # Load 4 Cb 00 00 00 00 u3 u2 u1 u0 - por %mm7, %mm5 # r7r6r5r4 r3g7g6g5 g4g3g2b7 b6b5b4b3 - movd 4(%edx), %mm1 # Load 4 Cr 00 00 00 00 v3 v2 v1 v0 - movq %mm5, 8(%esi) # store pixel 4-7 - - addl $8,%edi - addl $4,%ecx - addl $4,%edx - addl $16,%esi - decl %eax - jnz .L74 -.L72: - xorl $1,%ebp - jne .L76 - subl 16(%esp),%ecx - subl 16(%esp),%edx -.L76: - subl $1,44(%esp) - jnz .L68 - - emms - - popl %esi - popl %edi - popl %ebp - addl $8,%esp - ret diff --git a/libs/videoscale/.gitignore b/libs/videoscale/.gitignore deleted file mode 100644 index 08f5ed37d8..0000000000 --- a/libs/videoscale/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -Makefile -Makefile.in -*.o -*.lo -*.la -.deps -.libs diff --git a/libs/videoscale/Makefile.am b/libs/videoscale/Makefile.am deleted file mode 100644 index 640722ba31..0000000000 --- a/libs/videoscale/Makefile.am +++ /dev/null @@ -1,19 +0,0 @@ -filterdir = $(libdir)/gst - -filter_LTLIBRARIES = libgstvideoscale.la - -if HAVE_CPU_I386 -SCALER = gstscale_x86.c gstscale_x86_asm.s -else -SCALER = -endif - -libgstvideoscale_la_SOURCES = gstvideoscale.c $(SCALER) - -libgstvideoscaleincludedir = $(includedir)/gst/libs/gstvideoscale -libgstvideoscaleinclude_HEADERS = gstvideoscale.h - -noinst_HEADERS = gstscale_x86.h - -#CFLAGS += -S -O1 $(FOMIT_FRAME_POINTER) -funroll-all-loops -finline-functions -ffast-math -CFLAGS = $(GLIB_CFLAGS) $(GTK_CFLAGS) $(GST_CFLAGS) $(XML_CFLAGS) -O5 -fomit-frame-pointer -ffast-math diff --git a/libs/videoscale/gstscale_x86.c b/libs/videoscale/gstscale_x86.c deleted file mode 100644 index 22ecf317a9..0000000000 --- a/libs/videoscale/gstscale_x86.c +++ /dev/null @@ -1,80 +0,0 @@ -/* Gnome-Streamer - * Copyright (C) <1999> Erik Walthinsen - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -//#define DEBUG_ENABLED - -#include "gstvideoscale.h" - -/* scalers */ -void gst_videoscale_generate_rowbytes_x86 (unsigned char *copy_row, int src_w, int dst_w, int bpp); -void gst_videoscale_scale_nearest_x86 (GstVideoScale *scale, - unsigned char *src, unsigned char *dest, - int sw, int sh, int dw, int dh); - -#define PREFIX16 0x66 -#define STORE_BYTE 0xAA -#define STORE_WORD 0xAB -#define LOAD_BYTE 0xAC -#define LOAD_WORD 0xAD -#define RETURN 0xC3 - -void -gst_videoscale_generate_rowbytes_x86 (unsigned char *copy_row, int src_w, int dst_w, int bpp) -{ - int i; - int pos, inc; - unsigned char *eip; - unsigned char load, store; - - GST_DEBUG (0,"videoscale: setup scaling %p\n", copy_row); - - switch (bpp) { - case 1: - load = LOAD_BYTE; - store = STORE_BYTE; - break; - case 2: - case 4: - load = LOAD_WORD; - store = STORE_WORD; - break; - default: - return; - } - pos = 0x10000; - inc = (src_w << 16) / dst_w; - eip = copy_row; - for ( i=0; i= 0x10000L ) { - if ( bpp == 2 ) { - *eip++ = PREFIX16; - } - *eip++ = load; - pos -= 0x10000L; - } - if ( bpp == 2 ) { - *eip++ = PREFIX16; - } - *eip++ = store; - pos += inc; - } - *eip++ = RETURN; - GST_DEBUG (0,"scaler start/end %p %p %p\n", copy_row, eip, (void*)(eip-copy_row)); -} - diff --git a/libs/videoscale/gstscale_x86.h b/libs/videoscale/gstscale_x86.h deleted file mode 100644 index af73109003..0000000000 --- a/libs/videoscale/gstscale_x86.h +++ /dev/null @@ -1,30 +0,0 @@ -/* Gnome-Streamer - * Copyright (C) <1999> Erik Walthinsen - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - - -#ifndef __GST_VIDEOSCALE__X86_H__ -#define __GST_VIDEOSCALE__X86_H__ - - -/* scalers */ -void gst_videoscale_generate_rowbytes_x86 (unsigned char *copy_row, int src_w, int dst_w, int bpp); -void gst_videoscale_scale_nearest_x86 (GstVideoScale *scale, - unsigned char *src, unsigned char *dest, - int sw, int sh, int dw, int dh); -#endif /* __GST_VIDEOSCALE__X86_H__ */ diff --git a/libs/videoscale/gstscale_x86_asm.s b/libs/videoscale/gstscale_x86_asm.s deleted file mode 100644 index 9ec97852c4..0000000000 --- a/libs/videoscale/gstscale_x86_asm.s +++ /dev/null @@ -1,53 +0,0 @@ -.text - .align 4 -.globl gst_videoscale_scale_nearest_x86 - .type gst_videoscale_scale_nearest_x86,@function -gst_videoscale_scale_nearest_x86: - - subl $8,%esp - pushl %ebp - pushl %edi - pushl %esi - movl 28(%esp),%ebp - movl 24(%esp),%edx - addl $28,%edx - movl 24(%esp),%eax - movl %edx,8220(%eax) - movl $65536,12(%esp) - movl 40(%esp),%ecx - sall $16,%ecx - movl %ecx,%eax - cltd - idivl 48(%esp) - movl %eax,%ecx - movl 48(%esp),%eax - movl %eax,16(%esp) - testl %eax,%eax - jle .L92 - jmp .L100 - .p2align 4,,7 -.L97: - addl 36(%esp),%ebp - addl $-65536,12(%esp) -.L100: - cmpl $65536,12(%esp) - jg .L97 - movl 32(%esp),%edi - movl %ebp,%esi - movl 24(%esp),%edx - - movl 8220(%edx), %eax - call *%eax - - movl 44(%esp),%eax - addl %eax,32(%esp) - addl %ecx,12(%esp) - decl 16(%esp) - cmpl $0,16(%esp) - jg .L100 -.L92: - popl %esi - popl %edi - popl %ebp - addl $8,%esp - ret diff --git a/libs/videoscale/gstvideoscale.c b/libs/videoscale/gstvideoscale.c deleted file mode 100644 index b59ca99e65..0000000000 --- a/libs/videoscale/gstvideoscale.c +++ /dev/null @@ -1,393 +0,0 @@ -/* Gnome-Streamer - * Copyright (C) <1999> Erik Walthinsen - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -//#define DEBUG_ENABLED -#include -#include - -#include "config.h" -#include "gstvideoscale.h" -#ifdef HAVE_CPU_I386 -#include "gstscale_x86.h" -#endif - -static void gst_videoscale_scale_yuv (GstVideoScale *scale, unsigned char *src, unsigned char *dest); -static void gst_videoscale_scale_rgb (GstVideoScale *scale, unsigned char *src, unsigned char *dest); - -/* scalers */ -static void gst_videoscale_scale_nearest (GstVideoScale *scale, unsigned char *src, unsigned char *dest, - int sw, int sh, int dw, int dh); -static void gst_videoscale_scale_plane_slow (GstVideoScale *scale, unsigned char *src, unsigned char *dest, - int sw, int sh, int dw, int dh); -static void gst_videoscale_scale_point_sample (GstVideoScale *scale, unsigned char *src, unsigned char *dest, - int sw, int sh, int dw, int dh); - -/* filters */ -static unsigned char gst_videoscale_bilinear (unsigned char *src, double x, double y, int sw, int sh); -static unsigned char gst_videoscale_bicubic (unsigned char *src, double x, double y, int sw, int sh); - -GstVideoScale* -gst_videoscale_new (gint sw, gint sh, gint dw, gint dh, - GstColorSpaceType format, GstVideoScaleMethod method) -{ - GstVideoScale *new = g_malloc(sizeof(GstVideoScale)); - - new->source_width = sw; - new->source_height = sh; - new->dest_width = dw; - new->dest_height = dh; - new->format = format; - new->method = method; - - - switch (format) { - case GST_COLORSPACE_YUV420P: - new->scale = gst_videoscale_scale_yuv; - new->scale_bytes = 1; - break; - case GST_COLORSPACE_RGB555: - case GST_COLORSPACE_RGB565: - case GST_COLORSPACE_BGR555: - case GST_COLORSPACE_BGR565: - new->scale = gst_videoscale_scale_rgb; - new->scale_bytes = 2; - break; - case GST_COLORSPACE_RGB32: - case GST_COLORSPACE_BGR32: - new->scale = gst_videoscale_scale_rgb; - new->scale_bytes = 4; - break; - default: - g_print("videoscale: unsupported video format %d\n", format); - g_free(new); - return NULL; - } - - switch (method) { - case GST_VIDEOSCALE_POINT_SAMPLE: - new->scaler = gst_videoscale_scale_point_sample; - GST_DEBUG (0,"videoscale: scaling method POINT_SAMPLE\n"); - break; - case GST_VIDEOSCALE_NEAREST: -#ifdef HAVE_CPU_I386 - gst_videoscale_generate_rowbytes_x86 (new->copy_row, sw, dw, new->scale_bytes); - new->scaler = gst_videoscale_scale_nearest_x86; -#else - new->scaler = gst_videoscale_scale_nearest; -#endif - GST_DEBUG (0,"videoscale: scaling method NEAREST\n"); - break; - case GST_VIDEOSCALE_BILINEAR: - new->scaler = gst_videoscale_scale_plane_slow; - new->filter = gst_videoscale_bilinear; - GST_DEBUG (0,"videoscale: scaling method BILINEAR\n"); - break; - case GST_VIDEOSCALE_BICUBIC: - new->scaler = gst_videoscale_scale_plane_slow; - new->filter = gst_videoscale_bicubic; - GST_DEBUG (0,"videoscale: scaling method BICUBIC\n"); - break; - default: - g_print("videoscale: unsupported scaling method %d\n", method); - g_free(new); - return NULL; - } - - return new; -} - -void -gst_videoscale_destroy (GstVideoScale *scale) -{ - g_free(scale); -} - -static void -gst_videoscale_scale_rgb (GstVideoScale *scale, unsigned char *src, unsigned char *dest) -{ - int sw = scale->source_width; - int sh = scale->source_height; - int dw = scale->dest_width; - int dh = scale->dest_height; - GST_DEBUG (0,"videoscale: scaling RGB %dx%d to %dx%d\n", sw, sh, dw, dh); - - switch (scale->scale_bytes) { - case 2: - dw = ((dw + 1) & ~1) << 1; - sw = sw<<1; - break; - case 4: - dw = ((dw + 2) & ~3) << 2; - sw = sw<<2; - break; - default: - break; - } - - GST_DEBUG (0,"videoscale: %p %p\n", src, dest); - scale->scaler(scale, src, dest, sw, sh, dw, dh); -} - -static void -gst_videoscale_scale_yuv (GstVideoScale *scale, unsigned char *src, unsigned char *dest) -{ - int sw = scale->source_width; - int sh = scale->source_height; - int dw = scale->dest_width; - int dh = scale->dest_height; - - GST_DEBUG (0,"videoscale: scaling YUV420P %dx%d to %dx%d\n", sw, sh, dw, dh); - - scale->scaler(scale, src, dest, sw, sh, dw, dh); - - src += sw*sh; - dest += dw*dh; - - dh = dh>>1; - dw = dw>>1; - sh = sh>>1; - sw = sw>>1; - - scale->scaler(scale, src, dest, sw, sh, dw, dh); - - src += sw*sh; - dest += dw*dh; - - scale->scaler(scale, src, dest, sw, sh, dw, dh); -} - -#define RC(x,y) *(src+(int)(x)+(int)((y)*sw)) - -static unsigned char -gst_videoscale_bilinear (unsigned char *src, double x, double y, int sw, int sh) -{ - int j=floor(x); - int k=floor(y); - double a=x-j; - double b=y-k; - double dest; - int color; - - GST_DEBUG(0,"videoscale: scaling bilinear %f %f %dx%d\n", x, y, sw, sh); - - dest=(1-a)*(1-b)*RC(j,k)+ - a*(1-b)*RC(j+1,k); - - k = MIN(sh-1, k); - dest+= b*(1-a)*RC(j,k+1)+ - a*b*RC(j+1,k+1); - - color=rint(dest); - if (color<0) color=abs(color); // cannot have negative values ! - //if (color<0) color=0; // cannot have negative values ! - if (color>255) color=255; - - return (unsigned char) color; -} - -static unsigned char -gst_videoscale_bicubic (unsigned char *src, double x, double y, int sw, int sh) -{ - int j=floor(x); - int k=floor(y), k2; - double a=x-j; - double b=y-k; - double dest; - int color; - double t1, t2, t3, t4; - double a1, a2, a3, a4; - - GST_DEBUG (0,"videoscale: scaling bicubic %dx%d\n", sw, sh); - - a1 = -a*(1-a)*(1-a); - a2 = (1-2*a*a+a*a*a); - a3 = a*(1+a-a*a); - a4 = a*a*(1-a); - - k2 = MAX(0, k-1); - t1=a1*RC(j-1,k2)+ a2*RC(j,k2)+ a3*RC(j+1,k2)- a4*RC(j+2,k2); - t2=a1*RC(j-1,k)+ a2*RC(j,k)+ a3*RC(j+1,k)- a4*RC(j+2,k); - k2 = MIN(sh, k+1); - t3=a1*RC(j-1,k2)+ a2*RC(j,k2)+ a3*RC(j+1,k2)- a4*RC(j+2,k2); - k2 = MIN(sh, k+2); - t4=a1*RC(j-1,k2)+ a2*RC(j,k2)+ a3*RC(j+1,k2)- a4*RC(j+2,k2); - - dest= -b*(1-b)*(1-b)*t1+ (1-2*b*b+b*b*b)*t2+ b*(1+b-b*b)*t3+ b*b*(b-1)*t4; - - color=rint(dest); - if (color<0) color=abs(color); // cannot have negative values ! - if (color>255) color=255; - - return (unsigned char) color; -} - -static void -gst_videoscale_scale_plane_slow (GstVideoScale *scale, unsigned char *src, unsigned char *dest, - int sw, int sh, int dw, int dh) -{ - double zoomx = ((double)dw)/(double)sw; - double zoomy = ((double)dh)/(double)sh; - double xr, yr; - int x, y; - - GST_DEBUG (0,"videoscale: scale plane slow %dx%d %dx%d %g %g %p %p\n", sw, sh, dw, dh, zoomx, zoomy, src, dest); - - for (y=0; yfilter(src, xr, yr, sw, sh); - //*dest++ = gst_videoscale_bicubic(src, xr, yr, sw, sh); - } - } - } -} - -static void -gst_videoscale_scale_point_sample (GstVideoScale *scale, unsigned char *src, unsigned char *dest, - int sw, int sh, int dw, int dh) -{ - int ypos, yinc, y; - int xpos, xinc, x; - int sum, xcount, ycount, loop; - unsigned char *srcp, *srcp2; - - GST_DEBUG (0,"videoscale: scaling nearest point sample %p %p %d\n", src, dest, dw); - - ypos = 0x10000; - yinc = (sh<<16)/dh; - xinc = (sw<<16)/dw; - - for (y = dh; y; y--) { - - ycount = 1; - srcp = src; - while (ypos >0x10000) { - ycount++; - ypos-=0x10000; - src += sw; - } - - xpos = 0x10000; - for ( x=dw; x; x-- ) { - xcount = 0; - sum=0; - while ( xpos >= 0x10000L ) { - loop = ycount; - srcp2 = srcp; - while (loop--) { - sum += *srcp2; - srcp2 += sw; - } - srcp++; - xcount++; - xpos -= 0x10000L; - } - *dest++ = sum/(xcount*ycount); - xpos += xinc; - } - - ypos += yinc; - } -} - -static void -gst_videoscale_scale_nearest (GstVideoScale *scale, - unsigned char *src, - unsigned char *dest, - int sw, int sh, int dw, int dh) -{ - int ypos, yinc, y; - int xpos, xinc, x; - - GST_DEBUG (0, "videoscale: scaling nearest %p %p %d %d\n", src, dest, dw, scale->scale_bytes); - - - ypos = 0x10000; - yinc = (sh<<16)/dh; - xinc = (sw<<16)/dw; - - for (y = dh; y; y--) { - - while (ypos >0x10000) { - ypos-=0x10000; - src += sw; - } - - xpos = 0x10000; - - switch (scale->scale_bytes) { - case 4: - { - guint32 *destp = (guint32 *)dest; - guint32 *srcp = (guint32 *)src; - - for ( x=dw>>2; x; x-- ) { - while ( xpos >= 0x10000L ) { - srcp++; - xpos -= 0x10000L; - } - *destp++ = *srcp; - xpos += xinc; - } - break; - } - case 2: - { - guint16 *destp = (guint16 *)dest; - guint16 *srcp = (guint16 *)src; - - for ( x=dw>>1; x; x-- ) { - while ( xpos >= 0x10000L ) { - srcp++; - xpos -= 0x10000L; - } - *destp++ = *srcp; - xpos += xinc; - } - break; - } - case 1: - { - guchar *destp = dest; - guchar *srcp = src; - - for ( x=dw; x; x-- ) { - while ( xpos >= 0x10000L ) { - srcp++; - xpos -= 0x10000L; - } - *destp++ = *srcp; - xpos += xinc; - } - } - } - dest += dw; - - ypos += yinc; - } -} diff --git a/libs/videoscale/gstvideoscale.h b/libs/videoscale/gstvideoscale.h deleted file mode 100644 index b421d62c1e..0000000000 --- a/libs/videoscale/gstvideoscale.h +++ /dev/null @@ -1,57 +0,0 @@ -/* Gnome-Streamer - * Copyright (C) <1999> Erik Walthinsen - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - - -#ifndef __GST_VIDEOSCALE_H__ -#define __GST_VIDEOSCALE_H__ - -#include -#include - -typedef enum { - GST_VIDEOSCALE_POINT_SAMPLE, - GST_VIDEOSCALE_NEAREST, - GST_VIDEOSCALE_BILINEAR, - GST_VIDEOSCALE_BICUBIC -} GstVideoScaleMethod; - -typedef struct _GstVideoScale GstVideoScale; -typedef void (*GstVideoScaleScaler) (GstVideoScale *scale, guchar *src, guchar *dest); - -struct _GstVideoScale { - guint source_width; - guint source_height; - guint dest_width; - guint dest_height; - GstColorSpaceType format; - GstVideoScaleMethod method; - guint scale_bytes; - /* private */ - guchar copy_row[8192]; - guchar *temp; - GstVideoScaleScaler scale; - void (*scaler) (GstVideoScale *scale, guchar *src, guchar *dest, gint sw, gint sh, gint dw, gint dh); - guchar (*filter) (guchar *src, gdouble x, gdouble y, gint sw, gint sh); -}; - -GstVideoScale *gst_videoscale_new(gint sw, gint sh, gint dw, gint dh, GstColorSpaceType format, GstVideoScaleMethod method); -#define gst_videoscale_scale(scaler, src, dest) (scaler)->scale((scaler), (src), (dest)) -void gst_videoscale_destroy(GstVideoScale *scale); - -#endif /* __GST_VIDEOSCALE_H__ */