From 59bc72774d400dc1eace67dba5cd7601ad0f3e78 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim-Philipp=20M=C3=BCller?= Date: Tue, 14 Mar 2006 14:18:16 +0000 Subject: [PATCH] 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). --- ChangeLog | 6 ++++++ gst/avi/gstavidemux.c | 22 ++++++++++++++++------ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 552e149..2f70414 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2006-03-14 Tim-Philipp Müller + * 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 + * ext/jpeg/gstjpegdec.c: (gst_jpeg_dec_class_init), (gst_jpeg_dec_chain), (gst_jpeg_dec_change_state): * ext/jpeg/gstjpegdec.h: diff --git a/gst/avi/gstavidemux.c b/gst/avi/gstavidemux.c index 68f447c..7bc478a 100644 --- a/gst/avi/gstavidemux.c +++ b/gst/avi/gstavidemux.c @@ -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; + 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; + } + + stride = stream->strf.vids->width * (bpp / 8); + buf = gst_buffer_make_writable (buf); - if (GST_BUFFER_SIZE (buf) < (w * h)) { - GST_WARNING ("Buffer is smaller than reported Width x Height"); + if (GST_BUFFER_SIZE (buf) < (stride * h)) { + GST_WARNING ("Buffer is smaller than reported Width x Height x Depth"); return buf; } - tmp = g_malloc (w); + 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); -- 2.7.4