From 49d909dabf986206ea03f1d2d74b4676212057be Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 30 Oct 2014 11:46:14 +0100 Subject: [PATCH] video-scaler: add more ORC functions Add the old ORC functions for nearest and linear. Label them as Low quality because they are not as accurate but ORC lacks opcodes to express this for now. --- gst-libs/gst/video/video-orc.orc | 16 +++++++++++++++ gst-libs/gst/video/video-scaler.c | 41 +++++++++++++++++++++++++++++++++------ 2 files changed, 51 insertions(+), 6 deletions(-) diff --git a/gst-libs/gst/video/video-orc.orc b/gst-libs/gst/video/video-orc.orc index fff75af..24e7f66 100644 --- a/gst-libs/gst/video/video-orc.orc +++ b/gst-libs/gst/video/video-orc.orc @@ -1294,6 +1294,14 @@ x4 addb ayuv, ayuv2, c128 #loadidxl t, src, idx #storel dest, t +.function video_orc_resample_h_near_8888_lq +.dest 4 d1 guint32 +.source 4 s1 guint32 +.param 4 p1 +.param 4 p2 + +ldresnearl d1, s1, p1, p2 + #.function video_orc_resample_h_2tap_8888_16 #.source 4 src1 guint32 #.source 4 src2 guint32 @@ -1339,6 +1347,14 @@ x4 addb ayuv, ayuv2, c128 #x4 convhwb t2, q2 #x4 addb dest, t2, t1 +.function video_orc_resample_h_2tap_8888_lq +.dest 4 d1 guint32 +.source 4 s1 guint32 +.param 4 p1 +.param 4 p2 + +ldreslinl d1, s1, p1, p2 + .function video_orc_resample_v_2tap_8_lq .source 1 src1 guint32 .source 1 src2 guint32 diff --git a/gst-libs/gst/video/video-scaler.c b/gst-libs/gst/video/video-scaler.c index 7401911..74d31e6 100644 --- a/gst-libs/gst/video/video-scaler.c +++ b/gst-libs/gst/video/video-scaler.c @@ -48,6 +48,8 @@ struct _GstVideoScaler /* cached integer coefficients */ gint16 *taps_s16; + /* for ORC */ + gint inc; }; static void @@ -139,6 +141,12 @@ gst_video_scaler_new (GstVideoResamplerMethod method, GstVideoScalerFlags flags, gst_video_resampler_init (&scale->resampler, method, flags, out_size, n_taps, 0.0, in_size, out_size, options); } + + if (out_size == 1) + scale->inc = 0; + else + scale->inc = ((in_size - 1) << 16) / (out_size - 1) - 1; + return scale; } @@ -272,19 +280,27 @@ static void video_scale_h_near_8888 (GstVideoScaler * scale, gpointer src, gpointer dest, guint dest_offset, guint width) { - gint i; guint32 *s, *d; - guint32 *offset; - - offset = scale->resampler.offset + dest_offset; d = (guint32 *) dest + dest_offset; s = (guint32 *) src; - for (i = 0; i < width; i++) - d[i] = s[offset[i]]; +#if 0 + /* ORC is slower on this */ + video_orc_resample_h_near_8888_lq (d, s, 0, scale->inc, width); +#else + { + gint i; + guint32 *offset; + + offset = scale->resampler.offset + dest_offset; + for (i = 0; i < width; i++) + d[i] = s[offset[i]]; + } +#endif } +#if 0 #define BLEND_2TAP(a,b,p) (((((b)-(guint16)(a)) * p + S16_SCALE_ROUND) >> S16_SCALE) + (a)) static void @@ -322,6 +338,19 @@ video_scale_h_2tap_8888 (GstVideoScaler * scale, d[i * 4 + 3] = CLAMP (sum3, 0, 255); } } +#endif + +static void +video_scale_h_2tap_8888 (GstVideoScaler * scale, + gpointer src, gpointer dest, guint dest_offset, guint width) +{ + guint32 *s, *d; + + d = (guint32 *) dest + dest_offset; + s = (guint32 *) src; + + video_orc_resample_h_2tap_8888_lq (d, s, 0, scale->inc, width); +} static void video_scale_h_ntap_8888 (GstVideoScaler * scale, -- 2.7.4