gst/avi/gstavidemux.c: Fix DIB image inversion for pictures with a depth != 8 (#305279).

Original commit message from CVS:
* gst/avi/gstavidemux.c: (gst_avi_demux_invert):
Fix DIB image inversion for pictures with a
depth != 8 (#305279).
This commit is contained in:
Tim-Philipp Müller 2006-03-14 14:18:16 +00:00
parent 23b55c755d
commit 59bc72774d
2 changed files with 23 additions and 7 deletions

View file

@ -1,3 +1,9 @@
2006-03-14 Tim-Philipp Müller <tim at centricular dot net>
* gst/avi/gstavidemux.c: (gst_avi_demux_invert):
Fix DIB image inversion for pictures with a
depth != 8 (#305279).
2006-03-14 Tim-Philipp Müller <tim at centricular dot net>
* ext/jpeg/gstjpegdec.c: (gst_jpeg_dec_class_init),

View file

@ -2368,20 +2368,30 @@ swap_line (guint8 * d1, guint8 * d2, guint8 * tmp, gint bytes)
static GstBuffer *
gst_avi_demux_invert (avi_stream_context * stream, GstBuffer * buf)
{
gint y, h = stream->strf.vids->height, w = stream->strf.vids->width;
GstStructure *s;
gint y, h = stream->strf.vids->height;
gint bpp, stride;
guint8 *tmp = NULL;
buf = gst_buffer_make_writable (buf);
if (GST_BUFFER_SIZE (buf) < (w * h)) {
GST_WARNING ("Buffer is smaller than reported Width x Height");
s = gst_caps_get_structure (GST_PAD_CAPS (stream->pad), 0);
if (!gst_structure_get_int (s, "bpp", &bpp)) {
GST_WARNING ("Failed to retrieve depth from caps");
return buf;
}
tmp = g_malloc (w);
stride = stream->strf.vids->width * (bpp / 8);
buf = gst_buffer_make_writable (buf);
if (GST_BUFFER_SIZE (buf) < (stride * h)) {
GST_WARNING ("Buffer is smaller than reported Width x Height x Depth");
return buf;
}
tmp = g_malloc (stride);
for (y = 0; y < h / 2; y++) {
swap_line (GST_BUFFER_DATA (buf) + w * y,
GST_BUFFER_DATA (buf) + w * (h - 1 - y), tmp, w);
swap_line (GST_BUFFER_DATA (buf) + stride * y,
GST_BUFFER_DATA (buf) + stride * (h - 1 - y), tmp, stride);
}
g_free (tmp);