summaryrefslogtreecommitdiffstats
path: root/abs/extra/community/gstreamer0.10-base/ayuv64-lanczos.patch
blob: 64106e46506e01bb7d387075cd4a7d07ae7629e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
From e4f01106d08f3c2a65897bfe919bd65ce55545a8 Mon Sep 17 00:00:00 2001
From: David Schleef <ds@schleef.org>
Date: Wed, 25 Jan 2012 23:49:00 +0000
Subject: videoscale: Add AYUV64 path to Lanczos

---
diff --git a/gst/videoscale/gstvideoscale.c b/gst/videoscale/gstvideoscale.c
index 7b44647..6df4ba6 100644
--- a/gst/videoscale/gstvideoscale.c
+++ b/gst/videoscale/gstvideoscale.c
@@ -1199,6 +1199,11 @@ gst_video_scale_transform (GstBaseTransform * trans, GstBuffer * in,
         case GST_VIDEO_SCALE_4TAP:
           vs_image_scale_4tap_AYUV64 (&dest, &src, videoscale->tmp_buf);
           break;
+        case GST_VIDEO_SCALE_LANCZOS:
+          vs_image_scale_lanczos_AYUV64 (&dest, &src, videoscale->tmp_buf,
+              videoscale->sharpness, videoscale->dither, videoscale->submethod,
+              videoscale->envelope, videoscale->sharpen);
+          break;
         default:
           goto unknown_mode;
       }
diff --git a/gst/videoscale/vs_image.h b/gst/videoscale/vs_image.h
index 2312acc..7b34991 100644
--- a/gst/videoscale/vs_image.h
+++ b/gst/videoscale/vs_image.h
@@ -52,6 +52,9 @@ void vs_image_scale_linear_RGBA (const VSImage *dest, const VSImage *src,
 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);
+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);
 
 void vs_image_scale_nearest_RGB (const VSImage *dest, const VSImage *src,
     uint8_t *tmpbuf);
diff --git a/gst/videoscale/vs_lanczos.c b/gst/videoscale/vs_lanczos.c
index 1c87ba3..d141a01 100644
--- a/gst/videoscale/vs_lanczos.c
+++ b/gst/videoscale/vs_lanczos.c
@@ -204,6 +204,9 @@ static void vs_image_scale_lanczos_AYUV_float (const VSImage * dest,
 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 double
 sinc (double x)
@@ -590,6 +593,15 @@ vs_image_scale_lanczos_AYUV (const VSImage * dest, const VSImage * src,
   }
 }
 
+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) \
@@ -813,9 +825,9 @@ RESAMPLE_VERT_DITHER (resample_vert_dither_int16_generic, gint16, gint16,
     n_taps, shift)
 /* *INDENT-ON* */
 
-#define RESAMPLE_VERT_FLOAT(function, tap_type, src_type, _n_taps, _shift) \
+#define RESAMPLE_VERT_FLOAT(function, dest_type, clamp, tap_type, src_type, _n_taps, _shift) \
 static void \
-function (guint8 *dest, \
+function (dest_type *dest, \
     const tap_type *taps, const src_type *src, int stride, int n_taps, \
     int shift, int n) \
 { \
@@ -828,13 +840,13 @@ function (guint8 *dest, \
       const src_type *line = PTR_OFFSET(src, stride * l); \
       sum_y += line[i] * taps[l]; \
     } \
-    dest[i] = CLAMP (floor(0.5 + sum_y), 0, 255); \
+    dest[i] = CLAMP (floor(0.5 + sum_y), 0, clamp); \
   } \
 }
 
-#define RESAMPLE_VERT_FLOAT_DITHER(function, tap_type, src_type, _n_taps, _shift) \
+#define RESAMPLE_VERT_FLOAT_DITHER(function, dest_type, clamp, tap_type, src_type, _n_taps, _shift) \
 static void \
-function (guint8 *dest, \
+function (dest_type *dest, \
     const tap_type *taps, const src_type *src, int stride, int n_taps, \
     int shift, int n) \
 { \
@@ -849,19 +861,24 @@ function (guint8 *dest, \
       sum_y += line[i] * taps[l]; \
     } \
     err_y += sum_y; \
-    dest[i] = CLAMP (floor (err_y), 0, 255); \
+    dest[i] = CLAMP (floor (err_y), 0, clamp); \
     err_y -= floor (err_y); \
   } \
 }
 
 /* *INDENT-OFF* */
-RESAMPLE_VERT_FLOAT (resample_vert_double_generic, double, double, n_taps,
+RESAMPLE_VERT_FLOAT (resample_vert_double_generic, guint8, 255, double, double, n_taps,
     shift)
-RESAMPLE_VERT_FLOAT_DITHER (resample_vert_dither_double_generic, double, double,
+RESAMPLE_VERT_FLOAT_DITHER (resample_vert_dither_double_generic, guint8, 255, double, double,
     n_taps, shift)
 
-RESAMPLE_VERT_FLOAT (resample_vert_float_generic, float, float, n_taps, shift)
-RESAMPLE_VERT_FLOAT_DITHER (resample_vert_dither_float_generic, float, float,
+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* */
 
@@ -1556,3 +1573,77 @@ vs_image_scale_lanczos_AYUV_float (const VSImage * dest, const VSImage * src,
   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;
+
+  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);
+}
--
cgit v0.9.0.2-2-gbebe
From f8dc679ca7e9542e6f410062df5e332fc8e0ba9d Mon Sep 17 00:00:00 2001
From: David Schleef <ds@schleef.org>
Date: Sun, 19 Feb 2012 08:03:03 +0000
Subject: videoscale: fix AYUV64 scaling

---
diff --git a/gst/videoscale/vs_lanczos.c b/gst/videoscale/vs_lanczos.c
index d141a01..67cd401 100644
--- a/gst/videoscale/vs_lanczos.c
+++ b/gst/videoscale/vs_lanczos.c
@@ -728,6 +728,9 @@ RESAMPLE_HORIZ_AYUV_FLOAT (resample_horiz_double_ayuv_generic, double, double,
 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 (resample_horiz_int32_int32_u8_generic, gint32, gint32,
     guint8, n_taps, shift)
 RESAMPLE_HORIZ (resample_horiz_int16_int16_u8_generic, gint16, gint16,
@@ -1636,7 +1639,7 @@ vs_image_scale_lanczos_AYUV64_double (const VSImage * dest, const VSImage * src,
   scale->dither = dither;
 
   scale->horiz_resample_func =
-      (HorizResampleFunc) resample_horiz_double_ayuv_generic;
+      (HorizResampleFunc) resample_horiz_double_ayuv_generic_s16;
 
   scale->tmpdata =
       g_malloc (sizeof (double) * scale->dest->width * scale->src->height * 4);
--
cgit v0.9.0.2-2-gbebe