02-ayuv64-lanczos.patch 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. From e4f01106d08f3c2a65897bfe919bd65ce55545a8 Mon Sep 17 00:00:00 2001
  2. From: David Schleef <ds@schleef.org>
  3. Date: Wed, 25 Jan 2012 23:49:00 +0000
  4. Subject: videoscale: Add AYUV64 path to Lanczos
  5. ---
  6. diff --git a/gst/videoscale/gstvideoscale.c b/gst/videoscale/gstvideoscale.c
  7. index 7b44647..6df4ba6 100644
  8. --- a/gst/videoscale/gstvideoscale.c
  9. +++ b/gst/videoscale/gstvideoscale.c
  10. @@ -1199,6 +1199,11 @@ gst_video_scale_transform (GstBaseTransform * trans, GstBuffer * in,
  11. case GST_VIDEO_SCALE_4TAP:
  12. vs_image_scale_4tap_AYUV64 (&dest, &src, videoscale->tmp_buf);
  13. break;
  14. + case GST_VIDEO_SCALE_LANCZOS:
  15. + vs_image_scale_lanczos_AYUV64 (&dest, &src, videoscale->tmp_buf,
  16. + videoscale->sharpness, videoscale->dither, videoscale->submethod,
  17. + videoscale->envelope, videoscale->sharpen);
  18. + break;
  19. default:
  20. goto unknown_mode;
  21. }
  22. diff --git a/gst/videoscale/vs_image.h b/gst/videoscale/vs_image.h
  23. index 2312acc..7b34991 100644
  24. --- a/gst/videoscale/vs_image.h
  25. +++ b/gst/videoscale/vs_image.h
  26. @@ -52,6 +52,9 @@ void vs_image_scale_linear_RGBA (const VSImage *dest, const VSImage *src,
  27. void vs_image_scale_lanczos_AYUV (const VSImage * dest, const VSImage * src,
  28. uint8_t * tmpbuf, double sharpness, gboolean dither, int submethod,
  29. double a, double sharpen);
  30. +void vs_image_scale_lanczos_AYUV64 (const VSImage * dest, const VSImage * src,
  31. + uint8_t * tmpbuf, double sharpness, gboolean dither, int submethod,
  32. + double a, double sharpen);
  33. void vs_image_scale_nearest_RGB (const VSImage *dest, const VSImage *src,
  34. uint8_t *tmpbuf);
  35. diff --git a/gst/videoscale/vs_lanczos.c b/gst/videoscale/vs_lanczos.c
  36. index 1c87ba3..d141a01 100644
  37. --- a/gst/videoscale/vs_lanczos.c
  38. +++ b/gst/videoscale/vs_lanczos.c
  39. @@ -204,6 +204,9 @@ static void vs_image_scale_lanczos_AYUV_float (const VSImage * dest,
  40. static void vs_image_scale_lanczos_AYUV_double (const VSImage * dest,
  41. const VSImage * src, uint8_t * tmpbuf, double sharpness, gboolean dither,
  42. double a, double sharpen);
  43. +static void vs_image_scale_lanczos_AYUV64_double (const VSImage * dest,
  44. + const VSImage * src, uint8_t * tmpbuf, double sharpness, gboolean dither,
  45. + double a, double sharpen);
  46. static double
  47. sinc (double x)
  48. @@ -590,6 +593,15 @@ vs_image_scale_lanczos_AYUV (const VSImage * dest, const VSImage * src,
  49. }
  50. }
  51. +void
  52. +vs_image_scale_lanczos_AYUV64 (const VSImage * dest, const VSImage * src,
  53. + uint8_t * tmpbuf, double sharpness, gboolean dither, int submethod,
  54. + double a, double sharpen)
  55. +{
  56. + vs_image_scale_lanczos_AYUV64_double (dest, src, tmpbuf, sharpness, dither,
  57. + a, sharpen);
  58. +}
  59. +
  60. #define RESAMPLE_HORIZ_FLOAT(function, dest_type, tap_type, src_type, _n_taps) \
  61. @@ -813,9 +825,9 @@ RESAMPLE_VERT_DITHER (resample_vert_dither_int16_generic, gint16, gint16,
  62. n_taps, shift)
  63. /* *INDENT-ON* */
  64. -#define RESAMPLE_VERT_FLOAT(function, tap_type, src_type, _n_taps, _shift) \
  65. +#define RESAMPLE_VERT_FLOAT(function, dest_type, clamp, tap_type, src_type, _n_taps, _shift) \
  66. static void \
  67. -function (guint8 *dest, \
  68. +function (dest_type *dest, \
  69. const tap_type *taps, const src_type *src, int stride, int n_taps, \
  70. int shift, int n) \
  71. { \
  72. @@ -828,13 +840,13 @@ function (guint8 *dest, \
  73. const src_type *line = PTR_OFFSET(src, stride * l); \
  74. sum_y += line[i] * taps[l]; \
  75. } \
  76. - dest[i] = CLAMP (floor(0.5 + sum_y), 0, 255); \
  77. + dest[i] = CLAMP (floor(0.5 + sum_y), 0, clamp); \
  78. } \
  79. }
  80. -#define RESAMPLE_VERT_FLOAT_DITHER(function, tap_type, src_type, _n_taps, _shift) \
  81. +#define RESAMPLE_VERT_FLOAT_DITHER(function, dest_type, clamp, tap_type, src_type, _n_taps, _shift) \
  82. static void \
  83. -function (guint8 *dest, \
  84. +function (dest_type *dest, \
  85. const tap_type *taps, const src_type *src, int stride, int n_taps, \
  86. int shift, int n) \
  87. { \
  88. @@ -849,19 +861,24 @@ function (guint8 *dest, \
  89. sum_y += line[i] * taps[l]; \
  90. } \
  91. err_y += sum_y; \
  92. - dest[i] = CLAMP (floor (err_y), 0, 255); \
  93. + dest[i] = CLAMP (floor (err_y), 0, clamp); \
  94. err_y -= floor (err_y); \
  95. } \
  96. }
  97. /* *INDENT-OFF* */
  98. -RESAMPLE_VERT_FLOAT (resample_vert_double_generic, double, double, n_taps,
  99. +RESAMPLE_VERT_FLOAT (resample_vert_double_generic, guint8, 255, double, double, n_taps,
  100. shift)
  101. -RESAMPLE_VERT_FLOAT_DITHER (resample_vert_dither_double_generic, double, double,
  102. +RESAMPLE_VERT_FLOAT_DITHER (resample_vert_dither_double_generic, guint8, 255, double, double,
  103. n_taps, shift)
  104. -RESAMPLE_VERT_FLOAT (resample_vert_float_generic, float, float, n_taps, shift)
  105. -RESAMPLE_VERT_FLOAT_DITHER (resample_vert_dither_float_generic, float, float,
  106. +RESAMPLE_VERT_FLOAT (resample_vert_double_generic_u16, guint16, 65535, double, double, n_taps,
  107. + shift)
  108. +RESAMPLE_VERT_FLOAT_DITHER (resample_vert_dither_double_generic_u16, guint16, 65535, double, double,
  109. + n_taps, shift)
  110. +
  111. +RESAMPLE_VERT_FLOAT (resample_vert_float_generic, guint8, 255, float, float, n_taps, shift)
  112. +RESAMPLE_VERT_FLOAT_DITHER (resample_vert_dither_float_generic, guint8, 255, float, float,
  113. n_taps, shift)
  114. /* *INDENT-ON* */
  115. @@ -1556,3 +1573,77 @@ vs_image_scale_lanczos_AYUV_float (const VSImage * dest, const VSImage * src,
  116. scale1d_cleanup (&scale->y_scale1d);
  117. g_free (scale->tmpdata);
  118. }
  119. +
  120. +static void
  121. +vs_scale_lanczos_AYUV64_double (Scale * scale)
  122. +{
  123. + int j;
  124. + int yi;
  125. + int tmp_yi;
  126. +
  127. + tmp_yi = 0;
  128. +
  129. + for (j = 0; j < scale->dest->height; j++) {
  130. + guint16 *destline;
  131. + double *taps;
  132. +
  133. + destline = (guint16 *) (scale->dest->pixels + scale->dest->stride * j);
  134. +
  135. + yi = scale->y_scale1d.offsets[j];
  136. +
  137. + while (tmp_yi < yi + scale->y_scale1d.n_taps) {
  138. + scale->horiz_resample_func (TMP_LINE_DOUBLE_AYUV (tmp_yi),
  139. + scale->x_scale1d.offsets, scale->x_scale1d.taps, SRC_LINE (tmp_yi),
  140. + scale->x_scale1d.n_taps, 0, scale->dest->width);
  141. + tmp_yi++;
  142. + }
  143. +
  144. + taps = (double *) scale->y_scale1d.taps + j * scale->y_scale1d.n_taps;
  145. + if (scale->dither) {
  146. + resample_vert_dither_double_generic_u16 (destline,
  147. + taps, TMP_LINE_DOUBLE_AYUV (scale->y_scale1d.offsets[j]),
  148. + sizeof (double) * 4 * scale->dest->width,
  149. + scale->y_scale1d.n_taps, 0, scale->dest->width * 4);
  150. + } else {
  151. + resample_vert_double_generic_u16 (destline,
  152. + taps, TMP_LINE_DOUBLE_AYUV (scale->y_scale1d.offsets[j]),
  153. + sizeof (double) * 4 * scale->dest->width,
  154. + scale->y_scale1d.n_taps, 0, scale->dest->width * 4);
  155. + }
  156. + }
  157. +}
  158. +
  159. +void
  160. +vs_image_scale_lanczos_AYUV64_double (const VSImage * dest, const VSImage * src,
  161. + uint8_t * tmpbuf, double sharpness, gboolean dither, double a,
  162. + double sharpen)
  163. +{
  164. + Scale s = { 0 };
  165. + Scale *scale = &s;
  166. + int n_taps;
  167. +
  168. + scale->dest = dest;
  169. + scale->src = src;
  170. +
  171. + n_taps = scale1d_get_n_taps (src->width, dest->width, a, sharpness);
  172. + scale1d_calculate_taps (&scale->x_scale1d,
  173. + src->width, dest->width, n_taps, a, sharpness, sharpen);
  174. +
  175. + n_taps = scale1d_get_n_taps (src->height, dest->height, a, sharpness);
  176. + scale1d_calculate_taps (&scale->y_scale1d,
  177. + src->height, dest->height, n_taps, a, sharpness, sharpen);
  178. +
  179. + scale->dither = dither;
  180. +
  181. + scale->horiz_resample_func =
  182. + (HorizResampleFunc) resample_horiz_double_ayuv_generic;
  183. +
  184. + scale->tmpdata =
  185. + g_malloc (sizeof (double) * scale->dest->width * scale->src->height * 4);
  186. +
  187. + vs_scale_lanczos_AYUV64_double (scale);
  188. +
  189. + scale1d_cleanup (&scale->x_scale1d);
  190. + scale1d_cleanup (&scale->y_scale1d);
  191. + g_free (scale->tmpdata);
  192. +}
  193. --
  194. cgit v0.9.0.2-2-gbebe
  195. From f8dc679ca7e9542e6f410062df5e332fc8e0ba9d Mon Sep 17 00:00:00 2001
  196. From: David Schleef <ds@schleef.org>
  197. Date: Sun, 19 Feb 2012 08:03:03 +0000
  198. Subject: videoscale: fix AYUV64 scaling
  199. ---
  200. diff --git a/gst/videoscale/vs_lanczos.c b/gst/videoscale/vs_lanczos.c
  201. index d141a01..67cd401 100644
  202. --- a/gst/videoscale/vs_lanczos.c
  203. +++ b/gst/videoscale/vs_lanczos.c
  204. @@ -728,6 +728,9 @@ RESAMPLE_HORIZ_AYUV_FLOAT (resample_horiz_double_ayuv_generic, double, double,
  205. RESAMPLE_HORIZ_AYUV_FLOAT (resample_horiz_float_ayuv_generic, float, float,
  206. guint8, n_taps)
  207. +RESAMPLE_HORIZ_AYUV_FLOAT (resample_horiz_double_ayuv_generic_s16, double, double,
  208. + guint16, n_taps)
  209. +
  210. RESAMPLE_HORIZ (resample_horiz_int32_int32_u8_generic, gint32, gint32,
  211. guint8, n_taps, shift)
  212. RESAMPLE_HORIZ (resample_horiz_int16_int16_u8_generic, gint16, gint16,
  213. @@ -1636,7 +1639,7 @@ vs_image_scale_lanczos_AYUV64_double (const VSImage * dest, const VSImage * src,
  214. scale->dither = dither;
  215. scale->horiz_resample_func =
  216. - (HorizResampleFunc) resample_horiz_double_ayuv_generic;
  217. + (HorizResampleFunc) resample_horiz_double_ayuv_generic_s16;
  218. scale->tmpdata =
  219. g_malloc (sizeof (double) * scale->dest->width * scale->src->height * 4);
  220. --
  221. cgit v0.9.0.2-2-gbebe