g_ptr_array_remove_range (cache->lines, 0, to_remove);
}
cache->first += to_remove;
- if (cache->first < in_line)
- cache->first = in_line;
} else if (in_line < cache->first) {
gst_line_cache_clear (cache);
cache->first = in_line;
taps, convert->in_height, convert->out_height, convert->config);
gst_video_scaler_get_coeff (convert->v_scaler_i, 0, NULL, &taps_i);
- backlog = BACKLOG;
+ backlog = taps_i;
}
convert->v_scaler_p =
gst_video_scaler_new (method, 0, taps, convert->in_height,
if (!cache->pass_alloc) {
/* can't pass allocator, make new temp line allocator */
user_data =
- converter_alloc_new (sizeof (guint16) * width * 4, n_lines + BACKLOG,
- convert, NULL);
+ converter_alloc_new (sizeof (guint16) * width * 4,
+ n_lines + cache->backlog, convert, NULL);
notify = (GDestroyNotify) converter_alloc_free;
alloc_line = get_temp_line;
alloc_writable = FALSE;
params.dx = ceil (2.0 * params.envelope / params.fx);
n_taps = CLAMP (params.dx, 0, max_taps);
}
+ if (flags & GST_VIDEO_RESAMPLER_FLAG_HALF_TAPS && n_taps > 3)
+ n_taps /= 2;
params.fx = 2.0 * params.envelope / n_taps;
params.ex = 2.0 / n_taps;
/**
* GstVideoResamplerFlags:
* @GST_VIDEO_RESAMPLER_FLAG_NONE: no flags
+ * @GST_VIDEO_RESAMPLER_FLAG_HALF_TAPS: when no taps are given, half the
+ * number of calculated taps. This can be used when making scalers
+ * for the different fields of an interlaced picture. Since 1.10
*
* Different resampler flags.
*
*/
typedef enum {
GST_VIDEO_RESAMPLER_FLAG_NONE = (0),
+ GST_VIDEO_RESAMPLER_FLAG_HALF_TAPS = (1 << 0),
} GstVideoResamplerFlags;
/**
#endif
}
+#define INTERLACE_SHIFT 0.5
+
/**
* gst_video_scaler_new: (skip)
* @method: a #GstVideoResamplerMethod
if (flags & GST_VIDEO_SCALER_FLAG_INTERLACED) {
GstVideoResampler tresamp, bresamp;
+ gdouble shift;
+
+ shift = (INTERLACE_SHIFT * out_size) / in_size;
- gst_video_resampler_init (&tresamp, method, 0, (out_size + 1) / 2, n_taps,
- -0.5, (in_size + 1) / 2, (out_size + 1) / 2, options);
+ gst_video_resampler_init (&tresamp, method,
+ GST_VIDEO_RESAMPLER_FLAG_HALF_TAPS, (out_size + 1) / 2, n_taps, shift,
+ (in_size + 1) / 2, (out_size + 1) / 2, options);
n_taps = tresamp.max_taps;
gst_video_resampler_init (&bresamp, method, 0, out_size - tresamp.out_size,
- n_taps, 0.5, in_size - tresamp.in_size,
+ n_taps, -shift, in_size - tresamp.in_size,
out_size - tresamp.out_size, options);
resampler_zip (&scale->resampler, &tresamp, &bresamp);