From 835422b2ea3fafd31e32b05627d90be5ca2f403c Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 24 Oct 2014 17:08:43 +0200 Subject: [PATCH] videoscale: port to new API --- gst/videoscale/Makefile.am | 26 +- gst/videoscale/gstvideoscale.c | 570 +----- gst/videoscale/gstvideoscale.h | 7 +- gst/videoscale/gstvideoscaleorc-dist.c | 2561 ------------------------ gst/videoscale/gstvideoscaleorc-dist.h | 104 - gst/videoscale/gstvideoscaleorc.orc | 197 -- gst/videoscale/vs_4tap.c | 1634 --------------- gst/videoscale/vs_4tap.h | 76 - gst/videoscale/vs_fill_borders.c | 421 ---- gst/videoscale/vs_fill_borders.h | 44 - gst/videoscale/vs_image.c | 1282 ------------ gst/videoscale/vs_image.h | 182 -- gst/videoscale/vs_lanczos.c | 2125 -------------------- gst/videoscale/vs_scanline.c | 778 ------- gst/videoscale/vs_scanline.h | 85 - tests/check/Makefile.am | 10 +- 16 files changed, 62 insertions(+), 10040 deletions(-) delete mode 100644 gst/videoscale/gstvideoscaleorc-dist.c delete mode 100644 gst/videoscale/gstvideoscaleorc-dist.h delete mode 100644 gst/videoscale/gstvideoscaleorc.orc delete mode 100644 gst/videoscale/vs_4tap.c delete mode 100644 gst/videoscale/vs_4tap.h delete mode 100644 gst/videoscale/vs_fill_borders.c delete mode 100644 gst/videoscale/vs_fill_borders.h delete mode 100644 gst/videoscale/vs_image.c delete mode 100644 gst/videoscale/vs_image.h delete mode 100644 gst/videoscale/vs_lanczos.c delete mode 100644 gst/videoscale/vs_scanline.c delete mode 100644 gst/videoscale/vs_scanline.h diff --git a/gst/videoscale/Makefile.am b/gst/videoscale/Makefile.am index 5d96422cc7..053cddf4bf 100644 --- a/gst/videoscale/Makefile.am +++ b/gst/videoscale/Makefile.am @@ -1,39 +1,23 @@ plugin_LTLIBRARIES = libgstvideoscale.la -ORC_SOURCE=gstvideoscaleorc -include $(top_srcdir)/common/orc.mak +libgstvideoscale_la_SOURCES = gstvideoscale.c -libgstvideoscale_la_SOURCES = \ - gstvideoscale.c \ - vs_image.c \ - vs_scanline.c \ - vs_4tap.c \ - vs_fill_borders.c \ - vs_lanczos.c - -nodist_libgstvideoscale_la_SOURCES = $(ORC_NODIST_SOURCES) - -libgstvideoscale_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS) $(ORC_CFLAGS) +libgstvideoscale_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS) libgstvideoscale_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) libgstvideoscale_la_LIBADD = \ $(top_builddir)/gst-libs/gst/video/libgstvideo-$(GST_API_VERSION).la \ - $(GST_BASE_LIBS) $(GST_LIBS) $(ORC_LIBS) $(LIBM) + $(GST_BASE_LIBS) $(GST_LIBS) $(LIBM) libgstvideoscale_la_LIBTOOLFLAGS = $(GST_PLUGIN_LIBTOOLFLAGS) noinst_HEADERS = \ - gstvideoscale.h \ - vs_image.h \ - vs_scanline.h \ - vs_4tap.h \ - vs_fill_borders.h + gstvideoscale.h Android.mk: Makefile.am $(BUILT_SOURCES) androgenizer \ -:PROJECT libgstvideoscale -:SHARED libgstvideoscale \ -:TAGS eng debug \ -:REL_TOP $(top_srcdir) -:ABS_TOP $(abs_top_srcdir) \ - -:SOURCES $(libgstvideoscale_la_SOURCES) \ - $(nodist_libgstvideoscale_la_SOURCES) \ + -:SOURCES $(libgstvideoscale_la_SOURCES) -:CFLAGS $(DEFS) $(DEFAULT_INCLUDES) $(libgstvideoscale_la_CFLAGS) \ -:LDFLAGS $(libgstvideoscale_la_LDFLAGS) \ $(libgstvideoscale_la_LIBADD) \ diff --git a/gst/videoscale/gstvideoscale.c b/gst/videoscale/gstvideoscale.c index 527527b4f7..b0a6982f49 100644 --- a/gst/videoscale/gstvideoscale.c +++ b/gst/videoscale/gstvideoscale.c @@ -78,10 +78,6 @@ #include #include "gstvideoscale.h" -#include "gstvideoscaleorc.h" -#include "vs_image.h" -#include "vs_4tap.h" -#include "vs_fill_borders.h" /* debug variable definition */ GST_DEBUG_CATEGORY (video_scale_debug); @@ -120,11 +116,7 @@ enum * FIXME: add r210 support */ -#define GST_VIDEO_FORMATS "{ I420, YV12, YUY2, UYVY, AYUV, RGBx, " \ - "BGRx, xRGB, xBGR, RGBA, BGRA, ARGB, ABGR, RGB, " \ - "BGR, Y41B, Y42B, YVYU, Y444, GRAY8, GRAY16_BE, GRAY16_LE, " \ - "v308, RGB16, RGB15, ARGB64, AYUV64, NV12, NV21 } " - +#define GST_VIDEO_FORMATS GST_VIDEO_FORMATS_ALL static GstStaticCaps gst_video_scale_format_caps = GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE (GST_VIDEO_FORMATS) ";" @@ -200,9 +192,6 @@ static void gst_video_scale_set_property (GObject * object, guint prop_id, static void gst_video_scale_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec); -static GstFlowReturn do_scale (GstVideoFilter * filter, VSImage dest[4], - VSImage src[4]); - #define gst_video_scale_parent_class parent_class G_DEFINE_TYPE (GstVideoScale, gst_video_scale, GST_TYPE_VIDEO_FILTER); @@ -281,7 +270,6 @@ gst_video_scale_class_init (GstVideoScaleClass * klass) static void gst_video_scale_init (GstVideoScale * videoscale) { - videoscale->tmp_buf = NULL; videoscale->method = DEFAULT_PROP_METHOD; videoscale->add_borders = DEFAULT_PROP_ADD_BORDERS; videoscale->submethod = DEFAULT_PROP_SUBMETHOD; @@ -294,8 +282,8 @@ gst_video_scale_init (GstVideoScale * videoscale) static void gst_video_scale_finalize (GstVideoScale * videoscale) { - if (videoscale->tmp_buf) - g_free (videoscale->tmp_buf); + if (videoscale->convert) + gst_video_converter_free (videoscale->convert); G_OBJECT_CLASS (parent_class)->finalize (G_OBJECT (videoscale)); } @@ -397,47 +385,11 @@ gst_video_scale_get_property (GObject * object, guint prop_id, GValue * value, } } -static GstCaps * -get_formats_filter (GstVideoScaleMethod method) -{ - switch (method) { - case GST_VIDEO_SCALE_NEAREST: - case GST_VIDEO_SCALE_BILINEAR: - return NULL; - case GST_VIDEO_SCALE_4TAP: - { - static GstStaticCaps fourtap_filter = - GST_STATIC_CAPS ("video/x-raw(ANY)," - "format = (string) { RGBx, xRGB, BGRx, xBGR, RGBA, " - "ARGB, BGRA, ABGR, AYUV, ARGB64, AYUV64, " - "RGB, BGR, v308, YUY2, YVYU, UYVY, " - "GRAY8, GRAY16_LE, GRAY16_BE, I420, YV12, " - "Y444, Y42B, Y41B, RGB16, RGB15, NV12, NV21 }"); - return gst_static_caps_get (&fourtap_filter); - } - case GST_VIDEO_SCALE_LANCZOS: - { - static GstStaticCaps lanczos_filter = - GST_STATIC_CAPS ("video/x-raw(ANY)," - "format = (string) { RGBx, xRGB, BGRx, xBGR, RGBA, " - "ARGB, BGRA, ABGR, AYUV, ARGB64, AYUV64, " - "I420, YV12, Y444, Y42B, Y41B, NV12, NV21 }"); - return gst_static_caps_get (&lanczos_filter); - } - default: - g_assert_not_reached (); - break; - } - return NULL; -} - static GstCaps * gst_video_scale_transform_caps (GstBaseTransform * trans, GstPadDirection direction, GstCaps * caps, GstCaps * filter) { - GstVideoScale *videoscale = GST_VIDEO_SCALE (trans); - GstVideoScaleMethod method; - GstCaps *ret, *mfilter; + GstCaps *ret; GstStructure *structure; GstCapsFeatures *features; gint i, n; @@ -446,20 +398,6 @@ gst_video_scale_transform_caps (GstBaseTransform * trans, "Transforming caps %" GST_PTR_FORMAT " in direction %s", caps, (direction == GST_PAD_SINK) ? "sink" : "src"); - GST_OBJECT_LOCK (videoscale); - method = videoscale->method; - GST_OBJECT_UNLOCK (videoscale); - - /* filter the supported formats */ - /* FIXME: Ideally we would still allow passthrough for the color formats - * that are unsupported by the selected method */ - if ((mfilter = get_formats_filter (method))) { - caps = gst_caps_intersect_full (caps, mfilter, GST_CAPS_INTERSECT_FIRST); - gst_caps_unref (mfilter); - } else { - gst_caps_ref (caps); - } - ret = gst_caps_new_empty (); n = gst_caps_get_size (caps); for (i = 0; i < n; i++) { @@ -487,7 +425,6 @@ gst_video_scale_transform_caps (GstBaseTransform * trans, GST_TYPE_FRACTION_RANGE, 1, G_MAXINT, G_MAXINT, 1, NULL); } } - gst_caps_append_structure_full (ret, structure, gst_caps_features_copy (features)); } @@ -501,7 +438,6 @@ gst_video_scale_transform_caps (GstBaseTransform * trans, ret = intersection; } - gst_caps_unref (caps); GST_DEBUG_OBJECT (trans, "returning caps: %" GST_PTR_FORMAT, ret); return ret; @@ -552,16 +488,57 @@ gst_video_scale_set_info (GstVideoFilter * filter, GstCaps * in, } } - if (videoscale->tmp_buf) - g_free (videoscale->tmp_buf); - videoscale->tmp_buf = g_malloc (out_info->width * sizeof (guint64) * 4); - if (in_info->width == out_info->width && in_info->height == out_info->height && videoscale->borders_w == 0 && videoscale->borders_h == 0) { gst_base_transform_set_passthrough (GST_BASE_TRANSFORM (filter), TRUE); } else { + GstStructure *options; GST_CAT_DEBUG_OBJECT (GST_CAT_PERFORMANCE, filter, "setup videoscaling"); gst_base_transform_set_passthrough (GST_BASE_TRANSFORM (filter), FALSE); + + options = gst_structure_new_empty ("videoscale"); + + switch (videoscale->method) { + case GST_VIDEO_SCALE_NEAREST: + gst_structure_set (options, + GST_VIDEO_CONVERTER_OPT_RESAMPLER_METHOD, + GST_TYPE_VIDEO_RESAMPLER_METHOD, GST_VIDEO_RESAMPLER_METHOD_NEAREST, + NULL); + break; + case GST_VIDEO_SCALE_BILINEAR: + gst_structure_set (options, + GST_VIDEO_CONVERTER_OPT_RESAMPLER_METHOD, + GST_TYPE_VIDEO_RESAMPLER_METHOD, GST_VIDEO_RESAMPLER_METHOD_LINEAR, + NULL); + break; + case GST_VIDEO_SCALE_4TAP: + gst_structure_set (options, + GST_VIDEO_CONVERTER_OPT_RESAMPLER_METHOD, + GST_TYPE_VIDEO_RESAMPLER_METHOD, GST_VIDEO_RESAMPLER_METHOD_CUBIC, + NULL); + break; + case GST_VIDEO_SCALE_LANCZOS: + gst_structure_set (options, + GST_VIDEO_CONVERTER_OPT_RESAMPLER_METHOD, + GST_TYPE_VIDEO_RESAMPLER_METHOD, GST_VIDEO_RESAMPLER_METHOD_LANCZOS, + GST_VIDEO_RESAMPLER_OPT_ENVELOPE, G_TYPE_DOUBLE, + videoscale->envelope, GST_VIDEO_RESAMPLER_OPT_SHARPNESS, + G_TYPE_DOUBLE, videoscale->sharpness, + GST_VIDEO_RESAMPLER_OPT_SHARPEN, G_TYPE_DOUBLE, videoscale->sharpen, + NULL); + break; + } + gst_structure_set (options, + GST_VIDEO_CONVERTER_OPT_DEST_X, G_TYPE_INT, videoscale->borders_w / 2, + GST_VIDEO_CONVERTER_OPT_DEST_Y, G_TYPE_INT, videoscale->borders_h / 2, + GST_VIDEO_CONVERTER_OPT_DEST_WIDTH, G_TYPE_INT, + out_info->width - videoscale->borders_w, + GST_VIDEO_CONVERTER_OPT_DEST_HEIGHT, G_TYPE_INT, + out_info->height - videoscale->borders_h, NULL); + + if (videoscale->convert) + gst_video_converter_free (videoscale->convert); + videoscale->convert = gst_video_converter_new (in_info, out_info, options); } GST_DEBUG_OBJECT (videoscale, "from=%dx%d (par=%d/%d dar=%d/%d), size %" @@ -1012,457 +989,20 @@ done: return othercaps; } -static void -gst_video_scale_setup_vs_image (VSImage * image, GstVideoFrame * frame, - gint component, gint b_w, gint b_h, gboolean interlaced, gint field) -{ - GstVideoFormat format; - gint width, height; - - format = GST_VIDEO_FRAME_FORMAT (frame); - width = GST_VIDEO_FRAME_WIDTH (frame); - height = GST_VIDEO_FRAME_HEIGHT (frame); - - image->real_width = GST_VIDEO_FRAME_COMP_WIDTH (frame, component); - image->real_height = GST_VIDEO_FRAME_COMP_HEIGHT (frame, component); - image->width = GST_VIDEO_FORMAT_INFO_SCALE_WIDTH (frame->info.finfo, - component, MAX (1, width - b_w)); - image->height = GST_VIDEO_FORMAT_INFO_SCALE_HEIGHT (frame->info.finfo, - component, MAX (1, height - b_h)); - - if (interlaced) { - image->real_height /= 2; - image->height /= 2; - } - - image->border_top = (image->real_height - image->height) / 2; - image->border_bottom = image->real_height - image->height - image->border_top; - - if (format == GST_VIDEO_FORMAT_YUY2 || format == GST_VIDEO_FORMAT_YVYU - || format == GST_VIDEO_FORMAT_UYVY) { - g_assert (component == 0); - - image->border_left = (image->real_width - image->width) / 2; - - if (image->border_left % 2 == 1) - image->border_left--; - image->border_right = image->real_width - image->width - image->border_left; - } else { - image->border_left = (image->real_width - image->width) / 2; - image->border_right = image->real_width - image->width - image->border_left; - } - - image->real_pixels = GST_VIDEO_FRAME_PLANE_DATA (frame, component); - image->stride = GST_VIDEO_FRAME_PLANE_STRIDE (frame, component); - - if (interlaced) { - if (field == 1) - image->real_pixels += image->stride; - image->stride *= 2; - } - - image->pixels = - image->real_pixels + image->border_top * image->stride + - image->border_left * GST_VIDEO_FRAME_COMP_PSTRIDE (frame, component); - -} - -static const guint8 * -_get_black_for_format (GstVideoFormat format) -{ - static const guint8 black[][4] = { - {255, 0, 0, 0}, /* 0 = ARGB, ABGR, xRGB, xBGR */ - {0, 0, 0, 255}, /* 1 = RGBA, BGRA, RGBx, BGRx */ - {255, 16, 128, 128}, /* 2 = AYUV */ - {0, 0, 0, 0}, /* 3 = RGB and BGR */ - {16, 128, 128, 0}, /* 4 = v301 */ - {16, 128, 16, 128}, /* 5 = YUY2, YUYV */ - {128, 16, 128, 16}, /* 6 = UYVY */ - {16, 0, 0, 0}, /* 7 = Y */ - {0, 0, 0, 0} /* 8 = RGB565, RGB666 */ - }; - - switch (format) { - case GST_VIDEO_FORMAT_ARGB: - case GST_VIDEO_FORMAT_ABGR: - case GST_VIDEO_FORMAT_xRGB: - case GST_VIDEO_FORMAT_xBGR: - case GST_VIDEO_FORMAT_ARGB64: - return black[0]; - case GST_VIDEO_FORMAT_RGBA: - case GST_VIDEO_FORMAT_BGRA: - case GST_VIDEO_FORMAT_RGBx: - case GST_VIDEO_FORMAT_BGRx: - return black[1]; - case GST_VIDEO_FORMAT_AYUV: - case GST_VIDEO_FORMAT_AYUV64: - return black[2]; - case GST_VIDEO_FORMAT_RGB: - case GST_VIDEO_FORMAT_BGR: - return black[3]; - case GST_VIDEO_FORMAT_v308: - return black[4]; - case GST_VIDEO_FORMAT_YUY2: - case GST_VIDEO_FORMAT_YVYU: - return black[5]; - case GST_VIDEO_FORMAT_UYVY: - return black[6]; - case GST_VIDEO_FORMAT_GRAY8: - return black[7]; - case GST_VIDEO_FORMAT_GRAY16_LE: - case GST_VIDEO_FORMAT_GRAY16_BE: - return NULL; /* Handled by the caller */ - case GST_VIDEO_FORMAT_I420: - case GST_VIDEO_FORMAT_YV12: - case GST_VIDEO_FORMAT_Y444: - case GST_VIDEO_FORMAT_Y42B: - case GST_VIDEO_FORMAT_Y41B: - case GST_VIDEO_FORMAT_NV12: - case GST_VIDEO_FORMAT_NV21: - return black[4]; /* Y, U, V, 0 */ - case GST_VIDEO_FORMAT_RGB16: - case GST_VIDEO_FORMAT_RGB15: - return black[8]; - default: - return NULL; - } -} +#define GET_LINE(frame, line) \ + (gpointer)(((guint8*)(GST_VIDEO_FRAME_PLANE_DATA (frame, 0))) + \ + GST_VIDEO_FRAME_PLANE_STRIDE (frame, 0) * (line)) static GstFlowReturn gst_video_scale_transform_frame (GstVideoFilter * filter, GstVideoFrame * in_frame, GstVideoFrame * out_frame) { - GstVideoScale *videoscale = GST_VIDEO_SCALE (filter); + GstVideoScale *videoscale = GST_VIDEO_SCALE_CAST (filter); GstFlowReturn ret = GST_FLOW_OK; - VSImage dest[4] = { {NULL,}, }; - VSImage src[4] = { {NULL,}, }; - gint i; - gboolean interlaced; - interlaced = GST_VIDEO_FRAME_IS_INTERLACED (in_frame); - - for (i = 0; i < GST_VIDEO_FRAME_N_PLANES (in_frame); i++) { - gst_video_scale_setup_vs_image (&src[i], in_frame, i, 0, 0, interlaced, 0); - gst_video_scale_setup_vs_image (&dest[i], out_frame, i, - videoscale->borders_w, videoscale->borders_h, interlaced, 0); - } - ret = do_scale (filter, dest, src); - - if (interlaced) { - for (i = 0; i < GST_VIDEO_FRAME_N_PLANES (in_frame); i++) { - gst_video_scale_setup_vs_image (&src[i], in_frame, i, 0, 0, interlaced, - 1); - gst_video_scale_setup_vs_image (&dest[i], out_frame, i, - videoscale->borders_w, videoscale->borders_h, interlaced, 1); - } - ret = do_scale (filter, dest, src); - } - return ret; -} - -static GstFlowReturn -do_scale (GstVideoFilter * filter, VSImage dest[4], VSImage src[4]) -{ - GstVideoScale *videoscale = GST_VIDEO_SCALE (filter); - GstFlowReturn ret = GST_FLOW_OK; - gint method; - const guint8 *black; - GstVideoFormat format; - gboolean add_borders; - - GST_OBJECT_LOCK (videoscale); - method = videoscale->method; - add_borders = videoscale->add_borders; - GST_OBJECT_UNLOCK (videoscale); - - format = GST_VIDEO_INFO_FORMAT (&filter->in_info); - black = _get_black_for_format (format); - - if (filter->in_info.width == 1) { - method = GST_VIDEO_SCALE_NEAREST; - } - if (method == GST_VIDEO_SCALE_4TAP && - (filter->in_info.width < 4 || filter->in_info.height < 4)) { - method = GST_VIDEO_SCALE_BILINEAR; - } - - GST_CAT_DEBUG_OBJECT (GST_CAT_PERFORMANCE, filter, - "doing videoscale format %s", GST_VIDEO_INFO_NAME (&filter->in_info)); - - switch (format) { - case GST_VIDEO_FORMAT_RGBx: - case GST_VIDEO_FORMAT_xRGB: - case GST_VIDEO_FORMAT_BGRx: - case GST_VIDEO_FORMAT_xBGR: - case GST_VIDEO_FORMAT_RGBA: - case GST_VIDEO_FORMAT_ARGB: - case GST_VIDEO_FORMAT_BGRA: - case GST_VIDEO_FORMAT_ABGR: - case GST_VIDEO_FORMAT_AYUV: - if (add_borders) - vs_fill_borders_RGBA (&dest[0], black); - switch (method) { - case GST_VIDEO_SCALE_NEAREST: - vs_image_scale_nearest_RGBA (&dest[0], &src[0], videoscale->tmp_buf); - break; - case GST_VIDEO_SCALE_BILINEAR: - vs_image_scale_linear_RGBA (&dest[0], &src[0], videoscale->tmp_buf); - break; - case GST_VIDEO_SCALE_4TAP: - vs_image_scale_4tap_RGBA (&dest[0], &src[0], videoscale->tmp_buf); - break; - case GST_VIDEO_SCALE_LANCZOS: - vs_image_scale_lanczos_AYUV (&dest[0], &src[0], videoscale->tmp_buf, - videoscale->sharpness, videoscale->dither, videoscale->submethod, - videoscale->envelope, videoscale->sharpen); - break; - default: - goto unknown_mode; - } - break; - case GST_VIDEO_FORMAT_ARGB64: - case GST_VIDEO_FORMAT_AYUV64: - if (add_borders) - vs_fill_borders_AYUV64 (&dest[0], black); - switch (method) { - case GST_VIDEO_SCALE_NEAREST: - vs_image_scale_nearest_AYUV64 (&dest[0], &src[0], - videoscale->tmp_buf); - break; - case GST_VIDEO_SCALE_BILINEAR: - vs_image_scale_linear_AYUV64 (&dest[0], &src[0], videoscale->tmp_buf); - break; - case GST_VIDEO_SCALE_4TAP: - vs_image_scale_4tap_AYUV64 (&dest[0], &src[0], videoscale->tmp_buf); - break; - case GST_VIDEO_SCALE_LANCZOS: - vs_image_scale_lanczos_AYUV64 (&dest[0], &src[0], videoscale->tmp_buf, - videoscale->sharpness, videoscale->dither, videoscale->submethod, - videoscale->envelope, videoscale->sharpen); - break; - default: - goto unknown_mode; - } - break; - case GST_VIDEO_FORMAT_RGB: - case GST_VIDEO_FORMAT_BGR: - case GST_VIDEO_FORMAT_v308: - if (add_borders) - vs_fill_borders_RGB (&dest[0], black); - switch (method) { - case GST_VIDEO_SCALE_NEAREST: - vs_image_scale_nearest_RGB (&dest[0], &src[0], videoscale->tmp_buf); - break; - case GST_VIDEO_SCALE_BILINEAR: - vs_image_scale_linear_RGB (&dest[0], &src[0], videoscale->tmp_buf); - break; - case GST_VIDEO_SCALE_4TAP: - vs_image_scale_4tap_RGB (&dest[0], &src[0], videoscale->tmp_buf); - break; - default: - goto unknown_mode; - } - break; - case GST_VIDEO_FORMAT_YUY2: - case GST_VIDEO_FORMAT_YVYU: - if (add_borders) - vs_fill_borders_YUYV (&dest[0], black); - switch (method) { - case GST_VIDEO_SCALE_NEAREST: - vs_image_scale_nearest_YUYV (&dest[0], &src[0], videoscale->tmp_buf); - break; - case GST_VIDEO_SCALE_BILINEAR: - vs_image_scale_linear_YUYV (&dest[0], &src[0], videoscale->tmp_buf); - break; - case GST_VIDEO_SCALE_4TAP: - vs_image_scale_4tap_YUYV (&dest[0], &src[0], videoscale->tmp_buf); - break; - default: - goto unknown_mode; - } - break; - case GST_VIDEO_FORMAT_UYVY: - if (add_borders) - vs_fill_borders_UYVY (&dest[0], black); - switch (method) { - case GST_VIDEO_SCALE_NEAREST: - vs_image_scale_nearest_UYVY (&dest[0], &src[0], videoscale->tmp_buf); - break; - case GST_VIDEO_SCALE_BILINEAR: - vs_image_scale_linear_UYVY (&dest[0], &src[0], videoscale->tmp_buf); - break; - case GST_VIDEO_SCALE_4TAP: - vs_image_scale_4tap_UYVY (&dest[0], &src[0], videoscale->tmp_buf); - break; - default: - goto unknown_mode; - } - break; - case GST_VIDEO_FORMAT_GRAY8: - if (add_borders) - vs_fill_borders_Y (&dest[0], black); - switch (method) { - case GST_VIDEO_SCALE_NEAREST: - vs_image_scale_nearest_Y (&dest[0], &src[0], videoscale->tmp_buf); - break; - case GST_VIDEO_SCALE_BILINEAR: - vs_image_scale_linear_Y (&dest[0], &src[0], videoscale->tmp_buf); - break; - case GST_VIDEO_SCALE_4TAP: - vs_image_scale_4tap_Y (&dest[0], &src[0], videoscale->tmp_buf); - break; - default: - goto unknown_mode; - } - break; - case GST_VIDEO_FORMAT_GRAY16_LE: - case GST_VIDEO_FORMAT_GRAY16_BE: - if (add_borders) - vs_fill_borders_Y16 (&dest[0], 0); - switch (method) { - case GST_VIDEO_SCALE_NEAREST: - vs_image_scale_nearest_Y16 (&dest[0], &src[0], videoscale->tmp_buf); - break; - case GST_VIDEO_SCALE_BILINEAR: - vs_image_scale_linear_Y16 (&dest[0], &src[0], videoscale->tmp_buf); - break; - case GST_VIDEO_SCALE_4TAP: - vs_image_scale_4tap_Y16 (&dest[0], &src[0], videoscale->tmp_buf); - break; - default: - goto unknown_mode; - } - break; - case GST_VIDEO_FORMAT_I420: - case GST_VIDEO_FORMAT_YV12: - case GST_VIDEO_FORMAT_Y444: - case GST_VIDEO_FORMAT_Y42B: - case GST_VIDEO_FORMAT_Y41B: - if (add_borders) { - vs_fill_borders_Y (&dest[0], black); - vs_fill_borders_Y (&dest[1], black + 1); - vs_fill_borders_Y (&dest[2], black + 2); - } - switch (method) { - case GST_VIDEO_SCALE_NEAREST: - vs_image_scale_nearest_Y (&dest[0], &src[0], videoscale->tmp_buf); - vs_image_scale_nearest_Y (&dest[1], &src[1], videoscale->tmp_buf); - vs_image_scale_nearest_Y (&dest[2], &src[2], videoscale->tmp_buf); - break; - case GST_VIDEO_SCALE_BILINEAR: - vs_image_scale_linear_Y (&dest[0], &src[0], videoscale->tmp_buf); - vs_image_scale_linear_Y (&dest[1], &src[1], videoscale->tmp_buf); - vs_image_scale_linear_Y (&dest[2], &src[2], videoscale->tmp_buf); - break; - case GST_VIDEO_SCALE_4TAP: - vs_image_scale_4tap_Y (&dest[0], &src[0], videoscale->tmp_buf); - vs_image_scale_4tap_Y (&dest[1], &src[1], videoscale->tmp_buf); - vs_image_scale_4tap_Y (&dest[2], &src[2], videoscale->tmp_buf); - break; - case GST_VIDEO_SCALE_LANCZOS: - vs_image_scale_lanczos_Y (&dest[0], &src[0], videoscale->tmp_buf, - videoscale->sharpness, videoscale->dither, videoscale->submethod, - videoscale->envelope, videoscale->sharpen); - vs_image_scale_lanczos_Y (&dest[1], &src[1], videoscale->tmp_buf, - videoscale->sharpness, videoscale->dither, videoscale->submethod, - videoscale->envelope, videoscale->sharpen); - vs_image_scale_lanczos_Y (&dest[2], &src[2], videoscale->tmp_buf, - videoscale->sharpness, videoscale->dither, videoscale->submethod, - videoscale->envelope, videoscale->sharpen); - break; - default: - goto unknown_mode; - } - break; - case GST_VIDEO_FORMAT_NV12: - case GST_VIDEO_FORMAT_NV21: - /* NV21 format is exactly same as NV12 with the difference that u, v are reversed. - So same functions of NV12 could be reused */ - if (add_borders) { - vs_fill_borders_Y (&dest[0], black); - vs_fill_borders_Y16 (&dest[1], (black[1] << 8) | black[2]); - } - switch (method) { - case GST_VIDEO_SCALE_NEAREST: - vs_image_scale_nearest_Y (&dest[0], &src[0], videoscale->tmp_buf); - vs_image_scale_nearest_NV12 (&dest[1], &src[1], videoscale->tmp_buf); - break; - case GST_VIDEO_SCALE_BILINEAR: - vs_image_scale_linear_Y (&dest[0], &src[0], videoscale->tmp_buf); - vs_image_scale_linear_NV12 (&dest[1], &src[1], videoscale->tmp_buf); - break; - case GST_VIDEO_SCALE_4TAP: - vs_image_scale_4tap_Y (&dest[0], &src[0], videoscale->tmp_buf); - vs_image_scale_4tap_NV12 (&dest[1], &src[1], videoscale->tmp_buf); - break; - case GST_VIDEO_SCALE_LANCZOS: - vs_image_scale_lanczos_Y (&dest[0], &src[0], videoscale->tmp_buf, - videoscale->sharpness, videoscale->dither, videoscale->submethod, - videoscale->envelope, videoscale->sharpen); - vs_image_scale_lanczos_NV (&dest[1], &src[1], videoscale->tmp_buf, - videoscale->sharpness, videoscale->dither, videoscale->submethod, - videoscale->envelope, videoscale->sharpen); - break; - - default: - goto unknown_mode; - } - break; - case GST_VIDEO_FORMAT_RGB16: - if (add_borders) - vs_fill_borders_RGB565 (&dest[0], black); - switch (method) { - case GST_VIDEO_SCALE_NEAREST: - vs_image_scale_nearest_RGB565 (&dest[0], &src[0], - videoscale->tmp_buf); - break; - case GST_VIDEO_SCALE_BILINEAR: - vs_image_scale_linear_RGB565 (&dest[0], &src[0], videoscale->tmp_buf); - break; - case GST_VIDEO_SCALE_4TAP: - vs_image_scale_4tap_RGB565 (&dest[0], &src[0], videoscale->tmp_buf); - break; - default: - goto unknown_mode; - } - break; - case GST_VIDEO_FORMAT_RGB15: - if (add_borders) - vs_fill_borders_RGB555 (&dest[0], black); - switch (method) { - case GST_VIDEO_SCALE_NEAREST: - vs_image_scale_nearest_RGB555 (&dest[0], &src[0], - videoscale->tmp_buf); - break; - case GST_VIDEO_SCALE_BILINEAR: - vs_image_scale_linear_RGB555 (&dest[0], &src[0], videoscale->tmp_buf); - break; - case GST_VIDEO_SCALE_4TAP: - vs_image_scale_4tap_RGB555 (&dest[0], &src[0], videoscale->tmp_buf); - break; - default: - goto unknown_mode; - } - break; - default: - goto unsupported; - } + gst_video_converter_frame (videoscale->convert, in_frame, out_frame); return ret; - - /* ERRORS */ -unsupported: - { - GST_ELEMENT_ERROR (videoscale, STREAM, NOT_IMPLEMENTED, (NULL), - ("Unsupported format %d for scaling method %d", format, method)); - return GST_FLOW_ERROR; - } -unknown_mode: - { - GST_ELEMENT_ERROR (videoscale, STREAM, NOT_IMPLEMENTED, (NULL), - ("Unknown scaling method %d", videoscale->method)); - return GST_FLOW_ERROR; - } } static gboolean @@ -1515,8 +1055,6 @@ plugin_init (GstPlugin * plugin) "videoscale element"); GST_DEBUG_CATEGORY_GET (GST_CAT_PERFORMANCE, "GST_PERFORMANCE"); - vs_4tap_init (); - return TRUE; } diff --git a/gst/videoscale/gstvideoscale.h b/gst/videoscale/gstvideoscale.h index 37c056e192..5e5d8ee230 100644 --- a/gst/videoscale/gstvideoscale.h +++ b/gst/videoscale/gstvideoscale.h @@ -24,8 +24,6 @@ #include #include -#include "vs_image.h" - G_BEGIN_DECLS GST_DEBUG_CATEGORY_EXTERN (video_scale_debug); @@ -80,11 +78,10 @@ struct _GstVideoScale { int submethod; double envelope; + GstVideoConverter *convert; + gint borders_h; gint borders_w; - - /*< private >*/ - guint8 *tmp_buf; }; struct _GstVideoScaleClass { diff --git a/gst/videoscale/gstvideoscaleorc-dist.c b/gst/videoscale/gstvideoscaleorc-dist.c deleted file mode 100644 index 85b37fd3d3..0000000000 --- a/gst/videoscale/gstvideoscaleorc-dist.c +++ /dev/null @@ -1,2561 +0,0 @@ - -/* autogenerated from gstvideoscaleorc.orc */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif -#include - -#ifndef _ORC_INTEGER_TYPEDEFS_ -#define _ORC_INTEGER_TYPEDEFS_ -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L -#include -typedef int8_t orc_int8; -typedef int16_t orc_int16; -typedef int32_t orc_int32; -typedef int64_t orc_int64; -typedef uint8_t orc_uint8; -typedef uint16_t orc_uint16; -typedef uint32_t orc_uint32; -typedef uint64_t orc_uint64; -#define ORC_UINT64_C(x) UINT64_C(x) -#elif defined(_MSC_VER) -typedef signed __int8 orc_int8; -typedef signed __int16 orc_int16; -typedef signed __int32 orc_int32; -typedef signed __int64 orc_int64; -typedef unsigned __int8 orc_uint8; -typedef unsigned __int16 orc_uint16; -typedef unsigned __int32 orc_uint32; -typedef unsigned __int64 orc_uint64; -#define ORC_UINT64_C(x) (x##Ui64) -#define inline __inline -#else -#include -typedef signed char orc_int8; -typedef short orc_int16; -typedef int orc_int32; -typedef unsigned char orc_uint8; -typedef unsigned short orc_uint16; -typedef unsigned int orc_uint32; -#if INT_MAX == LONG_MAX -typedef long long orc_int64; -typedef unsigned long long orc_uint64; -#define ORC_UINT64_C(x) (x##ULL) -#else -typedef long orc_int64; -typedef unsigned long orc_uint64; -#define ORC_UINT64_C(x) (x##UL) -#endif -#endif -typedef union -{ - orc_int16 i; - orc_int8 x2[2]; -} orc_union16; -typedef union -{ - orc_int32 i; - float f; - orc_int16 x2[2]; - orc_int8 x4[4]; -} orc_union32; -typedef union -{ - orc_int64 i; - double f; - orc_int32 x2[2]; - float x2f[2]; - orc_int16 x4[4]; -} orc_union64; -#endif -#ifndef ORC_RESTRICT -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L -#define ORC_RESTRICT restrict -#elif defined(__GNUC__) && __GNUC__ >= 4 -#define ORC_RESTRICT __restrict__ -#else -#define ORC_RESTRICT -#endif -#endif - -#ifndef ORC_INTERNAL -#if defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590) -#define ORC_INTERNAL __attribute__((visibility("hidden"))) -#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550) -#define ORC_INTERNAL __hidden -#elif defined (__GNUC__) -#define ORC_INTERNAL __attribute__((visibility("hidden"))) -#else -#define ORC_INTERNAL -#endif -#endif - - -#ifndef DISABLE_ORC -#include -#endif -void video_scale_orc_merge_linear_u8 (orc_uint8 * ORC_RESTRICT d1, - const orc_uint8 * ORC_RESTRICT s1, const orc_uint8 * ORC_RESTRICT s2, - int p1, int n); -void video_scale_orc_merge_linear_u16 (orc_uint16 * ORC_RESTRICT d1, - const orc_uint16 * ORC_RESTRICT s1, const orc_uint16 * ORC_RESTRICT s2, - int p1, int p2, int n); -void video_scale_orc_splat_u16 (orc_uint16 * ORC_RESTRICT d1, int p1, int n); -void video_scale_orc_splat_u32 (orc_uint32 * ORC_RESTRICT d1, int p1, int n); -void video_scale_orc_splat_u64 (orc_uint64 * ORC_RESTRICT d1, orc_int64 p1, - int n); -void video_scale_orc_downsample_u8 (guint8 * ORC_RESTRICT d1, - const guint8 * ORC_RESTRICT s1, int n); -void video_scale_orc_downsample_u16 (guint16 * ORC_RESTRICT d1, - const guint16 * ORC_RESTRICT s1, int n); -void video_scale_orc_downsample_u32 (guint8 * ORC_RESTRICT d1, - const guint8 * ORC_RESTRICT s1, int n); -void video_scale_orc_downsample_yuyv (guint8 * ORC_RESTRICT d1, - const guint8 * ORC_RESTRICT s1, int n); -void video_scale_orc_resample_nearest_u8 (guint8 * ORC_RESTRICT d1, - const guint8 * ORC_RESTRICT s1, int p1, int p2, int n); -void video_scale_orc_resample_bilinear_u8 (guint8 * ORC_RESTRICT d1, - const guint8 * ORC_RESTRICT s1, int p1, int p2, int n); -void video_scale_orc_resample_nearest_u32 (guint8 * ORC_RESTRICT d1, - const guint8 * ORC_RESTRICT s1, int p1, int p2, int n); -void video_scale_orc_resample_bilinear_u32 (guint8 * ORC_RESTRICT d1, - const guint8 * ORC_RESTRICT s1, int p1, int p2, int n); -void video_scale_orc_resample_merge_bilinear_u32 (guint8 * ORC_RESTRICT d1, - guint8 * ORC_RESTRICT d2, const guint8 * ORC_RESTRICT s1, - const guint8 * ORC_RESTRICT s2, int p1, int p2, int p3, int n); -void video_scale_orc_merge_bicubic_u8 (guint8 * ORC_RESTRICT d1, - const guint8 * ORC_RESTRICT s1, const guint8 * ORC_RESTRICT s2, - const guint8 * ORC_RESTRICT s3, const guint8 * ORC_RESTRICT s4, int p1, - int p2, int p3, int p4, int n); - - -/* begin Orc C target preamble */ -#define ORC_CLAMP(x,a,b) ((x)<(a) ? (a) : ((x)>(b) ? (b) : (x))) -#define ORC_ABS(a) ((a)<0 ? -(a) : (a)) -#define ORC_MIN(a,b) ((a)<(b) ? (a) : (b)) -#define ORC_MAX(a,b) ((a)>(b) ? (a) : (b)) -#define ORC_SB_MAX 127 -#define ORC_SB_MIN (-1-ORC_SB_MAX) -#define ORC_UB_MAX 255 -#define ORC_UB_MIN 0 -#define ORC_SW_MAX 32767 -#define ORC_SW_MIN (-1-ORC_SW_MAX) -#define ORC_UW_MAX 65535 -#define ORC_UW_MIN 0 -#define ORC_SL_MAX 2147483647 -#define ORC_SL_MIN (-1-ORC_SL_MAX) -#define ORC_UL_MAX 4294967295U -#define ORC_UL_MIN 0 -#define ORC_CLAMP_SB(x) ORC_CLAMP(x,ORC_SB_MIN,ORC_SB_MAX) -#define ORC_CLAMP_UB(x) ORC_CLAMP(x,ORC_UB_MIN,ORC_UB_MAX) -#define ORC_CLAMP_SW(x) ORC_CLAMP(x,ORC_SW_MIN,ORC_SW_MAX) -#define ORC_CLAMP_UW(x) ORC_CLAMP(x,ORC_UW_MIN,ORC_UW_MAX) -#define ORC_CLAMP_SL(x) ORC_CLAMP(x,ORC_SL_MIN,ORC_SL_MAX) -#define ORC_CLAMP_UL(x) ORC_CLAMP(x,ORC_UL_MIN,ORC_UL_MAX) -#define ORC_SWAP_W(x) ((((x)&0xffU)<<8) | (((x)&0xff00U)>>8)) -#define ORC_SWAP_L(x) ((((x)&0xffU)<<24) | (((x)&0xff00U)<<8) | (((x)&0xff0000U)>>8) | (((x)&0xff000000U)>>24)) -#define ORC_SWAP_Q(x) ((((x)&ORC_UINT64_C(0xff))<<56) | (((x)&ORC_UINT64_C(0xff00))<<40) | (((x)&ORC_UINT64_C(0xff0000))<<24) | (((x)&ORC_UINT64_C(0xff000000))<<8) | (((x)&ORC_UINT64_C(0xff00000000))>>8) | (((x)&ORC_UINT64_C(0xff0000000000))>>24) | (((x)&ORC_UINT64_C(0xff000000000000))>>40) | (((x)&ORC_UINT64_C(0xff00000000000000))>>56)) -#define ORC_PTR_OFFSET(ptr,offset) ((void *)(((unsigned char *)(ptr)) + (offset))) -#define ORC_DENORMAL(x) ((x) & ((((x)&0x7f800000) == 0) ? 0xff800000 : 0xffffffff)) -#define ORC_ISNAN(x) ((((x)&0x7f800000) == 0x7f800000) && (((x)&0x007fffff) != 0)) -#define ORC_DENORMAL_DOUBLE(x) ((x) & ((((x)&ORC_UINT64_C(0x7ff0000000000000)) == 0) ? ORC_UINT64_C(0xfff0000000000000) : ORC_UINT64_C(0xffffffffffffffff))) -#define ORC_ISNAN_DOUBLE(x) ((((x)&ORC_UINT64_C(0x7ff0000000000000)) == ORC_UINT64_C(0x7ff0000000000000)) && (((x)&ORC_UINT64_C(0x000fffffffffffff)) != 0)) -#ifndef ORC_RESTRICT -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L -#define ORC_RESTRICT restrict -#elif defined(__GNUC__) && __GNUC__ >= 4 -#define ORC_RESTRICT __restrict__ -#else -#define ORC_RESTRICT -#endif -#endif -/* end Orc C target preamble */ - - - -/* video_scale_orc_merge_linear_u8 */ -#ifdef DISABLE_ORC -void -video_scale_orc_merge_linear_u8 (orc_uint8 * ORC_RESTRICT d1, - const orc_uint8 * ORC_RESTRICT s1, const orc_uint8 * ORC_RESTRICT s2, - int p1, int n) -{ - int i; - orc_int8 *ORC_RESTRICT ptr0; - const orc_int8 *ORC_RESTRICT ptr4; - const orc_int8 *ORC_RESTRICT ptr5; - orc_int8 var36; - orc_int8 var37; - orc_union16 var38; -#if defined(__APPLE__) && __GNUC__ == 4 && __GNUC_MINOR__ == 2 && defined (__i386__) - volatile orc_union16 var39; -#else - orc_union16 var39; -#endif - orc_int8 var40; - orc_int8 var41; - orc_union16 var42; - orc_union16 var43; - orc_union16 var44; - orc_union16 var45; - orc_union16 var46; - orc_int8 var47; - - ptr0 = (orc_int8 *) d1; - ptr4 = (orc_int8 *) s1; - ptr5 = (orc_int8 *) s2; - - /* 6: loadpw */ - var38.i = p1; - /* 8: loadpw */ - var39.i = (int) 0x00000080; /* 128 or 6.32404e-322f */ - - for (i = 0; i < n; i++) { - /* 0: loadb */ - var41 = ptr4[i]; - /* 1: loadb */ - var36 = ptr4[i]; - /* 2: convubw */ - var42.i = (orc_uint8) var36; - /* 3: loadb */ - var37 = ptr5[i]; - /* 4: convubw */ - var43.i = (orc_uint8) var37; - /* 5: subw */ - var44.i = var43.i - var42.i; - /* 7: mullw */ - var45.i = (var44.i * var38.i) & 0xffff; - /* 9: addw */ - var46.i = var45.i + var39.i; - /* 10: convhwb */ - var47 = ((orc_uint16) var46.i) >> 8; - /* 11: addb */ - var40 = var47 + var41; - /* 12: storeb */ - ptr0[i] = var40; - } - -} - -#else -static void -_backup_video_scale_orc_merge_linear_u8 (OrcExecutor * ORC_RESTRICT ex) -{ - int i; - int n = ex->n; - orc_int8 *ORC_RESTRICT ptr0; - const orc_int8 *ORC_RESTRICT ptr4; - const orc_int8 *ORC_RESTRICT ptr5; - orc_int8 var36; - orc_int8 var37; - orc_union16 var38; -#if defined(__APPLE__) && __GNUC__ == 4 && __GNUC_MINOR__ == 2 && defined (__i386__) - volatile orc_union16 var39; -#else - orc_union16 var39; -#endif - orc_int8 var40; - orc_int8 var41; - orc_union16 var42; - orc_union16 var43; - orc_union16 var44; - orc_union16 var45; - orc_union16 var46; - orc_int8 var47; - - ptr0 = (orc_int8 *) ex->arrays[0]; - ptr4 = (orc_int8 *) ex->arrays[4]; - ptr5 = (orc_int8 *) ex->arrays[5]; - - /* 6: loadpw */ - var38.i = ex->params[24]; - /* 8: loadpw */ - var39.i = (int) 0x00000080; /* 128 or 6.32404e-322f */ - - for (i = 0; i < n; i++) { - /* 0: loadb */ - var41 = ptr4[i]; - /* 1: loadb */ - var36 = ptr4[i]; - /* 2: convubw */ - var42.i = (orc_uint8) var36; - /* 3: loadb */ - var37 = ptr5[i]; - /* 4: convubw */ - var43.i = (orc_uint8) var37; - /* 5: subw */ - var44.i = var43.i - var42.i; - /* 7: mullw */ - var45.i = (var44.i * var38.i) & 0xffff; - /* 9: addw */ - var46.i = var45.i + var39.i; - /* 10: convhwb */ - var47 = ((orc_uint16) var46.i) >> 8; - /* 11: addb */ - var40 = var47 + var41; - /* 12: storeb */ - ptr0[i] = var40; - } - -} - -void -video_scale_orc_merge_linear_u8 (orc_uint8 * ORC_RESTRICT d1, - const orc_uint8 * ORC_RESTRICT s1, const orc_uint8 * ORC_RESTRICT s2, - int p1, int n) -{ - OrcExecutor _ex, *ex = &_ex; - static volatile int p_inited = 0; - static OrcCode *c = 0; - void (*func) (OrcExecutor *); - - if (!p_inited) { - orc_once_mutex_lock (); - if (!p_inited) { - OrcProgram *p; - -#if 1 - static const orc_uint8 bc[] = { - 1, 9, 31, 118, 105, 100, 101, 111, 95, 115, 99, 97, 108, 101, 95, 111, - 114, 99, 95, 109, 101, 114, 103, 101, 95, 108, 105, 110, 101, 97, 114, - 95, - 117, 56, 11, 1, 1, 12, 1, 1, 12, 1, 1, 14, 4, 128, 0, 0, - 0, 16, 1, 20, 2, 20, 2, 20, 1, 20, 1, 43, 34, 4, 150, 32, - 4, 150, 33, 5, 98, 33, 33, 32, 89, 33, 33, 24, 70, 33, 33, 16, - 158, 35, 33, 33, 0, 35, 34, 2, 0, - }; - p = orc_program_new_from_static_bytecode (bc); - orc_program_set_backup_function (p, - _backup_video_scale_orc_merge_linear_u8); -#else - p = orc_program_new (); - orc_program_set_name (p, "video_scale_orc_merge_linear_u8"); - orc_program_set_backup_function (p, - _backup_video_scale_orc_merge_linear_u8); - orc_program_add_destination (p, 1, "d1"); - orc_program_add_source (p, 1, "s1"); - orc_program_add_source (p, 1, "s2"); - orc_program_add_constant (p, 4, 0x00000080, "c1"); - orc_program_add_parameter (p, 1, "p1"); - orc_program_add_temporary (p, 2, "t1"); - orc_program_add_temporary (p, 2, "t2"); - orc_program_add_temporary (p, 1, "t3"); - orc_program_add_temporary (p, 1, "t4"); - - orc_program_append_2 (p, "loadb", 0, ORC_VAR_T3, ORC_VAR_S1, ORC_VAR_D1, - ORC_VAR_D1); - orc_program_append_2 (p, "convubw", 0, ORC_VAR_T1, ORC_VAR_S1, ORC_VAR_D1, - ORC_VAR_D1); - orc_program_append_2 (p, "convubw", 0, ORC_VAR_T2, ORC_VAR_S2, ORC_VAR_D1, - ORC_VAR_D1); - orc_program_append_2 (p, "subw", 0, ORC_VAR_T2, ORC_VAR_T2, ORC_VAR_T1, - ORC_VAR_D1); - orc_program_append_2 (p, "mullw", 0, ORC_VAR_T2, ORC_VAR_T2, ORC_VAR_P1, - ORC_VAR_D1); - orc_program_append_2 (p, "addw", 0, ORC_VAR_T2, ORC_VAR_T2, ORC_VAR_C1, - ORC_VAR_D1); - orc_program_append_2 (p, "convhwb", 0, ORC_VAR_T4, ORC_VAR_T2, ORC_VAR_D1, - ORC_VAR_D1); - orc_program_append_2 (p, "addb", 0, ORC_VAR_D1, ORC_VAR_T4, ORC_VAR_T3, - ORC_VAR_D1); -#endif - - orc_program_compile (p); - c = orc_program_take_code (p); - orc_program_free (p); - } - p_inited = TRUE; - orc_once_mutex_unlock (); - } - ex->arrays[ORC_VAR_A2] = c; - ex->program = 0; - - ex->n = n; - ex->arrays[ORC_VAR_D1] = d1; - ex->arrays[ORC_VAR_S1] = (void *) s1; - ex->arrays[ORC_VAR_S2] = (void *) s2; - ex->params[ORC_VAR_P1] = p1; - - func = c->exec; - func (ex); -} -#endif - - -/* video_scale_orc_merge_linear_u16 */ -#ifdef DISABLE_ORC -void -video_scale_orc_merge_linear_u16 (orc_uint16 * ORC_RESTRICT d1, - const orc_uint16 * ORC_RESTRICT s1, const orc_uint16 * ORC_RESTRICT s2, - int p1, int p2, int n) -{ - int i; - orc_union16 *ORC_RESTRICT ptr0; - const orc_union16 *ORC_RESTRICT ptr4; - const orc_union16 *ORC_RESTRICT ptr5; - orc_union16 var34; - orc_union16 var35; - orc_union16 var36; - orc_union16 var37; - orc_union16 var38; - orc_union32 var39; - orc_union32 var40; - orc_union32 var41; - orc_union32 var42; - - ptr0 = (orc_union16 *) d1; - ptr4 = (orc_union16 *) s1; - ptr5 = (orc_union16 *) s2; - - /* 1: loadpw */ - var35.i = p1; - /* 4: loadpw */ - var37.i = p2; - - for (i = 0; i < n; i++) { - /* 0: loadw */ - var34 = ptr4[i]; - /* 2: muluwl */ - var39.i = ((orc_uint16) var34.i) * ((orc_uint16) var35.i); - /* 3: loadw */ - var36 = ptr5[i]; - /* 5: muluwl */ - var40.i = ((orc_uint16) var36.i) * ((orc_uint16) var37.i); - /* 6: addl */ - var41.i = var39.i + var40.i; - /* 7: shrul */ - var42.i = ((orc_uint32) var41.i) >> 16; - /* 8: convlw */ - var38.i = var42.i; - /* 9: storew */ - ptr0[i] = var38; - } - -} - -#else -static void -_backup_video_scale_orc_merge_linear_u16 (OrcExecutor * ORC_RESTRICT ex) -{ - int i; - int n = ex->n; - orc_union16 *ORC_RESTRICT ptr0; - const orc_union16 *ORC_RESTRICT ptr4; - const orc_union16 *ORC_RESTRICT ptr5; - orc_union16 var34; - orc_union16 var35; - orc_union16 var36; - orc_union16 var37; - orc_union16 var38; - orc_union32 var39; - orc_union32 var40; - orc_union32 var41; - orc_union32 var42; - - ptr0 = (orc_union16 *) ex->arrays[0]; - ptr4 = (orc_union16 *) ex->arrays[4]; - ptr5 = (orc_union16 *) ex->arrays[5]; - - /* 1: loadpw */ - var35.i = ex->params[24]; - /* 4: loadpw */ - var37.i = ex->params[25]; - - for (i = 0; i < n; i++) { - /* 0: loadw */ - var34 = ptr4[i]; - /* 2: muluwl */ - var39.i = ((orc_uint16) var34.i) * ((orc_uint16) var35.i); - /* 3: loadw */ - var36 = ptr5[i]; - /* 5: muluwl */ - var40.i = ((orc_uint16) var36.i) * ((orc_uint16) var37.i); - /* 6: addl */ - var41.i = var39.i + var40.i; - /* 7: shrul */ - var42.i = ((orc_uint32) var41.i) >> 16; - /* 8: convlw */ - var38.i = var42.i; - /* 9: storew */ - ptr0[i] = var38; - } - -} - -void -video_scale_orc_merge_linear_u16 (orc_uint16 * ORC_RESTRICT d1, - const orc_uint16 * ORC_RESTRICT s1, const orc_uint16 * ORC_RESTRICT s2, - int p1, int p2, int n) -{ - OrcExecutor _ex, *ex = &_ex; - static volatile int p_inited = 0; - static OrcCode *c = 0; - void (*func) (OrcExecutor *); - - if (!p_inited) { - orc_once_mutex_lock (); - if (!p_inited) { - OrcProgram *p; - -#if 1 - static const orc_uint8 bc[] = { - 1, 9, 32, 118, 105, 100, 101, 111, 95, 115, 99, 97, 108, 101, 95, 111, - 114, 99, 95, 109, 101, 114, 103, 101, 95, 108, 105, 110, 101, 97, 114, - 95, - 117, 49, 54, 11, 2, 2, 12, 2, 2, 12, 2, 2, 14, 4, 16, 0, - 0, 0, 16, 2, 16, 2, 20, 4, 20, 4, 177, 32, 4, 24, 177, 33, - 5, 25, 103, 32, 32, 33, 126, 32, 32, 16, 163, 0, 32, 2, 0, - }; - p = orc_program_new_from_static_bytecode (bc); - orc_program_set_backup_function (p, - _backup_video_scale_orc_merge_linear_u16); -#else - p = orc_program_new (); - orc_program_set_name (p, "video_scale_orc_merge_linear_u16"); - orc_program_set_backup_function (p, - _backup_video_scale_orc_merge_linear_u16); - orc_program_add_destination (p, 2, "d1"); - orc_program_add_source (p, 2, "s1"); - orc_program_add_source (p, 2, "s2"); - orc_program_add_constant (p, 4, 0x00000010, "c1"); - orc_program_add_parameter (p, 2, "p1"); - orc_program_add_parameter (p, 2, "p2"); - orc_program_add_temporary (p, 4, "t1"); - orc_program_add_temporary (p, 4, "t2"); - - orc_program_append_2 (p, "muluwl", 0, ORC_VAR_T1, ORC_VAR_S1, ORC_VAR_P1, - ORC_VAR_D1); - orc_program_append_2 (p, "muluwl", 0, ORC_VAR_T2, ORC_VAR_S2, ORC_VAR_P2, - ORC_VAR_D1); - orc_program_append_2 (p, "addl", 0, ORC_VAR_T1, ORC_VAR_T1, ORC_VAR_T2, - ORC_VAR_D1); - orc_program_append_2 (p, "shrul", 0, ORC_VAR_T1, ORC_VAR_T1, ORC_VAR_C1, - ORC_VAR_D1); - orc_program_append_2 (p, "convlw", 0, ORC_VAR_D1, ORC_VAR_T1, ORC_VAR_D1, - ORC_VAR_D1); -#endif - - orc_program_compile (p); - c = orc_program_take_code (p); - orc_program_free (p); - } - p_inited = TRUE; - orc_once_mutex_unlock (); - } - ex->arrays[ORC_VAR_A2] = c; - ex->program = 0; - - ex->n = n; - ex->arrays[ORC_VAR_D1] = d1; - ex->arrays[ORC_VAR_S1] = (void *) s1; - ex->arrays[ORC_VAR_S2] = (void *) s2; - ex->params[ORC_VAR_P1] = p1; - ex->params[ORC_VAR_P2] = p2; - - func = c->exec; - func (ex); -} -#endif - - -/* video_scale_orc_splat_u16 */ -#ifdef DISABLE_ORC -void -video_scale_orc_splat_u16 (orc_uint16 * ORC_RESTRICT d1, int p1, int n) -{ - int i; - orc_union16 *ORC_RESTRICT ptr0; - orc_union16 var32; - orc_union16 var33; - - ptr0 = (orc_union16 *) d1; - - /* 0: loadpw */ - var32.i = p1; - - for (i = 0; i < n; i++) { - /* 1: copyw */ - var33.i = var32.i; - /* 2: storew */ - ptr0[i] = var33; - } - -} - -#else -static void -_backup_video_scale_orc_splat_u16 (OrcExecutor * ORC_RESTRICT ex) -{ - int i; - int n = ex->n; - orc_union16 *ORC_RESTRICT ptr0; - orc_union16 var32; - orc_union16 var33; - - ptr0 = (orc_union16 *) ex->arrays[0]; - - /* 0: loadpw */ - var32.i = ex->params[24]; - - for (i = 0; i < n; i++) { - /* 1: copyw */ - var33.i = var32.i; - /* 2: storew */ - ptr0[i] = var33; - } - -} - -void -video_scale_orc_splat_u16 (orc_uint16 * ORC_RESTRICT d1, int p1, int n) -{ - OrcExecutor _ex, *ex = &_ex; - static volatile int p_inited = 0; - static OrcCode *c = 0; - void (*func) (OrcExecutor *); - - if (!p_inited) { - orc_once_mutex_lock (); - if (!p_inited) { - OrcProgram *p; - -#if 1 - static const orc_uint8 bc[] = { - 1, 9, 25, 118, 105, 100, 101, 111, 95, 115, 99, 97, 108, 101, 95, 111, - 114, 99, 95, 115, 112, 108, 97, 116, 95, 117, 49, 54, 11, 2, 2, 16, - 2, 79, 0, 24, 2, 0, - }; - p = orc_program_new_from_static_bytecode (bc); - orc_program_set_backup_function (p, _backup_video_scale_orc_splat_u16); -#else - p = orc_program_new (); - orc_program_set_name (p, "video_scale_orc_splat_u16"); - orc_program_set_backup_function (p, _backup_video_scale_orc_splat_u16); - orc_program_add_destination (p, 2, "d1"); - orc_program_add_parameter (p, 2, "p1"); - - orc_program_append_2 (p, "copyw", 0, ORC_VAR_D1, ORC_VAR_P1, ORC_VAR_D1, - ORC_VAR_D1); -#endif - - orc_program_compile (p); - c = orc_program_take_code (p); - orc_program_free (p); - } - p_inited = TRUE; - orc_once_mutex_unlock (); - } - ex->arrays[ORC_VAR_A2] = c; - ex->program = 0; - - ex->n = n; - ex->arrays[ORC_VAR_D1] = d1; - ex->params[ORC_VAR_P1] = p1; - - func = c->exec; - func (ex); -} -#endif - - -/* video_scale_orc_splat_u32 */ -#ifdef DISABLE_ORC -void -video_scale_orc_splat_u32 (orc_uint32 * ORC_RESTRICT d1, int p1, int n) -{ - int i; - orc_union32 *ORC_RESTRICT ptr0; - orc_union32 var32; - orc_union32 var33; - - ptr0 = (orc_union32 *) d1; - - /* 0: loadpl */ - var32.i = p1; - - for (i = 0; i < n; i++) { - /* 1: copyl */ - var33.i = var32.i; - /* 2: storel */ - ptr0[i] = var33; - } - -} - -#else -static void -_backup_video_scale_orc_splat_u32 (OrcExecutor * ORC_RESTRICT ex) -{ - int i; - int n = ex->n; - orc_union32 *ORC_RESTRICT ptr0; - orc_union32 var32; - orc_union32 var33; - - ptr0 = (orc_union32 *) ex->arrays[0]; - - /* 0: loadpl */ - var32.i = ex->params[24]; - - for (i = 0; i < n; i++) { - /* 1: copyl */ - var33.i = var32.i; - /* 2: storel */ - ptr0[i] = var33; - } - -} - -void -video_scale_orc_splat_u32 (orc_uint32 * ORC_RESTRICT d1, int p1, int n) -{ - OrcExecutor _ex, *ex = &_ex; - static volatile int p_inited = 0; - static OrcCode *c = 0; - void (*func) (OrcExecutor *); - - if (!p_inited) { - orc_once_mutex_lock (); - if (!p_inited) { - OrcProgram *p; - -#if 1 - static const orc_uint8 bc[] = { - 1, 9, 25, 118, 105, 100, 101, 111, 95, 115, 99, 97, 108, 101, 95, 111, - 114, 99, 95, 115, 112, 108, 97, 116, 95, 117, 51, 50, 11, 4, 4, 16, - 4, 112, 0, 24, 2, 0, - }; - p = orc_program_new_from_static_bytecode (bc); - orc_program_set_backup_function (p, _backup_video_scale_orc_splat_u32); -#else - p = orc_program_new (); - orc_program_set_name (p, "video_scale_orc_splat_u32"); - orc_program_set_backup_function (p, _backup_video_scale_orc_splat_u32); - orc_program_add_destination (p, 4, "d1"); - orc_program_add_parameter (p, 4, "p1"); - - orc_program_append_2 (p, "copyl", 0, ORC_VAR_D1, ORC_VAR_P1, ORC_VAR_D1, - ORC_VAR_D1); -#endif - - orc_program_compile (p); - c = orc_program_take_code (p); - orc_program_free (p); - } - p_inited = TRUE; - orc_once_mutex_unlock (); - } - ex->arrays[ORC_VAR_A2] = c; - ex->program = 0; - - ex->n = n; - ex->arrays[ORC_VAR_D1] = d1; - ex->params[ORC_VAR_P1] = p1; - - func = c->exec; - func (ex); -} -#endif - - -/* video_scale_orc_splat_u64 */ -#ifdef DISABLE_ORC -void -video_scale_orc_splat_u64 (orc_uint64 * ORC_RESTRICT d1, orc_int64 p1, int n) -{ - int i; - orc_union64 *ORC_RESTRICT ptr0; - orc_union64 var32; - orc_union64 var33; - - ptr0 = (orc_union64 *) d1; - - /* 0: loadpq */ - var32.i = p1; - - for (i = 0; i < n; i++) { - /* 1: copyq */ - var33.i = var32.i; - /* 2: storeq */ - ptr0[i] = var33; - } - -} - -#else -static void -_backup_video_scale_orc_splat_u64 (OrcExecutor * ORC_RESTRICT ex) -{ - int i; - int n = ex->n; - orc_union64 *ORC_RESTRICT ptr0; - orc_union64 var32; - orc_union64 var33; - - ptr0 = (orc_union64 *) ex->arrays[0]; - - /* 0: loadpq */ - var32.i = - (ex->params[24] & 0xffffffff) | ((orc_uint64) (ex->params[24 + - (ORC_VAR_T1 - ORC_VAR_P1)]) << 32); - - for (i = 0; i < n; i++) { - /* 1: copyq */ - var33.i = var32.i; - /* 2: storeq */ - ptr0[i] = var33; - } - -} - -void -video_scale_orc_splat_u64 (orc_uint64 * ORC_RESTRICT d1, orc_int64 p1, int n) -{ - OrcExecutor _ex, *ex = &_ex; - static volatile int p_inited = 0; - static OrcCode *c = 0; - void (*func) (OrcExecutor *); - - if (!p_inited) { - orc_once_mutex_lock (); - if (!p_inited) { - OrcProgram *p; - -#if 1 - static const orc_uint8 bc[] = { - 1, 9, 25, 118, 105, 100, 101, 111, 95, 115, 99, 97, 108, 101, 95, 111, - 114, 99, 95, 115, 112, 108, 97, 116, 95, 117, 54, 52, 11, 8, 8, 18, - 8, 137, 0, 24, 2, 0, - }; - p = orc_program_new_from_static_bytecode (bc); - orc_program_set_backup_function (p, _backup_video_scale_orc_splat_u64); -#else - p = orc_program_new (); - orc_program_set_name (p, "video_scale_orc_splat_u64"); - orc_program_set_backup_function (p, _backup_video_scale_orc_splat_u64); - orc_program_add_destination (p, 8, "d1"); - orc_program_add_parameter_int64 (p, 8, "p1"); - - orc_program_append_2 (p, "copyq", 0, ORC_VAR_D1, ORC_VAR_P1, ORC_VAR_D1, - ORC_VAR_D1); -#endif - - orc_program_compile (p); - c = orc_program_take_code (p); - orc_program_free (p); - } - p_inited = TRUE; - orc_once_mutex_unlock (); - } - ex->arrays[ORC_VAR_A2] = c; - ex->program = 0; - - ex->n = n; - ex->arrays[ORC_VAR_D1] = d1; - { - orc_union64 tmp; - tmp.i = p1; - ex->params[ORC_VAR_P1] = tmp.x2[0]; - ex->params[ORC_VAR_T1] = tmp.x2[1]; - } - - func = c->exec; - func (ex); -} -#endif - - -/* video_scale_orc_downsample_u8 */ -#ifdef DISABLE_ORC -void -video_scale_orc_downsample_u8 (guint8 * ORC_RESTRICT d1, - const guint8 * ORC_RESTRICT s1, int n) -{ - int i; - orc_int8 *ORC_RESTRICT ptr0; - const orc_union16 *ORC_RESTRICT ptr4; - orc_union16 var34; - orc_int8 var35; - orc_int8 var36; - orc_int8 var37; - - ptr0 = (orc_int8 *) d1; - ptr4 = (orc_union16 *) s1; - - - for (i = 0; i < n; i++) { - /* 0: loadw */ - var34 = ptr4[i]; - /* 1: splitwb */ - { - orc_union16 _src; - _src.i = var34.i; - var36 = _src.x2[1]; - var37 = _src.x2[0]; - } - /* 2: avgub */ - var35 = ((orc_uint8) var36 + (orc_uint8) var37 + 1) >> 1; - /* 3: storeb */ - ptr0[i] = var35; - } - -} - -#else -static void -_backup_video_scale_orc_downsample_u8 (OrcExecutor * ORC_RESTRICT ex) -{ - int i; - int n = ex->n; - orc_int8 *ORC_RESTRICT ptr0; - const orc_union16 *ORC_RESTRICT ptr4; - orc_union16 var34; - orc_int8 var35; - orc_int8 var36; - orc_int8 var37; - - ptr0 = (orc_int8 *) ex->arrays[0]; - ptr4 = (orc_union16 *) ex->arrays[4]; - - - for (i = 0; i < n; i++) { - /* 0: loadw */ - var34 = ptr4[i]; - /* 1: splitwb */ - { - orc_union16 _src; - _src.i = var34.i; - var36 = _src.x2[1]; - var37 = _src.x2[0]; - } - /* 2: avgub */ - var35 = ((orc_uint8) var36 + (orc_uint8) var37 + 1) >> 1; - /* 3: storeb */ - ptr0[i] = var35; - } - -} - -void -video_scale_orc_downsample_u8 (guint8 * ORC_RESTRICT d1, - const guint8 * ORC_RESTRICT s1, int n) -{ - OrcExecutor _ex, *ex = &_ex; - static volatile int p_inited = 0; - static OrcCode *c = 0; - void (*func) (OrcExecutor *); - - if (!p_inited) { - orc_once_mutex_lock (); - if (!p_inited) { - OrcProgram *p; - -#if 1 - static const orc_uint8 bc[] = { - 1, 9, 29, 118, 105, 100, 101, 111, 95, 115, 99, 97, 108, 101, 95, 111, - 114, 99, 95, 100, 111, 119, 110, 115, 97, 109, 112, 108, 101, 95, 117, - 56, - 11, 1, 1, 12, 2, 2, 20, 1, 20, 1, 199, 32, 33, 4, 39, 0, - 32, 33, 2, 0, - }; - p = orc_program_new_from_static_bytecode (bc); - orc_program_set_backup_function (p, - _backup_video_scale_orc_downsample_u8); -#else - p = orc_program_new (); - orc_program_set_name (p, "video_scale_orc_downsample_u8"); - orc_program_set_backup_function (p, - _backup_video_scale_orc_downsample_u8); - orc_program_add_destination (p, 1, "d1"); - orc_program_add_source (p, 2, "s1"); - orc_program_add_temporary (p, 1, "t1"); - orc_program_add_temporary (p, 1, "t2"); - - orc_program_append_2 (p, "splitwb", 0, ORC_VAR_T1, ORC_VAR_T2, ORC_VAR_S1, - ORC_VAR_D1); - orc_program_append_2 (p, "avgub", 0, ORC_VAR_D1, ORC_VAR_T1, ORC_VAR_T2, - ORC_VAR_D1); -#endif - - orc_program_compile (p); - c = orc_program_take_code (p); - orc_program_free (p); - } - p_inited = TRUE; - orc_once_mutex_unlock (); - } - ex->arrays[ORC_VAR_A2] = c; - ex->program = 0; - - ex->n = n; - ex->arrays[ORC_VAR_D1] = d1; - ex->arrays[ORC_VAR_S1] = (void *) s1; - - func = c->exec; - func (ex); -} -#endif - - -/* video_scale_orc_downsample_u16 */ -#ifdef DISABLE_ORC -void -video_scale_orc_downsample_u16 (guint16 * ORC_RESTRICT d1, - const guint16 * ORC_RESTRICT s1, int n) -{ - int i; - orc_union16 *ORC_RESTRICT ptr0; - const orc_union32 *ORC_RESTRICT ptr4; - orc_union32 var34; - orc_union16 var35; - orc_union16 var36; - orc_union16 var37; - - ptr0 = (orc_union16 *) d1; - ptr4 = (orc_union32 *) s1; - - - for (i = 0; i < n; i++) { - /* 0: loadl */ - var34 = ptr4[i]; - /* 1: splitlw */ - { - orc_union32 _src; - _src.i = var34.i; - var36.i = _src.x2[1]; - var37.i = _src.x2[0]; - } - /* 2: avguw */ - var35.i = ((orc_uint16) var36.i + (orc_uint16) var37.i + 1) >> 1; - /* 3: storew */ - ptr0[i] = var35; - } - -} - -#else -static void -_backup_video_scale_orc_downsample_u16 (OrcExecutor * ORC_RESTRICT ex) -{ - int i; - int n = ex->n; - orc_union16 *ORC_RESTRICT ptr0; - const orc_union32 *ORC_RESTRICT ptr4; - orc_union32 var34; - orc_union16 var35; - orc_union16 var36; - orc_union16 var37; - - ptr0 = (orc_union16 *) ex->arrays[0]; - ptr4 = (orc_union32 *) ex->arrays[4]; - - - for (i = 0; i < n; i++) { - /* 0: loadl */ - var34 = ptr4[i]; - /* 1: splitlw */ - { - orc_union32 _src; - _src.i = var34.i; - var36.i = _src.x2[1]; - var37.i = _src.x2[0]; - } - /* 2: avguw */ - var35.i = ((orc_uint16) var36.i + (orc_uint16) var37.i + 1) >> 1; - /* 3: storew */ - ptr0[i] = var35; - } - -} - -void -video_scale_orc_downsample_u16 (guint16 * ORC_RESTRICT d1, - const guint16 * ORC_RESTRICT s1, int n) -{ - OrcExecutor _ex, *ex = &_ex; - static volatile int p_inited = 0; - static OrcCode *c = 0; - void (*func) (OrcExecutor *); - - if (!p_inited) { - orc_once_mutex_lock (); - if (!p_inited) { - OrcProgram *p; - -#if 1 - static const orc_uint8 bc[] = { - 1, 9, 30, 118, 105, 100, 101, 111, 95, 115, 99, 97, 108, 101, 95, 111, - 114, 99, 95, 100, 111, 119, 110, 115, 97, 109, 112, 108, 101, 95, 117, - 49, - 54, 11, 2, 2, 12, 4, 4, 20, 2, 20, 2, 198, 32, 33, 4, 76, - 0, 32, 33, 2, 0, - }; - p = orc_program_new_from_static_bytecode (bc); - orc_program_set_backup_function (p, - _backup_video_scale_orc_downsample_u16); -#else - p = orc_program_new (); - orc_program_set_name (p, "video_scale_orc_downsample_u16"); - orc_program_set_backup_function (p, - _backup_video_scale_orc_downsample_u16); - orc_program_add_destination (p, 2, "d1"); - orc_program_add_source (p, 4, "s1"); - orc_program_add_temporary (p, 2, "t1"); - orc_program_add_temporary (p, 2, "t2"); - - orc_program_append_2 (p, "splitlw", 0, ORC_VAR_T1, ORC_VAR_T2, ORC_VAR_S1, - ORC_VAR_D1); - orc_program_append_2 (p, "avguw", 0, ORC_VAR_D1, ORC_VAR_T1, ORC_VAR_T2, - ORC_VAR_D1); -#endif - - orc_program_compile (p); - c = orc_program_take_code (p); - orc_program_free (p); - } - p_inited = TRUE; - orc_once_mutex_unlock (); - } - ex->arrays[ORC_VAR_A2] = c; - ex->program = 0; - - ex->n = n; - ex->arrays[ORC_VAR_D1] = d1; - ex->arrays[ORC_VAR_S1] = (void *) s1; - - func = c->exec; - func (ex); -} -#endif - - -/* video_scale_orc_downsample_u32 */ -#ifdef DISABLE_ORC -void -video_scale_orc_downsample_u32 (guint8 * ORC_RESTRICT d1, - const guint8 * ORC_RESTRICT s1, int n) -{ - int i; - orc_union32 *ORC_RESTRICT ptr0; - const orc_union64 *ORC_RESTRICT ptr4; - orc_union64 var34; - orc_union32 var35; - orc_union32 var36; - orc_union32 var37; - - ptr0 = (orc_union32 *) d1; - ptr4 = (orc_union64 *) s1; - - - for (i = 0; i < n; i++) { - /* 0: loadq */ - var34 = ptr4[i]; - /* 1: splitql */ - { - orc_union64 _src; - _src.i = var34.i; - var36.i = _src.x2[1]; - var37.i = _src.x2[0]; - } - /* 2: avgub */ - var35.x4[0] = ((orc_uint8) var36.x4[0] + (orc_uint8) var37.x4[0] + 1) >> 1; - var35.x4[1] = ((orc_uint8) var36.x4[1] + (orc_uint8) var37.x4[1] + 1) >> 1; - var35.x4[2] = ((orc_uint8) var36.x4[2] + (orc_uint8) var37.x4[2] + 1) >> 1; - var35.x4[3] = ((orc_uint8) var36.x4[3] + (orc_uint8) var37.x4[3] + 1) >> 1; - /* 3: storel */ - ptr0[i] = var35; - } - -} - -#else -static void -_backup_video_scale_orc_downsample_u32 (OrcExecutor * ORC_RESTRICT ex) -{ - int i; - int n = ex->n; - orc_union32 *ORC_RESTRICT ptr0; - const orc_union64 *ORC_RESTRICT ptr4; - orc_union64 var34; - orc_union32 var35; - orc_union32 var36; - orc_union32 var37; - - ptr0 = (orc_union32 *) ex->arrays[0]; - ptr4 = (orc_union64 *) ex->arrays[4]; - - - for (i = 0; i < n; i++) { - /* 0: loadq */ - var34 = ptr4[i]; - /* 1: splitql */ - { - orc_union64 _src; - _src.i = var34.i; - var36.i = _src.x2[1]; - var37.i = _src.x2[0]; - } - /* 2: avgub */ - var35.x4[0] = ((orc_uint8) var36.x4[0] + (orc_uint8) var37.x4[0] + 1) >> 1; - var35.x4[1] = ((orc_uint8) var36.x4[1] + (orc_uint8) var37.x4[1] + 1) >> 1; - var35.x4[2] = ((orc_uint8) var36.x4[2] + (orc_uint8) var37.x4[2] + 1) >> 1; - var35.x4[3] = ((orc_uint8) var36.x4[3] + (orc_uint8) var37.x4[3] + 1) >> 1; - /* 3: storel */ - ptr0[i] = var35; - } - -} - -void -video_scale_orc_downsample_u32 (guint8 * ORC_RESTRICT d1, - const guint8 * ORC_RESTRICT s1, int n) -{ - OrcExecutor _ex, *ex = &_ex; - static volatile int p_inited = 0; - static OrcCode *c = 0; - void (*func) (OrcExecutor *); - - if (!p_inited) { - orc_once_mutex_lock (); - if (!p_inited) { - OrcProgram *p; - -#if 1 - static const orc_uint8 bc[] = { - 1, 9, 30, 118, 105, 100, 101, 111, 95, 115, 99, 97, 108, 101, 95, 111, - 114, 99, 95, 100, 111, 119, 110, 115, 97, 109, 112, 108, 101, 95, 117, - 51, - 50, 11, 4, 4, 12, 8, 8, 20, 4, 20, 4, 197, 32, 33, 4, 21, - 2, 39, 0, 32, 33, 2, 0, - }; - p = orc_program_new_from_static_bytecode (bc); - orc_program_set_backup_function (p, - _backup_video_scale_orc_downsample_u32); -#else - p = orc_program_new (); - orc_program_set_name (p, "video_scale_orc_downsample_u32"); - orc_program_set_backup_function (p, - _backup_video_scale_orc_downsample_u32); - orc_program_add_destination (p, 4, "d1"); - orc_program_add_source (p, 8, "s1"); - orc_program_add_temporary (p, 4, "t1"); - orc_program_add_temporary (p, 4, "t2"); - - orc_program_append_2 (p, "splitql", 0, ORC_VAR_T1, ORC_VAR_T2, ORC_VAR_S1, - ORC_VAR_D1); - orc_program_append_2 (p, "avgub", 2, ORC_VAR_D1, ORC_VAR_T1, ORC_VAR_T2, - ORC_VAR_D1); -#endif - - orc_program_compile (p); - c = orc_program_take_code (p); - orc_program_free (p); - } - p_inited = TRUE; - orc_once_mutex_unlock (); - } - ex->arrays[ORC_VAR_A2] = c; - ex->program = 0; - - ex->n = n; - ex->arrays[ORC_VAR_D1] = d1; - ex->arrays[ORC_VAR_S1] = (void *) s1; - - func = c->exec; - func (ex); -} -#endif - - -/* video_scale_orc_downsample_yuyv */ -#ifdef DISABLE_ORC -void -video_scale_orc_downsample_yuyv (guint8 * ORC_RESTRICT d1, - const guint8 * ORC_RESTRICT s1, int n) -{ - int i; - orc_union32 *ORC_RESTRICT ptr0; - const orc_union64 *ORC_RESTRICT ptr4; - orc_union64 var38; - orc_union32 var39; - orc_union32 var40; - orc_union32 var41; - orc_union16 var42; - orc_union16 var43; - orc_union16 var44; - orc_union16 var45; - orc_union16 var46; - orc_union16 var47; - - ptr0 = (orc_union32 *) d1; - ptr4 = (orc_union64 *) s1; - - - for (i = 0; i < n; i++) { - /* 0: loadq */ - var38 = ptr4[i]; - /* 1: splitwb */ - { - orc_union16 _src; - _src.i = var38.x4[0]; - var40.x4[0] = _src.x2[1]; - var41.x4[0] = _src.x2[0]; - } - { - orc_union16 _src; - _src.i = var38.x4[1]; - var40.x4[1] = _src.x2[1]; - var41.x4[1] = _src.x2[0]; - } - { - orc_union16 _src; - _src.i = var38.x4[2]; - var40.x4[2] = _src.x2[1]; - var41.x4[2] = _src.x2[0]; - } - { - orc_union16 _src; - _src.i = var38.x4[3]; - var40.x4[3] = _src.x2[1]; - var41.x4[3] = _src.x2[0]; - } - /* 2: splitwb */ - { - orc_union16 _src; - _src.i = var40.x2[0]; - var42.x2[0] = _src.x2[1]; - var43.x2[0] = _src.x2[0]; - } - { - orc_union16 _src; - _src.i = var40.x2[1]; - var42.x2[1] = _src.x2[1]; - var43.x2[1] = _src.x2[0]; - } - /* 3: avgub */ - var44.x2[0] = ((orc_uint8) var42.x2[0] + (orc_uint8) var43.x2[0] + 1) >> 1; - var44.x2[1] = ((orc_uint8) var42.x2[1] + (orc_uint8) var43.x2[1] + 1) >> 1; - /* 4: splitlw */ - { - orc_union32 _src; - _src.i = var41.i; - var45.i = _src.x2[1]; - var46.i = _src.x2[0]; - } - /* 5: avgub */ - var47.x2[0] = ((orc_uint8) var45.x2[0] + (orc_uint8) var46.x2[0] + 1) >> 1; - var47.x2[1] = ((orc_uint8) var45.x2[1] + (orc_uint8) var46.x2[1] + 1) >> 1; - /* 6: mergebw */ - { - orc_union16 _dest; - _dest.x2[0] = var44.x2[0]; - _dest.x2[1] = var47.x2[0]; - var39.x2[0] = _dest.i; - } - { - orc_union16 _dest; - _dest.x2[0] = var44.x2[1]; - _dest.x2[1] = var47.x2[1]; - var39.x2[1] = _dest.i; - } - /* 7: storel */ - ptr0[i] = var39; - } - -} - -#else -static void -_backup_video_scale_orc_downsample_yuyv (OrcExecutor * ORC_RESTRICT ex) -{ - int i; - int n = ex->n; - orc_union32 *ORC_RESTRICT ptr0; - const orc_union64 *ORC_RESTRICT ptr4; - orc_union64 var38; - orc_union32 var39; - orc_union32 var40; - orc_union32 var41; - orc_union16 var42; - orc_union16 var43; - orc_union16 var44; - orc_union16 var45; - orc_union16 var46; - orc_union16 var47; - - ptr0 = (orc_union32 *) ex->arrays[0]; - ptr4 = (orc_union64 *) ex->arrays[4]; - - - for (i = 0; i < n; i++) { - /* 0: loadq */ - var38 = ptr4[i]; - /* 1: splitwb */ - { - orc_union16 _src; - _src.i = var38.x4[0]; - var40.x4[0] = _src.x2[1]; - var41.x4[0] = _src.x2[0]; - } - { - orc_union16 _src; - _src.i = var38.x4[1]; - var40.x4[1] = _src.x2[1]; - var41.x4[1] = _src.x2[0]; - } - { - orc_union16 _src; - _src.i = var38.x4[2]; - var40.x4[2] = _src.x2[1]; - var41.x4[2] = _src.x2[0]; - } - { - orc_union16 _src; - _src.i = var38.x4[3]; - var40.x4[3] = _src.x2[1]; - var41.x4[3] = _src.x2[0]; - } - /* 2: splitwb */ - { - orc_union16 _src; - _src.i = var40.x2[0]; - var42.x2[0] = _src.x2[1]; - var43.x2[0] = _src.x2[0]; - } - { - orc_union16 _src; - _src.i = var40.x2[1]; - var42.x2[1] = _src.x2[1]; - var43.x2[1] = _src.x2[0]; - } - /* 3: avgub */ - var44.x2[0] = ((orc_uint8) var42.x2[0] + (orc_uint8) var43.x2[0] + 1) >> 1; - var44.x2[1] = ((orc_uint8) var42.x2[1] + (orc_uint8) var43.x2[1] + 1) >> 1; - /* 4: splitlw */ - { - orc_union32 _src; - _src.i = var41.i; - var45.i = _src.x2[1]; - var46.i = _src.x2[0]; - } - /* 5: avgub */ - var47.x2[0] = ((orc_uint8) var45.x2[0] + (orc_uint8) var46.x2[0] + 1) >> 1; - var47.x2[1] = ((orc_uint8) var45.x2[1] + (orc_uint8) var46.x2[1] + 1) >> 1; - /* 6: mergebw */ - { - orc_union16 _dest; - _dest.x2[0] = var44.x2[0]; - _dest.x2[1] = var47.x2[0]; - var39.x2[0] = _dest.i; - } - { - orc_union16 _dest; - _dest.x2[0] = var44.x2[1]; - _dest.x2[1] = var47.x2[1]; - var39.x2[1] = _dest.i; - } - /* 7: storel */ - ptr0[i] = var39; - } - -} - -void -video_scale_orc_downsample_yuyv (guint8 * ORC_RESTRICT d1, - const guint8 * ORC_RESTRICT s1, int n) -{ - OrcExecutor _ex, *ex = &_ex; - static volatile int p_inited = 0; - static OrcCode *c = 0; - void (*func) (OrcExecutor *); - - if (!p_inited) { - orc_once_mutex_lock (); - if (!p_inited) { - OrcProgram *p; - -#if 1 - static const orc_uint8 bc[] = { - 1, 9, 31, 118, 105, 100, 101, 111, 95, 115, 99, 97, 108, 101, 95, 111, - 114, 99, 95, 100, 111, 119, 110, 115, 97, 109, 112, 108, 101, 95, 121, - 117, - 121, 118, 11, 4, 4, 12, 8, 8, 20, 4, 20, 4, 20, 2, 20, 2, - 20, 2, 20, 2, 21, 2, 199, 32, 33, 4, 21, 1, 199, 34, 35, 32, - 21, 1, 39, 36, 34, 35, 198, 34, 35, 33, 21, 1, 39, 37, 34, 35, - 21, 1, 196, 0, 36, 37, 2, 0, - }; - p = orc_program_new_from_static_bytecode (bc); - orc_program_set_backup_function (p, - _backup_video_scale_orc_downsample_yuyv); -#else - p = orc_program_new (); - orc_program_set_name (p, "video_scale_orc_downsample_yuyv"); - orc_program_set_backup_function (p, - _backup_video_scale_orc_downsample_yuyv); - orc_program_add_destination (p, 4, "d1"); - orc_program_add_source (p, 8, "s1"); - orc_program_add_temporary (p, 4, "t1"); - orc_program_add_temporary (p, 4, "t2"); - orc_program_add_temporary (p, 2, "t3"); - orc_program_add_temporary (p, 2, "t4"); - orc_program_add_temporary (p, 2, "t5"); - orc_program_add_temporary (p, 2, "t6"); - - orc_program_append_2 (p, "splitwb", 2, ORC_VAR_T1, ORC_VAR_T2, ORC_VAR_S1, - ORC_VAR_D1); - orc_program_append_2 (p, "splitwb", 1, ORC_VAR_T3, ORC_VAR_T4, ORC_VAR_T1, - ORC_VAR_D1); - orc_program_append_2 (p, "avgub", 1, ORC_VAR_T5, ORC_VAR_T3, ORC_VAR_T4, - ORC_VAR_D1); - orc_program_append_2 (p, "splitlw", 0, ORC_VAR_T3, ORC_VAR_T4, ORC_VAR_T2, - ORC_VAR_D1); - orc_program_append_2 (p, "avgub", 1, ORC_VAR_T6, ORC_VAR_T3, ORC_VAR_T4, - ORC_VAR_D1); - orc_program_append_2 (p, "mergebw", 1, ORC_VAR_D1, ORC_VAR_T5, ORC_VAR_T6, - ORC_VAR_D1); -#endif - - orc_program_compile (p); - c = orc_program_take_code (p); - orc_program_free (p); - } - p_inited = TRUE; - orc_once_mutex_unlock (); - } - ex->arrays[ORC_VAR_A2] = c; - ex->program = 0; - - ex->n = n; - ex->arrays[ORC_VAR_D1] = d1; - ex->arrays[ORC_VAR_S1] = (void *) s1; - - func = c->exec; - func (ex); -} -#endif - - -/* video_scale_orc_resample_nearest_u8 */ -#ifdef DISABLE_ORC -void -video_scale_orc_resample_nearest_u8 (guint8 * ORC_RESTRICT d1, - const guint8 * ORC_RESTRICT s1, int p1, int p2, int n) -{ - int i; - orc_int8 *ORC_RESTRICT ptr0; - const orc_int8 *ORC_RESTRICT ptr4; - orc_int8 var32; - - ptr0 = (orc_int8 *) d1; - ptr4 = (orc_int8 *) s1; - - - for (i = 0; i < n; i++) { - /* 0: ldresnearb */ - var32 = ptr4[(p1 + i * p2) >> 16]; - /* 1: storeb */ - ptr0[i] = var32; - } - -} - -#else -static void -_backup_video_scale_orc_resample_nearest_u8 (OrcExecutor * ORC_RESTRICT ex) -{ - int i; - int n = ex->n; - orc_int8 *ORC_RESTRICT ptr0; - const orc_int8 *ORC_RESTRICT ptr4; - orc_int8 var32; - - ptr0 = (orc_int8 *) ex->arrays[0]; - ptr4 = (orc_int8 *) ex->arrays[4]; - - - for (i = 0; i < n; i++) { - /* 0: ldresnearb */ - var32 = ptr4[(ex->params[24] + i * ex->params[25]) >> 16]; - /* 1: storeb */ - ptr0[i] = var32; - } - -} - -void -video_scale_orc_resample_nearest_u8 (guint8 * ORC_RESTRICT d1, - const guint8 * ORC_RESTRICT s1, int p1, int p2, int n) -{ - OrcExecutor _ex, *ex = &_ex; - static volatile int p_inited = 0; - static OrcCode *c = 0; - void (*func) (OrcExecutor *); - - if (!p_inited) { - orc_once_mutex_lock (); - if (!p_inited) { - OrcProgram *p; - -#if 1 - static const orc_uint8 bc[] = { - 1, 9, 35, 118, 105, 100, 101, 111, 95, 115, 99, 97, 108, 101, 95, 111, - 114, 99, 95, 114, 101, 115, 97, 109, 112, 108, 101, 95, 110, 101, 97, - 114, - 101, 115, 116, 95, 117, 56, 11, 1, 1, 12, 1, 1, 16, 4, 16, 4, - 48, 0, 4, 24, 25, 2, 0, - }; - p = orc_program_new_from_static_bytecode (bc); - orc_program_set_backup_function (p, - _backup_video_scale_orc_resample_nearest_u8); -#else - p = orc_program_new (); - orc_program_set_name (p, "video_scale_orc_resample_nearest_u8"); - orc_program_set_backup_function (p, - _backup_video_scale_orc_resample_nearest_u8); - orc_program_add_destination (p, 1, "d1"); - orc_program_add_source (p, 1, "s1"); - orc_program_add_parameter (p, 4, "p1"); - orc_program_add_parameter (p, 4, "p2"); - - orc_program_append_2 (p, "ldresnearb", 0, ORC_VAR_D1, ORC_VAR_S1, - ORC_VAR_P1, ORC_VAR_P2); -#endif - - orc_program_compile (p); - c = orc_program_take_code (p); - orc_program_free (p); - } - p_inited = TRUE; - orc_once_mutex_unlock (); - } - ex->arrays[ORC_VAR_A2] = c; - ex->program = 0; - - ex->n = n; - ex->arrays[ORC_VAR_D1] = d1; - ex->arrays[ORC_VAR_S1] = (void *) s1; - ex->params[ORC_VAR_P1] = p1; - ex->params[ORC_VAR_P2] = p2; - - func = c->exec; - func (ex); -} -#endif - - -/* video_scale_orc_resample_bilinear_u8 */ -#ifdef DISABLE_ORC -void -video_scale_orc_resample_bilinear_u8 (guint8 * ORC_RESTRICT d1, - const guint8 * ORC_RESTRICT s1, int p1, int p2, int n) -{ - int i; - orc_int8 *ORC_RESTRICT ptr0; - const orc_int8 *ORC_RESTRICT ptr4; - orc_int8 var32; - - ptr0 = (orc_int8 *) d1; - ptr4 = (orc_int8 *) s1; - - - for (i = 0; i < n; i++) { - /* 0: ldreslinb */ - { - int tmp = p1 + i * p2; - var32 = - ((orc_uint8) ptr4[tmp >> 16] * (256 - ((tmp >> 8) & 0xff)) + - (orc_uint8) ptr4[(tmp >> 16) + 1] * ((tmp >> 8) & 0xff)) >> 8; - } - /* 1: storeb */ - ptr0[i] = var32; - } - -} - -#else -static void -_backup_video_scale_orc_resample_bilinear_u8 (OrcExecutor * ORC_RESTRICT ex) -{ - int i; - int n = ex->n; - orc_int8 *ORC_RESTRICT ptr0; - const orc_int8 *ORC_RESTRICT ptr4; - orc_int8 var32; - - ptr0 = (orc_int8 *) ex->arrays[0]; - ptr4 = (orc_int8 *) ex->arrays[4]; - - - for (i = 0; i < n; i++) { - /* 0: ldreslinb */ - { - int tmp = ex->params[24] + i * ex->params[25]; - var32 = - ((orc_uint8) ptr4[tmp >> 16] * (256 - ((tmp >> 8) & 0xff)) + - (orc_uint8) ptr4[(tmp >> 16) + 1] * ((tmp >> 8) & 0xff)) >> 8; - } - /* 1: storeb */ - ptr0[i] = var32; - } - -} - -void -video_scale_orc_resample_bilinear_u8 (guint8 * ORC_RESTRICT d1, - const guint8 * ORC_RESTRICT s1, int p1, int p2, int n) -{ - OrcExecutor _ex, *ex = &_ex; - static volatile int p_inited = 0; - static OrcCode *c = 0; - void (*func) (OrcExecutor *); - - if (!p_inited) { - orc_once_mutex_lock (); - if (!p_inited) { - OrcProgram *p; - -#if 1 - static const orc_uint8 bc[] = { - 1, 9, 36, 118, 105, 100, 101, 111, 95, 115, 99, 97, 108, 101, 95, 111, - 114, 99, 95, 114, 101, 115, 97, 109, 112, 108, 101, 95, 98, 105, 108, - 105, - 110, 101, 97, 114, 95, 117, 56, 11, 1, 1, 12, 1, 1, 16, 4, 16, - 4, 50, 0, 4, 24, 25, 2, 0, - }; - p = orc_program_new_from_static_bytecode (bc); - orc_program_set_backup_function (p, - _backup_video_scale_orc_resample_bilinear_u8); -#else - p = orc_program_new (); - orc_program_set_name (p, "video_scale_orc_resample_bilinear_u8"); - orc_program_set_backup_function (p, - _backup_video_scale_orc_resample_bilinear_u8); - orc_program_add_destination (p, 1, "d1"); - orc_program_add_source (p, 1, "s1"); - orc_program_add_parameter (p, 4, "p1"); - orc_program_add_parameter (p, 4, "p2"); - - orc_program_append_2 (p, "ldreslinb", 0, ORC_VAR_D1, ORC_VAR_S1, - ORC_VAR_P1, ORC_VAR_P2); -#endif - - orc_program_compile (p); - c = orc_program_take_code (p); - orc_program_free (p); - } - p_inited = TRUE; - orc_once_mutex_unlock (); - } - ex->arrays[ORC_VAR_A2] = c; - ex->program = 0; - - ex->n = n; - ex->arrays[ORC_VAR_D1] = d1; - ex->arrays[ORC_VAR_S1] = (void *) s1; - ex->params[ORC_VAR_P1] = p1; - ex->params[ORC_VAR_P2] = p2; - - func = c->exec; - func (ex); -} -#endif - - -/* video_scale_orc_resample_nearest_u32 */ -#ifdef DISABLE_ORC -void -video_scale_orc_resample_nearest_u32 (guint8 * ORC_RESTRICT d1, - const guint8 * ORC_RESTRICT s1, int p1, int p2, int n) -{ - int i; - orc_union32 *ORC_RESTRICT ptr0; - const orc_union32 *ORC_RESTRICT ptr4; - orc_union32 var32; - - ptr0 = (orc_union32 *) d1; - ptr4 = (orc_union32 *) s1; - - - for (i = 0; i < n; i++) { - /* 0: ldresnearl */ - var32 = ptr4[(p1 + i * p2) >> 16]; - /* 1: storel */ - ptr0[i] = var32; - } - -} - -#else -static void -_backup_video_scale_orc_resample_nearest_u32 (OrcExecutor * ORC_RESTRICT ex) -{ - int i; - int n = ex->n; - orc_union32 *ORC_RESTRICT ptr0; - const orc_union32 *ORC_RESTRICT ptr4; - orc_union32 var32; - - ptr0 = (orc_union32 *) ex->arrays[0]; - ptr4 = (orc_union32 *) ex->arrays[4]; - - - for (i = 0; i < n; i++) { - /* 0: ldresnearl */ - var32 = ptr4[(ex->params[24] + i * ex->params[25]) >> 16]; - /* 1: storel */ - ptr0[i] = var32; - } - -} - -void -video_scale_orc_resample_nearest_u32 (guint8 * ORC_RESTRICT d1, - const guint8 * ORC_RESTRICT s1, int p1, int p2, int n) -{ - OrcExecutor _ex, *ex = &_ex; - static volatile int p_inited = 0; - static OrcCode *c = 0; - void (*func) (OrcExecutor *); - - if (!p_inited) { - orc_once_mutex_lock (); - if (!p_inited) { - OrcProgram *p; - -#if 1 - static const orc_uint8 bc[] = { - 1, 9, 36, 118, 105, 100, 101, 111, 95, 115, 99, 97, 108, 101, 95, 111, - 114, 99, 95, 114, 101, 115, 97, 109, 112, 108, 101, 95, 110, 101, 97, - 114, - 101, 115, 116, 95, 117, 51, 50, 11, 4, 4, 12, 4, 4, 16, 4, 16, - 4, 49, 0, 4, 24, 25, 2, 0, - }; - p = orc_program_new_from_static_bytecode (bc); - orc_program_set_backup_function (p, - _backup_video_scale_orc_resample_nearest_u32); -#else - p = orc_program_new (); - orc_program_set_name (p, "video_scale_orc_resample_nearest_u32"); - orc_program_set_backup_function (p, - _backup_video_scale_orc_resample_nearest_u32); - orc_program_add_destination (p, 4, "d1"); - orc_program_add_source (p, 4, "s1"); - orc_program_add_parameter (p, 4, "p1"); - orc_program_add_parameter (p, 4, "p2"); - - orc_program_append_2 (p, "ldresnearl", 0, ORC_VAR_D1, ORC_VAR_S1, - ORC_VAR_P1, ORC_VAR_P2); -#endif - - orc_program_compile (p); - c = orc_program_take_code (p); - orc_program_free (p); - } - p_inited = TRUE; - orc_once_mutex_unlock (); - } - ex->arrays[ORC_VAR_A2] = c; - ex->program = 0; - - ex->n = n; - ex->arrays[ORC_VAR_D1] = d1; - ex->arrays[ORC_VAR_S1] = (void *) s1; - ex->params[ORC_VAR_P1] = p1; - ex->params[ORC_VAR_P2] = p2; - - func = c->exec; - func (ex); -} -#endif - - -/* video_scale_orc_resample_bilinear_u32 */ -#ifdef DISABLE_ORC -void -video_scale_orc_resample_bilinear_u32 (guint8 * ORC_RESTRICT d1, - const guint8 * ORC_RESTRICT s1, int p1, int p2, int n) -{ - int i; - orc_union32 *ORC_RESTRICT ptr0; - const orc_union32 *ORC_RESTRICT ptr4; - orc_union32 var32; - - ptr0 = (orc_union32 *) d1; - ptr4 = (orc_union32 *) s1; - - - for (i = 0; i < n; i++) { - /* 0: ldreslinl */ - { - int tmp = p1 + i * p2; - orc_union32 a = ptr4[tmp >> 16]; - orc_union32 b = ptr4[(tmp >> 16) + 1]; - var32.x4[0] = - ((orc_uint8) a.x4[0] * (256 - ((tmp >> 8) & 0xff)) + - (orc_uint8) b.x4[0] * ((tmp >> 8) & 0xff)) >> 8; - var32.x4[1] = - ((orc_uint8) a.x4[1] * (256 - ((tmp >> 8) & 0xff)) + - (orc_uint8) b.x4[1] * ((tmp >> 8) & 0xff)) >> 8; - var32.x4[2] = - ((orc_uint8) a.x4[2] * (256 - ((tmp >> 8) & 0xff)) + - (orc_uint8) b.x4[2] * ((tmp >> 8) & 0xff)) >> 8; - var32.x4[3] = - ((orc_uint8) a.x4[3] * (256 - ((tmp >> 8) & 0xff)) + - (orc_uint8) b.x4[3] * ((tmp >> 8) & 0xff)) >> 8; - } - /* 1: storel */ - ptr0[i] = var32; - } - -} - -#else -static void -_backup_video_scale_orc_resample_bilinear_u32 (OrcExecutor * ORC_RESTRICT ex) -{ - int i; - int n = ex->n; - orc_union32 *ORC_RESTRICT ptr0; - const orc_union32 *ORC_RESTRICT ptr4; - orc_union32 var32; - - ptr0 = (orc_union32 *) ex->arrays[0]; - ptr4 = (orc_union32 *) ex->arrays[4]; - - - for (i = 0; i < n; i++) { - /* 0: ldreslinl */ - { - int tmp = ex->params[24] + i * ex->params[25]; - orc_union32 a = ptr4[tmp >> 16]; - orc_union32 b = ptr4[(tmp >> 16) + 1]; - var32.x4[0] = - ((orc_uint8) a.x4[0] * (256 - ((tmp >> 8) & 0xff)) + - (orc_uint8) b.x4[0] * ((tmp >> 8) & 0xff)) >> 8; - var32.x4[1] = - ((orc_uint8) a.x4[1] * (256 - ((tmp >> 8) & 0xff)) + - (orc_uint8) b.x4[1] * ((tmp >> 8) & 0xff)) >> 8; - var32.x4[2] = - ((orc_uint8) a.x4[2] * (256 - ((tmp >> 8) & 0xff)) + - (orc_uint8) b.x4[2] * ((tmp >> 8) & 0xff)) >> 8; - var32.x4[3] = - ((orc_uint8) a.x4[3] * (256 - ((tmp >> 8) & 0xff)) + - (orc_uint8) b.x4[3] * ((tmp >> 8) & 0xff)) >> 8; - } - /* 1: storel */ - ptr0[i] = var32; - } - -} - -void -video_scale_orc_resample_bilinear_u32 (guint8 * ORC_RESTRICT d1, - const guint8 * ORC_RESTRICT s1, int p1, int p2, int n) -{ - OrcExecutor _ex, *ex = &_ex; - static volatile int p_inited = 0; - static OrcCode *c = 0; - void (*func) (OrcExecutor *); - - if (!p_inited) { - orc_once_mutex_lock (); - if (!p_inited) { - OrcProgram *p; - -#if 1 - static const orc_uint8 bc[] = { - 1, 9, 37, 118, 105, 100, 101, 111, 95, 115, 99, 97, 108, 101, 95, 111, - 114, 99, 95, 114, 101, 115, 97, 109, 112, 108, 101, 95, 98, 105, 108, - 105, - 110, 101, 97, 114, 95, 117, 51, 50, 11, 4, 4, 12, 4, 4, 16, 4, - 16, 4, 51, 0, 4, 24, 25, 2, 0, - }; - p = orc_program_new_from_static_bytecode (bc); - orc_program_set_backup_function (p, - _backup_video_scale_orc_resample_bilinear_u32); -#else - p = orc_program_new (); - orc_program_set_name (p, "video_scale_orc_resample_bilinear_u32"); - orc_program_set_backup_function (p, - _backup_video_scale_orc_resample_bilinear_u32); - orc_program_add_destination (p, 4, "d1"); - orc_program_add_source (p, 4, "s1"); - orc_program_add_parameter (p, 4, "p1"); - orc_program_add_parameter (p, 4, "p2"); - - orc_program_append_2 (p, "ldreslinl", 0, ORC_VAR_D1, ORC_VAR_S1, - ORC_VAR_P1, ORC_VAR_P2); -#endif - - orc_program_compile (p); - c = orc_program_take_code (p); - orc_program_free (p); - } - p_inited = TRUE; - orc_once_mutex_unlock (); - } - ex->arrays[ORC_VAR_A2] = c; - ex->program = 0; - - ex->n = n; - ex->arrays[ORC_VAR_D1] = d1; - ex->arrays[ORC_VAR_S1] = (void *) s1; - ex->params[ORC_VAR_P1] = p1; - ex->params[ORC_VAR_P2] = p2; - - func = c->exec; - func (ex); -} -#endif - - -/* video_scale_orc_resample_merge_bilinear_u32 */ -#ifdef DISABLE_ORC -void -video_scale_orc_resample_merge_bilinear_u32 (guint8 * ORC_RESTRICT d1, - guint8 * ORC_RESTRICT d2, const guint8 * ORC_RESTRICT s1, - const guint8 * ORC_RESTRICT s2, int p1, int p2, int p3, int n) -{ - int i; - orc_union32 *ORC_RESTRICT ptr0; - orc_union32 *ORC_RESTRICT ptr1; - const orc_union32 *ORC_RESTRICT ptr4; - const orc_union32 *ORC_RESTRICT ptr5; - orc_union64 var37; - orc_union32 var38; - orc_union32 var39; - orc_union32 var40; - orc_union64 var41; - orc_union64 var42; - orc_union64 var43; - orc_union64 var44; - orc_union32 var45; - - ptr0 = (orc_union32 *) d1; - ptr1 = (orc_union32 *) d2; - ptr4 = (orc_union32 *) s1; - ptr5 = (orc_union32 *) s2; - - /* 6: loadpw */ - var37.x4[0] = p1; - var37.x4[1] = p1; - var37.x4[2] = p1; - var37.x4[3] = p1; - - for (i = 0; i < n; i++) { - /* 0: ldreslinl */ - { - int tmp = p2 + i * p3; - orc_union32 a = ptr5[tmp >> 16]; - orc_union32 b = ptr5[(tmp >> 16) + 1]; - var39.x4[0] = - ((orc_uint8) a.x4[0] * (256 - ((tmp >> 8) & 0xff)) + - (orc_uint8) b.x4[0] * ((tmp >> 8) & 0xff)) >> 8; - var39.x4[1] = - ((orc_uint8) a.x4[1] * (256 - ((tmp >> 8) & 0xff)) + - (orc_uint8) b.x4[1] * ((tmp >> 8) & 0xff)) >> 8; - var39.x4[2] = - ((orc_uint8) a.x4[2] * (256 - ((tmp >> 8) & 0xff)) + - (orc_uint8) b.x4[2] * ((tmp >> 8) & 0xff)) >> 8; - var39.x4[3] = - ((orc_uint8) a.x4[3] * (256 - ((tmp >> 8) & 0xff)) + - (orc_uint8) b.x4[3] * ((tmp >> 8) & 0xff)) >> 8; - } - /* 1: storel */ - ptr1[i] = var39; - /* 2: loadl */ - var40 = ptr4[i]; - /* 3: convubw */ - var41.x4[0] = (orc_uint8) var40.x4[0]; - var41.x4[1] = (orc_uint8) var40.x4[1]; - var41.x4[2] = (orc_uint8) var40.x4[2]; - var41.x4[3] = (orc_uint8) var40.x4[3]; - /* 4: convubw */ - var42.x4[0] = (orc_uint8) var39.x4[0]; - var42.x4[1] = (orc_uint8) var39.x4[1]; - var42.x4[2] = (orc_uint8) var39.x4[2]; - var42.x4[3] = (orc_uint8) var39.x4[3]; - /* 5: subw */ - var43.x4[0] = var42.x4[0] - var41.x4[0]; - var43.x4[1] = var42.x4[1] - var41.x4[1]; - var43.x4[2] = var42.x4[2] - var41.x4[2]; - var43.x4[3] = var42.x4[3] - var41.x4[3]; - /* 7: mullw */ - var44.x4[0] = (var43.x4[0] * var37.x4[0]) & 0xffff; - var44.x4[1] = (var43.x4[1] * var37.x4[1]) & 0xffff; - var44.x4[2] = (var43.x4[2] * var37.x4[2]) & 0xffff; - var44.x4[3] = (var43.x4[3] * var37.x4[3]) & 0xffff; - /* 8: convhwb */ - var45.x4[0] = ((orc_uint16) var44.x4[0]) >> 8; - var45.x4[1] = ((orc_uint16) var44.x4[1]) >> 8; - var45.x4[2] = ((orc_uint16) var44.x4[2]) >> 8; - var45.x4[3] = ((orc_uint16) var44.x4[3]) >> 8; - /* 9: addb */ - var38.x4[0] = var45.x4[0] + var40.x4[0]; - var38.x4[1] = var45.x4[1] + var40.x4[1]; - var38.x4[2] = var45.x4[2] + var40.x4[2]; - var38.x4[3] = var45.x4[3] + var40.x4[3]; - /* 10: storel */ - ptr0[i] = var38; - } - -} - -#else -static void -_backup_video_scale_orc_resample_merge_bilinear_u32 (OrcExecutor * - ORC_RESTRICT ex) -{ - int i; - int n = ex->n; - orc_union32 *ORC_RESTRICT ptr0; - orc_union32 *ORC_RESTRICT ptr1; - const orc_union32 *ORC_RESTRICT ptr4; - const orc_union32 *ORC_RESTRICT ptr5; - orc_union64 var37; - orc_union32 var38; - orc_union32 var39; - orc_union32 var40; - orc_union64 var41; - orc_union64 var42; - orc_union64 var43; - orc_union64 var44; - orc_union32 var45; - - ptr0 = (orc_union32 *) ex->arrays[0]; - ptr1 = (orc_union32 *) ex->arrays[1]; - ptr4 = (orc_union32 *) ex->arrays[4]; - ptr5 = (orc_union32 *) ex->arrays[5]; - - /* 6: loadpw */ - var37.x4[0] = ex->params[24]; - var37.x4[1] = ex->params[24]; - var37.x4[2] = ex->params[24]; - var37.x4[3] = ex->params[24]; - - for (i = 0; i < n; i++) { - /* 0: ldreslinl */ - { - int tmp = ex->params[25] + i * ex->params[26]; - orc_union32 a = ptr5[tmp >> 16]; - orc_union32 b = ptr5[(tmp >> 16) + 1]; - var39.x4[0] = - ((orc_uint8) a.x4[0] * (256 - ((tmp >> 8) & 0xff)) + - (orc_uint8) b.x4[0] * ((tmp >> 8) & 0xff)) >> 8; - var39.x4[1] = - ((orc_uint8) a.x4[1] * (256 - ((tmp >> 8) & 0xff)) + - (orc_uint8) b.x4[1] * ((tmp >> 8) & 0xff)) >> 8; - var39.x4[2] = - ((orc_uint8) a.x4[2] * (256 - ((tmp >> 8) & 0xff)) + - (orc_uint8) b.x4[2] * ((tmp >> 8) & 0xff)) >> 8; - var39.x4[3] = - ((orc_uint8) a.x4[3] * (256 - ((tmp >> 8) & 0xff)) + - (orc_uint8) b.x4[3] * ((tmp >> 8) & 0xff)) >> 8; - } - /* 1: storel */ - ptr1[i] = var39; - /* 2: loadl */ - var40 = ptr4[i]; - /* 3: convubw */ - var41.x4[0] = (orc_uint8) var40.x4[0]; - var41.x4[1] = (orc_uint8) var40.x4[1]; - var41.x4[2] = (orc_uint8) var40.x4[2]; - var41.x4[3] = (orc_uint8) var40.x4[3]; - /* 4: convubw */ - var42.x4[0] = (orc_uint8) var39.x4[0]; - var42.x4[1] = (orc_uint8) var39.x4[1]; - var42.x4[2] = (orc_uint8) var39.x4[2]; - var42.x4[3] = (orc_uint8) var39.x4[3]; - /* 5: subw */ - var43.x4[0] = var42.x4[0] - var41.x4[0]; - var43.x4[1] = var42.x4[1] - var41.x4[1]; - var43.x4[2] = var42.x4[2] - var41.x4[2]; - var43.x4[3] = var42.x4[3] - var41.x4[3]; - /* 7: mullw */ - var44.x4[0] = (var43.x4[0] * var37.x4[0]) & 0xffff; - var44.x4[1] = (var43.x4[1] * var37.x4[1]) & 0xffff; - var44.x4[2] = (var43.x4[2] * var37.x4[2]) & 0xffff; - var44.x4[3] = (var43.x4[3] * var37.x4[3]) & 0xffff; - /* 8: convhwb */ - var45.x4[0] = ((orc_uint16) var44.x4[0]) >> 8; - var45.x4[1] = ((orc_uint16) var44.x4[1]) >> 8; - var45.x4[2] = ((orc_uint16) var44.x4[2]) >> 8; - var45.x4[3] = ((orc_uint16) var44.x4[3]) >> 8; - /* 9: addb */ - var38.x4[0] = var45.x4[0] + var40.x4[0]; - var38.x4[1] = var45.x4[1] + var40.x4[1]; - var38.x4[2] = var45.x4[2] + var40.x4[2]; - var38.x4[3] = var45.x4[3] + var40.x4[3]; - /* 10: storel */ - ptr0[i] = var38; - } - -} - -void -video_scale_orc_resample_merge_bilinear_u32 (guint8 * ORC_RESTRICT d1, - guint8 * ORC_RESTRICT d2, const guint8 * ORC_RESTRICT s1, - const guint8 * ORC_RESTRICT s2, int p1, int p2, int p3, int n) -{ - OrcExecutor _ex, *ex = &_ex; - static volatile int p_inited = 0; - static OrcCode *c = 0; - void (*func) (OrcExecutor *); - - if (!p_inited) { - orc_once_mutex_lock (); - if (!p_inited) { - OrcProgram *p; - -#if 1 - static const orc_uint8 bc[] = { - 1, 9, 43, 118, 105, 100, 101, 111, 95, 115, 99, 97, 108, 101, 95, 111, - 114, 99, 95, 114, 101, 115, 97, 109, 112, 108, 101, 95, 109, 101, 114, - 103, - 101, 95, 98, 105, 108, 105, 110, 101, 97, 114, 95, 117, 51, 50, 11, 4, - 4, 11, 4, 4, 12, 4, 4, 12, 4, 4, 16, 4, 16, 4, 16, 4, - 20, 4, 20, 4, 20, 4, 20, 8, 20, 8, 51, 33, 5, 25, 26, 128, - 1, 33, 113, 32, 4, 21, 2, 150, 35, 32, 21, 2, 150, 36, 33, 21, - 2, 98, 36, 36, 35, 21, 2, 89, 36, 36, 24, 21, 2, 158, 34, 36, - 21, 2, 33, 0, 34, 32, 2, 0, - }; - p = orc_program_new_from_static_bytecode (bc); - orc_program_set_backup_function (p, - _backup_video_scale_orc_resample_merge_bilinear_u32); -#else - p = orc_program_new (); - orc_program_set_name (p, "video_scale_orc_resample_merge_bilinear_u32"); - orc_program_set_backup_function (p, - _backup_video_scale_orc_resample_merge_bilinear_u32); - orc_program_add_destination (p, 4, "d1"); - orc_program_add_destination (p, 4, "d2"); - orc_program_add_source (p, 4, "s1"); - orc_program_add_source (p, 4, "s2"); - orc_program_add_parameter (p, 4, "p1"); - orc_program_add_parameter (p, 4, "p2"); - orc_program_add_parameter (p, 4, "p3"); - orc_program_add_temporary (p, 4, "t1"); - orc_program_add_temporary (p, 4, "t2"); - orc_program_add_temporary (p, 4, "t3"); - orc_program_add_temporary (p, 8, "t4"); - orc_program_add_temporary (p, 8, "t5"); - - orc_program_append_2 (p, "ldreslinl", 0, ORC_VAR_T2, ORC_VAR_S2, - ORC_VAR_P2, ORC_VAR_P3); - orc_program_append_2 (p, "storel", 0, ORC_VAR_D2, ORC_VAR_T2, ORC_VAR_D1, - ORC_VAR_D1); - orc_program_append_2 (p, "loadl", 0, ORC_VAR_T1, ORC_VAR_S1, ORC_VAR_D1, - ORC_VAR_D1); - orc_program_append_2 (p, "convubw", 2, ORC_VAR_T4, ORC_VAR_T1, ORC_VAR_D1, - ORC_VAR_D1); - orc_program_append_2 (p, "convubw", 2, ORC_VAR_T5, ORC_VAR_T2, ORC_VAR_D1, - ORC_VAR_D1); - orc_program_append_2 (p, "subw", 2, ORC_VAR_T5, ORC_VAR_T5, ORC_VAR_T4, - ORC_VAR_D1); - orc_program_append_2 (p, "mullw", 2, ORC_VAR_T5, ORC_VAR_T5, ORC_VAR_P1, - ORC_VAR_D1); - orc_program_append_2 (p, "convhwb", 2, ORC_VAR_T3, ORC_VAR_T5, ORC_VAR_D1, - ORC_VAR_D1); - orc_program_append_2 (p, "addb", 2, ORC_VAR_D1, ORC_VAR_T3, ORC_VAR_T1, - ORC_VAR_D1); -#endif - - orc_program_compile (p); - c = orc_program_take_code (p); - orc_program_free (p); - } - p_inited = TRUE; - orc_once_mutex_unlock (); - } - ex->arrays[ORC_VAR_A2] = c; - ex->program = 0; - - ex->n = n; - ex->arrays[ORC_VAR_D1] = d1; - ex->arrays[ORC_VAR_D2] = d2; - ex->arrays[ORC_VAR_S1] = (void *) s1; - ex->arrays[ORC_VAR_S2] = (void *) s2; - ex->params[ORC_VAR_P1] = p1; - ex->params[ORC_VAR_P2] = p2; - ex->params[ORC_VAR_P3] = p3; - - func = c->exec; - func (ex); -} -#endif - - -/* video_scale_orc_merge_bicubic_u8 */ -#ifdef DISABLE_ORC -void -video_scale_orc_merge_bicubic_u8 (guint8 * ORC_RESTRICT d1, - const guint8 * ORC_RESTRICT s1, const guint8 * ORC_RESTRICT s2, - const guint8 * ORC_RESTRICT s3, const guint8 * ORC_RESTRICT s4, int p1, - int p2, int p3, int p4, int n) -{ - int i; - orc_int8 *ORC_RESTRICT ptr0; - const orc_int8 *ORC_RESTRICT ptr4; - const orc_int8 *ORC_RESTRICT ptr5; - const orc_int8 *ORC_RESTRICT ptr6; - const orc_int8 *ORC_RESTRICT ptr7; - orc_int8 var34; - orc_int8 var35; - orc_int8 var36; - orc_int8 var37; - orc_int8 var38; - orc_int8 var39; - orc_int8 var40; - orc_int8 var41; -#if defined(__APPLE__) && __GNUC__ == 4 && __GNUC_MINOR__ == 2 && defined (__i386__) - volatile orc_union16 var42; -#else - orc_union16 var42; -#endif - orc_int8 var43; - orc_union16 var44; - orc_union16 var45; - orc_union16 var46; - orc_union16 var47; - orc_union16 var48; - orc_union16 var49; - orc_union16 var50; - orc_union16 var51; - orc_union16 var52; - - ptr0 = (orc_int8 *) d1; - ptr4 = (orc_int8 *) s1; - ptr5 = (orc_int8 *) s2; - ptr6 = (orc_int8 *) s3; - ptr7 = (orc_int8 *) s4; - - /* 1: loadpb */ - var35 = p2; - /* 4: loadpb */ - var37 = p3; - /* 8: loadpb */ - var39 = p1; - /* 12: loadpb */ - var41 = p4; - /* 15: loadpw */ - var42.i = (int) 0x00000020; /* 32 or 1.58101e-322f */ - - for (i = 0; i < n; i++) { - /* 0: loadb */ - var34 = ptr5[i]; - /* 2: mulubw */ - var44.i = ((orc_uint8) var34) * ((orc_uint8) var35); - /* 3: loadb */ - var36 = ptr6[i]; - /* 5: mulubw */ - var45.i = ((orc_uint8) var36) * ((orc_uint8) var37); - /* 6: addw */ - var46.i = var44.i + var45.i; - /* 7: loadb */ - var38 = ptr4[i]; - /* 9: mulubw */ - var47.i = ((orc_uint8) var38) * ((orc_uint8) var39); - /* 10: subw */ - var48.i = var46.i - var47.i; - /* 11: loadb */ - var40 = ptr7[i]; - /* 13: mulubw */ - var49.i = ((orc_uint8) var40) * ((orc_uint8) var41); - /* 14: subw */ - var50.i = var48.i - var49.i; - /* 16: addw */ - var51.i = var50.i + var42.i; - /* 17: shrsw */ - var52.i = var51.i >> 6; - /* 18: convsuswb */ - var43 = ORC_CLAMP_UB (var52.i); - /* 19: storeb */ - ptr0[i] = var43; - } - -} - -#else -static void -_backup_video_scale_orc_merge_bicubic_u8 (OrcExecutor * ORC_RESTRICT ex) -{ - int i; - int n = ex->n; - orc_int8 *ORC_RESTRICT ptr0; - const orc_int8 *ORC_RESTRICT ptr4; - const orc_int8 *ORC_RESTRICT ptr5; - const orc_int8 *ORC_RESTRICT ptr6; - const orc_int8 *ORC_RESTRICT ptr7; - orc_int8 var34; - orc_int8 var35; - orc_int8 var36; - orc_int8 var37; - orc_int8 var38; - orc_int8 var39; - orc_int8 var40; - orc_int8 var41; -#if defined(__APPLE__) && __GNUC__ == 4 && __GNUC_MINOR__ == 2 && defined (__i386__) - volatile orc_union16 var42; -#else - orc_union16 var42; -#endif - orc_int8 var43; - orc_union16 var44; - orc_union16 var45; - orc_union16 var46; - orc_union16 var47; - orc_union16 var48; - orc_union16 var49; - orc_union16 var50; - orc_union16 var51; - orc_union16 var52; - - ptr0 = (orc_int8 *) ex->arrays[0]; - ptr4 = (orc_int8 *) ex->arrays[4]; - ptr5 = (orc_int8 *) ex->arrays[5]; - ptr6 = (orc_int8 *) ex->arrays[6]; - ptr7 = (orc_int8 *) ex->arrays[7]; - - /* 1: loadpb */ - var35 = ex->params[25]; - /* 4: loadpb */ - var37 = ex->params[26]; - /* 8: loadpb */ - var39 = ex->params[24]; - /* 12: loadpb */ - var41 = ex->params[27]; - /* 15: loadpw */ - var42.i = (int) 0x00000020; /* 32 or 1.58101e-322f */ - - for (i = 0; i < n; i++) { - /* 0: loadb */ - var34 = ptr5[i]; - /* 2: mulubw */ - var44.i = ((orc_uint8) var34) * ((orc_uint8) var35); - /* 3: loadb */ - var36 = ptr6[i]; - /* 5: mulubw */ - var45.i = ((orc_uint8) var36) * ((orc_uint8) var37); - /* 6: addw */ - var46.i = var44.i + var45.i; - /* 7: loadb */ - var38 = ptr4[i]; - /* 9: mulubw */ - var47.i = ((orc_uint8) var38) * ((orc_uint8) var39); - /* 10: subw */ - var48.i = var46.i - var47.i; - /* 11: loadb */ - var40 = ptr7[i]; - /* 13: mulubw */ - var49.i = ((orc_uint8) var40) * ((orc_uint8) var41); - /* 14: subw */ - var50.i = var48.i - var49.i; - /* 16: addw */ - var51.i = var50.i + var42.i; - /* 17: shrsw */ - var52.i = var51.i >> 6; - /* 18: convsuswb */ - var43 = ORC_CLAMP_UB (var52.i); - /* 19: storeb */ - ptr0[i] = var43; - } - -} - -void -video_scale_orc_merge_bicubic_u8 (guint8 * ORC_RESTRICT d1, - const guint8 * ORC_RESTRICT s1, const guint8 * ORC_RESTRICT s2, - const guint8 * ORC_RESTRICT s3, const guint8 * ORC_RESTRICT s4, int p1, - int p2, int p3, int p4, int n) -{ - OrcExecutor _ex, *ex = &_ex; - static volatile int p_inited = 0; - static OrcCode *c = 0; - void (*func) (OrcExecutor *); - - if (!p_inited) { - orc_once_mutex_lock (); - if (!p_inited) { - OrcProgram *p; - -#if 1 - static const orc_uint8 bc[] = { - 1, 9, 32, 118, 105, 100, 101, 111, 95, 115, 99, 97, 108, 101, 95, 111, - 114, 99, 95, 109, 101, 114, 103, 101, 95, 98, 105, 99, 117, 98, 105, 99, - 95, 117, 56, 11, 1, 1, 12, 1, 1, 12, 1, 1, 12, 1, 1, 12, - 1, 1, 14, 4, 32, 0, 0, 0, 14, 4, 6, 0, 0, 0, 16, 4, - 16, 4, 16, 4, 16, 4, 20, 2, 20, 2, 175, 32, 5, 25, 175, 33, - 6, 26, 70, 32, 32, 33, 175, 33, 4, 24, 98, 32, 32, 33, 175, 33, - 7, 27, 98, 32, 32, 33, 70, 32, 32, 16, 94, 32, 32, 17, 160, 0, - 32, 2, 0, - }; - p = orc_program_new_from_static_bytecode (bc); - orc_program_set_backup_function (p, - _backup_video_scale_orc_merge_bicubic_u8); -#else - p = orc_program_new (); - orc_program_set_name (p, "video_scale_orc_merge_bicubic_u8"); - orc_program_set_backup_function (p, - _backup_video_scale_orc_merge_bicubic_u8); - orc_program_add_destination (p, 1, "d1"); - orc_program_add_source (p, 1, "s1"); - orc_program_add_source (p, 1, "s2"); - orc_program_add_source (p, 1, "s3"); - orc_program_add_source (p, 1, "s4"); - orc_program_add_constant (p, 4, 0x00000020, "c1"); - orc_program_add_constant (p, 4, 0x00000006, "c2"); - orc_program_add_parameter (p, 4, "p1"); - orc_program_add_parameter (p, 4, "p2"); - orc_program_add_parameter (p, 4, "p3"); - orc_program_add_parameter (p, 4, "p4"); - orc_program_add_temporary (p, 2, "t1"); - orc_program_add_temporary (p, 2, "t2"); - - orc_program_append_2 (p, "mulubw", 0, ORC_VAR_T1, ORC_VAR_S2, ORC_VAR_P2, - ORC_VAR_D1); - orc_program_append_2 (p, "mulubw", 0, ORC_VAR_T2, ORC_VAR_S3, ORC_VAR_P3, - ORC_VAR_D1); - orc_program_append_2 (p, "addw", 0, ORC_VAR_T1, ORC_VAR_T1, ORC_VAR_T2, - ORC_VAR_D1); - orc_program_append_2 (p, "mulubw", 0, ORC_VAR_T2, ORC_VAR_S1, ORC_VAR_P1, - ORC_VAR_D1); - orc_program_append_2 (p, "subw", 0, ORC_VAR_T1, ORC_VAR_T1, ORC_VAR_T2, - ORC_VAR_D1); - orc_program_append_2 (p, "mulubw", 0, ORC_VAR_T2, ORC_VAR_S4, ORC_VAR_P4, - ORC_VAR_D1); - orc_program_append_2 (p, "subw", 0, ORC_VAR_T1, ORC_VAR_T1, ORC_VAR_T2, - ORC_VAR_D1); - orc_program_append_2 (p, "addw", 0, ORC_VAR_T1, ORC_VAR_T1, ORC_VAR_C1, - ORC_VAR_D1); - orc_program_append_2 (p, "shrsw", 0, ORC_VAR_T1, ORC_VAR_T1, ORC_VAR_C2, - ORC_VAR_D1); - orc_program_append_2 (p, "convsuswb", 0, ORC_VAR_D1, ORC_VAR_T1, - ORC_VAR_D1, ORC_VAR_D1); -#endif - - orc_program_compile (p); - c = orc_program_take_code (p); - orc_program_free (p); - } - p_inited = TRUE; - orc_once_mutex_unlock (); - } - ex->arrays[ORC_VAR_A2] = c; - ex->program = 0; - - ex->n = n; - ex->arrays[ORC_VAR_D1] = d1; - ex->arrays[ORC_VAR_S1] = (void *) s1; - ex->arrays[ORC_VAR_S2] = (void *) s2; - ex->arrays[ORC_VAR_S3] = (void *) s3; - ex->arrays[ORC_VAR_S4] = (void *) s4; - ex->params[ORC_VAR_P1] = p1; - ex->params[ORC_VAR_P2] = p2; - ex->params[ORC_VAR_P3] = p3; - ex->params[ORC_VAR_P4] = p4; - - func = c->exec; - func (ex); -} -#endif diff --git a/gst/videoscale/gstvideoscaleorc-dist.h b/gst/videoscale/gstvideoscaleorc-dist.h deleted file mode 100644 index 868f07b4be..0000000000 --- a/gst/videoscale/gstvideoscaleorc-dist.h +++ /dev/null @@ -1,104 +0,0 @@ - -/* autogenerated from gstvideoscaleorc.orc */ - -#ifndef _GSTVIDEOSCALEORC_H_ -#define _GSTVIDEOSCALEORC_H_ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - - - -#ifndef _ORC_INTEGER_TYPEDEFS_ -#define _ORC_INTEGER_TYPEDEFS_ -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L -#include -typedef int8_t orc_int8; -typedef int16_t orc_int16; -typedef int32_t orc_int32; -typedef int64_t orc_int64; -typedef uint8_t orc_uint8; -typedef uint16_t orc_uint16; -typedef uint32_t orc_uint32; -typedef uint64_t orc_uint64; -#define ORC_UINT64_C(x) UINT64_C(x) -#elif defined(_MSC_VER) -typedef signed __int8 orc_int8; -typedef signed __int16 orc_int16; -typedef signed __int32 orc_int32; -typedef signed __int64 orc_int64; -typedef unsigned __int8 orc_uint8; -typedef unsigned __int16 orc_uint16; -typedef unsigned __int32 orc_uint32; -typedef unsigned __int64 orc_uint64; -#define ORC_UINT64_C(x) (x##Ui64) -#define inline __inline -#else -#include -typedef signed char orc_int8; -typedef short orc_int16; -typedef int orc_int32; -typedef unsigned char orc_uint8; -typedef unsigned short orc_uint16; -typedef unsigned int orc_uint32; -#if INT_MAX == LONG_MAX -typedef long long orc_int64; -typedef unsigned long long orc_uint64; -#define ORC_UINT64_C(x) (x##ULL) -#else -typedef long orc_int64; -typedef unsigned long orc_uint64; -#define ORC_UINT64_C(x) (x##UL) -#endif -#endif -typedef union { orc_int16 i; orc_int8 x2[2]; } orc_union16; -typedef union { orc_int32 i; float f; orc_int16 x2[2]; orc_int8 x4[4]; } orc_union32; -typedef union { orc_int64 i; double f; orc_int32 x2[2]; float x2f[2]; orc_int16 x4[4]; } orc_union64; -#endif -#ifndef ORC_RESTRICT -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L -#define ORC_RESTRICT restrict -#elif defined(__GNUC__) && __GNUC__ >= 4 -#define ORC_RESTRICT __restrict__ -#else -#define ORC_RESTRICT -#endif -#endif - -#ifndef ORC_INTERNAL -#if defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590) -#define ORC_INTERNAL __attribute__((visibility("hidden"))) -#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550) -#define ORC_INTERNAL __hidden -#elif defined (__GNUC__) -#define ORC_INTERNAL __attribute__((visibility("hidden"))) -#else -#define ORC_INTERNAL -#endif -#endif - -void video_scale_orc_merge_linear_u8 (orc_uint8 * ORC_RESTRICT d1, const orc_uint8 * ORC_RESTRICT s1, const orc_uint8 * ORC_RESTRICT s2, int p1, int n); -void video_scale_orc_merge_linear_u16 (orc_uint16 * ORC_RESTRICT d1, const orc_uint16 * ORC_RESTRICT s1, const orc_uint16 * ORC_RESTRICT s2, int p1, int p2, int n); -void video_scale_orc_splat_u16 (orc_uint16 * ORC_RESTRICT d1, int p1, int n); -void video_scale_orc_splat_u32 (orc_uint32 * ORC_RESTRICT d1, int p1, int n); -void video_scale_orc_splat_u64 (orc_uint64 * ORC_RESTRICT d1, orc_int64 p1, int n); -void video_scale_orc_downsample_u8 (guint8 * ORC_RESTRICT d1, const guint8 * ORC_RESTRICT s1, int n); -void video_scale_orc_downsample_u16 (guint16 * ORC_RESTRICT d1, const guint16 * ORC_RESTRICT s1, int n); -void video_scale_orc_downsample_u32 (guint8 * ORC_RESTRICT d1, const guint8 * ORC_RESTRICT s1, int n); -void video_scale_orc_downsample_yuyv (guint8 * ORC_RESTRICT d1, const guint8 * ORC_RESTRICT s1, int n); -void video_scale_orc_resample_nearest_u8 (guint8 * ORC_RESTRICT d1, const guint8 * ORC_RESTRICT s1, int p1, int p2, int n); -void video_scale_orc_resample_bilinear_u8 (guint8 * ORC_RESTRICT d1, const guint8 * ORC_RESTRICT s1, int p1, int p2, int n); -void video_scale_orc_resample_nearest_u32 (guint8 * ORC_RESTRICT d1, const guint8 * ORC_RESTRICT s1, int p1, int p2, int n); -void video_scale_orc_resample_bilinear_u32 (guint8 * ORC_RESTRICT d1, const guint8 * ORC_RESTRICT s1, int p1, int p2, int n); -void video_scale_orc_resample_merge_bilinear_u32 (guint8 * ORC_RESTRICT d1, guint8 * ORC_RESTRICT d2, const guint8 * ORC_RESTRICT s1, const guint8 * ORC_RESTRICT s2, int p1, int p2, int p3, int n); -void video_scale_orc_merge_bicubic_u8 (guint8 * ORC_RESTRICT d1, const guint8 * ORC_RESTRICT s1, const guint8 * ORC_RESTRICT s2, const guint8 * ORC_RESTRICT s3, const guint8 * ORC_RESTRICT s4, int p1, int p2, int p3, int p4, int n); - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/gst/videoscale/gstvideoscaleorc.orc b/gst/videoscale/gstvideoscaleorc.orc deleted file mode 100644 index 06e8c9beae..0000000000 --- a/gst/videoscale/gstvideoscaleorc.orc +++ /dev/null @@ -1,197 +0,0 @@ - -.function video_scale_orc_merge_linear_u8 -.dest 1 d1 -.source 1 s1 -.source 1 s2 -.param 1 p1 -.temp 2 t1 -.temp 2 t2 -.temp 1 a -.temp 1 t - -loadb a, s1 -convubw t1, s1 -convubw t2, s2 -subw t2, t2, t1 -mullw t2, t2, p1 -addw t2, t2, 128 -convhwb t, t2 -addb d1, t, a - - - -.function video_scale_orc_merge_linear_u16 -.dest 2 d1 -.source 2 s1 -.source 2 s2 -.param 2 p1 -.param 2 p2 -.temp 4 t1 -.temp 4 t2 - -# This is slightly different thatn the u8 case, since muluwl -# tends to be much faster than mulll -muluwl t1, s1, p1 -muluwl t2, s2, p2 -addl t1, t1, t2 -shrul t1, t1, 16 -convlw d1, t1 - - -.function video_scale_orc_splat_u16 -.dest 2 d1 -.param 2 p1 - -copyw d1, p1 - - -.function video_scale_orc_splat_u32 -.dest 4 d1 -.param 4 p1 - -copyl d1, p1 - - -.function video_scale_orc_splat_u64 -.dest 8 d1 -.longparam 8 p1 - -copyq d1, p1 - - -.function video_scale_orc_downsample_u8 -.dest 1 d1 guint8 -.source 2 s1 guint8 -.temp 1 t1 -.temp 1 t2 - -splitwb t1, t2, s1 -avgub d1, t1, t2 - - -.function video_scale_orc_downsample_u16 -.dest 2 d1 guint16 -.source 4 s1 guint16 -.temp 2 t1 -.temp 2 t2 - -splitlw t1, t2, s1 -avguw d1, t1, t2 - - -.function video_scale_orc_downsample_u32 -.dest 4 d1 guint8 -.source 8 s1 guint8 -.temp 4 t1 -.temp 4 t2 - -splitql t1, t2, s1 -x4 avgub d1, t1, t2 - - -.function video_scale_orc_downsample_yuyv -.dest 4 d1 guint8 -.source 8 s1 guint8 -.temp 4 yyyy -.temp 4 uvuv -.temp 2 t1 -.temp 2 t2 -.temp 2 yy -.temp 2 uv - -x4 splitwb yyyy, uvuv, s1 -x2 splitwb t1, t2, yyyy -x2 avgub yy, t1, t2 -splitlw t1, t2, uvuv -x2 avgub uv, t1, t2 -x2 mergebw d1, yy, uv - - - -.function video_scale_orc_resample_nearest_u8 -.dest 1 d1 guint8 -.source 1 s1 guint8 -.param 4 p1 -.param 4 p2 - -ldresnearb d1, s1, p1, p2 - - -.function video_scale_orc_resample_bilinear_u8 -.dest 1 d1 guint8 -.source 1 s1 guint8 -.param 4 p1 -.param 4 p2 - -ldreslinb d1, s1, p1, p2 - - -.function video_scale_orc_resample_nearest_u32 -.dest 4 d1 guint8 -.source 4 s1 guint8 -.param 4 p1 -.param 4 p2 - -ldresnearl d1, s1, p1, p2 - - -.function video_scale_orc_resample_bilinear_u32 -.dest 4 d1 guint8 -.source 4 s1 guint8 -.param 4 p1 -.param 4 p2 - -ldreslinl d1, s1, p1, p2 - - -.function video_scale_orc_resample_merge_bilinear_u32 -.dest 4 d1 guint8 -.dest 4 d2 guint8 -.source 4 s1 guint8 -.source 4 s2 guint8 -.temp 4 a -.temp 4 b -.temp 4 t -.temp 8 t1 -.temp 8 t2 -.param 4 p1 -.param 4 p2 -.param 4 p3 - -ldreslinl b, s2, p2, p3 -storel d2, b -loadl a, s1 -x4 convubw t1, a -x4 convubw t2, b -x4 subw t2, t2, t1 -x4 mullw t2, t2, p1 -x4 convhwb t, t2 -x4 addb d1, t, a - - - -.function video_scale_orc_merge_bicubic_u8 -.dest 1 d1 guint8 -.source 1 s1 guint8 -.source 1 s2 guint8 -.source 1 s3 guint8 -.source 1 s4 guint8 -.param 4 p1 -.param 4 p2 -.param 4 p3 -.param 4 p4 -.temp 2 t1 -.temp 2 t2 - -mulubw t1, s2, p2 -mulubw t2, s3, p3 -addw t1, t1, t2 -mulubw t2, s1, p1 -subw t1, t1, t2 -mulubw t2, s4, p4 -subw t1, t1, t2 -addw t1, t1, 32 -shrsw t1, t1, 6 -convsuswb d1, t1 - - diff --git a/gst/videoscale/vs_4tap.c b/gst/videoscale/vs_4tap.c deleted file mode 100644 index 344c34ca1d..0000000000 --- a/gst/videoscale/vs_4tap.c +++ /dev/null @@ -1,1634 +0,0 @@ -/* - * Image Scaling Functions (4 tap) - * Copyright (c) 2005 David A. Schleef - * Copyright (c) 2009 Sebastian Dröge - * 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. - */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "vs_image.h" -#include "vs_scanline.h" - -#include "vs_4tap.h" - -#include - -#define SHIFT 10 - -static int16_t vs_4tap_taps[256][4]; - - -static void vs_scanline_resample_4tap_Y (uint8_t * dest, uint8_t * src, - int n, int src_width, int *xacc, int increment); -static 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); - -static void vs_scanline_resample_4tap_RGBA (uint8_t * dest, uint8_t * src, - int n, int src_width, int *xacc, int increment); -static 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); - -static void vs_scanline_resample_4tap_RGB (uint8_t * dest, uint8_t * src, - int n, int src_width, int *xacc, int increment); -static 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); - -static void vs_scanline_resample_4tap_YUYV (uint8_t * dest, uint8_t * src, - int n, int src_width, int *xacc, int increment); -static 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); - -static void vs_scanline_resample_4tap_UYVY (uint8_t * dest, uint8_t * src, - int n, int src_width, int *xacc, int increment); -static 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); - -static void vs_scanline_resample_4tap_RGB565 (uint8_t * dest, uint8_t * src, - int n, int src_width, int *xacc, int increment); -static void vs_scanline_merge_4tap_RGB565 (uint8_t * dest, uint8_t * src1, - uint8_t * src2, uint8_t * src3, uint8_t * src4, int n, int acc); - -static void vs_scanline_resample_4tap_RGB555 (uint8_t * dest, uint8_t * src, - int n, int src_width, int *xacc, int increment); -static void vs_scanline_merge_4tap_RGB555 (uint8_t * dest, uint8_t * src1, - uint8_t * src2, uint8_t * src3, uint8_t * src4, int n, int acc); - -static void vs_scanline_resample_4tap_Y16 (uint8_t * dest, uint8_t * src, - int n, int src_width, int *xacc, int increment); -static 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); - -static void vs_scanline_resample_4tap_AYUV64 (uint16_t * dest, uint16_t * src, - int n, int src_width, int *xacc, int increment); -static 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); - -static void vs_scanline_merge_4tap_NV (uint8_t * dest, uint8_t * src1, - uint8_t * src2, uint8_t * src3, uint8_t * src4, int n, int acc); -static void vs_scanline_resample_4tap_NV (uint8_t * dest, uint8_t * src, int n, - int src_width, int *xacc, int increment); - -static double -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; - return sin (G_PI * x) / (G_PI * x) * (1 - 0.25 * x * x); -#endif -#if 1 - if (x == 0) - return 1; - return sin (G_PI * x) / (G_PI * x); -#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, - int n, int src_width, int *xacc, int increment) -{ - 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; - if (j - 1 >= 0 && j + 2 < src_width) { - y = vs_4tap_taps[x][0] * src[j - 1]; - 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); - 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; - 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++) { - 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); - } -} - - -static void -vs_scanline_resample_4tap_NV (uint8_t * dest, uint8_t * src, - int n, int src_width, int *xacc, int increment) -{ - int i; - int j; - int acc; - int x; - int u, v; - int stride = src_width * 2; - - acc = *xacc; - for (i = 0; i < n; i++) { - j = acc >> 16; - j *= 2; - x = (acc & 0xff00) >> 8; - if (j - 1 >= 0 && j + 2 < src_width) { - u = vs_4tap_taps[x][0] * src[j - 2]; - v = vs_4tap_taps[x][0] * src[j - 1]; - u += vs_4tap_taps[x][1] * src[j]; - v += vs_4tap_taps[x][1] * src[j + 1]; - u += vs_4tap_taps[x][2] * src[j + 2]; - v += vs_4tap_taps[x][2] * src[j + 3]; - u += vs_4tap_taps[x][3] * src[j + 4]; - v += vs_4tap_taps[x][3] * src[j + 5]; - } else { - u = vs_4tap_taps[x][0] * src[CLAMP (j - 2, 0, stride - 1)]; - v = vs_4tap_taps[x][0] * src[CLAMP (j - 1, 0, stride - 1)]; - u += vs_4tap_taps[x][1] * src[CLAMP (j, 0, stride - 1)]; - v += vs_4tap_taps[x][1] * src[CLAMP (j + 1, 0, stride - 1)]; - u += vs_4tap_taps[x][2] * src[CLAMP (j + 2, 0, stride - 1)]; - v += vs_4tap_taps[x][2] * src[CLAMP (j + 3, 0, stride - 1)]; - u += vs_4tap_taps[x][3] * src[CLAMP (j + 4, 0, stride - 1)]; - v += vs_4tap_taps[x][3] * src[CLAMP (j + 5, 0, stride - 1)]; - } - u += (1 << (SHIFT - 1)); - v += (1 << (SHIFT - 1)); - dest[i * 2] = CLAMP (u >> SHIFT, 0, 255); - dest[i * 2 + 1] = CLAMP (v >> SHIFT, 0, 255); - acc += increment; - } - *xacc = acc; -} - -static void -vs_scanline_merge_4tap_NV (uint8_t * dest, uint8_t * src1, uint8_t * src2, - uint8_t * src3, uint8_t * src4, int n, int acc) -{ - int i; - int val; - 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 * 2); i++) { - val = a * src1[i]; - val += b * src2[i]; - val += c * src3[i]; - val += d * src4[i]; - val += (1 << (SHIFT - 1)); - dest[i] = CLAMP (val >> SHIFT, 0, 255); - } -} - -void -vs_image_scale_4tap_NV12 (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; - /* The below loop is to initialize the 4 buffers present in tmpbuf - For scaling there are used in cyclic way, so they need to be - initialized before entering the main loop */ - for (i = 0; i < 4; i++) { - xacc = 0; - vs_scanline_resample_4tap_NV (tmpbuf + i * dest->stride, - src->pixels + CLAMP (i, 0, src->height - 1) * src->stride, dest->width, - src->width, &xacc, x_increment); - } - - 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_NV (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_NV (dest->pixels + i * dest->stride, - t0, t1, t2, t3, dest->width, yacc & 0xffff); - - yacc += y_increment; - } -} - - -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; - - 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_Y (tmpbuf + i * dest->stride, - src->pixels + CLAMP (i, 0, src->height - 1) * src->stride, dest->width, - src->width, &xacc, x_increment); - } - - 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_Y (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_Y (dest->pixels + i * dest->stride, - t0, t1, t2, t3, dest->width, yacc & 0xffff); - - yacc += y_increment; - } -} - -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[j - 1]; - 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, - src->pixels + CLAMP (i, 0, src->height - 1) * src->stride, dest->width, - src->width, &xacc, x_increment); - } - - 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; - } -} - -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[(j - 1) * 4 + off]; - 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), 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]; - } - 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, - src->pixels + CLAMP (i, 0, src->height) * src->stride, - dest->width, src->width, &xacc, x_increment); - } - - 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; - } -} - -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[(j - 1) * 3 + off]; - 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, - src->pixels + CLAMP (i, 0, src->height - 1) * src->stride, dest->width, - src->width, &xacc, x_increment); - } - - 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; - } -} - -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; - int quads = (n + 1) / 2; - 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); - - acc = *xacc; - for (i = 0; i < quads; i++) { - j = acc >> 16; - x = (acc & 0xffff) >> 8; - - if (j - 1 >= 0 && j + 2 < src_width) { - y = vs_4tap_taps[x][0] * src[j * 2 + 0 - 2]; - 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 { - 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)]; - } - y += (1 << (SHIFT - 1)); - dest[i * 4 + 0] = CLAMP (y >> SHIFT, 0, 255); - - j = acc >> 17; - x = (acc & 0x1ffff) >> 9; - - if (2 * j - 1 >= 0 && 2 * j + 4 < src_width) { - 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 { - 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)]; - } - y += (1 << (SHIFT - 1)); - dest[i * 4 + 1] = CLAMP (y >> SHIFT, 0, 255); - - if (2 * i + 1 < n) { - if (2 * j - 1 >= 0 && 2 * j + 4 < src_width) { - y = vs_4tap_taps[x][0] * src[MAX (j * 4 + 3 - 4, 3)]; - 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]; - } else { - 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)]; - } - y += (1 << (SHIFT - 1)); - dest[i * 4 + 3] = CLAMP (y >> SHIFT, 0, 255); - } - - acc += increment; - j = acc >> 16; - x = (acc & 0xffff) >> 8; - - if (2 * i + 1 < n) { - if (j - 1 >= 0 && j + 2 < src_width) { - y = vs_4tap_taps[x][0] * src[j * 2 + 0 - 2]; - 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 { - 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)]; - } - y += (1 << (SHIFT - 1)); - dest[i * 4 + 2] = CLAMP (y >> SHIFT, 0, 255); - acc += increment; - } - } - *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; - int quads = (n + 1) / 2; - - 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 < 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]; - y += (1 << (SHIFT - 1)); - 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); - } - } -} - -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, - src->pixels + CLAMP (i, 0, src->height - 1) * src->stride, dest->width, - src->width, &xacc, x_increment); - } - - 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, - 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_YUYV (dest->pixels + i * dest->stride, - t0, t1, t2, t3, dest->width, yacc & 0xffff); - - yacc += y_increment; - } -} - -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; - int quads = (n + 1) / 2; - 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); - - acc = *xacc; - for (i = 0; i < quads; i++) { - j = acc >> 16; - x = (acc & 0xffff) >> 8; - - 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 { - 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)]; - } - y += (1 << (SHIFT - 1)); - dest[i * 4 + 1] = CLAMP (y >> SHIFT, 0, 255); - - j = acc >> 17; - x = (acc & 0x1ffff) >> 9; - - if (2 * j - 2 >= 0 && 2 * j + 4 < src_width) { - 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 { - 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)]; - } - y += (1 << (SHIFT - 1)); - dest[i * 4 + 0] = CLAMP (y >> SHIFT, 0, 255); - - if (2 * i + 1 < n) { - if (2 * j - 1 >= 0 && 2 * j + 4 < src_width) { - y = vs_4tap_taps[x][0] * src[MAX (j * 4 + 2 - 4, 2)]; - 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]; - } else { - 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)]; - } - y += (1 << (SHIFT - 1)); - dest[i * 4 + 2] = CLAMP (y >> SHIFT, 0, 255); - } - - acc += increment; - j = acc >> 16; - x = (acc & 0xffff) >> 8; - - if (2 * i + 1 < n) { - if (j - 1 >= 0 && j + 2 < src_width) { - 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]; - } else { - 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)]; - } - y += (1 << (SHIFT - 1)); - dest[i * 4 + 3] = CLAMP (y >> SHIFT, 0, 255); - acc += increment; - } - } - *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; - int quads = (n + 1) / 2; - - 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 < 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]; - y += (1 << (SHIFT - 1)); - 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); - } - } -} - -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, - src->pixels + CLAMP (i, 0, src->height - 1) * src->stride, dest->width, - src->width, &xacc, x_increment); - } - - 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, - 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_UYVY (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 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[(j - 1)]); - 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[(j - 1)]); - 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[(j - 1)]); - 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_g, y_b); - 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_g, y_b); - } -} - -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, - src->pixels + CLAMP (i, 0, src->height - 1) * src->stride, dest->width, - src->width, &xacc, x_increment); - } - - 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)>>7 | ((x)&0x7c00)>>12) -#define RGB555_G(x) (((x)&0x03e0)>>2 | ((x)&0x03e0)>>7) -#define RGB555_B(x) (((x)&0x001f)<<3 | ((x)&0x001f)>>2) - -#define RGB555(r,g,b) \ - ((((r)<<7)&0x7c00) | (((g)<<2)&0x03e0) | (((b)>>3)&0x001f)) - -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[(j - 1)]); - 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[(j - 1)]); - 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[(j - 1)]); - 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_g, y_b); - 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_g, y_b); - } -} - -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, - src->pixels + CLAMP (i, 0, src->height - 1) * src->stride, dest->width, - src->width, &xacc, x_increment); - } - - 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; - } -} - -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[(j - 1) * 4 + off]; - 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; - /* destination stride in pixels for easier use with tmpbuf variable */ - int dest_pixstride = dest->stride / sizeof (guint16); - - 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 (tmpbuf + i * dest_pixstride, - (guint16 *) (src->pixels + CLAMP (i, 0, src->height - 1) * src->stride), - dest->width, src->width, &xacc, x_increment); - } - - 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 (tmpbuf + ((k + - 3) & 3) * dest_pixstride, - (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_pixstride; - t1 = tmpbuf + (CLAMP (j, 0, src->height - 1) & 3) * dest_pixstride; - t2 = tmpbuf + (CLAMP (j + 1, 0, src->height - 1) & 3) * dest_pixstride; - t3 = tmpbuf + (CLAMP (j + 2, 0, src->height - 1) & 3) * dest_pixstride; - vs_scanline_merge_4tap_AYUV64 ((guint16 *) (dest->pixels + - i * dest->stride), t0, t1, t2, t3, dest->width, yacc & 0xffff); - - yacc += y_increment; - } -} diff --git a/gst/videoscale/vs_4tap.h b/gst/videoscale/vs_4tap.h deleted file mode 100644 index 15ccadcdd4..0000000000 --- a/gst/videoscale/vs_4tap.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Image Scaling Functions (4 tap) - * Copyright (c) 2005 David A. Schleef - * 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. - */ - -#ifndef _VS_4TAP_H_ -#define _VS_4TAP_H_ - -#include "vs_image.h" - -G_GNUC_INTERNAL void vs_4tap_init (void); - -G_GNUC_INTERNAL void vs_image_scale_4tap_Y (const VSImage * dest, - const VSImage * src, - uint8_t * tmpbuf); - -G_GNUC_INTERNAL void vs_image_scale_4tap_NV12 (const VSImage * dest, - const VSImage * src, - uint8_t * tmpbuf); - -G_GNUC_INTERNAL void vs_image_scale_4tap_RGBA (const VSImage * dest, - const VSImage * src, - uint8_t * tmpbuf); - -G_GNUC_INTERNAL void vs_image_scale_4tap_RGB (const VSImage * dest, - const VSImage * src, - uint8_t * tmpbuf); - -G_GNUC_INTERNAL void vs_image_scale_4tap_YUYV (const VSImage * dest, - const VSImage * src, - uint8_t * tmpbuf); - -G_GNUC_INTERNAL void vs_image_scale_4tap_UYVY (const VSImage * dest, - const VSImage * src, - uint8_t * tmpbuf); - -G_GNUC_INTERNAL void vs_image_scale_4tap_RGB565 (const VSImage * dest, - const VSImage * src, - uint8_t * tmpbuf); - -G_GNUC_INTERNAL void vs_image_scale_4tap_RGB555 (const VSImage * dest, - const VSImage * src, - uint8_t * tmpbuf); - -G_GNUC_INTERNAL void vs_image_scale_4tap_Y16 (const VSImage * dest, - const VSImage * src, - uint8_t * tmpbuf); - -G_GNUC_INTERNAL void vs_image_scale_4tap_AYUV64 (const VSImage * dest, - const VSImage * src, - uint8_t * tmpbuf); - -#endif - diff --git a/gst/videoscale/vs_fill_borders.c b/gst/videoscale/vs_fill_borders.c deleted file mode 100644 index 37ae78bef5..0000000000 --- a/gst/videoscale/vs_fill_borders.c +++ /dev/null @@ -1,421 +0,0 @@ -/* - * Image Scaling Functions - * Copyright (c) 2010 Sebastian Dröge - * 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. - */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include - -#include "vs_fill_borders.h" -#include "gstvideoscaleorc.h" - -#if G_BYTE_ORDER == G_LITTLE_ENDIAN -#define READ_UINT32(ptr) GST_READ_UINT32_LE(ptr) -#define READ_UINT16(ptr) GST_READ_UINT16_LE(ptr) -#else -#define READ_UINT32(ptr) GST_READ_UINT32_BE(ptr) -#define READ_UINT16(ptr) GST_READ_UINT16_BE(ptr) -#endif - -void -vs_fill_borders_RGBA (const VSImage * dest, const uint8_t * val) -{ - int i; - int top = dest->border_top, bottom = dest->border_bottom; - int left = dest->border_left, right = dest->border_right; - int width = dest->width; - int height = dest->height; - int real_width = dest->real_width; - gsize stride = dest->stride; - int tmp, tmp2; - uint8_t *data; - uint32_t v = READ_UINT32 (val); - - data = dest->real_pixels; - for (i = 0; i < top; i++) { - video_scale_orc_splat_u32 ((uint32_t *) data, v, real_width); - data += stride; - } - - if (left || right) { - tmp = height; - tmp2 = (left + width) * 4; - for (i = 0; i < tmp; i++) { - video_scale_orc_splat_u32 ((uint32_t *) data, v, left); - video_scale_orc_splat_u32 ((uint32_t *) (data + tmp2), v, right); - data += stride; - } - } else { - data += stride * height; - } - - for (i = 0; i < bottom; i++) { - video_scale_orc_splat_u32 ((uint32_t *) data, v, real_width); - data += stride; - } -} - -static void -_memset_u24 (uint8_t * data, uint8_t val1, uint8_t val2, uint8_t val3, - unsigned int n) -{ - unsigned int i; - - for (i = 0; i < n; i++) { - data[0] = val1; - data[1] = val2; - data[2] = val3; - data += 3; - } -} - -void -vs_fill_borders_RGB (const VSImage * dest, const uint8_t * val) -{ - int i; - int top = dest->border_top, bottom = dest->border_bottom; - int left = dest->border_left, right = dest->border_right; - int width = dest->width; - int height = dest->height; - int real_width = dest->real_width; - gsize stride = dest->stride; - int tmp, tmp2; - uint8_t *data; - - data = dest->real_pixels; - for (i = 0; i < top; i++) { - _memset_u24 (data, val[0], val[1], val[2], real_width); - data += stride; - } - - if (left || right) { - tmp = height; - tmp2 = (left + width) * 3; - for (i = 0; i < tmp; i++) { - _memset_u24 (data, val[0], val[1], val[2], left); - _memset_u24 (data + tmp2, val[0], val[1], val[2], right); - data += stride; - } - } else { - data += stride * height; - } - - for (i = 0; i < bottom; i++) { - _memset_u24 (data, val[0], val[1], val[2], real_width); - data += stride; - } -} - -void -vs_fill_borders_YUYV (const VSImage * dest, const uint8_t * val) -{ - int i, j; - int top = dest->border_top, bottom = dest->border_bottom; - int left = dest->border_left, right = dest->border_right; - int width = dest->width; - int height = dest->height; - int real_width = dest->real_width; - gsize stride = dest->stride; - int tmp, tmp2; - uint8_t *data; - - data = dest->real_pixels; - for (i = 0; i < top; i++) { - for (j = 0; j < real_width; j++) { - data[2 * j] = val[0]; - data[2 * j + 1] = (j % 2 == 0) ? val[1] : val[3]; - } - data += stride; - } - - if (left || right) { - tmp = height; - tmp2 = (left + width) * 2; - for (i = 0; i < tmp; i++) { - for (j = 0; j < left; j++) { - data[2 * j] = val[0]; - data[2 * j + 1] = (j % 2 == 0) ? val[1] : val[3]; - } - for (j = 0; j < right; j++) { - data[tmp2 + 2 * j] = val[0]; - data[tmp2 + 2 * j + 1] = (j % 2 == 0) ? val[1] : val[3]; - } - data += stride; - } - } else { - data += stride * height; - } - - for (i = 0; i < bottom; i++) { - for (j = 0; j < real_width; j++) { - data[2 * j] = val[0]; - data[2 * j + 1] = (j % 2 == 0) ? val[1] : val[3]; - } - data += stride; - } -} - -void -vs_fill_borders_UYVY (const VSImage * dest, const uint8_t * val) -{ - int i, j; - int top = dest->border_top, bottom = dest->border_bottom; - int left = dest->border_left, right = dest->border_right; - int width = dest->width; - int height = dest->height; - int real_width = dest->real_width; - gsize stride = dest->stride; - int tmp, tmp2; - uint8_t *data; - - data = dest->real_pixels; - for (i = 0; i < top; i++) { - for (j = 0; j < real_width; j++) { - data[2 * j] = (j % 2 == 0) ? val[0] : val[2]; - data[2 * j + 1] = val[1]; - } - data += stride; - } - - if (left || right) { - tmp = height; - tmp2 = (left + width) * 2; - for (i = 0; i < tmp; i++) { - for (j = 0; j < left; j++) { - data[2 * j] = (j % 2 == 0) ? val[0] : val[2]; - data[2 * j + 1] = val[1]; - } - for (j = 0; j < right; j++) { - data[tmp2 + 2 * j] = (j % 2 == 0) ? val[0] : val[2]; - data[tmp2 + 2 * j + 1] = val[1]; - } - data += stride; - } - } else { - data += stride * height; - } - - for (i = 0; i < bottom; i++) { - for (j = 0; j < real_width; j++) { - data[2 * j] = (j % 2 == 0) ? val[0] : val[2]; - data[2 * j + 1] = val[1]; - } - data += stride; - } -} - -void -vs_fill_borders_Y (const VSImage * dest, const uint8_t * val) -{ - int i; - int top = dest->border_top, bottom = dest->border_bottom; - int left = dest->border_left, right = dest->border_right; - int width = dest->width; - int height = dest->height; - int real_width = dest->real_width; - gsize stride = dest->stride; - int tmp, tmp2; - uint8_t *data; - - data = dest->real_pixels; - for (i = 0; i < top; i++) { - memset (data, *val, real_width); - data += stride; - } - - if (left || right) { - tmp = height; - tmp2 = left + width; - for (i = 0; i < tmp; i++) { - memset (data, *val, left); - memset (data + tmp2, *val, right); - data += stride; - } - } else { - data += stride * height; - } - - for (i = 0; i < bottom; i++) { - memset (data, *val, real_width); - data += stride; - } -} - -void -vs_fill_borders_Y16 (const VSImage * dest, const uint16_t val) -{ - int i; - int top = dest->border_top, bottom = dest->border_bottom; - int left = dest->border_left, right = dest->border_right; - int width = dest->width; - int height = dest->height; - int real_width = dest->real_width; - gsize stride = dest->stride; - int tmp, tmp2; - uint8_t *data; - - data = dest->real_pixels; - for (i = 0; i < top; i++) { - video_scale_orc_splat_u16 ((uint16_t *) data, val, real_width); - data += stride; - } - - if (left || right) { - tmp = height; - tmp2 = (left + width) * 2; - for (i = 0; i < tmp; i++) { - video_scale_orc_splat_u16 ((uint16_t *) data, val, left); - video_scale_orc_splat_u16 ((uint16_t *) (data + tmp2), val, right); - data += stride; - } - } else { - data += stride * height; - } - - for (i = 0; i < bottom; i++) { - video_scale_orc_splat_u16 ((uint16_t *) data, val, real_width); - data += stride; - } -} - -void -vs_fill_borders_RGB565 (const VSImage * dest, const uint8_t * val) -{ - int i; - int top = dest->border_top, bottom = dest->border_bottom; - int left = dest->border_left, right = dest->border_right; - int width = dest->width; - int height = dest->height; - int real_width = dest->real_width; - gsize stride = dest->stride; - int tmp, tmp2; - uint8_t *data; - uint16_t v = READ_UINT16 (val); - - data = dest->real_pixels; - for (i = 0; i < top; i++) { - video_scale_orc_splat_u16 ((uint16_t *) data, v, real_width); - data += stride; - } - - if (left || right) { - tmp = height; - tmp2 = (left + width) * 2; - for (i = 0; i < tmp; i++) { - video_scale_orc_splat_u16 ((uint16_t *) data, v, left); - video_scale_orc_splat_u16 ((uint16_t *) (data + tmp2), v, right); - data += stride; - } - } else { - data += stride * height; - } - - for (i = 0; i < bottom; i++) { - video_scale_orc_splat_u16 ((uint16_t *) data, v, real_width); - data += stride; - } -} - -void -vs_fill_borders_RGB555 (const VSImage * dest, const uint8_t * val) -{ - int i; - int top = dest->border_top, bottom = dest->border_bottom; - int left = dest->border_left, right = dest->border_right; - int width = dest->width; - int height = dest->height; - int real_width = dest->real_width; - gsize stride = dest->stride; - int tmp, tmp2; - uint8_t *data; - uint16_t v = READ_UINT16 (val); - - data = dest->real_pixels; - for (i = 0; i < top; i++) { - video_scale_orc_splat_u16 ((uint16_t *) data, v, real_width); - data += stride; - } - - if (left || right) { - tmp = height; - tmp2 = (left + width) * 2; - for (i = 0; i < tmp; i++) { - video_scale_orc_splat_u16 ((uint16_t *) data, v, left); - video_scale_orc_splat_u16 ((uint16_t *) (data + tmp2), v, right); - data += stride; - } - } else { - data += stride * height; - } - - for (i = 0; i < bottom; i++) { - video_scale_orc_splat_u16 ((uint16_t *) data, v, real_width); - data += stride; - } -} - -void -vs_fill_borders_AYUV64 (const VSImage * dest, const uint8_t * val) -{ - int i; - int top = dest->border_top, bottom = dest->border_bottom; - int left = dest->border_left, right = dest->border_right; - int width = dest->width; - int height = dest->height; - int real_width = dest->real_width; - gsize stride = dest->stride; - int tmp, tmp2; - uint8_t *data; - uint64_t v; - - v = (((guint32) val[0]) << 8) | (((guint32) val[1]) << 24) | - (((guint64) val[2]) << 40) | (((guint64) val[3]) << 56); - - data = dest->real_pixels; - for (i = 0; i < top; i++) { - video_scale_orc_splat_u64 ((uint64_t *) data, v, real_width); - data += stride; - } - - if (left || right) { - tmp = height; - tmp2 = (left + width) * 8; - for (i = 0; i < tmp; i++) { - video_scale_orc_splat_u64 ((uint64_t *) data, v, left); - video_scale_orc_splat_u64 ((uint64_t *) (data + tmp2), v, right); - data += stride; - } - } else { - data += stride * height; - } - - for (i = 0; i < bottom; i++) { - video_scale_orc_splat_u64 ((uint64_t *) data, v, real_width); - data += stride; - } -} diff --git a/gst/videoscale/vs_fill_borders.h b/gst/videoscale/vs_fill_borders.h deleted file mode 100644 index 5cbb8bfffd..0000000000 --- a/gst/videoscale/vs_fill_borders.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Image Scaling Functions - * Copyright (c) 2010 Sebastian Dröge - * 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. - */ - -#ifndef __VS_FILL_BORDERS_H__ -#define __VS_FILL_BORDERS_H__ - -#include <_stdint.h> -#include "vs_image.h" - -G_GNUC_INTERNAL void vs_fill_borders_RGBA (const VSImage *dest, const uint8_t *val); -G_GNUC_INTERNAL void vs_fill_borders_RGB (const VSImage *dest, const uint8_t *val); -G_GNUC_INTERNAL void vs_fill_borders_YUYV (const VSImage *dest, const uint8_t *val); -G_GNUC_INTERNAL void vs_fill_borders_UYVY (const VSImage *dest, const uint8_t *val); -G_GNUC_INTERNAL void vs_fill_borders_Y (const VSImage *dest, const uint8_t *val); -G_GNUC_INTERNAL void vs_fill_borders_Y16 (const VSImage *dest, const uint16_t val); -G_GNUC_INTERNAL void vs_fill_borders_RGB565 (const VSImage *dest, const uint8_t *val); -G_GNUC_INTERNAL void vs_fill_borders_RGB555 (const VSImage *dest, const uint8_t *val); -G_GNUC_INTERNAL void vs_fill_borders_AYUV64 (const VSImage *dest, const uint8_t *val); - -#endif /* __VS_FILL_BORDERS_H__ */ diff --git a/gst/videoscale/vs_image.c b/gst/videoscale/vs_image.c deleted file mode 100644 index 00096fdeff..0000000000 --- a/gst/videoscale/vs_image.c +++ /dev/null @@ -1,1282 +0,0 @@ -/* - * Image Scaling Functions - * Copyright (c) 2005-2012 David A. Schleef - * 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. - */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include - -#include "vs_scanline.h" -#include "vs_image.h" - -#include "gstvideoscaleorc.h" -#include - -#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, - uint8_t * tmpbuf) -{ - 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 + 0x8000) >> 16; - - if (j == prev_j) { - memcpy (dest->pixels + i * dest->stride, - dest->pixels + (i - 1) * dest->stride, dest->width * 4); - } else { - video_scale_orc_resample_nearest_u32 (dest->pixels + i * dest->stride, - src->pixels + j * src->stride, 0, x_increment, dest->width); - } - - prev_j = j; - acc += y_increment; - } -} - -void -vs_image_scale_linear_RGBA (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; - - 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 = dest->width * 4; - -#define LINE(x) ((tmpbuf) + (dest_size)*((x)&1)) - - acc = 0; - video_scale_orc_resample_bilinear_u32 (LINE (0), src->pixels, - 0, x_increment, dest->width); - 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) { - video_scale_orc_resample_bilinear_u32 (LINE (j), - src->pixels + j * src->stride, 0, x_increment, dest->width); - y1++; - } - if (j >= y1) { - video_scale_orc_resample_bilinear_u32 (LINE (j + 1), - src->pixels + (j + 1) * src->stride, 0, x_increment, dest->width); - y1++; - } - video_scale_orc_merge_linear_u8 (dest->pixels + i * dest->stride, - LINE (j), LINE (j + 1), (x >> 8), dest->width * 4); - } - - acc += y_increment; - } -} - - -void -vs_image_scale_nearest_RGB (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 + 0x8000) >> 16; - - xacc = 0; - vs_scanline_resample_nearest_RGB (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_RGB (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 = dest->width * 3; - - tmp1 = tmpbuf; - tmp2 = tmpbuf + dest_size; - - acc = 0; - xacc = 0; - y2 = -1; - vs_scanline_resample_linear_RGB (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_RGB (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_RGB (tmp2, - src->pixels + (j + 1) * src->stride, src->width, dest->width, - &xacc, x_increment); - 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, - src->pixels + (j + 1) * src->stride, src->width, dest->width, - &xacc, x_increment); - 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, - src->width, dest->width, &xacc, x_increment); - y1 = j; - xacc = 0; - vs_scanline_resample_linear_RGB (tmp2, - src->pixels + (j + 1) * src->stride, src->width, dest->width, &xacc, - 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, - 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 + 0x8000) >> 16; - - xacc = 0; - vs_scanline_resample_nearest_YUYV (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_YUYV (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_YUYV (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_YUYV (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_YUYV (tmp2, - src->pixels + (j + 1) * src->stride, src->width, dest->width, - &xacc, x_increment); - y2 = j + 1; - } - vs_scanline_merge_linear_YUYV (dest->pixels + i * dest->stride, - tmp1, tmp2, dest->width, x); - } else if (j == y2) { - if (j + 1 != y1) { - xacc = 0; - vs_scanline_resample_linear_YUYV (tmp1, - src->pixels + (j + 1) * src->stride, src->width, dest->width, - &xacc, x_increment); - y1 = j + 1; - } - vs_scanline_merge_linear_YUYV (dest->pixels + i * dest->stride, - tmp2, tmp1, dest->width, x); - } else { - xacc = 0; - vs_scanline_resample_linear_YUYV (tmp1, src->pixels + j * src->stride, - src->width, dest->width, &xacc, x_increment); - y1 = j; - xacc = 0; - vs_scanline_resample_linear_YUYV (tmp2, - src->pixels + (j + 1) * src->stride, src->width, dest->width, - &xacc, x_increment); - y2 = (j + 1); - vs_scanline_merge_linear_YUYV (dest->pixels + i * dest->stride, - tmp1, tmp2, dest->width, x); - } - } - - acc += y_increment; - } -} - -/* UYVY */ - -void -vs_image_scale_nearest_UYVY (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 + 0x8000) >> 16; - - xacc = 0; - vs_scanline_resample_nearest_UYVY (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_UYVY (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_UYVY (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_UYVY (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_UYVY (tmp2, - src->pixels + (j + 1) * src->stride, src->width, dest->width, - &xacc, x_increment); - y2 = j + 1; - } - vs_scanline_merge_linear_UYVY (dest->pixels + i * dest->stride, - tmp1, tmp2, dest->width, x); - } else if (j == y2) { - if (j + 1 != y1) { - xacc = 0; - vs_scanline_resample_linear_UYVY (tmp1, - src->pixels + (j + 1) * src->stride, src->width, dest->width, - &xacc, x_increment); - y1 = j + 1; - } - vs_scanline_merge_linear_UYVY (dest->pixels + i * dest->stride, - tmp2, tmp1, dest->width, x); - } else { - xacc = 0; - vs_scanline_resample_linear_UYVY (tmp1, src->pixels + j * src->stride, - src->width, dest->width, &xacc, x_increment); - y1 = j; - xacc = 0; - vs_scanline_resample_linear_UYVY (tmp2, - src->pixels + (j + 1) * src->stride, src->width, dest->width, - &xacc, x_increment); - y2 = (j + 1); - vs_scanline_merge_linear_UYVY (dest->pixels + i * dest->stride, - tmp1, tmp2, dest->width, x); - } - } - - acc += y_increment; - } -} - -/* 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 + 0x8000) >> 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; - } -} - -/* greyscale */ - -void -vs_image_scale_nearest_Y (const VSImage * dest, const VSImage * src, - uint8_t * tmpbuf) -{ - int acc; - int y_increment; - int x_increment; - int i; - int 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; - for (i = 0; i < dest->height; i++) { - j = (acc + 0x8000) >> 16; - - video_scale_orc_resample_nearest_u8 (dest->pixels + i * dest->stride, - src->pixels + j * src->stride, 0, x_increment, dest->width); - acc += y_increment; - } -} - -void -vs_image_scale_linear_Y (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; - - 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 = dest->width; - - tmp1 = tmpbuf; - tmp2 = tmpbuf + dest_size; - - acc = 0; - y2 = -1; - video_scale_orc_resample_bilinear_u8 (tmp1, src->pixels, - 0, x_increment, dest->width); - 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 { - video_scale_orc_resample_bilinear_u8 (tmp1, - src->pixels + j * src->stride, 0, x_increment, dest->width); - y1 = j; - memcpy (dest->pixels + i * dest->stride, tmp1, dest_size); - } - } else { - if (j == y1) { - if (j + 1 != y2) { - video_scale_orc_resample_bilinear_u8 (tmp2, - src->pixels + (j + 1) * src->stride, 0, x_increment, dest->width); - y2 = j + 1; - } - if ((x >> 8) == 0) { - memcpy (dest->pixels + i * dest->stride, tmp1, dest->width); - } else { - video_scale_orc_merge_linear_u8 (dest->pixels + i * dest->stride, - tmp1, tmp2, (x >> 8), dest->width); - } - } else if (j == y2) { - if (j + 1 != y1) { - video_scale_orc_resample_bilinear_u8 (tmp1, - src->pixels + (j + 1) * src->stride, 0, x_increment, dest->width); - y1 = j + 1; - } - if ((x >> 8) == 0) { - memcpy (dest->pixels + i * dest->stride, tmp2, dest->width); - } else { - video_scale_orc_merge_linear_u8 (dest->pixels + i * dest->stride, - tmp2, tmp1, (x >> 8), dest->width); - } - } else { - video_scale_orc_resample_bilinear_u8 (tmp1, - src->pixels + j * src->stride, 0, x_increment, dest->width); - y1 = j; - video_scale_orc_resample_bilinear_u8 (tmp2, - src->pixels + (j + 1) * src->stride, 0, x_increment, dest->width); - y2 = (j + 1); - if ((x >> 8) == 0) { - memcpy (dest->pixels + i * dest->stride, tmp1, dest->width); - } else { - video_scale_orc_merge_linear_u8 (dest->pixels + i * dest->stride, - tmp1, tmp2, (x >> 8), dest->width); - } - } - } - - acc += y_increment; - } -} - -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 + 0x8000) >> 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 - 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 = 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; - } -} - -/* RGB565 */ - -void -vs_image_scale_nearest_RGB565 (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 + 0x8000) >> 16; - - xacc = 0; - vs_scanline_resample_nearest_RGB565 (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_RGB565 (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 = dest->width * 2; - - tmp1 = tmpbuf; - tmp2 = tmpbuf + dest_size; - - acc = 0; - xacc = 0; - y2 = -1; - vs_scanline_resample_linear_RGB565 (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_RGB565 (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_RGB565 (tmp2, - src->pixels + (j + 1) * src->stride, src->width, dest->width, - &xacc, x_increment); - 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, - src->pixels + (j + 1) * src->stride, src->width, dest->width, - &xacc, x_increment); - 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, - src->width, dest->width, &xacc, x_increment); - y1 = j; - xacc = 0; - vs_scanline_resample_linear_RGB565 (tmp2, - src->pixels + (j + 1) * src->stride, src->width, dest->width, &xacc, - 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, - 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 + 0x8000) >> 16; - - xacc = 0; - vs_scanline_resample_nearest_RGB555 (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_RGB555 (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 = dest->width * 2; - - tmp1 = tmpbuf; - tmp2 = tmpbuf + dest_size; - - acc = 0; - xacc = 0; - y2 = -1; - vs_scanline_resample_linear_RGB555 (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_RGB555 (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_RGB555 (tmp2, - src->pixels + (j + 1) * src->stride, src->width, dest->width, - &xacc, x_increment); - 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, - src->pixels + (j + 1) * src->stride, src->width, dest->width, - &xacc, x_increment); - 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, - src->width, dest->width, &xacc, x_increment); - y1 = j; - xacc = 0; - vs_scanline_resample_linear_RGB555 (tmp2, - src->pixels + (j + 1) * src->stride, src->width, dest->width, &xacc, - x_increment); - y2 = (j + 1); - vs_scanline_merge_linear_RGB555 (dest->pixels + i * dest->stride, - tmp1, tmp2, dest->width, x); - } - } - - acc += y_increment; - } -} - -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 + 0x8000) >> 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 - 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 = dest->width * 8; - -#undef LINE -#define LINE(x) ((guint16 *)((tmpbuf) + (dest_size)*((x)&1))) - - acc = 0; - 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); - 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); - video_scale_orc_merge_linear_u16 ((guint16 *) (dest->pixels + - i * dest->stride), LINE (j), LINE (j + 1), 65536 - x, x, - dest->width * 4); - y1++; - } else { - video_scale_orc_merge_linear_u16 ((guint16 *) (dest->pixels + - i * dest->stride), LINE (j), LINE (j + 1), 65536 - x, x, - dest->width * 4); - } - } - - acc += y_increment; - } -} diff --git a/gst/videoscale/vs_image.h b/gst/videoscale/vs_image.h deleted file mode 100644 index 87c6e71845..0000000000 --- a/gst/videoscale/vs_image.h +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Image Scaling Functions - * Copyright (c) 2005 David A. Schleef - * 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. - */ - -#ifndef __VS_IMAGE_H__ -#define __VS_IMAGE_H__ - -#include -#include <_stdint.h> - -typedef struct _VSImage VSImage; - -struct _VSImage { - uint8_t *real_pixels; - int real_width; - int real_height; - int border_left, border_right; - int border_top, border_bottom; - uint8_t *pixels; - int width; - int height; - gsize stride; -}; - -G_GNUC_INTERNAL void vs_image_scale_nearest_RGBA (const VSImage * dest, - const VSImage * src, - uint8_t * tmpbuf); -G_GNUC_INTERNAL void vs_image_scale_linear_RGBA (const VSImage * dest, - const VSImage * src, - uint8_t * tmpbuf); - - -G_GNUC_INTERNAL void vs_image_scale_lanczos_AYUV (const VSImage * dest, - const VSImage * src, - uint8_t * tmpbuf, - double sharpness, - gboolean dither, - int submethod, - double a, - double sharpen); - -G_GNUC_INTERNAL void vs_image_scale_lanczos_AYUV64 (const VSImage * dest, - const VSImage * src, - uint8_t * tmpbuf, - double sharpness, - gboolean dither, - int submethod, - double a, - double sharpen); - - -G_GNUC_INTERNAL void vs_image_scale_nearest_RGB (const VSImage * dest, - const VSImage * src, - uint8_t * tmpbuf); - -G_GNUC_INTERNAL void vs_image_scale_linear_RGB (const VSImage * dest, - const VSImage * src, - uint8_t * tmpbuf); - - -G_GNUC_INTERNAL void vs_image_scale_nearest_YUYV (const VSImage * dest, - const VSImage * src, - uint8_t * tmpbuf); - -G_GNUC_INTERNAL void vs_image_scale_linear_YUYV (const VSImage * dest, - const VSImage * src, - uint8_t * tmpbuf); - - -G_GNUC_INTERNAL void vs_image_scale_nearest_UYVY (const VSImage * dest, - const VSImage * src, - uint8_t * tmpbuf); - -G_GNUC_INTERNAL void vs_image_scale_linear_UYVY (const VSImage * dest, - const VSImage * src, - uint8_t * tmpbuf); - - -G_GNUC_INTERNAL void vs_image_scale_nearest_NV12 (const VSImage * dest, - const VSImage * src, - uint8_t * tmpbuf); - -G_GNUC_INTERNAL void vs_image_scale_linear_NV12 (const VSImage * dest, - const VSImage * src, - uint8_t * tmpbuf); - - -G_GNUC_INTERNAL void vs_image_scale_nearest_Y (const VSImage * dest, - const VSImage * src, - uint8_t * tmpbuf); - -G_GNUC_INTERNAL void vs_image_scale_linear_Y (const VSImage * dest, - const VSImage * src, - uint8_t * tmpbuf); - -G_GNUC_INTERNAL void vs_image_scale_lanczos_Y (const VSImage * dest, - const VSImage * src, - uint8_t * tmpbuf, - double sharpness, - gboolean dither, - int submethod, - double a, - double sharpen); - -G_GNUC_INTERNAL void vs_image_scale_lanczos_NV (const VSImage * dest, - const VSImage * src, - uint8_t * tmpbuf, - double sharpness, - gboolean dither, - int submethod, - double a, - double sharpen); - -G_GNUC_INTERNAL void vs_image_scale_nearest_RGB565 (const VSImage * dest, - const VSImage * src, - uint8_t * tmpbuf); - -G_GNUC_INTERNAL void vs_image_scale_linear_RGB565 (const VSImage * dest, - const VSImage * src, - uint8_t * tmpbuf); - - -G_GNUC_INTERNAL void vs_image_scale_nearest_RGB555 (const VSImage * dest, - const VSImage * src, - uint8_t * tmpbuf); - -G_GNUC_INTERNAL void vs_image_scale_linear_RGB555 (const VSImage * dest, - const VSImage * src, - uint8_t * tmpbuf); - - -G_GNUC_INTERNAL void vs_image_scale_nearest_Y16 (const VSImage * dest, - const VSImage * src, - uint8_t * tmpbuf); - -G_GNUC_INTERNAL void vs_image_scale_linear_Y16 (const VSImage * dest, - const VSImage * src, - uint8_t * tmpbuf); - - -G_GNUC_INTERNAL void vs_image_scale_nearest_AYUV16 (const VSImage * dest, - const VSImage * src, - uint8_t * tmpbuf); - -G_GNUC_INTERNAL void vs_image_scale_linear_AYUV16 (const VSImage * dest, - const VSImage * src, - uint8_t * tmpbuf); - - -G_GNUC_INTERNAL void vs_image_scale_nearest_AYUV64 (const VSImage * dest, - const VSImage * src, - uint8_t * tmpbuf8); - -G_GNUC_INTERNAL void vs_image_scale_linear_AYUV64 (const VSImage * dest, - const VSImage * src, - uint8_t * tmpbuf8); - -#endif - diff --git a/gst/videoscale/vs_lanczos.c b/gst/videoscale/vs_lanczos.c deleted file mode 100644 index 51da0a3933..0000000000 --- a/gst/videoscale/vs_lanczos.c +++ /dev/null @@ -1,2125 +0,0 @@ -/* - * Image Scaling Functions - * Copyright (c) 2011 David A. Schleef - * 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. - */ -/* - * - * Modified Lanczos scaling algorithm - * ================================== - * - * This algorithm was developed by the author. The primary goals of - * the algorithm are high-quality video downscaling for medium scale - * factors (in the range of 1.3x to 5.0x) using methods that can be - * converted to SIMD code. Concerns with existing algorithms were - * mainly related to either over-soft filtering (Lanczos) or aliasing - * (bilinear or any other method with inadequate sampling). - * - * The problems with bilinear scaling are apparent when downscaling - * more than a factor of 2. For example, when downscaling by a factor - * of 3, only two-thirds of the input pixels contribute to the output - * pixels. This is only considering scaling in one direction; after - * scaling both vertically and horizontally in a 2-D image, fewer than - * half of the input pixels contribute to the output, so it should not - * be surprising that the output is suboptimal. - * - * The problems with Lanczos scaling are more subtle. From a theoretical - * perspective, Lanczos is an optimal algorithm for resampling equally- - * spaced values. This theoretical perspective is based on analysis - * done in frequency space, thus, Lanczos works very well for audio - * resampling, since the ear hears primarily in frequency space. The - * human visual system is sensitive primarily in the spatial domain, - * therefore any resampling algorithm should take this into account. - * This difference is immediately clear in the size of resampling - * window or envelope that is chosen for resampling: for audio, an - * envelope of a=64 is typical, in image scaling, the envelope is - * usually a=2 or a=3. - * - * One result of the HVS being sensitive in the spatial domain (and - * also probably due to oversampling capabilities of the retina and - * visual cortex) is that it is less sensitive to the exact magnitude - * of high-frequency visual signals than to the appropriate amount of - * energy in the nearby frequency band. A Lanczos kernel with a=2 - * or a=3 strongly decreases the amount of energy in the high frequency - * bands. The energy in this area can be increased by increasing a, - * which brings in energy from different areas of the image (bad for - * reasons mentioned above), or by oversampling the input data. We - * have chosen two methods for doing the latter. Firstly, there is - * a sharpness parameter, which increases the cutoff frequency of the - * filter, aliasing higher frequency noise into the passband. And - * secondly, there is the sharpen parameter, which increases the - * contribution of high-frequency (but in-band) components. - * - * An alternate explanation of the usefulness of a sharpening filter - * is that many natural images have a roughly 1/f spectrum. In order - * for a downsampled image to look more "natural" when high frequencies - * are removed, the frequencies in the pass band near the cutoff - * frequency are amplified, causing the spectrum to be more roughly - * 1/f. I said "roughly", not "literally". - * - * This alternate explanation is useful for understanding the author's - * secondary motivation for developing this algorithm, namely, as a - * method of video compression. Several recent techniques (such as - * HTTP Live Streaming and SVC) use image scaling as a method to get - * increased compression out of nominally non-scalable codecs such as - * H.264. For optimal quality, it is thusly important to consider - * the scaler and encoder as a combined unit. Tuning of the sharpness - * and sharpen parameters was performed using the Toro encoder tuner, - * where scaled and encoded video was compared to unscaled and encoded - * video. This tuning suggested values that were very close to the - * values chosen by manual inspection of scaled images and video. - * - * The optimal values of sharpen and sharpness were slightly different - * depending whether the comparison was still images or video. Video - * comparisons were more sensitive to aliasing, since the aliasing - * artifacts tended to move or "crawl" around the video. The default - * values are for video; image scaling may prefer higher values. - * - * A number of related techniques were rejected for various reasons. - * An early technique of selecting the sharpness factor locally based - * on edge detection (in order to use a higher sharpness values without - * the corresponding aliasing on edges) worked very well for still - * images, but caused too much "crawling" on textures in video. Also, - * this method is slow, as it does not parallelize well. - * - * Non-separable techniques were rejected because the fastest would - * have been at least 4x slower. - * - * It is infrequently appreciated that image scaling should ideally be - * done in linear light space. Converting to linear light space has - * a similar effect to a sharpening filter. This approach was not - * taken because the added benefit is minor compared to the additional - * computational cost. Morever, the benefit is decreased by increasing - * the strength of the sharpening filter. - * - */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include - -#include "vs_scanline.h" -#include "vs_image.h" - -#include "gstvideoscaleorc.h" -#include -#include - -#define NEED_CLAMP(x,a,b) ((x) < (a) || (x) > (b)) - -#define ROUND_UP_2(x) (((x)+1)&~1) -#define ROUND_UP_4(x) (((x)+3)&~3) -#define ROUND_UP_8(x) (((x)+7)&~7) - -#define SRC_LINE(i) (scale->src->pixels + scale->src->stride * (i)) - -#define TMP_LINE_S16(i) ((gint16 *)scale->tmpdata + (i)*(scale->dest->width)) -#define TMP_LINE_S32(i) ((gint32 *)scale->tmpdata + (i)*(scale->dest->width)) -#define TMP_LINE_FLOAT(i) ((float *)scale->tmpdata + (i)*(scale->dest->width)) -#define TMP_LINE_DOUBLE(i) ((double *)scale->tmpdata + (i)*(scale->dest->width)) -#define TMP_LINE_S16_AYUV(i) ((gint16 *)scale->tmpdata + (i)*4*(scale->dest->width)) -#define TMP_LINE_S32_AYUV(i) ((gint32 *)scale->tmpdata + (i)*4*(scale->dest->width)) -#define TMP_LINE_FLOAT_AYUV(i) ((float *)scale->tmpdata + (i)*4*(scale->dest->width)) -#define TMP_LINE_DOUBLE_AYUV(i) ((double *)scale->tmpdata + (i)*4*(scale->dest->width)) -#define TMP_LINE_S32_NV(i) ((gint32 *)scale->tmpdata + (i)*2*(scale->dest->width)) -#define TMP_LINE_S16_NV(i) ((gint16 *)scale->tmpdata + (i)*2*(scale->dest->width)) -#define TMP_LINE_FLOAT_NV(i) ((float *)scale->tmpdata + (i)*2*(scale->dest->width)) -#define TMP_LINE_DOUBLE_NV(i) ((double *)scale->tmpdata + (i)*2*(scale->dest->width)) - -#define PTR_OFFSET(a,b) ((void *)((char *)(a) + (b))) - -typedef void (*HorizResampleFunc) (void *dest, const gint32 * offsets, - const void *taps, const void *src, int n_taps, int shift, int n); - -typedef struct _Scale1D Scale1D; -struct _Scale1D -{ - int n; - double offset; - double scale; - - double fx; - double ex; - int dx; - - int n_taps; - gint32 *offsets; - void *taps; -}; - -typedef struct _Scale Scale; -struct _Scale -{ - const VSImage *dest; - const VSImage *src; - - double sharpness; - gboolean dither; - - void *tmpdata; - - HorizResampleFunc horiz_resample_func; - - Scale1D x_scale1d; - Scale1D y_scale1d; -}; - -static void vs_image_scale_lanczos_Y_int16 (const VSImage * dest, - const VSImage * src, uint8_t * tmpbuf, double sharpness, gboolean dither, - double a, double sharpen); -static void vs_image_scale_lanczos_Y_int32 (const VSImage * dest, - const VSImage * src, uint8_t * tmpbuf, double sharpness, gboolean dither, - double a, double sharpen); -static void vs_image_scale_lanczos_Y_float (const VSImage * dest, - const VSImage * src, uint8_t * tmpbuf, double sharpness, gboolean dither, - double a, double sharpen); -static void vs_image_scale_lanczos_Y_double (const VSImage * dest, - const VSImage * src, uint8_t * tmpbuf, double sharpness, gboolean dither, - double a, double sharpen); -static void vs_image_scale_lanczos_AYUV_int16 (const VSImage * dest, - const VSImage * src, uint8_t * tmpbuf, double sharpness, gboolean dither, - double a, double sharpen); -static void vs_image_scale_lanczos_AYUV_int32 (const VSImage * dest, - const VSImage * src, uint8_t * tmpbuf, double sharpness, gboolean dither, - double a, double sharpen); -static void vs_image_scale_lanczos_AYUV_float (const VSImage * dest, - const VSImage * src, uint8_t * tmpbuf, double sharpness, gboolean dither, - double a, double sharpen); -static void vs_image_scale_lanczos_AYUV_double (const VSImage * dest, - const VSImage * src, uint8_t * tmpbuf, double sharpness, gboolean dither, - double a, double sharpen); -static void vs_image_scale_lanczos_AYUV64_double (const VSImage * dest, - const VSImage * src, uint8_t * tmpbuf, double sharpness, gboolean dither, - double a, double sharpen); - -static void vs_image_scale_lanczos_NV_int16 (const VSImage * dest, - const VSImage * src, uint8_t * tmpbuf, double sharpness, gboolean dither, - double a, double sharpen); -static void vs_image_scale_lanczos_NV_int32 (const VSImage * dest, - const VSImage * src, uint8_t * tmpbuf, double sharpness, gboolean dither, - double a, double sharpen); -static void vs_image_scale_lanczos_NV_float (const VSImage * dest, - const VSImage * src, uint8_t * tmpbuf, double sharpness, gboolean dither, - double a, double sharpen); -static void vs_image_scale_lanczos_NV_double (const VSImage * dest, - const VSImage * src, uint8_t * tmpbuf, double sharpness, gboolean dither, - double a, double sharpen); - -static double -sinc (double x) -{ - if (x == 0) - return 1; - return sin (G_PI * x) / (G_PI * x); -} - -static double -envelope (double x) -{ - if (x <= -1 || x >= 1) - return 0; - return sinc (x); -} - -static int -scale1d_get_n_taps (int src_size, int dest_size, double a, double sharpness) -{ - double scale; - double fx; - int dx; - - scale = src_size / (double) dest_size; - if (scale > 1.0) { - fx = (1.0 / scale) * sharpness; - } else { - fx = (1.0) * sharpness; - } - dx = ceil (a / fx); - - return 2 * dx; -} - -static void -scale1d_cleanup (Scale1D * scale) -{ - g_free (scale->taps); - g_free (scale->offsets); -} - -/* - * Calculates a set of taps for each destination element in double - * format. Each set of taps sums to 1.0. - * - */ -static void -scale1d_calculate_taps (Scale1D * scale, int src_size, int dest_size, - int n_taps, double a, double sharpness, double sharpen) -{ - int j; - double *tap_array; - gint32 *offsets; - double scale_offset; - double scale_increment; - int dx; - double fx; - double ex; - - scale->scale = src_size / (double) dest_size; - scale->offset = scale->scale / 2 - 0.5; - - if (scale->scale > 1.0) { - scale->fx = (1.0 / scale->scale) * sharpness; - } else { - scale->fx = (1.0) * sharpness; - } - scale->ex = scale->fx / a; - scale->dx = ceil (a / scale->fx); - - g_assert (n_taps >= 2 * scale->dx); - scale->n_taps = n_taps; - - scale->taps = g_malloc (sizeof (double) * scale->n_taps * dest_size); - scale->offsets = g_malloc (sizeof (gint32) * dest_size); - tap_array = scale->taps; - offsets = scale->offsets; - - scale_offset = scale->offset; - scale_increment = scale->scale; - dx = scale->dx; - fx = scale->fx; - ex = scale->ex; - - for (j = 0; j < dest_size; j++) { - double x; - int xi; - int l; - double weight; - double *taps; - - x = scale_offset + scale_increment * j; - x = CLAMP (x, 0, src_size); - xi = ceil (x) - dx; - - offsets[j] = xi; - weight = 0; - taps = tap_array + j * n_taps; - - for (l = 0; l < n_taps; l++) { - int xl = xi + l; - taps[l] = sinc ((x - xl) * fx) * envelope ((x - xl) * ex); - taps[l] -= sharpen * envelope ((x - xl) * ex); - weight += taps[l]; - } - g_assert (envelope ((x - (xi - 1)) * ex) == 0); - g_assert (envelope ((x - (xi + n_taps)) * ex) == 0); - for (l = 0; l < n_taps; l++) { - taps[l] /= weight; - } - - if (xi < 0) { - int shift = -xi; - - for (l = 0; l < shift; l++) { - taps[shift] += taps[l]; - } - for (l = 0; l < n_taps - shift; l++) { - taps[l] = taps[shift + l]; - } - for (; l < n_taps; l++) { - taps[l] = 0; - } - offsets[j] += shift; - } - - if (xi > src_size - n_taps) { - int shift = xi - (src_size - n_taps); - - for (l = 0; l < shift; l++) { - taps[n_taps - shift - 1] += taps[n_taps - shift + l]; - } - for (l = 0; l < n_taps - shift; l++) { - taps[n_taps - 1 - l] = taps[n_taps - 1 - shift - l]; - } - for (l = 0; l < shift; l++) { - taps[l] = 0; - } - offsets[j] -= shift; - } - } -} - -/* - * Calculates a set of taps for each destination element in float - * format. Each set of taps sums to 1.0. - */ -static void -scale1d_calculate_taps_float (Scale1D * scale, int src_size, int dest_size, - int n_taps, double a, double sharpness, double sharpen) -{ - double *taps_d; - float *taps_f; - int j; - - scale1d_calculate_taps (scale, src_size, dest_size, n_taps, a, sharpness, - sharpen); - - taps_d = scale->taps; - taps_f = g_malloc (sizeof (float) * scale->n_taps * dest_size); - - for (j = 0; j < dest_size * n_taps; j++) { - taps_f[j] = taps_d[j]; - } - - g_free (taps_d); - scale->taps = taps_f; -} - -/* - * Calculates a set of taps for each destination element in gint32 - * format. Each set of taps sums to (very nearly) (1<taps; - taps_i = g_malloc (sizeof (gint32) * scale->n_taps * dest_size); - - multiplier = (1 << shift); - - for (j = 0; j < dest_size; j++) { - for (i = 0; i < n_taps; i++) { - taps_i[j * n_taps + i] = - floor (0.5 + taps_d[j * n_taps + i] * multiplier); - } - } - - g_free (taps_d); - scale->taps = taps_i; -} - -/* - * Calculates a set of taps for each destination element in gint16 - * format. Each set of taps sums to (1<taps; - taps_i = g_malloc (sizeof (gint16) * scale->n_taps * dest_size); - - multiplier = (1 << shift); - - /* Various methods for converting floating point taps to integer. - * The dB values are the SSIM value between scaling an image via - * the floating point pathway vs. the integer pathway using the - * given code to generate the taps. Only one image was tested, - * scaling from 1920x1080 to 640x360. Several variations of the - * methods were also tested, with nothing appearing useful. */ -#if 0 - /* Standard round to integer. This causes bad DC errors. */ - /* 44.588 dB */ - for (j = 0; j < dest_size; j++) { - for (i = 0; i < n_taps; i++) { - taps_i[j * n_taps + i] = - floor (0.5 + taps_d[j * n_taps + i] * multiplier); - } - } -#endif -#if 0 - /* Dithering via error propogation. Works pretty well, but - * really we want to propogate errors across rows, which would - * mean having several sets of tap arrays. Possible, but more work, - * and it may not even be better. */ - /* 57.0961 dB */ - { - double err = 0; - for (j = 0; j < dest_size; j++) { - for (i = 0; i < n_taps; i++) { - err += taps_d[j * n_taps + i] * multiplier; - taps_i[j * n_taps + i] = floor (err); - err -= floor (err); - } - } - } -#endif -#if 1 - /* Round to integer, but with an adjustable bias that we use to - * eliminate the DC error. This search method is a bit crude, and - * could perhaps be improved somewhat. */ - /* 60.4851 dB */ - for (j = 0; j < dest_size; j++) { - int k; - for (k = 0; k < 100; k++) { - int sum = 0; - double offset; - - offset = k * 0.01; - for (i = 0; i < n_taps; i++) { - taps_i[j * n_taps + i] = - floor (offset + taps_d[j * n_taps + i] * multiplier); - sum += taps_i[j * n_taps + i]; - } - - if (sum >= (1 << shift)) - break; - } - } -#endif -#if 0 - /* Round to integer, but adjust the multiplier. The search method is - * wrong a lot, but was sufficient enough to calculate dB error. */ - /* 58.6517 dB */ - for (j = 0; j < dest_size; j++) { - int k; - int sum = 0; - for (k = 0; k < 200; k++) { - sum = 0; - - multiplier = (1 << shift) - 1.0 + k * 0.01; - for (i = 0; i < n_taps; i++) { - taps_i[j * n_taps + i] = - floor (0.5 + taps_d[j * n_taps + i] * multiplier); - sum += taps_i[j * n_taps + i]; - } - - if (sum >= (1 << shift)) - break; - } - if (sum != (1 << shift)) { - GST_ERROR ("%g %d", multiplier, sum); - } - } -#endif -#if 0 - /* Round to integer, but subtract the error from the largest tap */ - /* 58.3677 dB */ - for (j = 0; j < dest_size; j++) { - int err = -multiplier; - for (i = 0; i < n_taps; i++) { - taps_i[j * n_taps + i] = - floor (0.5 + taps_d[j * n_taps + i] * multiplier); - err += taps_i[j * n_taps + i]; - } - if (taps_i[j * n_taps + (n_taps / 2 - 1)] > - taps_i[j * n_taps + (n_taps / 2)]) { - taps_i[j * n_taps + (n_taps / 2 - 1)] -= err; - } else { - taps_i[j * n_taps + (n_taps / 2)] -= err; - } - } -#endif - - g_free (taps_d); - scale->taps = taps_i; -} - - -void -vs_image_scale_lanczos_Y (const VSImage * dest, const VSImage * src, - uint8_t * tmpbuf, double sharpness, gboolean dither, int submethod, - double a, double sharpen) -{ - switch (submethod) { - case 0: - default: - vs_image_scale_lanczos_Y_int16 (dest, src, tmpbuf, sharpness, dither, a, - sharpen); - break; - case 1: - vs_image_scale_lanczos_Y_int32 (dest, src, tmpbuf, sharpness, dither, a, - sharpen); - break; - case 2: - vs_image_scale_lanczos_Y_float (dest, src, tmpbuf, sharpness, dither, a, - sharpen); - break; - case 3: - vs_image_scale_lanczos_Y_double (dest, src, tmpbuf, sharpness, dither, a, - sharpen); - break; - } -} - -void -vs_image_scale_lanczos_AYUV (const VSImage * dest, const VSImage * src, - uint8_t * tmpbuf, double sharpness, gboolean dither, int submethod, - double a, double sharpen) -{ - switch (submethod) { - case 0: - default: - vs_image_scale_lanczos_AYUV_int16 (dest, src, tmpbuf, sharpness, dither, - a, sharpen); - break; - case 1: - vs_image_scale_lanczos_AYUV_int32 (dest, src, tmpbuf, sharpness, dither, - a, sharpen); - break; - case 2: - vs_image_scale_lanczos_AYUV_float (dest, src, tmpbuf, sharpness, dither, - a, sharpen); - break; - case 3: - vs_image_scale_lanczos_AYUV_double (dest, src, tmpbuf, sharpness, dither, - a, sharpen); - break; - } -} - -void -vs_image_scale_lanczos_AYUV64 (const VSImage * dest, const VSImage * src, - uint8_t * tmpbuf, double sharpness, gboolean dither, int submethod, - double a, double sharpen) -{ - vs_image_scale_lanczos_AYUV64_double (dest, src, tmpbuf, sharpness, dither, - a, sharpen); -} - - - -#define RESAMPLE_HORIZ_FLOAT(function, dest_type, tap_type, src_type, _n_taps) \ -static void \ -function (dest_type *dest, const gint32 *offsets, \ - const tap_type *taps, const src_type *src, int n_taps, int shift, int n) \ -{ \ - int i; \ - int k; \ - dest_type sum; \ - const src_type *srcline; \ - const tap_type *tapsline; \ - for (i = 0; i < n; i++) { \ - srcline = src + offsets[i]; \ - tapsline = taps + i * _n_taps; \ - sum = 0; \ - for (k = 0; k < _n_taps; k++) { \ - sum += srcline[k] * tapsline[k]; \ - } \ - dest[i] = sum; \ - } \ -} - -#define RESAMPLE_HORIZ(function, dest_type, tap_type, src_type, _n_taps, _shift) \ -static void \ -function (dest_type *dest, const gint32 *offsets, \ - const tap_type *taps, const src_type *src, int n_taps, int shift, int n) \ -{ \ - int i; \ - int k; \ - dest_type sum; \ - const src_type *srcline; \ - const tap_type *tapsline; \ - int offset; \ - if (_shift > 0) offset = (1<<_shift)>>1; \ - else offset = 0; \ - for (i = 0; i < n; i++) { \ - srcline = src + offsets[i]; \ - tapsline = taps + i * _n_taps; \ - sum = 0; \ - for (k = 0; k < _n_taps; k++) { \ - sum += srcline[k] * tapsline[k]; \ - } \ - dest[i] = (sum + offset) >> _shift; \ - } \ -} - -#define RESAMPLE_HORIZ_AYUV_FLOAT(function, dest_type, tap_type, src_type, _n_taps) \ -static void \ -function (dest_type *dest, const gint32 *offsets, \ - const tap_type *taps, const src_type *src, int n_taps, int shift, int n) \ -{ \ - int i; \ - int j; \ - int k; \ - int l; \ - dest_type sum1; \ - dest_type sum2; \ - dest_type sum3; \ - dest_type sum4; \ - const src_type *srcline; \ - const tap_type *tapsline; \ - for (i = 0; i < n; i++) { \ - srcline = src + 4*offsets[i]; \ - tapsline = taps + i * _n_taps; \ - sum1 = 0; \ - sum2 = 0; \ - sum3 = 0; \ - sum4 = 0; \ - for (k = 0; k < _n_taps; k++) { \ - l = k * 4; \ - sum1 += srcline[l] * tapsline[k]; \ - sum2 += srcline[l + 1] * tapsline[k]; \ - sum3 += srcline[l + 2] * tapsline[k]; \ - sum4 += srcline[l + 3] * tapsline[k]; \ - } \ - j = i * 4; \ - dest[j] = sum1; \ - dest[j + 1] = sum2; \ - dest[j + 2] = sum3; \ - dest[j + 3] = sum4; \ - } \ -} - -#define RESAMPLE_HORIZ_AYUV(function, dest_type, tap_type, src_type, _n_taps, _shift) \ -static void \ -function (dest_type *dest, const gint32 *offsets, \ - const tap_type *taps, const src_type *src, int n_taps, int shift, int n) \ -{ \ - int i; \ - int j; \ - int k; \ - int l; \ - dest_type sum1; \ - dest_type sum2; \ - dest_type sum3; \ - dest_type sum4; \ - const src_type *srcline; \ - const tap_type *tapsline; \ - int offset; \ - if (_shift > 0) offset = (1<<_shift)>>1; \ - else offset = 0; \ - for (i = 0; i < n; i++) { \ - srcline = src + 4*offsets[i]; \ - tapsline = taps + i * _n_taps; \ - sum1 = 0; \ - sum2 = 0; \ - sum3 = 0; \ - sum4 = 0; \ - for (k = 0; k < _n_taps; k++) { \ - l = k * 4; \ - sum1 += srcline[l] * tapsline[k]; \ - sum2 += srcline[l + 1] * tapsline[k]; \ - sum3 += srcline[l + 2] * tapsline[k]; \ - sum4 += srcline[l + 3] * tapsline[k]; \ - } \ - j = i * 4; \ - dest[j] = (sum1 + offset) >> _shift; \ - dest[j + 1] = (sum2 + offset) >> _shift; \ - dest[j + 2] = (sum3 + offset) >> _shift; \ - dest[j + 3] = (sum4 + offset) >> _shift; \ - } \ -} - -#define RESAMPLE_HORIZ_NV(function, dest_type, tap_type, src_type, _n_taps, _shift) \ -static void \ -function (dest_type *dest, const gint32 *offsets, \ - const tap_type *taps, const src_type *src, int n_taps, int shift, int n) \ -{ \ - int i; \ - int j; \ - int k; \ - int l; \ - dest_type sum1; \ - dest_type sum2; \ - const src_type *srcline; \ - const tap_type *tapsline; \ - int offset; \ - if (_shift > 0) offset = (1 << _shift) >> 1; \ - else offset = 0; \ - for (i = 0; i < n; i++) { \ - srcline = src + 2 * offsets[i]; \ - tapsline = taps + i * _n_taps; \ - sum1 = 0; \ - sum2 = 0; \ - for (k = 0; k < _n_taps; k++) { \ - l = k * 2; \ - sum1 += srcline[l] * tapsline[k]; \ - sum2 += srcline[l + 1] * tapsline[k]; \ - } \ - j = i * 2; \ - dest[j] = (sum1 + offset) >> _shift; \ - dest[j + 1] = (sum2 + offset) >> _shift; \ - } \ -} - -#define RESAMPLE_HORIZ_NV_FLOAT(function, dest_type, tap_type, src_type, _n_taps) \ -static void \ -function (dest_type *dest, const gint32 *offsets, \ - const tap_type *taps, const src_type *src, int n_taps, int shift, int n) \ -{ \ - int i; \ - int j; \ - int k; \ - int l; \ - dest_type sum1; \ - dest_type sum2; \ - const src_type *srcline; \ - const tap_type *tapsline; \ - for (i = 0; i < n; i++) { \ - srcline = src + 2 * offsets[i]; \ - tapsline = taps + i * _n_taps; \ - sum1 = 0; \ - sum2 = 0; \ - for (k = 0; k < _n_taps; k++) { \ - l = k * 2; \ - sum1 += srcline[l] * tapsline[k]; \ - sum2 += srcline[l + 1] * tapsline[k]; \ - } \ - j = i * 2; \ - dest[j] = sum1; \ - dest[j + 1] = sum2; \ - } \ -} - - -/* *INDENT-OFF* */ -RESAMPLE_HORIZ_FLOAT (resample_horiz_double_u8_generic, double, double, - guint8, n_taps) -RESAMPLE_HORIZ_FLOAT (resample_horiz_float_u8_generic, float, float, - guint8, n_taps) -RESAMPLE_HORIZ_AYUV_FLOAT (resample_horiz_double_ayuv_generic, double, double, - guint8, n_taps) -RESAMPLE_HORIZ_AYUV_FLOAT (resample_horiz_float_ayuv_generic, float, float, - guint8, n_taps) - -RESAMPLE_HORIZ_AYUV_FLOAT (resample_horiz_double_ayuv_generic_s16, double, double, - guint16, n_taps) -RESAMPLE_HORIZ_NV_FLOAT (resample_horiz_double_nv_generic, double, double, - guint8, n_taps) -RESAMPLE_HORIZ_NV_FLOAT (resample_horiz_float_nv_generic, float, float, - guint8, n_taps) - -RESAMPLE_HORIZ (resample_horiz_int32_int32_u8_generic, gint32, gint32, - guint8, n_taps, shift) -RESAMPLE_HORIZ (resample_horiz_int16_int16_u8_generic, gint16, gint16, - guint8, n_taps, shift) -RESAMPLE_HORIZ_AYUV (resample_horiz_int32_int32_ayuv_generic, gint32, gint32, - guint8, n_taps, shift) -RESAMPLE_HORIZ_AYUV (resample_horiz_int16_int16_ayuv_generic, gint16, gint16, - guint8, n_taps, shift) - -/* Candidates for orcification */ -RESAMPLE_HORIZ (resample_horiz_int32_int32_u8_taps16_shift0, gint32, gint32, - guint8, 16, 0) -RESAMPLE_HORIZ (resample_horiz_int32_int32_u8_taps12_shift0, gint32, gint32, - guint8, 12, 0) -RESAMPLE_HORIZ (resample_horiz_int32_int32_u8_taps8_shift0, gint32, gint32, - guint8, 8, 0) -RESAMPLE_HORIZ (resample_horiz_int32_int32_u8_taps4_shift0, gint32, gint32, - guint8, 4, 0) -RESAMPLE_HORIZ (resample_horiz_int16_int16_u8_taps16_shift0, gint16, gint16, - guint8, 16, 0) -RESAMPLE_HORIZ (resample_horiz_int16_int16_u8_taps12_shift0, gint16, gint16, - guint8, 12, 0) -RESAMPLE_HORIZ (resample_horiz_int16_int16_u8_taps8_shift0, gint16, gint16, - guint8, 8, 0) -RESAMPLE_HORIZ (resample_horiz_int16_int16_u8_taps4_shift0, gint16, gint16, - guint8, 4, 0) - -RESAMPLE_HORIZ_AYUV (resample_horiz_int32_int32_ayuv_taps16_shift0, gint32, gint32, - guint8, 16, 0) -RESAMPLE_HORIZ_AYUV (resample_horiz_int32_int32_ayuv_taps12_shift0, gint32, gint32, - guint8, 12, 0) -RESAMPLE_HORIZ_AYUV (resample_horiz_int32_int32_ayuv_taps8_shift0, gint32, gint32, - guint8, 8, 0) -RESAMPLE_HORIZ_AYUV (resample_horiz_int32_int32_ayuv_taps4_shift0, gint32, gint32, - guint8, 4, 0) -RESAMPLE_HORIZ_AYUV (resample_horiz_int16_int16_ayuv_taps16_shift0, gint16, gint16, - guint8, 16, 0) -RESAMPLE_HORIZ_AYUV (resample_horiz_int16_int16_ayuv_taps12_shift0, gint16, gint16, - guint8, 12, 0) -RESAMPLE_HORIZ_AYUV (resample_horiz_int16_int16_ayuv_taps8_shift0, gint16, gint16, - guint8, 8, 0) -RESAMPLE_HORIZ_AYUV (resample_horiz_int16_int16_ayuv_taps4_shift0, gint16, gint16, - guint8, 4, 0) - -RESAMPLE_HORIZ_NV (resample_horiz_int32_int32_nv_taps16_shift0, gint32, gint32, - guint8, 16, 0) -RESAMPLE_HORIZ_NV (resample_horiz_int32_int32_nv_taps12_shift0, gint32, gint32, - guint8, 12, 0) -RESAMPLE_HORIZ_NV (resample_horiz_int32_int32_nv_taps8_shift0, gint32, gint32, - guint8, 8, 0) -RESAMPLE_HORIZ_NV (resample_horiz_int32_int32_nv_taps4_shift0, gint32, gint32, - guint8, 4, 0) -RESAMPLE_HORIZ_NV (resample_horiz_int32_int32_nv_generic, gint32, gint32, - guint8, n_taps, shift) -RESAMPLE_HORIZ_NV (resample_horiz_int16_int16_nv_taps16_shift0, gint16, gint16, - guint8, 16, 0) -RESAMPLE_HORIZ_NV (resample_horiz_int16_int16_nv_taps12_shift0, gint16, gint16, - guint8, 12, 0) -RESAMPLE_HORIZ_NV (resample_horiz_int16_int16_nv_taps8_shift0, gint16, gint16, - guint8, 8, 0) -RESAMPLE_HORIZ_NV (resample_horiz_int16_int16_nv_taps4_shift0, gint16, gint16, - guint8, 4, 0) -RESAMPLE_HORIZ_NV (resample_horiz_int16_int16_nv_generic, gint32, gint32, - guint8, n_taps, shift) -/* *INDENT-ON* */ - -#define RESAMPLE_VERT(function, tap_type, src_type, _n_taps, _shift) \ -static void \ -function (guint8 *dest, \ - const tap_type *taps, const src_type *src, int stride, int n_taps, \ - int shift, int n) \ -{ \ - int i; \ - int l; \ - gint32 sum_y; \ - gint32 offset = (1<<_shift) >> 1; \ - for (i = 0; i < n; i++) { \ - sum_y = 0; \ - for (l = 0; l < n_taps; l++) { \ - const src_type *line = PTR_OFFSET(src, stride * l); \ - sum_y += line[i] * taps[l]; \ - } \ - dest[i] = CLAMP ((sum_y + offset) >> _shift, 0, 255); \ - } \ -} - -#define RESAMPLE_VERT_DITHER(function, tap_type, src_type, _n_taps, _shift) \ -static void \ -function (guint8 *dest, \ - const tap_type *taps, const src_type *src, int stride, int n_taps, \ - int shift, int n) \ -{ \ - int i; \ - int l; \ - gint32 sum_y; \ - gint32 err_y = 0; \ - gint32 mask = (1<<_shift) - 1; \ - for (i = 0; i < n; i++) { \ - sum_y = 0; \ - for (l = 0; l < n_taps; l++) { \ - const src_type *line = PTR_OFFSET(src, stride * l); \ - sum_y += line[i] * taps[l]; \ - } \ - err_y += sum_y; \ - dest[i] = CLAMP (err_y >> _shift, 0, 255); \ - err_y &= mask; \ - } \ -} - -/* *INDENT-OFF* */ -RESAMPLE_VERT (resample_vert_int32_generic, gint32, gint32, n_taps, shift) -RESAMPLE_VERT_DITHER (resample_vert_dither_int32_generic, gint32, gint32, - n_taps, shift) -RESAMPLE_VERT (resample_vert_int16_generic, gint16, gint16, n_taps, shift); -RESAMPLE_VERT_DITHER (resample_vert_dither_int16_generic, gint16, gint16, - n_taps, shift) -/* *INDENT-ON* */ - -#define RESAMPLE_VERT_FLOAT(function, dest_type, clamp, tap_type, src_type, _n_taps, _shift) \ -static void \ -function (dest_type *dest, \ - const tap_type *taps, const src_type *src, int stride, int n_taps, \ - int shift, int n) \ -{ \ - int i; \ - int l; \ - src_type sum_y; \ - for (i = 0; i < n; i++) { \ - sum_y = 0; \ - for (l = 0; l < n_taps; l++) { \ - const src_type *line = PTR_OFFSET(src, stride * l); \ - sum_y += line[i] * taps[l]; \ - } \ - dest[i] = CLAMP (floor(0.5 + sum_y), 0, clamp); \ - } \ -} - -#define RESAMPLE_VERT_FLOAT_DITHER(function, dest_type, clamp, tap_type, src_type, _n_taps, _shift) \ -static void \ -function (dest_type *dest, \ - const tap_type *taps, const src_type *src, int stride, int n_taps, \ - int shift, int n) \ -{ \ - int i; \ - int l; \ - src_type sum_y; \ - src_type err_y = 0; \ - for (i = 0; i < n; i++) { \ - sum_y = 0; \ - for (l = 0; l < n_taps; l++) { \ - const src_type *line = PTR_OFFSET(src, stride * l); \ - sum_y += line[i] * taps[l]; \ - } \ - err_y += sum_y; \ - dest[i] = CLAMP (floor (err_y), 0, clamp); \ - err_y -= floor (err_y); \ - } \ -} -/* *INDENT-OFF* */ - -RESAMPLE_VERT_FLOAT (resample_vert_double_generic, guint8, 255, double, double, n_taps, - shift) -RESAMPLE_VERT_FLOAT_DITHER (resample_vert_dither_double_generic, guint8, 255, double, double, - n_taps, shift) - -RESAMPLE_VERT_FLOAT (resample_vert_double_generic_u16, guint16, 65535, double, double, n_taps, - shift) -RESAMPLE_VERT_FLOAT_DITHER (resample_vert_dither_double_generic_u16, guint16, 65535, double, double, - n_taps, shift) - -RESAMPLE_VERT_FLOAT (resample_vert_float_generic, guint8, 255, float, float, n_taps, shift) -RESAMPLE_VERT_FLOAT_DITHER (resample_vert_dither_float_generic, guint8, 255, float, float, - n_taps, shift) -/* *INDENT-ON* */ - -#define S16_SHIFT1 7 -#define S16_SHIFT2 7 -#define S16_MIDSHIFT 0 -#define S16_POSTSHIFT (S16_SHIFT1+S16_SHIFT2-S16_MIDSHIFT) -static void -vs_scale_lanczos_Y_int16 (Scale * scale) -{ - int j; - int yi; - int tmp_yi; - - tmp_yi = 0; - - for (j = 0; j < scale->dest->height; j++) { - guint8 *destline; - gint16 *taps; - - destline = scale->dest->pixels + scale->dest->stride * j; - - yi = scale->y_scale1d.offsets[j]; - - while (tmp_yi < yi + scale->y_scale1d.n_taps) { - scale->horiz_resample_func (TMP_LINE_S16 (tmp_yi), - scale->x_scale1d.offsets, scale->x_scale1d.taps, SRC_LINE (tmp_yi), - scale->x_scale1d.n_taps, S16_MIDSHIFT, scale->dest->width); - tmp_yi++; - } - - taps = (gint16 *) scale->y_scale1d.taps + j * scale->y_scale1d.n_taps; - if (scale->dither) { - resample_vert_dither_int16_generic (destline, - taps, TMP_LINE_S16 (scale->y_scale1d.offsets[j]), - sizeof (gint16) * scale->dest->width, scale->y_scale1d.n_taps, - S16_POSTSHIFT, scale->dest->width); - } else { - resample_vert_int16_generic (destline, - taps, TMP_LINE_S16 (scale->y_scale1d.offsets[j]), - sizeof (gint16) * scale->dest->width, scale->y_scale1d.n_taps, - S16_POSTSHIFT, scale->dest->width); - } - } -} - -void -vs_image_scale_lanczos_Y_int16 (const VSImage * dest, const VSImage * src, - uint8_t * tmpbuf, double sharpness, gboolean dither, double a, - double sharpen) -{ - Scale s = { 0 }; - Scale *scale = &s; - int n_taps; - - scale->dest = dest; - scale->src = src; - - n_taps = scale1d_get_n_taps (src->width, dest->width, a, sharpness); - n_taps = ROUND_UP_4 (n_taps); - scale1d_calculate_taps_int16 (&scale->x_scale1d, - src->width, dest->width, n_taps, a, sharpness, sharpen, S16_SHIFT1); - - n_taps = scale1d_get_n_taps (src->height, dest->height, a, sharpness); - scale1d_calculate_taps_int16 (&scale->y_scale1d, - src->height, dest->height, n_taps, a, sharpness, sharpen, S16_SHIFT2); - - scale->dither = dither; - - switch (scale->x_scale1d.n_taps) { - case 4: - scale->horiz_resample_func = - (HorizResampleFunc) resample_horiz_int16_int16_u8_taps4_shift0; - break; - case 8: - scale->horiz_resample_func = - (HorizResampleFunc) resample_horiz_int16_int16_u8_taps8_shift0; - break; - case 12: - scale->horiz_resample_func = - (HorizResampleFunc) resample_horiz_int16_int16_u8_taps12_shift0; - break; - case 16: - scale->horiz_resample_func = - (HorizResampleFunc) resample_horiz_int16_int16_u8_taps16_shift0; - break; - default: - scale->horiz_resample_func = - (HorizResampleFunc) resample_horiz_int16_int16_u8_generic; - break; - } - - scale->tmpdata = - g_malloc (sizeof (gint16) * scale->dest->width * scale->src->height); - - vs_scale_lanczos_Y_int16 (scale); - - scale1d_cleanup (&scale->x_scale1d); - scale1d_cleanup (&scale->y_scale1d); - g_free (scale->tmpdata); -} - - -#define S32_SHIFT1 11 -#define S32_SHIFT2 11 -#define S32_MIDSHIFT 0 -#define S32_POSTSHIFT (S32_SHIFT1+S32_SHIFT2-S32_MIDSHIFT) - -static void -vs_scale_lanczos_Y_int32 (Scale * scale) -{ - int j; - int yi; - int tmp_yi; - - tmp_yi = 0; - - for (j = 0; j < scale->dest->height; j++) { - guint8 *destline; - gint32 *taps; - - destline = scale->dest->pixels + scale->dest->stride * j; - - yi = scale->y_scale1d.offsets[j]; - - while (tmp_yi < yi + scale->y_scale1d.n_taps) { - scale->horiz_resample_func (TMP_LINE_S32 (tmp_yi), - scale->x_scale1d.offsets, scale->x_scale1d.taps, SRC_LINE (tmp_yi), - scale->x_scale1d.n_taps, S32_MIDSHIFT, scale->dest->width); - tmp_yi++; - } - - taps = (gint32 *) scale->y_scale1d.taps + j * scale->y_scale1d.n_taps; - if (scale->dither) { - resample_vert_dither_int32_generic (destline, - taps, TMP_LINE_S32 (scale->y_scale1d.offsets[j]), - sizeof (gint32) * scale->dest->width, - scale->y_scale1d.n_taps, S32_POSTSHIFT, scale->dest->width); - } else { - resample_vert_int32_generic (destline, - taps, TMP_LINE_S32 (scale->y_scale1d.offsets[j]), - sizeof (gint32) * scale->dest->width, - scale->y_scale1d.n_taps, S32_POSTSHIFT, scale->dest->width); - } - } -} - -void -vs_image_scale_lanczos_Y_int32 (const VSImage * dest, const VSImage * src, - uint8_t * tmpbuf, double sharpness, gboolean dither, double a, - double sharpen) -{ - Scale s = { 0 }; - Scale *scale = &s; - int n_taps; - - scale->dest = dest; - scale->src = src; - - n_taps = scale1d_get_n_taps (src->width, dest->width, a, sharpness); - n_taps = ROUND_UP_4 (n_taps); - scale1d_calculate_taps_int32 (&scale->x_scale1d, - src->width, dest->width, n_taps, a, sharpness, sharpen, S32_SHIFT1); - - n_taps = scale1d_get_n_taps (src->height, dest->height, a, sharpness); - scale1d_calculate_taps_int32 (&scale->y_scale1d, - src->height, dest->height, n_taps, a, sharpness, sharpen, S32_SHIFT2); - - scale->dither = dither; - - switch (scale->x_scale1d.n_taps) { - case 4: - scale->horiz_resample_func = - (HorizResampleFunc) resample_horiz_int32_int32_u8_taps4_shift0; - break; - case 8: - scale->horiz_resample_func = - (HorizResampleFunc) resample_horiz_int32_int32_u8_taps8_shift0; - break; - case 12: - scale->horiz_resample_func = - (HorizResampleFunc) resample_horiz_int32_int32_u8_taps12_shift0; - break; - case 16: - scale->horiz_resample_func = - (HorizResampleFunc) resample_horiz_int32_int32_u8_taps16_shift0; - break; - default: - scale->horiz_resample_func = - (HorizResampleFunc) resample_horiz_int32_int32_u8_generic; - break; - } - - scale->tmpdata = - g_malloc (sizeof (int32_t) * scale->dest->width * scale->src->height); - - vs_scale_lanczos_Y_int32 (scale); - - scale1d_cleanup (&scale->x_scale1d); - scale1d_cleanup (&scale->y_scale1d); - g_free (scale->tmpdata); -} - -static void -vs_scale_lanczos_Y_double (Scale * scale) -{ - int j; - int yi; - int tmp_yi; - - tmp_yi = 0; - - for (j = 0; j < scale->dest->height; j++) { - guint8 *destline; - double *taps; - - destline = scale->dest->pixels + scale->dest->stride * j; - - yi = scale->y_scale1d.offsets[j]; - - while (tmp_yi < yi + scale->y_scale1d.n_taps) { - scale->horiz_resample_func (TMP_LINE_DOUBLE (tmp_yi), - scale->x_scale1d.offsets, scale->x_scale1d.taps, SRC_LINE (tmp_yi), - scale->x_scale1d.n_taps, 0, scale->dest->width); - tmp_yi++; - } - - taps = (double *) scale->y_scale1d.taps + j * scale->y_scale1d.n_taps; - if (scale->dither) { - resample_vert_dither_double_generic (destline, - taps, TMP_LINE_DOUBLE (scale->y_scale1d.offsets[j]), - sizeof (double) * scale->dest->width, - scale->y_scale1d.n_taps, 0, scale->dest->width); - } else { - resample_vert_double_generic (destline, - taps, TMP_LINE_DOUBLE (scale->y_scale1d.offsets[j]), - sizeof (double) * scale->dest->width, - scale->y_scale1d.n_taps, 0, scale->dest->width); - } - } -} - -void -vs_image_scale_lanczos_Y_double (const VSImage * dest, const VSImage * src, - uint8_t * tmpbuf, double sharpness, gboolean dither, double a, - double sharpen) -{ - Scale s = { 0 }; - Scale *scale = &s; - int n_taps; - - scale->dest = dest; - scale->src = src; - - n_taps = scale1d_get_n_taps (src->width, dest->width, a, sharpness); - scale1d_calculate_taps (&scale->x_scale1d, - src->width, dest->width, n_taps, a, sharpness, sharpen); - - n_taps = scale1d_get_n_taps (src->height, dest->height, a, sharpness); - scale1d_calculate_taps (&scale->y_scale1d, - src->height, dest->height, n_taps, a, sharpness, sharpen); - - scale->dither = dither; - - scale->horiz_resample_func = - (HorizResampleFunc) resample_horiz_double_u8_generic; - - scale->tmpdata = - g_malloc (sizeof (double) * scale->dest->width * scale->src->height); - - vs_scale_lanczos_Y_double (scale); - - scale1d_cleanup (&scale->x_scale1d); - scale1d_cleanup (&scale->y_scale1d); - g_free (scale->tmpdata); -} - -static void -vs_scale_lanczos_Y_float (Scale * scale) -{ - int j; - int yi; - int tmp_yi; - - tmp_yi = 0; - - for (j = 0; j < scale->dest->height; j++) { - guint8 *destline; - float *taps; - - destline = scale->dest->pixels + scale->dest->stride * j; - - yi = scale->y_scale1d.offsets[j]; - - while (tmp_yi < yi + scale->y_scale1d.n_taps) { - scale->horiz_resample_func (TMP_LINE_FLOAT (tmp_yi), - scale->x_scale1d.offsets, scale->x_scale1d.taps, SRC_LINE (tmp_yi), - scale->x_scale1d.n_taps, 0, scale->dest->width); - tmp_yi++; - } - - taps = (float *) scale->y_scale1d.taps + j * scale->y_scale1d.n_taps; - if (scale->dither) { - resample_vert_dither_float_generic (destline, - taps, TMP_LINE_FLOAT (scale->y_scale1d.offsets[j]), - sizeof (float) * scale->dest->width, - scale->y_scale1d.n_taps, 0, scale->dest->width); - } else { - resample_vert_float_generic (destline, - taps, TMP_LINE_FLOAT (scale->y_scale1d.offsets[j]), - sizeof (float) * scale->dest->width, - scale->y_scale1d.n_taps, 0, scale->dest->width); - } - } -} - -void -vs_image_scale_lanczos_Y_float (const VSImage * dest, const VSImage * src, - uint8_t * tmpbuf, double sharpness, gboolean dither, double a, - double sharpen) -{ - Scale s = { 0 }; - Scale *scale = &s; - int n_taps; - - scale->dest = dest; - scale->src = src; - - n_taps = scale1d_get_n_taps (src->width, dest->width, a, sharpness); - scale1d_calculate_taps_float (&scale->x_scale1d, - src->width, dest->width, n_taps, a, sharpness, sharpen); - - n_taps = scale1d_get_n_taps (src->height, dest->height, a, sharpness); - scale1d_calculate_taps_float (&scale->y_scale1d, - src->height, dest->height, n_taps, a, sharpness, sharpen); - - scale->dither = dither; - - scale->horiz_resample_func = - (HorizResampleFunc) resample_horiz_float_u8_generic; - - scale->tmpdata = - g_malloc (sizeof (float) * scale->dest->width * scale->src->height); - - vs_scale_lanczos_Y_float (scale); - - scale1d_cleanup (&scale->x_scale1d); - scale1d_cleanup (&scale->y_scale1d); - g_free (scale->tmpdata); -} - -static void -vs_scale_lanczos_AYUV_int16 (Scale * scale) -{ - int j; - int yi; - int tmp_yi; - - tmp_yi = 0; - - for (j = 0; j < scale->dest->height; j++) { - guint8 *destline; - gint16 *taps; - - destline = scale->dest->pixels + scale->dest->stride * j; - - yi = scale->y_scale1d.offsets[j]; - - while (tmp_yi < yi + scale->y_scale1d.n_taps) { - scale->horiz_resample_func (TMP_LINE_S16_AYUV (tmp_yi), - scale->x_scale1d.offsets, scale->x_scale1d.taps, SRC_LINE (tmp_yi), - scale->x_scale1d.n_taps, S16_MIDSHIFT, scale->dest->width); - tmp_yi++; - } - - taps = (gint16 *) scale->y_scale1d.taps + j * scale->y_scale1d.n_taps; - if (scale->dither) { - resample_vert_dither_int16_generic (destline, - taps, TMP_LINE_S16_AYUV (scale->y_scale1d.offsets[j]), - sizeof (gint16) * 4 * scale->dest->width, - scale->y_scale1d.n_taps, S16_POSTSHIFT, scale->dest->width * 4); - } else { - resample_vert_int16_generic (destline, - taps, TMP_LINE_S16_AYUV (scale->y_scale1d.offsets[j]), - sizeof (gint16) * 4 * scale->dest->width, - scale->y_scale1d.n_taps, S16_POSTSHIFT, scale->dest->width * 4); - } - } -} - -void -vs_image_scale_lanczos_AYUV_int16 (const VSImage * dest, const VSImage * src, - uint8_t * tmpbuf, double sharpness, gboolean dither, double a, - double sharpen) -{ - Scale s = { 0 }; - Scale *scale = &s; - int n_taps; - - scale->dest = dest; - scale->src = src; - - n_taps = scale1d_get_n_taps (src->width, dest->width, a, sharpness); - n_taps = ROUND_UP_4 (n_taps); - scale1d_calculate_taps_int16 (&scale->x_scale1d, - src->width, dest->width, n_taps, a, sharpness, sharpen, S16_SHIFT1); - - n_taps = scale1d_get_n_taps (src->height, dest->height, a, sharpness); - scale1d_calculate_taps_int16 (&scale->y_scale1d, - src->height, dest->height, n_taps, a, sharpness, sharpen, S16_SHIFT2); - - scale->dither = dither; - - switch (scale->x_scale1d.n_taps) { - case 4: - scale->horiz_resample_func = - (HorizResampleFunc) resample_horiz_int16_int16_ayuv_taps4_shift0; - break; - case 8: - scale->horiz_resample_func = - (HorizResampleFunc) resample_horiz_int16_int16_ayuv_taps8_shift0; - break; - case 12: - scale->horiz_resample_func = - (HorizResampleFunc) resample_horiz_int16_int16_ayuv_taps12_shift0; - break; - case 16: - scale->horiz_resample_func = - (HorizResampleFunc) resample_horiz_int16_int16_ayuv_taps16_shift0; - break; - default: - scale->horiz_resample_func = - (HorizResampleFunc) resample_horiz_int16_int16_ayuv_generic; - break; - } - - scale->tmpdata = - g_malloc (sizeof (gint16) * scale->dest->width * scale->src->height * 4); - - vs_scale_lanczos_AYUV_int16 (scale); - - scale1d_cleanup (&scale->x_scale1d); - scale1d_cleanup (&scale->y_scale1d); - g_free (scale->tmpdata); -} - -static void -vs_scale_lanczos_AYUV_int32 (Scale * scale) -{ - int j; - int yi; - int tmp_yi; - - tmp_yi = 0; - - for (j = 0; j < scale->dest->height; j++) { - guint8 *destline; - gint32 *taps; - - destline = scale->dest->pixels + scale->dest->stride * j; - - yi = scale->y_scale1d.offsets[j]; - - while (tmp_yi < yi + scale->y_scale1d.n_taps) { - scale->horiz_resample_func (TMP_LINE_S32_AYUV (tmp_yi), - scale->x_scale1d.offsets, scale->x_scale1d.taps, SRC_LINE (tmp_yi), - scale->x_scale1d.n_taps, S32_MIDSHIFT, scale->dest->width); - tmp_yi++; - } - - taps = (gint32 *) scale->y_scale1d.taps + j * scale->y_scale1d.n_taps; - if (scale->dither) { - resample_vert_dither_int32_generic (destline, - taps, TMP_LINE_S32_AYUV (scale->y_scale1d.offsets[j]), - sizeof (gint32) * 4 * scale->dest->width, scale->y_scale1d.n_taps, - S32_POSTSHIFT, scale->dest->width * 4); - } else { - resample_vert_int32_generic (destline, - taps, TMP_LINE_S32_AYUV (scale->y_scale1d.offsets[j]), - sizeof (gint32) * 4 * scale->dest->width, scale->y_scale1d.n_taps, - S32_POSTSHIFT, scale->dest->width * 4); - } - } -} - -void -vs_image_scale_lanczos_AYUV_int32 (const VSImage * dest, const VSImage * src, - uint8_t * tmpbuf, double sharpness, gboolean dither, double a, - double sharpen) -{ - Scale s = { 0 }; - Scale *scale = &s; - int n_taps; - - scale->dest = dest; - scale->src = src; - - n_taps = scale1d_get_n_taps (src->width, dest->width, a, sharpness); - n_taps = ROUND_UP_4 (n_taps); - scale1d_calculate_taps_int32 (&scale->x_scale1d, - src->width, dest->width, n_taps, a, sharpness, sharpen, S32_SHIFT1); - - n_taps = scale1d_get_n_taps (src->height, dest->height, a, sharpness); - scale1d_calculate_taps_int32 (&scale->y_scale1d, - src->height, dest->height, n_taps, a, sharpness, sharpen, S32_SHIFT2); - - scale->dither = dither; - - switch (scale->x_scale1d.n_taps) { - case 4: - scale->horiz_resample_func = - (HorizResampleFunc) resample_horiz_int32_int32_ayuv_taps4_shift0; - break; - case 8: - scale->horiz_resample_func = - (HorizResampleFunc) resample_horiz_int32_int32_ayuv_taps8_shift0; - break; - case 12: - scale->horiz_resample_func = - (HorizResampleFunc) resample_horiz_int32_int32_ayuv_taps12_shift0; - break; - case 16: - scale->horiz_resample_func = - (HorizResampleFunc) resample_horiz_int32_int32_ayuv_taps16_shift0; - break; - default: - scale->horiz_resample_func = - (HorizResampleFunc) resample_horiz_int32_int32_ayuv_generic; - break; - } - - scale->tmpdata = - g_malloc (sizeof (int32_t) * scale->dest->width * scale->src->height * 4); - - vs_scale_lanczos_AYUV_int32 (scale); - - scale1d_cleanup (&scale->x_scale1d); - scale1d_cleanup (&scale->y_scale1d); - g_free (scale->tmpdata); -} - -static void -vs_scale_lanczos_AYUV_double (Scale * scale) -{ - int j; - int yi; - int tmp_yi; - - tmp_yi = 0; - - for (j = 0; j < scale->dest->height; j++) { - guint8 *destline; - double *taps; - - destline = scale->dest->pixels + scale->dest->stride * j; - - yi = scale->y_scale1d.offsets[j]; - - while (tmp_yi < yi + scale->y_scale1d.n_taps) { - scale->horiz_resample_func (TMP_LINE_DOUBLE_AYUV (tmp_yi), - scale->x_scale1d.offsets, scale->x_scale1d.taps, SRC_LINE (tmp_yi), - scale->x_scale1d.n_taps, 0, scale->dest->width); - tmp_yi++; - } - - taps = (double *) scale->y_scale1d.taps + j * scale->y_scale1d.n_taps; - if (scale->dither) { - resample_vert_dither_double_generic (destline, - taps, TMP_LINE_DOUBLE_AYUV (scale->y_scale1d.offsets[j]), - sizeof (double) * 4 * scale->dest->width, - scale->y_scale1d.n_taps, 0, scale->dest->width * 4); - } else { - resample_vert_double_generic (destline, - taps, TMP_LINE_DOUBLE_AYUV (scale->y_scale1d.offsets[j]), - sizeof (double) * 4 * scale->dest->width, - scale->y_scale1d.n_taps, 0, scale->dest->width * 4); - } - } -} - -void -vs_image_scale_lanczos_AYUV_double (const VSImage * dest, const VSImage * src, - uint8_t * tmpbuf, double sharpness, gboolean dither, double a, - double sharpen) -{ - Scale s = { 0 }; - Scale *scale = &s; - int n_taps; - - scale->dest = dest; - scale->src = src; - - n_taps = scale1d_get_n_taps (src->width, dest->width, a, sharpness); - scale1d_calculate_taps (&scale->x_scale1d, - src->width, dest->width, n_taps, a, sharpness, sharpen); - - n_taps = scale1d_get_n_taps (src->height, dest->height, a, sharpness); - scale1d_calculate_taps (&scale->y_scale1d, - src->height, dest->height, n_taps, a, sharpness, sharpen); - - scale->dither = dither; - - scale->horiz_resample_func = - (HorizResampleFunc) resample_horiz_double_ayuv_generic; - - scale->tmpdata = - g_malloc (sizeof (double) * scale->dest->width * scale->src->height * 4); - - vs_scale_lanczos_AYUV_double (scale); - - scale1d_cleanup (&scale->x_scale1d); - scale1d_cleanup (&scale->y_scale1d); - g_free (scale->tmpdata); -} - -static void -vs_scale_lanczos_AYUV_float (Scale * scale) -{ - int j; - int yi; - int tmp_yi; - - tmp_yi = 0; - - for (j = 0; j < scale->dest->height; j++) { - guint8 *destline; - float *taps; - - destline = scale->dest->pixels + scale->dest->stride * j; - - yi = scale->y_scale1d.offsets[j]; - - while (tmp_yi < yi + scale->y_scale1d.n_taps) { - scale->horiz_resample_func (TMP_LINE_FLOAT_AYUV (tmp_yi), - scale->x_scale1d.offsets, scale->x_scale1d.taps, SRC_LINE (tmp_yi), - scale->x_scale1d.n_taps, 0, scale->dest->width); - tmp_yi++; - } - - taps = (float *) scale->y_scale1d.taps + j * scale->y_scale1d.n_taps; - if (scale->dither) { - resample_vert_dither_float_generic (destline, - taps, TMP_LINE_FLOAT_AYUV (scale->y_scale1d.offsets[j]), - sizeof (float) * 4 * scale->dest->width, scale->y_scale1d.n_taps, 0, - scale->dest->width * 4); - } else { - resample_vert_float_generic (destline, - taps, TMP_LINE_FLOAT_AYUV (scale->y_scale1d.offsets[j]), - sizeof (float) * 4 * scale->dest->width, scale->y_scale1d.n_taps, 0, - scale->dest->width * 4); - } - } -} - -void -vs_image_scale_lanczos_AYUV_float (const VSImage * dest, const VSImage * src, - uint8_t * tmpbuf, double sharpness, gboolean dither, double a, - double sharpen) -{ - Scale s = { 0 }; - Scale *scale = &s; - int n_taps; - - scale->dest = dest; - scale->src = src; - - n_taps = scale1d_get_n_taps (src->width, dest->width, a, sharpness); - scale1d_calculate_taps_float (&scale->x_scale1d, - src->width, dest->width, n_taps, a, sharpness, sharpen); - - n_taps = scale1d_get_n_taps (src->height, dest->height, a, sharpness); - scale1d_calculate_taps_float (&scale->y_scale1d, - src->height, dest->height, n_taps, a, sharpness, sharpen); - - scale->dither = dither; - - scale->horiz_resample_func = - (HorizResampleFunc) resample_horiz_float_ayuv_generic; - - scale->tmpdata = - g_malloc (sizeof (float) * scale->dest->width * scale->src->height * 4); - - vs_scale_lanczos_AYUV_float (scale); - - scale1d_cleanup (&scale->x_scale1d); - scale1d_cleanup (&scale->y_scale1d); - g_free (scale->tmpdata); -} - -static void -vs_scale_lanczos_AYUV64_double (Scale * scale) -{ - int j; - int yi; - int tmp_yi; - - tmp_yi = 0; - - for (j = 0; j < scale->dest->height; j++) { - guint16 *destline; - double *taps; - - destline = (guint16 *) (scale->dest->pixels + scale->dest->stride * j); - - yi = scale->y_scale1d.offsets[j]; - - while (tmp_yi < yi + scale->y_scale1d.n_taps) { - scale->horiz_resample_func (TMP_LINE_DOUBLE_AYUV (tmp_yi), - scale->x_scale1d.offsets, scale->x_scale1d.taps, SRC_LINE (tmp_yi), - scale->x_scale1d.n_taps, 0, scale->dest->width); - tmp_yi++; - } - - taps = (double *) scale->y_scale1d.taps + j * scale->y_scale1d.n_taps; - if (scale->dither) { - resample_vert_dither_double_generic_u16 (destline, - taps, TMP_LINE_DOUBLE_AYUV (scale->y_scale1d.offsets[j]), - sizeof (double) * 4 * scale->dest->width, - scale->y_scale1d.n_taps, 0, scale->dest->width * 4); - } else { - resample_vert_double_generic_u16 (destline, - taps, TMP_LINE_DOUBLE_AYUV (scale->y_scale1d.offsets[j]), - sizeof (double) * 4 * scale->dest->width, - scale->y_scale1d.n_taps, 0, scale->dest->width * 4); - } - } -} - -void -vs_image_scale_lanczos_AYUV64_double (const VSImage * dest, const VSImage * src, - uint8_t * tmpbuf, double sharpness, gboolean dither, double a, - double sharpen) -{ - Scale s = { 0 }; - Scale *scale = &s; - int n_taps; - - scale->dest = dest; - scale->src = src; - - n_taps = scale1d_get_n_taps (src->width, dest->width, a, sharpness); - scale1d_calculate_taps (&scale->x_scale1d, - src->width, dest->width, n_taps, a, sharpness, sharpen); - - n_taps = scale1d_get_n_taps (src->height, dest->height, a, sharpness); - scale1d_calculate_taps (&scale->y_scale1d, - src->height, dest->height, n_taps, a, sharpness, sharpen); - - scale->dither = dither; - - scale->horiz_resample_func = - (HorizResampleFunc) resample_horiz_double_ayuv_generic_s16; - - scale->tmpdata = - g_malloc (sizeof (double) * scale->dest->width * scale->src->height * 4); - - vs_scale_lanczos_AYUV64_double (scale); - - scale1d_cleanup (&scale->x_scale1d); - scale1d_cleanup (&scale->y_scale1d); - g_free (scale->tmpdata); -} - -void -vs_image_scale_lanczos_NV (const VSImage * dest, const VSImage * src, - uint8_t * tmpbuf, double sharpness, gboolean dither, int submethod, - double a, double sharpen) -{ - - switch (submethod) { - case 0: - default: - vs_image_scale_lanczos_NV_int16 (dest, src, tmpbuf, sharpness, dither, - a, sharpen); - break; - case 1: - vs_image_scale_lanczos_NV_int32 (dest, src, tmpbuf, sharpness, dither, - a, sharpen); - break; - case 2: - vs_image_scale_lanczos_NV_float (dest, src, tmpbuf, sharpness, dither, - a, sharpen); - break; - case 3: - vs_image_scale_lanczos_NV_double (dest, src, tmpbuf, sharpness, dither, - a, sharpen); - break; - } -} - -static void -vs_scale_lanczos_NV_int16 (Scale * scale) -{ - int j; - int yi; - int tmp_yi; - - tmp_yi = 0; - - for (j = 0; j < scale->dest->height; j++) { - guint8 *destline; - gint16 *taps; - - destline = scale->dest->pixels + scale->dest->stride * j; - - yi = scale->y_scale1d.offsets[j]; - - while (tmp_yi < yi + scale->y_scale1d.n_taps) { - scale->horiz_resample_func (TMP_LINE_S16_NV (tmp_yi), - scale->x_scale1d.offsets, scale->x_scale1d.taps, SRC_LINE (tmp_yi), - scale->x_scale1d.n_taps, S16_MIDSHIFT, scale->dest->width); - tmp_yi++; - } - - taps = (gint16 *) scale->y_scale1d.taps + j * scale->y_scale1d.n_taps; - if (scale->dither) { - resample_vert_dither_int16_generic (destline, - taps, TMP_LINE_S16_NV (scale->y_scale1d.offsets[j]), - sizeof (gint16) * 2 * scale->dest->width, - scale->y_scale1d.n_taps, S16_POSTSHIFT, scale->dest->width * 2); - } else { - resample_vert_int16_generic (destline, - taps, TMP_LINE_S16_NV (scale->y_scale1d.offsets[j]), - sizeof (gint16) * 2 * scale->dest->width, - scale->y_scale1d.n_taps, S16_POSTSHIFT, scale->dest->width * 2); - } - } -} - -static void -vs_scale_lanczos_NV_int32 (Scale * scale) -{ - int j; - int yi; - int tmp_yi; - - tmp_yi = 0; - - for (j = 0; j < scale->dest->height; j++) { - guint8 *destline; - gint32 *taps; - - destline = scale->dest->pixels + scale->dest->stride * j; - - yi = scale->y_scale1d.offsets[j]; - - while (tmp_yi < yi + scale->y_scale1d.n_taps) { - scale->horiz_resample_func (TMP_LINE_S32_NV (tmp_yi), - scale->x_scale1d.offsets, scale->x_scale1d.taps, SRC_LINE (tmp_yi), - scale->x_scale1d.n_taps, S32_MIDSHIFT, scale->dest->width); - tmp_yi++; - } - - taps = (gint32 *) scale->y_scale1d.taps + j * scale->y_scale1d.n_taps; - if (scale->dither) { - resample_vert_dither_int32_generic (destline, - taps, TMP_LINE_S32_NV (scale->y_scale1d.offsets[j]), - sizeof (gint32) * 2 * scale->dest->width, scale->y_scale1d.n_taps, - S32_POSTSHIFT, scale->dest->width * 2); - } else { - resample_vert_int32_generic (destline, - taps, TMP_LINE_S32_NV (scale->y_scale1d.offsets[j]), - sizeof (gint32) * 2 * scale->dest->width, scale->y_scale1d.n_taps, - S32_POSTSHIFT, scale->dest->width * 2); - } - } -} - -static void -vs_scale_lanczos_NV_float (Scale * scale) -{ - int j; - int yi; - int tmp_yi; - - tmp_yi = 0; - - for (j = 0; j < scale->dest->height; j++) { - guint8 *destline; - float *taps; - - destline = scale->dest->pixels + scale->dest->stride * j; - - yi = scale->y_scale1d.offsets[j]; - - while (tmp_yi < yi + scale->y_scale1d.n_taps) { - scale->horiz_resample_func (TMP_LINE_FLOAT_NV (tmp_yi), - scale->x_scale1d.offsets, scale->x_scale1d.taps, SRC_LINE (tmp_yi), - scale->x_scale1d.n_taps, 0, scale->dest->width); - tmp_yi++; - } - - taps = (float *) scale->y_scale1d.taps + j * scale->y_scale1d.n_taps; - if (scale->dither) { - resample_vert_dither_float_generic (destline, - taps, TMP_LINE_FLOAT_NV (scale->y_scale1d.offsets[j]), - sizeof (float) * 2 * scale->dest->width, scale->y_scale1d.n_taps, 0, - scale->dest->width * 2); - } else { - resample_vert_float_generic (destline, - taps, TMP_LINE_FLOAT_NV (scale->y_scale1d.offsets[j]), - sizeof (float) * 2 * scale->dest->width, scale->y_scale1d.n_taps, 0, - scale->dest->width * 2); - } - } -} - -static void -vs_scale_lanczos_NV_double (Scale * scale) -{ - int j; - int yi; - int tmp_yi; - - tmp_yi = 0; - - for (j = 0; j < scale->dest->height; j++) { - guint8 *destline; - double *taps; - - destline = scale->dest->pixels + scale->dest->stride * j; - - yi = scale->y_scale1d.offsets[j]; - - while (tmp_yi < yi + scale->y_scale1d.n_taps) { - scale->horiz_resample_func (TMP_LINE_DOUBLE_NV (tmp_yi), - scale->x_scale1d.offsets, scale->x_scale1d.taps, SRC_LINE (tmp_yi), - scale->x_scale1d.n_taps, 0, scale->dest->width); - tmp_yi++; - } - - taps = (double *) scale->y_scale1d.taps + j * scale->y_scale1d.n_taps; - if (scale->dither) { - resample_vert_dither_double_generic (destline, - taps, TMP_LINE_DOUBLE_NV (scale->y_scale1d.offsets[j]), - sizeof (double) * 2 * scale->dest->width, - scale->y_scale1d.n_taps, 0, scale->dest->width * 2); - } else { - resample_vert_double_generic (destline, - taps, TMP_LINE_DOUBLE_NV (scale->y_scale1d.offsets[j]), - sizeof (double) * 2 * scale->dest->width, - scale->y_scale1d.n_taps, 0, scale->dest->width * 2); - } - } -} - -void -vs_image_scale_lanczos_NV_int32 (const VSImage * dest, const VSImage * src, - uint8_t * tmpbuf, double sharpness, gboolean dither, double a, - double sharpen) -{ - Scale s = { 0 }; - Scale *scale = &s; - int n_taps; - - scale->dest = dest; - scale->src = src; - - n_taps = scale1d_get_n_taps (src->width, dest->width, a, sharpness); - n_taps = ROUND_UP_4 (n_taps); - scale1d_calculate_taps_int32 (&scale->x_scale1d, - src->width, dest->width, n_taps, a, sharpness, sharpen, S32_SHIFT1); - - n_taps = scale1d_get_n_taps (src->height, dest->height, a, sharpness); - scale1d_calculate_taps_int32 (&scale->y_scale1d, - src->height, dest->height, n_taps, a, sharpness, sharpen, S32_SHIFT2); - - scale->dither = dither; - - switch (scale->x_scale1d.n_taps) { - case 4: - scale->horiz_resample_func = - (HorizResampleFunc) resample_horiz_int32_int32_nv_taps4_shift0; - break; - case 8: - scale->horiz_resample_func = - (HorizResampleFunc) resample_horiz_int32_int32_nv_taps8_shift0; - break; - case 12: - scale->horiz_resample_func = - (HorizResampleFunc) resample_horiz_int32_int32_nv_taps12_shift0; - break; - case 16: - scale->horiz_resample_func = - (HorizResampleFunc) resample_horiz_int32_int32_nv_taps16_shift0; - break; - default: - scale->horiz_resample_func = - (HorizResampleFunc) resample_horiz_int32_int32_nv_generic; - break; - } - - scale->tmpdata = - g_malloc (sizeof (int32_t) * scale->dest->width * scale->src->height * 2); - - vs_scale_lanczos_NV_int32 (scale); - - scale1d_cleanup (&scale->x_scale1d); - scale1d_cleanup (&scale->y_scale1d); - g_free (scale->tmpdata); -} - -void -vs_image_scale_lanczos_NV_int16 (const VSImage * dest, const VSImage * src, - uint8_t * tmpbuf, double sharpness, gboolean dither, double a, - double sharpen) -{ - Scale s = { 0 }; - Scale *scale = &s; - int n_taps; - - scale->dest = dest; - scale->src = src; - - n_taps = scale1d_get_n_taps (src->width, dest->width, a, sharpness); - n_taps = ROUND_UP_4 (n_taps); - scale1d_calculate_taps_int16 (&scale->x_scale1d, - src->width, dest->width, n_taps, a, sharpness, sharpen, S16_SHIFT1); - - n_taps = scale1d_get_n_taps (src->height, dest->height, a, sharpness); - scale1d_calculate_taps_int16 (&scale->y_scale1d, - src->height, dest->height, n_taps, a, sharpness, sharpen, S16_SHIFT2); - - scale->dither = dither; - - switch (scale->x_scale1d.n_taps) { - case 4: - scale->horiz_resample_func = - (HorizResampleFunc) resample_horiz_int16_int16_nv_taps4_shift0; - break; - case 8: - scale->horiz_resample_func = - (HorizResampleFunc) resample_horiz_int16_int16_nv_taps8_shift0; - break; - case 12: - scale->horiz_resample_func = - (HorizResampleFunc) resample_horiz_int16_int16_nv_taps12_shift0; - break; - case 16: - scale->horiz_resample_func = - (HorizResampleFunc) resample_horiz_int16_int16_nv_taps16_shift0; - break; - default: - scale->horiz_resample_func = - (HorizResampleFunc) resample_horiz_int16_int16_nv_generic; - break; - } - - scale->tmpdata = - g_malloc (sizeof (gint16) * scale->dest->width * scale->src->height * 2); - - vs_scale_lanczos_NV_int16 (scale); - - scale1d_cleanup (&scale->x_scale1d); - scale1d_cleanup (&scale->y_scale1d); - g_free (scale->tmpdata); -} - -void -vs_image_scale_lanczos_NV_float (const VSImage * dest, const VSImage * src, - uint8_t * tmpbuf, double sharpness, gboolean dither, double a, - double sharpen) -{ - Scale s = { 0 }; - Scale *scale = &s; - int n_taps; - - scale->dest = dest; - scale->src = src; - - n_taps = scale1d_get_n_taps (src->width, dest->width, a, sharpness); - scale1d_calculate_taps_float (&scale->x_scale1d, - src->width, dest->width, n_taps, a, sharpness, sharpen); - - n_taps = scale1d_get_n_taps (src->height, dest->height, a, sharpness); - scale1d_calculate_taps_float (&scale->y_scale1d, - src->height, dest->height, n_taps, a, sharpness, sharpen); - - scale->dither = dither; - - scale->horiz_resample_func = - (HorizResampleFunc) resample_horiz_float_nv_generic; - - scale->tmpdata = - g_malloc (sizeof (float) * scale->dest->width * scale->src->height * 2); - - vs_scale_lanczos_NV_float (scale); - - scale1d_cleanup (&scale->x_scale1d); - scale1d_cleanup (&scale->y_scale1d); - g_free (scale->tmpdata); -} - -void -vs_image_scale_lanczos_NV_double (const VSImage * dest, const VSImage * src, - uint8_t * tmpbuf, double sharpness, gboolean dither, double a, - double sharpen) -{ - Scale s = { 0 }; - Scale *scale = &s; - int n_taps; - - scale->dest = dest; - scale->src = src; - - n_taps = scale1d_get_n_taps (src->width, dest->width, a, sharpness); - scale1d_calculate_taps (&scale->x_scale1d, - src->width, dest->width, n_taps, a, sharpness, sharpen); - - n_taps = scale1d_get_n_taps (src->height, dest->height, a, sharpness); - scale1d_calculate_taps (&scale->y_scale1d, - src->height, dest->height, n_taps, a, sharpness, sharpen); - - scale->dither = dither; - - scale->horiz_resample_func = - (HorizResampleFunc) resample_horiz_double_nv_generic; - - scale->tmpdata = - g_malloc (sizeof (double) * scale->dest->width * scale->src->height * 2); - - vs_scale_lanczos_NV_double (scale); - - scale1d_cleanup (&scale->x_scale1d); - scale1d_cleanup (&scale->y_scale1d); - g_free (scale->tmpdata); -} diff --git a/gst/videoscale/vs_scanline.c b/gst/videoscale/vs_scanline.c deleted file mode 100644 index d67ee5c89e..0000000000 --- a/gst/videoscale/vs_scanline.c +++ /dev/null @@ -1,778 +0,0 @@ -/* - * Image Scaling Functions - * Copyright (c) 2005 David A. Schleef - * 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. - */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "vs_scanline.h" - -#include "gstvideoscaleorc.h" -#include - -#include - -/* greyscale, i.e., single componenet */ - -#define BLEND(a,b,x) (((a) * (65536 - (x)) + (b) * (x)) >> 16) -#define BLEND15(a,b,x) (((a) * (32768 - (x)) + (b) * (x)) >> 15) - -void -vs_scanline_downsample_Y (uint8_t * dest, uint8_t * src, int n) -{ - video_scale_orc_downsample_u8 (dest, src, n); -} - -void -vs_scanline_resample_nearest_Y (uint8_t * dest, uint8_t * src, int src_width, - int n, int *accumulator, int increment) -{ - video_scale_orc_resample_nearest_u8 (dest, src, *accumulator, increment, n); - - *accumulator += n * increment; -} - -#include -void -vs_scanline_resample_linear_Y (uint8_t * dest, uint8_t * src, int src_width, - int n, int *accumulator, int increment) -{ - video_scale_orc_resample_bilinear_u8 (dest, src, *accumulator, increment, n); - - *accumulator += n * increment; -} - -void -vs_scanline_merge_linear_Y (uint8_t * dest, uint8_t * src1, uint8_t * src2, - int n, int x) -{ - uint32_t value = x >> 8; - - if (value == 0) { - memcpy (dest, src1, n); - } else { - video_scale_orc_merge_linear_u8 (dest, src1, src2, value, n); - } -} - -void -vs_scanline_downsample_Y16 (uint8_t * dest, uint8_t * src, int n) -{ - video_scale_orc_downsample_u16 ((uint16_t *) dest, (uint16_t *) src, n); -} - -void -vs_scanline_resample_nearest_Y16 (uint8_t * dest, uint8_t * src, int src_width, - int n, int *accumulator, int increment) -{ - int acc = *accumulator; - int i, j; - uint16_t *d = (uint16_t *) dest, *s = (uint16_t *) src; - - for (i = 0; i < n; i++) { - j = (acc + 0x8000) >> 16; - d[i] = s[j]; - - acc += increment; - } - - *accumulator = acc; -} - -void -vs_scanline_resample_linear_Y16 (uint8_t * dest, uint8_t * src, int src_width, - int n, int *accumulator, int increment) -{ - int acc = *accumulator; - int i; - int j; - int x; - uint16_t *d = (uint16_t *) dest, *s = (uint16_t *) src; - - for (i = 0; i < n; i++) { - j = acc >> 16; - - if (j + 1 < src_width) { - x = acc & 0xffff; - d[i] = BLEND (s[j], s[j + 1], x); - } else - d[i] = s[j]; - - acc += increment; - } - *accumulator = acc; -} - -void -vs_scanline_merge_linear_Y16 (uint8_t * dest, uint8_t * src1, uint8_t * src2, - int n, int x) -{ - uint16_t *d = (uint16_t *) dest; - const uint16_t *s1 = (const uint16_t *) src1; - const uint16_t *s2 = (const uint16_t *) src2; - - if (x == 0) { - memcpy (d, s1, n * 2); - } else { - video_scale_orc_merge_linear_u16 (d, s1, s2, 65536 - x, x, n); - } -} - -/* RGBA */ - -void -vs_scanline_downsample_RGBA (uint8_t * dest, uint8_t * src, int n) -{ - video_scale_orc_downsample_u32 (dest, src, n); -} - -void -vs_scanline_resample_nearest_RGBA (uint8_t * dest, uint8_t * src, int src_width, - int n, int *accumulator, int increment) -{ - video_scale_orc_resample_nearest_u32 (dest, src, *accumulator, increment, n); - - *accumulator += n * increment; -} - -void -vs_scanline_resample_linear_RGBA (uint8_t * dest, uint8_t * src, int src_width, - int n, int *accumulator, int increment) -{ - video_scale_orc_resample_bilinear_u32 (dest, src, *accumulator, increment, n); - - *accumulator += n * increment; -} - -void -vs_scanline_merge_linear_RGBA (uint8_t * dest, uint8_t * src1, uint8_t * src2, - int n, int x) -{ - uint32_t value = x >> 8; - - if (value == 0) { - memcpy (dest, src1, n * 4); - } else { - video_scale_orc_merge_linear_u8 (dest, src1, src2, value, n * 4); - } -} - - -/* RGB */ - -void -vs_scanline_downsample_RGB (uint8_t * dest, uint8_t * src, int n) -{ - int i; - - for (i = 0; i < n; i++) { - dest[i * 3 + 0] = (src[i * 6 + 0] + src[i * 6 + 3]) / 2; - dest[i * 3 + 1] = (src[i * 6 + 1] + src[i * 6 + 4]) / 2; - dest[i * 3 + 2] = (src[i * 6 + 2] + src[i * 6 + 5]) / 2; - } -} - -void -vs_scanline_resample_nearest_RGB (uint8_t * dest, uint8_t * src, int src_width, - int n, int *accumulator, int increment) -{ - int acc = *accumulator; - int i; - int j; - - for (i = 0; i < n; i++) { - j = (acc + 0x8000) >> 16; - - dest[i * 3 + 0] = src[j * 3 + 0]; - dest[i * 3 + 1] = src[j * 3 + 1]; - dest[i * 3 + 2] = src[j * 3 + 2]; - - acc += increment; - } - - *accumulator = acc; -} - -void -vs_scanline_resample_linear_RGB (uint8_t * dest, uint8_t * src, int src_width, - int n, int *accumulator, int increment) -{ - int acc = *accumulator; - int i; - int j; - int x; - - for (i = 0; i < n; i++) { - j = acc >> 16; - - if (j + 1 < src_width) { - x = acc & 0xffff; - dest[i * 3 + 0] = BLEND (src[j * 3 + 0], src[j * 3 + 3], x); - dest[i * 3 + 1] = BLEND (src[j * 3 + 1], src[j * 3 + 4], x); - dest[i * 3 + 2] = BLEND (src[j * 3 + 2], src[j * 3 + 5], x); - } else { - dest[i * 3 + 0] = src[j * 3 + 0]; - dest[i * 3 + 1] = src[j * 3 + 1]; - dest[i * 3 + 2] = src[j * 3 + 2]; - } - acc += increment; - } - - *accumulator = acc; -} - -void -vs_scanline_merge_linear_RGB (uint8_t * dest, uint8_t * src1, uint8_t * src2, - int n, int x) -{ - uint32_t value = x >> 8; - - if (value == 0) { - memcpy (dest, src1, n * 3); - } else { - video_scale_orc_merge_linear_u8 (dest, src1, src2, value, n * 3); - } -} - - -/* YUYV */ - -/* n is the number of pixels */ -/* increment is per Y pixel */ - -void -vs_scanline_downsample_YUYV (uint8_t * dest, uint8_t * src, int n) -{ - video_scale_orc_downsample_yuyv (dest, src, n); -} - -void -vs_scanline_resample_nearest_YUYV (uint8_t * dest, uint8_t * src, int src_width, - int n, int *accumulator, int increment) -{ - int acc = *accumulator; - int i, j; - - for (i = 0; i < n; i += 2) { - j = (acc + 0x8000) >> 16; - dest[i * 2 + 0] = src[j * 2 + 0]; - - j >>= 1; - dest[i * 2 + 1] = src[j * 4 + 1]; - dest[i * 2 + 3] = src[j * 4 + 3]; - - acc += increment; - - if (i < n - 1) { - j = (acc + 0x8000) >> 16; - dest[i * 2 + 2] = src[j * 2 + 0]; - - acc += increment; - } - } - - *accumulator = acc; -} - -void -vs_scanline_resample_linear_YUYV (uint8_t * dest, uint8_t * src, int src_width, - int n, int *accumulator, int increment) -{ - int acc = *accumulator; - int i, j, x; - - for (i = 0; i < n; i += 2) { - j = acc >> 16; - x = acc & 0xffff; - - if (j + 1 < src_width) - dest[i * 2 + 0] = BLEND (src[j * 2 + 0], src[j * 2 + 2], x); - else - dest[i * 2 + 0] = src[j * 2 + 0]; - - j >>= 1; - if (2 * (j + 1) < src_width) { - dest[i * 2 + 1] = BLEND (src[j * 4 + 1], src[j * 4 + 5], x); - dest[i * 2 + 3] = BLEND (src[j * 4 + 3], src[j * 4 + 7], x); - } else { - dest[i * 2 + 1] = src[j * 4 + 1]; - dest[i * 2 + 3] = src[j * 4 + 3]; - } - - acc += increment; - - if (i < n - 1) { - j = acc >> 16; - - if (j + 1 < src_width) { - x = acc & 0xffff; - dest[i * 2 + 2] = BLEND (src[j * 2 + 0], src[j * 2 + 2], x); - } else - dest[i * 2 + 2] = src[j * 2 + 0]; - - acc += increment; - } - } - *accumulator = acc; -} - -void -vs_scanline_merge_linear_YUYV (uint8_t * dest, uint8_t * src1, uint8_t * src2, - int n, int x) -{ - int quads = (n + 1) / 2; - uint32_t value = x >> 8; - - if (value == 0) { - memcpy (dest, src1, quads * 4); - } else { - video_scale_orc_merge_linear_u8 (dest, src1, src2, value, quads * 4); - } -} - - -/* UYVY */ - -/* n is the number of bi-pixels */ -/* increment is per Y pixel */ - -void -vs_scanline_downsample_UYVY (uint8_t * dest, uint8_t * src, int n) -{ - int i; - - for (i = 0; i < n; i++) { - dest[i * 4 + 0] = (src[i * 8 + 0] + src[i * 8 + 4]) / 2; - dest[i * 4 + 1] = (src[i * 8 + 1] + src[i * 8 + 3]) / 2; - dest[i * 4 + 2] = (src[i * 8 + 2] + src[i * 8 + 6]) / 2; - dest[i * 4 + 3] = (src[i * 8 + 5] + src[i * 8 + 7]) / 2; - } -} - -void -vs_scanline_resample_nearest_UYVY (uint8_t * dest, uint8_t * src, int src_width, - int n, int *accumulator, int increment) -{ - int acc = *accumulator; - int i, j; - - for (i = 0; i < n; i += 2) { - j = (acc + 0x8000) >> 16; - dest[i * 2 + 1] = src[j * 2 + 1]; - - j >>= 1; - dest[i * 2 + 0] = src[j * 4 + 0]; - dest[i * 2 + 2] = src[j * 4 + 2]; - - acc += increment; - - if (i < n - 1) { - j = (acc + 0x8000) >> 16; - dest[i * 2 + 3] = src[j * 2 + 1]; - - acc += increment; - } - } - - *accumulator = acc; -} - -void -vs_scanline_resample_linear_UYVY (uint8_t * dest, uint8_t * src, int src_width, - int n, int *accumulator, int increment) -{ - int acc = *accumulator; - int i, j, x; - - for (i = 0; i < n; i += 2) { - j = acc >> 16; - x = acc & 0xffff; - - if (j + 1 < src_width) - dest[i * 2 + 1] = BLEND (src[j * 2 + 1], src[j * 2 + 3], x); - else - dest[i * 2 + 1] = src[j * 2 + 1]; - - j >>= 1; - if (2 * (j + 1) < src_width) { - dest[i * 2 + 0] = BLEND (src[j * 4 + 0], src[j * 4 + 4], x); - dest[i * 2 + 2] = BLEND (src[j * 4 + 2], src[j * 4 + 6], x); - } else { - dest[i * 2 + 0] = src[j * 4 + 0]; - dest[i * 2 + 2] = src[j * 4 + 2]; - } - - acc += increment; - - if (i < n - 1) { - j = acc >> 16; - - if (j + 1 < src_width) { - x = acc & 0xffff; - dest[i * 2 + 3] = BLEND (src[j * 2 + 1], src[j * 2 + 3], x); - } else - dest[i * 2 + 3] = src[j * 2 + 1]; - - acc += increment; - } - } -} - -void -vs_scanline_merge_linear_UYVY (uint8_t * dest, uint8_t * src1, - uint8_t * src2, int n, int x) -{ - int quads = (n + 1) / 2; - uint32_t value = x >> 8; - - if (value == 0) { - memcpy (dest, src1, quads * 4); - } else { - video_scale_orc_merge_linear_u8 (dest, src1, src2, value, quads * 4); - } -} - - -/* NV12 */ - -/* n is the number of bi-pixels */ - -void -vs_scanline_downsample_NV12 (uint8_t * dest, uint8_t * src, int n) -{ - int i; - - for (i = 0; i < n; i++) { - dest[i * 2 + 0] = (src[i * 4 + 0] + src[i * 4 + 2]) / 2; - dest[i * 2 + 1] = (src[i * 4 + 1] + src[i * 4 + 3]) / 2; - } -} - -void -vs_scanline_resample_nearest_NV12 (uint8_t * dest, uint8_t * src, int src_width, - int n, int *accumulator, int increment) -{ - int acc = *accumulator; - int i, j; - - for (i = 0; i < n; i++) { - j = (acc + 0x8000) >> 16; - - dest[i * 2 + 0] = src[j * 2 + 0]; - dest[i * 2 + 1] = src[j * 2 + 1]; - - acc += increment; - } - - *accumulator = acc; -} - -void -vs_scanline_resample_linear_NV12 (uint8_t * dest, uint8_t * src, int src_width, - int n, int *accumulator, int increment) -{ - int acc = *accumulator; - int i; - int j; - int x; - - for (i = 0; i < n; i++) { - j = acc >> 16; - - if (j + 1 < src_width) { - x = acc & 0xffff; - dest[i * 2 + 0] = BLEND (src[j * 2 + 0], src[j * 2 + 2], x); - dest[i * 2 + 1] = BLEND (src[j * 2 + 1], src[j * 2 + 3], x); - } else { - dest[i * 2 + 0] = src[j * 2 + 0]; - dest[i * 2 + 1] = src[j * 2 + 1]; - } - acc += increment; - } - *accumulator = acc; -} - -void -vs_scanline_merge_linear_NV12 (uint8_t * dest, uint8_t * src1, - uint8_t * src2, int n, int x) -{ - uint32_t value = x >> 8; - - if (value == 0) { - memcpy (dest, src1, n * 2); - } else { - video_scale_orc_merge_linear_u8 (dest, src1, src2, value, n * 2); - } -} - - -/* RGB565 */ - -/* 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_downsample_RGB565 (uint8_t * dest_u8, uint8_t * src_u8, int n) -{ - uint16_t *dest = (uint16_t *) dest_u8; - uint16_t *src = (uint16_t *) src_u8; - int i; - - for (i = 0; i < n; i++) { - dest[i] = RGB565 ( - (RGB565_R (src[i * 2]) + RGB565_R (src[i * 2 + 1])) / 2, - (RGB565_G (src[i * 2]) + RGB565_G (src[i * 2 + 1])) / 2, - (RGB565_B (src[i * 2]) + RGB565_B (src[i * 2 + 1])) / 2); - } -} - -void -vs_scanline_resample_nearest_RGB565 (uint8_t * dest_u8, uint8_t * src_u8, - int src_width, int n, int *accumulator, int increment) -{ - uint16_t *dest = (uint16_t *) dest_u8; - uint16_t *src = (uint16_t *) src_u8; - int acc = *accumulator; - int i, j; - - for (i = 0; i < n; i++) { - j = (acc + 0x8000) >> 16; - dest[i] = src[j]; - - acc += increment; - } - - *accumulator = acc; -} - -void -vs_scanline_resample_linear_RGB565 (uint8_t * dest_u8, uint8_t * src_u8, - int src_width, int n, int *accumulator, int increment) -{ - uint16_t *dest = (uint16_t *) dest_u8; - uint16_t *src = (uint16_t *) src_u8; - int acc = *accumulator; - int i; - int j; - int x; - - for (i = 0; i < n; i++) { - j = acc >> 16; - - if (j + 1 < src_width) { - x = acc & 0xffff; - dest[i] = RGB565 (BLEND (RGB565_R (src[j]), RGB565_R (src[j + 1]), x), - BLEND (RGB565_G (src[j]), RGB565_G (src[j + 1]), x), - BLEND (RGB565_B (src[j]), RGB565_B (src[j + 1]), x)); - } else { - dest[i] = RGB565 (RGB565_R (src[j]), - RGB565_G (src[j]), RGB565_B (src[j])); - } - - acc += increment; - } - - *accumulator = acc; -} - -void -vs_scanline_merge_linear_RGB565 (uint8_t * dest_u8, uint8_t * src1_u8, - uint8_t * src2_u8, int n, int x) -{ - uint16_t *dest = (uint16_t *) dest_u8; - uint16_t *src1 = (uint16_t *) src1_u8; - uint16_t *src2 = (uint16_t *) src2_u8; - int i; - - if (x == 0) { - memcpy (dest, src1, n * 2); - } else { - for (i = 0; i < n; i++) { - dest[i] = RGB565 (BLEND (RGB565_R (src1[i]), RGB565_R (src2[i]), x), - BLEND (RGB565_G (src1[i]), RGB565_G (src2[i]), x), - BLEND (RGB565_B (src1[i]), RGB565_B (src2[i]), x)); - } - } -} - - -/* RGB555 */ - -/* note that src and dest are uint16_t, and thus endian dependent */ - -#define RGB555_R(x) (((x)&0x7c00)>>7 | ((x)&0x7c00)>>12) -#define RGB555_G(x) (((x)&0x03e0)>>2 | ((x)&0x03e0)>>7) -#define RGB555_B(x) (((x)&0x001f)<<3 | ((x)&0x001f)>>2) - -#define RGB555(r,g,b) \ - ((((r)<<7)&0x7c00) | (((g)<<2)&0x03e0) | (((b)>>3)&0x001f)) - -void -vs_scanline_downsample_RGB555 (uint8_t * dest_u8, uint8_t * src_u8, int n) -{ - uint16_t *dest = (uint16_t *) dest_u8; - uint16_t *src = (uint16_t *) src_u8; - int i; - - for (i = 0; i < n; i++) { - dest[i] = RGB555 ( - (RGB555_R (src[i * 2]) + RGB555_R (src[i * 2 + 1])) / 2, - (RGB555_G (src[i * 2]) + RGB555_G (src[i * 2 + 1])) / 2, - (RGB555_B (src[i * 2]) + RGB555_B (src[i * 2 + 1])) / 2); - } -} - -void -vs_scanline_resample_nearest_RGB555 (uint8_t * dest_u8, uint8_t * src_u8, - int src_width, int n, int *accumulator, int increment) -{ - uint16_t *dest = (uint16_t *) dest_u8; - uint16_t *src = (uint16_t *) src_u8; - int acc = *accumulator; - int i, j; - - for (i = 0; i < n; i++) { - j = (acc + 0x8000) >> 16; - - dest[i] = src[j]; - - acc += increment; - } - - *accumulator = acc; -} - -void -vs_scanline_resample_linear_RGB555 (uint8_t * dest_u8, uint8_t * src_u8, - int src_width, int n, int *accumulator, int increment) -{ - uint16_t *dest = (uint16_t *) dest_u8; - uint16_t *src = (uint16_t *) src_u8; - int acc = *accumulator; - int i; - int j; - int x; - - for (i = 0; i < n; i++) { - j = acc >> 16; - - if (j + 1 < src_width) { - x = acc & 0xffff; - dest[i] = RGB555 (BLEND (RGB555_R (src[j]), RGB555_R (src[j + 1]), x), - BLEND (RGB555_G (src[j]), RGB555_G (src[j + 1]), x), - BLEND (RGB555_B (src[j]), RGB555_B (src[j + 1]), x)); - } else { - dest[i] = RGB555 (RGB555_R (src[j]), - RGB555_G (src[j]), RGB555_B (src[j])); - } - - acc += increment; - } - - *accumulator = acc; -} - -void -vs_scanline_merge_linear_RGB555 (uint8_t * dest_u8, uint8_t * src1_u8, - uint8_t * src2_u8, int n, int x) -{ - uint16_t *dest = (uint16_t *) dest_u8; - uint16_t *src1 = (uint16_t *) src1_u8; - uint16_t *src2 = (uint16_t *) src2_u8; - int i; - - if (x == 0) { - memcpy (dest, src1, n * 2); - } else { - for (i = 0; i < n; i++) { - dest[i] = RGB555 (BLEND (RGB555_R (src1[i]), RGB555_R (src2[i]), x), - BLEND (RGB555_G (src1[i]), RGB555_G (src2[i]), x), - BLEND (RGB555_B (src1[i]), RGB555_B (src2[i]), x)); - } - } -} - -void -vs_scanline_resample_nearest_AYUV64 (uint8_t * dest8, uint8_t * src8, - int src_width, int n, int *accumulator, int increment) -{ - guint16 *dest = (guint16 *) dest8; - guint16 *src = (guint16 *) src8; - int acc = *accumulator; - int i, j; - - for (i = 0; i < n; i++) { - j = (acc + 0x8000) >> 16; - - dest[i * 4 + 0] = src[j * 4 + 0]; - dest[i * 4 + 1] = src[j * 4 + 1]; - dest[i * 4 + 2] = src[j * 4 + 2]; - dest[i * 4 + 3] = src[j * 4 + 3]; - - acc += increment; - } - - *accumulator = acc; -} - -void -vs_scanline_resample_linear_AYUV64 (uint8_t * dest8, uint8_t * src8, - int src_width, int n, int *accumulator, int increment) -{ - guint16 *dest = (guint16 *) dest8; - guint16 *src = (guint16 *) src8; - int acc = *accumulator; - int i; - int j; - int x; - - for (i = 0; i < n; i++) { - j = acc >> 16; - x = (acc & 0xffff) >> 1; - - if (j + 1 < src_width) { - dest[i * 4 + 0] = BLEND15 (src[j * 4 + 0], src[j * 4 + 4], x); - dest[i * 4 + 1] = BLEND15 (src[j * 4 + 1], src[j * 4 + 5], x); - dest[i * 4 + 2] = BLEND15 (src[j * 4 + 2], src[j * 4 + 6], x); - dest[i * 4 + 3] = BLEND15 (src[j * 4 + 3], src[j * 4 + 7], x); - } else { - dest[i * 4 + 0] = src[j * 4 + 0]; - dest[i * 4 + 1] = src[j * 4 + 1]; - dest[i * 4 + 2] = src[j * 4 + 2]; - dest[i * 4 + 3] = src[j * 4 + 3]; - } - acc += increment; - } - - *accumulator = acc; -} diff --git a/gst/videoscale/vs_scanline.h b/gst/videoscale/vs_scanline.h deleted file mode 100644 index b953e98c4f..0000000000 --- a/gst/videoscale/vs_scanline.h +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Image Scaling Functions - * Copyright (c) 2005 David A. Schleef - * 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. - */ - -#ifndef __VS_SCANLINE_H__ -#define __VS_SCANLINE_H__ - -#include <_stdint.h> -#include - -G_GNUC_INTERNAL void vs_scanline_downsample_Y (uint8_t *dest, uint8_t *src, int n); -G_GNUC_INTERNAL void vs_scanline_resample_nearest_Y (uint8_t *dest, uint8_t *src, int n, int src_width, int *accumulator, int increment); -G_GNUC_INTERNAL void vs_scanline_resample_linear_Y (uint8_t *dest, uint8_t *src, int n, int src_width, int *accumulator, int increment); -G_GNUC_INTERNAL void vs_scanline_merge_linear_Y (uint8_t *dest, uint8_t *src1, uint8_t *src2, int n, int x); - -G_GNUC_INTERNAL void vs_scanline_downsample_RGBA (uint8_t *dest, uint8_t *src, int n); -G_GNUC_INTERNAL void vs_scanline_resample_nearest_RGBA (uint8_t *dest, uint8_t *src, int src_width, int n, int *accumulator, int increment); -G_GNUC_INTERNAL void vs_scanline_resample_linear_RGBA (uint8_t *dest, uint8_t *src, int src_width, int n, int *accumulator, int increment); -G_GNUC_INTERNAL void vs_scanline_merge_linear_RGBA (uint8_t *dest, uint8_t *src1, uint8_t *src2, int n, int x); - -G_GNUC_INTERNAL void vs_scanline_downsample_RGB (uint8_t *dest, uint8_t *src, int n); -G_GNUC_INTERNAL void vs_scanline_resample_nearest_RGB (uint8_t *dest, uint8_t *src, int src_width, int n, int *accumulator, int increment); -G_GNUC_INTERNAL void vs_scanline_resample_linear_RGB (uint8_t *dest, uint8_t *src, int src_width, int n, int *accumulator, int increment); -G_GNUC_INTERNAL void vs_scanline_merge_linear_RGB (uint8_t *dest, uint8_t *src1, uint8_t *src2, int n, int x); - -G_GNUC_INTERNAL void vs_scanline_downsample_YUYV (uint8_t *dest, uint8_t *src, int n); -G_GNUC_INTERNAL void vs_scanline_resample_nearest_YUYV (uint8_t *dest, uint8_t *src, int src_width, int n, int *accumulator, int increment); -G_GNUC_INTERNAL void vs_scanline_resample_linear_YUYV (uint8_t *dest, uint8_t *src, int src_width, int n, int *accumulator, int increment); -G_GNUC_INTERNAL void vs_scanline_merge_linear_YUYV (uint8_t *dest, uint8_t *src1, uint8_t *src2, int n, int x); - -G_GNUC_INTERNAL void vs_scanline_downsample_UYVY (uint8_t *dest, uint8_t *src, int n); -G_GNUC_INTERNAL void vs_scanline_resample_nearest_UYVY (uint8_t *dest, uint8_t *src, int src_width, int n, int *accumulator, int increment); -G_GNUC_INTERNAL void vs_scanline_resample_linear_UYVY (uint8_t *dest, uint8_t *src, int src_width, int n, int *accumulator, int increment); -G_GNUC_INTERNAL void vs_scanline_merge_linear_UYVY (uint8_t *dest, uint8_t *src1, uint8_t *src2, int n, int x); - -G_GNUC_INTERNAL void vs_scanline_downsample_NV12 (uint8_t *dest, uint8_t *src, int n); -G_GNUC_INTERNAL void vs_scanline_resample_nearest_NV12 (uint8_t *dest, uint8_t *src, int src_width, int n, int *accumulator, int increment); -G_GNUC_INTERNAL void vs_scanline_resample_linear_NV12 (uint8_t *dest, uint8_t *src, int src_width, int n, int *accumulator, int increment); -G_GNUC_INTERNAL void vs_scanline_merge_linear_NV12 (uint8_t *dest, uint8_t *src1, uint8_t *src2, int n, int x); - -G_GNUC_INTERNAL void vs_scanline_downsample_RGB565 (uint8_t *dest, uint8_t *src, int n); -G_GNUC_INTERNAL void vs_scanline_resample_nearest_RGB565 (uint8_t *dest, uint8_t *src, int src_width, int n, int *accumulator, int increment); -G_GNUC_INTERNAL void vs_scanline_resample_linear_RGB565 (uint8_t *dest, uint8_t *src, int src_width, int n, int *accumulator, int increment); -G_GNUC_INTERNAL void vs_scanline_merge_linear_RGB565 (uint8_t *dest, uint8_t *src1, uint8_t *src2, int n, int x); - -G_GNUC_INTERNAL void vs_scanline_downsample_RGB555 (uint8_t *dest, uint8_t *src, int n); -G_GNUC_INTERNAL void vs_scanline_resample_nearest_RGB555 (uint8_t *dest, uint8_t *src, int src_width, int n, int *accumulator, int increment); -G_GNUC_INTERNAL void vs_scanline_resample_linear_RGB555 (uint8_t *dest, uint8_t *src, int src_width, int n, int *accumulator, int increment); -G_GNUC_INTERNAL void vs_scanline_merge_linear_RGB555 (uint8_t *dest, uint8_t *src1, uint8_t *src2, int n, int x); - -G_GNUC_INTERNAL void vs_scanline_downsample_Y16 (uint8_t *dest, uint8_t *src, int n); -G_GNUC_INTERNAL void vs_scanline_resample_nearest_Y16 (uint8_t *dest, uint8_t *src, int n, int src_width, int *accumulator, int increment); -G_GNUC_INTERNAL void vs_scanline_resample_linear_Y16 (uint8_t *dest, uint8_t *src, int n, int src_width, int *accumulator, int increment); -G_GNUC_INTERNAL void vs_scanline_merge_linear_Y16 (uint8_t *dest, uint8_t *src1, uint8_t *src2, int n, int x); - -G_GNUC_INTERNAL void vs_scanline_resample_nearest_AYUV64 (uint8_t * dest, uint8_t * src, - int src_width, int n, int *accumulator, int increment); -G_GNUC_INTERNAL void vs_scanline_resample_linear_AYUV64 (uint8_t * dest, uint8_t * src, - int src_width, int n, int *accumulator, int increment); - -#endif - diff --git a/tests/check/Makefile.am b/tests/check/Makefile.am index 9a3d639da7..625bb229bb 100644 --- a/tests/check/Makefile.am +++ b/tests/check/Makefile.am @@ -140,7 +140,7 @@ check_adder = endif if HAVE_ORC -check_orc = orc/video orc/audio orc/adder orc/audioconvert orc/volume orc/videoscale orc/videotestsrc +check_orc = orc/video orc/audio orc/adder orc/audioconvert orc/volume orc/videotestsrc else check_orc = endif @@ -230,7 +230,6 @@ check_PROGRAMS = \ $(check_typefind) \ $(check_videoconvert) \ $(check_videorate) \ - $(check_videoscale) \ $(check_videotestsrc) \ $(check_volume) \ $(check_vorbis) \ @@ -640,9 +639,6 @@ nodist_orc_audioconvert_SOURCES = orc/audioconvert.c orc_volume_CFLAGS = $(ORC_CFLAGS) orc_volume_LDADD = $(ORC_LIBS) -lorc-test-0.4 nodist_orc_volume_SOURCES = orc/volume.c -orc_videoscale_CFLAGS = $(ORC_CFLAGS) -orc_videoscale_LDADD = $(ORC_LIBS) -lorc-test-0.4 -nodist_orc_videoscale_SOURCES = orc/videoscale.c orc_videotestsrc_CFLAGS = $(ORC_CFLAGS) orc_videotestsrc_LDADD = $(ORC_LIBS) -lorc-test-0.4 nodist_orc_videotestsrc_SOURCES = orc/videotestsrc.c @@ -667,10 +663,6 @@ orc/volume.c: $(top_srcdir)/gst/volume/gstvolumeorc.orc $(MKDIR_P) orc/ $(ORCC) --test -o $@ $< -orc/videoscale.c: $(top_srcdir)/gst/videoscale/gstvideoscaleorc.orc - $(MKDIR_P) orc/ - $(ORCC) --test -o $@ $< - orc/videotestsrc.c: $(top_srcdir)/gst/videotestsrc/gstvideotestsrcorc.orc $(MKDIR_P) orc/ $(ORCC) --test -o $@ $<