diff --git a/ChangeLog b/ChangeLog index 64b831dc4d..3375779391 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2006-05-28 Edward Hervey + + * ext/jpeg/gstjpegdec.c: (gst_jpeg_dec_finalize), + (gst_jpeg_dec_init), (gst_jpeg_dec_chain), + (gst_jpeg_dec_sink_event), (gst_jpeg_dec_change_state): + * ext/jpeg/gstjpegdec.h: + Clip outgoing buffers according to currently configured segment. + 2006-05-28 Tim-Philipp Müller * ext/taglib/gstid3v2mux.cc: diff --git a/common b/common index 325a1848e3..2f06c5cbc7 160000 --- a/common +++ b/common @@ -1 +1 @@ -Subproject commit 325a1848e38c12e0e787baa70e7b9aacf20ee799 +Subproject commit 2f06c5cbc778e158d2429b09efc6740ff5281295 diff --git a/ext/jpeg/gstjpegdec.c b/ext/jpeg/gstjpegdec.c index ca42dc7c81..1713b06f2a 100644 --- a/ext/jpeg/gstjpegdec.c +++ b/ext/jpeg/gstjpegdec.c @@ -117,6 +117,9 @@ gst_jpeg_dec_finalize (GObject * object) if (dec->tempbuf) gst_buffer_unref (dec->tempbuf); + if (dec->segment) + gst_segment_free (dec->segment); + G_OBJECT_CLASS (parent_class)->finalize (object); } @@ -246,6 +249,8 @@ gst_jpeg_dec_init (GstJpegDec * dec) gst_pad_new_from_static_template (&gst_jpeg_dec_src_pad_template, "src"); gst_element_add_pad (GST_ELEMENT (dec), dec->srcpad); + dec->segment = gst_segment_new (); + /* setup jpeglib */ memset (&dec->cinfo, 0, sizeof (dec->cinfo)); memset (&dec->jerr, 0, sizeof (dec->jerr)); @@ -915,6 +920,34 @@ gst_jpeg_dec_chain (GstPad * pad, GstBuffer * buf) GST_LOG_OBJECT (dec, "decompressing finished"); jpeg_finish_decompress (&dec->cinfo); + /* Clipping */ + if (dec->segment->format == GST_FORMAT_TIME) { + gint64 start, stop, clip_start, clip_stop; + + GST_LOG_OBJECT (dec, "Attempting clipping"); + + start = GST_BUFFER_TIMESTAMP (outbuf); + if (GST_BUFFER_DURATION (outbuf) == GST_CLOCK_TIME_NONE) + stop = start; + else + stop = start + GST_BUFFER_DURATION (outbuf); + + if (gst_segment_clip (dec->segment, GST_FORMAT_TIME, + start, stop, &clip_start, &clip_stop)) { + GST_LOG_OBJECT (dec, "Clipping start to %" GST_TIME_FORMAT, + GST_TIME_ARGS (clip_start)); + GST_BUFFER_TIMESTAMP (outbuf) = clip_start; + if (GST_BUFFER_DURATION (outbuf) != GST_CLOCK_TIME_NONE) { + GST_LOG_OBJECT (dec, "Clipping duration to %" GST_TIME_FORMAT, + GST_TIME_ARGS (clip_stop - clip_start)); + GST_BUFFER_DURATION (outbuf) = clip_stop - clip_start; + } + } else { + GST_WARNING_OBJECT (dec, + "Outgoing buffer is outsided configured segment"); + } + } + GST_LOG_OBJECT (dec, "pushing buffer (ts=%" GST_TIME_FORMAT ", dur=%" GST_TIME_FORMAT, GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (outbuf)), GST_TIME_ARGS (GST_BUFFER_DURATION (outbuf))); @@ -986,6 +1019,23 @@ gst_jpeg_dec_sink_event (GstPad * pad, GstEvent * event) GST_DEBUG_OBJECT (dec, "Aborting decompress"); jpeg_abort_decompress (&dec->cinfo); break; + case GST_EVENT_NEWSEGMENT:{ + gboolean update; + gdouble rate; + GstFormat format; + gint64 start, stop, position; + + /* Once -good depends on core >= 0.10.6, use newsegment_full */ + gst_event_parse_new_segment (event, &update, &rate, &format, + &start, &stop, &position); + GST_DEBUG_OBJECT (dec, "Got NEWSEGMENT [%" GST_TIME_FORMAT + " - %" GST_TIME_FORMAT " / %" GST_TIME_FORMAT "]", + GST_TIME_ARGS (start), GST_TIME_ARGS (stop), + GST_TIME_ARGS (position)); + gst_segment_set_newsegment (dec->segment, update, rate, format, + start, stop, position); + } + break; default: break; } @@ -1012,6 +1062,7 @@ gst_jpeg_dec_change_state (GstElement * element, GstStateChange transition) dec->caps_height = -1; dec->packetized = FALSE; dec->next_ts = 0; + gst_segment_init (dec->segment, GST_FORMAT_TIME); default: break; } diff --git a/ext/jpeg/gstjpegdec.h b/ext/jpeg/gstjpegdec.h index 5be8ec5f96..57bab63573 100644 --- a/ext/jpeg/gstjpegdec.h +++ b/ext/jpeg/gstjpegdec.h @@ -23,7 +23,7 @@ #include -#include +#include /* this is a hack hack hack to get around jpeglib header bugs... */ #ifdef HAVE_STDLIB_H @@ -75,6 +75,8 @@ struct _GstJpegDec { /* the (expected) timestamp of the next frame */ guint64 next_ts; + GstSegment *segment; + /* video state */ gint framerate_numerator; gint framerate_denominator;