diff options
author | Tim-Philipp Müller <tim@centricular.net> | 2006-03-14 14:18:16 +0000 |
---|---|---|
committer | Tim-Philipp Müller <tim@centricular.net> | 2006-03-14 14:18:16 +0000 |
commit | 59bc72774d400dc1eace67dba5cd7601ad0f3e78 (patch) | |
tree | 73a3de5032ffb1369c849ef426f4c9acd728be8c /gst/avi | |
parent | 23b55c755d97d9b078751b4899ae5cc46fa1c16a (diff) |
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).
Diffstat (limited to 'gst/avi')
-rw-r--r-- | gst/avi/gstavidemux.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/gst/avi/gstavidemux.c b/gst/avi/gstavidemux.c index 68f447ce..7bc478a4 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); |