2006-11-14 23:08:38 +00:00
|
|
|
/*
|
|
|
|
* Image Scaling Functions (4 tap)
|
|
|
|
* Copyright (c) 2005 David A. Schleef <ds@schleef.org>
|
2009-03-27 12:15:11 +00:00
|
|
|
* Copyright (c) 2009 Sebastian Dröge <sebastian.droege@collabora.co.uk>
|
2006-11-14 23:08:38 +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 "vs_image.h"
|
|
|
|
#include "vs_scanline.h"
|
|
|
|
|
Correct all relevant warnings found by the sparse semantic code analyzer. This include marking several symbols static...
Original commit message from CVS:
* ext/alsa/gstalsamixertrack.c: (gst_alsa_mixer_track_get_type):
* ext/alsa/gstalsasink.c: (set_hwparams):
* ext/alsa/gstalsasrc.c: (set_hwparams):
* ext/gio/gstgio.c: (gst_gio_uri_handler_get_uri):
* ext/ogg/gstoggmux.h:
* ext/ogg/gstogmparse.c:
* gst-libs/gst/audio/audio.c:
* gst-libs/gst/fft/kiss_fft_f64.c: (kiss_fft_f64_alloc):
* gst-libs/gst/pbutils/missing-plugins.c:
(gst_missing_uri_sink_message_new),
(gst_missing_element_message_new),
(gst_missing_decoder_message_new),
(gst_missing_encoder_message_new):
* gst-libs/gst/rtp/gstbasertppayload.c:
* gst-libs/gst/rtp/gstrtcpbuffer.c:
(gst_rtcp_packet_bye_get_reason):
* gst/audioconvert/gstaudioconvert.c:
* gst/audioresample/gstaudioresample.c:
* gst/ffmpegcolorspace/imgconvert.c:
* gst/playback/test.c: (gen_video_element), (gen_audio_element):
* gst/typefind/gsttypefindfunctions.c:
* gst/videoscale/vs_4tap.c:
* gst/videoscale/vs_4tap.h:
* sys/v4l/gstv4lelement.c:
* sys/v4l/gstv4lsrc.c: (gst_v4lsrc_get_any_caps):
* sys/v4l/v4l_calls.c:
* sys/v4l/v4lsrc_calls.c: (gst_v4lsrc_capture_init),
(gst_v4lsrc_try_capture):
* sys/ximage/ximagesink.c: (gst_ximagesink_check_xshm_calls),
(gst_ximagesink_ximage_new):
* sys/xvimage/xvimagesink.c: (gst_xvimagesink_check_xshm_calls),
(gst_xvimagesink_xvimage_new):
* tests/check/elements/audioconvert.c:
* tests/check/elements/audioresample.c:
(fail_unless_perfect_stream):
* tests/check/elements/audiotestsrc.c: (setup_audiotestsrc):
* tests/check/elements/decodebin.c:
* tests/check/elements/gdpdepay.c: (setup_gdpdepay),
(setup_gdpdepay_streamheader):
* tests/check/elements/gdppay.c: (setup_gdppay), (GST_START_TEST),
(setup_gdppay_streamheader):
* tests/check/elements/gnomevfssink.c: (setup_gnomevfssink):
* tests/check/elements/multifdsink.c: (setup_multifdsink):
* tests/check/elements/textoverlay.c:
* tests/check/elements/videorate.c: (setup_videorate):
* tests/check/elements/videotestsrc.c: (setup_videotestsrc):
* tests/check/elements/volume.c: (setup_volume):
* tests/check/elements/vorbisdec.c: (setup_vorbisdec):
* tests/check/elements/vorbistag.c:
* tests/check/generic/clock-selection.c:
* tests/check/generic/states.c: (setup), (teardown):
* tests/check/libs/cddabasesrc.c:
* tests/check/libs/video.c:
* tests/check/pipelines/gio.c:
* tests/check/pipelines/oggmux.c:
* tests/check/pipelines/simple-launch-lines.c:
(simple_launch_lines_suite):
* tests/check/pipelines/streamheader.c:
* tests/check/pipelines/theoraenc.c:
* tests/check/pipelines/vorbisdec.c:
* tests/check/pipelines/vorbisenc.c:
* tests/examples/seek/scrubby.c:
* tests/examples/seek/seek.c: (query_positions_elems),
(query_positions_pads):
* tests/icles/stress-xoverlay.c: (myclock):
Correct all relevant warnings found by the sparse semantic code
analyzer. This include marking several symbols static, using
NULL instead of 0 for pointers and using "foo (void)" instead
of "foo ()" for declarations.
* win32/common/libgstrtp.def:
Add gst_rtp_buffer_set_extension_data to the symbol definition file.
2008-03-03 06:04:31 +00:00
|
|
|
#include "vs_4tap.h"
|
|
|
|
|
2010-10-05 18:15:47 +00:00
|
|
|
#include <gst/math-compat.h>
|
2006-11-14 23:08:38 +00:00
|
|
|
|
|
|
|
#define SHIFT 10
|
|
|
|
|
Correct all relevant warnings found by the sparse semantic code analyzer. This include marking several symbols static...
Original commit message from CVS:
* ext/alsa/gstalsamixertrack.c: (gst_alsa_mixer_track_get_type):
* ext/alsa/gstalsasink.c: (set_hwparams):
* ext/alsa/gstalsasrc.c: (set_hwparams):
* ext/gio/gstgio.c: (gst_gio_uri_handler_get_uri):
* ext/ogg/gstoggmux.h:
* ext/ogg/gstogmparse.c:
* gst-libs/gst/audio/audio.c:
* gst-libs/gst/fft/kiss_fft_f64.c: (kiss_fft_f64_alloc):
* gst-libs/gst/pbutils/missing-plugins.c:
(gst_missing_uri_sink_message_new),
(gst_missing_element_message_new),
(gst_missing_decoder_message_new),
(gst_missing_encoder_message_new):
* gst-libs/gst/rtp/gstbasertppayload.c:
* gst-libs/gst/rtp/gstrtcpbuffer.c:
(gst_rtcp_packet_bye_get_reason):
* gst/audioconvert/gstaudioconvert.c:
* gst/audioresample/gstaudioresample.c:
* gst/ffmpegcolorspace/imgconvert.c:
* gst/playback/test.c: (gen_video_element), (gen_audio_element):
* gst/typefind/gsttypefindfunctions.c:
* gst/videoscale/vs_4tap.c:
* gst/videoscale/vs_4tap.h:
* sys/v4l/gstv4lelement.c:
* sys/v4l/gstv4lsrc.c: (gst_v4lsrc_get_any_caps):
* sys/v4l/v4l_calls.c:
* sys/v4l/v4lsrc_calls.c: (gst_v4lsrc_capture_init),
(gst_v4lsrc_try_capture):
* sys/ximage/ximagesink.c: (gst_ximagesink_check_xshm_calls),
(gst_ximagesink_ximage_new):
* sys/xvimage/xvimagesink.c: (gst_xvimagesink_check_xshm_calls),
(gst_xvimagesink_xvimage_new):
* tests/check/elements/audioconvert.c:
* tests/check/elements/audioresample.c:
(fail_unless_perfect_stream):
* tests/check/elements/audiotestsrc.c: (setup_audiotestsrc):
* tests/check/elements/decodebin.c:
* tests/check/elements/gdpdepay.c: (setup_gdpdepay),
(setup_gdpdepay_streamheader):
* tests/check/elements/gdppay.c: (setup_gdppay), (GST_START_TEST),
(setup_gdppay_streamheader):
* tests/check/elements/gnomevfssink.c: (setup_gnomevfssink):
* tests/check/elements/multifdsink.c: (setup_multifdsink):
* tests/check/elements/textoverlay.c:
* tests/check/elements/videorate.c: (setup_videorate):
* tests/check/elements/videotestsrc.c: (setup_videotestsrc):
* tests/check/elements/volume.c: (setup_volume):
* tests/check/elements/vorbisdec.c: (setup_vorbisdec):
* tests/check/elements/vorbistag.c:
* tests/check/generic/clock-selection.c:
* tests/check/generic/states.c: (setup), (teardown):
* tests/check/libs/cddabasesrc.c:
* tests/check/libs/video.c:
* tests/check/pipelines/gio.c:
* tests/check/pipelines/oggmux.c:
* tests/check/pipelines/simple-launch-lines.c:
(simple_launch_lines_suite):
* tests/check/pipelines/streamheader.c:
* tests/check/pipelines/theoraenc.c:
* tests/check/pipelines/vorbisdec.c:
* tests/check/pipelines/vorbisenc.c:
* tests/examples/seek/scrubby.c:
* tests/examples/seek/seek.c: (query_positions_elems),
(query_positions_pads):
* tests/icles/stress-xoverlay.c: (myclock):
Correct all relevant warnings found by the sparse semantic code
analyzer. This include marking several symbols static, using
NULL instead of 0 for pointers and using "foo (void)" instead
of "foo ()" for declarations.
* win32/common/libgstrtp.def:
Add gst_rtp_buffer_set_extension_data to the symbol definition file.
2008-03-03 06:04:31 +00:00
|
|
|
static int16_t vs_4tap_taps[256][4];
|
2006-11-14 23:08:38 +00:00
|
|
|
|
Correct all relevant warnings found by the sparse semantic code analyzer. This include marking several symbols static...
Original commit message from CVS:
* ext/alsa/gstalsamixertrack.c: (gst_alsa_mixer_track_get_type):
* ext/alsa/gstalsasink.c: (set_hwparams):
* ext/alsa/gstalsasrc.c: (set_hwparams):
* ext/gio/gstgio.c: (gst_gio_uri_handler_get_uri):
* ext/ogg/gstoggmux.h:
* ext/ogg/gstogmparse.c:
* gst-libs/gst/audio/audio.c:
* gst-libs/gst/fft/kiss_fft_f64.c: (kiss_fft_f64_alloc):
* gst-libs/gst/pbutils/missing-plugins.c:
(gst_missing_uri_sink_message_new),
(gst_missing_element_message_new),
(gst_missing_decoder_message_new),
(gst_missing_encoder_message_new):
* gst-libs/gst/rtp/gstbasertppayload.c:
* gst-libs/gst/rtp/gstrtcpbuffer.c:
(gst_rtcp_packet_bye_get_reason):
* gst/audioconvert/gstaudioconvert.c:
* gst/audioresample/gstaudioresample.c:
* gst/ffmpegcolorspace/imgconvert.c:
* gst/playback/test.c: (gen_video_element), (gen_audio_element):
* gst/typefind/gsttypefindfunctions.c:
* gst/videoscale/vs_4tap.c:
* gst/videoscale/vs_4tap.h:
* sys/v4l/gstv4lelement.c:
* sys/v4l/gstv4lsrc.c: (gst_v4lsrc_get_any_caps):
* sys/v4l/v4l_calls.c:
* sys/v4l/v4lsrc_calls.c: (gst_v4lsrc_capture_init),
(gst_v4lsrc_try_capture):
* sys/ximage/ximagesink.c: (gst_ximagesink_check_xshm_calls),
(gst_ximagesink_ximage_new):
* sys/xvimage/xvimagesink.c: (gst_xvimagesink_check_xshm_calls),
(gst_xvimagesink_xvimage_new):
* tests/check/elements/audioconvert.c:
* tests/check/elements/audioresample.c:
(fail_unless_perfect_stream):
* tests/check/elements/audiotestsrc.c: (setup_audiotestsrc):
* tests/check/elements/decodebin.c:
* tests/check/elements/gdpdepay.c: (setup_gdpdepay),
(setup_gdpdepay_streamheader):
* tests/check/elements/gdppay.c: (setup_gdppay), (GST_START_TEST),
(setup_gdppay_streamheader):
* tests/check/elements/gnomevfssink.c: (setup_gnomevfssink):
* tests/check/elements/multifdsink.c: (setup_multifdsink):
* tests/check/elements/textoverlay.c:
* tests/check/elements/videorate.c: (setup_videorate):
* tests/check/elements/videotestsrc.c: (setup_videotestsrc):
* tests/check/elements/volume.c: (setup_volume):
* tests/check/elements/vorbisdec.c: (setup_vorbisdec):
* tests/check/elements/vorbistag.c:
* tests/check/generic/clock-selection.c:
* tests/check/generic/states.c: (setup), (teardown):
* tests/check/libs/cddabasesrc.c:
* tests/check/libs/video.c:
* tests/check/pipelines/gio.c:
* tests/check/pipelines/oggmux.c:
* tests/check/pipelines/simple-launch-lines.c:
(simple_launch_lines_suite):
* tests/check/pipelines/streamheader.c:
* tests/check/pipelines/theoraenc.c:
* tests/check/pipelines/vorbisdec.c:
* tests/check/pipelines/vorbisenc.c:
* tests/examples/seek/scrubby.c:
* tests/examples/seek/seek.c: (query_positions_elems),
(query_positions_pads):
* tests/icles/stress-xoverlay.c: (myclock):
Correct all relevant warnings found by the sparse semantic code
analyzer. This include marking several symbols static, using
NULL instead of 0 for pointers and using "foo (void)" instead
of "foo ()" for declarations.
* win32/common/libgstrtp.def:
Add gst_rtp_buffer_set_extension_data to the symbol definition file.
2008-03-03 06:04:31 +00:00
|
|
|
static double
|
2006-11-14 23:08:38 +00:00
|
|
|
vs_4tap_func (double x)
|
|
|
|
{
|
|
|
|
#if 0
|
|
|
|
if (x < -1)
|
|
|
|
return 0;
|
|
|
|
if (x > 1)
|
|
|
|
return 0;
|
|
|
|
if (x < 0)
|
|
|
|
return 1 + x;
|
|
|
|
return 1 - x;
|
|
|
|
#endif
|
|
|
|
#if 0
|
|
|
|
if (x == 0)
|
|
|
|
return 1;
|
2011-06-01 05:14:09 +00:00
|
|
|
return sin (G_PI * x) / (G_PI * x) * (1 - 0.25 * x * x);
|
2006-11-14 23:08:38 +00:00
|
|
|
#endif
|
|
|
|
#if 1
|
|
|
|
if (x == 0)
|
|
|
|
return 1;
|
2011-06-01 05:14:09 +00:00
|
|
|
return sin (G_PI * x) / (G_PI * x);
|
2006-11-14 23:08:38 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
vs_4tap_init (void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
double a, b, c, d;
|
|
|
|
double sum;
|
|
|
|
|
|
|
|
for (i = 0; i < 256; i++) {
|
|
|
|
a = vs_4tap_func (-1 - i / 256.0);
|
|
|
|
b = vs_4tap_func (0 - i / 256.0);
|
|
|
|
c = vs_4tap_func (1 - i / 256.0);
|
|
|
|
d = vs_4tap_func (2 - i / 256.0);
|
|
|
|
sum = a + b + c + d;
|
|
|
|
|
|
|
|
vs_4tap_taps[i][0] = rint ((1 << SHIFT) * (a / sum));
|
|
|
|
vs_4tap_taps[i][1] = rint ((1 << SHIFT) * (b / sum));
|
|
|
|
vs_4tap_taps[i][2] = rint ((1 << SHIFT) * (c / sum));
|
|
|
|
vs_4tap_taps[i][3] = rint ((1 << SHIFT) * (d / sum));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
vs_scanline_resample_4tap_Y (uint8_t * dest, uint8_t * src,
|
2008-01-14 01:19:34 +00:00
|
|
|
int n, int src_width, int *xacc, int increment)
|
2006-11-14 23:08:38 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int j;
|
|
|
|
int acc;
|
|
|
|
int x;
|
|
|
|
int y;
|
|
|
|
|
|
|
|
acc = *xacc;
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
j = acc >> 16;
|
|
|
|
x = (acc & 0xff00) >> 8;
|
2008-01-14 01:19:34 +00:00
|
|
|
if (j - 1 >= 0 && j + 2 < src_width) {
|
|
|
|
y = vs_4tap_taps[x][0] * src[MAX (j - 1, 0)];
|
|
|
|
y += vs_4tap_taps[x][1] * src[j];
|
|
|
|
y += vs_4tap_taps[x][2] * src[j + 1];
|
|
|
|
y += vs_4tap_taps[x][3] * src[j + 2];
|
|
|
|
} else {
|
|
|
|
y = vs_4tap_taps[x][0] * src[CLAMP (j - 1, 0, src_width - 1)];
|
|
|
|
y += vs_4tap_taps[x][1] * src[CLAMP (j, 0, src_width - 1)];
|
|
|
|
y += vs_4tap_taps[x][2] * src[CLAMP (j + 1, 0, src_width - 1)];
|
|
|
|
y += vs_4tap_taps[x][3] * src[CLAMP (j + 2, 0, src_width - 1)];
|
|
|
|
}
|
|
|
|
y += (1 << (SHIFT - 1));
|
|
|
|
dest[i] = CLAMP (y >> SHIFT, 0, 255);
|
2006-11-14 23:08:38 +00:00
|
|
|
acc += increment;
|
|
|
|
}
|
|
|
|
*xacc = acc;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
vs_scanline_merge_4tap_Y (uint8_t * dest, uint8_t * src1, uint8_t * src2,
|
|
|
|
uint8_t * src3, uint8_t * src4, int n, int acc)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int y;
|
2008-01-14 01:19:34 +00:00
|
|
|
int a, b, c, d;
|
2006-11-14 23:08:38 +00:00
|
|
|
|
|
|
|
acc = (acc >> 8) & 0xff;
|
2008-01-14 01:19:34 +00:00
|
|
|
a = vs_4tap_taps[acc][0];
|
|
|
|
b = vs_4tap_taps[acc][1];
|
|
|
|
c = vs_4tap_taps[acc][2];
|
|
|
|
d = vs_4tap_taps[acc][3];
|
2006-11-14 23:08:38 +00:00
|
|
|
for (i = 0; i < n; i++) {
|
2008-01-14 01:19:34 +00:00
|
|
|
y = a * src1[i];
|
|
|
|
y += b * src2[i];
|
|
|
|
y += c * src3[i];
|
|
|
|
y += d * src4[i];
|
|
|
|
y += (1 << (SHIFT - 1));
|
|
|
|
dest[i] = CLAMP (y >> SHIFT, 0, 255);
|
2006-11-14 23:08:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
vs_image_scale_4tap_Y (const VSImage * dest, const VSImage * src,
|
|
|
|
uint8_t * tmpbuf)
|
|
|
|
{
|
|
|
|
int yacc;
|
|
|
|
int y_increment;
|
|
|
|
int x_increment;
|
|
|
|
int i;
|
|
|
|
int j;
|
|
|
|
int xacc;
|
|
|
|
int k;
|
|
|
|
|
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);
|
2006-11-14 23:08:38 +00:00
|
|
|
|
|
|
|
k = 0;
|
|
|
|
for (i = 0; i < 4; i++) {
|
|
|
|
xacc = 0;
|
|
|
|
vs_scanline_resample_4tap_Y (tmpbuf + i * dest->width,
|
2011-04-23 19:46:09 +00:00
|
|
|
src->pixels + CLAMP (i, 0, src->height - 1) * src->stride, dest->width,
|
|
|
|
src->width, &xacc, x_increment);
|
2006-11-14 23:08:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
yacc = 0;
|
|
|
|
for (i = 0; i < dest->height; i++) {
|
|
|
|
uint8_t *t0, *t1, *t2, *t3;
|
|
|
|
|
|
|
|
j = yacc >> 16;
|
|
|
|
|
2007-06-15 15:23:36 +00:00
|
|
|
while (j > k) {
|
2006-11-14 23:08:38 +00:00
|
|
|
k++;
|
|
|
|
if (k + 3 < src->height) {
|
|
|
|
xacc = 0;
|
|
|
|
vs_scanline_resample_4tap_Y (tmpbuf + ((k + 3) & 3) * dest->width,
|
|
|
|
src->pixels + (k + 3) * src->stride,
|
2008-01-14 01:19:34 +00:00
|
|
|
dest->width, src->width, &xacc, x_increment);
|
2006-11-14 23:08:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
t0 = tmpbuf + (CLAMP (j - 1, 0, src->height - 1) & 3) * dest->width;
|
|
|
|
t1 = tmpbuf + (CLAMP (j, 0, src->height - 1) & 3) * dest->width;
|
|
|
|
t2 = tmpbuf + (CLAMP (j + 1, 0, src->height - 1) & 3) * dest->width;
|
|
|
|
t3 = tmpbuf + (CLAMP (j + 2, 0, src->height - 1) & 3) * dest->width;
|
|
|
|
vs_scanline_merge_4tap_Y (dest->pixels + i * dest->stride,
|
|
|
|
t0, t1, t2, t3, dest->width, yacc & 0xffff);
|
|
|
|
|
|
|
|
yacc += y_increment;
|
|
|
|
}
|
|
|
|
}
|
2009-03-26 21:08:26 +00:00
|
|
|
|
2009-05-26 13:23:45 +00:00
|
|
|
void
|
|
|
|
vs_scanline_resample_4tap_Y16 (uint8_t * dest, uint8_t * src,
|
|
|
|
int n, int src_width, int *xacc, int increment)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int j;
|
|
|
|
int acc;
|
|
|
|
int x;
|
|
|
|
int y;
|
|
|
|
uint16_t *d = (uint16_t *) dest, *s = (uint16_t *) src;
|
|
|
|
|
|
|
|
acc = *xacc;
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
j = acc >> 16;
|
|
|
|
x = (acc & 0xff00) >> 8;
|
|
|
|
if (j - 1 >= 0 && j + 2 < src_width) {
|
|
|
|
y = vs_4tap_taps[x][0] * s[MAX (j - 1, 0)];
|
|
|
|
y += vs_4tap_taps[x][1] * s[j];
|
|
|
|
y += vs_4tap_taps[x][2] * s[j + 1];
|
|
|
|
y += vs_4tap_taps[x][3] * s[j + 2];
|
|
|
|
} else {
|
|
|
|
y = vs_4tap_taps[x][0] * s[CLAMP (j - 1, 0, src_width - 1)];
|
|
|
|
y += vs_4tap_taps[x][1] * s[CLAMP (j, 0, src_width - 1)];
|
|
|
|
y += vs_4tap_taps[x][2] * s[CLAMP (j + 1, 0, src_width - 1)];
|
|
|
|
y += vs_4tap_taps[x][3] * s[CLAMP (j + 2, 0, src_width - 1)];
|
|
|
|
}
|
|
|
|
y += (1 << (SHIFT - 1));
|
|
|
|
d[i] = CLAMP (y >> SHIFT, 0, 65535);
|
|
|
|
acc += increment;
|
|
|
|
}
|
|
|
|
*xacc = acc;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
vs_scanline_merge_4tap_Y16 (uint8_t * dest, uint8_t * src1, uint8_t * src2,
|
|
|
|
uint8_t * src3, uint8_t * src4, int n, int acc)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int y;
|
|
|
|
int a, b, c, d;
|
|
|
|
uint16_t *de = (uint16_t *) dest, *s1 = (uint16_t *) src1;
|
|
|
|
uint16_t *s2 = (uint16_t *) src2, *s3 = (uint16_t *) src3;
|
|
|
|
uint16_t *s4 = (uint16_t *) src4;
|
|
|
|
|
|
|
|
acc = (acc >> 8) & 0xff;
|
|
|
|
a = vs_4tap_taps[acc][0];
|
|
|
|
b = vs_4tap_taps[acc][1];
|
|
|
|
c = vs_4tap_taps[acc][2];
|
|
|
|
d = vs_4tap_taps[acc][3];
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
y = a * s1[i];
|
|
|
|
y += b * s2[i];
|
|
|
|
y += c * s3[i];
|
|
|
|
y += d * s4[i];
|
|
|
|
y += (1 << (SHIFT - 1));
|
|
|
|
de[i] = CLAMP (y >> SHIFT, 0, 65535);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
vs_image_scale_4tap_Y16 (const VSImage * dest, const VSImage * src,
|
|
|
|
uint8_t * tmpbuf)
|
|
|
|
{
|
|
|
|
int yacc;
|
|
|
|
int y_increment;
|
|
|
|
int x_increment;
|
|
|
|
int i;
|
|
|
|
int j;
|
|
|
|
int xacc;
|
|
|
|
int k;
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
k = 0;
|
|
|
|
for (i = 0; i < 4; i++) {
|
|
|
|
xacc = 0;
|
|
|
|
vs_scanline_resample_4tap_Y16 (tmpbuf + i * dest->stride,
|
2011-04-23 19:46:09 +00:00
|
|
|
src->pixels + CLAMP (i, 0, src->height - 1) * src->stride, dest->width,
|
|
|
|
src->width, &xacc, x_increment);
|
2009-05-26 13:23:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
yacc = 0;
|
|
|
|
for (i = 0; i < dest->height; i++) {
|
|
|
|
uint8_t *t0, *t1, *t2, *t3;
|
|
|
|
|
|
|
|
j = yacc >> 16;
|
|
|
|
|
|
|
|
while (j > k) {
|
|
|
|
k++;
|
|
|
|
if (k + 3 < src->height) {
|
|
|
|
xacc = 0;
|
|
|
|
vs_scanline_resample_4tap_Y16 (tmpbuf + ((k + 3) & 3) * dest->stride,
|
|
|
|
src->pixels + (k + 3) * src->stride,
|
|
|
|
dest->width, src->width, &xacc, x_increment);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
t0 = tmpbuf + (CLAMP (j - 1, 0, src->height - 1) & 3) * dest->stride;
|
|
|
|
t1 = tmpbuf + (CLAMP (j, 0, src->height - 1) & 3) * dest->stride;
|
|
|
|
t2 = tmpbuf + (CLAMP (j + 1, 0, src->height - 1) & 3) * dest->stride;
|
|
|
|
t3 = tmpbuf + (CLAMP (j + 2, 0, src->height - 1) & 3) * dest->stride;
|
|
|
|
vs_scanline_merge_4tap_Y16 (dest->pixels + i * dest->stride,
|
|
|
|
t0, t1, t2, t3, dest->width, yacc & 0xffff);
|
|
|
|
|
|
|
|
yacc += y_increment;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-26 21:08:26 +00:00
|
|
|
void
|
|
|
|
vs_scanline_resample_4tap_RGBA (uint8_t * dest, uint8_t * src,
|
|
|
|
int n, int src_width, int *xacc, int increment)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int j;
|
|
|
|
int acc;
|
|
|
|
int x;
|
|
|
|
int y;
|
|
|
|
int off;
|
|
|
|
|
|
|
|
acc = *xacc;
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
j = acc >> 16;
|
|
|
|
x = (acc & 0xffff) >> 8;
|
|
|
|
|
|
|
|
for (off = 0; off < 4; off++) {
|
|
|
|
if (j - 1 >= 0 && j + 2 < src_width) {
|
|
|
|
y = vs_4tap_taps[x][0] * src[MAX ((j - 1) * 4 + off, 0)];
|
|
|
|
y += vs_4tap_taps[x][1] * src[j * 4 + off];
|
|
|
|
y += vs_4tap_taps[x][2] * src[(j + 1) * 4 + off];
|
|
|
|
y += vs_4tap_taps[x][3] * src[(j + 2) * 4 + off];
|
|
|
|
} else {
|
2011-04-23 19:46:09 +00:00
|
|
|
y = vs_4tap_taps[x][0] *
|
|
|
|
src[CLAMP ((j - 1), 0, src_width - 1) * 4 + off];
|
|
|
|
y += vs_4tap_taps[x][1] *
|
|
|
|
src[CLAMP ((j + 0), 0, src_width - 1) * 4 + off];
|
|
|
|
y += vs_4tap_taps[x][2] *
|
|
|
|
src[CLAMP ((j + 1), 0, src_width - 1) * 4 + off];
|
|
|
|
y += vs_4tap_taps[x][3] *
|
|
|
|
src[CLAMP ((j + 2), 0, src_width - 1) * 4 + off];
|
2009-03-26 21:08:26 +00:00
|
|
|
}
|
|
|
|
y += (1 << (SHIFT - 1));
|
|
|
|
dest[i * 4 + off] = CLAMP (y >> SHIFT, 0, 255);
|
|
|
|
}
|
|
|
|
acc += increment;
|
|
|
|
}
|
|
|
|
*xacc = acc;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
vs_scanline_merge_4tap_RGBA (uint8_t * dest, uint8_t * src1, uint8_t * src2,
|
|
|
|
uint8_t * src3, uint8_t * src4, int n, int acc)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int y;
|
|
|
|
int off;
|
|
|
|
int a, b, c, d;
|
|
|
|
|
|
|
|
acc = (acc >> 8) & 0xff;
|
|
|
|
a = vs_4tap_taps[acc][0];
|
|
|
|
b = vs_4tap_taps[acc][1];
|
|
|
|
c = vs_4tap_taps[acc][2];
|
|
|
|
d = vs_4tap_taps[acc][3];
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
for (off = 0; off < 4; off++) {
|
|
|
|
y = a * src1[i * 4 + off];
|
|
|
|
y += b * src2[i * 4 + off];
|
|
|
|
y += c * src3[i * 4 + off];
|
|
|
|
y += d * src4[i * 4 + off];
|
|
|
|
y += (1 << (SHIFT - 1));
|
|
|
|
dest[i * 4 + off] = CLAMP (y >> SHIFT, 0, 255);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
vs_image_scale_4tap_RGBA (const VSImage * dest, const VSImage * src,
|
|
|
|
uint8_t * tmpbuf)
|
|
|
|
{
|
|
|
|
int yacc;
|
|
|
|
int y_increment;
|
|
|
|
int x_increment;
|
|
|
|
int i;
|
|
|
|
int j;
|
|
|
|
int xacc;
|
|
|
|
int k;
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
k = 0;
|
|
|
|
for (i = 0; i < 4; i++) {
|
|
|
|
xacc = 0;
|
|
|
|
vs_scanline_resample_4tap_RGBA (tmpbuf + i * dest->stride,
|
2011-04-23 19:46:09 +00:00
|
|
|
src->pixels + CLAMP (i, 0, src->height) * src->stride,
|
|
|
|
dest->width, src->width, &xacc, x_increment);
|
2009-03-26 21:08:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
yacc = 0;
|
|
|
|
for (i = 0; i < dest->height; i++) {
|
|
|
|
uint8_t *t0, *t1, *t2, *t3;
|
|
|
|
|
|
|
|
j = yacc >> 16;
|
|
|
|
|
|
|
|
while (j > k) {
|
|
|
|
k++;
|
|
|
|
if (k + 3 < src->height) {
|
|
|
|
xacc = 0;
|
|
|
|
vs_scanline_resample_4tap_RGBA (tmpbuf + ((k + 3) & 3) * dest->stride,
|
|
|
|
src->pixels + (k + 3) * src->stride,
|
|
|
|
dest->width, src->width, &xacc, x_increment);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
t0 = tmpbuf + (CLAMP (j - 1, 0, src->height - 1) & 3) * dest->stride;
|
|
|
|
t1 = tmpbuf + (CLAMP (j, 0, src->height - 1) & 3) * dest->stride;
|
|
|
|
t2 = tmpbuf + (CLAMP (j + 1, 0, src->height - 1) & 3) * dest->stride;
|
|
|
|
t3 = tmpbuf + (CLAMP (j + 2, 0, src->height - 1) & 3) * dest->stride;
|
|
|
|
vs_scanline_merge_4tap_RGBA (dest->pixels + i * dest->stride,
|
|
|
|
t0, t1, t2, t3, dest->width, yacc & 0xffff);
|
|
|
|
|
|
|
|
yacc += y_increment;
|
|
|
|
}
|
|
|
|
}
|
2009-03-26 21:14:53 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
vs_scanline_resample_4tap_RGB (uint8_t * dest, uint8_t * src,
|
|
|
|
int n, int src_width, int *xacc, int increment)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int j;
|
|
|
|
int acc;
|
|
|
|
int x;
|
|
|
|
int y;
|
|
|
|
int off;
|
|
|
|
|
|
|
|
acc = *xacc;
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
j = acc >> 16;
|
|
|
|
x = (acc & 0xffff) >> 8;
|
|
|
|
|
|
|
|
for (off = 0; off < 3; off++) {
|
|
|
|
if (j - 1 >= 0 && j + 2 < src_width) {
|
|
|
|
y = vs_4tap_taps[x][0] * src[MAX ((j - 1) * 3 + off, 0)];
|
|
|
|
y += vs_4tap_taps[x][1] * src[j * 3 + off];
|
|
|
|
y += vs_4tap_taps[x][2] * src[(j + 1) * 3 + off];
|
|
|
|
y += vs_4tap_taps[x][3] * src[(j + 2) * 3 + off];
|
|
|
|
} else {
|
|
|
|
y = vs_4tap_taps[x][0] * src[CLAMP ((j - 1) * 3 + off, 0,
|
|
|
|
3 * (src_width - 1) + off)];
|
|
|
|
y += vs_4tap_taps[x][1] * src[CLAMP (j * 3 + off, 0,
|
|
|
|
3 * (src_width - 1) + off)];
|
|
|
|
y += vs_4tap_taps[x][2] * src[CLAMP ((j + 1) * 3 + off, 0,
|
|
|
|
3 * (src_width - 1) + off)];
|
|
|
|
y += vs_4tap_taps[x][3] * src[CLAMP ((j + 2) * 3 + off, 0,
|
|
|
|
3 * (src_width - 1) + off)];
|
|
|
|
}
|
|
|
|
y += (1 << (SHIFT - 1));
|
|
|
|
dest[i * 3 + off] = CLAMP (y >> SHIFT, 0, 255);
|
|
|
|
}
|
|
|
|
acc += increment;
|
|
|
|
}
|
|
|
|
*xacc = acc;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
vs_scanline_merge_4tap_RGB (uint8_t * dest, uint8_t * src1, uint8_t * src2,
|
|
|
|
uint8_t * src3, uint8_t * src4, int n, int acc)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int y;
|
|
|
|
int off;
|
|
|
|
int a, b, c, d;
|
|
|
|
|
|
|
|
acc = (acc >> 8) & 0xff;
|
|
|
|
a = vs_4tap_taps[acc][0];
|
|
|
|
b = vs_4tap_taps[acc][1];
|
|
|
|
c = vs_4tap_taps[acc][2];
|
|
|
|
d = vs_4tap_taps[acc][3];
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
for (off = 0; off < 3; off++) {
|
|
|
|
y = a * src1[i * 3 + off];
|
|
|
|
y += b * src2[i * 3 + off];
|
|
|
|
y += c * src3[i * 3 + off];
|
|
|
|
y += d * src4[i * 3 + off];
|
|
|
|
y += (1 << (SHIFT - 1));
|
|
|
|
dest[i * 3 + off] = CLAMP (y >> SHIFT, 0, 255);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
vs_image_scale_4tap_RGB (const VSImage * dest, const VSImage * src,
|
|
|
|
uint8_t * tmpbuf)
|
|
|
|
{
|
|
|
|
int yacc;
|
|
|
|
int y_increment;
|
|
|
|
int x_increment;
|
|
|
|
int i;
|
|
|
|
int j;
|
|
|
|
int xacc;
|
|
|
|
int k;
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
k = 0;
|
|
|
|
for (i = 0; i < 4; i++) {
|
|
|
|
xacc = 0;
|
|
|
|
vs_scanline_resample_4tap_RGB (tmpbuf + i * dest->stride,
|
2011-04-23 19:46:09 +00:00
|
|
|
src->pixels + CLAMP (i, 0, src->height - 1) * src->stride, dest->width,
|
|
|
|
src->width, &xacc, x_increment);
|
2009-03-26 21:14:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
yacc = 0;
|
|
|
|
for (i = 0; i < dest->height; i++) {
|
|
|
|
uint8_t *t0, *t1, *t2, *t3;
|
|
|
|
|
|
|
|
j = yacc >> 16;
|
|
|
|
|
|
|
|
while (j > k) {
|
|
|
|
k++;
|
|
|
|
if (k + 3 < src->height) {
|
|
|
|
xacc = 0;
|
|
|
|
vs_scanline_resample_4tap_RGB (tmpbuf + ((k + 3) & 3) * dest->stride,
|
|
|
|
src->pixels + (k + 3) * src->stride,
|
|
|
|
dest->width, src->width, &xacc, x_increment);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
t0 = tmpbuf + (CLAMP (j - 1, 0, src->height - 1) & 3) * dest->stride;
|
|
|
|
t1 = tmpbuf + (CLAMP (j, 0, src->height - 1) & 3) * dest->stride;
|
|
|
|
t2 = tmpbuf + (CLAMP (j + 1, 0, src->height - 1) & 3) * dest->stride;
|
|
|
|
t3 = tmpbuf + (CLAMP (j + 2, 0, src->height - 1) & 3) * dest->stride;
|
|
|
|
vs_scanline_merge_4tap_RGB (dest->pixels + i * dest->stride,
|
|
|
|
t0, t1, t2, t3, dest->width, yacc & 0xffff);
|
|
|
|
|
|
|
|
yacc += y_increment;
|
|
|
|
}
|
|
|
|
}
|
2009-03-27 08:33:58 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
vs_scanline_resample_4tap_YUYV (uint8_t * dest, uint8_t * src,
|
|
|
|
int n, int src_width, int *xacc, int increment)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int j;
|
|
|
|
int acc;
|
|
|
|
int x;
|
|
|
|
int y;
|
2009-03-29 09:53:40 +00:00
|
|
|
int quads = (n + 1) / 2;
|
2009-04-02 09:10:12 +00:00
|
|
|
int last_y = 2 * (src_width - 1);
|
|
|
|
int last_u =
|
|
|
|
MAX ((2 * (src_width - 1) % 4 ==
|
|
|
|
0) ? 2 * (src_width - 1) + 1 : 2 * (src_width - 1) - 1, 1);
|
|
|
|
int last_v =
|
|
|
|
MAX ((2 * (src_width - 1) % 4 ==
|
|
|
|
2) ? 2 * (src_width - 1) + 1 : 2 * (src_width - 1) - 1, 1);
|
2009-03-27 08:33:58 +00:00
|
|
|
|
|
|
|
acc = *xacc;
|
2009-03-29 09:53:40 +00:00
|
|
|
for (i = 0; i < quads; i++) {
|
2009-03-27 08:33:58 +00:00
|
|
|
j = acc >> 16;
|
|
|
|
x = (acc & 0xffff) >> 8;
|
|
|
|
|
2009-03-29 09:53:40 +00:00
|
|
|
if (j - 1 >= 0 && j + 2 < src_width) {
|
|
|
|
y = vs_4tap_taps[x][0] * src[MAX (j * 2 + 0 - 2, 0)];
|
|
|
|
y += vs_4tap_taps[x][1] * src[j * 2 + 0];
|
|
|
|
y += vs_4tap_taps[x][2] * src[j * 2 + 0 + 2];
|
|
|
|
y += vs_4tap_taps[x][3] * src[j * 2 + 0 + 4];
|
|
|
|
} else {
|
2009-04-02 09:10:12 +00:00
|
|
|
y = vs_4tap_taps[x][0] * src[CLAMP (j * 2 + 0 - 2, 0, last_y)];
|
|
|
|
y += vs_4tap_taps[x][1] * src[CLAMP (j * 2 + 0, 0, last_y)];
|
|
|
|
y += vs_4tap_taps[x][2] * src[CLAMP (j * 2 + 0 + 2, 0, last_y)];
|
|
|
|
y += vs_4tap_taps[x][3] * src[CLAMP (j * 2 + 0 + 4, 0, last_y)];
|
2009-03-29 09:53:40 +00:00
|
|
|
}
|
|
|
|
y += (1 << (SHIFT - 1));
|
|
|
|
dest[i * 4 + 0] = CLAMP (y >> SHIFT, 0, 255);
|
|
|
|
|
|
|
|
j = acc >> 17;
|
|
|
|
x = (acc & 0x1ffff) >> 9;
|
|
|
|
|
2010-03-17 15:46:32 +00:00
|
|
|
if (2 * j - 1 >= 0 && 2 * j + 4 < src_width) {
|
2009-03-29 09:53:40 +00:00
|
|
|
y = vs_4tap_taps[x][0] * src[MAX (j * 4 + 1 - 4, 1)];
|
|
|
|
y += vs_4tap_taps[x][1] * src[j * 4 + 1];
|
|
|
|
y += vs_4tap_taps[x][2] * src[j * 4 + 1 + 4];
|
|
|
|
y += vs_4tap_taps[x][3] * src[j * 4 + 1 + 8];
|
|
|
|
} else {
|
2009-04-02 09:10:12 +00:00
|
|
|
y = vs_4tap_taps[x][0] * src[CLAMP (j * 4 + 1 - 4, 1, last_u)];
|
|
|
|
y += vs_4tap_taps[x][1] * src[CLAMP (j * 4 + 1, 1, last_u)];
|
|
|
|
y += vs_4tap_taps[x][2] * src[CLAMP (j * 4 + 1 + 4, 1, last_u)];
|
|
|
|
y += vs_4tap_taps[x][3] * src[CLAMP (j * 4 + 1 + 8, 1, last_u)];
|
2009-03-29 09:53:40 +00:00
|
|
|
}
|
|
|
|
y += (1 << (SHIFT - 1));
|
|
|
|
dest[i * 4 + 1] = CLAMP (y >> SHIFT, 0, 255);
|
|
|
|
|
2009-04-02 08:52:06 +00:00
|
|
|
if (2 * i + 1 < n) {
|
2010-03-17 15:46:32 +00:00
|
|
|
if (2 * j - 1 >= 0 && 2 * j + 4 < src_width) {
|
2009-04-02 08:52:06 +00:00
|
|
|
y = vs_4tap_taps[x][0] * src[MAX (j * 4 + 3 - 4, 3)];
|
2009-03-29 09:53:40 +00:00
|
|
|
y += vs_4tap_taps[x][1] * src[j * 4 + 3];
|
|
|
|
y += vs_4tap_taps[x][2] * src[j * 4 + 3 + 4];
|
|
|
|
y += vs_4tap_taps[x][3] * src[j * 4 + 3 + 8];
|
2009-03-27 18:12:49 +00:00
|
|
|
} else {
|
2009-04-02 09:10:12 +00:00
|
|
|
y = vs_4tap_taps[x][0] * src[CLAMP (j * 4 + 3 - 4, 3, last_v)];
|
|
|
|
y += vs_4tap_taps[x][1] * src[CLAMP (j * 4 + 3, 3, last_v)];
|
|
|
|
y += vs_4tap_taps[x][2] * src[CLAMP (j * 4 + 3 + 4, 3, last_v)];
|
|
|
|
y += vs_4tap_taps[x][3] * src[CLAMP (j * 4 + 3 + 8, 3, last_v)];
|
2009-03-27 18:12:49 +00:00
|
|
|
}
|
|
|
|
y += (1 << (SHIFT - 1));
|
2009-03-29 09:53:40 +00:00
|
|
|
dest[i * 4 + 3] = CLAMP (y >> SHIFT, 0, 255);
|
2009-03-27 18:12:49 +00:00
|
|
|
}
|
|
|
|
|
2009-03-29 09:53:40 +00:00
|
|
|
acc += increment;
|
|
|
|
j = acc >> 16;
|
|
|
|
x = (acc & 0xffff) >> 8;
|
|
|
|
|
2009-04-02 08:52:06 +00:00
|
|
|
if (2 * i + 1 < n) {
|
2009-03-27 08:33:58 +00:00
|
|
|
if (j - 1 >= 0 && j + 2 < src_width) {
|
2009-03-29 09:53:40 +00:00
|
|
|
y = vs_4tap_taps[x][0] * src[MAX (j * 2 + 0 - 2, 0)];
|
|
|
|
y += vs_4tap_taps[x][1] * src[j * 2 + 0];
|
|
|
|
y += vs_4tap_taps[x][2] * src[j * 2 + 0 + 2];
|
|
|
|
y += vs_4tap_taps[x][3] * src[j * 2 + 0 + 4];
|
2009-03-27 08:33:58 +00:00
|
|
|
} else {
|
2009-04-02 09:10:12 +00:00
|
|
|
y = vs_4tap_taps[x][0] * src[CLAMP (j * 2 + 0 - 2, 0, last_y)];
|
|
|
|
y += vs_4tap_taps[x][1] * src[CLAMP (j * 2 + 0, 0, last_y)];
|
|
|
|
y += vs_4tap_taps[x][2] * src[CLAMP (j * 2 + 0 + 2, 0, last_y)];
|
|
|
|
y += vs_4tap_taps[x][3] * src[CLAMP (j * 2 + 0 + 4, 0, last_y)];
|
2009-03-27 08:33:58 +00:00
|
|
|
}
|
|
|
|
y += (1 << (SHIFT - 1));
|
2009-03-29 09:53:40 +00:00
|
|
|
dest[i * 4 + 2] = CLAMP (y >> SHIFT, 0, 255);
|
|
|
|
acc += increment;
|
2009-03-27 08:33:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
*xacc = acc;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
vs_scanline_merge_4tap_YUYV (uint8_t * dest, uint8_t * src1, uint8_t * src2,
|
|
|
|
uint8_t * src3, uint8_t * src4, int n, int acc)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int y;
|
|
|
|
int a, b, c, d;
|
2009-03-29 09:53:40 +00:00
|
|
|
int quads = (n + 1) / 2;
|
2009-03-27 08:33:58 +00:00
|
|
|
|
|
|
|
acc = (acc >> 8) & 0xff;
|
|
|
|
a = vs_4tap_taps[acc][0];
|
|
|
|
b = vs_4tap_taps[acc][1];
|
|
|
|
c = vs_4tap_taps[acc][2];
|
|
|
|
d = vs_4tap_taps[acc][3];
|
2009-03-29 09:53:40 +00:00
|
|
|
for (i = 0; i < quads; i++) {
|
|
|
|
y = a * src1[i * 4 + 0];
|
|
|
|
y += b * src2[i * 4 + 0];
|
|
|
|
y += c * src3[i * 4 + 0];
|
|
|
|
y += d * src4[i * 4 + 0];
|
|
|
|
y += (1 << (SHIFT - 1));
|
|
|
|
dest[i * 4 + 0] = CLAMP (y >> SHIFT, 0, 255);
|
|
|
|
|
|
|
|
y = a * src1[i * 4 + 1];
|
|
|
|
y += b * src2[i * 4 + 1];
|
|
|
|
y += c * src3[i * 4 + 1];
|
|
|
|
y += d * src4[i * 4 + 1];
|
|
|
|
y += (1 << (SHIFT - 1));
|
|
|
|
dest[i * 4 + 1] = CLAMP (y >> SHIFT, 0, 255);
|
|
|
|
|
|
|
|
if (2 * i + 1 < n) {
|
|
|
|
y = a * src1[i * 4 + 2];
|
|
|
|
y += b * src2[i * 4 + 2];
|
|
|
|
y += c * src3[i * 4 + 2];
|
|
|
|
y += d * src4[i * 4 + 2];
|
2009-03-27 08:33:58 +00:00
|
|
|
y += (1 << (SHIFT - 1));
|
2009-03-29 09:53:40 +00:00
|
|
|
dest[i * 4 + 2] = CLAMP (y >> SHIFT, 0, 255);
|
|
|
|
|
|
|
|
y = a * src1[i * 4 + 3];
|
|
|
|
y += b * src2[i * 4 + 3];
|
|
|
|
y += c * src3[i * 4 + 3];
|
|
|
|
y += d * src4[i * 4 + 3];
|
|
|
|
y += (1 << (SHIFT - 1));
|
|
|
|
dest[i * 4 + 3] = CLAMP (y >> SHIFT, 0, 255);
|
2009-03-27 08:33:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
vs_image_scale_4tap_YUYV (const VSImage * dest, const VSImage * src,
|
|
|
|
uint8_t * tmpbuf)
|
|
|
|
{
|
|
|
|
int yacc;
|
|
|
|
int y_increment;
|
|
|
|
int x_increment;
|
|
|
|
int i;
|
|
|
|
int j;
|
|
|
|
int xacc;
|
|
|
|
int k;
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
k = 0;
|
|
|
|
for (i = 0; i < 4; i++) {
|
|
|
|
xacc = 0;
|
|
|
|
vs_scanline_resample_4tap_YUYV (tmpbuf + i * dest->stride,
|
2011-04-23 19:46:09 +00:00
|
|
|
src->pixels + CLAMP (i, 0, src->height - 1) * src->stride, dest->width,
|
|
|
|
src->width, &xacc, x_increment);
|
2009-03-27 08:33:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
yacc = 0;
|
|
|
|
for (i = 0; i < dest->height; i++) {
|
|
|
|
uint8_t *t0, *t1, *t2, *t3;
|
|
|
|
|
|
|
|
j = yacc >> 16;
|
|
|
|
|
|
|
|
while (j > k) {
|
|
|
|
k++;
|
|
|
|
if (k + 3 < src->height) {
|
|
|
|
xacc = 0;
|
|
|
|
vs_scanline_resample_4tap_YUYV (tmpbuf + ((k + 3) & 3) * dest->stride,
|
|
|
|
src->pixels + (k + 3) * src->stride,
|
2009-03-29 09:53:40 +00:00
|
|
|
dest->width, src->width, &xacc, x_increment);
|
2009-03-27 08:33:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
t0 = tmpbuf + (CLAMP (j - 1, 0, src->height - 1) & 3) * dest->stride;
|
|
|
|
t1 = tmpbuf + (CLAMP (j, 0, src->height - 1) & 3) * dest->stride;
|
|
|
|
t2 = tmpbuf + (CLAMP (j + 1, 0, src->height - 1) & 3) * dest->stride;
|
|
|
|
t3 = tmpbuf + (CLAMP (j + 2, 0, src->height - 1) & 3) * dest->stride;
|
|
|
|
vs_scanline_merge_4tap_YUYV (dest->pixels + i * dest->stride,
|
2009-03-29 09:53:40 +00:00
|
|
|
t0, t1, t2, t3, dest->width, yacc & 0xffff);
|
2009-03-27 08:33:58 +00:00
|
|
|
|
|
|
|
yacc += y_increment;
|
|
|
|
}
|
|
|
|
}
|
2009-03-27 09:47:39 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
vs_scanline_resample_4tap_UYVY (uint8_t * dest, uint8_t * src,
|
|
|
|
int n, int src_width, int *xacc, int increment)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int j;
|
|
|
|
int acc;
|
|
|
|
int x;
|
|
|
|
int y;
|
2009-03-29 09:53:40 +00:00
|
|
|
int quads = (n + 1) / 2;
|
2009-04-02 09:10:12 +00:00
|
|
|
int last_y = 2 * (src_width - 1) + 1;
|
|
|
|
int last_u =
|
|
|
|
MAX ((2 * (src_width - 1) % 4 ==
|
|
|
|
0) ? 2 * (src_width - 1) : 2 * (src_width - 1) - 2, 0);
|
|
|
|
int last_v =
|
|
|
|
MAX ((2 * (src_width - 1) % 4 ==
|
|
|
|
2) ? 2 * (src_width - 1) : 2 * (src_width - 1) - 2, 0);
|
2009-03-27 09:47:39 +00:00
|
|
|
|
|
|
|
acc = *xacc;
|
2009-03-29 09:53:40 +00:00
|
|
|
for (i = 0; i < quads; i++) {
|
2009-03-27 09:47:39 +00:00
|
|
|
j = acc >> 16;
|
|
|
|
x = (acc & 0xffff) >> 8;
|
|
|
|
|
2009-03-29 09:53:40 +00:00
|
|
|
if (j - 1 >= 0 && j + 2 < src_width) {
|
|
|
|
y = vs_4tap_taps[x][0] * src[MAX (j * 2 + 1 - 2, 1)];
|
|
|
|
y += vs_4tap_taps[x][1] * src[j * 2 + 1];
|
|
|
|
y += vs_4tap_taps[x][2] * src[j * 2 + 1 + 2];
|
|
|
|
y += vs_4tap_taps[x][3] * src[j * 2 + 1 + 4];
|
|
|
|
} else {
|
2009-04-02 09:10:12 +00:00
|
|
|
y = vs_4tap_taps[x][0] * src[CLAMP (j * 2 + 1 - 2, 1, last_y)];
|
|
|
|
y += vs_4tap_taps[x][1] * src[CLAMP (j * 2 + 1, 1, last_y)];
|
|
|
|
y += vs_4tap_taps[x][2] * src[CLAMP (j * 2 + 1 + 2, 1, last_y)];
|
|
|
|
y += vs_4tap_taps[x][3] * src[CLAMP (j * 2 + 1 + 4, 1, last_y)];
|
2009-03-29 09:53:40 +00:00
|
|
|
}
|
|
|
|
y += (1 << (SHIFT - 1));
|
|
|
|
dest[i * 4 + 1] = CLAMP (y >> SHIFT, 0, 255);
|
|
|
|
|
|
|
|
j = acc >> 17;
|
|
|
|
x = (acc & 0x1ffff) >> 9;
|
|
|
|
|
2010-03-17 15:46:32 +00:00
|
|
|
if (2 * j - 2 >= 0 && 2 * j + 4 < src_width) {
|
2009-03-29 09:53:40 +00:00
|
|
|
y = vs_4tap_taps[x][0] * src[MAX (j * 4 + 0 - 4, 0)];
|
|
|
|
y += vs_4tap_taps[x][1] * src[j * 4 + 0];
|
|
|
|
y += vs_4tap_taps[x][2] * src[j * 4 + 0 + 4];
|
|
|
|
y += vs_4tap_taps[x][3] * src[j * 4 + 0 + 8];
|
|
|
|
} else {
|
2009-04-02 09:10:12 +00:00
|
|
|
y = vs_4tap_taps[x][0] * src[CLAMP (j * 4 + 0 - 4, 0, last_u)];
|
|
|
|
y += vs_4tap_taps[x][1] * src[CLAMP (j * 4 + 0, 0, last_u)];
|
|
|
|
y += vs_4tap_taps[x][2] * src[CLAMP (j * 4 + 0 + 4, 0, last_u)];
|
|
|
|
y += vs_4tap_taps[x][3] * src[CLAMP (j * 4 + 0 + 8, 0, last_u)];
|
2009-03-29 09:53:40 +00:00
|
|
|
}
|
|
|
|
y += (1 << (SHIFT - 1));
|
|
|
|
dest[i * 4 + 0] = CLAMP (y >> SHIFT, 0, 255);
|
|
|
|
|
2009-04-02 08:52:06 +00:00
|
|
|
if (2 * i + 1 < n) {
|
2010-03-17 15:46:32 +00:00
|
|
|
if (2 * j - 1 >= 0 && 2 * j + 4 < src_width) {
|
2009-04-02 08:52:06 +00:00
|
|
|
y = vs_4tap_taps[x][0] * src[MAX (j * 4 + 2 - 4, 2)];
|
2009-03-29 09:53:40 +00:00
|
|
|
y += vs_4tap_taps[x][1] * src[j * 4 + 2];
|
|
|
|
y += vs_4tap_taps[x][2] * src[j * 4 + 2 + 4];
|
|
|
|
y += vs_4tap_taps[x][3] * src[j * 4 + 2 + 8];
|
2009-03-27 09:47:39 +00:00
|
|
|
} else {
|
2009-04-02 09:10:12 +00:00
|
|
|
y = vs_4tap_taps[x][0] * src[CLAMP (j * 4 + 2 - 4, 2, last_v)];
|
|
|
|
y += vs_4tap_taps[x][1] * src[CLAMP (j * 4 + 2, 2, last_v)];
|
|
|
|
y += vs_4tap_taps[x][2] * src[CLAMP (j * 4 + 2 + 4, 2, last_v)];
|
|
|
|
y += vs_4tap_taps[x][3] * src[CLAMP (j * 4 + 2 + 8, 2, last_v)];
|
2009-03-27 09:47:39 +00:00
|
|
|
}
|
|
|
|
y += (1 << (SHIFT - 1));
|
2009-03-29 09:53:40 +00:00
|
|
|
dest[i * 4 + 2] = CLAMP (y >> SHIFT, 0, 255);
|
2009-03-27 09:47:39 +00:00
|
|
|
}
|
2009-03-27 18:12:49 +00:00
|
|
|
|
2009-03-29 09:53:40 +00:00
|
|
|
acc += increment;
|
|
|
|
j = acc >> 16;
|
|
|
|
x = (acc & 0xffff) >> 8;
|
|
|
|
|
2009-04-02 08:52:06 +00:00
|
|
|
if (2 * i + 1 < n) {
|
2009-03-27 18:12:49 +00:00
|
|
|
if (j - 1 >= 0 && j + 2 < src_width) {
|
2009-03-29 09:53:40 +00:00
|
|
|
y = vs_4tap_taps[x][0] * src[MAX (j * 2 + 1 - 2, 0)];
|
|
|
|
y += vs_4tap_taps[x][1] * src[j * 2 + 1];
|
|
|
|
y += vs_4tap_taps[x][2] * src[j * 2 + 1 + 2];
|
|
|
|
y += vs_4tap_taps[x][3] * src[j * 2 + 1 + 4];
|
2009-03-27 18:12:49 +00:00
|
|
|
} else {
|
2009-04-02 09:10:12 +00:00
|
|
|
y = vs_4tap_taps[x][0] * src[CLAMP (j * 2 + 1 - 2, 1, last_y)];
|
|
|
|
y += vs_4tap_taps[x][1] * src[CLAMP (j * 2 + 1, 1, last_y)];
|
|
|
|
y += vs_4tap_taps[x][2] * src[CLAMP (j * 2 + 1 + 2, 1, last_y)];
|
|
|
|
y += vs_4tap_taps[x][3] * src[CLAMP (j * 2 + 1 + 4, 1, last_y)];
|
2009-03-27 18:12:49 +00:00
|
|
|
}
|
|
|
|
y += (1 << (SHIFT - 1));
|
2009-03-29 09:53:40 +00:00
|
|
|
dest[i * 4 + 3] = CLAMP (y >> SHIFT, 0, 255);
|
|
|
|
acc += increment;
|
2009-03-27 18:12:49 +00:00
|
|
|
}
|
2009-03-27 09:47:39 +00:00
|
|
|
}
|
|
|
|
*xacc = acc;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
vs_scanline_merge_4tap_UYVY (uint8_t * dest, uint8_t * src1, uint8_t * src2,
|
|
|
|
uint8_t * src3, uint8_t * src4, int n, int acc)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int y;
|
|
|
|
int a, b, c, d;
|
2009-03-29 09:53:40 +00:00
|
|
|
int quads = (n + 1) / 2;
|
2009-03-27 09:47:39 +00:00
|
|
|
|
|
|
|
acc = (acc >> 8) & 0xff;
|
|
|
|
a = vs_4tap_taps[acc][0];
|
|
|
|
b = vs_4tap_taps[acc][1];
|
|
|
|
c = vs_4tap_taps[acc][2];
|
|
|
|
d = vs_4tap_taps[acc][3];
|
2009-03-29 09:53:40 +00:00
|
|
|
for (i = 0; i < quads; i++) {
|
|
|
|
y = a * src1[i * 4 + 0];
|
|
|
|
y += b * src2[i * 4 + 0];
|
|
|
|
y += c * src3[i * 4 + 0];
|
|
|
|
y += d * src4[i * 4 + 0];
|
|
|
|
y += (1 << (SHIFT - 1));
|
|
|
|
dest[i * 4 + 0] = CLAMP (y >> SHIFT, 0, 255);
|
|
|
|
|
|
|
|
y = a * src1[i * 4 + 1];
|
|
|
|
y += b * src2[i * 4 + 1];
|
|
|
|
y += c * src3[i * 4 + 1];
|
|
|
|
y += d * src4[i * 4 + 1];
|
|
|
|
y += (1 << (SHIFT - 1));
|
|
|
|
dest[i * 4 + 1] = CLAMP (y >> SHIFT, 0, 255);
|
|
|
|
|
|
|
|
if (2 * i + 1 < n) {
|
|
|
|
y = a * src1[i * 4 + 2];
|
|
|
|
y += b * src2[i * 4 + 2];
|
|
|
|
y += c * src3[i * 4 + 2];
|
|
|
|
y += d * src4[i * 4 + 2];
|
2009-03-27 09:47:39 +00:00
|
|
|
y += (1 << (SHIFT - 1));
|
2009-03-29 09:53:40 +00:00
|
|
|
dest[i * 4 + 2] = CLAMP (y >> SHIFT, 0, 255);
|
|
|
|
|
|
|
|
y = a * src1[i * 4 + 3];
|
|
|
|
y += b * src2[i * 4 + 3];
|
|
|
|
y += c * src3[i * 4 + 3];
|
|
|
|
y += d * src4[i * 4 + 3];
|
|
|
|
y += (1 << (SHIFT - 1));
|
|
|
|
dest[i * 4 + 3] = CLAMP (y >> SHIFT, 0, 255);
|
2009-03-27 09:47:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
vs_image_scale_4tap_UYVY (const VSImage * dest, const VSImage * src,
|
|
|
|
uint8_t * tmpbuf)
|
|
|
|
{
|
|
|
|
int yacc;
|
|
|
|
int y_increment;
|
|
|
|
int x_increment;
|
|
|
|
int i;
|
|
|
|
int j;
|
|
|
|
int xacc;
|
|
|
|
int k;
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
k = 0;
|
|
|
|
for (i = 0; i < 4; i++) {
|
|
|
|
xacc = 0;
|
|
|
|
vs_scanline_resample_4tap_UYVY (tmpbuf + i * dest->stride,
|
2011-04-23 19:46:09 +00:00
|
|
|
src->pixels + CLAMP (i, 0, src->height - 1) * src->stride, dest->width,
|
|
|
|
src->width, &xacc, x_increment);
|
2009-03-27 09:47:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
yacc = 0;
|
|
|
|
for (i = 0; i < dest->height; i++) {
|
|
|
|
uint8_t *t0, *t1, *t2, *t3;
|
|
|
|
|
|
|
|
j = yacc >> 16;
|
|
|
|
|
|
|
|
while (j > k) {
|
|
|
|
k++;
|
|
|
|
if (k + 3 < src->height) {
|
|
|
|
xacc = 0;
|
|
|
|
vs_scanline_resample_4tap_UYVY (tmpbuf + ((k + 3) & 3) * dest->stride,
|
|
|
|
src->pixels + (k + 3) * src->stride,
|
2009-03-29 09:53:40 +00:00
|
|
|
dest->width, src->width, &xacc, x_increment);
|
2009-03-27 09:47:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
t0 = tmpbuf + (CLAMP (j - 1, 0, src->height - 1) & 3) * dest->stride;
|
|
|
|
t1 = tmpbuf + (CLAMP (j, 0, src->height - 1) & 3) * dest->stride;
|
|
|
|
t2 = tmpbuf + (CLAMP (j + 1, 0, src->height - 1) & 3) * dest->stride;
|
|
|
|
t3 = tmpbuf + (CLAMP (j + 2, 0, src->height - 1) & 3) * dest->stride;
|
|
|
|
vs_scanline_merge_4tap_UYVY (dest->pixels + i * dest->stride,
|
2009-03-29 09:53:40 +00:00
|
|
|
t0, t1, t2, t3, dest->width, yacc & 0xffff);
|
2009-03-27 09:47:39 +00:00
|
|
|
|
|
|
|
yacc += y_increment;
|
|
|
|
}
|
|
|
|
}
|
2009-03-27 12:14:00 +00:00
|
|
|
|
|
|
|
/* note that src and dest are uint16_t, and thus endian dependent */
|
|
|
|
|
|
|
|
#define RGB565_R(x) (((x)&0xf800)>>8 | ((x)&0xf800)>>13)
|
|
|
|
#define RGB565_G(x) (((x)&0x07e0)>>3 | ((x)&0x07e0)>>9)
|
|
|
|
#define RGB565_B(x) (((x)&0x001f)<<3 | ((x)&0x001f)>>2)
|
|
|
|
|
|
|
|
#define RGB565(r,g,b) \
|
|
|
|
((((r)<<8)&0xf800) | (((g)<<3)&0x07e0) | (((b)>>3)&0x001f))
|
|
|
|
|
|
|
|
void
|
|
|
|
vs_scanline_resample_4tap_RGB565 (uint8_t * dest_u8, uint8_t * src_u8,
|
|
|
|
int n, int src_width, int *xacc, int increment)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int j;
|
|
|
|
int acc;
|
|
|
|
int x;
|
|
|
|
int y, y_r, y_b, y_g;
|
|
|
|
uint16_t *dest = (uint16_t *) dest_u8;
|
|
|
|
uint16_t *src = (uint16_t *) src_u8;
|
|
|
|
|
|
|
|
acc = *xacc;
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
j = acc >> 16;
|
|
|
|
x = acc & 0xffff >> 8;
|
|
|
|
|
|
|
|
if (j - 1 >= 0 && j + 2 < src_width) {
|
|
|
|
y = vs_4tap_taps[x][0] * RGB565_R (src[MAX ((j - 1), 0)]);
|
|
|
|
y += vs_4tap_taps[x][1] * RGB565_R (src[j]);
|
|
|
|
y += vs_4tap_taps[x][2] * RGB565_R (src[(j + 1)]);
|
|
|
|
y += vs_4tap_taps[x][3] * RGB565_R (src[(j + 2)]);
|
|
|
|
} else {
|
|
|
|
y = vs_4tap_taps[x][0] * RGB565_R (src[CLAMP ((j - 1), 0,
|
|
|
|
src_width - 1)]);
|
|
|
|
y += vs_4tap_taps[x][1] * RGB565_R (src[CLAMP (j, 0, src_width - 1)]);
|
|
|
|
y += vs_4tap_taps[x][2] * RGB565_R (src[CLAMP ((j + 1), 0,
|
|
|
|
src_width - 1)]);
|
|
|
|
y += vs_4tap_taps[x][3] * RGB565_R (src[CLAMP ((j + 2), 0,
|
|
|
|
src_width - 1)]);
|
|
|
|
}
|
|
|
|
y += (1 << (SHIFT - 1));
|
|
|
|
y_r = CLAMP (y >> SHIFT, 0, 255);
|
|
|
|
|
|
|
|
if (j - 1 >= 0 && j + 2 < src_width) {
|
|
|
|
y = vs_4tap_taps[x][0] * RGB565_G (src[MAX ((j - 1), 0)]);
|
|
|
|
y += vs_4tap_taps[x][1] * RGB565_G (src[j]);
|
|
|
|
y += vs_4tap_taps[x][2] * RGB565_G (src[(j + 1)]);
|
|
|
|
y += vs_4tap_taps[x][3] * RGB565_G (src[(j + 2)]);
|
|
|
|
} else {
|
|
|
|
y = vs_4tap_taps[x][0] * RGB565_G (src[CLAMP ((j - 1), 0,
|
|
|
|
src_width - 1)]);
|
|
|
|
y += vs_4tap_taps[x][1] * RGB565_G (src[CLAMP (j, 0, src_width - 1)]);
|
|
|
|
y += vs_4tap_taps[x][2] * RGB565_G (src[CLAMP ((j + 1), 0,
|
|
|
|
src_width - 1)]);
|
|
|
|
y += vs_4tap_taps[x][3] * RGB565_G (src[CLAMP ((j + 2), 0,
|
|
|
|
src_width - 1)]);
|
|
|
|
}
|
|
|
|
y += (1 << (SHIFT - 1));
|
|
|
|
y_g = CLAMP (y >> SHIFT, 0, 255);
|
|
|
|
|
|
|
|
if (j - 1 >= 0 && j + 2 < src_width) {
|
|
|
|
y = vs_4tap_taps[x][0] * RGB565_B (src[MAX ((j - 1), 0)]);
|
|
|
|
y += vs_4tap_taps[x][1] * RGB565_B (src[j]);
|
|
|
|
y += vs_4tap_taps[x][2] * RGB565_B (src[(j + 1)]);
|
|
|
|
y += vs_4tap_taps[x][3] * RGB565_B (src[(j + 2)]);
|
|
|
|
} else {
|
|
|
|
y = vs_4tap_taps[x][0] * RGB565_B (src[CLAMP ((j - 1), 0,
|
|
|
|
src_width - 1)]);
|
|
|
|
y += vs_4tap_taps[x][1] * RGB565_B (src[CLAMP (j, 0, src_width - 1)]);
|
|
|
|
y += vs_4tap_taps[x][2] * RGB565_B (src[CLAMP ((j + 1), 0,
|
|
|
|
src_width - 1)]);
|
|
|
|
y += vs_4tap_taps[x][3] * RGB565_B (src[CLAMP ((j + 2), 0,
|
|
|
|
src_width - 1)]);
|
|
|
|
}
|
|
|
|
y += (1 << (SHIFT - 1));
|
|
|
|
y_b = CLAMP (y >> SHIFT, 0, 255);
|
|
|
|
|
|
|
|
dest[i] = RGB565 (y_r, y_b, y_g);
|
|
|
|
acc += increment;
|
|
|
|
}
|
|
|
|
*xacc = acc;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
vs_scanline_merge_4tap_RGB565 (uint8_t * dest_u8, uint8_t * src1_u8,
|
|
|
|
uint8_t * src2_u8, uint8_t * src3_u8, uint8_t * src4_u8, int n, int acc)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int y, y_r, y_b, y_g;
|
|
|
|
int a, b, c, d;
|
|
|
|
uint16_t *dest = (uint16_t *) dest_u8;
|
|
|
|
uint16_t *src1 = (uint16_t *) src1_u8;
|
|
|
|
uint16_t *src2 = (uint16_t *) src2_u8;
|
|
|
|
uint16_t *src3 = (uint16_t *) src3_u8;
|
|
|
|
uint16_t *src4 = (uint16_t *) src4_u8;
|
|
|
|
|
|
|
|
acc = (acc >> 8) & 0xff;
|
|
|
|
a = vs_4tap_taps[acc][0];
|
|
|
|
b = vs_4tap_taps[acc][1];
|
|
|
|
c = vs_4tap_taps[acc][2];
|
|
|
|
d = vs_4tap_taps[acc][3];
|
|
|
|
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
y = a * RGB565_R (src1[i]);
|
|
|
|
y += b * RGB565_R (src2[i]);
|
|
|
|
y += c * RGB565_R (src3[i]);
|
|
|
|
y += d * RGB565_R (src4[i]);
|
|
|
|
y += (1 << (SHIFT - 1));
|
|
|
|
y_r = CLAMP (y >> SHIFT, 0, 255);
|
|
|
|
|
|
|
|
y = a * RGB565_G (src1[i]);
|
|
|
|
y += b * RGB565_G (src2[i]);
|
|
|
|
y += c * RGB565_G (src3[i]);
|
|
|
|
y += d * RGB565_G (src4[i]);
|
|
|
|
y += (1 << (SHIFT - 1));
|
|
|
|
y_g = CLAMP (y >> SHIFT, 0, 255);
|
|
|
|
|
|
|
|
y = a * RGB565_B (src1[i]);
|
|
|
|
y += b * RGB565_B (src2[i]);
|
|
|
|
y += c * RGB565_B (src3[i]);
|
|
|
|
y += d * RGB565_B (src4[i]);
|
|
|
|
y += (1 << (SHIFT - 1));
|
|
|
|
y_b = CLAMP (y >> SHIFT, 0, 255);
|
|
|
|
|
|
|
|
dest[i] = RGB565 (y_r, y_b, y_g);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
vs_image_scale_4tap_RGB565 (const VSImage * dest, const VSImage * src,
|
|
|
|
uint8_t * tmpbuf)
|
|
|
|
{
|
|
|
|
int yacc;
|
|
|
|
int y_increment;
|
|
|
|
int x_increment;
|
|
|
|
int i;
|
|
|
|
int j;
|
|
|
|
int xacc;
|
|
|
|
int k;
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
k = 0;
|
|
|
|
for (i = 0; i < 4; i++) {
|
|
|
|
xacc = 0;
|
|
|
|
vs_scanline_resample_4tap_RGB565 (tmpbuf + i * dest->stride,
|
2011-04-23 19:46:09 +00:00
|
|
|
src->pixels + CLAMP (i, 0, src->height - 1) * src->stride, dest->width,
|
|
|
|
src->width, &xacc, x_increment);
|
2009-03-27 12:14:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
yacc = 0;
|
|
|
|
for (i = 0; i < dest->height; i++) {
|
|
|
|
uint8_t *t0, *t1, *t2, *t3;
|
|
|
|
|
|
|
|
j = yacc >> 16;
|
|
|
|
|
|
|
|
while (j > k) {
|
|
|
|
k++;
|
|
|
|
if (k + 3 < src->height) {
|
|
|
|
xacc = 0;
|
|
|
|
vs_scanline_resample_4tap_RGB565 (tmpbuf + ((k + 3) & 3) * dest->stride,
|
|
|
|
src->pixels + (k + 3) * src->stride,
|
|
|
|
dest->width, src->width, &xacc, x_increment);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
t0 = tmpbuf + (CLAMP (j - 1, 0, src->height - 1) & 3) * dest->stride;
|
|
|
|
t1 = tmpbuf + (CLAMP (j, 0, src->height - 1) & 3) * dest->stride;
|
|
|
|
t2 = tmpbuf + (CLAMP (j + 1, 0, src->height - 1) & 3) * dest->stride;
|
|
|
|
t3 = tmpbuf + (CLAMP (j + 2, 0, src->height - 1) & 3) * dest->stride;
|
|
|
|
vs_scanline_merge_4tap_RGB565 (dest->pixels + i * dest->stride,
|
|
|
|
t0, t1, t2, t3, dest->width, yacc & 0xffff);
|
|
|
|
|
|
|
|
yacc += y_increment;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* note that src and dest are uint16_t, and thus endian dependent */
|
|
|
|
|
|
|
|
#define RGB555_R(x) (((x)&0x7c00)>>8 | ((x)&0x7c00)>>13)
|
|
|
|
#define RGB555_G(x) (((x)&0x03e0)>>3 | ((x)&0x03e0)>>9)
|
|
|
|
#define RGB555_B(x) (((x)&0x001f)<<3 | ((x)&0x001f)>>2)
|
|
|
|
|
|
|
|
#define RGB555(r,g,b) \
|
2009-03-27 18:12:49 +00:00
|
|
|
((((r)<<7)&0x7c00) | (((g)<<2)&0x03e0) | (((b)>>3)&0x001f))
|
2009-03-27 12:14:00 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
vs_scanline_resample_4tap_RGB555 (uint8_t * dest_u8, uint8_t * src_u8,
|
|
|
|
int n, int src_width, int *xacc, int increment)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int j;
|
|
|
|
int acc;
|
|
|
|
int x;
|
|
|
|
int y, y_r, y_b, y_g;
|
|
|
|
uint16_t *dest = (uint16_t *) dest_u8;
|
|
|
|
uint16_t *src = (uint16_t *) src_u8;
|
|
|
|
|
|
|
|
acc = *xacc;
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
j = acc >> 16;
|
|
|
|
x = acc & 0xffff >> 8;
|
|
|
|
|
|
|
|
if (j - 1 >= 0 && j + 2 < src_width) {
|
|
|
|
y = vs_4tap_taps[x][0] * RGB555_R (src[MAX ((j - 1), 0)]);
|
|
|
|
y += vs_4tap_taps[x][1] * RGB555_R (src[j]);
|
|
|
|
y += vs_4tap_taps[x][2] * RGB555_R (src[(j + 1)]);
|
|
|
|
y += vs_4tap_taps[x][3] * RGB555_R (src[(j + 2)]);
|
|
|
|
} else {
|
|
|
|
y = vs_4tap_taps[x][0] * RGB555_R (src[CLAMP ((j - 1), 0,
|
|
|
|
src_width - 1)]);
|
|
|
|
y += vs_4tap_taps[x][1] * RGB555_R (src[CLAMP (j, 0, src_width - 1)]);
|
|
|
|
y += vs_4tap_taps[x][2] * RGB555_R (src[CLAMP ((j + 1), 0,
|
|
|
|
src_width - 1)]);
|
|
|
|
y += vs_4tap_taps[x][3] * RGB555_R (src[CLAMP ((j + 2), 0,
|
|
|
|
src_width - 1)]);
|
|
|
|
}
|
|
|
|
y += (1 << (SHIFT - 1));
|
|
|
|
y_r = CLAMP (y >> SHIFT, 0, 255);
|
|
|
|
|
|
|
|
if (j - 1 >= 0 && j + 2 < src_width) {
|
|
|
|
y = vs_4tap_taps[x][0] * RGB555_G (src[MAX ((j - 1), 0)]);
|
|
|
|
y += vs_4tap_taps[x][1] * RGB555_G (src[j]);
|
|
|
|
y += vs_4tap_taps[x][2] * RGB555_G (src[(j + 1)]);
|
|
|
|
y += vs_4tap_taps[x][3] * RGB555_G (src[(j + 2)]);
|
|
|
|
} else {
|
|
|
|
y = vs_4tap_taps[x][0] * RGB555_G (src[CLAMP ((j - 1), 0,
|
|
|
|
src_width - 1)]);
|
|
|
|
y += vs_4tap_taps[x][1] * RGB555_G (src[CLAMP (j, 0, src_width - 1)]);
|
|
|
|
y += vs_4tap_taps[x][2] * RGB555_G (src[CLAMP ((j + 1), 0,
|
|
|
|
src_width - 1)]);
|
|
|
|
y += vs_4tap_taps[x][3] * RGB555_G (src[CLAMP ((j + 2), 0,
|
|
|
|
src_width - 1)]);
|
|
|
|
}
|
|
|
|
y += (1 << (SHIFT - 1));
|
|
|
|
y_g = CLAMP (y >> SHIFT, 0, 255);
|
|
|
|
|
|
|
|
if (j - 1 >= 0 && j + 2 < src_width) {
|
|
|
|
y = vs_4tap_taps[x][0] * RGB555_B (src[MAX ((j - 1), 0)]);
|
|
|
|
y += vs_4tap_taps[x][1] * RGB555_B (src[j]);
|
|
|
|
y += vs_4tap_taps[x][2] * RGB555_B (src[(j + 1)]);
|
|
|
|
y += vs_4tap_taps[x][3] * RGB555_B (src[(j + 2)]);
|
|
|
|
} else {
|
|
|
|
y = vs_4tap_taps[x][0] * RGB555_B (src[CLAMP ((j - 1), 0,
|
|
|
|
src_width - 1)]);
|
|
|
|
y += vs_4tap_taps[x][1] * RGB555_B (src[CLAMP (j, 0, src_width - 1)]);
|
|
|
|
y += vs_4tap_taps[x][2] * RGB555_B (src[CLAMP ((j + 1), 0,
|
|
|
|
src_width - 1)]);
|
|
|
|
y += vs_4tap_taps[x][3] * RGB555_B (src[CLAMP ((j + 2), 0,
|
|
|
|
src_width - 1)]);
|
|
|
|
}
|
|
|
|
y += (1 << (SHIFT - 1));
|
|
|
|
y_b = CLAMP (y >> SHIFT, 0, 255);
|
|
|
|
|
|
|
|
dest[i] = RGB555 (y_r, y_b, y_g);
|
|
|
|
acc += increment;
|
|
|
|
}
|
|
|
|
*xacc = acc;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
vs_scanline_merge_4tap_RGB555 (uint8_t * dest_u8, uint8_t * src1_u8,
|
|
|
|
uint8_t * src2_u8, uint8_t * src3_u8, uint8_t * src4_u8, int n, int acc)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int y, y_r, y_b, y_g;
|
|
|
|
int a, b, c, d;
|
|
|
|
uint16_t *dest = (uint16_t *) dest_u8;
|
|
|
|
uint16_t *src1 = (uint16_t *) src1_u8;
|
|
|
|
uint16_t *src2 = (uint16_t *) src2_u8;
|
|
|
|
uint16_t *src3 = (uint16_t *) src3_u8;
|
|
|
|
uint16_t *src4 = (uint16_t *) src4_u8;
|
|
|
|
|
|
|
|
acc = (acc >> 8) & 0xff;
|
|
|
|
a = vs_4tap_taps[acc][0];
|
|
|
|
b = vs_4tap_taps[acc][1];
|
|
|
|
c = vs_4tap_taps[acc][2];
|
|
|
|
d = vs_4tap_taps[acc][3];
|
|
|
|
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
y = a * RGB555_R (src1[i]);
|
|
|
|
y += b * RGB555_R (src2[i]);
|
|
|
|
y += c * RGB555_R (src3[i]);
|
|
|
|
y += d * RGB555_R (src4[i]);
|
|
|
|
y += (1 << (SHIFT - 1));
|
|
|
|
y_r = CLAMP (y >> SHIFT, 0, 255);
|
|
|
|
|
|
|
|
y = a * RGB555_G (src1[i]);
|
|
|
|
y += b * RGB555_G (src2[i]);
|
|
|
|
y += c * RGB555_G (src3[i]);
|
|
|
|
y += d * RGB555_G (src4[i]);
|
|
|
|
y += (1 << (SHIFT - 1));
|
|
|
|
y_g = CLAMP (y >> SHIFT, 0, 255);
|
|
|
|
|
|
|
|
y = a * RGB555_B (src1[i]);
|
|
|
|
y += b * RGB555_B (src2[i]);
|
|
|
|
y += c * RGB555_B (src3[i]);
|
|
|
|
y += d * RGB555_B (src4[i]);
|
|
|
|
y += (1 << (SHIFT - 1));
|
|
|
|
y_b = CLAMP (y >> SHIFT, 0, 255);
|
|
|
|
|
|
|
|
dest[i] = RGB555 (y_r, y_b, y_g);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
vs_image_scale_4tap_RGB555 (const VSImage * dest, const VSImage * src,
|
|
|
|
uint8_t * tmpbuf)
|
|
|
|
{
|
|
|
|
int yacc;
|
|
|
|
int y_increment;
|
|
|
|
int x_increment;
|
|
|
|
int i;
|
|
|
|
int j;
|
|
|
|
int xacc;
|
|
|
|
int k;
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
k = 0;
|
|
|
|
for (i = 0; i < 4; i++) {
|
|
|
|
xacc = 0;
|
|
|
|
vs_scanline_resample_4tap_RGB555 (tmpbuf + i * dest->stride,
|
2011-04-23 19:46:09 +00:00
|
|
|
src->pixels + CLAMP (i, 0, src->height - 1) * src->stride, dest->width,
|
|
|
|
src->width, &xacc, x_increment);
|
2009-03-27 12:14:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
yacc = 0;
|
|
|
|
for (i = 0; i < dest->height; i++) {
|
|
|
|
uint8_t *t0, *t1, *t2, *t3;
|
|
|
|
|
|
|
|
j = yacc >> 16;
|
|
|
|
|
|
|
|
while (j > k) {
|
|
|
|
k++;
|
|
|
|
if (k + 3 < src->height) {
|
|
|
|
xacc = 0;
|
|
|
|
vs_scanline_resample_4tap_RGB555 (tmpbuf + ((k + 3) & 3) * dest->stride,
|
|
|
|
src->pixels + (k + 3) * src->stride,
|
|
|
|
dest->width, src->width, &xacc, x_increment);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
t0 = tmpbuf + (CLAMP (j - 1, 0, src->height - 1) & 3) * dest->stride;
|
|
|
|
t1 = tmpbuf + (CLAMP (j, 0, src->height - 1) & 3) * dest->stride;
|
|
|
|
t2 = tmpbuf + (CLAMP (j + 1, 0, src->height - 1) & 3) * dest->stride;
|
|
|
|
t3 = tmpbuf + (CLAMP (j + 2, 0, src->height - 1) & 3) * dest->stride;
|
|
|
|
vs_scanline_merge_4tap_RGB555 (dest->pixels + i * dest->stride,
|
|
|
|
t0, t1, t2, t3, dest->width, yacc & 0xffff);
|
|
|
|
|
|
|
|
yacc += y_increment;
|
|
|
|
}
|
|
|
|
}
|
2011-02-20 02:50:37 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
vs_scanline_resample_4tap_AYUV64 (uint16_t * dest, uint16_t * src,
|
|
|
|
int n, int src_width, int *xacc, int increment)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int j;
|
|
|
|
int acc;
|
|
|
|
int x;
|
|
|
|
int y;
|
|
|
|
int off;
|
|
|
|
|
|
|
|
acc = *xacc;
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
j = acc >> 16;
|
|
|
|
x = (acc & 0xffff) >> 8;
|
|
|
|
|
|
|
|
for (off = 0; off < 4; off++) {
|
|
|
|
if (j - 1 >= 0 && j + 2 < src_width) {
|
|
|
|
y = vs_4tap_taps[x][0] * src[MAX ((j - 1) * 4 + off, 0)];
|
|
|
|
y += vs_4tap_taps[x][1] * src[j * 4 + off];
|
|
|
|
y += vs_4tap_taps[x][2] * src[(j + 1) * 4 + off];
|
|
|
|
y += vs_4tap_taps[x][3] * src[(j + 2) * 4 + off];
|
|
|
|
} else {
|
|
|
|
y = vs_4tap_taps[x][0] * src[CLAMP ((j - 1) * 4 + off, 0,
|
|
|
|
4 * (src_width - 1) + off)];
|
|
|
|
y += vs_4tap_taps[x][1] * src[CLAMP (j * 4 + off, 0,
|
|
|
|
4 * (src_width - 1) + off)];
|
|
|
|
y += vs_4tap_taps[x][2] * src[CLAMP ((j + 1) * 4 + off, 0,
|
|
|
|
4 * (src_width - 1) + off)];
|
|
|
|
y += vs_4tap_taps[x][3] * src[CLAMP ((j + 2) * 4 + off, 0,
|
|
|
|
4 * (src_width - 1) + off)];
|
|
|
|
}
|
|
|
|
y += (1 << (SHIFT - 1));
|
|
|
|
dest[i * 4 + off] = CLAMP (y >> SHIFT, 0, 255);
|
|
|
|
}
|
|
|
|
acc += increment;
|
|
|
|
}
|
|
|
|
*xacc = acc;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
vs_scanline_merge_4tap_AYUV64 (uint16_t * dest, uint16_t * src1,
|
|
|
|
uint16_t * src2, uint16_t * src3, uint16_t * src4, int n, int acc)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int y;
|
|
|
|
int off;
|
|
|
|
int a, b, c, d;
|
|
|
|
|
|
|
|
acc = (acc >> 8) & 0xff;
|
|
|
|
a = vs_4tap_taps[acc][0];
|
|
|
|
b = vs_4tap_taps[acc][1];
|
|
|
|
c = vs_4tap_taps[acc][2];
|
|
|
|
d = vs_4tap_taps[acc][3];
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
for (off = 0; off < 4; off++) {
|
|
|
|
y = a * src1[i * 4 + off];
|
|
|
|
y += b * src2[i * 4 + off];
|
|
|
|
y += c * src3[i * 4 + off];
|
|
|
|
y += d * src4[i * 4 + off];
|
|
|
|
y += (1 << (SHIFT - 1));
|
|
|
|
dest[i * 4 + off] = CLAMP (y >> SHIFT, 0, 65535);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
vs_image_scale_4tap_AYUV64 (const VSImage * dest, const VSImage * src,
|
|
|
|
uint8_t * tmpbuf8)
|
|
|
|
{
|
|
|
|
int yacc;
|
|
|
|
int y_increment;
|
|
|
|
int x_increment;
|
|
|
|
int i;
|
|
|
|
int j;
|
|
|
|
int xacc;
|
|
|
|
int k;
|
|
|
|
guint16 *tmpbuf = (guint16 *) tmpbuf8;
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
k = 0;
|
|
|
|
for (i = 0; i < 4; i++) {
|
|
|
|
xacc = 0;
|
|
|
|
vs_scanline_resample_4tap_AYUV64 ((guint16 *) (tmpbuf + i * dest->stride),
|
2011-04-23 19:46:09 +00:00
|
|
|
(guint16 *) (src->pixels + CLAMP (i, 0, src->height - 1) * src->stride),
|
|
|
|
dest->width, src->width, &xacc, x_increment);
|
2011-02-20 02:50:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
yacc = 0;
|
|
|
|
for (i = 0; i < dest->height; i++) {
|
|
|
|
uint16_t *t0, *t1, *t2, *t3;
|
|
|
|
|
|
|
|
j = yacc >> 16;
|
|
|
|
|
|
|
|
while (j > k) {
|
|
|
|
k++;
|
|
|
|
if (k + 3 < src->height) {
|
|
|
|
xacc = 0;
|
|
|
|
vs_scanline_resample_4tap_AYUV64 ((guint16 *) (tmpbuf + ((k +
|
|
|
|
3) & 3) * dest->stride),
|
|
|
|
(guint16 *) (src->pixels + (k + 3) * src->stride), dest->width,
|
|
|
|
src->width, &xacc, x_increment);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
t0 = tmpbuf + (CLAMP (j - 1, 0, src->height - 1) & 3) * dest->stride;
|
|
|
|
t1 = tmpbuf + (CLAMP (j, 0, src->height - 1) & 3) * dest->stride;
|
|
|
|
t2 = tmpbuf + (CLAMP (j + 1, 0, src->height - 1) & 3) * dest->stride;
|
|
|
|
t3 = tmpbuf + (CLAMP (j + 2, 0, src->height - 1) & 3) * dest->stride;
|
|
|
|
vs_scanline_merge_4tap_AYUV64 ((guint16 *) (dest->pixels +
|
|
|
|
i * dest->stride), t0, t1, t2, t3, dest->width, yacc & 0xffff);
|
|
|
|
|
|
|
|
yacc += y_increment;
|
|
|
|
}
|
|
|
|
}
|