From: <rb...@fr...> - 2005-01-29 15:47:37
|
CVS Root: /cvs/gstreamer Module: gst-plugins Changes by: rbultje Date: Sat Jan 29 2005 07:47:30 PST Log message: * gst/avi/gstavidemux.c: (gst_avi_demux_add_stream), (swap_line), (gst_avi_demux_invert), (gst_avi_demux_process_next_entry), (gst_avi_demux_stream_data): * gst/avi/gstavidemux.h: Invert DIB images. Fixes #132341. Modified files: . : ChangeLog gst/avi : gstavidemux.c gstavidemux.h Links: http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins/ChangeLog.diff?r1=1.1579&r2=1.1580 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins/gst/avi/gstavidemux.c.diff?r1=1.130&r2=1.131 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins/gst/avi/gstavidemux.h.diff?r1=1.26&r2=1.27 ====Begin Diffs==== Index: ChangeLog =================================================================== RCS file: /cvs/gstreamer/gst-plugins/ChangeLog,v retrieving revision 1.1579 retrieving revision 1.1580 diff -u -d -r1.1579 -r1.1580 --- ChangeLog 29 Jan 2005 15:24:38 -0000 1.1579 +++ ChangeLog 29 Jan 2005 15:47:17 -0000 1.1580 @@ -1,5 +1,13 @@ 2005-01-29 Ronald S. Bultje <rb...@ro...> + * gst/avi/gstavidemux.c: (gst_avi_demux_add_stream), (swap_line), + (gst_avi_demux_invert), (gst_avi_demux_process_next_entry), + (gst_avi_demux_stream_data): + * gst/avi/gstavidemux.h: + Invert DIB images. Fixes #132341. + +2005-01-29 Ronald S. Bultje <rb...@ro...> * gst/ffmpegcolorspace/gstffmpegcolorspace.c: (gst_ffmpegcsp_chain): D'oh, reference the palette data, not the palette structure. Index: gstavidemux.c RCS file: /cvs/gstreamer/gst-plugins/gst/avi/gstavidemux.c,v retrieving revision 1.130 retrieving revision 1.131 diff -u -d -r1.130 -r1.131 --- gstavidemux.c 27 Jan 2005 10:14:22 -0000 1.130 +++ gstavidemux.c 29 Jan 2005 15:47:18 -0000 1.131 @@ -884,7 +884,7 @@ GstPadTemplate *templ = NULL; GstPad *pad; avi_stream_context *stream; - gint blockalign = 0, bitrate = 0; + gint blockalign = 0, bitrate = 0, width = 0, height = 0; guint64 *locations = NULL; GstTagList *list = gst_tag_list_new (); gboolean have_tag = FALSE; @@ -1003,6 +1003,8 @@ have_tag = TRUE; g_free (codec_name); } + width = strf.vids->width; + height = strf.vids->height; g_free (strf.vids); avi->num_v_streams++; break; @@ -1076,6 +1078,8 @@ stream->skip = 0; stream->blockalign = blockalign; stream->bitrate = bitrate; + stream->width = width; + stream->height = height; stream->indexes = locations; gst_pad_set_element_private (pad, stream); avi->num_streams++; @@ -1984,6 +1988,37 @@ return TRUE; } +/* + * Invert DIB buffers... Takes existing buffer and + * returns either the buffer or a new one (with old + * one dereferenced). + */ +static inline void +swap_line (guint8 * d1, guint8 * d2, guint8 * tmp, gint bytes) +{ + memcpy (tmp, d1, bytes); + memcpy (d1, d2, bytes); + memcpy (d2, tmp, bytes); +} +static GstBuffer * +gst_avi_demux_invert (avi_stream_context * stream, GstBuffer * buf) + buf = gst_buffer_copy_on_write (buf); + gint y, h = stream->height, w = stream->width; + guint8 *tmp = g_malloc (w); + 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); + } + g_free (tmp); + return buf; static gboolean gst_avi_demux_process_next_entry (GstAviDemux * avi) { @@ -2036,6 +2071,9 @@ GST_ERROR ("Failed to read %d bytes of data", entry->size); return FALSE; } + if (stream->strh->fcc_handler == GST_MAKE_FOURCC ('D', 'I', 'B', ' ')) { + buf = gst_avi_demux_invert (stream, buf); + } if (entry->flags & GST_RIFF_IF_KEYFRAME) { GST_BUFFER_FLAG_SET (buf, GST_BUFFER_KEY_UNIT); @@ -2126,6 +2164,10 @@ } else { GstClockTime dur_ts; GST_BUFFER_TIMESTAMP (buf) = next_ts; gst_pad_query (stream->pad, GST_QUERY_POSITION, &format, &dur_ts); GST_BUFFER_DURATION (buf) = dur_ts - next_ts; Index: gstavidemux.h RCS file: /cvs/gstreamer/gst-plugins/gst/avi/gstavidemux.h,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- gstavidemux.h 12 Oct 2004 12:29:45 -0000 1.26 +++ gstavidemux.h 29 Jan 2005 15:47:18 -0000 1.27 @@ -64,6 +64,7 @@ GstCaps *caps; gst_riff_strh *strh; gint blockalign, bitrate; + gint width, height; /* current position (byte, frame, time) */ guint current_frame; |