guint16 *errline;
guint tmplines_idx;
+ guint n_btmplines;
+ gpointer *btmplines;
+ guint btmplines_idx;
+
gboolean fill_border;
gpointer borderline;
guint32 border_argb;
gint in_line, gpointer user_data);
static void
-alloc_tmplines (GstVideoConverter * convert, guint lines, gint width)
+alloc_tmplines (GstVideoConverter * convert, guint lines, guint blines,
+ gint width)
{
gint i;
convert->n_tmplines = lines;
convert->tmplines = g_malloc (lines * sizeof (gpointer));
- for (i = 0; i < lines; i++) {
+ for (i = 0; i < lines; i++)
convert->tmplines[i] = g_malloc (sizeof (guint16) * (width + 8) * 4);
+ convert->tmplines_idx = 0;
+
+ convert->n_btmplines = blines;
+ convert->btmplines = g_malloc (blines * sizeof (gpointer));
+ for (i = 0; i < blines; i++) {
+ convert->btmplines[i] = g_malloc (sizeof (guint16) * (width + 8) * 4);
if (convert->borderline)
- memcpy (convert->tmplines[i], convert->borderline, width * 8);
+ memcpy (convert->btmplines[i], convert->borderline, width * 8);
}
- convert->tmplines_idx = 0;
+ convert->btmplines_idx = 0;
}
static gpointer
return tmpline;
}
+static gpointer
+get_border_temp_line (GstLineCache * cache, gint idx, gpointer user_data)
+{
+ GstVideoConverter *convert = user_data;
+ gpointer tmpline;
+
+ GST_DEBUG ("get border temp line %d", idx);
+ tmpline = (guint8 *) convert->btmplines[convert->btmplines_idx] +
+ (convert->out_x * convert->pack_pstride);
+ convert->btmplines_idx = (convert->btmplines_idx + 1) % convert->n_btmplines;
+
+ return tmpline;
+}
+
static GstLineCache *
chain_unpack_line (GstVideoConverter * convert)
{
if (convert->identity_pack)
alloc_line = get_dest_line;
else
- alloc_line = get_temp_line;
+ alloc_line = get_border_temp_line;
/* now walk backwards, we try to write into the dest lines directly
* and keep track if the source needs to be writable */
}
/* FIXME */
- alloc_tmplines (convert, 64, width);
+ alloc_tmplines (convert, 64, 4, width);
done:
return convert;
for (i = 0; i < convert->n_tmplines; i++)
g_free (convert->tmplines[i]);
g_free (convert->tmplines);
+ for (i = 0; i < convert->n_btmplines; i++)
+ g_free (convert->btmplines[i]);
+ g_free (convert->btmplines);
g_free (convert->errline);
g_free (convert->borderline);
{
GstVideoConverter *convert = user_data;
guint8 *line;
+ gint pstride = convert->pack_pstride;
+ gint out_x = convert->out_x;
GST_DEBUG ("get dest line %d", idx);
line = FRAME_GET_LINE (convert->dest, idx);
- line += convert->out_x * convert->pack_pstride;
+
+ if (convert->borderline) {
+ gint r_border = (out_x + convert->out_width) * pstride;
+ gint rb_width = convert->out_maxwidth * pstride - r_border;
+ gint lb_width = out_x * pstride;
+
+ memcpy (line, convert->borderline, lb_width);
+ memcpy (line + r_border, convert->borderline, rb_width);
+ }
+ line += out_x * pstride;
+
return line;
}
gint out_maxwidth, out_maxheight;
gint out_x, out_y, out_height;
gint pack_lines, pstride;
- gint r_border, out_width, lb_width, rb_width;
+ gint lb_width;
- out_width = convert->out_width;
out_height = convert->out_height;
out_maxwidth = convert->out_maxwidth;
out_maxheight = convert->out_maxheight;
pack_lines = convert->lines; /* only 1 for now */
pstride = convert->pack_pstride;
- r_border = (out_x + out_width) * pstride;
- rb_width = out_maxwidth * pstride - r_border;
lb_width = out_x * pstride;
if (convert->borderline) {
for (i = 0; i < out_height; i += pack_lines) {
gpointer *lines;
- guint8 *l;
/* load the lines needed to pack */
- lines =
- gst_line_cache_get_lines (convert->pack_lines, i + out_y, i,
- pack_lines);
-
- /* take away the border */
- l = ((guint8 *) lines[0]) - lb_width;
-
- if (convert->borderline) {
- /* FIXME this can be optimized if we make separate temp lines with
- * border for the output lines */
- memcpy (l, convert->borderline, lb_width);
- memcpy (l + r_border, convert->borderline, rb_width);
- }
+ lines = gst_line_cache_get_lines (convert->pack_lines, i + out_y,
+ i, pack_lines);
+
if (!convert->identity_pack) {
+ /* take away the border */
+ guint8 *l = ((guint8 *) lines[0]) - lb_width;
/* and pack into destination */
GST_DEBUG ("pack line %d", i + out_y);
PACK_FRAME (dest, l, i + out_y, out_maxwidth);
if (transforms[i].needs_color_matrix)
video_converter_compute_matrix (convert);
convert->convert = transforms[i].convert;
- alloc_tmplines (convert, 1, GST_VIDEO_INFO_WIDTH (&convert->in_info));
+ alloc_tmplines (convert, 1, 0, GST_VIDEO_INFO_WIDTH (&convert->in_info));
return TRUE;
}
}