From: <wt...@ke...> - 2006-02-28 10:22:28
|
CVS Root: /cvs/gstreamer Module: gst-plugins-good Changes by: wtay Date: Tue Feb 28 2006 10:22:23 UTC Log message: * docs/plugins/Makefile.am: * docs/plugins/gst-plugins-good-plugins-docs.sgml: * docs/plugins/gst-plugins-good-plugins-sections.txt: Added dvdec and dvdemux to docs. * ext/dv/gstdvdec.c: (gst_dvdec_base_init), (gst_dvdec_chain): Added docs. Check frame sizes so we don't crash when don't have enough data. Send nice error messages on error. * ext/dv/gstdvdemux.c: (gst_dvdemux_base_init), (gst_dvdemux_class_init), (gst_dvdemux_init), (gst_dvdemux_finalize), (gst_dvdemux_reset), (gst_dvdemux_src_convert), (gst_dvdemux_sink_convert), (gst_dvdemux_src_query), (gst_dvdemux_sink_query), (gst_dvdemux_push_event), (gst_dvdemux_handle_sink_event), (gst_dvdemux_convert_src_pair), (gst_dvdemux_convert_sink_pair), (gst_dvdemux_convert_src_to_sink), (gst_dvdemux_handle_push_seek), (gst_dvdemux_do_seek), (gst_dvdemux_handle_pull_seek), (gst_dvdemux_handle_src_event), (gst_dvdemux_demux_audio), (gst_dvdemux_demux_video), (gst_dvdemux_demux_frame), (gst_dvdemux_flush), (gst_dvdemux_chain), (gst_dvdemux_loop), (gst_dvdemux_sink_activate_push), (gst_dvdemux_sink_activate_pull), (gst_dvdemux_sink_activate), (gst_dvdemux_change_state): * ext/dv/gstdvdemux.h: Added docs. Implement pull mode. Fix memleaks. Reduce memcpy for the video demuxing. Modified files: . : ChangeLog docs/plugins : Makefile.am gst-plugins-good-plugins-docs.sgml gst-plugins-good-plugins-sections.txt ext/dv : gstdvdec.c gstdvdemux.c gstdvdemux.h Links: http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/ChangeLog.diff?r1=1.2187&r2=1.2188 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/docs/plugins/Makefile.am.diff?r1=1.16&r2=1.17 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/docs/plugins/gst-plugins-good-plugins-docs.sgml.diff?r1=1.17&r2=1.18 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/docs/plugins/gst-plugins-good-plugins-sections.txt.diff?r1=1.15&r2=1.16 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/ext/dv/gstdvdec.c.diff?r1=1.99&r2=1.100 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/ext/dv/gstdvdemux.c.diff?r1=1.19&r2=1.20 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/ext/dv/gstdvdemux.h.diff?r1=1.5&r2=1.6 ====Begin Diffs==== Index: ChangeLog =================================================================== RCS file: /cvs/gstreamer/gst-plugins-good/ChangeLog,v retrieving revision 1.2187 retrieving revision 1.2188 diff -u -d -r1.2187 -r1.2188 --- ChangeLog 28 Feb 2006 09:21:27 -0000 1.2187 +++ ChangeLog 28 Feb 2006 10:22:11 -0000 1.2188 @@ -1,3 +1,36 @@ +2006-02-28 Wim Taymans <wi...@fl...> + + * docs/plugins/Makefile.am: + * docs/plugins/gst-plugins-good-plugins-docs.sgml: + * docs/plugins/gst-plugins-good-plugins-sections.txt: + Added dvdec and dvdemux to docs. + * ext/dv/gstdvdec.c: (gst_dvdec_base_init), (gst_dvdec_chain): + Added docs. + Check frame sizes so we don't crash when don't have enough + data. + Send nice error messages on error. + * ext/dv/gstdvdemux.c: (gst_dvdemux_base_init), + (gst_dvdemux_class_init), (gst_dvdemux_init), + (gst_dvdemux_finalize), (gst_dvdemux_reset), + (gst_dvdemux_src_convert), (gst_dvdemux_sink_convert), + (gst_dvdemux_src_query), (gst_dvdemux_sink_query), + (gst_dvdemux_push_event), (gst_dvdemux_handle_sink_event), + (gst_dvdemux_convert_src_pair), (gst_dvdemux_convert_sink_pair), + (gst_dvdemux_convert_src_to_sink), (gst_dvdemux_handle_push_seek), + (gst_dvdemux_do_seek), (gst_dvdemux_handle_pull_seek), + (gst_dvdemux_handle_src_event), (gst_dvdemux_demux_audio), + (gst_dvdemux_demux_video), (gst_dvdemux_demux_frame), + (gst_dvdemux_flush), (gst_dvdemux_chain), (gst_dvdemux_loop), + (gst_dvdemux_sink_activate_push), (gst_dvdemux_sink_activate_pull), + (gst_dvdemux_sink_activate), (gst_dvdemux_change_state): + * ext/dv/gstdvdemux.h: + Implement pull mode. + Fix memleaks. + Reduce memcpy for the video demuxing. 2006-02-28 Jan Schmidt <th...@ma...> * ext/annodex/gstcmmldec.c: (gst_cmml_dec_sink_event), Index: Makefile.am RCS file: /cvs/gstreamer/gst-plugins-good/docs/plugins/Makefile.am,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- Makefile.am 16 Feb 2006 14:13:47 -0000 1.16 +++ Makefile.am 28 Feb 2006 10:22:11 -0000 1.17 @@ -82,6 +82,8 @@ $(top_srcdir)/gst/id3demux/gstid3demux.h \ $(top_srcdir)/ext/cairo/gsttimeoverlay.h \ $(top_srcdir)/ext/cdio/gstcdiocddasrc.h \ + $(top_srcdir)/ext/dv/gstdvdec.h \ + $(top_srcdir)/ext/dv/gstdvdemux.h \ $(top_srcdir)/ext/flac/gstflacdec.h \ $(top_srcdir)/ext/hal/gsthalaudiosink.h \ $(top_srcdir)/ext/hal/gsthalaudiosrc.h \ Index: gst-plugins-good-plugins-docs.sgml RCS file: /cvs/gstreamer/gst-plugins-good/docs/plugins/gst-plugins-good-plugins-docs.sgml,v retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- gst-plugins-good-plugins-docs.sgml 16 Feb 2006 14:13:47 -0000 1.17 +++ gst-plugins-good-plugins-docs.sgml 28 Feb 2006 10:22:11 -0000 1.18 @@ -17,6 +17,8 @@ <xi:include href="xml/element-autovideosink.xml" /> <xi:include href="xml/element-cairotimeoverlay.xml" /> <xi:include href="xml/element-cdiocddasrc.xml" /> + <xi:include href="xml/element-dvdec.xml" /> + <xi:include href="xml/element-dvdemux.xml" /> <xi:include href="xml/element-flacdec.xml" /> <xi:include href="xml/element-goom.xml" /> <xi:include href="xml/element-halaudiosink.xml" /> Index: gst-plugins-good-plugins-sections.txt RCS file: /cvs/gstreamer/gst-plugins-good/docs/plugins/gst-plugins-good-plugins-sections.txt,v retrieving revision 1.15 diff -u -d -r1.15 -r1.16 --- gst-plugins-good-plugins-sections.txt 24 Feb 2006 19:07:09 -0000 1.15 +++ gst-plugins-good-plugins-sections.txt 28 Feb 2006 10:22:11 -0000 1.16 @@ -47,6 +47,22 @@ </SECTION> <SECTION> +<FILE>element-dvdec</FILE> +GstDVDec +<TITLE>dvdec</TITLE> +<SUBSECTION Standard> +GstDVDecClass +</SECTION> +<SECTION> +<FILE>element-dvdemux</FILE> +GstDVDemux +<TITLE>dvdemux</TITLE> +GstDVDemuxClass <FILE>element-flacdec</FILE> GstFlacDec <TITLE>flacdec</TITLE> Index: gstdvdec.c RCS file: /cvs/gstreamer/gst-plugins-good/ext/dv/gstdvdec.c,v retrieving revision 1.99 retrieving revision 1.100 diff -u -d -r1.99 -r1.100 --- gstdvdec.c 22 Feb 2006 20:22:25 -0000 1.99 +++ gstdvdec.c 28 Feb 2006 10:22:11 -0000 1.100 @@ -18,6 +18,30 @@ * Boston, MA 02111-1307, USA. */ +/** + * SECTION:element-dvdec + * + * <refsect2> + * <para> + * dvdec decodes DV video into raw video. The element expects a full DV frame + * as input, which is 120000 bytes for NTSC and 144000 for PAL video. + * </para> + * This element can perform simple frame dropping with the drop-factor + * property. Setting this property to a value N > 1 will only decode every + * Nth frame. + * <title>Example launch line</title> + * <programlisting> + * gst-launch filesrc location=test.dv ! dvdemux name=demux ! dvdec ! xvimagesink + * </programlisting> + * This pipeline decodes and renders the raw DV stream to a videosink. + * Last reviewed on 2006-02-28 (0.10.3) + * </refsect2> + */ #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -33,6 +57,9 @@ "Uses libdv to decode DV video (libdv.sourceforge.net)", "Erik Walthinsen <om...@cs...>," "Wim Taymans <wi...@fl...>"); +/* sizes of one input buffer */ +#define NTSC_BUFFER 120000 +#define PAL_BUFFER 144000 #define DV_DEFAULT_QUALITY DV_QUALITY_BEST #define DV_DEFAULT_DECODE_NTH 1 @@ -265,12 +292,25 @@ gint outframe_pitches[3]; GstBuffer *outbuf; GstFlowReturn ret = GST_FLOW_OK; + guint length; dvdec = GST_DVDEC (gst_pad_get_parent (pad)); inframe = GST_BUFFER_DATA (buf); - if (dv_parse_header (dvdec->decoder, inframe) < 0) - g_assert_not_reached (); + /* buffer should be at least the size of one NTSC frame, this should + * be enough to decode the header. */ + if (G_UNLIKELY (GST_BUFFER_SIZE (buf) < NTSC_BUFFER)) + goto wrong_size; + if (G_UNLIKELY (dv_parse_header (dvdec->decoder, inframe) < 0)) + goto parse_header_error; + /* check the buffer is of right size after we know if we are + * dealing with PAL or NTSC */ + length = (dvdec->PAL ? PAL_BUFFER : NTSC_BUFFER); + if (G_UNLIKELY (GST_BUFFER_SIZE (buf) < length)) dv_parse_packs (dvdec->decoder, inframe); if (dvdec->video_offset % dvdec->drop_factor != 0) @@ -280,7 +320,7 @@ gst_pad_alloc_buffer_and_set_caps (dvdec->srcpad, 0, (720 * dvdec->height) * dvdec->bpp, GST_PAD_CAPS (dvdec->srcpad), &outbuf); - if (ret != GST_FLOW_OK) + if (G_UNLIKELY (ret != GST_FLOW_OK)) goto no_buffer; outframe = GST_BUFFER_DATA (outbuf); @@ -306,19 +346,33 @@ ret = gst_pad_push (dvdec->srcpad, outbuf); skip: - gst_buffer_unref (buf); dvdec->video_offset++; +done: + gst_buffer_unref (buf); gst_object_unref (dvdec); return ret; /* ERRORS */ +wrong_size: + { + GST_ELEMENT_ERROR (dvdec, STREAM, DECODE, + (NULL), ("Input buffer too small")); + ret = GST_FLOW_ERROR; + goto done; + } +parse_header_error: + (NULL), ("Error parsing DV header")); no_buffer: { GST_DEBUG_OBJECT (dvdec, "could not allocate buffer"); - gst_buffer_unref (buf); - gst_object_unref (dvdec); - return ret; } } Index: gstdvdemux.c RCS file: /cvs/gstreamer/gst-plugins-good/ext/dv/gstdvdemux.c,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- gstdvdemux.c 22 Feb 2006 20:22:25 -0000 1.19 +++ gstdvdemux.c 28 Feb 2006 10:22:11 -0000 1.20 @@ -27,6 +27,29 @@ #include <gst/audio/audio.h> #include "gstdvdemux.h" + * SECTION:element-dvdemux + * dvdemux splits raw DV into its audio and video components. The audio will be + * decoded raw samples and the video will be encoded DV video. [...1338 lines suppressed...] - dvdemux->video_offset = 0; - dvdemux->framecount = 0; - dvdemux->found_header = FALSE; - dvdemux->frame_len = -1; - dvdemux->timestamp = 0LL; - dvdemux->need_segment = FALSE; - dvdemux->new_media = FALSE; - dvdemux->framerate_numerator = 0; - dvdemux->framerate_denominator = 0; - dvdemux->total_frames = 0; - dvdemux->height = 0; - dvdemux->frequency = 0; - dvdemux->channels = 0; - dvdemux->wide = FALSE; - gst_segment_init (&dvdemux->byte_segment, GST_FORMAT_BYTES); - gst_segment_init (&dvdemux->time_segment, GST_FORMAT_TIME); + gst_dvdemux_reset (dvdemux); break; case GST_STATE_CHANGE_PAUSED_TO_PLAYING: Index: gstdvdemux.h RCS file: /cvs/gstreamer/gst-plugins-good/ext/dv/gstdvdemux.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- gstdvdemux.h 22 Feb 2006 20:22:25 -0000 1.5 +++ gstdvdemux.h 28 Feb 2006 10:22:11 -0000 1.6 @@ -42,6 +42,9 @@ typedef struct _GstDVDemux GstDVDemux; typedef struct _GstDVDemuxClass GstDVDemuxClass; +typedef gboolean (*GstDVDemuxSeekHandler) (GstDVDemux *demux, GstPad * pad, GstEvent * event); struct _GstDVDemux { GstElement element; @@ -67,14 +70,14 @@ gint framecount; - guint64 timestamp; - guint64 duration; - gint64 total_frames; - guint64 audio_offset; - guint64 video_offset; + gint64 frame_offset; + gint64 audio_offset; + gint64 video_offset; + GstDVDemuxSeekHandler seek_handler; GstSegment byte_segment; GstSegment time_segment; + gboolean running; gboolean need_segment; gboolean new_media; |