2002-03-20 21:45:03 +00:00
|
|
|
/* GStreamer
|
2001-12-22 23:27:17 +00:00
|
|
|
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
*
|
|
|
|
* 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
|
2003-11-06 22:18:56 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
2003-11-07 12:47:02 +00:00
|
|
|
|
2003-04-22 07:32:50 +00:00
|
|
|
#include <gst/gst.h>
|
2001-12-22 23:27:17 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <math.h>
|
2003-04-22 07:32:50 +00:00
|
|
|
#include <videoscale.h>
|
|
|
|
#include <string.h>
|
2001-12-22 23:27:17 +00:00
|
|
|
|
|
|
|
#include "gstvideoscale.h"
|
|
|
|
#undef HAVE_CPU_I386
|
|
|
|
#ifdef HAVE_CPU_I386
|
|
|
|
#include "videoscale_x86.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* scalers */
|
2004-03-14 22:34:34 +00:00
|
|
|
static void gst_videoscale_scale_nearest (GstVideoscale * scale,
|
|
|
|
unsigned char *dest, unsigned char *src, int sw, int sh, int dw, int dh);
|
2003-04-22 07:32:50 +00:00
|
|
|
#if 0
|
2004-03-14 22:34:34 +00:00
|
|
|
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);
|
2001-12-22 23:27:17 +00:00
|
|
|
|
|
|
|
/* filters */
|
2004-03-14 22:34:34 +00:00
|
|
|
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);
|
2003-05-02 20:36:55 +00:00
|
|
|
#endif
|
2001-12-22 23:27:17 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
static void gst_videoscale_planar411 (GstVideoscale * scale,
|
|
|
|
unsigned char *dest, unsigned char *src);
|
|
|
|
static void gst_videoscale_planar400 (GstVideoscale * scale,
|
|
|
|
unsigned char *dest, unsigned char *src);
|
|
|
|
static void gst_videoscale_packed422 (GstVideoscale * scale,
|
|
|
|
unsigned char *dest, unsigned char *src);
|
|
|
|
static void gst_videoscale_packed422rev (GstVideoscale * scale,
|
|
|
|
unsigned char *dest, unsigned char *src);
|
|
|
|
static void gst_videoscale_32bit (GstVideoscale * scale, unsigned char *dest,
|
|
|
|
unsigned char *src);
|
|
|
|
static void gst_videoscale_24bit (GstVideoscale * scale, unsigned char *dest,
|
|
|
|
unsigned char *src);
|
|
|
|
static void gst_videoscale_16bit (GstVideoscale * scale, unsigned char *dest,
|
|
|
|
unsigned char *src);
|
|
|
|
|
|
|
|
static void gst_videoscale_scale_nearest_str2 (GstVideoscale * scale,
|
|
|
|
unsigned char *dest, unsigned char *src, int sw, int sh, int dw, int dh);
|
|
|
|
static void gst_videoscale_scale_nearest_str4 (GstVideoscale * scale,
|
|
|
|
unsigned char *dest, unsigned char *src, int sw, int sh, int dw, int dh);
|
|
|
|
static void gst_videoscale_scale_nearest_32bit (GstVideoscale * scale,
|
|
|
|
unsigned char *dest, unsigned char *src, int sw, int sh, int dw, int dh);
|
|
|
|
static void gst_videoscale_scale_nearest_24bit (GstVideoscale * scale,
|
|
|
|
unsigned char *dest, unsigned char *src, int sw, int sh, int dw, int dh);
|
|
|
|
static void gst_videoscale_scale_nearest_16bit (GstVideoscale * scale,
|
|
|
|
unsigned char *dest, unsigned char *src, int sw, int sh, int dw, int dh);
|
2003-04-22 07:32:50 +00:00
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
#define fourcc_YUY2 GST_MAKE_FOURCC('Y','U','Y','2')
|
|
|
|
#define fourcc_UYVY GST_MAKE_FOURCC('U','Y','V','Y')
|
|
|
|
#define fourcc_Y422 GST_MAKE_FOURCC('Y','4','2','2')
|
|
|
|
#define fourcc_UYNV GST_MAKE_FOURCC('U','Y','N','V')
|
|
|
|
#define fourcc_YVYU GST_MAKE_FOURCC('Y','V','Y','U')
|
|
|
|
#define fourcc_YV12 GST_MAKE_FOURCC('Y','V','1','2')
|
|
|
|
#define fourcc_I420 GST_MAKE_FOURCC('I','4','2','0')
|
|
|
|
#define fourcc_Y800 GST_MAKE_FOURCC('Y','8','0','0')
|
|
|
|
#define fourcc_RGB_ GST_MAKE_FOURCC('R','G','B',' ')
|
|
|
|
|
2003-04-22 07:32:50 +00:00
|
|
|
struct videoscale_format_struct videoscale_formats[] = {
|
2004-03-14 22:34:34 +00:00
|
|
|
/* packed */
|
|
|
|
{fourcc_YUY2, 16, gst_videoscale_packed422,},
|
|
|
|
{fourcc_UYVY, 16, gst_videoscale_packed422rev,},
|
|
|
|
{fourcc_Y422, 16, gst_videoscale_packed422rev,},
|
|
|
|
{fourcc_UYNV, 16, gst_videoscale_packed422rev,},
|
|
|
|
{fourcc_YVYU, 16, gst_videoscale_packed422,},
|
|
|
|
/* planar */
|
|
|
|
{fourcc_YV12, 12, gst_videoscale_planar411,},
|
|
|
|
{fourcc_I420, 12, gst_videoscale_planar411,},
|
|
|
|
{fourcc_Y800, 8, gst_videoscale_planar400,},
|
|
|
|
/* RGB */
|
|
|
|
{fourcc_RGB_, 32, gst_videoscale_32bit, 24, G_BIG_ENDIAN, 0x00ff0000,
|
|
|
|
0x0000ff00, 0x000000ff},
|
|
|
|
{fourcc_RGB_, 32, gst_videoscale_32bit, 24, G_BIG_ENDIAN, 0x000000ff,
|
|
|
|
0x0000ff00, 0x00ff0000},
|
|
|
|
{fourcc_RGB_, 32, gst_videoscale_32bit, 24, G_BIG_ENDIAN, 0xff000000,
|
|
|
|
0x00ff0000, 0x0000ff00},
|
|
|
|
{fourcc_RGB_, 32, gst_videoscale_32bit, 24, G_BIG_ENDIAN, 0x0000ff00,
|
|
|
|
0x00ff0000, 0xff000000},
|
|
|
|
{fourcc_RGB_, 24, gst_videoscale_24bit, 24, G_BIG_ENDIAN, 0xff0000, 0x00ff00,
|
|
|
|
0x0000ff},
|
|
|
|
{fourcc_RGB_, 24, gst_videoscale_24bit, 24, G_BIG_ENDIAN, 0x0000ff, 0x00ff00,
|
|
|
|
0xff0000},
|
|
|
|
{fourcc_RGB_, 16, gst_videoscale_16bit, 16, G_BYTE_ORDER, 0xf800, 0x07e0,
|
|
|
|
0x001f},
|
|
|
|
{fourcc_RGB_, 16, gst_videoscale_16bit, 15, G_BYTE_ORDER, 0x7c00, 0x03e0,
|
|
|
|
0x001f},
|
2003-04-22 07:32:50 +00:00
|
|
|
};
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
int videoscale_n_formats =
|
|
|
|
sizeof (videoscale_formats) / sizeof (videoscale_formats[0]);
|
2003-04-22 07:32:50 +00:00
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
GstStructure *
|
|
|
|
videoscale_get_structure (struct videoscale_format_struct *format)
|
2003-04-22 07:32:50 +00:00
|
|
|
{
|
2003-12-22 01:47:09 +00:00
|
|
|
GstStructure *structure;
|
2003-04-22 07:32:50 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
if (format->scale == NULL)
|
2003-04-22 07:32:50 +00:00
|
|
|
return NULL;
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
if (format->depth) {
|
2003-12-22 01:47:09 +00:00
|
|
|
structure = gst_structure_new ("video/x-raw-rgb",
|
2004-03-15 19:32:28 +00:00
|
|
|
"depth", G_TYPE_INT, format->depth,
|
|
|
|
"bpp", G_TYPE_INT, format->bpp,
|
|
|
|
"endianness", G_TYPE_INT, format->endianness,
|
|
|
|
"red_mask", G_TYPE_INT, format->red_mask,
|
|
|
|
"green_mask", G_TYPE_INT, format->green_mask,
|
|
|
|
"blue_mask", G_TYPE_INT, format->blue_mask, NULL);
|
2004-03-14 22:34:34 +00:00
|
|
|
} else {
|
2003-12-22 01:47:09 +00:00
|
|
|
structure = gst_structure_new ("video/x-raw-yuv",
|
2004-03-15 19:32:28 +00:00
|
|
|
"format", GST_TYPE_FOURCC, format->fourcc, NULL);
|
2003-04-22 07:32:50 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_structure_set (structure,
|
2003-12-31 08:02:04 +00:00
|
|
|
"width", GST_TYPE_INT_RANGE, 100, G_MAXINT,
|
|
|
|
"height", GST_TYPE_INT_RANGE, 100, G_MAXINT,
|
2004-03-14 22:34:34 +00:00
|
|
|
"framerate", GST_TYPE_DOUBLE_RANGE, 0.0, G_MAXDOUBLE, NULL);
|
2003-12-22 01:47:09 +00:00
|
|
|
|
|
|
|
return structure;
|
2003-04-22 07:32:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct videoscale_format_struct *
|
2004-03-14 22:34:34 +00:00
|
|
|
videoscale_find_by_structure (GstStructure * structure)
|
2003-04-22 07:32:50 +00:00
|
|
|
{
|
|
|
|
int i;
|
2003-12-22 01:47:09 +00:00
|
|
|
gboolean ret;
|
|
|
|
struct videoscale_format_struct *format;
|
2003-04-22 07:32:50 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
GST_DEBUG ("finding %s", gst_structure_to_string (structure));
|
2003-04-22 07:32:50 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
g_return_val_if_fail (structure != NULL, NULL);
|
2003-04-22 07:32:50 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
if (strcmp (gst_structure_get_name (structure), "video/x-raw-yuv") == 0) {
|
2003-12-22 01:47:09 +00:00
|
|
|
unsigned int fourcc;
|
2003-04-22 07:32:50 +00:00
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
ret = gst_structure_get_fourcc (structure, "format", &fourcc);
|
2004-03-14 22:34:34 +00:00
|
|
|
if (!ret)
|
|
|
|
return NULL;
|
|
|
|
for (i = 0; i < videoscale_n_formats; i++) {
|
2003-12-22 01:47:09 +00:00
|
|
|
format = videoscale_formats + i;
|
2004-03-14 22:34:34 +00:00
|
|
|
if (format->depth == 0 && format->fourcc == fourcc) {
|
2004-03-15 19:32:28 +00:00
|
|
|
return format;
|
2003-12-22 01:47:09 +00:00
|
|
|
}
|
|
|
|
}
|
2004-03-14 22:34:34 +00:00
|
|
|
} else {
|
2003-12-22 01:47:09 +00:00
|
|
|
int bpp;
|
|
|
|
int depth;
|
|
|
|
int endianness;
|
|
|
|
int red_mask;
|
|
|
|
int green_mask;
|
|
|
|
int blue_mask;
|
|
|
|
|
|
|
|
ret = gst_structure_get_int (structure, "bpp", &bpp);
|
|
|
|
ret &= gst_structure_get_int (structure, "depth", &depth);
|
|
|
|
ret &= gst_structure_get_int (structure, "endianness", &endianness);
|
|
|
|
ret &= gst_structure_get_int (structure, "red_mask", &red_mask);
|
|
|
|
ret &= gst_structure_get_int (structure, "green_mask", &green_mask);
|
|
|
|
ret &= gst_structure_get_int (structure, "blue_mask", &blue_mask);
|
2004-03-14 22:34:34 +00:00
|
|
|
if (!ret)
|
|
|
|
return NULL;
|
|
|
|
for (i = 0; i < videoscale_n_formats; i++) {
|
2003-12-22 01:47:09 +00:00
|
|
|
format = videoscale_formats + i;
|
2004-03-14 22:34:34 +00:00
|
|
|
if (format->bpp == bpp && format->depth == depth &&
|
2004-03-15 19:32:28 +00:00
|
|
|
format->endianness == endianness && format->red_mask == red_mask &&
|
|
|
|
format->green_mask == green_mask && format->blue_mask == blue_mask) {
|
|
|
|
return format;
|
2003-04-22 07:32:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2001-12-22 23:27:17 +00:00
|
|
|
void
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_videoscale_setup (GstVideoscale * videoscale)
|
2001-12-22 23:27:17 +00:00
|
|
|
{
|
2003-11-11 05:35:31 +00:00
|
|
|
g_return_if_fail (GST_IS_VIDEOSCALE (videoscale));
|
|
|
|
g_return_if_fail (videoscale->format != NULL);
|
|
|
|
|
2004-02-25 17:37:26 +00:00
|
|
|
GST_DEBUG_OBJECT (videoscale, "format=%p " GST_FOURCC_FORMAT
|
2004-03-14 22:34:34 +00:00
|
|
|
" from %dx%d to %dx%d",
|
|
|
|
videoscale->format,
|
|
|
|
GST_FOURCC_ARGS (videoscale->format->fourcc),
|
|
|
|
videoscale->from_width, videoscale->from_height,
|
|
|
|
videoscale->to_width, videoscale->to_height);
|
|
|
|
|
|
|
|
if (videoscale->to_width == 0 || videoscale->to_height == 0 ||
|
|
|
|
videoscale->from_width == 0 || videoscale->from_height == 0) {
|
2003-12-31 08:02:04 +00:00
|
|
|
g_critical ("bad sizes %dx%d %dx%d",
|
2004-03-15 19:32:28 +00:00
|
|
|
videoscale->from_width, videoscale->from_height,
|
|
|
|
videoscale->to_width, videoscale->to_height);
|
2003-04-22 07:32:50 +00:00
|
|
|
return;
|
2001-12-22 23:27:17 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
if (videoscale->to_width == videoscale->from_width &&
|
|
|
|
videoscale->to_height == videoscale->from_height) {
|
2004-02-25 17:37:26 +00:00
|
|
|
GST_DEBUG_OBJECT (videoscale, "using passthru");
|
2003-04-22 07:32:50 +00:00
|
|
|
videoscale->passthru = TRUE;
|
|
|
|
videoscale->inited = TRUE;
|
|
|
|
return;
|
2001-12-22 23:27:17 +00:00
|
|
|
}
|
|
|
|
|
2004-02-25 17:37:26 +00:00
|
|
|
GST_DEBUG_OBJECT (videoscale, "scaling method POINT_SAMPLE");
|
2003-04-22 07:32:50 +00:00
|
|
|
|
|
|
|
videoscale->from_buf_size = (videoscale->from_width * videoscale->from_height
|
2004-03-14 22:34:34 +00:00
|
|
|
* videoscale->format->bpp) / 8;
|
2003-04-22 07:32:50 +00:00
|
|
|
videoscale->to_buf_size = (videoscale->to_width * videoscale->to_height
|
2004-03-14 22:34:34 +00:00
|
|
|
* videoscale->format->bpp) / 8;
|
2003-04-22 07:32:50 +00:00
|
|
|
|
2003-11-11 05:35:31 +00:00
|
|
|
videoscale->passthru = FALSE;
|
2003-04-22 07:32:50 +00:00
|
|
|
videoscale->inited = TRUE;
|
2001-12-22 23:27:17 +00:00
|
|
|
}
|
|
|
|
|
2003-04-22 07:32:50 +00:00
|
|
|
#if 0
|
2001-12-22 23:27:17 +00:00
|
|
|
static void
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_videoscale_scale_rgb (GstVideoscale * scale, unsigned char *dest,
|
|
|
|
unsigned char *src)
|
2001-12-22 23:27:17 +00:00
|
|
|
{
|
2003-04-22 07:32:50 +00:00
|
|
|
int sw = scale->from_width;
|
|
|
|
int sh = scale->from_height;
|
|
|
|
int dw = scale->to_width;
|
|
|
|
int dh = scale->to_height;
|
2004-03-14 22:34:34 +00:00
|
|
|
|
2004-02-25 17:37:26 +00:00
|
|
|
GST_DEBUG_OBJECT (scale, "scaling RGB %dx%d to %dx%d", sw, sh, dw, dh);
|
2001-12-22 23:27:17 +00:00
|
|
|
|
|
|
|
switch (scale->scale_bytes) {
|
|
|
|
case 2:
|
2004-03-14 22:34:34 +00:00
|
|
|
dw = ((dw + 1) & ~1) << 1;
|
|
|
|
sw = sw << 1;
|
|
|
|
break;
|
2001-12-22 23:27:17 +00:00
|
|
|
case 4:
|
2004-03-14 22:34:34 +00:00
|
|
|
dw = ((dw + 2) & ~3) << 2;
|
|
|
|
sw = sw << 2;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2001-12-22 23:27:17 +00:00
|
|
|
}
|
|
|
|
|
2004-02-25 17:37:26 +00:00
|
|
|
GST_DEBUG_OBJECT (scale, "%p %p", src, dest);
|
2003-04-22 07:32:50 +00:00
|
|
|
//scale->scaler(scale, src, dest, sw, sh, dw, dh);
|
2001-12-22 23:27:17 +00:00
|
|
|
}
|
2003-04-22 07:32:50 +00:00
|
|
|
#endif
|
2001-12-22 23:27:17 +00:00
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_videoscale_planar411 (GstVideoscale * scale, unsigned char *dest,
|
|
|
|
unsigned char *src)
|
2001-12-22 23:27:17 +00:00
|
|
|
{
|
2003-04-22 07:32:50 +00:00
|
|
|
int sw = scale->from_width;
|
|
|
|
int sh = scale->from_height;
|
|
|
|
int dw = scale->to_width;
|
|
|
|
int dh = scale->to_height;
|
2001-12-22 23:27:17 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
GST_DEBUG_OBJECT (scale, "scaling planar 4:1:1 %dx%d to %dx%d", sw, sh, dw,
|
|
|
|
dh);
|
2001-12-22 23:27:17 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_videoscale_scale_nearest (scale, dest, src, sw, sh, dw, dh);
|
2001-12-22 23:27:17 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
src += sw * sh;
|
|
|
|
dest += dw * dh;
|
2001-12-22 23:27:17 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
dh = dh >> 1;
|
|
|
|
dw = dw >> 1;
|
|
|
|
sh = sh >> 1;
|
|
|
|
sw = sw >> 1;
|
2001-12-22 23:27:17 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_videoscale_scale_nearest (scale, dest, src, sw, sh, dw, dh);
|
2001-12-22 23:27:17 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
src += sw * sh;
|
|
|
|
dest += dw * dh;
|
2001-12-22 23:27:17 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_videoscale_scale_nearest (scale, dest, src, sw, sh, dw, dh);
|
2003-04-22 07:32:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_videoscale_planar400 (GstVideoscale * scale, unsigned char *dest,
|
|
|
|
unsigned char *src)
|
2003-04-22 07:32:50 +00:00
|
|
|
{
|
|
|
|
int sw = scale->from_width;
|
|
|
|
int sh = scale->from_height;
|
|
|
|
int dw = scale->to_width;
|
|
|
|
int dh = scale->to_height;
|
|
|
|
|
2004-02-25 17:37:26 +00:00
|
|
|
GST_DEBUG_OBJECT (scale, "scaling Y-only %dx%d to %dx%d", sw, sh, dw, dh);
|
2003-04-22 07:32:50 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_videoscale_scale_nearest (scale, dest, src, sw, sh, dw, dh);
|
2003-04-22 07:32:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_videoscale_packed422 (GstVideoscale * scale, unsigned char *dest,
|
|
|
|
unsigned char *src)
|
2003-04-22 07:32:50 +00:00
|
|
|
{
|
|
|
|
int sw = scale->from_width;
|
|
|
|
int sh = scale->from_height;
|
|
|
|
int dw = scale->to_width;
|
|
|
|
int dh = scale->to_height;
|
|
|
|
|
2004-02-25 17:37:26 +00:00
|
|
|
GST_DEBUG_OBJECT (scale, "scaling 4:2:2 %dx%d to %dx%d", sw, sh, dw, dh);
|
2003-04-22 07:32:50 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_videoscale_scale_nearest_str2 (scale, dest, src, sw, sh, dw, dh);
|
|
|
|
gst_videoscale_scale_nearest_str4 (scale, dest + 1, src + 1, sw / 2, sh,
|
|
|
|
dw / 2, dh);
|
|
|
|
gst_videoscale_scale_nearest_str4 (scale, dest + 3, src + 3, sw / 2, sh,
|
|
|
|
dw / 2, dh);
|
2003-04-22 07:32:50 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_videoscale_packed422rev (GstVideoscale * scale, unsigned char *dest,
|
|
|
|
unsigned char *src)
|
2003-04-22 07:32:50 +00:00
|
|
|
{
|
|
|
|
int sw = scale->from_width;
|
|
|
|
int sh = scale->from_height;
|
|
|
|
int dw = scale->to_width;
|
|
|
|
int dh = scale->to_height;
|
|
|
|
|
2004-02-25 17:37:26 +00:00
|
|
|
GST_DEBUG_OBJECT (scale, "scaling 4:2:2 %dx%d to %dx%d", sw, sh, dw, dh);
|
2003-04-22 07:32:50 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_videoscale_scale_nearest_str2 (scale, dest + 1, src, sw, sh, dw, dh);
|
|
|
|
gst_videoscale_scale_nearest_str4 (scale, dest, src + 1, sw / 2, sh, dw / 2,
|
|
|
|
dh);
|
|
|
|
gst_videoscale_scale_nearest_str4 (scale, dest + 2, src + 3, sw / 2, sh,
|
|
|
|
dw / 2, dh);
|
2003-04-22 07:32:50 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_videoscale_32bit (GstVideoscale * scale, unsigned char *dest,
|
|
|
|
unsigned char *src)
|
2003-04-22 07:32:50 +00:00
|
|
|
{
|
|
|
|
int sw = scale->from_width;
|
|
|
|
int sh = scale->from_height;
|
|
|
|
int dw = scale->to_width;
|
|
|
|
int dh = scale->to_height;
|
|
|
|
|
2004-02-25 17:37:26 +00:00
|
|
|
GST_DEBUG_OBJECT (scale, "scaling 32bit %dx%d to %dx%d", sw, sh, dw, dh);
|
2003-04-22 07:32:50 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_videoscale_scale_nearest_32bit (scale, dest, src, sw, sh, dw, dh);
|
2003-04-22 07:32:50 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_videoscale_24bit (GstVideoscale * scale, unsigned char *dest,
|
|
|
|
unsigned char *src)
|
2003-04-22 07:32:50 +00:00
|
|
|
{
|
|
|
|
int sw = scale->from_width;
|
|
|
|
int sh = scale->from_height;
|
|
|
|
int dw = scale->to_width;
|
|
|
|
int dh = scale->to_height;
|
|
|
|
|
2004-02-25 17:37:26 +00:00
|
|
|
GST_DEBUG_OBJECT (scale, "scaling 24bit %dx%d to %dx%d", sw, sh, dw, dh);
|
2003-04-22 07:32:50 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_videoscale_scale_nearest_24bit (scale, dest, src, sw, sh, dw, dh);
|
2003-04-22 07:32:50 +00:00
|
|
|
|
2001-12-22 23:27:17 +00:00
|
|
|
}
|
|
|
|
|
2003-04-22 07:39:34 +00:00
|
|
|
static void
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_videoscale_16bit (GstVideoscale * scale, unsigned char *dest,
|
|
|
|
unsigned char *src)
|
2003-04-22 07:39:34 +00:00
|
|
|
{
|
|
|
|
int sw = scale->from_width;
|
|
|
|
int sh = scale->from_height;
|
|
|
|
int dw = scale->to_width;
|
|
|
|
int dh = scale->to_height;
|
|
|
|
|
2004-02-25 17:37:26 +00:00
|
|
|
GST_DEBUG_OBJECT (scale, "scaling 16bit %dx%d to %dx%d", sw, sh, dw, dh);
|
2003-04-22 07:39:34 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_videoscale_scale_nearest_16bit (scale, dest, src, sw, sh, dw, dh);
|
2003-04-22 07:39:34 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2003-05-02 20:36:55 +00:00
|
|
|
#if 0
|
2001-12-22 23:27:17 +00:00
|
|
|
#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)
|
|
|
|
{
|
2004-03-14 22:34:34 +00:00
|
|
|
int j = floor (x);
|
|
|
|
int k = floor (y);
|
|
|
|
double a = x - j;
|
|
|
|
double b = y - k;
|
2001-12-22 23:27:17 +00:00
|
|
|
double dest;
|
|
|
|
int color;
|
|
|
|
|
2004-02-25 17:37:26 +00:00
|
|
|
GST_DEBUG_OBJECT (scale, "scaling bilinear %f %f %dx%d", x, y, sw, sh);
|
2001-12-22 23:27:17 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
dest = (1 - a) * (1 - b) * RC (j, k) + a * (1 - b) * RC (j + 1, k);
|
2001-12-22 23:27:17 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
k = MIN (sh - 1, k);
|
|
|
|
dest += b * (1 - a) * RC (j, k + 1) + a * b * RC (j + 1, k + 1);
|
2001-12-22 23:27:17 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
color = rint (dest);
|
|
|
|
if (color < 0)
|
2004-03-15 19:32:28 +00:00
|
|
|
color = abs (color); /* cannot have negative values ! */
|
2002-03-19 04:10:06 +00:00
|
|
|
/*if (color<0) color=0; // cannot have negative values ! */
|
2004-03-14 22:34:34 +00:00
|
|
|
if (color > 255)
|
|
|
|
color = 255;
|
2001-12-22 23:27:17 +00:00
|
|
|
|
|
|
|
return (unsigned char) color;
|
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned char
|
|
|
|
gst_videoscale_bicubic (unsigned char *src, double x, double y, int sw, int sh)
|
|
|
|
{
|
2004-03-14 22:34:34 +00:00
|
|
|
int j = floor (x);
|
|
|
|
int k = floor (y), k2;
|
|
|
|
double a = x - j;
|
|
|
|
double b = y - k;
|
2001-12-22 23:27:17 +00:00
|
|
|
double dest;
|
|
|
|
int color;
|
|
|
|
double t1, t2, t3, t4;
|
|
|
|
double a1, a2, a3, a4;
|
|
|
|
|
2004-02-25 17:37:26 +00:00
|
|
|
GST_DEBUG_OBJECT (scale, "scaling bicubic %dx%d", sw, sh);
|
2001-12-22 23:27:17 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
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)
|
2004-03-15 19:32:28 +00:00
|
|
|
color = abs (color); /* cannot have negative values ! */
|
2004-03-14 22:34:34 +00:00
|
|
|
if (color > 255)
|
|
|
|
color = 255;
|
2001-12-22 23:27:17 +00:00
|
|
|
|
|
|
|
return (unsigned char) color;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_videoscale_scale_plane_slow (GstVideoscale * scale, unsigned char *src,
|
|
|
|
unsigned char *dest, int sw, int sh, int dw, int dh)
|
2001-12-22 23:27:17 +00:00
|
|
|
{
|
2004-03-14 22:34:34 +00:00
|
|
|
double zoomx = ((double) dw) / (double) sw;
|
|
|
|
double zoomy = ((double) dh) / (double) sh;
|
2001-12-22 23:27:17 +00:00
|
|
|
double xr, yr;
|
|
|
|
int x, y;
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
GST_DEBUG_OBJECT (scale, "scale plane slow %dx%d %dx%d %g %g %p %p", sw, sh,
|
|
|
|
dw, dh, zoomx, zoomy, src, dest);
|
2001-12-22 23:27:17 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
for (y = 0; y < dh; y++) {
|
|
|
|
yr = ((double) y) / zoomy;
|
|
|
|
for (x = 0; x < dw; x++) {
|
|
|
|
xr = ((double) x) / zoomx;
|
2001-12-22 23:27:17 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
GST_DEBUG_OBJECT (scale, "scale plane slow %g %g %p", xr, yr,
|
2004-03-15 19:32:28 +00:00
|
|
|
(src + (int) (x) + (int) ((y) * sw)));
|
2001-12-22 23:27:17 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
if (floor (xr) == xr && floor (yr) == yr) {
|
2004-03-15 19:32:28 +00:00
|
|
|
GST_DEBUG_OBJECT (scale, "scale plane %g %g %p %p", xr, yr,
|
|
|
|
(src + (int) (x) + (int) ((y) * sw)), dest);
|
|
|
|
*dest++ = RC (xr, yr);
|
2004-03-14 22:34:34 +00:00
|
|
|
} else {
|
2004-03-15 19:32:28 +00:00
|
|
|
*dest++ = scale->filter (src, xr, yr, sw, sh);
|
|
|
|
/**dest++ = gst_videoscale_bicubic(src, xr, yr, sw, sh); */
|
2001-12-22 23:27:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-04-22 07:32:50 +00:00
|
|
|
#endif
|
2001-12-22 23:27:17 +00:00
|
|
|
|
2003-04-22 07:32:50 +00:00
|
|
|
#if 0
|
2001-12-22 23:27:17 +00:00
|
|
|
static void
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_videoscale_scale_point_sample (GstVideoscale * scale, unsigned char *src,
|
|
|
|
unsigned char *dest, int sw, int sh, int dw, int dh)
|
2001-12-22 23:27:17 +00:00
|
|
|
{
|
|
|
|
int ypos, yinc, y;
|
|
|
|
int xpos, xinc, x;
|
|
|
|
int sum, xcount, ycount, loop;
|
|
|
|
unsigned char *srcp, *srcp2;
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
GST_DEBUG_OBJECT (scale, "scaling nearest point sample %p %p %d", src, dest,
|
|
|
|
dw);
|
2001-12-22 23:27:17 +00:00
|
|
|
|
|
|
|
ypos = 0x10000;
|
2004-03-14 22:34:34 +00:00
|
|
|
yinc = (sh << 16) / dh;
|
|
|
|
xinc = (sw << 16) / dw;
|
2001-12-22 23:27:17 +00:00
|
|
|
|
|
|
|
for (y = dh; y; y--) {
|
|
|
|
|
|
|
|
ycount = 1;
|
|
|
|
srcp = src;
|
2004-03-14 22:34:34 +00:00
|
|
|
while (ypos > 0x10000) {
|
2001-12-22 23:27:17 +00:00
|
|
|
ycount++;
|
2004-03-14 22:34:34 +00:00
|
|
|
ypos -= 0x10000;
|
2001-12-22 23:27:17 +00:00
|
|
|
src += sw;
|
|
|
|
}
|
|
|
|
|
|
|
|
xpos = 0x10000;
|
2004-03-14 22:34:34 +00:00
|
|
|
for (x = dw; x; x--) {
|
2001-12-22 23:27:17 +00:00
|
|
|
xcount = 0;
|
2004-03-14 22:34:34 +00:00
|
|
|
sum = 0;
|
|
|
|
while (xpos >= 0x10000L) {
|
2004-03-15 19:32:28 +00:00
|
|
|
loop = ycount;
|
|
|
|
srcp2 = srcp;
|
|
|
|
while (loop--) {
|
|
|
|
sum += *srcp2;
|
|
|
|
srcp2 += sw;
|
|
|
|
}
|
|
|
|
srcp++;
|
|
|
|
xcount++;
|
|
|
|
xpos -= 0x10000L;
|
2001-12-22 23:27:17 +00:00
|
|
|
}
|
2004-03-14 22:34:34 +00:00
|
|
|
*dest++ = sum / (xcount * ycount);
|
2001-12-22 23:27:17 +00:00
|
|
|
xpos += xinc;
|
|
|
|
}
|
|
|
|
|
|
|
|
ypos += yinc;
|
|
|
|
}
|
|
|
|
}
|
2003-04-22 07:32:50 +00:00
|
|
|
#endif
|
2001-12-22 23:27:17 +00:00
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_videoscale_scale_nearest (GstVideoscale * scale,
|
|
|
|
unsigned char *dest, unsigned char *src, int sw, int sh, int dw, int dh)
|
2001-12-22 23:27:17 +00:00
|
|
|
{
|
|
|
|
int ypos, yinc, y;
|
|
|
|
int xpos, xinc, x;
|
2003-04-22 07:32:50 +00:00
|
|
|
guchar *destp = dest;
|
|
|
|
guchar *srcp = src;
|
2001-12-22 23:27:17 +00:00
|
|
|
|
2004-02-25 17:37:26 +00:00
|
|
|
GST_DEBUG_OBJECT (scale, "scaling nearest %p %p %d", src, dest, dw);
|
2001-12-22 23:27:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
ypos = 0x10000;
|
2004-03-14 22:34:34 +00:00
|
|
|
yinc = (sh << 16) / dh;
|
|
|
|
xinc = (sw << 16) / dw;
|
2001-12-22 23:27:17 +00:00
|
|
|
|
|
|
|
for (y = dh; y; y--) {
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
while (ypos > 0x10000) {
|
|
|
|
ypos -= 0x10000;
|
2001-12-22 23:27:17 +00:00
|
|
|
src += sw;
|
|
|
|
}
|
|
|
|
|
|
|
|
xpos = 0x10000;
|
|
|
|
|
2003-04-22 07:32:50 +00:00
|
|
|
srcp = src;
|
|
|
|
destp = dest;
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
for (x = dw; x; x--) {
|
|
|
|
while (xpos >= 0x10000L) {
|
2004-03-15 19:32:28 +00:00
|
|
|
srcp++;
|
|
|
|
xpos -= 0x10000L;
|
2001-12-22 23:27:17 +00:00
|
|
|
}
|
2003-04-22 07:32:50 +00:00
|
|
|
*destp++ = *srcp;
|
|
|
|
xpos += xinc;
|
|
|
|
}
|
|
|
|
dest += dw;
|
|
|
|
|
|
|
|
ypos += yinc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_videoscale_scale_nearest_str2 (GstVideoscale * scale,
|
|
|
|
unsigned char *dest, unsigned char *src, int sw, int sh, int dw, int dh)
|
2003-04-22 07:32:50 +00:00
|
|
|
{
|
|
|
|
int ypos, yinc, y;
|
|
|
|
int xpos, xinc, x;
|
|
|
|
guchar *destp = dest;
|
|
|
|
guchar *srcp = src;
|
|
|
|
|
2004-02-25 17:37:26 +00:00
|
|
|
GST_DEBUG_OBJECT (scale, "scaling nearest %p %p %d", src, dest, dw);
|
2003-04-22 07:32:50 +00:00
|
|
|
|
|
|
|
|
|
|
|
ypos = 0x10000;
|
2004-03-14 22:34:34 +00:00
|
|
|
yinc = (sh << 16) / dh;
|
|
|
|
xinc = (sw << 16) / dw;
|
2003-04-22 07:32:50 +00:00
|
|
|
|
|
|
|
for (y = dh; y; y--) {
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
while (ypos > 0x10000) {
|
|
|
|
ypos -= 0x10000;
|
|
|
|
src += sw * 2;
|
2003-04-22 07:32:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
xpos = 0x10000;
|
|
|
|
|
|
|
|
srcp = src;
|
|
|
|
destp = dest;
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
for (x = dw; x; x--) {
|
|
|
|
while (xpos >= 0x10000L) {
|
2004-03-15 19:32:28 +00:00
|
|
|
srcp += 2;
|
|
|
|
xpos -= 0x10000L;
|
2001-12-22 23:27:17 +00:00
|
|
|
}
|
2003-04-22 07:32:50 +00:00
|
|
|
*destp = *srcp;
|
2004-03-14 22:34:34 +00:00
|
|
|
destp += 2;
|
2003-04-22 07:32:50 +00:00
|
|
|
xpos += xinc;
|
|
|
|
}
|
2004-03-14 22:34:34 +00:00
|
|
|
dest += dw * 2;
|
2003-04-22 07:32:50 +00:00
|
|
|
|
|
|
|
ypos += yinc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_videoscale_scale_nearest_str4 (GstVideoscale * scale,
|
|
|
|
unsigned char *dest, unsigned char *src, int sw, int sh, int dw, int dh)
|
2003-04-22 07:32:50 +00:00
|
|
|
{
|
|
|
|
int ypos, yinc, y;
|
|
|
|
int xpos, xinc, x;
|
|
|
|
guchar *destp = dest;
|
|
|
|
guchar *srcp = src;
|
|
|
|
|
2004-02-25 17:37:26 +00:00
|
|
|
GST_DEBUG_OBJECT (scale, "scaling nearest %p %p %d", src, dest, dw);
|
2003-04-22 07:32:50 +00:00
|
|
|
|
|
|
|
|
|
|
|
ypos = 0x10000;
|
2004-03-14 22:34:34 +00:00
|
|
|
yinc = (sh << 16) / dh;
|
|
|
|
xinc = (sw << 16) / dw;
|
2003-04-22 07:32:50 +00:00
|
|
|
|
|
|
|
for (y = dh; y; y--) {
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
while (ypos > 0x10000) {
|
|
|
|
ypos -= 0x10000;
|
|
|
|
src += sw * 4;
|
2003-04-22 07:32:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
xpos = 0x10000;
|
|
|
|
|
|
|
|
srcp = src;
|
|
|
|
destp = dest;
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
for (x = dw; x; x--) {
|
|
|
|
while (xpos >= 0x10000L) {
|
2004-03-15 19:32:28 +00:00
|
|
|
srcp += 4;
|
|
|
|
xpos -= 0x10000L;
|
2001-12-22 23:27:17 +00:00
|
|
|
}
|
2003-04-22 07:32:50 +00:00
|
|
|
*destp = *srcp;
|
2004-03-14 22:34:34 +00:00
|
|
|
destp += 4;
|
2003-04-22 07:32:50 +00:00
|
|
|
xpos += xinc;
|
2001-12-22 23:27:17 +00:00
|
|
|
}
|
2004-03-14 22:34:34 +00:00
|
|
|
dest += dw * 4;
|
2003-04-22 07:32:50 +00:00
|
|
|
|
|
|
|
ypos += yinc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_videoscale_scale_nearest_32bit (GstVideoscale * scale,
|
|
|
|
unsigned char *dest, unsigned char *src, int sw, int sh, int dw, int dh)
|
2003-04-22 07:32:50 +00:00
|
|
|
{
|
|
|
|
int ypos, yinc, y;
|
|
|
|
int xpos, xinc, x;
|
|
|
|
guchar *destp = dest;
|
|
|
|
guchar *srcp = src;
|
|
|
|
|
2004-02-25 17:37:26 +00:00
|
|
|
GST_DEBUG_OBJECT (scale, "scaling nearest %p %p %d", src, dest, dw);
|
2003-04-22 07:32:50 +00:00
|
|
|
|
|
|
|
|
|
|
|
ypos = 0x10000;
|
2004-03-14 22:34:34 +00:00
|
|
|
yinc = (sh << 16) / dh;
|
|
|
|
xinc = (sw << 16) / dw;
|
2003-04-22 07:32:50 +00:00
|
|
|
|
|
|
|
for (y = dh; y; y--) {
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
while (ypos > 0x10000) {
|
|
|
|
ypos -= 0x10000;
|
|
|
|
src += sw * 4;
|
2003-04-22 07:32:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
xpos = 0x10000;
|
|
|
|
|
|
|
|
srcp = src;
|
|
|
|
destp = dest;
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
for (x = dw; x; x--) {
|
|
|
|
while (xpos >= 0x10000L) {
|
2004-03-15 19:32:28 +00:00
|
|
|
srcp += 4;
|
|
|
|
xpos -= 0x10000L;
|
2003-04-22 07:32:50 +00:00
|
|
|
}
|
2004-03-14 22:34:34 +00:00
|
|
|
*(guint32 *) destp = *(guint32 *) srcp;
|
|
|
|
destp += 4;
|
2003-04-22 07:32:50 +00:00
|
|
|
xpos += xinc;
|
|
|
|
}
|
2004-03-14 22:34:34 +00:00
|
|
|
dest += dw * 4;
|
2003-04-22 07:32:50 +00:00
|
|
|
|
|
|
|
ypos += yinc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_videoscale_scale_nearest_24bit (GstVideoscale * scale,
|
|
|
|
unsigned char *dest, unsigned char *src, int sw, int sh, int dw, int dh)
|
2003-04-22 07:32:50 +00:00
|
|
|
{
|
|
|
|
int ypos, yinc, y;
|
|
|
|
int xpos, xinc, x;
|
|
|
|
guchar *destp = dest;
|
|
|
|
guchar *srcp = src;
|
|
|
|
|
2004-02-25 17:37:26 +00:00
|
|
|
GST_DEBUG_OBJECT (scale, "scaling nearest %p %p %d", src, dest, dw);
|
2003-04-22 07:32:50 +00:00
|
|
|
|
|
|
|
|
|
|
|
ypos = 0x10000;
|
2004-03-14 22:34:34 +00:00
|
|
|
yinc = (sh << 16) / dh;
|
|
|
|
xinc = (sw << 16) / dw;
|
2003-04-22 07:32:50 +00:00
|
|
|
|
|
|
|
for (y = dh; y; y--) {
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
while (ypos > 0x10000) {
|
|
|
|
ypos -= 0x10000;
|
|
|
|
src += sw * 3;
|
2003-04-22 07:32:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
xpos = 0x10000;
|
|
|
|
|
|
|
|
srcp = src;
|
|
|
|
destp = dest;
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
for (x = dw; x; x--) {
|
|
|
|
while (xpos >= 0x10000L) {
|
2004-03-15 19:32:28 +00:00
|
|
|
srcp += 3;
|
|
|
|
xpos -= 0x10000L;
|
2003-04-22 07:32:50 +00:00
|
|
|
}
|
|
|
|
destp[0] = srcp[0];
|
|
|
|
destp[1] = srcp[1];
|
|
|
|
destp[2] = srcp[2];
|
2004-03-14 22:34:34 +00:00
|
|
|
destp += 3;
|
2003-04-22 07:32:50 +00:00
|
|
|
xpos += xinc;
|
|
|
|
}
|
2004-03-14 22:34:34 +00:00
|
|
|
dest += dw * 3;
|
2001-12-22 23:27:17 +00:00
|
|
|
|
|
|
|
ypos += yinc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-04-22 07:39:34 +00:00
|
|
|
static void
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_videoscale_scale_nearest_16bit (GstVideoscale * scale,
|
|
|
|
unsigned char *dest, unsigned char *src, int sw, int sh, int dw, int dh)
|
2003-04-22 07:39:34 +00:00
|
|
|
{
|
|
|
|
int ypos, yinc, y;
|
|
|
|
int xpos, xinc, x;
|
|
|
|
guchar *destp = dest;
|
|
|
|
guchar *srcp = src;
|
|
|
|
|
2004-02-25 17:37:26 +00:00
|
|
|
GST_DEBUG_OBJECT (scale, "scaling nearest %p %p %d", src, dest, dw);
|
2003-04-22 07:39:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
ypos = 0x10000;
|
2004-03-14 22:34:34 +00:00
|
|
|
yinc = (sh << 16) / dh;
|
|
|
|
xinc = (sw << 16) / dw;
|
2003-04-22 07:39:34 +00:00
|
|
|
|
|
|
|
for (y = dh; y; y--) {
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
while (ypos > 0x10000) {
|
|
|
|
ypos -= 0x10000;
|
|
|
|
src += sw * 2;
|
2003-04-22 07:39:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
xpos = 0x10000;
|
|
|
|
|
|
|
|
srcp = src;
|
|
|
|
destp = dest;
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
for (x = dw; x; x--) {
|
|
|
|
while (xpos >= 0x10000L) {
|
2004-03-15 19:32:28 +00:00
|
|
|
srcp += 2;
|
|
|
|
xpos -= 0x10000L;
|
2003-04-22 07:39:34 +00:00
|
|
|
}
|
|
|
|
destp[0] = srcp[0];
|
|
|
|
destp[1] = srcp[1];
|
2004-03-14 22:34:34 +00:00
|
|
|
destp += 2;
|
2003-04-22 07:39:34 +00:00
|
|
|
xpos += xinc;
|
|
|
|
}
|
2004-03-14 22:34:34 +00:00
|
|
|
dest += dw * 2;
|
2003-04-22 07:39:34 +00:00
|
|
|
|
|
|
|
ypos += yinc;
|
|
|
|
}
|
|
|
|
}
|