2005-07-01 16:55:43 +00:00
|
|
|
/*
|
|
|
|
* Image Scaling Functions
|
2012-01-30 16:21:54 +00:00
|
|
|
* Copyright (c) 2005-2012 David A. Schleef <ds@schleef.org>
|
2005-07-01 16:55:43 +00:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
|
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
|
|
|
|
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
|
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
|
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
|
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
|
|
|
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "vs_scanline.h"
|
|
|
|
#include "vs_image.h"
|
|
|
|
|
2010-06-14 22:42:09 +00:00
|
|
|
#include "gstvideoscaleorc.h"
|
|
|
|
#include <gst/gst.h>
|
|
|
|
|
2005-07-01 16:55:43 +00:00
|
|
|
#define ROUND_UP_2(x) (((x)+1)&~1)
|
|
|
|
#define ROUND_UP_4(x) (((x)+3)&~3)
|
|
|
|
#define ROUND_UP_8(x) (((x)+7)&~7)
|
|
|
|
|
|
|
|
void
|
|
|
|
vs_image_scale_nearest_RGBA (const VSImage * dest, const VSImage * src,
|
2006-11-14 23:08:38 +00:00
|
|
|
uint8_t * tmpbuf)
|
2005-07-01 16:55:43 +00:00
|
|
|
{
|
|
|
|
int acc;
|
|
|
|
int y_increment;
|
|
|
|
int x_increment;
|
|
|
|
int i;
|
|
|
|
int j;
|
2010-06-14 22:42:09 +00:00
|
|
|
int prev_j;
|
2005-07-01 16:55:43 +00:00
|
|
|
|
gst/videoscale/: Support 1x1 images as input and output as for example the BBC HQ new streams have 1x1 GIFs in the pl...
Original commit message from CVS:
* gst/videoscale/gstvideoscale.c:
* gst/videoscale/vs_4tap.c: (vs_image_scale_4tap_Y):
* gst/videoscale/vs_image.c: (vs_image_scale_nearest_RGBA),
(vs_image_scale_linear_RGBA), (vs_image_scale_nearest_RGB),
(vs_image_scale_linear_RGB), (vs_image_scale_nearest_YUYV),
(vs_image_scale_linear_YUYV), (vs_image_scale_nearest_UYVY),
(vs_image_scale_linear_UYVY), (vs_image_scale_nearest_Y),
(vs_image_scale_linear_Y), (vs_image_scale_nearest_RGB565),
(vs_image_scale_linear_RGB565), (vs_image_scale_nearest_RGB555),
(vs_image_scale_linear_RGB555):
Support 1x1 images as input and output as for example the BBC HQ new
streams have 1x1 GIFs in the playlists for some reason.
2008-05-02 10:02:05 +00:00
|
|
|
if (dest->height == 1)
|
|
|
|
y_increment = 0;
|
|
|
|
else
|
|
|
|
y_increment = ((src->height - 1) << 16) / (dest->height - 1);
|
|
|
|
|
|
|
|
if (dest->width == 1)
|
|
|
|
x_increment = 0;
|
|
|
|
else
|
|
|
|
x_increment = ((src->width - 1) << 16) / (dest->width - 1);
|
|
|
|
|
2005-07-01 16:55:43 +00:00
|
|
|
|
|
|
|
acc = 0;
|
2010-06-14 22:42:09 +00:00
|
|
|
prev_j = -1;
|
2005-07-01 16:55:43 +00:00
|
|
|
for (i = 0; i < dest->height; i++) {
|
|
|
|
j = acc >> 16;
|
|
|
|
|
2010-06-14 22:42:09 +00:00
|
|
|
if (j == prev_j) {
|
|
|
|
memcpy (dest->pixels + i * dest->stride,
|
|
|
|
dest->pixels + (i - 1) * dest->stride, dest->width * 4);
|
|
|
|
} else {
|
|
|
|
gst_videoscale_orc_resample_nearest_u32 (dest->pixels + i * dest->stride,
|
|
|
|
src->pixels + j * src->stride, 0, x_increment, dest->width);
|
|
|
|
}
|
2005-07-01 16:55:43 +00:00
|
|
|
|
2010-06-14 22:42:09 +00:00
|
|
|
prev_j = j;
|
2005-07-01 16:55:43 +00:00
|
|
|
acc += y_increment;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
vs_image_scale_linear_RGBA (const VSImage * dest, const VSImage * src,
|
2006-11-14 23:08:38 +00:00
|
|
|
uint8_t * tmpbuf)
|
2005-07-01 16:55:43 +00:00
|
|
|
{
|
|
|
|
int acc;
|
|
|
|
int y_increment;
|
|
|
|
int x_increment;
|
|
|
|
int y1;
|
|
|
|
int i;
|
|
|
|
int j;
|
|
|
|
int x;
|
|
|
|
int dest_size;
|
|
|
|
|
gst/videoscale/: Support 1x1 images as input and output as for example the BBC HQ new streams have 1x1 GIFs in the pl...
Original commit message from CVS:
* gst/videoscale/gstvideoscale.c:
* gst/videoscale/vs_4tap.c: (vs_image_scale_4tap_Y):
* gst/videoscale/vs_image.c: (vs_image_scale_nearest_RGBA),
(vs_image_scale_linear_RGBA), (vs_image_scale_nearest_RGB),
(vs_image_scale_linear_RGB), (vs_image_scale_nearest_YUYV),
(vs_image_scale_linear_YUYV), (vs_image_scale_nearest_UYVY),
(vs_image_scale_linear_UYVY), (vs_image_scale_nearest_Y),
(vs_image_scale_linear_Y), (vs_image_scale_nearest_RGB565),
(vs_image_scale_linear_RGB565), (vs_image_scale_nearest_RGB555),
(vs_image_scale_linear_RGB555):
Support 1x1 images as input and output as for example the BBC HQ new
streams have 1x1 GIFs in the playlists for some reason.
2008-05-02 10:02:05 +00:00
|
|
|
if (dest->height == 1)
|
|
|
|
y_increment = 0;
|
|
|
|
else
|
2011-04-23 20:42:23 +00:00
|
|
|
y_increment = ((src->height - 1) << 16) / (dest->height - 1) - 1;
|
gst/videoscale/: Support 1x1 images as input and output as for example the BBC HQ new streams have 1x1 GIFs in the pl...
Original commit message from CVS:
* gst/videoscale/gstvideoscale.c:
* gst/videoscale/vs_4tap.c: (vs_image_scale_4tap_Y):
* gst/videoscale/vs_image.c: (vs_image_scale_nearest_RGBA),
(vs_image_scale_linear_RGBA), (vs_image_scale_nearest_RGB),
(vs_image_scale_linear_RGB), (vs_image_scale_nearest_YUYV),
(vs_image_scale_linear_YUYV), (vs_image_scale_nearest_UYVY),
(vs_image_scale_linear_UYVY), (vs_image_scale_nearest_Y),
(vs_image_scale_linear_Y), (vs_image_scale_nearest_RGB565),
(vs_image_scale_linear_RGB565), (vs_image_scale_nearest_RGB555),
(vs_image_scale_linear_RGB555):
Support 1x1 images as input and output as for example the BBC HQ new
streams have 1x1 GIFs in the playlists for some reason.
2008-05-02 10:02:05 +00:00
|
|
|
|
|
|
|
if (dest->width == 1)
|
|
|
|
x_increment = 0;
|
|
|
|
else
|
2011-04-23 20:42:23 +00:00
|
|
|
x_increment = ((src->width - 1) << 16) / (dest->width - 1) - 1;
|
2005-07-01 16:55:43 +00:00
|
|
|
|
|
|
|
dest_size = dest->width * 4;
|
|
|
|
|
2010-06-14 22:42:09 +00:00
|
|
|
#define LINE(x) ((tmpbuf) + (dest_size)*((x)&1))
|
2005-07-01 16:55:43 +00:00
|
|
|
|
|
|
|
acc = 0;
|
2010-06-14 22:42:09 +00:00
|
|
|
gst_videoscale_orc_resample_bilinear_u32 (LINE (0), src->pixels,
|
|
|
|
0, x_increment, dest->width);
|
2005-07-01 16:55:43 +00:00
|
|
|
y1 = 0;
|
|
|
|
for (i = 0; i < dest->height; i++) {
|
|
|
|
j = acc >> 16;
|
|
|
|
x = acc & 0xffff;
|
|
|
|
|
|
|
|
if (x == 0) {
|
2010-06-14 22:42:09 +00:00
|
|
|
memcpy (dest->pixels + i * dest->stride, LINE (j), dest_size);
|
2005-07-01 16:55:43 +00:00
|
|
|
} else {
|
2010-06-14 22:42:09 +00:00
|
|
|
if (j > y1) {
|
|
|
|
gst_videoscale_orc_resample_bilinear_u32 (LINE (j),
|
|
|
|
src->pixels + j * src->stride, 0, x_increment, dest->width);
|
|
|
|
y1++;
|
|
|
|
}
|
|
|
|
if (j >= y1) {
|
2011-04-25 01:45:40 +00:00
|
|
|
gst_videoscale_orc_resample_bilinear_u32 (LINE (j + 1),
|
|
|
|
src->pixels + (j + 1) * src->stride, 0, x_increment, dest->width);
|
2010-06-14 22:42:09 +00:00
|
|
|
y1++;
|
2005-07-01 16:55:43 +00:00
|
|
|
}
|
2011-04-25 01:16:20 +00:00
|
|
|
orc_merge_linear_u8 (dest->pixels + i * dest->stride,
|
|
|
|
LINE (j), LINE (j + 1), (x >> 8), dest->width * 4);
|
2005-07-01 16:55:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
acc += y_increment;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
vs_image_scale_nearest_RGB (const VSImage * dest, const VSImage * src,
|
2006-11-14 23:08:38 +00:00
|
|
|
uint8_t * tmpbuf)
|
2005-07-01 16:55:43 +00:00
|
|
|
{
|
|
|
|
int acc;
|
|
|
|
int y_increment;
|
|
|
|
int x_increment;
|
|
|
|
int i;
|
|
|
|
int j;
|
|
|
|
int xacc;
|
|
|
|
|
gst/videoscale/: Support 1x1 images as input and output as for example the BBC HQ new streams have 1x1 GIFs in the pl...
Original commit message from CVS:
* gst/videoscale/gstvideoscale.c:
* gst/videoscale/vs_4tap.c: (vs_image_scale_4tap_Y):
* gst/videoscale/vs_image.c: (vs_image_scale_nearest_RGBA),
(vs_image_scale_linear_RGBA), (vs_image_scale_nearest_RGB),
(vs_image_scale_linear_RGB), (vs_image_scale_nearest_YUYV),
(vs_image_scale_linear_YUYV), (vs_image_scale_nearest_UYVY),
(vs_image_scale_linear_UYVY), (vs_image_scale_nearest_Y),
(vs_image_scale_linear_Y), (vs_image_scale_nearest_RGB565),
(vs_image_scale_linear_RGB565), (vs_image_scale_nearest_RGB555),
(vs_image_scale_linear_RGB555):
Support 1x1 images as input and output as for example the BBC HQ new
streams have 1x1 GIFs in the playlists for some reason.
2008-05-02 10:02:05 +00:00
|
|
|
if (dest->height == 1)
|
|
|
|
y_increment = 0;
|
|
|
|
else
|
|
|
|
y_increment = ((src->height - 1) << 16) / (dest->height - 1);
|
|
|
|
|
|
|
|
if (dest->width == 1)
|
|
|
|
x_increment = 0;
|
|
|
|
else
|
|
|
|
x_increment = ((src->width - 1) << 16) / (dest->width - 1);
|
2005-07-01 16:55:43 +00:00
|
|
|
|
|
|
|
acc = 0;
|
|
|
|
for (i = 0; i < dest->height; i++) {
|
|
|
|
j = acc >> 16;
|
|
|
|
|
|
|
|
xacc = 0;
|
|
|
|
vs_scanline_resample_nearest_RGB (dest->pixels + i * dest->stride,
|
2009-03-28 15:08:44 +00:00
|
|
|
src->pixels + j * src->stride, src->width, dest->width, &xacc,
|
|
|
|
x_increment);
|
2005-07-01 16:55:43 +00:00
|
|
|
|
|
|
|
acc += y_increment;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
vs_image_scale_linear_RGB (const VSImage * dest, const VSImage * src,
|
2006-11-14 23:08:38 +00:00
|
|
|
uint8_t * tmpbuf)
|
2005-07-01 16:55:43 +00:00
|
|
|
{
|
|
|
|
int acc;
|
|
|
|
int y_increment;
|
|
|
|
int x_increment;
|
2006-11-14 23:08:38 +00:00
|
|
|
uint8_t *tmp1;
|
|
|
|
uint8_t *tmp2;
|
2005-07-01 16:55:43 +00:00
|
|
|
int y1;
|
|
|
|
int y2;
|
|
|
|
int i;
|
|
|
|
int j;
|
|
|
|
int x;
|
|
|
|
int dest_size;
|
|
|
|
int xacc;
|
|
|
|
|
gst/videoscale/: Support 1x1 images as input and output as for example the BBC HQ new streams have 1x1 GIFs in the pl...
Original commit message from CVS:
* gst/videoscale/gstvideoscale.c:
* gst/videoscale/vs_4tap.c: (vs_image_scale_4tap_Y):
* gst/videoscale/vs_image.c: (vs_image_scale_nearest_RGBA),
(vs_image_scale_linear_RGBA), (vs_image_scale_nearest_RGB),
(vs_image_scale_linear_RGB), (vs_image_scale_nearest_YUYV),
(vs_image_scale_linear_YUYV), (vs_image_scale_nearest_UYVY),
(vs_image_scale_linear_UYVY), (vs_image_scale_nearest_Y),
(vs_image_scale_linear_Y), (vs_image_scale_nearest_RGB565),
(vs_image_scale_linear_RGB565), (vs_image_scale_nearest_RGB555),
(vs_image_scale_linear_RGB555):
Support 1x1 images as input and output as for example the BBC HQ new
streams have 1x1 GIFs in the playlists for some reason.
2008-05-02 10:02:05 +00:00
|
|
|
if (dest->height == 1)
|
|
|
|
y_increment = 0;
|
|
|
|
else
|
2011-04-23 20:42:23 +00:00
|
|
|
y_increment = ((src->height - 1) << 16) / (dest->height - 1) - 1;
|
gst/videoscale/: Support 1x1 images as input and output as for example the BBC HQ new streams have 1x1 GIFs in the pl...
Original commit message from CVS:
* gst/videoscale/gstvideoscale.c:
* gst/videoscale/vs_4tap.c: (vs_image_scale_4tap_Y):
* gst/videoscale/vs_image.c: (vs_image_scale_nearest_RGBA),
(vs_image_scale_linear_RGBA), (vs_image_scale_nearest_RGB),
(vs_image_scale_linear_RGB), (vs_image_scale_nearest_YUYV),
(vs_image_scale_linear_YUYV), (vs_image_scale_nearest_UYVY),
(vs_image_scale_linear_UYVY), (vs_image_scale_nearest_Y),
(vs_image_scale_linear_Y), (vs_image_scale_nearest_RGB565),
(vs_image_scale_linear_RGB565), (vs_image_scale_nearest_RGB555),
(vs_image_scale_linear_RGB555):
Support 1x1 images as input and output as for example the BBC HQ new
streams have 1x1 GIFs in the playlists for some reason.
2008-05-02 10:02:05 +00:00
|
|
|
|
|
|
|
if (dest->width == 1)
|
|
|
|
x_increment = 0;
|
|
|
|
else
|
2011-04-23 20:42:23 +00:00
|
|
|
x_increment = ((src->width - 1) << 16) / (dest->width - 1) - 1;
|
2005-07-01 16:55:43 +00:00
|
|
|
|
|
|
|
dest_size = dest->width * 3;
|
|
|
|
|
|
|
|
tmp1 = tmpbuf;
|
|
|
|
tmp2 = tmpbuf + dest_size;
|
|
|
|
|
|
|
|
acc = 0;
|
|
|
|
xacc = 0;
|
|
|
|
y2 = -1;
|
2009-03-28 15:08:44 +00:00
|
|
|
vs_scanline_resample_linear_RGB (tmp1, src->pixels, src->width, dest->width,
|
|
|
|
&xacc, x_increment);
|
2005-07-01 16:55:43 +00:00
|
|
|
y1 = 0;
|
|
|
|
for (i = 0; i < dest->height; i++) {
|
|
|
|
j = acc >> 16;
|
|
|
|
x = acc & 0xffff;
|
|
|
|
|
|
|
|
if (x == 0) {
|
|
|
|
if (j == y1) {
|
|
|
|
memcpy (dest->pixels + i * dest->stride, tmp1, dest_size);
|
|
|
|
} else if (j == y2) {
|
|
|
|
memcpy (dest->pixels + i * dest->stride, tmp2, dest_size);
|
|
|
|
} else {
|
|
|
|
xacc = 0;
|
|
|
|
vs_scanline_resample_linear_RGB (tmp1, src->pixels + j * src->stride,
|
2009-03-28 15:08:44 +00:00
|
|
|
src->width, dest->width, &xacc, x_increment);
|
2005-07-01 16:55:43 +00:00
|
|
|
y1 = j;
|
|
|
|
memcpy (dest->pixels + i * dest->stride, tmp1, dest_size);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (j == y1) {
|
|
|
|
if (j + 1 != y2) {
|
|
|
|
xacc = 0;
|
|
|
|
vs_scanline_resample_linear_RGB (tmp2,
|
2009-03-28 15:08:44 +00:00
|
|
|
src->pixels + (j + 1) * src->stride, src->width, dest->width,
|
|
|
|
&xacc, x_increment);
|
2005-07-01 16:55:43 +00:00
|
|
|
y2 = j + 1;
|
|
|
|
}
|
|
|
|
vs_scanline_merge_linear_RGB (dest->pixels + i * dest->stride,
|
|
|
|
tmp1, tmp2, dest->width, x);
|
|
|
|
} else if (j == y2) {
|
|
|
|
if (j + 1 != y1) {
|
|
|
|
xacc = 0;
|
|
|
|
vs_scanline_resample_linear_RGB (tmp1,
|
2009-03-28 15:08:44 +00:00
|
|
|
src->pixels + (j + 1) * src->stride, src->width, dest->width,
|
|
|
|
&xacc, x_increment);
|
2005-07-01 16:55:43 +00:00
|
|
|
y1 = j + 1;
|
|
|
|
}
|
|
|
|
vs_scanline_merge_linear_RGB (dest->pixels + i * dest->stride,
|
|
|
|
tmp2, tmp1, dest->width, x);
|
|
|
|
} else {
|
|
|
|
xacc = 0;
|
|
|
|
vs_scanline_resample_linear_RGB (tmp1, src->pixels + j * src->stride,
|
2009-03-28 15:08:44 +00:00
|
|
|
src->width, dest->width, &xacc, x_increment);
|
2005-07-01 16:55:43 +00:00
|
|
|
y1 = j;
|
|
|
|
xacc = 0;
|
|
|
|
vs_scanline_resample_linear_RGB (tmp2,
|
2009-03-28 15:08:44 +00:00
|
|
|
src->pixels + (j + 1) * src->stride, src->width, dest->width, &xacc,
|
2005-07-01 16:55:43 +00:00
|
|
|
x_increment);
|
|
|
|
y2 = (j + 1);
|
|
|
|
vs_scanline_merge_linear_RGB (dest->pixels + i * dest->stride,
|
|
|
|
tmp1, tmp2, dest->width, x);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
acc += y_increment;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* YUYV */
|
|
|
|
|
|
|
|
void
|
|
|
|
vs_image_scale_nearest_YUYV (const VSImage * dest, const VSImage * src,
|
2006-11-14 23:08:38 +00:00
|
|
|
uint8_t * tmpbuf)
|
2005-07-01 16:55:43 +00:00
|
|
|
{
|
|
|
|
int acc;
|
|
|
|
int y_increment;
|
|
|
|
int x_increment;
|
|
|
|
int i;
|
|
|
|
int j;
|
|
|
|
int xacc;
|
|
|
|
|
gst/videoscale/: Support 1x1 images as input and output as for example the BBC HQ new streams have 1x1 GIFs in the pl...
Original commit message from CVS:
* gst/videoscale/gstvideoscale.c:
* gst/videoscale/vs_4tap.c: (vs_image_scale_4tap_Y):
* gst/videoscale/vs_image.c: (vs_image_scale_nearest_RGBA),
(vs_image_scale_linear_RGBA), (vs_image_scale_nearest_RGB),
(vs_image_scale_linear_RGB), (vs_image_scale_nearest_YUYV),
(vs_image_scale_linear_YUYV), (vs_image_scale_nearest_UYVY),
(vs_image_scale_linear_UYVY), (vs_image_scale_nearest_Y),
(vs_image_scale_linear_Y), (vs_image_scale_nearest_RGB565),
(vs_image_scale_linear_RGB565), (vs_image_scale_nearest_RGB555),
(vs_image_scale_linear_RGB555):
Support 1x1 images as input and output as for example the BBC HQ new
streams have 1x1 GIFs in the playlists for some reason.
2008-05-02 10:02:05 +00:00
|
|
|
if (dest->height == 1)
|
|
|
|
y_increment = 0;
|
|
|
|
else
|
|
|
|
y_increment = ((src->height - 1) << 16) / (dest->height - 1);
|
|
|
|
|
|
|
|
if (dest->width == 1)
|
|
|
|
x_increment = 0;
|
|
|
|
else
|
|
|
|
x_increment = ((src->width - 1) << 16) / (dest->width - 1);
|
2005-07-01 16:55:43 +00:00
|
|
|
|
|
|
|
acc = 0;
|
|
|
|
for (i = 0; i < dest->height; i++) {
|
|
|
|
j = acc >> 16;
|
|
|
|
|
|
|
|
xacc = 0;
|
|
|
|
vs_scanline_resample_nearest_YUYV (dest->pixels + i * dest->stride,
|
2009-03-28 15:08:44 +00:00
|
|
|
src->pixels + j * src->stride, src->width, dest->width, &xacc,
|
|
|
|
x_increment);
|
2005-07-01 16:55:43 +00:00
|
|
|
|
|
|
|
acc += y_increment;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
vs_image_scale_linear_YUYV (const VSImage * dest, const VSImage * src,
|
2006-11-14 23:08:38 +00:00
|
|
|
uint8_t * tmpbuf)
|
2005-07-01 16:55:43 +00:00
|
|
|
{
|
|
|
|
int acc;
|
|
|
|
int y_increment;
|
|
|
|
int x_increment;
|
2006-11-14 23:08:38 +00:00
|
|
|
uint8_t *tmp1;
|
|
|
|
uint8_t *tmp2;
|
2005-07-01 16:55:43 +00:00
|
|
|
int y1;
|
|
|
|
int y2;
|
|
|
|
int i;
|
|
|
|
int j;
|
|
|
|
int x;
|
|
|
|
int dest_size;
|
|
|
|
int xacc;
|
|
|
|
|
gst/videoscale/: Support 1x1 images as input and output as for example the BBC HQ new streams have 1x1 GIFs in the pl...
Original commit message from CVS:
* gst/videoscale/gstvideoscale.c:
* gst/videoscale/vs_4tap.c: (vs_image_scale_4tap_Y):
* gst/videoscale/vs_image.c: (vs_image_scale_nearest_RGBA),
(vs_image_scale_linear_RGBA), (vs_image_scale_nearest_RGB),
(vs_image_scale_linear_RGB), (vs_image_scale_nearest_YUYV),
(vs_image_scale_linear_YUYV), (vs_image_scale_nearest_UYVY),
(vs_image_scale_linear_UYVY), (vs_image_scale_nearest_Y),
(vs_image_scale_linear_Y), (vs_image_scale_nearest_RGB565),
(vs_image_scale_linear_RGB565), (vs_image_scale_nearest_RGB555),
(vs_image_scale_linear_RGB555):
Support 1x1 images as input and output as for example the BBC HQ new
streams have 1x1 GIFs in the playlists for some reason.
2008-05-02 10:02:05 +00:00
|
|
|
if (dest->height == 1)
|
|
|
|
y_increment = 0;
|
|
|
|
else
|
2011-04-23 20:42:23 +00:00
|
|
|
y_increment = ((src->height - 1) << 16) / (dest->height - 1) - 1;
|
gst/videoscale/: Support 1x1 images as input and output as for example the BBC HQ new streams have 1x1 GIFs in the pl...
Original commit message from CVS:
* gst/videoscale/gstvideoscale.c:
* gst/videoscale/vs_4tap.c: (vs_image_scale_4tap_Y):
* gst/videoscale/vs_image.c: (vs_image_scale_nearest_RGBA),
(vs_image_scale_linear_RGBA), (vs_image_scale_nearest_RGB),
(vs_image_scale_linear_RGB), (vs_image_scale_nearest_YUYV),
(vs_image_scale_linear_YUYV), (vs_image_scale_nearest_UYVY),
(vs_image_scale_linear_UYVY), (vs_image_scale_nearest_Y),
(vs_image_scale_linear_Y), (vs_image_scale_nearest_RGB565),
(vs_image_scale_linear_RGB565), (vs_image_scale_nearest_RGB555),
(vs_image_scale_linear_RGB555):
Support 1x1 images as input and output as for example the BBC HQ new
streams have 1x1 GIFs in the playlists for some reason.
2008-05-02 10:02:05 +00:00
|
|
|
|
|
|
|
if (dest->width == 1)
|
|
|
|
x_increment = 0;
|
|
|
|
else
|
2011-04-23 20:42:23 +00:00
|
|
|
x_increment = ((src->width - 1) << 16) / (dest->width - 1) - 1;
|
2005-07-01 16:55:43 +00:00
|
|
|
|
|
|
|
dest_size = ROUND_UP_4 (dest->width * 2);
|
|
|
|
|
|
|
|
tmp1 = tmpbuf;
|
|
|
|
tmp2 = tmpbuf + dest_size;
|
|
|
|
|
|
|
|
acc = 0;
|
|
|
|
xacc = 0;
|
|
|
|
y2 = -1;
|
2009-03-28 15:08:44 +00:00
|
|
|
vs_scanline_resample_linear_YUYV (tmp1, src->pixels, src->width, dest->width,
|
|
|
|
&xacc, x_increment);
|
2005-07-01 16:55:43 +00:00
|
|
|
y1 = 0;
|
|
|
|
for (i = 0; i < dest->height; i++) {
|
|
|
|
j = acc >> 16;
|
|
|
|
x = acc & 0xffff;
|
|
|
|
|
|
|
|
if (x == 0) {
|
|
|
|
if (j == y1) {
|
|
|
|
memcpy (dest->pixels + i * dest->stride, tmp1, dest_size);
|
|
|
|
} else if (j == y2) {
|
|
|
|
memcpy (dest->pixels + i * dest->stride, tmp2, dest_size);
|
|
|
|
} else {
|
|
|
|
xacc = 0;
|
|
|
|
vs_scanline_resample_linear_YUYV (tmp1, src->pixels + j * src->stride,
|
2009-03-28 15:08:44 +00:00
|
|
|
src->width, dest->width, &xacc, x_increment);
|
2005-07-01 16:55:43 +00:00
|
|
|
y1 = j;
|
|
|
|
memcpy (dest->pixels + i * dest->stride, tmp1, dest_size);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (j == y1) {
|
|
|
|
if (j + 1 != y2) {
|
|
|
|
xacc = 0;
|
|
|
|
vs_scanline_resample_linear_YUYV (tmp2,
|
2009-03-28 15:08:44 +00:00
|
|
|
src->pixels + (j + 1) * src->stride, src->width, dest->width,
|
|
|
|
&xacc, x_increment);
|
2005-07-01 16:55:43 +00:00
|
|
|
y2 = j + 1;
|
|
|
|
}
|
|
|
|
vs_scanline_merge_linear_YUYV (dest->pixels + i * dest->stride,
|
2009-03-28 15:08:44 +00:00
|
|
|
tmp1, tmp2, dest->width, x);
|
2005-07-01 16:55:43 +00:00
|
|
|
} else if (j == y2) {
|
|
|
|
if (j + 1 != y1) {
|
|
|
|
xacc = 0;
|
|
|
|
vs_scanline_resample_linear_YUYV (tmp1,
|
2009-03-28 15:08:44 +00:00
|
|
|
src->pixels + (j + 1) * src->stride, src->width, dest->width,
|
|
|
|
&xacc, x_increment);
|
2005-07-01 16:55:43 +00:00
|
|
|
y1 = j + 1;
|
|
|
|
}
|
|
|
|
vs_scanline_merge_linear_YUYV (dest->pixels + i * dest->stride,
|
2009-03-28 15:08:44 +00:00
|
|
|
tmp2, tmp1, dest->width, x);
|
2005-07-01 16:55:43 +00:00
|
|
|
} else {
|
|
|
|
xacc = 0;
|
|
|
|
vs_scanline_resample_linear_YUYV (tmp1, src->pixels + j * src->stride,
|
2009-03-28 15:08:44 +00:00
|
|
|
src->width, dest->width, &xacc, x_increment);
|
2005-07-01 16:55:43 +00:00
|
|
|
y1 = j;
|
|
|
|
xacc = 0;
|
|
|
|
vs_scanline_resample_linear_YUYV (tmp2,
|
2009-03-28 15:08:44 +00:00
|
|
|
src->pixels + (j + 1) * src->stride, src->width, dest->width,
|
|
|
|
&xacc, x_increment);
|
2005-07-01 16:55:43 +00:00
|
|
|
y2 = (j + 1);
|
|
|
|
vs_scanline_merge_linear_YUYV (dest->pixels + i * dest->stride,
|
2009-03-28 15:08:44 +00:00
|
|
|
tmp1, tmp2, dest->width, x);
|
2005-07-01 16:55:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
acc += y_increment;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* UYVY */
|
|
|
|
|
|
|
|
void
|
|
|
|
vs_image_scale_nearest_UYVY (const VSImage * dest, const VSImage * src,
|
2006-11-14 23:08:38 +00:00
|
|
|
uint8_t * tmpbuf)
|
2005-07-01 16:55:43 +00:00
|
|
|
{
|
|
|
|
int acc;
|
|
|
|
int y_increment;
|
|
|
|
int x_increment;
|
|
|
|
int i;
|
|
|
|
int j;
|
|
|
|
int xacc;
|
|
|
|
|
gst/videoscale/: Support 1x1 images as input and output as for example the BBC HQ new streams have 1x1 GIFs in the pl...
Original commit message from CVS:
* gst/videoscale/gstvideoscale.c:
* gst/videoscale/vs_4tap.c: (vs_image_scale_4tap_Y):
* gst/videoscale/vs_image.c: (vs_image_scale_nearest_RGBA),
(vs_image_scale_linear_RGBA), (vs_image_scale_nearest_RGB),
(vs_image_scale_linear_RGB), (vs_image_scale_nearest_YUYV),
(vs_image_scale_linear_YUYV), (vs_image_scale_nearest_UYVY),
(vs_image_scale_linear_UYVY), (vs_image_scale_nearest_Y),
(vs_image_scale_linear_Y), (vs_image_scale_nearest_RGB565),
(vs_image_scale_linear_RGB565), (vs_image_scale_nearest_RGB555),
(vs_image_scale_linear_RGB555):
Support 1x1 images as input and output as for example the BBC HQ new
streams have 1x1 GIFs in the playlists for some reason.
2008-05-02 10:02:05 +00:00
|
|
|
if (dest->height == 1)
|
|
|
|
y_increment = 0;
|
|
|
|
else
|
|
|
|
y_increment = ((src->height - 1) << 16) / (dest->height - 1);
|
|
|
|
|
|
|
|
if (dest->width == 1)
|
|
|
|
x_increment = 0;
|
|
|
|
else
|
|
|
|
x_increment = ((src->width - 1) << 16) / (dest->width - 1);
|
2005-07-01 16:55:43 +00:00
|
|
|
|
|
|
|
acc = 0;
|
|
|
|
for (i = 0; i < dest->height; i++) {
|
|
|
|
j = acc >> 16;
|
|
|
|
|
|
|
|
xacc = 0;
|
|
|
|
vs_scanline_resample_nearest_UYVY (dest->pixels + i * dest->stride,
|
2009-03-28 15:08:44 +00:00
|
|
|
src->pixels + j * src->stride, src->width, dest->width, &xacc,
|
|
|
|
x_increment);
|
2005-07-01 16:55:43 +00:00
|
|
|
|
|
|
|
acc += y_increment;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
vs_image_scale_linear_UYVY (const VSImage * dest, const VSImage * src,
|
2006-11-14 23:08:38 +00:00
|
|
|
uint8_t * tmpbuf)
|
2005-07-01 16:55:43 +00:00
|
|
|
{
|
|
|
|
int acc;
|
|
|
|
int y_increment;
|
|
|
|
int x_increment;
|
2006-11-14 23:08:38 +00:00
|
|
|
uint8_t *tmp1;
|
|
|
|
uint8_t *tmp2;
|
2005-07-01 16:55:43 +00:00
|
|
|
int y1;
|
|
|
|
int y2;
|
|
|
|
int i;
|
|
|
|
int j;
|
|
|
|
int x;
|
|
|
|
int dest_size;
|
|
|
|
int xacc;
|
|
|
|
|
gst/videoscale/: Support 1x1 images as input and output as for example the BBC HQ new streams have 1x1 GIFs in the pl...
Original commit message from CVS:
* gst/videoscale/gstvideoscale.c:
* gst/videoscale/vs_4tap.c: (vs_image_scale_4tap_Y):
* gst/videoscale/vs_image.c: (vs_image_scale_nearest_RGBA),
(vs_image_scale_linear_RGBA), (vs_image_scale_nearest_RGB),
(vs_image_scale_linear_RGB), (vs_image_scale_nearest_YUYV),
(vs_image_scale_linear_YUYV), (vs_image_scale_nearest_UYVY),
(vs_image_scale_linear_UYVY), (vs_image_scale_nearest_Y),
(vs_image_scale_linear_Y), (vs_image_scale_nearest_RGB565),
(vs_image_scale_linear_RGB565), (vs_image_scale_nearest_RGB555),
(vs_image_scale_linear_RGB555):
Support 1x1 images as input and output as for example the BBC HQ new
streams have 1x1 GIFs in the playlists for some reason.
2008-05-02 10:02:05 +00:00
|
|
|
if (dest->height == 1)
|
|
|
|
y_increment = 0;
|
|
|
|
else
|
2011-04-23 20:42:23 +00:00
|
|
|
y_increment = ((src->height - 1) << 16) / (dest->height - 1) - 1;
|
gst/videoscale/: Support 1x1 images as input and output as for example the BBC HQ new streams have 1x1 GIFs in the pl...
Original commit message from CVS:
* gst/videoscale/gstvideoscale.c:
* gst/videoscale/vs_4tap.c: (vs_image_scale_4tap_Y):
* gst/videoscale/vs_image.c: (vs_image_scale_nearest_RGBA),
(vs_image_scale_linear_RGBA), (vs_image_scale_nearest_RGB),
(vs_image_scale_linear_RGB), (vs_image_scale_nearest_YUYV),
(vs_image_scale_linear_YUYV), (vs_image_scale_nearest_UYVY),
(vs_image_scale_linear_UYVY), (vs_image_scale_nearest_Y),
(vs_image_scale_linear_Y), (vs_image_scale_nearest_RGB565),
(vs_image_scale_linear_RGB565), (vs_image_scale_nearest_RGB555),
(vs_image_scale_linear_RGB555):
Support 1x1 images as input and output as for example the BBC HQ new
streams have 1x1 GIFs in the playlists for some reason.
2008-05-02 10:02:05 +00:00
|
|
|
|
|
|
|
if (dest->width == 1)
|
|
|
|
x_increment = 0;
|
|
|
|
else
|
2011-04-23 20:42:23 +00:00
|
|
|
x_increment = ((src->width - 1) << 16) / (dest->width - 1) - 1;
|
2005-07-01 16:55:43 +00:00
|
|
|
|
|
|
|
dest_size = ROUND_UP_4 (dest->width * 2);
|
|
|
|
|
|
|
|
tmp1 = tmpbuf;
|
|
|
|
tmp2 = tmpbuf + dest_size;
|
|
|
|
|
|
|
|
acc = 0;
|
|
|
|
xacc = 0;
|
|
|
|
y2 = -1;
|
2009-03-28 15:08:44 +00:00
|
|
|
vs_scanline_resample_linear_UYVY (tmp1, src->pixels, src->width, dest->width,
|
|
|
|
&xacc, x_increment);
|
2005-07-01 16:55:43 +00:00
|
|
|
y1 = 0;
|
|
|
|
for (i = 0; i < dest->height; i++) {
|
|
|
|
j = acc >> 16;
|
|
|
|
x = acc & 0xffff;
|
|
|
|
|
|
|
|
if (x == 0) {
|
|
|
|
if (j == y1) {
|
|
|
|
memcpy (dest->pixels + i * dest->stride, tmp1, dest_size);
|
|
|
|
} else if (j == y2) {
|
|
|
|
memcpy (dest->pixels + i * dest->stride, tmp2, dest_size);
|
|
|
|
} else {
|
|
|
|
xacc = 0;
|
|
|
|
vs_scanline_resample_linear_UYVY (tmp1, src->pixels + j * src->stride,
|
2009-03-28 15:08:44 +00:00
|
|
|
src->width, dest->width, &xacc, x_increment);
|
2005-07-01 16:55:43 +00:00
|
|
|
y1 = j;
|
|
|
|
memcpy (dest->pixels + i * dest->stride, tmp1, dest_size);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (j == y1) {
|
|
|
|
if (j + 1 != y2) {
|
|
|
|
xacc = 0;
|
|
|
|
vs_scanline_resample_linear_UYVY (tmp2,
|
2009-03-28 15:08:44 +00:00
|
|
|
src->pixels + (j + 1) * src->stride, src->width, dest->width,
|
|
|
|
&xacc, x_increment);
|
2005-07-01 16:55:43 +00:00
|
|
|
y2 = j + 1;
|
|
|
|
}
|
|
|
|
vs_scanline_merge_linear_UYVY (dest->pixels + i * dest->stride,
|
2009-03-28 15:08:44 +00:00
|
|
|
tmp1, tmp2, dest->width, x);
|
2005-07-01 16:55:43 +00:00
|
|
|
} else if (j == y2) {
|
|
|
|
if (j + 1 != y1) {
|
|
|
|
xacc = 0;
|
|
|
|
vs_scanline_resample_linear_UYVY (tmp1,
|
2009-03-28 15:08:44 +00:00
|
|
|
src->pixels + (j + 1) * src->stride, src->width, dest->width,
|
|
|
|
&xacc, x_increment);
|
2005-07-01 16:55:43 +00:00
|
|
|
y1 = j + 1;
|
|
|
|
}
|
|
|
|
vs_scanline_merge_linear_UYVY (dest->pixels + i * dest->stride,
|
2009-03-28 15:08:44 +00:00
|
|
|
tmp2, tmp1, dest->width, x);
|
2005-07-01 16:55:43 +00:00
|
|
|
} else {
|
|
|
|
xacc = 0;
|
|
|
|
vs_scanline_resample_linear_UYVY (tmp1, src->pixels + j * src->stride,
|
2009-03-28 15:08:44 +00:00
|
|
|
src->width, dest->width, &xacc, x_increment);
|
2005-07-01 16:55:43 +00:00
|
|
|
y1 = j;
|
|
|
|
xacc = 0;
|
|
|
|
vs_scanline_resample_linear_UYVY (tmp2,
|
2009-03-28 15:08:44 +00:00
|
|
|
src->pixels + (j + 1) * src->stride, src->width, dest->width,
|
|
|
|
&xacc, x_increment);
|
2005-07-01 16:55:43 +00:00
|
|
|
y2 = (j + 1);
|
|
|
|
vs_scanline_merge_linear_UYVY (dest->pixels + i * dest->stride,
|
2009-03-28 15:08:44 +00:00
|
|
|
tmp1, tmp2, dest->width, x);
|
2005-07-01 16:55:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
acc += y_increment;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-30 16:21:54 +00:00
|
|
|
/* NV12 */
|
|
|
|
|
|
|
|
void
|
|
|
|
vs_image_scale_nearest_NV12 (const VSImage * dest, const VSImage * src,
|
|
|
|
uint8_t * tmpbuf)
|
|
|
|
{
|
|
|
|
int acc;
|
|
|
|
int y_increment;
|
|
|
|
int x_increment;
|
|
|
|
int i;
|
|
|
|
int j;
|
|
|
|
int xacc;
|
|
|
|
|
|
|
|
if (dest->height == 1)
|
|
|
|
y_increment = 0;
|
|
|
|
else
|
|
|
|
y_increment = ((src->height - 1) << 16) / (dest->height - 1);
|
|
|
|
|
|
|
|
if (dest->width == 1)
|
|
|
|
x_increment = 0;
|
|
|
|
else
|
|
|
|
x_increment = ((src->width - 1) << 16) / (dest->width - 1);
|
|
|
|
|
|
|
|
acc = 0;
|
|
|
|
for (i = 0; i < dest->height; i++) {
|
|
|
|
j = acc >> 16;
|
|
|
|
|
|
|
|
xacc = 0;
|
|
|
|
vs_scanline_resample_nearest_NV12 (dest->pixels + i * dest->stride,
|
|
|
|
src->pixels + j * src->stride, src->width, dest->width, &xacc,
|
|
|
|
x_increment);
|
|
|
|
|
|
|
|
acc += y_increment;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
vs_image_scale_linear_NV12 (const VSImage * dest, const VSImage * src,
|
|
|
|
uint8_t * tmpbuf)
|
|
|
|
{
|
|
|
|
int acc;
|
|
|
|
int y_increment;
|
|
|
|
int x_increment;
|
|
|
|
uint8_t *tmp1;
|
|
|
|
uint8_t *tmp2;
|
|
|
|
int y1;
|
|
|
|
int y2;
|
|
|
|
int i;
|
|
|
|
int j;
|
|
|
|
int x;
|
|
|
|
int dest_size;
|
|
|
|
int xacc;
|
|
|
|
|
|
|
|
if (dest->height == 1)
|
|
|
|
y_increment = 0;
|
|
|
|
else
|
|
|
|
y_increment = ((src->height - 1) << 16) / (dest->height - 1) - 1;
|
|
|
|
|
|
|
|
if (dest->width == 1)
|
|
|
|
x_increment = 0;
|
|
|
|
else
|
|
|
|
x_increment = ((src->width - 1) << 16) / (dest->width - 1) - 1;
|
|
|
|
|
|
|
|
dest_size = ROUND_UP_4 (dest->width * 2);
|
|
|
|
|
|
|
|
tmp1 = tmpbuf;
|
|
|
|
tmp2 = tmpbuf + dest_size;
|
|
|
|
|
|
|
|
acc = 0;
|
|
|
|
xacc = 0;
|
|
|
|
y2 = -1;
|
|
|
|
vs_scanline_resample_linear_NV12 (tmp1, src->pixels, src->width, dest->width,
|
|
|
|
&xacc, x_increment);
|
|
|
|
y1 = 0;
|
|
|
|
for (i = 0; i < dest->height; i++) {
|
|
|
|
j = acc >> 16;
|
|
|
|
x = acc & 0xffff;
|
|
|
|
|
|
|
|
if (x == 0) {
|
|
|
|
if (j == y1) {
|
|
|
|
memcpy (dest->pixels + i * dest->stride, tmp1, dest_size);
|
|
|
|
} else if (j == y2) {
|
|
|
|
memcpy (dest->pixels + i * dest->stride, tmp2, dest_size);
|
|
|
|
} else {
|
|
|
|
xacc = 0;
|
|
|
|
vs_scanline_resample_linear_NV12 (tmp1, src->pixels + j * src->stride,
|
|
|
|
src->width, dest->width, &xacc, x_increment);
|
|
|
|
y1 = j;
|
|
|
|
memcpy (dest->pixels + i * dest->stride, tmp1, dest_size);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (j == y1) {
|
|
|
|
if (j + 1 != y2) {
|
|
|
|
xacc = 0;
|
|
|
|
vs_scanline_resample_linear_NV12 (tmp2,
|
|
|
|
src->pixels + (j + 1) * src->stride, src->width, dest->width,
|
|
|
|
&xacc, x_increment);
|
|
|
|
y2 = j + 1;
|
|
|
|
}
|
|
|
|
vs_scanline_merge_linear_NV12 (dest->pixels + i * dest->stride,
|
|
|
|
tmp1, tmp2, dest->width, x);
|
|
|
|
} else if (j == y2) {
|
|
|
|
if (j + 1 != y1) {
|
|
|
|
xacc = 0;
|
|
|
|
vs_scanline_resample_linear_NV12 (tmp1,
|
|
|
|
src->pixels + (j + 1) * src->stride, src->width, dest->width,
|
|
|
|
&xacc, x_increment);
|
|
|
|
y1 = j + 1;
|
|
|
|
}
|
|
|
|
vs_scanline_merge_linear_NV12 (dest->pixels + i * dest->stride,
|
|
|
|
tmp2, tmp1, dest->width, x);
|
|
|
|
} else {
|
|
|
|
xacc = 0;
|
|
|
|
vs_scanline_resample_linear_NV12 (tmp1, src->pixels + j * src->stride,
|
|
|
|
src->width, dest->width, &xacc, x_increment);
|
|
|
|
y1 = j;
|
|
|
|
xacc = 0;
|
|
|
|
vs_scanline_resample_linear_NV12 (tmp2,
|
|
|
|
src->pixels + (j + 1) * src->stride, src->width, dest->width,
|
|
|
|
&xacc, x_increment);
|
|
|
|
y2 = (j + 1);
|
|
|
|
vs_scanline_merge_linear_NV12 (dest->pixels + i * dest->stride,
|
|
|
|
tmp1, tmp2, dest->width, x);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
acc += y_increment;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-07-01 16:55:43 +00:00
|
|
|
/* greyscale */
|
|
|
|
|
|
|
|
void
|
|
|
|
vs_image_scale_nearest_Y (const VSImage * dest, const VSImage * src,
|
2006-11-14 23:08:38 +00:00
|
|
|
uint8_t * tmpbuf)
|
2005-07-01 16:55:43 +00:00
|
|
|
{
|
|
|
|
int acc;
|
|
|
|
int y_increment;
|
|
|
|
int x_increment;
|
|
|
|
int i;
|
|
|
|
int j;
|
|
|
|
|
gst/videoscale/: Support 1x1 images as input and output as for example the BBC HQ new streams have 1x1 GIFs in the pl...
Original commit message from CVS:
* gst/videoscale/gstvideoscale.c:
* gst/videoscale/vs_4tap.c: (vs_image_scale_4tap_Y):
* gst/videoscale/vs_image.c: (vs_image_scale_nearest_RGBA),
(vs_image_scale_linear_RGBA), (vs_image_scale_nearest_RGB),
(vs_image_scale_linear_RGB), (vs_image_scale_nearest_YUYV),
(vs_image_scale_linear_YUYV), (vs_image_scale_nearest_UYVY),
(vs_image_scale_linear_UYVY), (vs_image_scale_nearest_Y),
(vs_image_scale_linear_Y), (vs_image_scale_nearest_RGB565),
(vs_image_scale_linear_RGB565), (vs_image_scale_nearest_RGB555),
(vs_image_scale_linear_RGB555):
Support 1x1 images as input and output as for example the BBC HQ new
streams have 1x1 GIFs in the playlists for some reason.
2008-05-02 10:02:05 +00:00
|
|
|
if (dest->height == 1)
|
|
|
|
y_increment = 0;
|
|
|
|
else
|
|
|
|
y_increment = ((src->height - 1) << 16) / (dest->height - 1);
|
|
|
|
|
|
|
|
if (dest->width == 1)
|
|
|
|
x_increment = 0;
|
|
|
|
else
|
|
|
|
x_increment = ((src->width - 1) << 16) / (dest->width - 1);
|
2005-07-01 16:55:43 +00:00
|
|
|
|
|
|
|
acc = 0;
|
|
|
|
for (i = 0; i < dest->height; i++) {
|
|
|
|
j = acc >> 16;
|
|
|
|
|
2010-06-14 22:42:09 +00:00
|
|
|
gst_videoscale_orc_resample_nearest_u8 (dest->pixels + i * dest->stride,
|
|
|
|
src->pixels + j * src->stride, 0, x_increment, dest->width);
|
2005-07-01 16:55:43 +00:00
|
|
|
acc += y_increment;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
vs_image_scale_linear_Y (const VSImage * dest, const VSImage * src,
|
2006-11-14 23:08:38 +00:00
|
|
|
uint8_t * tmpbuf)
|
2005-07-01 16:55:43 +00:00
|
|
|
{
|
|
|
|
int acc;
|
|
|
|
int y_increment;
|
|
|
|
int x_increment;
|
2006-11-14 23:08:38 +00:00
|
|
|
uint8_t *tmp1;
|
|
|
|
uint8_t *tmp2;
|
2005-07-01 16:55:43 +00:00
|
|
|
int y1;
|
|
|
|
int y2;
|
|
|
|
int i;
|
|
|
|
int j;
|
|
|
|
int x;
|
|
|
|
int dest_size;
|
|
|
|
|
gst/videoscale/: Support 1x1 images as input and output as for example the BBC HQ new streams have 1x1 GIFs in the pl...
Original commit message from CVS:
* gst/videoscale/gstvideoscale.c:
* gst/videoscale/vs_4tap.c: (vs_image_scale_4tap_Y):
* gst/videoscale/vs_image.c: (vs_image_scale_nearest_RGBA),
(vs_image_scale_linear_RGBA), (vs_image_scale_nearest_RGB),
(vs_image_scale_linear_RGB), (vs_image_scale_nearest_YUYV),
(vs_image_scale_linear_YUYV), (vs_image_scale_nearest_UYVY),
(vs_image_scale_linear_UYVY), (vs_image_scale_nearest_Y),
(vs_image_scale_linear_Y), (vs_image_scale_nearest_RGB565),
(vs_image_scale_linear_RGB565), (vs_image_scale_nearest_RGB555),
(vs_image_scale_linear_RGB555):
Support 1x1 images as input and output as for example the BBC HQ new
streams have 1x1 GIFs in the playlists for some reason.
2008-05-02 10:02:05 +00:00
|
|
|
if (dest->height == 1)
|
|
|
|
y_increment = 0;
|
|
|
|
else
|
2011-04-23 20:42:23 +00:00
|
|
|
y_increment = ((src->height - 1) << 16) / (dest->height - 1) - 1;
|
gst/videoscale/: Support 1x1 images as input and output as for example the BBC HQ new streams have 1x1 GIFs in the pl...
Original commit message from CVS:
* gst/videoscale/gstvideoscale.c:
* gst/videoscale/vs_4tap.c: (vs_image_scale_4tap_Y):
* gst/videoscale/vs_image.c: (vs_image_scale_nearest_RGBA),
(vs_image_scale_linear_RGBA), (vs_image_scale_nearest_RGB),
(vs_image_scale_linear_RGB), (vs_image_scale_nearest_YUYV),
(vs_image_scale_linear_YUYV), (vs_image_scale_nearest_UYVY),
(vs_image_scale_linear_UYVY), (vs_image_scale_nearest_Y),
(vs_image_scale_linear_Y), (vs_image_scale_nearest_RGB565),
(vs_image_scale_linear_RGB565), (vs_image_scale_nearest_RGB555),
(vs_image_scale_linear_RGB555):
Support 1x1 images as input and output as for example the BBC HQ new
streams have 1x1 GIFs in the playlists for some reason.
2008-05-02 10:02:05 +00:00
|
|
|
|
|
|
|
if (dest->width == 1)
|
|
|
|
x_increment = 0;
|
|
|
|
else
|
2011-04-23 20:42:23 +00:00
|
|
|
x_increment = ((src->width - 1) << 16) / (dest->width - 1) - 1;
|
2005-07-01 16:55:43 +00:00
|
|
|
|
|
|
|
dest_size = dest->width;
|
|
|
|
|
|
|
|
tmp1 = tmpbuf;
|
|
|
|
tmp2 = tmpbuf + dest_size;
|
|
|
|
|
|
|
|
acc = 0;
|
|
|
|
y2 = -1;
|
2010-06-14 22:42:09 +00:00
|
|
|
gst_videoscale_orc_resample_bilinear_u8 (tmp1, src->pixels,
|
|
|
|
0, x_increment, dest->width);
|
2005-07-01 16:55:43 +00:00
|
|
|
y1 = 0;
|
|
|
|
for (i = 0; i < dest->height; i++) {
|
|
|
|
j = acc >> 16;
|
|
|
|
x = acc & 0xffff;
|
|
|
|
|
|
|
|
if (x == 0) {
|
|
|
|
if (j == y1) {
|
|
|
|
memcpy (dest->pixels + i * dest->stride, tmp1, dest_size);
|
|
|
|
} else if (j == y2) {
|
|
|
|
memcpy (dest->pixels + i * dest->stride, tmp2, dest_size);
|
|
|
|
} else {
|
2010-06-14 22:42:09 +00:00
|
|
|
gst_videoscale_orc_resample_bilinear_u8 (tmp1,
|
|
|
|
src->pixels + j * src->stride, 0, x_increment, dest->width);
|
2005-07-01 16:55:43 +00:00
|
|
|
y1 = j;
|
|
|
|
memcpy (dest->pixels + i * dest->stride, tmp1, dest_size);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (j == y1) {
|
|
|
|
if (j + 1 != y2) {
|
2010-06-14 22:42:09 +00:00
|
|
|
gst_videoscale_orc_resample_bilinear_u8 (tmp2,
|
|
|
|
src->pixels + (j + 1) * src->stride, 0, x_increment, dest->width);
|
2005-07-01 16:55:43 +00:00
|
|
|
y2 = j + 1;
|
|
|
|
}
|
2010-06-14 22:42:09 +00:00
|
|
|
if ((x >> 8) == 0) {
|
|
|
|
memcpy (dest->pixels + i * dest->stride, tmp1, dest->width);
|
|
|
|
} else {
|
|
|
|
orc_merge_linear_u8 (dest->pixels + i * dest->stride,
|
|
|
|
tmp1, tmp2, (x >> 8), dest->width);
|
|
|
|
}
|
2005-07-01 16:55:43 +00:00
|
|
|
} else if (j == y2) {
|
|
|
|
if (j + 1 != y1) {
|
2010-06-14 22:42:09 +00:00
|
|
|
gst_videoscale_orc_resample_bilinear_u8 (tmp1,
|
|
|
|
src->pixels + (j + 1) * src->stride, 0, x_increment, dest->width);
|
2005-07-01 16:55:43 +00:00
|
|
|
y1 = j + 1;
|
|
|
|
}
|
2010-06-14 22:42:09 +00:00
|
|
|
if ((x >> 8) == 0) {
|
|
|
|
memcpy (dest->pixels + i * dest->stride, tmp2, dest->width);
|
|
|
|
} else {
|
|
|
|
orc_merge_linear_u8 (dest->pixels + i * dest->stride,
|
|
|
|
tmp2, tmp1, (x >> 8), dest->width);
|
|
|
|
}
|
2005-07-01 16:55:43 +00:00
|
|
|
} else {
|
2010-06-14 22:42:09 +00:00
|
|
|
gst_videoscale_orc_resample_bilinear_u8 (tmp1,
|
|
|
|
src->pixels + j * src->stride, 0, x_increment, dest->width);
|
2005-07-01 16:55:43 +00:00
|
|
|
y1 = j;
|
2010-06-14 22:42:09 +00:00
|
|
|
gst_videoscale_orc_resample_bilinear_u8 (tmp2,
|
|
|
|
src->pixels + (j + 1) * src->stride, 0, x_increment, dest->width);
|
2005-07-01 16:55:43 +00:00
|
|
|
y2 = (j + 1);
|
2010-06-14 22:42:09 +00:00
|
|
|
if ((x >> 8) == 0) {
|
|
|
|
memcpy (dest->pixels + i * dest->stride, tmp1, dest->width);
|
|
|
|
} else {
|
|
|
|
orc_merge_linear_u8 (dest->pixels + i * dest->stride,
|
|
|
|
tmp1, tmp2, (x >> 8), dest->width);
|
|
|
|
}
|
2005-07-01 16:55:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
acc += y_increment;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-26 13:23:45 +00:00
|
|
|
void
|
|
|
|
vs_image_scale_nearest_Y16 (const VSImage * dest, const VSImage * src,
|
|
|
|
uint8_t * tmpbuf)
|
|
|
|
{
|
|
|
|
int acc;
|
|
|
|
int y_increment;
|
|
|
|
int x_increment;
|
|
|
|
int i;
|
|
|
|
int j;
|
|
|
|
int xacc;
|
|
|
|
|
|
|
|
if (dest->height == 1)
|
|
|
|
y_increment = 0;
|
|
|
|
else
|
|
|
|
y_increment = ((src->height - 1) << 16) / (dest->height - 1);
|
|
|
|
|
|
|
|
if (dest->width == 1)
|
|
|
|
x_increment = 0;
|
|
|
|
else
|
|
|
|
x_increment = ((src->width - 1) << 16) / (dest->width - 1);
|
|
|
|
|
|
|
|
acc = 0;
|
|
|
|
for (i = 0; i < dest->height; i++) {
|
|
|
|
j = acc >> 16;
|
|
|
|
|
|
|
|
xacc = 0;
|
|
|
|
vs_scanline_resample_nearest_Y16 (dest->pixels + i * dest->stride,
|
|
|
|
src->pixels + j * src->stride, src->width, dest->width, &xacc,
|
|
|
|
x_increment);
|
|
|
|
|
|
|
|
acc += y_increment;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
vs_image_scale_linear_Y16 (const VSImage * dest, const VSImage * src,
|
|
|
|
uint8_t * tmpbuf)
|
|
|
|
{
|
|
|
|
int acc;
|
|
|
|
int y_increment;
|
|
|
|
int x_increment;
|
|
|
|
uint8_t *tmp1;
|
|
|
|
uint8_t *tmp2;
|
|
|
|
int y1;
|
|
|
|
int y2;
|
|
|
|
int i;
|
|
|
|
int j;
|
|
|
|
int x;
|
|
|
|
int dest_size;
|
|
|
|
int xacc;
|
|
|
|
|
|
|
|
if (dest->height == 1)
|
|
|
|
y_increment = 0;
|
|
|
|
else
|
2011-04-23 20:42:23 +00:00
|
|
|
y_increment = ((src->height - 1) << 16) / (dest->height - 1) - 1;
|
2009-05-26 13:23:45 +00:00
|
|
|
|
|
|
|
if (dest->width == 1)
|
|
|
|
x_increment = 0;
|
|
|
|
else
|
2011-04-23 20:42:23 +00:00
|
|
|
x_increment = ((src->width - 1) << 16) / (dest->width - 1) - 1;
|
2009-05-26 13:23:45 +00:00
|
|
|
|
|
|
|
dest_size = 2 * dest->width;
|
|
|
|
|
|
|
|
tmp1 = tmpbuf;
|
|
|
|
tmp2 = tmpbuf + dest_size;
|
|
|
|
|
|
|
|
acc = 0;
|
|
|
|
xacc = 0;
|
|
|
|
y2 = -1;
|
|
|
|
vs_scanline_resample_linear_Y16 (tmp1, src->pixels, src->width, dest->width,
|
|
|
|
&xacc, x_increment);
|
|
|
|
y1 = 0;
|
|
|
|
for (i = 0; i < dest->height; i++) {
|
|
|
|
j = acc >> 16;
|
|
|
|
x = acc & 0xffff;
|
|
|
|
|
|
|
|
if (x == 0) {
|
|
|
|
if (j == y1) {
|
|
|
|
memcpy (dest->pixels + i * dest->stride, tmp1, dest_size);
|
|
|
|
} else if (j == y2) {
|
|
|
|
memcpy (dest->pixels + i * dest->stride, tmp2, dest_size);
|
|
|
|
} else {
|
|
|
|
xacc = 0;
|
|
|
|
vs_scanline_resample_linear_Y16 (tmp1, src->pixels + j * src->stride,
|
|
|
|
src->width, dest->width, &xacc, x_increment);
|
|
|
|
y1 = j;
|
|
|
|
memcpy (dest->pixels + i * dest->stride, tmp1, dest_size);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (j == y1) {
|
|
|
|
if (j + 1 != y2) {
|
|
|
|
xacc = 0;
|
|
|
|
vs_scanline_resample_linear_Y16 (tmp2,
|
|
|
|
src->pixels + (j + 1) * src->stride, src->width, dest->width,
|
|
|
|
&xacc, x_increment);
|
|
|
|
y2 = j + 1;
|
|
|
|
}
|
|
|
|
vs_scanline_merge_linear_Y16 (dest->pixels + i * dest->stride,
|
|
|
|
tmp1, tmp2, dest->width, x);
|
|
|
|
} else if (j == y2) {
|
|
|
|
if (j + 1 != y1) {
|
|
|
|
xacc = 0;
|
|
|
|
vs_scanline_resample_linear_Y16 (tmp1,
|
|
|
|
src->pixels + (j + 1) * src->stride, src->width, dest->width,
|
|
|
|
&xacc, x_increment);
|
|
|
|
y1 = j + 1;
|
|
|
|
}
|
|
|
|
vs_scanline_merge_linear_Y16 (dest->pixels + i * dest->stride,
|
|
|
|
tmp2, tmp1, dest->width, x);
|
|
|
|
} else {
|
|
|
|
xacc = 0;
|
|
|
|
vs_scanline_resample_linear_Y16 (tmp1, src->pixels + j * src->stride,
|
|
|
|
src->width, dest->width, &xacc, x_increment);
|
|
|
|
y1 = j;
|
|
|
|
xacc = 0;
|
|
|
|
vs_scanline_resample_linear_Y16 (tmp2,
|
|
|
|
src->pixels + (j + 1) * src->stride, src->width, dest->width, &xacc,
|
|
|
|
x_increment);
|
|
|
|
y2 = (j + 1);
|
|
|
|
vs_scanline_merge_linear_Y16 (dest->pixels + i * dest->stride,
|
|
|
|
tmp1, tmp2, dest->width, x);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
acc += y_increment;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-07-01 16:55:43 +00:00
|
|
|
/* RGB565 */
|
|
|
|
|
|
|
|
void
|
|
|
|
vs_image_scale_nearest_RGB565 (const VSImage * dest, const VSImage * src,
|
2006-11-14 23:08:38 +00:00
|
|
|
uint8_t * tmpbuf)
|
2005-07-01 16:55:43 +00:00
|
|
|
{
|
|
|
|
int acc;
|
|
|
|
int y_increment;
|
|
|
|
int x_increment;
|
|
|
|
int i;
|
|
|
|
int j;
|
|
|
|
int xacc;
|
|
|
|
|
gst/videoscale/: Support 1x1 images as input and output as for example the BBC HQ new streams have 1x1 GIFs in the pl...
Original commit message from CVS:
* gst/videoscale/gstvideoscale.c:
* gst/videoscale/vs_4tap.c: (vs_image_scale_4tap_Y):
* gst/videoscale/vs_image.c: (vs_image_scale_nearest_RGBA),
(vs_image_scale_linear_RGBA), (vs_image_scale_nearest_RGB),
(vs_image_scale_linear_RGB), (vs_image_scale_nearest_YUYV),
(vs_image_scale_linear_YUYV), (vs_image_scale_nearest_UYVY),
(vs_image_scale_linear_UYVY), (vs_image_scale_nearest_Y),
(vs_image_scale_linear_Y), (vs_image_scale_nearest_RGB565),
(vs_image_scale_linear_RGB565), (vs_image_scale_nearest_RGB555),
(vs_image_scale_linear_RGB555):
Support 1x1 images as input and output as for example the BBC HQ new
streams have 1x1 GIFs in the playlists for some reason.
2008-05-02 10:02:05 +00:00
|
|
|
if (dest->height == 1)
|
|
|
|
y_increment = 0;
|
|
|
|
else
|
|
|
|
y_increment = ((src->height - 1) << 16) / (dest->height - 1);
|
|
|
|
|
|
|
|
if (dest->width == 1)
|
|
|
|
x_increment = 0;
|
|
|
|
else
|
|
|
|
x_increment = ((src->width - 1) << 16) / (dest->width - 1);
|
2005-07-01 16:55:43 +00:00
|
|
|
|
|
|
|
acc = 0;
|
|
|
|
for (i = 0; i < dest->height; i++) {
|
|
|
|
j = acc >> 16;
|
|
|
|
|
|
|
|
xacc = 0;
|
|
|
|
vs_scanline_resample_nearest_RGB565 (dest->pixels + i * dest->stride,
|
2009-03-28 15:08:44 +00:00
|
|
|
src->pixels + j * src->stride, src->width, dest->width, &xacc,
|
|
|
|
x_increment);
|
2005-07-01 16:55:43 +00:00
|
|
|
|
|
|
|
acc += y_increment;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
vs_image_scale_linear_RGB565 (const VSImage * dest, const VSImage * src,
|
2006-11-14 23:08:38 +00:00
|
|
|
uint8_t * tmpbuf)
|
2005-07-01 16:55:43 +00:00
|
|
|
{
|
|
|
|
int acc;
|
|
|
|
int y_increment;
|
|
|
|
int x_increment;
|
2006-11-14 23:08:38 +00:00
|
|
|
uint8_t *tmp1;
|
|
|
|
uint8_t *tmp2;
|
2005-07-01 16:55:43 +00:00
|
|
|
int y1;
|
|
|
|
int y2;
|
|
|
|
int i;
|
|
|
|
int j;
|
|
|
|
int x;
|
|
|
|
int dest_size;
|
|
|
|
int xacc;
|
|
|
|
|
gst/videoscale/: Support 1x1 images as input and output as for example the BBC HQ new streams have 1x1 GIFs in the pl...
Original commit message from CVS:
* gst/videoscale/gstvideoscale.c:
* gst/videoscale/vs_4tap.c: (vs_image_scale_4tap_Y):
* gst/videoscale/vs_image.c: (vs_image_scale_nearest_RGBA),
(vs_image_scale_linear_RGBA), (vs_image_scale_nearest_RGB),
(vs_image_scale_linear_RGB), (vs_image_scale_nearest_YUYV),
(vs_image_scale_linear_YUYV), (vs_image_scale_nearest_UYVY),
(vs_image_scale_linear_UYVY), (vs_image_scale_nearest_Y),
(vs_image_scale_linear_Y), (vs_image_scale_nearest_RGB565),
(vs_image_scale_linear_RGB565), (vs_image_scale_nearest_RGB555),
(vs_image_scale_linear_RGB555):
Support 1x1 images as input and output as for example the BBC HQ new
streams have 1x1 GIFs in the playlists for some reason.
2008-05-02 10:02:05 +00:00
|
|
|
if (dest->height == 1)
|
|
|
|
y_increment = 0;
|
|
|
|
else
|
2011-04-23 20:42:23 +00:00
|
|
|
y_increment = ((src->height - 1) << 16) / (dest->height - 1) - 1;
|
gst/videoscale/: Support 1x1 images as input and output as for example the BBC HQ new streams have 1x1 GIFs in the pl...
Original commit message from CVS:
* gst/videoscale/gstvideoscale.c:
* gst/videoscale/vs_4tap.c: (vs_image_scale_4tap_Y):
* gst/videoscale/vs_image.c: (vs_image_scale_nearest_RGBA),
(vs_image_scale_linear_RGBA), (vs_image_scale_nearest_RGB),
(vs_image_scale_linear_RGB), (vs_image_scale_nearest_YUYV),
(vs_image_scale_linear_YUYV), (vs_image_scale_nearest_UYVY),
(vs_image_scale_linear_UYVY), (vs_image_scale_nearest_Y),
(vs_image_scale_linear_Y), (vs_image_scale_nearest_RGB565),
(vs_image_scale_linear_RGB565), (vs_image_scale_nearest_RGB555),
(vs_image_scale_linear_RGB555):
Support 1x1 images as input and output as for example the BBC HQ new
streams have 1x1 GIFs in the playlists for some reason.
2008-05-02 10:02:05 +00:00
|
|
|
|
|
|
|
if (dest->width == 1)
|
|
|
|
x_increment = 0;
|
|
|
|
else
|
2011-04-23 20:42:23 +00:00
|
|
|
x_increment = ((src->width - 1) << 16) / (dest->width - 1) - 1;
|
2005-07-01 16:55:43 +00:00
|
|
|
|
|
|
|
dest_size = dest->width * 2;
|
|
|
|
|
|
|
|
tmp1 = tmpbuf;
|
|
|
|
tmp2 = tmpbuf + dest_size;
|
|
|
|
|
|
|
|
acc = 0;
|
|
|
|
xacc = 0;
|
|
|
|
y2 = -1;
|
2009-03-28 15:08:44 +00:00
|
|
|
vs_scanline_resample_linear_RGB565 (tmp1, src->pixels, src->width,
|
|
|
|
dest->width, &xacc, x_increment);
|
2005-07-01 16:55:43 +00:00
|
|
|
y1 = 0;
|
|
|
|
for (i = 0; i < dest->height; i++) {
|
|
|
|
j = acc >> 16;
|
|
|
|
x = acc & 0xffff;
|
|
|
|
|
|
|
|
if (x == 0) {
|
|
|
|
if (j == y1) {
|
|
|
|
memcpy (dest->pixels + i * dest->stride, tmp1, dest_size);
|
|
|
|
} else if (j == y2) {
|
|
|
|
memcpy (dest->pixels + i * dest->stride, tmp2, dest_size);
|
|
|
|
} else {
|
|
|
|
xacc = 0;
|
|
|
|
vs_scanline_resample_linear_RGB565 (tmp1, src->pixels + j * src->stride,
|
2009-03-28 15:08:44 +00:00
|
|
|
src->width, dest->width, &xacc, x_increment);
|
2005-07-01 16:55:43 +00:00
|
|
|
y1 = j;
|
|
|
|
memcpy (dest->pixels + i * dest->stride, tmp1, dest_size);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (j == y1) {
|
|
|
|
if (j + 1 != y2) {
|
|
|
|
xacc = 0;
|
|
|
|
vs_scanline_resample_linear_RGB565 (tmp2,
|
2009-03-28 15:08:44 +00:00
|
|
|
src->pixels + (j + 1) * src->stride, src->width, dest->width,
|
|
|
|
&xacc, x_increment);
|
2005-07-01 16:55:43 +00:00
|
|
|
y2 = j + 1;
|
|
|
|
}
|
|
|
|
vs_scanline_merge_linear_RGB565 (dest->pixels + i * dest->stride,
|
|
|
|
tmp1, tmp2, dest->width, x);
|
|
|
|
} else if (j == y2) {
|
|
|
|
if (j + 1 != y1) {
|
|
|
|
xacc = 0;
|
|
|
|
vs_scanline_resample_linear_RGB565 (tmp1,
|
2009-03-28 15:08:44 +00:00
|
|
|
src->pixels + (j + 1) * src->stride, src->width, dest->width,
|
|
|
|
&xacc, x_increment);
|
2005-07-01 16:55:43 +00:00
|
|
|
y1 = j + 1;
|
|
|
|
}
|
|
|
|
vs_scanline_merge_linear_RGB565 (dest->pixels + i * dest->stride,
|
|
|
|
tmp2, tmp1, dest->width, x);
|
|
|
|
} else {
|
|
|
|
xacc = 0;
|
|
|
|
vs_scanline_resample_linear_RGB565 (tmp1, src->pixels + j * src->stride,
|
2009-03-28 15:08:44 +00:00
|
|
|
src->width, dest->width, &xacc, x_increment);
|
2005-07-01 16:55:43 +00:00
|
|
|
y1 = j;
|
|
|
|
xacc = 0;
|
|
|
|
vs_scanline_resample_linear_RGB565 (tmp2,
|
2009-03-28 15:08:44 +00:00
|
|
|
src->pixels + (j + 1) * src->stride, src->width, dest->width, &xacc,
|
2005-07-01 16:55:43 +00:00
|
|
|
x_increment);
|
|
|
|
y2 = (j + 1);
|
|
|
|
vs_scanline_merge_linear_RGB565 (dest->pixels + i * dest->stride,
|
|
|
|
tmp1, tmp2, dest->width, x);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
acc += y_increment;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* RGB555 */
|
|
|
|
|
|
|
|
void
|
|
|
|
vs_image_scale_nearest_RGB555 (const VSImage * dest, const VSImage * src,
|
2006-11-14 23:08:38 +00:00
|
|
|
uint8_t * tmpbuf)
|
2005-07-01 16:55:43 +00:00
|
|
|
{
|
|
|
|
int acc;
|
|
|
|
int y_increment;
|
|
|
|
int x_increment;
|
|
|
|
int i;
|
|
|
|
int j;
|
|
|
|
int xacc;
|
|
|
|
|
gst/videoscale/: Support 1x1 images as input and output as for example the BBC HQ new streams have 1x1 GIFs in the pl...
Original commit message from CVS:
* gst/videoscale/gstvideoscale.c:
* gst/videoscale/vs_4tap.c: (vs_image_scale_4tap_Y):
* gst/videoscale/vs_image.c: (vs_image_scale_nearest_RGBA),
(vs_image_scale_linear_RGBA), (vs_image_scale_nearest_RGB),
(vs_image_scale_linear_RGB), (vs_image_scale_nearest_YUYV),
(vs_image_scale_linear_YUYV), (vs_image_scale_nearest_UYVY),
(vs_image_scale_linear_UYVY), (vs_image_scale_nearest_Y),
(vs_image_scale_linear_Y), (vs_image_scale_nearest_RGB565),
(vs_image_scale_linear_RGB565), (vs_image_scale_nearest_RGB555),
(vs_image_scale_linear_RGB555):
Support 1x1 images as input and output as for example the BBC HQ new
streams have 1x1 GIFs in the playlists for some reason.
2008-05-02 10:02:05 +00:00
|
|
|
if (dest->height == 1)
|
|
|
|
y_increment = 0;
|
|
|
|
else
|
|
|
|
y_increment = ((src->height - 1) << 16) / (dest->height - 1);
|
|
|
|
|
|
|
|
if (dest->width == 1)
|
|
|
|
x_increment = 0;
|
|
|
|
else
|
|
|
|
x_increment = ((src->width - 1) << 16) / (dest->width - 1);
|
2005-07-01 16:55:43 +00:00
|
|
|
|
|
|
|
acc = 0;
|
|
|
|
for (i = 0; i < dest->height; i++) {
|
|
|
|
j = acc >> 16;
|
|
|
|
|
|
|
|
xacc = 0;
|
|
|
|
vs_scanline_resample_nearest_RGB555 (dest->pixels + i * dest->stride,
|
2009-03-28 15:08:44 +00:00
|
|
|
src->pixels + j * src->stride, src->width, dest->width, &xacc,
|
|
|
|
x_increment);
|
2005-07-01 16:55:43 +00:00
|
|
|
|
|
|
|
acc += y_increment;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
vs_image_scale_linear_RGB555 (const VSImage * dest, const VSImage * src,
|
2006-11-14 23:08:38 +00:00
|
|
|
uint8_t * tmpbuf)
|
2005-07-01 16:55:43 +00:00
|
|
|
{
|
|
|
|
int acc;
|
|
|
|
int y_increment;
|
|
|
|
int x_increment;
|
2006-11-14 23:08:38 +00:00
|
|
|
uint8_t *tmp1;
|
|
|
|
uint8_t *tmp2;
|
2005-07-01 16:55:43 +00:00
|
|
|
int y1;
|
|
|
|
int y2;
|
|
|
|
int i;
|
|
|
|
int j;
|
|
|
|
int x;
|
|
|
|
int dest_size;
|
|
|
|
int xacc;
|
|
|
|
|
gst/videoscale/: Support 1x1 images as input and output as for example the BBC HQ new streams have 1x1 GIFs in the pl...
Original commit message from CVS:
* gst/videoscale/gstvideoscale.c:
* gst/videoscale/vs_4tap.c: (vs_image_scale_4tap_Y):
* gst/videoscale/vs_image.c: (vs_image_scale_nearest_RGBA),
(vs_image_scale_linear_RGBA), (vs_image_scale_nearest_RGB),
(vs_image_scale_linear_RGB), (vs_image_scale_nearest_YUYV),
(vs_image_scale_linear_YUYV), (vs_image_scale_nearest_UYVY),
(vs_image_scale_linear_UYVY), (vs_image_scale_nearest_Y),
(vs_image_scale_linear_Y), (vs_image_scale_nearest_RGB565),
(vs_image_scale_linear_RGB565), (vs_image_scale_nearest_RGB555),
(vs_image_scale_linear_RGB555):
Support 1x1 images as input and output as for example the BBC HQ new
streams have 1x1 GIFs in the playlists for some reason.
2008-05-02 10:02:05 +00:00
|
|
|
if (dest->height == 1)
|
|
|
|
y_increment = 0;
|
|
|
|
else
|
2011-04-23 20:42:23 +00:00
|
|
|
y_increment = ((src->height - 1) << 16) / (dest->height - 1) - 1;
|
gst/videoscale/: Support 1x1 images as input and output as for example the BBC HQ new streams have 1x1 GIFs in the pl...
Original commit message from CVS:
* gst/videoscale/gstvideoscale.c:
* gst/videoscale/vs_4tap.c: (vs_image_scale_4tap_Y):
* gst/videoscale/vs_image.c: (vs_image_scale_nearest_RGBA),
(vs_image_scale_linear_RGBA), (vs_image_scale_nearest_RGB),
(vs_image_scale_linear_RGB), (vs_image_scale_nearest_YUYV),
(vs_image_scale_linear_YUYV), (vs_image_scale_nearest_UYVY),
(vs_image_scale_linear_UYVY), (vs_image_scale_nearest_Y),
(vs_image_scale_linear_Y), (vs_image_scale_nearest_RGB565),
(vs_image_scale_linear_RGB565), (vs_image_scale_nearest_RGB555),
(vs_image_scale_linear_RGB555):
Support 1x1 images as input and output as for example the BBC HQ new
streams have 1x1 GIFs in the playlists for some reason.
2008-05-02 10:02:05 +00:00
|
|
|
|
|
|
|
if (dest->width == 1)
|
|
|
|
x_increment = 0;
|
|
|
|
else
|
2011-04-23 20:42:23 +00:00
|
|
|
x_increment = ((src->width - 1) << 16) / (dest->width - 1) - 1;
|
2005-07-01 16:55:43 +00:00
|
|
|
|
|
|
|
dest_size = dest->width * 2;
|
|
|
|
|
|
|
|
tmp1 = tmpbuf;
|
|
|
|
tmp2 = tmpbuf + dest_size;
|
|
|
|
|
|
|
|
acc = 0;
|
|
|
|
xacc = 0;
|
|
|
|
y2 = -1;
|
2009-03-28 15:08:44 +00:00
|
|
|
vs_scanline_resample_linear_RGB555 (tmp1, src->pixels, src->width,
|
|
|
|
dest->width, &xacc, x_increment);
|
2005-07-01 16:55:43 +00:00
|
|
|
y1 = 0;
|
|
|
|
for (i = 0; i < dest->height; i++) {
|
|
|
|
j = acc >> 16;
|
|
|
|
x = acc & 0xffff;
|
|
|
|
|
|
|
|
if (x == 0) {
|
|
|
|
if (j == y1) {
|
|
|
|
memcpy (dest->pixels + i * dest->stride, tmp1, dest_size);
|
|
|
|
} else if (j == y2) {
|
|
|
|
memcpy (dest->pixels + i * dest->stride, tmp2, dest_size);
|
|
|
|
} else {
|
|
|
|
xacc = 0;
|
|
|
|
vs_scanline_resample_linear_RGB555 (tmp1, src->pixels + j * src->stride,
|
2009-03-28 15:08:44 +00:00
|
|
|
src->width, dest->width, &xacc, x_increment);
|
2005-07-01 16:55:43 +00:00
|
|
|
y1 = j;
|
|
|
|
memcpy (dest->pixels + i * dest->stride, tmp1, dest_size);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (j == y1) {
|
|
|
|
if (j + 1 != y2) {
|
|
|
|
xacc = 0;
|
|
|
|
vs_scanline_resample_linear_RGB555 (tmp2,
|
2009-03-28 15:08:44 +00:00
|
|
|
src->pixels + (j + 1) * src->stride, src->width, dest->width,
|
|
|
|
&xacc, x_increment);
|
2005-07-01 16:55:43 +00:00
|
|
|
y2 = j + 1;
|
|
|
|
}
|
|
|
|
vs_scanline_merge_linear_RGB555 (dest->pixels + i * dest->stride,
|
|
|
|
tmp1, tmp2, dest->width, x);
|
|
|
|
} else if (j == y2) {
|
|
|
|
if (j + 1 != y1) {
|
|
|
|
xacc = 0;
|
|
|
|
vs_scanline_resample_linear_RGB555 (tmp1,
|
2009-03-28 15:08:44 +00:00
|
|
|
src->pixels + (j + 1) * src->stride, src->width, dest->width,
|
|
|
|
&xacc, x_increment);
|
2005-07-01 16:55:43 +00:00
|
|
|
y1 = j + 1;
|
|
|
|
}
|
|
|
|
vs_scanline_merge_linear_RGB555 (dest->pixels + i * dest->stride,
|
|
|
|
tmp2, tmp1, dest->width, x);
|
|
|
|
} else {
|
|
|
|
xacc = 0;
|
|
|
|
vs_scanline_resample_linear_RGB555 (tmp1, src->pixels + j * src->stride,
|
2009-03-28 15:08:44 +00:00
|
|
|
src->width, dest->width, &xacc, x_increment);
|
2005-07-01 16:55:43 +00:00
|
|
|
y1 = j;
|
|
|
|
xacc = 0;
|
|
|
|
vs_scanline_resample_linear_RGB555 (tmp2,
|
2009-03-28 15:08:44 +00:00
|
|
|
src->pixels + (j + 1) * src->stride, src->width, dest->width, &xacc,
|
2005-07-01 16:55:43 +00:00
|
|
|
x_increment);
|
|
|
|
y2 = (j + 1);
|
|
|
|
vs_scanline_merge_linear_RGB555 (dest->pixels + i * dest->stride,
|
|
|
|
tmp1, tmp2, dest->width, x);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
acc += y_increment;
|
|
|
|
}
|
|
|
|
}
|
2011-02-20 02:50:37 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
vs_image_scale_nearest_AYUV64 (const VSImage * dest, const VSImage * src,
|
|
|
|
uint8_t * tmpbuf8)
|
|
|
|
{
|
|
|
|
int acc;
|
|
|
|
int y_increment;
|
|
|
|
int x_increment;
|
|
|
|
int i;
|
|
|
|
int j;
|
|
|
|
int prev_j;
|
|
|
|
|
|
|
|
if (dest->height == 1)
|
|
|
|
y_increment = 0;
|
|
|
|
else
|
|
|
|
y_increment = ((src->height - 1) << 16) / (dest->height - 1);
|
|
|
|
|
|
|
|
if (dest->width == 1)
|
|
|
|
x_increment = 0;
|
|
|
|
else
|
|
|
|
x_increment = ((src->width - 1) << 16) / (dest->width - 1);
|
|
|
|
|
|
|
|
|
|
|
|
acc = 0;
|
|
|
|
prev_j = -1;
|
|
|
|
for (i = 0; i < dest->height; i++) {
|
|
|
|
j = acc >> 16;
|
|
|
|
|
|
|
|
if (j == prev_j) {
|
|
|
|
memcpy (dest->pixels + i * dest->stride,
|
|
|
|
dest->pixels + (i - 1) * dest->stride, dest->width * 8);
|
|
|
|
} else {
|
|
|
|
int xacc = 0;
|
|
|
|
vs_scanline_resample_nearest_AYUV64 (dest->pixels + i * dest->stride,
|
|
|
|
src->pixels + j * src->stride, src->width, dest->width, &xacc,
|
|
|
|
x_increment);
|
|
|
|
}
|
|
|
|
|
|
|
|
prev_j = j;
|
|
|
|
acc += y_increment;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
vs_image_scale_linear_AYUV64 (const VSImage * dest, const VSImage * src,
|
|
|
|
uint8_t * tmpbuf)
|
|
|
|
{
|
|
|
|
int acc;
|
|
|
|
int y_increment;
|
|
|
|
int x_increment;
|
|
|
|
int y1;
|
|
|
|
int i;
|
|
|
|
int j;
|
|
|
|
int x;
|
|
|
|
int dest_size;
|
|
|
|
int xacc;
|
|
|
|
|
|
|
|
if (dest->height == 1)
|
|
|
|
y_increment = 0;
|
|
|
|
else
|
2011-04-23 20:42:23 +00:00
|
|
|
y_increment = ((src->height - 1) << 16) / (dest->height - 1) - 1;
|
2011-02-20 02:50:37 +00:00
|
|
|
|
|
|
|
if (dest->width == 1)
|
|
|
|
x_increment = 0;
|
|
|
|
else
|
2011-04-23 20:42:23 +00:00
|
|
|
x_increment = ((src->width - 1) << 16) / (dest->width - 1) - 1;
|
2011-02-20 02:50:37 +00:00
|
|
|
|
|
|
|
dest_size = dest->width * 8;
|
|
|
|
|
|
|
|
#undef LINE
|
|
|
|
#define LINE(x) ((guint16 *)((tmpbuf) + (dest_size)*((x)&1)))
|
|
|
|
|
|
|
|
acc = 0;
|
|
|
|
//gst_videoscale_orc_resample_bilinear_u64 (LINE (0), src->pixels,
|
|
|
|
// 0, x_increment, dest->width);
|
|
|
|
xacc = 0;
|
|
|
|
vs_scanline_resample_linear_AYUV64 ((guint8 *) LINE (0),
|
|
|
|
src->pixels, src->width, dest->width, &xacc, x_increment);
|
|
|
|
y1 = 0;
|
|
|
|
for (i = 0; i < dest->height; i++) {
|
|
|
|
j = acc >> 16;
|
|
|
|
x = acc & 0xffff;
|
|
|
|
|
|
|
|
if (x == 0) {
|
|
|
|
memcpy (dest->pixels + i * dest->stride, LINE (j), dest_size);
|
|
|
|
} else {
|
|
|
|
if (j > y1) {
|
|
|
|
xacc = 0;
|
|
|
|
vs_scanline_resample_linear_AYUV64 ((guint8 *) LINE (j),
|
|
|
|
src->pixels + j * src->stride, src->width, dest->width, &xacc,
|
|
|
|
x_increment);
|
|
|
|
//gst_videoscale_orc_resample_bilinear_u64 (LINE (j),
|
|
|
|
// src->pixels + j * src->stride, 0, x_increment, dest->width);
|
|
|
|
y1++;
|
|
|
|
}
|
|
|
|
if (j >= y1) {
|
|
|
|
xacc = 0;
|
|
|
|
vs_scanline_resample_linear_AYUV64 ((guint8 *) LINE (j + 1),
|
|
|
|
src->pixels + (j + 1) * src->stride, src->width, dest->width, &xacc,
|
|
|
|
x_increment);
|
|
|
|
orc_merge_linear_u16 ((guint16 *) (dest->pixels + i * dest->stride),
|
|
|
|
LINE (j), LINE (j + 1), 65536 - x, x, dest->width * 4);
|
|
|
|
//gst_videoscale_orc_resample_merge_bilinear_u64 (dest->pixels +
|
|
|
|
// i * dest->stride, LINE (j + 1), LINE (j),
|
|
|
|
// src->pixels + (j + 1) * src->stride, (x >> 8), 0, x_increment,
|
|
|
|
// dest->width);
|
|
|
|
y1++;
|
|
|
|
} else {
|
|
|
|
orc_merge_linear_u16 ((guint16 *) (dest->pixels + i * dest->stride),
|
|
|
|
LINE (j), LINE (j + 1), 65536 - x, x, dest->width * 4);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
acc += y_increment;
|
|
|
|
}
|
|
|
|
}
|