2002-03-20 21:45:03 +00:00
|
|
|
/* GStreamer
|
2001-12-23 06:03:21 +00:00
|
|
|
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2003-06-29 19:46:09 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
2001-12-23 06:03:21 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include <inttypes.h>
|
|
|
|
|
|
|
|
#include "gstmpeg2dec.h"
|
|
|
|
|
2006-11-21 12:15:58 +00:00
|
|
|
/* 16byte-aligns a buffer for libmpeg2 */
|
2006-11-03 09:52:12 +00:00
|
|
|
#define ALIGN_16(p) ((void *)(((uintptr_t)(p) + 15) & ~((uintptr_t)15)))
|
|
|
|
|
2003-09-11 17:13:24 +00:00
|
|
|
/* mpeg2dec changed a struct name after 0.3.1, here's a workaround */
|
|
|
|
/* mpeg2dec also only defined MPEG2_RELEASE after 0.3.1
|
2005-07-19 20:51:16 +00:00
|
|
|
#if MPEG2_RELEASE < MPEG2_VERSION(0,3,2)
|
2003-09-11 17:13:24 +00:00
|
|
|
*/
|
|
|
|
#ifndef MPEG2_RELEASE
|
2004-01-03 23:45:32 +00:00
|
|
|
#define MPEG2_VERSION(a,b,c) ((((a)&0xff)<<16)|(((b)&0xff)<<8)|((c)&0xff))
|
|
|
|
#define MPEG2_RELEASE MPEG2_VERSION(0,3,1)
|
2003-09-11 17:13:24 +00:00
|
|
|
typedef picture_t mpeg2_picture_t;
|
2003-10-06 12:16:21 +00:00
|
|
|
typedef gint mpeg2_state_t;
|
2004-03-14 22:34:30 +00:00
|
|
|
|
2003-10-07 10:08:30 +00:00
|
|
|
#define STATE_BUFFER 0
|
2003-09-11 17:13:24 +00:00
|
|
|
#endif
|
|
|
|
|
2004-04-01 11:48:27 +00:00
|
|
|
GST_DEBUG_CATEGORY_STATIC (mpeg2dec_debug);
|
|
|
|
#define GST_CAT_DEFAULT (mpeg2dec_debug)
|
2003-07-25 02:04:01 +00:00
|
|
|
|
2001-12-23 06:03:21 +00:00
|
|
|
/* elementfactory information */
|
2006-04-13 19:08:20 +00:00
|
|
|
static const GstElementDetails gst_mpeg2dec_details =
|
|
|
|
GST_ELEMENT_DETAILS ("mpeg1 and mpeg2 video decoder",
|
|
|
|
"Codec/Decoder/Video",
|
|
|
|
"Uses libmpeg2 to decode MPEG video streams",
|
|
|
|
"Wim Taymans <wim.taymans@chello.be>");
|
2001-12-23 06:03:21 +00:00
|
|
|
|
2007-03-02 13:01:48 +00:00
|
|
|
/* Send a warning message about decoding errors after receiving this many
|
|
|
|
* STATE_INVALID return values from mpeg2_parse. -1 means never.
|
2006-02-27 14:49:05 +00:00
|
|
|
*/
|
2007-03-02 13:01:48 +00:00
|
|
|
#define WARN_THRESHOLD (5)
|
2006-02-27 14:49:05 +00:00
|
|
|
|
2008-11-25 03:44:06 +00:00
|
|
|
//#define enable_user_data
|
2004-03-13 00:19:26 +00:00
|
|
|
#ifdef enable_user_data
|
2003-12-22 01:47:08 +00:00
|
|
|
static GstStaticPadTemplate user_data_template_factory =
|
2004-03-14 22:34:30 +00:00
|
|
|
GST_STATIC_PAD_TEMPLATE ("user_data",
|
|
|
|
GST_PAD_SRC,
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS_ANY);
|
2004-03-13 00:19:26 +00:00
|
|
|
#endif
|
2002-12-19 07:45:11 +00:00
|
|
|
|
2003-12-22 01:47:08 +00:00
|
|
|
static GstStaticPadTemplate sink_template_factory =
|
2004-03-14 22:34:30 +00:00
|
|
|
GST_STATIC_PAD_TEMPLATE ("sink",
|
|
|
|
GST_PAD_SINK,
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS ("video/mpeg, "
|
2004-03-15 19:32:25 +00:00
|
|
|
"mpegversion = (int) [ 1, 2 ], " "systemstream = (boolean) false")
|
2004-03-14 22:34:30 +00:00
|
|
|
);
|
|
|
|
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
static GstStaticPadTemplate src_template_factory =
|
|
|
|
GST_STATIC_PAD_TEMPLATE ("src",
|
|
|
|
GST_PAD_SRC,
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS ("video/x-raw-yuv, "
|
2008-11-25 03:44:06 +00:00
|
|
|
"format = (fourcc) { YV12, I420, Y42B, Y444 }, "
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
"width = (int) [ 16, 4096 ], "
|
|
|
|
"height = (int) [ 16, 4096 ], "
|
2006-11-15 13:57:21 +00:00
|
|
|
"framerate = (fraction) [ 0/1, 2147483647/1 ]")
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
);
|
|
|
|
|
2004-03-14 22:34:30 +00:00
|
|
|
static void gst_mpeg2dec_base_init (gpointer g_class);
|
|
|
|
static void gst_mpeg2dec_class_init (GstMpeg2decClass * klass);
|
|
|
|
static void gst_mpeg2dec_init (GstMpeg2dec * mpeg2dec);
|
|
|
|
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
static void gst_mpeg2dec_finalize (GObject * object);
|
2005-02-05 07:36:01 +00:00
|
|
|
static void gst_mpeg2dec_reset (GstMpeg2dec * mpeg2dec);
|
2004-03-14 22:34:30 +00:00
|
|
|
|
|
|
|
static void gst_mpeg2dec_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * pspec);
|
|
|
|
static void gst_mpeg2dec_get_property (GObject * object, guint prop_id,
|
|
|
|
GValue * value, GParamSpec * pspec);
|
2008-09-28 17:33:43 +00:00
|
|
|
|
|
|
|
#ifndef GST_DISABLE_INDEX
|
2004-03-14 22:34:30 +00:00
|
|
|
static void gst_mpeg2dec_set_index (GstElement * element, GstIndex * index);
|
|
|
|
static GstIndex *gst_mpeg2dec_get_index (GstElement * element);
|
2008-09-28 17:33:43 +00:00
|
|
|
#endif
|
2004-03-14 22:34:30 +00:00
|
|
|
|
|
|
|
static gboolean gst_mpeg2dec_src_event (GstPad * pad, GstEvent * event);
|
|
|
|
static const GstQueryType *gst_mpeg2dec_get_src_query_types (GstPad * pad);
|
|
|
|
|
2005-07-19 20:51:16 +00:00
|
|
|
static gboolean gst_mpeg2dec_src_query (GstPad * pad, GstQuery * query);
|
|
|
|
|
|
|
|
static gboolean gst_mpeg2dec_sink_convert (GstPad * pad, GstFormat src_format,
|
2004-03-14 22:34:30 +00:00
|
|
|
gint64 src_value, GstFormat * dest_format, gint64 * dest_value);
|
2005-07-19 20:51:16 +00:00
|
|
|
static gboolean gst_mpeg2dec_src_convert (GstPad * pad, GstFormat src_format,
|
2004-03-14 22:34:30 +00:00
|
|
|
gint64 src_value, GstFormat * dest_format, gint64 * dest_value);
|
|
|
|
|
2005-09-02 15:43:54 +00:00
|
|
|
static GstStateChangeReturn gst_mpeg2dec_change_state (GstElement * element,
|
|
|
|
GstStateChange transition);
|
2004-03-14 22:34:30 +00:00
|
|
|
|
2005-07-19 20:51:16 +00:00
|
|
|
static gboolean gst_mpeg2dec_sink_event (GstPad * pad, GstEvent * event);
|
2008-10-14 12:51:41 +00:00
|
|
|
static gboolean gst_mpeg2dec_setcaps (GstPad * pad, GstCaps * caps);
|
2005-07-19 20:51:16 +00:00
|
|
|
static GstFlowReturn gst_mpeg2dec_chain (GstPad * pad, GstBuffer * buf);
|
|
|
|
|
2006-06-07 17:05:48 +00:00
|
|
|
static void clear_buffers (GstMpeg2dec * mpeg2dec);
|
|
|
|
|
2005-07-19 20:51:16 +00:00
|
|
|
//static gboolean gst_mpeg2dec_sink_query (GstPad * pad, GstQuery * query);
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
static const GstFormat *gst_mpeg2dec_get_formats (GstPad * pad);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
static const GstEventMask *gst_mpeg2dec_get_event_masks (GstPad * pad);
|
|
|
|
#endif
|
2001-12-23 06:03:21 +00:00
|
|
|
|
|
|
|
static GstElementClass *parent_class = NULL;
|
2004-03-14 22:34:30 +00:00
|
|
|
|
2006-02-15 10:18:39 +00:00
|
|
|
static gboolean crop_buffer (GstMpeg2dec * mpeg2dec, GstBuffer ** buf);
|
2005-01-17 13:54:30 +00:00
|
|
|
|
2001-12-23 06:03:21 +00:00
|
|
|
/*static guint gst_mpeg2dec_signals[LAST_SIGNAL] = { 0 };*/
|
|
|
|
|
|
|
|
GType
|
|
|
|
gst_mpeg2dec_get_type (void)
|
|
|
|
{
|
|
|
|
static GType mpeg2dec_type = 0;
|
2004-03-14 22:34:30 +00:00
|
|
|
|
2001-12-23 06:03:21 +00:00
|
|
|
if (!mpeg2dec_type) {
|
|
|
|
static const GTypeInfo mpeg2dec_info = {
|
2004-03-14 22:34:30 +00:00
|
|
|
sizeof (GstMpeg2decClass),
|
2003-11-02 00:33:31 +00:00
|
|
|
gst_mpeg2dec_base_init,
|
2001-12-23 06:03:21 +00:00
|
|
|
NULL,
|
2004-03-14 22:34:30 +00:00
|
|
|
(GClassInitFunc) gst_mpeg2dec_class_init,
|
2001-12-23 06:03:21 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
2004-03-14 22:34:30 +00:00
|
|
|
sizeof (GstMpeg2dec),
|
2001-12-23 06:03:21 +00:00
|
|
|
0,
|
2004-03-14 22:34:30 +00:00
|
|
|
(GInstanceInitFunc) gst_mpeg2dec_init,
|
2001-12-23 06:03:21 +00:00
|
|
|
};
|
2004-03-15 19:32:25 +00:00
|
|
|
|
2004-03-14 22:34:30 +00:00
|
|
|
mpeg2dec_type =
|
2004-03-15 19:32:25 +00:00
|
|
|
g_type_register_static (GST_TYPE_ELEMENT, "GstMpeg2dec", &mpeg2dec_info,
|
|
|
|
0);
|
2001-12-23 06:03:21 +00:00
|
|
|
}
|
2004-04-01 11:48:27 +00:00
|
|
|
|
|
|
|
GST_DEBUG_CATEGORY_INIT (mpeg2dec_debug, "mpeg2dec", 0,
|
|
|
|
"MPEG2 decoder element");
|
|
|
|
|
2001-12-23 06:03:21 +00:00
|
|
|
return mpeg2dec_type;
|
|
|
|
}
|
|
|
|
|
2003-11-02 00:33:31 +00:00
|
|
|
static void
|
|
|
|
gst_mpeg2dec_base_init (gpointer g_class)
|
|
|
|
{
|
|
|
|
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
|
|
|
|
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
gst_element_class_add_pad_template (element_class,
|
|
|
|
gst_static_pad_template_get (&src_template_factory));
|
2004-03-14 22:34:30 +00:00
|
|
|
gst_element_class_add_pad_template (element_class,
|
|
|
|
gst_static_pad_template_get (&sink_template_factory));
|
2004-03-13 00:19:26 +00:00
|
|
|
#ifdef enable_user_data
|
2004-03-14 22:34:30 +00:00
|
|
|
gst_element_class_add_pad_template (element_class,
|
|
|
|
gst_static_pad_template_get (&user_data_template_factory));
|
2004-03-13 00:19:26 +00:00
|
|
|
#endif
|
2003-11-02 00:33:31 +00:00
|
|
|
gst_element_class_set_details (element_class, &gst_mpeg2dec_details);
|
|
|
|
}
|
|
|
|
|
2001-12-23 06:03:21 +00:00
|
|
|
static void
|
2004-03-14 22:34:30 +00:00
|
|
|
gst_mpeg2dec_class_init (GstMpeg2decClass * klass)
|
2001-12-23 06:03:21 +00:00
|
|
|
{
|
|
|
|
GObjectClass *gobject_class;
|
|
|
|
GstElementClass *gstelement_class;
|
|
|
|
|
2004-03-14 22:34:30 +00:00
|
|
|
gobject_class = (GObjectClass *) klass;
|
|
|
|
gstelement_class = (GstElementClass *) klass;
|
2001-12-23 06:03:21 +00:00
|
|
|
|
2006-04-08 21:42:19 +00:00
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
2001-12-23 06:03:21 +00:00
|
|
|
|
2004-03-14 22:34:30 +00:00
|
|
|
gobject_class->set_property = gst_mpeg2dec_set_property;
|
|
|
|
gobject_class->get_property = gst_mpeg2dec_get_property;
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
gobject_class->finalize = gst_mpeg2dec_finalize;
|
2001-12-23 06:03:21 +00:00
|
|
|
|
|
|
|
gstelement_class->change_state = gst_mpeg2dec_change_state;
|
2008-09-28 17:33:43 +00:00
|
|
|
#ifndef GST_DISABLE_INDEX
|
2004-03-14 22:34:30 +00:00
|
|
|
gstelement_class->set_index = gst_mpeg2dec_set_index;
|
|
|
|
gstelement_class->get_index = gst_mpeg2dec_get_index;
|
2008-09-28 17:33:43 +00:00
|
|
|
#endif
|
2001-12-23 06:03:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:30 +00:00
|
|
|
gst_mpeg2dec_init (GstMpeg2dec * mpeg2dec)
|
2001-12-23 06:03:21 +00:00
|
|
|
{
|
2002-12-05 00:29:11 +00:00
|
|
|
/* create the sink and src pads */
|
2004-03-14 22:34:30 +00:00
|
|
|
mpeg2dec->sinkpad =
|
2006-11-15 11:41:39 +00:00
|
|
|
gst_pad_new_from_static_template (&sink_template_factory, "sink");
|
2004-03-14 22:34:30 +00:00
|
|
|
gst_pad_set_chain_function (mpeg2dec->sinkpad,
|
|
|
|
GST_DEBUG_FUNCPTR (gst_mpeg2dec_chain));
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
#if 0
|
|
|
|
gst_pad_set_query_function (mpeg2dec->sinkpad,
|
|
|
|
GST_DEBUG_FUNCPTR (gst_mpeg2dec_get_sink_query));
|
|
|
|
#endif
|
2005-07-19 20:51:16 +00:00
|
|
|
gst_pad_set_event_function (mpeg2dec->sinkpad,
|
|
|
|
GST_DEBUG_FUNCPTR (gst_mpeg2dec_sink_event));
|
2008-10-14 12:51:41 +00:00
|
|
|
gst_pad_set_setcaps_function (mpeg2dec->sinkpad,
|
|
|
|
GST_DEBUG_FUNCPTR (gst_mpeg2dec_setcaps));
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
gst_element_add_pad (GST_ELEMENT (mpeg2dec), mpeg2dec->sinkpad);
|
2004-03-14 22:34:30 +00:00
|
|
|
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
mpeg2dec->srcpad =
|
2006-11-15 11:41:39 +00:00
|
|
|
gst_pad_new_from_static_template (&src_template_factory, "src");
|
2004-03-14 22:34:30 +00:00
|
|
|
gst_pad_set_event_function (mpeg2dec->srcpad,
|
|
|
|
GST_DEBUG_FUNCPTR (gst_mpeg2dec_src_event));
|
|
|
|
gst_pad_set_query_type_function (mpeg2dec->srcpad,
|
|
|
|
GST_DEBUG_FUNCPTR (gst_mpeg2dec_get_src_query_types));
|
|
|
|
gst_pad_set_query_function (mpeg2dec->srcpad,
|
|
|
|
GST_DEBUG_FUNCPTR (gst_mpeg2dec_src_query));
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
gst_pad_use_fixed_caps (mpeg2dec->srcpad);
|
|
|
|
gst_element_add_pad (GST_ELEMENT (mpeg2dec), mpeg2dec->srcpad);
|
2001-12-23 06:03:21 +00:00
|
|
|
|
2004-03-13 00:19:26 +00:00
|
|
|
#ifdef enable_user_data
|
2004-03-14 22:34:30 +00:00
|
|
|
mpeg2dec->userdatapad =
|
2006-11-15 11:41:39 +00:00
|
|
|
gst_pad_new_from_static_template (&user_data_template_factory,
|
|
|
|
"user_data");
|
2002-12-19 07:45:11 +00:00
|
|
|
gst_element_add_pad (GST_ELEMENT (mpeg2dec), mpeg2dec->userdatapad);
|
2004-03-13 00:19:26 +00:00
|
|
|
#endif
|
2002-12-19 07:45:11 +00:00
|
|
|
|
2006-02-27 14:49:05 +00:00
|
|
|
mpeg2dec->error_count = 0;
|
2006-11-21 12:15:58 +00:00
|
|
|
mpeg2dec->can_allocate_aligned = TRUE;
|
2006-02-27 14:49:05 +00:00
|
|
|
|
2002-12-23 00:32:36 +00:00
|
|
|
/* initialize the mpeg2dec acceleration */
|
2002-12-26 22:46:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
gst_mpeg2dec_finalize (GObject * object)
|
2002-12-26 22:46:26 +00:00
|
|
|
{
|
|
|
|
GstMpeg2dec *mpeg2dec = GST_MPEG2DEC (object);
|
|
|
|
|
2005-10-26 16:45:04 +00:00
|
|
|
if (mpeg2dec->decoder) {
|
|
|
|
GST_DEBUG_OBJECT (mpeg2dec, "closing decoder");
|
|
|
|
mpeg2_close (mpeg2dec->decoder);
|
|
|
|
mpeg2dec->decoder = NULL;
|
|
|
|
}
|
2006-06-07 17:05:48 +00:00
|
|
|
clear_buffers (mpeg2dec);
|
2006-11-03 09:52:12 +00:00
|
|
|
g_free (mpeg2dec->dummybuf[3]);
|
|
|
|
mpeg2dec->dummybuf[3] = NULL;
|
2001-12-23 06:03:21 +00:00
|
|
|
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
2001-12-23 06:03:21 +00:00
|
|
|
}
|
|
|
|
|
2005-02-05 07:36:01 +00:00
|
|
|
static void
|
|
|
|
gst_mpeg2dec_reset (GstMpeg2dec * mpeg2dec)
|
|
|
|
{
|
|
|
|
/* reset the initial video state */
|
|
|
|
mpeg2dec->format = MPEG2DEC_FORMAT_NONE;
|
|
|
|
mpeg2dec->width = -1;
|
|
|
|
mpeg2dec->height = -1;
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
gst_segment_init (&mpeg2dec->segment, GST_FORMAT_UNDEFINED);
|
2005-02-05 07:36:01 +00:00
|
|
|
mpeg2dec->discont_state = MPEG2DEC_DISC_NEW_PICTURE;
|
|
|
|
mpeg2dec->frame_period = 0;
|
|
|
|
mpeg2dec->need_sequence = TRUE;
|
2006-06-07 17:05:48 +00:00
|
|
|
mpeg2dec->next_time = -1;
|
2005-10-26 16:45:04 +00:00
|
|
|
mpeg2dec->offset = 0;
|
2006-02-27 14:49:05 +00:00
|
|
|
mpeg2dec->error_count = 0;
|
2006-11-21 12:15:58 +00:00
|
|
|
mpeg2dec->can_allocate_aligned = TRUE;
|
ext/mpeg2dec/gstmpeg2dec.c: Forward GstFlowReturn about everywhere.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_reset),
(gst_mpeg2dec_alloc_buffer), (gst_mpeg2dec_negotiate_format),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_src_query), (normal_seek),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
Forward GstFlowReturn about everywhere.
Handle seeking correctly.
2005-10-27 21:50:11 +00:00
|
|
|
mpeg2_reset (mpeg2dec->decoder, 1);
|
2005-02-05 07:36:01 +00:00
|
|
|
}
|
2005-10-26 16:45:04 +00:00
|
|
|
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
static void
|
|
|
|
gst_mpeg2dec_qos_reset (GstMpeg2dec * mpeg2dec)
|
|
|
|
{
|
|
|
|
GST_OBJECT_LOCK (mpeg2dec);
|
|
|
|
mpeg2dec->proportion = 1.0;
|
|
|
|
mpeg2dec->earliest_time = -1;
|
|
|
|
GST_OBJECT_UNLOCK (mpeg2dec);
|
|
|
|
}
|
|
|
|
|
2008-09-28 17:33:43 +00:00
|
|
|
#ifndef GST_DISABLE_INDEX
|
2001-12-23 06:03:21 +00:00
|
|
|
static void
|
2004-03-14 22:34:30 +00:00
|
|
|
gst_mpeg2dec_set_index (GstElement * element, GstIndex * index)
|
2001-12-23 06:03:21 +00:00
|
|
|
{
|
2002-12-05 00:29:11 +00:00
|
|
|
GstMpeg2dec *mpeg2dec = GST_MPEG2DEC (element);
|
2004-03-14 22:34:30 +00:00
|
|
|
|
2002-12-12 22:15:39 +00:00
|
|
|
mpeg2dec->index = index;
|
2001-12-23 06:03:21 +00:00
|
|
|
|
2002-12-12 22:15:39 +00:00
|
|
|
gst_index_get_writer_id (index, GST_OBJECT (element), &mpeg2dec->index_id);
|
2001-12-23 06:03:21 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:30 +00:00
|
|
|
static GstIndex *
|
|
|
|
gst_mpeg2dec_get_index (GstElement * element)
|
2001-12-23 06:03:21 +00:00
|
|
|
{
|
2002-12-05 00:29:11 +00:00
|
|
|
GstMpeg2dec *mpeg2dec = GST_MPEG2DEC (element);
|
2001-12-23 06:03:21 +00:00
|
|
|
|
2002-12-12 22:15:39 +00:00
|
|
|
return mpeg2dec->index;
|
2002-12-05 00:29:11 +00:00
|
|
|
}
|
2008-09-28 17:33:43 +00:00
|
|
|
#endif
|
2001-12-23 06:03:21 +00:00
|
|
|
|
2006-02-17 11:51:12 +00:00
|
|
|
/* see gst-plugins/gst/games/gstvideoimage.c, paint_setup_I420() */
|
|
|
|
#define I420_Y_ROWSTRIDE(width) (GST_ROUND_UP_4(width))
|
|
|
|
#define I420_U_ROWSTRIDE(width) (GST_ROUND_UP_8(width)/2)
|
|
|
|
#define I420_V_ROWSTRIDE(width) ((GST_ROUND_UP_8(I420_Y_ROWSTRIDE(width)))/2)
|
|
|
|
|
|
|
|
#define I420_Y_OFFSET(w,h) (0)
|
|
|
|
#define I420_U_OFFSET(w,h) (I420_Y_OFFSET(w,h)+(I420_Y_ROWSTRIDE(w)*GST_ROUND_UP_2(h)))
|
|
|
|
#define I420_V_OFFSET(w,h) (I420_U_OFFSET(w,h)+(I420_U_ROWSTRIDE(w)*GST_ROUND_UP_2(h)/2))
|
|
|
|
|
|
|
|
#define I420_SIZE(w,h) (I420_V_OFFSET(w,h)+(I420_V_ROWSTRIDE(w)*GST_ROUND_UP_2(h)/2))
|
|
|
|
|
|
|
|
static GstBuffer *
|
|
|
|
crop_copy_i420_buffer (GstMpeg2dec * mpeg2dec, GstBuffer * input)
|
|
|
|
{
|
|
|
|
GstBuffer *outbuf;
|
|
|
|
guint8 *dest, *src;
|
|
|
|
guint outsize, line;
|
|
|
|
|
|
|
|
outsize = I420_SIZE (mpeg2dec->width, mpeg2dec->height);
|
|
|
|
GST_LOG_OBJECT (mpeg2dec, "Copying input buffer %ux%u (%u) to output buffer "
|
|
|
|
"%ux%u (%u)", mpeg2dec->decoded_width, mpeg2dec->decoded_height,
|
|
|
|
GST_BUFFER_SIZE (input), mpeg2dec->width, mpeg2dec->height, outsize);
|
|
|
|
outbuf = gst_buffer_new_and_alloc (outsize);
|
|
|
|
|
|
|
|
/* Copy Y first */
|
|
|
|
src = GST_BUFFER_DATA (input);
|
|
|
|
dest = GST_BUFFER_DATA (outbuf);
|
|
|
|
for (line = 0; line < mpeg2dec->height; line++) {
|
|
|
|
memcpy (dest, src, mpeg2dec->width);
|
|
|
|
dest += I420_Y_ROWSTRIDE (mpeg2dec->width);
|
|
|
|
src += I420_Y_ROWSTRIDE (mpeg2dec->decoded_width);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* U */
|
|
|
|
src = GST_BUFFER_DATA (input)
|
|
|
|
+ I420_U_OFFSET (mpeg2dec->decoded_width, mpeg2dec->decoded_height);
|
|
|
|
dest = GST_BUFFER_DATA (outbuf)
|
|
|
|
+ I420_U_OFFSET (mpeg2dec->width, mpeg2dec->height);
|
|
|
|
for (line = 0; line < mpeg2dec->height / 2; line++) {
|
|
|
|
memcpy (dest, src, mpeg2dec->width / 2);
|
|
|
|
dest += I420_U_ROWSTRIDE (mpeg2dec->width);
|
|
|
|
src += I420_U_ROWSTRIDE (mpeg2dec->decoded_width);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* V */
|
|
|
|
src = GST_BUFFER_DATA (input)
|
|
|
|
+ I420_V_OFFSET (mpeg2dec->decoded_width, mpeg2dec->decoded_height);
|
|
|
|
dest = GST_BUFFER_DATA (outbuf)
|
|
|
|
+ I420_V_OFFSET (mpeg2dec->width, mpeg2dec->height);
|
|
|
|
for (line = 0; line < mpeg2dec->height / 2; line++) {
|
|
|
|
memcpy (dest, src, mpeg2dec->width / 2);
|
|
|
|
dest += I420_V_ROWSTRIDE (mpeg2dec->width);
|
|
|
|
src += I420_V_ROWSTRIDE (mpeg2dec->decoded_width);
|
|
|
|
}
|
|
|
|
|
|
|
|
return outbuf;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* FIXME: this is unlikely to be right stride-wise and offset-wise */
|
|
|
|
static GstBuffer *
|
|
|
|
crop_copy_i422_buffer (GstMpeg2dec * mpeg2dec, GstBuffer * input)
|
|
|
|
{
|
|
|
|
GstBuffer *outbuf;
|
|
|
|
guint8 *in_data, *out_data;
|
|
|
|
guint line;
|
|
|
|
|
|
|
|
outbuf = gst_buffer_new_and_alloc (mpeg2dec->width * mpeg2dec->height * 2);
|
|
|
|
|
|
|
|
/* Copy Y first */
|
|
|
|
in_data = GST_BUFFER_DATA (input);
|
|
|
|
out_data = GST_BUFFER_DATA (outbuf);
|
|
|
|
for (line = 0; line < mpeg2dec->height; line++) {
|
|
|
|
memcpy (out_data, in_data, mpeg2dec->width);
|
|
|
|
out_data += mpeg2dec->width;
|
|
|
|
in_data += mpeg2dec->decoded_width;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now copy U & V */
|
|
|
|
in_data = GST_BUFFER_DATA (input)
|
|
|
|
+ mpeg2dec->decoded_width * mpeg2dec->decoded_height;
|
|
|
|
for (line = 0; line < mpeg2dec->height; line++) {
|
|
|
|
memcpy (out_data, in_data, mpeg2dec->width / 2);
|
|
|
|
memcpy (out_data + mpeg2dec->width * mpeg2dec->height / 2,
|
|
|
|
in_data + mpeg2dec->decoded_width * mpeg2dec->decoded_height / 2,
|
|
|
|
mpeg2dec->width / 2);
|
|
|
|
out_data += mpeg2dec->width / 2;
|
|
|
|
in_data += mpeg2dec->decoded_width / 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
return outbuf;
|
|
|
|
}
|
|
|
|
|
2006-02-15 10:18:39 +00:00
|
|
|
static gboolean
|
|
|
|
crop_buffer (GstMpeg2dec * mpeg2dec, GstBuffer ** buf)
|
2005-01-17 13:54:30 +00:00
|
|
|
{
|
2008-11-25 03:44:06 +00:00
|
|
|
gboolean result = TRUE;
|
2006-02-15 10:18:39 +00:00
|
|
|
GstBuffer *input = *buf;
|
2005-01-17 13:54:30 +00:00
|
|
|
GstBuffer *outbuf = input;
|
|
|
|
|
|
|
|
/*We crop only if the target region is smaller than the input one */
|
|
|
|
if ((mpeg2dec->decoded_width > mpeg2dec->width) ||
|
|
|
|
(mpeg2dec->decoded_height > mpeg2dec->height)) {
|
2005-07-19 20:51:16 +00:00
|
|
|
/* If we don't know about the format, we just return the original
|
2005-01-17 13:54:30 +00:00
|
|
|
* buffer.
|
|
|
|
*/
|
|
|
|
if (mpeg2dec->format == MPEG2DEC_FORMAT_I422 ||
|
|
|
|
mpeg2dec->format == MPEG2DEC_FORMAT_I420 ||
|
|
|
|
mpeg2dec->format == MPEG2DEC_FORMAT_YV12) {
|
2005-07-19 20:51:16 +00:00
|
|
|
/*FIXME: I have tried to use gst_buffer_copy_on_write, but it
|
2005-01-17 13:54:30 +00:00
|
|
|
* still have some artifact, so I'me allocating new buffer
|
|
|
|
* for each frame decoded...
|
|
|
|
*/
|
|
|
|
if (mpeg2dec->format == MPEG2DEC_FORMAT_I422) {
|
2006-02-17 11:51:12 +00:00
|
|
|
outbuf = crop_copy_i422_buffer (mpeg2dec, input);
|
2005-01-17 13:54:30 +00:00
|
|
|
} else {
|
2006-02-17 11:51:12 +00:00
|
|
|
outbuf = crop_copy_i420_buffer (mpeg2dec, input);
|
2005-01-17 13:54:30 +00:00
|
|
|
}
|
|
|
|
|
2006-02-17 11:51:12 +00:00
|
|
|
gst_buffer_set_caps (outbuf, GST_PAD_CAPS (mpeg2dec->srcpad));
|
2007-07-11 23:18:14 +00:00
|
|
|
gst_buffer_copy_metadata (outbuf, input, GST_BUFFER_COPY_TIMESTAMPS);
|
2006-07-10 11:52:58 +00:00
|
|
|
gst_buffer_unref (input);
|
2005-01-17 13:54:30 +00:00
|
|
|
|
2006-02-15 10:18:39 +00:00
|
|
|
*buf = outbuf;
|
|
|
|
result = TRUE;
|
2005-01-17 13:54:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-15 10:18:39 +00:00
|
|
|
return result;
|
2005-01-17 13:54:30 +00:00
|
|
|
}
|
|
|
|
|
2006-04-13 19:08:20 +00:00
|
|
|
static GstFlowReturn
|
|
|
|
gst_mpeg2dec_alloc_sized_buf (GstMpeg2dec * mpeg2dec, guint size,
|
|
|
|
GstBuffer ** obuf)
|
|
|
|
{
|
2006-11-21 12:15:58 +00:00
|
|
|
if (mpeg2dec->can_allocate_aligned
|
|
|
|
&& mpeg2dec->decoded_width == mpeg2dec->width
|
|
|
|
&& mpeg2dec->decoded_height == mpeg2dec->height) {
|
|
|
|
GstFlowReturn ret;
|
2006-04-13 19:08:20 +00:00
|
|
|
|
|
|
|
ret = gst_pad_alloc_buffer_and_set_caps (mpeg2dec->srcpad,
|
|
|
|
GST_BUFFER_OFFSET_NONE, size, GST_PAD_CAPS (mpeg2dec->srcpad), obuf);
|
2008-11-25 03:44:06 +00:00
|
|
|
if (ret != GST_FLOW_OK) {
|
2006-11-21 12:15:58 +00:00
|
|
|
return ret;
|
2008-11-25 03:44:06 +00:00
|
|
|
}
|
2006-11-21 12:15:58 +00:00
|
|
|
|
|
|
|
/* libmpeg2 needs 16 byte aligned buffers... test for this here
|
|
|
|
* and if it fails only a single time create our own buffers from
|
|
|
|
* there on below that are correctly aligned */
|
|
|
|
if (((uintptr_t) GST_BUFFER_DATA (*obuf)) % 16 == 0) {
|
2006-11-21 12:33:25 +00:00
|
|
|
GST_LOG_OBJECT (mpeg2dec, "return 16 byte aligned buffer");
|
2006-11-21 12:15:58 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (mpeg2dec,
|
2006-11-21 12:33:25 +00:00
|
|
|
"can't get 16 byte aligned buffers, creating our own ones");
|
2006-11-21 12:15:58 +00:00
|
|
|
gst_buffer_unref (*obuf);
|
|
|
|
mpeg2dec->can_allocate_aligned = FALSE;
|
2006-04-13 19:08:20 +00:00
|
|
|
}
|
|
|
|
|
2006-11-21 12:15:58 +00:00
|
|
|
/* can't use gst_pad_alloc_buffer() here because the output buffer will
|
2006-11-21 12:33:25 +00:00
|
|
|
* either be cropped later or be bigger than expected (for the alignment),
|
|
|
|
* and basetransform-based elements will complain about the wrong unit size
|
|
|
|
* when not operating in passthrough mode */
|
2006-11-21 12:15:58 +00:00
|
|
|
*obuf = gst_buffer_new_and_alloc (size + 15);
|
2006-11-21 12:33:25 +00:00
|
|
|
GST_BUFFER_DATA (*obuf) = (guint8 *) ALIGN_16 (GST_BUFFER_DATA (*obuf));
|
2006-11-21 12:15:58 +00:00
|
|
|
GST_BUFFER_SIZE (*obuf) = size;
|
|
|
|
gst_buffer_set_caps (*obuf, GST_PAD_CAPS (mpeg2dec->srcpad));
|
|
|
|
|
|
|
|
return GST_FLOW_OK;
|
2006-04-13 19:08:20 +00:00
|
|
|
}
|
|
|
|
|
ext/mpeg2dec/gstmpeg2dec.c: Forward GstFlowReturn about everywhere.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_reset),
(gst_mpeg2dec_alloc_buffer), (gst_mpeg2dec_negotiate_format),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_src_query), (normal_seek),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
Forward GstFlowReturn about everywhere.
Handle seeking correctly.
2005-10-27 21:50:11 +00:00
|
|
|
static GstFlowReturn
|
|
|
|
gst_mpeg2dec_alloc_buffer (GstMpeg2dec * mpeg2dec, gint64 offset,
|
|
|
|
GstBuffer ** obuf)
|
2002-12-05 00:29:11 +00:00
|
|
|
{
|
|
|
|
GstBuffer *outbuf = NULL;
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
guint8 *buf[3];
|
2005-07-19 20:51:16 +00:00
|
|
|
GstFlowReturn ret = GST_FLOW_OK;
|
|
|
|
|
2006-11-21 12:15:58 +00:00
|
|
|
ret = gst_mpeg2dec_alloc_sized_buf (mpeg2dec, mpeg2dec->size, &outbuf);
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
if (ret != GST_FLOW_OK)
|
|
|
|
goto no_buffer;
|
ext/mpeg2dec/gstmpeg2dec.c: Forward GstFlowReturn about everywhere.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_reset),
(gst_mpeg2dec_alloc_buffer), (gst_mpeg2dec_negotiate_format),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_src_query), (normal_seek),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
Forward GstFlowReturn about everywhere.
Handle seeking correctly.
2005-10-27 21:50:11 +00:00
|
|
|
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
buf[0] = GST_BUFFER_DATA (outbuf);
|
|
|
|
buf[1] = buf[0] + mpeg2dec->u_offs;
|
|
|
|
buf[2] = buf[0] + mpeg2dec->v_offs;
|
2005-07-19 20:51:16 +00:00
|
|
|
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
GST_DEBUG_OBJECT (mpeg2dec, "set_buf: %p %p %p, outbuf %p",
|
|
|
|
buf[0], buf[1], buf[2], outbuf);
|
2004-04-01 11:48:27 +00:00
|
|
|
|
2005-10-26 16:45:04 +00:00
|
|
|
mpeg2_set_buf (mpeg2dec->decoder, buf, outbuf);
|
2001-12-23 06:03:21 +00:00
|
|
|
|
2005-10-26 16:45:04 +00:00
|
|
|
/* we store the original byteoffset of this picture in the stream here
|
|
|
|
* because we need it for indexing */
|
|
|
|
GST_BUFFER_OFFSET (outbuf) = offset;
|
2005-07-19 20:51:16 +00:00
|
|
|
|
ext/mpeg2dec/gstmpeg2dec.c: Forward GstFlowReturn about everywhere.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_reset),
(gst_mpeg2dec_alloc_buffer), (gst_mpeg2dec_negotiate_format),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_src_query), (normal_seek),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
Forward GstFlowReturn about everywhere.
Handle seeking correctly.
2005-10-27 21:50:11 +00:00
|
|
|
*obuf = outbuf;
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
no_buffer:
|
|
|
|
{
|
|
|
|
if (GST_FLOW_IS_FATAL (ret)) {
|
|
|
|
GST_ELEMENT_ERROR (mpeg2dec, RESOURCE, FAILED, (NULL),
|
|
|
|
("Failed to allocate memory for buffer, reason %s",
|
|
|
|
gst_flow_get_name (ret)));
|
|
|
|
}
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
GST_DEBUG_OBJECT (mpeg2dec, "no output buffer, reason %s",
|
|
|
|
gst_flow_get_name (ret));
|
|
|
|
mpeg2_set_buf (mpeg2dec->decoder, mpeg2dec->dummybuf, NULL);
|
2006-04-13 19:08:20 +00:00
|
|
|
*obuf = NULL;
|
|
|
|
return ret;
|
ext/mpeg2dec/gstmpeg2dec.c: Forward GstFlowReturn about everywhere.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_reset),
(gst_mpeg2dec_alloc_buffer), (gst_mpeg2dec_negotiate_format),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_src_query), (normal_seek),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
Forward GstFlowReturn about everywhere.
Handle seeking correctly.
2005-10-27 21:50:11 +00:00
|
|
|
}
|
2001-12-23 06:03:21 +00:00
|
|
|
}
|
|
|
|
|
2002-12-05 00:29:11 +00:00
|
|
|
static gboolean
|
2004-03-14 22:34:30 +00:00
|
|
|
gst_mpeg2dec_negotiate_format (GstMpeg2dec * mpeg2dec)
|
2001-12-23 06:03:21 +00:00
|
|
|
{
|
2003-12-22 01:47:08 +00:00
|
|
|
GstCaps *caps;
|
2005-10-26 16:45:04 +00:00
|
|
|
guint32 fourcc;
|
2004-03-31 06:31:47 +00:00
|
|
|
const mpeg2_info_t *info;
|
|
|
|
const mpeg2_sequence_t *sequence;
|
2002-12-05 00:29:11 +00:00
|
|
|
|
2004-03-31 06:31:47 +00:00
|
|
|
info = mpeg2_info (mpeg2dec->decoder);
|
|
|
|
sequence = info->sequence;
|
|
|
|
|
|
|
|
if (sequence->width != sequence->chroma_width &&
|
2005-10-26 16:45:04 +00:00
|
|
|
sequence->height != sequence->chroma_height) {
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
|
2005-10-26 16:45:04 +00:00
|
|
|
fourcc = GST_STR_FOURCC ("I420");
|
|
|
|
mpeg2dec->format = MPEG2DEC_FORMAT_I420;
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
mpeg2dec->size =
|
|
|
|
I420_SIZE (mpeg2dec->decoded_width, mpeg2dec->decoded_height);
|
|
|
|
|
|
|
|
mpeg2dec->u_offs =
|
|
|
|
I420_U_OFFSET (mpeg2dec->decoded_width, mpeg2dec->decoded_height);
|
|
|
|
mpeg2dec->v_offs =
|
|
|
|
I420_V_OFFSET (mpeg2dec->decoded_width, mpeg2dec->decoded_height);
|
|
|
|
|
2008-12-01 14:39:34 +00:00
|
|
|
} else if ((sequence->width == sequence->chroma_width &&
|
|
|
|
sequence->height != sequence->chroma_height) ||
|
|
|
|
(sequence->width != sequence->chroma_width &&
|
|
|
|
sequence->height == sequence->chroma_height)) {
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
gint halfsize;
|
|
|
|
|
2005-10-26 16:45:04 +00:00
|
|
|
fourcc = GST_STR_FOURCC ("Y42B");
|
|
|
|
mpeg2dec->format = MPEG2DEC_FORMAT_I422;
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
halfsize = mpeg2dec->decoded_width * mpeg2dec->decoded_height;
|
|
|
|
mpeg2dec->size = halfsize * 2;
|
|
|
|
mpeg2dec->u_offs = halfsize;
|
|
|
|
mpeg2dec->v_offs = halfsize + (halfsize / 2);
|
2005-10-26 16:45:04 +00:00
|
|
|
} else {
|
2008-11-25 03:44:06 +00:00
|
|
|
gint size;
|
|
|
|
|
|
|
|
size = mpeg2dec->decoded_width * mpeg2dec->decoded_height;
|
|
|
|
|
|
|
|
fourcc = GST_STR_FOURCC ("Y444");
|
|
|
|
mpeg2dec->format = MPEG2DEC_FORMAT_Y444;
|
|
|
|
mpeg2dec->size = size * 3;
|
|
|
|
mpeg2dec->u_offs = size;
|
|
|
|
mpeg2dec->v_offs = size * 2;
|
2004-03-31 06:31:47 +00:00
|
|
|
}
|
|
|
|
|
2006-06-19 11:59:14 +00:00
|
|
|
if (mpeg2dec->pixel_width == 0 || mpeg2dec->pixel_height == 0) {
|
2006-06-19 15:16:43 +00:00
|
|
|
GValue par = { 0, }
|
|
|
|
, dar = {
|
|
|
|
0,}
|
|
|
|
, dimensions = {
|
|
|
|
0,};
|
|
|
|
|
|
|
|
/* assume display aspect ratio (DAR) of 4:3 */
|
|
|
|
g_value_init (&dar, GST_TYPE_FRACTION);
|
|
|
|
gst_value_set_fraction (&dar, 4, 3);
|
|
|
|
g_value_init (&dimensions, GST_TYPE_FRACTION);
|
|
|
|
gst_value_set_fraction (&dimensions, mpeg2dec->height, mpeg2dec->width);
|
|
|
|
|
|
|
|
g_value_init (&par, GST_TYPE_FRACTION);
|
|
|
|
if (!gst_value_fraction_multiply (&par, &dar, &dimensions)) {
|
|
|
|
gst_value_set_fraction (&dimensions, 1, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
mpeg2dec->pixel_width = gst_value_get_fraction_numerator (&par);
|
|
|
|
mpeg2dec->pixel_height = gst_value_get_fraction_denominator (&par);
|
|
|
|
|
|
|
|
GST_WARNING_OBJECT (mpeg2dec, "Unknown pixel-aspect-ratio, assuming %d:%d",
|
|
|
|
mpeg2dec->pixel_width, mpeg2dec->pixel_height);
|
|
|
|
|
|
|
|
g_value_unset (&par);
|
|
|
|
g_value_unset (&dar);
|
|
|
|
g_value_unset (&dimensions);
|
2006-06-19 11:59:14 +00:00
|
|
|
}
|
|
|
|
|
2004-01-02 10:06:22 +00:00
|
|
|
caps = gst_caps_new_simple ("video/x-raw-yuv",
|
2005-10-26 16:45:04 +00:00
|
|
|
"format", GST_TYPE_FOURCC, fourcc,
|
2004-03-14 22:34:30 +00:00
|
|
|
"width", G_TYPE_INT, mpeg2dec->width,
|
|
|
|
"height", G_TYPE_INT, mpeg2dec->height,
|
2004-07-27 16:43:19 +00:00
|
|
|
"pixel-aspect-ratio", GST_TYPE_FRACTION, mpeg2dec->pixel_width,
|
|
|
|
mpeg2dec->pixel_height,
|
2005-11-23 00:12:24 +00:00
|
|
|
"framerate", GST_TYPE_FRACTION, mpeg2dec->fps_n, mpeg2dec->fps_d, NULL);
|
2003-12-22 01:47:08 +00:00
|
|
|
|
2005-10-26 16:45:04 +00:00
|
|
|
gst_pad_set_caps (mpeg2dec->srcpad, caps);
|
|
|
|
gst_caps_unref (caps);
|
2003-02-02 20:03:10 +00:00
|
|
|
|
2002-12-05 00:29:11 +00:00
|
|
|
return TRUE;
|
2001-12-23 06:03:21 +00:00
|
|
|
}
|
|
|
|
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
static void
|
|
|
|
init_dummybuf (GstMpeg2dec * mpeg2dec)
|
|
|
|
{
|
2006-11-03 09:52:12 +00:00
|
|
|
g_free (mpeg2dec->dummybuf[3]);
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
|
2006-11-21 12:15:58 +00:00
|
|
|
/* libmpeg2 needs 16 byte aligned buffers... care for this here */
|
2006-11-03 09:52:12 +00:00
|
|
|
mpeg2dec->dummybuf[3] = g_malloc0 (mpeg2dec->size + 15);
|
|
|
|
mpeg2dec->dummybuf[0] = ALIGN_16 (mpeg2dec->dummybuf[3]);
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
mpeg2dec->dummybuf[1] = mpeg2dec->dummybuf[0] + mpeg2dec->u_offs;
|
2006-09-15 16:14:15 +00:00
|
|
|
mpeg2dec->dummybuf[2] = mpeg2dec->dummybuf[0] + mpeg2dec->v_offs;
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
}
|
|
|
|
|
ext/mpeg2dec/gstmpeg2dec.c: Forward GstFlowReturn about everywhere.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_reset),
(gst_mpeg2dec_alloc_buffer), (gst_mpeg2dec_negotiate_format),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_src_query), (normal_seek),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
Forward GstFlowReturn about everywhere.
Handle seeking correctly.
2005-10-27 21:50:11 +00:00
|
|
|
static GstFlowReturn
|
2005-02-04 13:43:28 +00:00
|
|
|
handle_sequence (GstMpeg2dec * mpeg2dec, const mpeg2_info_t * info)
|
|
|
|
{
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
GstFlowReturn ret = GST_FLOW_OK;
|
2005-02-04 13:43:28 +00:00
|
|
|
|
2008-02-04 14:27:32 +00:00
|
|
|
if (info->sequence->frame_period == 0) {
|
|
|
|
GST_WARNING_OBJECT (mpeg2dec, "Frame period is 0!");
|
|
|
|
ret = GST_FLOW_ERROR;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2005-02-04 13:43:28 +00:00
|
|
|
mpeg2dec->width = info->sequence->picture_width;
|
|
|
|
mpeg2dec->height = info->sequence->picture_height;
|
|
|
|
mpeg2dec->decoded_width = info->sequence->width;
|
|
|
|
mpeg2dec->decoded_height = info->sequence->height;
|
|
|
|
mpeg2dec->total_frames = 0;
|
|
|
|
|
2008-10-14 12:51:41 +00:00
|
|
|
/* don't take the sequence PAR if we already have one from the sink caps */
|
|
|
|
if (!mpeg2dec->have_par) {
|
|
|
|
mpeg2dec->pixel_width = info->sequence->pixel_width;
|
|
|
|
mpeg2dec->pixel_height = info->sequence->pixel_height;
|
|
|
|
}
|
|
|
|
|
2008-07-13 10:13:06 +00:00
|
|
|
/* mpeg2 video can only be from 16x16 to 4096x4096. Everything
|
|
|
|
* else is a corrupted files */
|
|
|
|
if (mpeg2dec->width > 4096 || mpeg2dec->width < 16 ||
|
|
|
|
mpeg2dec->height > 4096 || mpeg2dec->height < 16) {
|
|
|
|
GST_ERROR_OBJECT (mpeg2dec, "Invalid frame dimensions: %d x %d",
|
|
|
|
mpeg2dec->width, mpeg2dec->height);
|
|
|
|
return GST_FLOW_ERROR;
|
|
|
|
}
|
|
|
|
|
2006-11-15 13:57:21 +00:00
|
|
|
/* set framerate */
|
|
|
|
mpeg2dec->fps_n = 27000000;
|
|
|
|
mpeg2dec->fps_d = info->sequence->frame_period;
|
2005-02-04 13:43:28 +00:00
|
|
|
mpeg2dec->frame_period = info->sequence->frame_period * GST_USECOND / 27;
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (mpeg2dec,
|
2005-11-23 00:12:24 +00:00
|
|
|
"sequence flags: %d, frame period: %d (%g), frame rate: %d/%d",
|
2005-02-04 13:43:28 +00:00
|
|
|
info->sequence->flags, info->sequence->frame_period,
|
2005-11-23 00:12:24 +00:00
|
|
|
(double) (mpeg2dec->frame_period) / GST_SECOND, mpeg2dec->fps_n,
|
|
|
|
mpeg2dec->fps_d);
|
2005-02-04 13:43:28 +00:00
|
|
|
GST_DEBUG_OBJECT (mpeg2dec, "profile: %02x, colour_primaries: %d",
|
|
|
|
info->sequence->profile_level_id, info->sequence->colour_primaries);
|
|
|
|
GST_DEBUG_OBJECT (mpeg2dec, "transfer chars: %d, matrix coef: %d",
|
|
|
|
info->sequence->transfer_characteristics,
|
|
|
|
info->sequence->matrix_coefficients);
|
|
|
|
|
2005-10-26 16:45:04 +00:00
|
|
|
if (!gst_mpeg2dec_negotiate_format (mpeg2dec))
|
|
|
|
goto negotiate_failed;
|
|
|
|
|
|
|
|
mpeg2_custom_fbuf (mpeg2dec->decoder, 1);
|
2005-02-04 13:43:28 +00:00
|
|
|
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
init_dummybuf (mpeg2dec);
|
2005-02-04 13:43:28 +00:00
|
|
|
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
/* Pump in some null buffers, because otherwise libmpeg2 doesn't
|
|
|
|
* initialise the discard_fbuf->id */
|
|
|
|
mpeg2_set_buf (mpeg2dec->decoder, mpeg2dec->dummybuf, NULL);
|
|
|
|
mpeg2_set_buf (mpeg2dec->decoder, mpeg2dec->dummybuf, NULL);
|
|
|
|
mpeg2_set_buf (mpeg2dec->decoder, mpeg2dec->dummybuf, NULL);
|
2005-10-27 17:26:13 +00:00
|
|
|
|
2005-02-04 13:43:28 +00:00
|
|
|
mpeg2dec->need_sequence = FALSE;
|
|
|
|
|
ext/mpeg2dec/gstmpeg2dec.c: Forward GstFlowReturn about everywhere.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_reset),
(gst_mpeg2dec_alloc_buffer), (gst_mpeg2dec_negotiate_format),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_src_query), (normal_seek),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
Forward GstFlowReturn about everywhere.
Handle seeking correctly.
2005-10-27 21:50:11 +00:00
|
|
|
done:
|
|
|
|
return ret;
|
2005-10-26 16:45:04 +00:00
|
|
|
|
|
|
|
negotiate_failed:
|
|
|
|
{
|
|
|
|
GST_ELEMENT_ERROR (mpeg2dec, CORE, NEGOTIATION, (NULL), (NULL));
|
ext/mpeg2dec/gstmpeg2dec.c: Forward GstFlowReturn about everywhere.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_reset),
(gst_mpeg2dec_alloc_buffer), (gst_mpeg2dec_negotiate_format),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_src_query), (normal_seek),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
Forward GstFlowReturn about everywhere.
Handle seeking correctly.
2005-10-27 21:50:11 +00:00
|
|
|
ret = GST_FLOW_NOT_NEGOTIATED;
|
|
|
|
goto done;
|
2005-10-26 16:45:04 +00:00
|
|
|
}
|
2005-02-04 13:43:28 +00:00
|
|
|
}
|
|
|
|
|
2006-06-07 17:05:48 +00:00
|
|
|
static void
|
|
|
|
clear_buffers (GstMpeg2dec * mpeg2dec)
|
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
GstBuffer **bufpen;
|
|
|
|
|
|
|
|
for (i = 0; i < 4; i++) {
|
|
|
|
bufpen = &mpeg2dec->ip_buffers[i];
|
|
|
|
if (*bufpen)
|
|
|
|
gst_buffer_unref (*bufpen);
|
|
|
|
*bufpen = NULL;
|
|
|
|
}
|
|
|
|
bufpen = &mpeg2dec->b_buffer;
|
|
|
|
if (*bufpen)
|
|
|
|
gst_buffer_unref (*bufpen);
|
|
|
|
*bufpen = NULL;
|
|
|
|
}
|
|
|
|
|
2008-01-10 15:24:08 +00:00
|
|
|
static void
|
|
|
|
clear_queued (GstMpeg2dec * mpeg2dec)
|
|
|
|
{
|
|
|
|
g_list_foreach (mpeg2dec->queued, (GFunc) gst_mini_object_unref, NULL);
|
|
|
|
g_list_free (mpeg2dec->queued);
|
|
|
|
mpeg2dec->queued = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstFlowReturn
|
|
|
|
flush_queued (GstMpeg2dec * mpeg2dec)
|
|
|
|
{
|
2008-01-14 11:41:32 +00:00
|
|
|
GstFlowReturn res = GST_FLOW_OK;
|
2008-01-10 15:24:08 +00:00
|
|
|
|
|
|
|
while (mpeg2dec->queued) {
|
|
|
|
GstBuffer *buf = GST_BUFFER_CAST (mpeg2dec->queued->data);
|
|
|
|
|
|
|
|
GST_LOG_OBJECT (mpeg2dec, "pushing buffer %p, timestamp %"
|
|
|
|
GST_TIME_FORMAT ", duration %" GST_TIME_FORMAT, buf,
|
|
|
|
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)),
|
|
|
|
GST_TIME_ARGS (GST_BUFFER_DURATION (buf)));
|
|
|
|
|
|
|
|
/* iterate ouput queue an push downstream */
|
|
|
|
res = gst_pad_push (mpeg2dec->srcpad, buf);
|
|
|
|
|
|
|
|
mpeg2dec->queued = g_list_delete_link (mpeg2dec->queued, mpeg2dec->queued);
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
ext/mpeg2dec/gstmpeg2dec.c: Forward GstFlowReturn about everywhere.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_reset),
(gst_mpeg2dec_alloc_buffer), (gst_mpeg2dec_negotiate_format),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_src_query), (normal_seek),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
Forward GstFlowReturn about everywhere.
Handle seeking correctly.
2005-10-27 21:50:11 +00:00
|
|
|
static GstFlowReturn
|
2005-02-04 13:43:28 +00:00
|
|
|
handle_picture (GstMpeg2dec * mpeg2dec, const mpeg2_info_t * info)
|
|
|
|
{
|
|
|
|
gboolean key_frame = FALSE;
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
GstBuffer *outbuf, **bufpen;
|
ext/mpeg2dec/gstmpeg2dec.c: Forward GstFlowReturn about everywhere.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_reset),
(gst_mpeg2dec_alloc_buffer), (gst_mpeg2dec_negotiate_format),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_src_query), (normal_seek),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
Forward GstFlowReturn about everywhere.
Handle seeking correctly.
2005-10-27 21:50:11 +00:00
|
|
|
GstFlowReturn ret;
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
gint type;
|
2005-02-04 13:43:28 +00:00
|
|
|
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
ret = gst_mpeg2dec_alloc_buffer (mpeg2dec, mpeg2dec->offset, &outbuf);
|
|
|
|
if (ret != GST_FLOW_OK)
|
|
|
|
goto no_buffer;
|
2005-10-26 16:45:04 +00:00
|
|
|
|
2005-02-04 13:43:28 +00:00
|
|
|
if (info->current_picture) {
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
type = info->current_picture->flags & PIC_MASK_CODING_TYPE;
|
|
|
|
} else {
|
|
|
|
type = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (mpeg2dec, "handle picture type %d", type);
|
|
|
|
|
|
|
|
key_frame = type == PIC_FLAG_CODING_TYPE_I;
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case PIC_FLAG_CODING_TYPE_I:
|
|
|
|
mpeg2_skip (mpeg2dec->decoder, 0);
|
2008-01-10 15:24:08 +00:00
|
|
|
if (mpeg2dec->segment.rate < 0.0) {
|
|
|
|
/* negative rate, flush the queued pictures in reverse */
|
|
|
|
GST_DEBUG_OBJECT (mpeg2dec, "flushing queued buffers");
|
|
|
|
flush_queued (mpeg2dec);
|
|
|
|
}
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
case PIC_FLAG_CODING_TYPE_P:
|
2006-06-07 17:05:48 +00:00
|
|
|
bufpen = &mpeg2dec->ip_buffers[mpeg2dec->ip_bufpos];
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
GST_DEBUG_OBJECT (mpeg2dec, "I/P unref %p, ref %p", *bufpen, outbuf);
|
|
|
|
if (*bufpen)
|
|
|
|
gst_buffer_unref (*bufpen);
|
|
|
|
*bufpen = outbuf;
|
|
|
|
mpeg2dec->ip_bufpos = (mpeg2dec->ip_bufpos + 1) & 3;
|
|
|
|
break;
|
|
|
|
case PIC_FLAG_CODING_TYPE_B:
|
2006-06-07 17:05:48 +00:00
|
|
|
bufpen = &mpeg2dec->b_buffer;
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
GST_DEBUG_OBJECT (mpeg2dec, "B unref %p, ref %p", *bufpen, outbuf);
|
|
|
|
if (*bufpen)
|
|
|
|
gst_buffer_unref (*bufpen);
|
|
|
|
*bufpen = outbuf;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2005-02-04 13:43:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (mpeg2dec, "picture %s, outbuf %p, offset %"
|
|
|
|
G_GINT64_FORMAT,
|
|
|
|
key_frame ? ", kf," : " ", outbuf, GST_BUFFER_OFFSET (outbuf)
|
|
|
|
);
|
|
|
|
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
if (mpeg2dec->discont_state == MPEG2DEC_DISC_NEW_PICTURE && key_frame) {
|
2005-02-04 13:43:28 +00:00
|
|
|
mpeg2dec->discont_state = MPEG2DEC_DISC_NEW_KEYFRAME;
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
}
|
2005-02-04 13:43:28 +00:00
|
|
|
|
ext/mpeg2dec/gstmpeg2dec.c: Forward GstFlowReturn about everywhere.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_reset),
(gst_mpeg2dec_alloc_buffer), (gst_mpeg2dec_negotiate_format),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_src_query), (normal_seek),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
Forward GstFlowReturn about everywhere.
Handle seeking correctly.
2005-10-27 21:50:11 +00:00
|
|
|
return ret;
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
|
|
|
|
no_buffer:
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
2005-02-04 13:43:28 +00:00
|
|
|
}
|
|
|
|
|
2008-01-10 15:24:08 +00:00
|
|
|
/* try to clip the buffer to the segment boundaries */
|
|
|
|
static gboolean
|
|
|
|
clip_buffer (GstMpeg2dec * dec, GstBuffer * buf)
|
|
|
|
{
|
|
|
|
gboolean res = TRUE;
|
|
|
|
GstClockTime in_ts, in_dur, stop;
|
|
|
|
gint64 cstart, cstop;
|
|
|
|
|
|
|
|
in_ts = GST_BUFFER_TIMESTAMP (buf);
|
|
|
|
in_dur = GST_BUFFER_DURATION (buf);
|
|
|
|
|
|
|
|
GST_LOG_OBJECT (dec,
|
|
|
|
"timestamp:%" GST_TIME_FORMAT " , duration:%" GST_TIME_FORMAT,
|
|
|
|
GST_TIME_ARGS (in_ts), GST_TIME_ARGS (in_dur));
|
|
|
|
|
|
|
|
/* can't clip without TIME segment */
|
|
|
|
if (dec->segment.format != GST_FORMAT_TIME)
|
|
|
|
goto beach;
|
|
|
|
|
|
|
|
/* we need a start time */
|
|
|
|
if (!GST_CLOCK_TIME_IS_VALID (in_ts))
|
|
|
|
goto beach;
|
|
|
|
|
|
|
|
/* generate valid stop, if duration unknown, we have unknown stop */
|
|
|
|
stop =
|
|
|
|
GST_CLOCK_TIME_IS_VALID (in_dur) ? (in_ts + in_dur) : GST_CLOCK_TIME_NONE;
|
|
|
|
|
|
|
|
/* now clip */
|
|
|
|
if (!(res = gst_segment_clip (&dec->segment, GST_FORMAT_TIME,
|
|
|
|
in_ts, stop, &cstart, &cstop)))
|
|
|
|
goto beach;
|
|
|
|
|
|
|
|
/* update timestamp and possibly duration if the clipped stop time is
|
|
|
|
* valid */
|
|
|
|
GST_BUFFER_TIMESTAMP (buf) = cstart;
|
|
|
|
if (GST_CLOCK_TIME_IS_VALID (cstop))
|
|
|
|
GST_BUFFER_DURATION (buf) = cstop - cstart;
|
|
|
|
|
|
|
|
beach:
|
|
|
|
GST_LOG_OBJECT (dec, "%sdropping", (res ? "not " : ""));
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
ext/mpeg2dec/gstmpeg2dec.c: Forward GstFlowReturn about everywhere.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_reset),
(gst_mpeg2dec_alloc_buffer), (gst_mpeg2dec_negotiate_format),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_src_query), (normal_seek),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
Forward GstFlowReturn about everywhere.
Handle seeking correctly.
2005-10-27 21:50:11 +00:00
|
|
|
static GstFlowReturn
|
2005-02-04 13:43:28 +00:00
|
|
|
handle_slice (GstMpeg2dec * mpeg2dec, const mpeg2_info_t * info)
|
|
|
|
{
|
|
|
|
GstBuffer *outbuf = NULL;
|
ext/mpeg2dec/gstmpeg2dec.c: Forward GstFlowReturn about everywhere.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_reset),
(gst_mpeg2dec_alloc_buffer), (gst_mpeg2dec_negotiate_format),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_src_query), (normal_seek),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
Forward GstFlowReturn about everywhere.
Handle seeking correctly.
2005-10-27 21:50:11 +00:00
|
|
|
GstFlowReturn ret = GST_FLOW_OK;
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
const mpeg2_picture_t *picture;
|
|
|
|
gboolean key_frame = FALSE;
|
|
|
|
GstClockTime time;
|
2005-10-19 16:01:35 +00:00
|
|
|
|
2005-02-04 13:43:28 +00:00
|
|
|
GST_DEBUG_OBJECT (mpeg2dec, "picture slice/end %p %p %p %p",
|
|
|
|
info->display_fbuf,
|
|
|
|
info->display_picture, info->current_picture,
|
|
|
|
(info->display_fbuf ? info->display_fbuf->id : NULL));
|
|
|
|
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
if (!info->display_fbuf || !info->display_fbuf->id)
|
|
|
|
goto no_display;
|
2005-02-04 13:43:28 +00:00
|
|
|
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
outbuf = GST_BUFFER (info->display_fbuf->id);
|
2005-02-04 13:43:28 +00:00
|
|
|
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
picture = info->display_picture;
|
2005-02-04 13:43:28 +00:00
|
|
|
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
key_frame = (picture->flags & PIC_MASK_CODING_TYPE) == PIC_FLAG_CODING_TYPE_I;
|
2005-10-27 17:26:13 +00:00
|
|
|
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
GST_DEBUG_OBJECT (mpeg2dec, "picture flags: %d, type: %d, keyframe: %d",
|
|
|
|
picture->flags, picture->flags & PIC_MASK_CODING_TYPE, key_frame);
|
2005-02-04 13:43:28 +00:00
|
|
|
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
if (key_frame) {
|
|
|
|
GST_BUFFER_FLAG_UNSET (outbuf, GST_BUFFER_FLAG_DELTA_UNIT);
|
|
|
|
mpeg2_skip (mpeg2dec->decoder, 0);
|
|
|
|
} else {
|
|
|
|
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DELTA_UNIT);
|
|
|
|
}
|
2005-10-27 17:26:13 +00:00
|
|
|
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
if (mpeg2dec->discont_state == MPEG2DEC_DISC_NEW_KEYFRAME && key_frame)
|
|
|
|
mpeg2dec->discont_state = MPEG2DEC_DISC_NONE;
|
2005-02-04 13:43:28 +00:00
|
|
|
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
time = GST_CLOCK_TIME_NONE;
|
2005-10-27 17:26:13 +00:00
|
|
|
|
2005-02-04 13:43:28 +00:00
|
|
|
#if MPEG2_RELEASE < MPEG2_VERSION(0,4,0)
|
2006-10-10 16:58:32 +00:00
|
|
|
if (picture->flags & PIC_FLAG_PTS) {
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
time = MPEG_TIME_TO_GST_TIME (picture->pts);
|
2006-10-10 16:58:32 +00:00
|
|
|
GST_DEBUG_OBJECT (mpeg2dec, "picture pts %" G_GUINT64_FORMAT
|
|
|
|
", time %" GST_TIME_FORMAT, picture->pts, GST_TIME_ARGS (time));
|
|
|
|
}
|
2005-02-04 13:43:28 +00:00
|
|
|
#else
|
2006-10-10 16:58:32 +00:00
|
|
|
if (picture->flags & PIC_FLAG_TAGS) {
|
|
|
|
guint64 pts = (((guint64) picture->tag2) << 32) | picture->tag;
|
|
|
|
|
|
|
|
time = MPEG_TIME_TO_GST_TIME (pts);
|
|
|
|
GST_DEBUG_OBJECT (mpeg2dec, "picture tags %" G_GUINT64_FORMAT
|
|
|
|
", time %" GST_TIME_FORMAT, pts, GST_TIME_ARGS (time));
|
|
|
|
}
|
2005-02-04 13:43:28 +00:00
|
|
|
#endif
|
2005-10-27 17:26:13 +00:00
|
|
|
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
if (time == GST_CLOCK_TIME_NONE) {
|
|
|
|
time = mpeg2dec->next_time;
|
|
|
|
GST_DEBUG_OBJECT (mpeg2dec, "picture didn't have pts");
|
|
|
|
} else {
|
2005-02-04 13:43:28 +00:00
|
|
|
GST_DEBUG_OBJECT (mpeg2dec,
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
"picture had pts %" GST_TIME_FORMAT ", we had %"
|
|
|
|
GST_TIME_FORMAT, GST_TIME_ARGS (time),
|
|
|
|
GST_TIME_ARGS (mpeg2dec->next_time));
|
|
|
|
mpeg2dec->next_time = time;
|
|
|
|
}
|
|
|
|
GST_BUFFER_TIMESTAMP (outbuf) = time;
|
2005-02-04 13:43:28 +00:00
|
|
|
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
/* TODO set correct offset here based on frame number */
|
|
|
|
if (info->display_picture_2nd) {
|
|
|
|
GST_BUFFER_DURATION (outbuf) = (picture->nb_fields +
|
|
|
|
info->display_picture_2nd->nb_fields) * mpeg2dec->frame_period / 2;
|
|
|
|
} else {
|
|
|
|
GST_BUFFER_DURATION (outbuf) =
|
|
|
|
picture->nb_fields * mpeg2dec->frame_period / 2;
|
|
|
|
}
|
|
|
|
mpeg2dec->next_time += GST_BUFFER_DURATION (outbuf);
|
2005-02-04 13:43:28 +00:00
|
|
|
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
GST_DEBUG_OBJECT (mpeg2dec,
|
|
|
|
"picture: %s %s fields:%d off:%" G_GINT64_FORMAT " ts:%"
|
|
|
|
GST_TIME_FORMAT,
|
|
|
|
(picture->flags & PIC_FLAG_TOP_FIELD_FIRST ? "tff " : " "),
|
|
|
|
(picture->flags & PIC_FLAG_PROGRESSIVE_FRAME ? "prog" : " "),
|
|
|
|
picture->nb_fields, GST_BUFFER_OFFSET (outbuf),
|
|
|
|
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (outbuf)));
|
|
|
|
|
2008-09-28 17:33:43 +00:00
|
|
|
#ifndef GST_DISABLE_INDEX
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
if (mpeg2dec->index) {
|
|
|
|
gst_index_add_association (mpeg2dec->index, mpeg2dec->index_id,
|
|
|
|
(key_frame ? GST_ASSOCIATION_FLAG_KEY_UNIT : 0),
|
|
|
|
GST_FORMAT_BYTES, GST_BUFFER_OFFSET (outbuf),
|
|
|
|
GST_FORMAT_TIME, GST_BUFFER_TIMESTAMP (outbuf), 0);
|
|
|
|
}
|
2008-09-28 17:33:43 +00:00
|
|
|
#endif
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
|
|
|
|
if (picture->flags & PIC_FLAG_SKIP)
|
|
|
|
goto skip;
|
|
|
|
|
|
|
|
if (mpeg2dec->discont_state != MPEG2DEC_DISC_NONE)
|
|
|
|
goto drop;
|
|
|
|
|
2008-01-10 15:24:08 +00:00
|
|
|
/* check for clipping */
|
|
|
|
if (!clip_buffer (mpeg2dec, outbuf))
|
|
|
|
goto clipped;
|
|
|
|
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
if (GST_CLOCK_TIME_IS_VALID (time)) {
|
|
|
|
gboolean need_skip;
|
|
|
|
GstClockTime qostime;
|
|
|
|
|
|
|
|
/* qos needs to be done on running time */
|
|
|
|
qostime = gst_segment_to_running_time (&mpeg2dec->segment, GST_FORMAT_TIME,
|
|
|
|
time);
|
|
|
|
|
|
|
|
GST_OBJECT_LOCK (mpeg2dec);
|
|
|
|
/* check for QoS, don't perform the last steps of getting and
|
|
|
|
* pushing the buffers that are known to be late. */
|
|
|
|
/* FIXME, we can also entirely skip decoding if the next valid buffer is
|
|
|
|
* known to be after a keyframe (using the granule_shift) */
|
|
|
|
need_skip = mpeg2dec->earliest_time != -1
|
|
|
|
&& qostime <= mpeg2dec->earliest_time;
|
|
|
|
GST_OBJECT_UNLOCK (mpeg2dec);
|
|
|
|
|
|
|
|
if (need_skip)
|
|
|
|
goto dropping_qos;
|
2005-02-04 13:43:28 +00:00
|
|
|
}
|
|
|
|
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
/* ref before pushing it out, so we still have the ref in our
|
|
|
|
* array of buffers */
|
|
|
|
gst_buffer_ref (outbuf);
|
2006-07-10 11:52:58 +00:00
|
|
|
|
|
|
|
/* do cropping if needed */
|
|
|
|
crop_buffer (mpeg2dec, &outbuf);
|
|
|
|
|
2008-01-10 15:24:08 +00:00
|
|
|
if (mpeg2dec->segment.rate >= 0.0) {
|
|
|
|
/* forward: push right away */
|
|
|
|
GST_LOG_OBJECT (mpeg2dec, "pushing buffer %p, timestamp %"
|
|
|
|
GST_TIME_FORMAT ", duration %" GST_TIME_FORMAT,
|
|
|
|
outbuf,
|
|
|
|
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (outbuf)),
|
|
|
|
GST_TIME_ARGS (GST_BUFFER_DURATION (outbuf)));
|
|
|
|
|
|
|
|
ret = gst_pad_push (mpeg2dec->srcpad, outbuf);
|
|
|
|
GST_DEBUG_OBJECT (mpeg2dec, "pushed with result %s",
|
|
|
|
gst_flow_get_name (ret));
|
|
|
|
} else {
|
|
|
|
/* reverse: queue, we'll push in reverse when we receive the next (previous)
|
|
|
|
* keyframe. */
|
|
|
|
GST_DEBUG_OBJECT (mpeg2dec, "queued frame");
|
|
|
|
mpeg2dec->queued = g_list_prepend (mpeg2dec->queued, outbuf);
|
|
|
|
ret = GST_FLOW_OK;
|
|
|
|
}
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
|
ext/mpeg2dec/gstmpeg2dec.c: Forward GstFlowReturn about everywhere.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_reset),
(gst_mpeg2dec_alloc_buffer), (gst_mpeg2dec_negotiate_format),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_src_query), (normal_seek),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
Forward GstFlowReturn about everywhere.
Handle seeking correctly.
2005-10-27 21:50:11 +00:00
|
|
|
return ret;
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
|
|
|
|
/* special cases */
|
|
|
|
no_display:
|
|
|
|
{
|
|
|
|
GST_DEBUG_OBJECT (mpeg2dec, "no picture to display");
|
|
|
|
return GST_FLOW_OK;
|
|
|
|
}
|
|
|
|
skip:
|
|
|
|
{
|
|
|
|
GST_DEBUG_OBJECT (mpeg2dec, "dropping buffer because of skip flag");
|
|
|
|
return GST_FLOW_OK;
|
|
|
|
}
|
|
|
|
drop:
|
|
|
|
{
|
|
|
|
GST_DEBUG_OBJECT (mpeg2dec, "dropping buffer, discont state %d",
|
|
|
|
mpeg2dec->discont_state);
|
|
|
|
return GST_FLOW_OK;
|
|
|
|
}
|
2008-01-10 15:24:08 +00:00
|
|
|
clipped:
|
|
|
|
{
|
|
|
|
GST_DEBUG_OBJECT (mpeg2dec, "dropping buffer, clipped");
|
|
|
|
return GST_FLOW_OK;
|
|
|
|
}
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
dropping_qos:
|
|
|
|
{
|
|
|
|
GST_DEBUG_OBJECT (mpeg2dec, "dropping buffer because of QoS");
|
|
|
|
return GST_FLOW_OK;
|
|
|
|
}
|
2005-02-04 13:43:28 +00:00
|
|
|
}
|
|
|
|
|
2003-12-22 01:47:08 +00:00
|
|
|
#if 0
|
2002-12-19 20:05:10 +00:00
|
|
|
static void
|
2004-03-14 22:34:30 +00:00
|
|
|
update_streaminfo (GstMpeg2dec * mpeg2dec)
|
2002-12-19 20:05:10 +00:00
|
|
|
{
|
|
|
|
GstCaps *caps;
|
|
|
|
GstProps *props;
|
|
|
|
GstPropsEntry *entry;
|
|
|
|
const mpeg2_info_t *info;
|
|
|
|
|
|
|
|
info = mpeg2_info (mpeg2dec->decoder);
|
|
|
|
|
|
|
|
props = gst_props_empty_new ();
|
|
|
|
|
2004-03-14 22:34:30 +00:00
|
|
|
entry =
|
|
|
|
gst_props_entry_new ("framerate",
|
|
|
|
G_TYPE_DOUBLE (GST_SECOND / (float) mpeg2dec->frame_period));
|
2002-12-19 20:05:10 +00:00
|
|
|
gst_props_add_entry (props, entry);
|
2004-03-14 22:34:30 +00:00
|
|
|
entry =
|
|
|
|
gst_props_entry_new ("bitrate",
|
|
|
|
G_TYPE_INT (info->sequence->byte_rate * 8));
|
2002-12-19 20:05:10 +00:00
|
|
|
gst_props_add_entry (props, entry);
|
|
|
|
|
|
|
|
caps = gst_caps_new ("mpeg2dec_streaminfo",
|
2004-03-14 22:34:30 +00:00
|
|
|
"application/x-gst-streaminfo", props);
|
2002-12-19 20:05:10 +00:00
|
|
|
|
2003-02-02 20:03:10 +00:00
|
|
|
gst_caps_replace_sink (&mpeg2dec->streaminfo, caps);
|
2002-12-19 20:05:10 +00:00
|
|
|
g_object_notify (G_OBJECT (mpeg2dec), "streaminfo");
|
|
|
|
}
|
2003-12-22 01:47:08 +00:00
|
|
|
#endif
|
2002-12-19 20:05:10 +00:00
|
|
|
|
2005-07-19 20:51:16 +00:00
|
|
|
static GstFlowReturn
|
|
|
|
gst_mpeg2dec_chain (GstPad * pad, GstBuffer * buf)
|
2001-12-23 06:03:21 +00:00
|
|
|
{
|
2005-10-26 16:45:04 +00:00
|
|
|
GstMpeg2dec *mpeg2dec;
|
2001-12-23 06:03:21 +00:00
|
|
|
guint32 size;
|
2002-12-05 00:29:11 +00:00
|
|
|
guint8 *data, *end;
|
ext/a52dec/gsta52dec.c: Add some debug output. Check that a discont has a valid time associated.
Original commit message from CVS:
* ext/a52dec/gsta52dec.c: (gst_a52dec_push),
(gst_a52dec_handle_event), (gst_a52dec_chain):
Add some debug output. Check that a discont has a valid
time associated.
* ext/alsa/gstalsasink.c: (gst_alsa_sink_check_event),
(gst_alsa_sink_loop):
Ignore TAG events. A little extra debug for broken timestamps.
* ext/dvdnav/dvdnavsrc.c: (dvdnavsrc_init), (dvdnavsrc_loop),
(dvdnavsrc_change_state):
Ensure we send a discont to engage the link before we send any
other events.
* ext/dvdread/dvdreadsrc.c: (dvdreadsrc_init),
(dvdreadsrc_finalize), (_close), (_open), (_seek_title),
(_seek_chapter), (seek_sector), (dvdreadsrc_get),
(dvdreadsrc_uri_get_uri), (dvdreadsrc_uri_set_uri):
Handle URI of the form dvd://title[,chapter[,angle]]. Currently only
dvd://title works in totem because typefinding sends a seek that ends
up going back to chapter 1 regardless.
* ext/mpeg2dec/gstmpeg2dec.c:
* ext/mpeg2dec/gstmpeg2dec.h:
Output correct timestamps and handle disconts.
* ext/ogg/gstoggdemux.c: (get_relative):
Small guard against a null dereference.
* ext/pango/gsttextoverlay.c: (gst_textoverlay_finalize),
(gst_textoverlay_set_property):
Free memory when done. Don't call gst_event_filler_get_duration on
EOS events. Use GST_LOG and GST_WARNING instead of g_message and
g_warning.
* ext/smoothwave/gstsmoothwave.c: (gst_smoothwave_init),
(draw_line), (gst_smoothwave_dispose), (gst_sw_sinklink),
(gst_sw_srclink), (gst_smoothwave_chain):
Draw solid lines, prettier colours.
* gst/mpeg2sub/gstmpeg2subt.c: (gst_mpeg2subt_init):
Add a default palette that'll work for some movies.
* gst/mpegstream/gstdvddemux.c: (gst_dvd_demux_init),
(gst_dvd_demux_handle_dvd_event), (gst_dvd_demux_send_discont),
(gst_dvd_demux_send_subbuffer), (gst_dvd_demux_reset):
* gst/mpegstream/gstdvddemux.h:
* gst/mpegstream/gstmpegdemux.c: (gst_mpeg_demux_send_discont),
(gst_mpeg_demux_parse_syshead), (gst_mpeg_demux_parse_pes):
* gst/mpegstream/gstmpegparse.c: (gst_mpeg_parse_init),
(gst_mpeg_parse_handle_discont), (gst_mpeg_parse_parse_packhead):
* gst/mpegstream/gstmpegparse.h:
Use PTM/NAV events when for timestamp adjustment when connected to
dvdnavsrc. Don't use many discont events where one suffices.
* gst/playback/gstplaybasebin.c: (group_destroy),
(gen_preroll_element), (gst_play_base_bin_add_element):
* gst/playback/gstplaybasebin.h:
Make sure we remove subtitles from the same bin we put them in.
* gst/subparse/gstsubparse.c: (convert_encoding), (parse_subrip),
(gst_subparse_buffer_format_autodetect),
(gst_subparse_change_state):
Fix some memleaks and invalid accesses.
* gst/typefind/gsttypefindfunctions.c: (ogganx_type_find),
(oggskel_type_find), (cmml_type_find), (plugin_init):
Some typefind functions for Annodex v3.0 files
* gst/wavparse/gstwavparse.h:
GstRiffReadClass is the correct parent class.
2005-01-25 15:34:08 +00:00
|
|
|
GstClockTime pts;
|
2002-12-05 00:29:11 +00:00
|
|
|
const mpeg2_info_t *info;
|
2003-10-06 12:16:21 +00:00
|
|
|
mpeg2_state_t state;
|
2002-12-05 00:29:11 +00:00
|
|
|
gboolean done = FALSE;
|
ext/mpeg2dec/gstmpeg2dec.c: Forward GstFlowReturn about everywhere.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_reset),
(gst_mpeg2dec_alloc_buffer), (gst_mpeg2dec_negotiate_format),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_src_query), (normal_seek),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
Forward GstFlowReturn about everywhere.
Handle seeking correctly.
2005-10-27 21:50:11 +00:00
|
|
|
GstFlowReturn ret = GST_FLOW_OK;
|
2001-12-23 06:03:21 +00:00
|
|
|
|
2005-10-26 16:45:04 +00:00
|
|
|
mpeg2dec = GST_MPEG2DEC (GST_PAD_PARENT (pad));
|
2001-12-23 06:03:21 +00:00
|
|
|
|
|
|
|
size = GST_BUFFER_SIZE (buf);
|
|
|
|
data = GST_BUFFER_DATA (buf);
|
|
|
|
pts = GST_BUFFER_TIMESTAMP (buf);
|
2005-10-26 16:45:04 +00:00
|
|
|
|
2008-01-10 15:24:08 +00:00
|
|
|
if (GST_BUFFER_IS_DISCONT (buf)) {
|
|
|
|
GST_LOG_OBJECT (mpeg2dec, "DISCONT, reset decoder");
|
|
|
|
/* when we receive a discont, reset our state as to not create too much
|
|
|
|
* distortion in the picture due to missing packets */
|
|
|
|
mpeg2_reset (mpeg2dec->decoder, 0);
|
|
|
|
mpeg2_skip (mpeg2dec->decoder, 1);
|
|
|
|
mpeg2dec->discont_state = MPEG2DEC_DISC_NEW_PICTURE;
|
|
|
|
}
|
|
|
|
|
2004-07-07 16:49:49 +00:00
|
|
|
GST_LOG_OBJECT (mpeg2dec, "received buffer, timestamp %"
|
|
|
|
GST_TIME_FORMAT ", duration %" GST_TIME_FORMAT,
|
|
|
|
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)),
|
|
|
|
GST_TIME_ARGS (GST_BUFFER_DURATION (buf)));
|
2001-12-23 06:03:21 +00:00
|
|
|
|
2005-10-26 16:45:04 +00:00
|
|
|
info = mpeg2dec->info;
|
2002-12-05 00:29:11 +00:00
|
|
|
end = data + size;
|
|
|
|
|
2005-02-04 13:43:28 +00:00
|
|
|
mpeg2dec->offset = GST_BUFFER_OFFSET (buf);
|
2005-10-26 16:45:04 +00:00
|
|
|
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
if (pts != GST_CLOCK_TIME_NONE) {
|
|
|
|
gint64 mpeg_pts = GST_TIME_TO_MPEG_TIME (pts);
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (mpeg2dec,
|
|
|
|
"have pts: %" G_GINT64_FORMAT " (%" GST_TIME_FORMAT ")",
|
|
|
|
mpeg_pts, GST_TIME_ARGS (MPEG_TIME_TO_GST_TIME (mpeg_pts)));
|
|
|
|
|
|
|
|
#if MPEG2_RELEASE >= MPEG2_VERSION(0,4,0)
|
|
|
|
mpeg2_tag_picture (mpeg2dec->decoder, mpeg_pts & 0xffffffff,
|
|
|
|
mpeg_pts >> 32);
|
|
|
|
#else
|
|
|
|
mpeg2_pts (mpeg2dec->decoder, mpeg_pts);
|
|
|
|
#endif
|
|
|
|
} else {
|
|
|
|
GST_LOG ("no pts");
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_LOG_OBJECT (mpeg2dec, "calling mpeg2_buffer");
|
|
|
|
mpeg2_buffer (mpeg2dec->decoder, data, end);
|
|
|
|
GST_LOG_OBJECT (mpeg2dec, "calling mpeg2_buffer done");
|
|
|
|
|
2002-12-05 00:29:11 +00:00
|
|
|
while (!done) {
|
ext/a52dec/gsta52dec.c: Add some debug output. Check that a discont has a valid time associated.
Original commit message from CVS:
* ext/a52dec/gsta52dec.c: (gst_a52dec_push),
(gst_a52dec_handle_event), (gst_a52dec_chain):
Add some debug output. Check that a discont has a valid
time associated.
* ext/alsa/gstalsasink.c: (gst_alsa_sink_check_event),
(gst_alsa_sink_loop):
Ignore TAG events. A little extra debug for broken timestamps.
* ext/dvdnav/dvdnavsrc.c: (dvdnavsrc_init), (dvdnavsrc_loop),
(dvdnavsrc_change_state):
Ensure we send a discont to engage the link before we send any
other events.
* ext/dvdread/dvdreadsrc.c: (dvdreadsrc_init),
(dvdreadsrc_finalize), (_close), (_open), (_seek_title),
(_seek_chapter), (seek_sector), (dvdreadsrc_get),
(dvdreadsrc_uri_get_uri), (dvdreadsrc_uri_set_uri):
Handle URI of the form dvd://title[,chapter[,angle]]. Currently only
dvd://title works in totem because typefinding sends a seek that ends
up going back to chapter 1 regardless.
* ext/mpeg2dec/gstmpeg2dec.c:
* ext/mpeg2dec/gstmpeg2dec.h:
Output correct timestamps and handle disconts.
* ext/ogg/gstoggdemux.c: (get_relative):
Small guard against a null dereference.
* ext/pango/gsttextoverlay.c: (gst_textoverlay_finalize),
(gst_textoverlay_set_property):
Free memory when done. Don't call gst_event_filler_get_duration on
EOS events. Use GST_LOG and GST_WARNING instead of g_message and
g_warning.
* ext/smoothwave/gstsmoothwave.c: (gst_smoothwave_init),
(draw_line), (gst_smoothwave_dispose), (gst_sw_sinklink),
(gst_sw_srclink), (gst_smoothwave_chain):
Draw solid lines, prettier colours.
* gst/mpeg2sub/gstmpeg2subt.c: (gst_mpeg2subt_init):
Add a default palette that'll work for some movies.
* gst/mpegstream/gstdvddemux.c: (gst_dvd_demux_init),
(gst_dvd_demux_handle_dvd_event), (gst_dvd_demux_send_discont),
(gst_dvd_demux_send_subbuffer), (gst_dvd_demux_reset):
* gst/mpegstream/gstdvddemux.h:
* gst/mpegstream/gstmpegdemux.c: (gst_mpeg_demux_send_discont),
(gst_mpeg_demux_parse_syshead), (gst_mpeg_demux_parse_pes):
* gst/mpegstream/gstmpegparse.c: (gst_mpeg_parse_init),
(gst_mpeg_parse_handle_discont), (gst_mpeg_parse_parse_packhead):
* gst/mpegstream/gstmpegparse.h:
Use PTM/NAV events when for timestamp adjustment when connected to
dvdnavsrc. Don't use many discont events where one suffices.
* gst/playback/gstplaybasebin.c: (group_destroy),
(gen_preroll_element), (gst_play_base_bin_add_element):
* gst/playback/gstplaybasebin.h:
Make sure we remove subtitles from the same bin we put them in.
* gst/subparse/gstsubparse.c: (convert_encoding), (parse_subrip),
(gst_subparse_buffer_format_autodetect),
(gst_subparse_change_state):
Fix some memleaks and invalid accesses.
* gst/typefind/gsttypefindfunctions.c: (ogganx_type_find),
(oggskel_type_find), (cmml_type_find), (plugin_init):
Some typefind functions for Annodex v3.0 files
* gst/wavparse/gstwavparse.h:
GstRiffReadClass is the correct parent class.
2005-01-25 15:34:08 +00:00
|
|
|
GST_LOG_OBJECT (mpeg2dec, "calling parse");
|
2002-12-05 00:29:11 +00:00
|
|
|
state = mpeg2_parse (mpeg2dec->decoder);
|
2004-07-07 16:49:49 +00:00
|
|
|
GST_DEBUG_OBJECT (mpeg2dec, "parse state %d", state);
|
2005-10-26 16:45:04 +00:00
|
|
|
|
2002-12-05 00:29:11 +00:00
|
|
|
switch (state) {
|
2008-11-24 09:51:39 +00:00
|
|
|
#if MPEG2_RELEASE >= MPEG2_VERSION (0, 5, 0)
|
|
|
|
case STATE_SEQUENCE_MODIFIED:
|
|
|
|
GST_DEBUG_OBJECT (mpeg2dec, "sequence modified");
|
|
|
|
/* fall through */
|
|
|
|
#endif
|
2002-12-05 00:29:11 +00:00
|
|
|
case STATE_SEQUENCE:
|
ext/mpeg2dec/gstmpeg2dec.c: Forward GstFlowReturn about everywhere.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_reset),
(gst_mpeg2dec_alloc_buffer), (gst_mpeg2dec_negotiate_format),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_src_query), (normal_seek),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
Forward GstFlowReturn about everywhere.
Handle seeking correctly.
2005-10-27 21:50:11 +00:00
|
|
|
ret = handle_sequence (mpeg2dec, info);
|
2008-02-04 14:27:32 +00:00
|
|
|
/* if there is an error handling the sequence
|
|
|
|
* reset the decoder, maybe something more elegant
|
|
|
|
* could be done.
|
|
|
|
*/
|
|
|
|
if (ret == GST_FLOW_ERROR) {
|
|
|
|
mpeg2dec->error_count++;
|
|
|
|
GST_WARNING_OBJECT (mpeg2dec, "Decoding error #%d",
|
|
|
|
mpeg2dec->error_count);
|
|
|
|
if (mpeg2dec->error_count >= WARN_THRESHOLD && WARN_THRESHOLD > 0) {
|
|
|
|
GST_ELEMENT_WARNING (mpeg2dec, STREAM, DECODE,
|
|
|
|
("%d consecutive decoding errors", mpeg2dec->error_count),
|
|
|
|
(NULL));
|
|
|
|
}
|
|
|
|
mpeg2_reset (mpeg2dec->decoder, 0);
|
|
|
|
mpeg2_skip (mpeg2dec->decoder, 1);
|
|
|
|
mpeg2dec->discont_state = MPEG2DEC_DISC_NEW_PICTURE;
|
|
|
|
|
|
|
|
goto exit;
|
|
|
|
}
|
2004-03-15 19:32:25 +00:00
|
|
|
break;
|
2002-12-05 00:29:11 +00:00
|
|
|
case STATE_SEQUENCE_REPEATED:
|
2004-07-07 16:49:49 +00:00
|
|
|
GST_DEBUG_OBJECT (mpeg2dec, "sequence repeated");
|
2005-10-26 16:45:04 +00:00
|
|
|
break;
|
2002-12-05 00:29:11 +00:00
|
|
|
case STATE_GOP:
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
GST_DEBUG_OBJECT (mpeg2dec, "gop");
|
2004-03-15 19:32:25 +00:00
|
|
|
break;
|
2002-12-05 00:29:11 +00:00
|
|
|
case STATE_PICTURE:
|
ext/mpeg2dec/gstmpeg2dec.c: Forward GstFlowReturn about everywhere.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_reset),
(gst_mpeg2dec_alloc_buffer), (gst_mpeg2dec_negotiate_format),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_src_query), (normal_seek),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
Forward GstFlowReturn about everywhere.
Handle seeking correctly.
2005-10-27 21:50:11 +00:00
|
|
|
ret = handle_picture (mpeg2dec, info);
|
2004-03-15 19:32:25 +00:00
|
|
|
break;
|
2002-12-05 00:29:11 +00:00
|
|
|
case STATE_SLICE_1ST:
|
ext/a52dec/gsta52dec.c: Add some debug output. Check that a discont has a valid time associated.
Original commit message from CVS:
* ext/a52dec/gsta52dec.c: (gst_a52dec_push),
(gst_a52dec_handle_event), (gst_a52dec_chain):
Add some debug output. Check that a discont has a valid
time associated.
* ext/alsa/gstalsasink.c: (gst_alsa_sink_check_event),
(gst_alsa_sink_loop):
Ignore TAG events. A little extra debug for broken timestamps.
* ext/dvdnav/dvdnavsrc.c: (dvdnavsrc_init), (dvdnavsrc_loop),
(dvdnavsrc_change_state):
Ensure we send a discont to engage the link before we send any
other events.
* ext/dvdread/dvdreadsrc.c: (dvdreadsrc_init),
(dvdreadsrc_finalize), (_close), (_open), (_seek_title),
(_seek_chapter), (seek_sector), (dvdreadsrc_get),
(dvdreadsrc_uri_get_uri), (dvdreadsrc_uri_set_uri):
Handle URI of the form dvd://title[,chapter[,angle]]. Currently only
dvd://title works in totem because typefinding sends a seek that ends
up going back to chapter 1 regardless.
* ext/mpeg2dec/gstmpeg2dec.c:
* ext/mpeg2dec/gstmpeg2dec.h:
Output correct timestamps and handle disconts.
* ext/ogg/gstoggdemux.c: (get_relative):
Small guard against a null dereference.
* ext/pango/gsttextoverlay.c: (gst_textoverlay_finalize),
(gst_textoverlay_set_property):
Free memory when done. Don't call gst_event_filler_get_duration on
EOS events. Use GST_LOG and GST_WARNING instead of g_message and
g_warning.
* ext/smoothwave/gstsmoothwave.c: (gst_smoothwave_init),
(draw_line), (gst_smoothwave_dispose), (gst_sw_sinklink),
(gst_sw_srclink), (gst_smoothwave_chain):
Draw solid lines, prettier colours.
* gst/mpeg2sub/gstmpeg2subt.c: (gst_mpeg2subt_init):
Add a default palette that'll work for some movies.
* gst/mpegstream/gstdvddemux.c: (gst_dvd_demux_init),
(gst_dvd_demux_handle_dvd_event), (gst_dvd_demux_send_discont),
(gst_dvd_demux_send_subbuffer), (gst_dvd_demux_reset):
* gst/mpegstream/gstdvddemux.h:
* gst/mpegstream/gstmpegdemux.c: (gst_mpeg_demux_send_discont),
(gst_mpeg_demux_parse_syshead), (gst_mpeg_demux_parse_pes):
* gst/mpegstream/gstmpegparse.c: (gst_mpeg_parse_init),
(gst_mpeg_parse_handle_discont), (gst_mpeg_parse_parse_packhead):
* gst/mpegstream/gstmpegparse.h:
Use PTM/NAV events when for timestamp adjustment when connected to
dvdnavsrc. Don't use many discont events where one suffices.
* gst/playback/gstplaybasebin.c: (group_destroy),
(gen_preroll_element), (gst_play_base_bin_add_element):
* gst/playback/gstplaybasebin.h:
Make sure we remove subtitles from the same bin we put them in.
* gst/subparse/gstsubparse.c: (convert_encoding), (parse_subrip),
(gst_subparse_buffer_format_autodetect),
(gst_subparse_change_state):
Fix some memleaks and invalid accesses.
* gst/typefind/gsttypefindfunctions.c: (ogganx_type_find),
(oggskel_type_find), (cmml_type_find), (plugin_init):
Some typefind functions for Annodex v3.0 files
* gst/wavparse/gstwavparse.h:
GstRiffReadClass is the correct parent class.
2005-01-25 15:34:08 +00:00
|
|
|
GST_LOG_OBJECT (mpeg2dec, "1st slice of frame encountered");
|
2004-03-15 19:32:25 +00:00
|
|
|
break;
|
2002-12-05 00:29:11 +00:00
|
|
|
case STATE_PICTURE_2ND:
|
ext/a52dec/gsta52dec.c: Add some debug output. Check that a discont has a valid time associated.
Original commit message from CVS:
* ext/a52dec/gsta52dec.c: (gst_a52dec_push),
(gst_a52dec_handle_event), (gst_a52dec_chain):
Add some debug output. Check that a discont has a valid
time associated.
* ext/alsa/gstalsasink.c: (gst_alsa_sink_check_event),
(gst_alsa_sink_loop):
Ignore TAG events. A little extra debug for broken timestamps.
* ext/dvdnav/dvdnavsrc.c: (dvdnavsrc_init), (dvdnavsrc_loop),
(dvdnavsrc_change_state):
Ensure we send a discont to engage the link before we send any
other events.
* ext/dvdread/dvdreadsrc.c: (dvdreadsrc_init),
(dvdreadsrc_finalize), (_close), (_open), (_seek_title),
(_seek_chapter), (seek_sector), (dvdreadsrc_get),
(dvdreadsrc_uri_get_uri), (dvdreadsrc_uri_set_uri):
Handle URI of the form dvd://title[,chapter[,angle]]. Currently only
dvd://title works in totem because typefinding sends a seek that ends
up going back to chapter 1 regardless.
* ext/mpeg2dec/gstmpeg2dec.c:
* ext/mpeg2dec/gstmpeg2dec.h:
Output correct timestamps and handle disconts.
* ext/ogg/gstoggdemux.c: (get_relative):
Small guard against a null dereference.
* ext/pango/gsttextoverlay.c: (gst_textoverlay_finalize),
(gst_textoverlay_set_property):
Free memory when done. Don't call gst_event_filler_get_duration on
EOS events. Use GST_LOG and GST_WARNING instead of g_message and
g_warning.
* ext/smoothwave/gstsmoothwave.c: (gst_smoothwave_init),
(draw_line), (gst_smoothwave_dispose), (gst_sw_sinklink),
(gst_sw_srclink), (gst_smoothwave_chain):
Draw solid lines, prettier colours.
* gst/mpeg2sub/gstmpeg2subt.c: (gst_mpeg2subt_init):
Add a default palette that'll work for some movies.
* gst/mpegstream/gstdvddemux.c: (gst_dvd_demux_init),
(gst_dvd_demux_handle_dvd_event), (gst_dvd_demux_send_discont),
(gst_dvd_demux_send_subbuffer), (gst_dvd_demux_reset):
* gst/mpegstream/gstdvddemux.h:
* gst/mpegstream/gstmpegdemux.c: (gst_mpeg_demux_send_discont),
(gst_mpeg_demux_parse_syshead), (gst_mpeg_demux_parse_pes):
* gst/mpegstream/gstmpegparse.c: (gst_mpeg_parse_init),
(gst_mpeg_parse_handle_discont), (gst_mpeg_parse_parse_packhead):
* gst/mpegstream/gstmpegparse.h:
Use PTM/NAV events when for timestamp adjustment when connected to
dvdnavsrc. Don't use many discont events where one suffices.
* gst/playback/gstplaybasebin.c: (group_destroy),
(gen_preroll_element), (gst_play_base_bin_add_element):
* gst/playback/gstplaybasebin.h:
Make sure we remove subtitles from the same bin we put them in.
* gst/subparse/gstsubparse.c: (convert_encoding), (parse_subrip),
(gst_subparse_buffer_format_autodetect),
(gst_subparse_change_state):
Fix some memleaks and invalid accesses.
* gst/typefind/gsttypefindfunctions.c: (ogganx_type_find),
(oggskel_type_find), (cmml_type_find), (plugin_init):
Some typefind functions for Annodex v3.0 files
* gst/wavparse/gstwavparse.h:
GstRiffReadClass is the correct parent class.
2005-01-25 15:34:08 +00:00
|
|
|
GST_LOG_OBJECT (mpeg2dec,
|
|
|
|
"Second picture header encountered. Decoding 2nd field");
|
2004-03-15 19:32:25 +00:00
|
|
|
break;
|
2004-01-14 06:41:52 +00:00
|
|
|
#if MPEG2_RELEASE >= MPEG2_VERSION (0, 4, 0)
|
|
|
|
case STATE_INVALID_END:
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
GST_DEBUG_OBJECT (mpeg2dec, "invalid end");
|
2004-01-14 06:41:52 +00:00
|
|
|
#endif
|
2002-12-05 00:29:11 +00:00
|
|
|
case STATE_END:
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
GST_DEBUG_OBJECT (mpeg2dec, "end");
|
2005-02-04 13:43:28 +00:00
|
|
|
mpeg2dec->need_sequence = TRUE;
|
|
|
|
case STATE_SLICE:
|
ext/mpeg2dec/gstmpeg2dec.c: Forward GstFlowReturn about everywhere.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_reset),
(gst_mpeg2dec_alloc_buffer), (gst_mpeg2dec_negotiate_format),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_src_query), (normal_seek),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
Forward GstFlowReturn about everywhere.
Handle seeking correctly.
2005-10-27 21:50:11 +00:00
|
|
|
ret = handle_slice (mpeg2dec, info);
|
2004-03-15 19:32:25 +00:00
|
|
|
break;
|
2003-10-06 12:16:21 +00:00
|
|
|
case STATE_BUFFER:
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
done = TRUE;
|
2004-03-15 19:32:25 +00:00
|
|
|
break;
|
|
|
|
/* error */
|
2002-12-05 00:29:11 +00:00
|
|
|
case STATE_INVALID:
|
2007-03-02 13:01:48 +00:00
|
|
|
/* FIXME: at some point we should probably send newsegment events to
|
|
|
|
* let downstream know that parts of the stream are missing */
|
2006-02-27 14:49:05 +00:00
|
|
|
mpeg2dec->error_count++;
|
|
|
|
GST_WARNING_OBJECT (mpeg2dec, "Decoding error #%d",
|
|
|
|
mpeg2dec->error_count);
|
2007-03-02 13:01:48 +00:00
|
|
|
if (mpeg2dec->error_count >= WARN_THRESHOLD && WARN_THRESHOLD > 0) {
|
|
|
|
GST_ELEMENT_WARNING (mpeg2dec, STREAM, DECODE,
|
|
|
|
("%d consecutive decoding errors", mpeg2dec->error_count),
|
|
|
|
(NULL));
|
2006-02-27 14:49:05 +00:00
|
|
|
}
|
2005-02-04 13:43:28 +00:00
|
|
|
goto exit;
|
2002-12-05 00:29:11 +00:00
|
|
|
default:
|
ext/a52dec/gsta52dec.c: Add some debug output. Check that a discont has a valid time associated.
Original commit message from CVS:
* ext/a52dec/gsta52dec.c: (gst_a52dec_push),
(gst_a52dec_handle_event), (gst_a52dec_chain):
Add some debug output. Check that a discont has a valid
time associated.
* ext/alsa/gstalsasink.c: (gst_alsa_sink_check_event),
(gst_alsa_sink_loop):
Ignore TAG events. A little extra debug for broken timestamps.
* ext/dvdnav/dvdnavsrc.c: (dvdnavsrc_init), (dvdnavsrc_loop),
(dvdnavsrc_change_state):
Ensure we send a discont to engage the link before we send any
other events.
* ext/dvdread/dvdreadsrc.c: (dvdreadsrc_init),
(dvdreadsrc_finalize), (_close), (_open), (_seek_title),
(_seek_chapter), (seek_sector), (dvdreadsrc_get),
(dvdreadsrc_uri_get_uri), (dvdreadsrc_uri_set_uri):
Handle URI of the form dvd://title[,chapter[,angle]]. Currently only
dvd://title works in totem because typefinding sends a seek that ends
up going back to chapter 1 regardless.
* ext/mpeg2dec/gstmpeg2dec.c:
* ext/mpeg2dec/gstmpeg2dec.h:
Output correct timestamps and handle disconts.
* ext/ogg/gstoggdemux.c: (get_relative):
Small guard against a null dereference.
* ext/pango/gsttextoverlay.c: (gst_textoverlay_finalize),
(gst_textoverlay_set_property):
Free memory when done. Don't call gst_event_filler_get_duration on
EOS events. Use GST_LOG and GST_WARNING instead of g_message and
g_warning.
* ext/smoothwave/gstsmoothwave.c: (gst_smoothwave_init),
(draw_line), (gst_smoothwave_dispose), (gst_sw_sinklink),
(gst_sw_srclink), (gst_smoothwave_chain):
Draw solid lines, prettier colours.
* gst/mpeg2sub/gstmpeg2subt.c: (gst_mpeg2subt_init):
Add a default palette that'll work for some movies.
* gst/mpegstream/gstdvddemux.c: (gst_dvd_demux_init),
(gst_dvd_demux_handle_dvd_event), (gst_dvd_demux_send_discont),
(gst_dvd_demux_send_subbuffer), (gst_dvd_demux_reset):
* gst/mpegstream/gstdvddemux.h:
* gst/mpegstream/gstmpegdemux.c: (gst_mpeg_demux_send_discont),
(gst_mpeg_demux_parse_syshead), (gst_mpeg_demux_parse_pes):
* gst/mpegstream/gstmpegparse.c: (gst_mpeg_parse_init),
(gst_mpeg_parse_handle_discont), (gst_mpeg_parse_parse_packhead):
* gst/mpegstream/gstmpegparse.h:
Use PTM/NAV events when for timestamp adjustment when connected to
dvdnavsrc. Don't use many discont events where one suffices.
* gst/playback/gstplaybasebin.c: (group_destroy),
(gen_preroll_element), (gst_play_base_bin_add_element):
* gst/playback/gstplaybasebin.h:
Make sure we remove subtitles from the same bin we put them in.
* gst/subparse/gstsubparse.c: (convert_encoding), (parse_subrip),
(gst_subparse_buffer_format_autodetect),
(gst_subparse_change_state):
Fix some memleaks and invalid accesses.
* gst/typefind/gsttypefindfunctions.c: (ogganx_type_find),
(oggskel_type_find), (cmml_type_find), (plugin_init):
Some typefind functions for Annodex v3.0 files
* gst/wavparse/gstwavparse.h:
GstRiffReadClass is the correct parent class.
2005-01-25 15:34:08 +00:00
|
|
|
GST_ERROR_OBJECT (mpeg2dec, "Unknown libmpeg2 state %d, FIXME", state);
|
2006-02-27 14:49:05 +00:00
|
|
|
goto exit;
|
2002-12-05 00:29:11 +00:00
|
|
|
}
|
2002-12-19 07:45:11 +00:00
|
|
|
|
2006-02-27 14:49:05 +00:00
|
|
|
mpeg2dec->error_count = 0;
|
|
|
|
|
2002-12-19 21:05:57 +00:00
|
|
|
/*
|
2002-12-19 07:45:11 +00:00
|
|
|
* FIXME: should pass more information such as state the user data is from
|
|
|
|
*/
|
2004-03-13 00:19:26 +00:00
|
|
|
#ifdef enable_user_data
|
2002-12-19 21:05:57 +00:00
|
|
|
if (info->user_data_len > 0) {
|
2005-10-26 16:45:04 +00:00
|
|
|
GstBuffer *udbuf = gst_buffer_new_and_alloc (info->user_data_len);
|
2002-12-19 21:05:57 +00:00
|
|
|
|
2005-10-26 16:45:04 +00:00
|
|
|
memcpy (GST_BUFFER_DATA (udbuf), info->user_data, info->user_data_len);
|
2002-12-19 21:05:57 +00:00
|
|
|
|
2005-10-26 16:45:04 +00:00
|
|
|
gst_pad_push (mpeg2dec->userdatapad, udbuf);
|
2002-12-19 21:05:57 +00:00
|
|
|
}
|
2004-03-13 00:19:26 +00:00
|
|
|
#endif
|
2005-07-19 20:51:16 +00:00
|
|
|
|
ext/mpeg2dec/gstmpeg2dec.c: Forward GstFlowReturn about everywhere.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_reset),
(gst_mpeg2dec_alloc_buffer), (gst_mpeg2dec_negotiate_format),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_src_query), (normal_seek),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
Forward GstFlowReturn about everywhere.
Handle seeking correctly.
2005-10-27 21:50:11 +00:00
|
|
|
if (ret != GST_FLOW_OK) {
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
GST_DEBUG_OBJECT (mpeg2dec, "exit loop, reason %s",
|
|
|
|
gst_flow_get_name (ret));
|
ext/mpeg2dec/gstmpeg2dec.c: Forward GstFlowReturn about everywhere.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_reset),
(gst_mpeg2dec_alloc_buffer), (gst_mpeg2dec_negotiate_format),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_src_query), (normal_seek),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
Forward GstFlowReturn about everywhere.
Handle seeking correctly.
2005-10-27 21:50:11 +00:00
|
|
|
break;
|
|
|
|
}
|
2002-12-05 00:29:11 +00:00
|
|
|
}
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
done:
|
2005-02-05 07:36:01 +00:00
|
|
|
gst_buffer_unref (buf);
|
ext/mpeg2dec/gstmpeg2dec.c: Forward GstFlowReturn about everywhere.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_reset),
(gst_mpeg2dec_alloc_buffer), (gst_mpeg2dec_negotiate_format),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_src_query), (normal_seek),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
Forward GstFlowReturn about everywhere.
Handle seeking correctly.
2005-10-27 21:50:11 +00:00
|
|
|
return ret;
|
2005-02-05 07:36:01 +00:00
|
|
|
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
/* errors */
|
2002-12-27 04:04:04 +00:00
|
|
|
exit:
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
{
|
|
|
|
ret = GST_FLOW_OK;
|
|
|
|
goto done;
|
|
|
|
}
|
2005-07-19 20:51:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_mpeg2dec_sink_event (GstPad * pad, GstEvent * event)
|
|
|
|
{
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
GstMpeg2dec *mpeg2dec;
|
2005-07-19 20:51:16 +00:00
|
|
|
gboolean ret = TRUE;
|
|
|
|
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
mpeg2dec = GST_MPEG2DEC (gst_pad_get_parent (pad));
|
|
|
|
|
ext/mpeg2dec/gstmpeg2dec.c: Set DELTA_UNIT flag on outgoing buffers if this is NOT a keyframe; nice-ify debug message...
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (handle_slice),
(gst_mpeg2dec_sink_event):
Set DELTA_UNIT flag on outgoing buffers if this is NOT a keyframe;
nice-ify debug message in event handler; add CHECKME.
* gst/mpegstream/gstdvddemux.c: (gst_dvd_demux_process_event),
(gst_dvd_demux_send_event), (gst_dvd_demux_process_private),
(gst_dvd_demux_send_subbuffer), (gst_dvd_demux_reset),
(gst_dvd_demux_sync_stream_to_time):
* gst/mpegstream/gstmpegdemux.c: (gst_mpeg_demux_class_init),
(gst_mpeg_demux_process_event), (gst_mpeg_demux_send_event),
(gst_mpeg_demux_handle_discont), (gst_mpeg_demux_new_output_pad),
(gst_mpeg_demux_parse_packet), (gst_mpeg_demux_parse_pes),
(gst_mpeg_demux_send_subbuffer), (gst_mpeg_demux_process_private),
(gst_mpeg_demux_sync_stream_to_time),
(gst_mpeg_demux_handle_src_event), (gst_mpeg_demux_reset):
* gst/mpegstream/gstmpegdemux.h:
* gst/mpegstream/gstmpegparse.c: (gst_mpeg_parse_init),
(gst_mpeg_parse_handle_discont), (gst_mpeg_parse_send_buffer),
(gst_mpeg_parse_process_event), (gst_mpeg_parse_send_discont),
(gst_mpeg_parse_send_event), (gst_mpeg_parse_event),
(gst_mpeg_parse_chain):
* gst/mpegstream/gstmpegparse.h:
Get rid of GST_PAD_IS_USABLE and fix GstFlowReturn vs. gboolean
return value confusion (gst_pad_push vs. gst_pad_send_event and
gst_pad_push_event); pass flow return values to caller;
miscellaneous fixes and clean-ups.
2005-11-15 14:19:38 +00:00
|
|
|
GST_DEBUG_OBJECT (mpeg2dec, "Got %s event on sink pad",
|
|
|
|
GST_EVENT_TYPE_NAME (event));
|
|
|
|
|
2005-07-19 20:51:16 +00:00
|
|
|
switch (GST_EVENT_TYPE (event)) {
|
Various event updates and cleanups.
Original commit message from CVS:
* ext/amrnb/amrnbparse.c: (gst_amrnbparse_event),
(gst_amrnbparse_loop):
* ext/dv/gstdvdec.c: (gst_dvdec_handle_sink_event),
(gst_dvdec_handle_src_event), (gst_dvdec_decode_frame):
* ext/mad/gstid3tag.c: (gst_id3_tag_src_event),
(gst_id3_tag_sink_event), (gst_id3_tag_chain):
* ext/mad/gstmad.c: (gst_mad_src_query), (index_seek),
(normal_seek), (gst_mad_sink_event), (gst_mad_chain):
* ext/mpeg2dec/gstmpeg2dec.c:
* ext/shout2/gstshout2.c: (gst_shout2send_event):
* ext/sidplay/gstsiddec.cc:
* gst/avi/gstavidemux.c: (gst_avi_demux_handle_src_event),
(gst_avi_demux_send_event), (gst_avi_demux_stream_header),
(gst_avi_demux_handle_seek), (gst_avi_demux_process_next_entry):
* gst/goom/gstgoom.c: (gst_goom_event):
* gst/realmedia/rmdemux.c: (gst_rmdemux_sink_event),
(gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream):
* gst/wavparse/gstwavparse.c: (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_srcpad_event):
Various event updates and cleanups.
2005-07-27 18:37:25 +00:00
|
|
|
case GST_EVENT_NEWSEGMENT:
|
2005-07-19 20:51:16 +00:00
|
|
|
{
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
gboolean update;
|
|
|
|
GstFormat format;
|
|
|
|
gdouble rate, arate;
|
|
|
|
gint64 start, stop, time;
|
|
|
|
|
|
|
|
gst_event_parse_new_segment_full (event, &update, &rate, &arate, &format,
|
|
|
|
&start, &stop, &time);
|
|
|
|
|
|
|
|
/* we need TIME and a positive rate */
|
|
|
|
if (format != GST_FORMAT_TIME)
|
|
|
|
goto newseg_wrong_format;
|
|
|
|
|
|
|
|
/* now configure the values */
|
|
|
|
gst_segment_set_newsegment_full (&mpeg2dec->segment, update,
|
|
|
|
rate, arate, format, start, stop, time);
|
|
|
|
|
2008-01-10 15:24:08 +00:00
|
|
|
GST_DEBUG_OBJECT (mpeg2dec,
|
|
|
|
"Pushing newseg rate %g, applied rate %g, format %d, start %"
|
|
|
|
G_GINT64_FORMAT ", stop %" G_GINT64_FORMAT ", pos %" G_GINT64_FORMAT,
|
|
|
|
rate, arate, format, start, stop, time);
|
|
|
|
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
ret = gst_pad_push_event (mpeg2dec->srcpad, event);
|
2005-07-19 20:51:16 +00:00
|
|
|
break;
|
|
|
|
}
|
Various event updates and cleanups.
Original commit message from CVS:
* ext/amrnb/amrnbparse.c: (gst_amrnbparse_event),
(gst_amrnbparse_loop):
* ext/dv/gstdvdec.c: (gst_dvdec_handle_sink_event),
(gst_dvdec_handle_src_event), (gst_dvdec_decode_frame):
* ext/mad/gstid3tag.c: (gst_id3_tag_src_event),
(gst_id3_tag_sink_event), (gst_id3_tag_chain):
* ext/mad/gstmad.c: (gst_mad_src_query), (index_seek),
(normal_seek), (gst_mad_sink_event), (gst_mad_chain):
* ext/mpeg2dec/gstmpeg2dec.c:
* ext/shout2/gstshout2.c: (gst_shout2send_event):
* ext/sidplay/gstsiddec.cc:
* gst/avi/gstavidemux.c: (gst_avi_demux_handle_src_event),
(gst_avi_demux_send_event), (gst_avi_demux_stream_header),
(gst_avi_demux_handle_seek), (gst_avi_demux_process_next_entry):
* gst/goom/gstgoom.c: (gst_goom_event):
* gst/realmedia/rmdemux.c: (gst_rmdemux_sink_event),
(gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream):
* gst/wavparse/gstwavparse.c: (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_srcpad_event):
Various event updates and cleanups.
2005-07-27 18:37:25 +00:00
|
|
|
case GST_EVENT_FLUSH_START:
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
ret = gst_pad_push_event (mpeg2dec->srcpad, event);
|
Various event updates and cleanups.
Original commit message from CVS:
* ext/amrnb/amrnbparse.c: (gst_amrnbparse_event),
(gst_amrnbparse_loop):
* ext/dv/gstdvdec.c: (gst_dvdec_handle_sink_event),
(gst_dvdec_handle_src_event), (gst_dvdec_decode_frame):
* ext/mad/gstid3tag.c: (gst_id3_tag_src_event),
(gst_id3_tag_sink_event), (gst_id3_tag_chain):
* ext/mad/gstmad.c: (gst_mad_src_query), (index_seek),
(normal_seek), (gst_mad_sink_event), (gst_mad_chain):
* ext/mpeg2dec/gstmpeg2dec.c:
* ext/shout2/gstshout2.c: (gst_shout2send_event):
* ext/sidplay/gstsiddec.cc:
* gst/avi/gstavidemux.c: (gst_avi_demux_handle_src_event),
(gst_avi_demux_send_event), (gst_avi_demux_stream_header),
(gst_avi_demux_handle_seek), (gst_avi_demux_process_next_entry):
* gst/goom/gstgoom.c: (gst_goom_event):
* gst/realmedia/rmdemux.c: (gst_rmdemux_sink_event),
(gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream):
* gst/wavparse/gstwavparse.c: (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_srcpad_event):
Various event updates and cleanups.
2005-07-27 18:37:25 +00:00
|
|
|
break;
|
|
|
|
case GST_EVENT_FLUSH_STOP:
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
{
|
2005-07-19 20:51:16 +00:00
|
|
|
mpeg2dec->discont_state = MPEG2DEC_DISC_NEW_PICTURE;
|
2005-10-26 16:45:04 +00:00
|
|
|
mpeg2dec->next_time = -1;;
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
gst_mpeg2dec_qos_reset (mpeg2dec);
|
2005-10-26 16:45:04 +00:00
|
|
|
mpeg2_reset (mpeg2dec->decoder, 0);
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
mpeg2_skip (mpeg2dec->decoder, 1);
|
2008-01-10 15:24:08 +00:00
|
|
|
clear_queued (mpeg2dec);
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
ret = gst_pad_push_event (mpeg2dec->srcpad, event);
|
2005-07-19 20:51:16 +00:00
|
|
|
break;
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
}
|
2005-07-19 20:51:16 +00:00
|
|
|
case GST_EVENT_EOS:
|
2008-09-28 17:33:43 +00:00
|
|
|
#ifndef GST_DISABLE_INDEX
|
2005-07-19 20:51:16 +00:00
|
|
|
if (mpeg2dec->index && mpeg2dec->closed) {
|
|
|
|
gst_index_commit (mpeg2dec->index, mpeg2dec->index_id);
|
|
|
|
}
|
2008-09-28 17:33:43 +00:00
|
|
|
#endif
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
ret = gst_pad_push_event (mpeg2dec->srcpad, event);
|
2005-07-19 20:51:16 +00:00
|
|
|
break;
|
|
|
|
default:
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
ret = gst_pad_push_event (mpeg2dec->srcpad, event);
|
2005-07-19 20:51:16 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
done:
|
|
|
|
gst_object_unref (mpeg2dec);
|
2005-07-19 20:51:16 +00:00
|
|
|
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
return ret;
|
2005-07-19 20:51:16 +00:00
|
|
|
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
/* ERRORS */
|
|
|
|
newseg_wrong_format:
|
|
|
|
{
|
|
|
|
GST_DEBUG_OBJECT (mpeg2dec, "received non TIME newsegment");
|
|
|
|
gst_event_unref (event);
|
|
|
|
goto done;
|
|
|
|
}
|
2002-12-05 00:29:11 +00:00
|
|
|
}
|
|
|
|
|
2008-10-14 12:51:41 +00:00
|
|
|
static gboolean
|
|
|
|
gst_mpeg2dec_setcaps (GstPad * pad, GstCaps * caps)
|
|
|
|
{
|
|
|
|
GstMpeg2dec *mpeg2dec;
|
|
|
|
GstStructure *s;
|
|
|
|
|
|
|
|
mpeg2dec = GST_MPEG2DEC (gst_pad_get_parent (pad));
|
|
|
|
|
|
|
|
s = gst_caps_get_structure (caps, 0);
|
|
|
|
|
|
|
|
/* parse the par, this overrides the encoded par */
|
|
|
|
mpeg2dec->have_par = gst_structure_get_fraction (s, "pixel-aspect-ratio",
|
|
|
|
&mpeg2dec->pixel_width, &mpeg2dec->pixel_height);
|
|
|
|
|
|
|
|
gst_object_unref (mpeg2dec);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2002-05-26 21:59:22 +00:00
|
|
|
static gboolean
|
2005-07-19 20:51:16 +00:00
|
|
|
gst_mpeg2dec_sink_convert (GstPad * pad, GstFormat src_format, gint64 src_value,
|
2004-03-14 22:34:30 +00:00
|
|
|
GstFormat * dest_format, gint64 * dest_value)
|
2002-05-26 21:59:22 +00:00
|
|
|
{
|
|
|
|
gboolean res = TRUE;
|
|
|
|
GstMpeg2dec *mpeg2dec;
|
2002-12-05 00:29:11 +00:00
|
|
|
const mpeg2_info_t *info;
|
2004-03-14 22:34:30 +00:00
|
|
|
|
2005-07-19 20:51:16 +00:00
|
|
|
mpeg2dec = GST_MPEG2DEC (GST_PAD_PARENT (pad));
|
2002-05-26 21:59:22 +00:00
|
|
|
|
2002-12-26 22:46:26 +00:00
|
|
|
if (mpeg2dec->decoder == NULL)
|
|
|
|
return FALSE;
|
|
|
|
|
2005-07-19 20:51:16 +00:00
|
|
|
if (src_format == *dest_format) {
|
|
|
|
*dest_value = src_value;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2002-12-05 00:29:11 +00:00
|
|
|
info = mpeg2_info (mpeg2dec->decoder);
|
|
|
|
|
2002-05-26 21:59:22 +00:00
|
|
|
switch (src_format) {
|
|
|
|
case GST_FORMAT_BYTES:
|
|
|
|
switch (*dest_format) {
|
2004-03-15 19:32:25 +00:00
|
|
|
case GST_FORMAT_TIME:
|
|
|
|
if (info->sequence && info->sequence->byte_rate) {
|
2006-06-07 17:05:48 +00:00
|
|
|
*dest_value =
|
|
|
|
gst_util_uint64_scale_int (GST_SECOND, src_value,
|
|
|
|
info->sequence->byte_rate);
|
2006-05-02 10:28:48 +00:00
|
|
|
GST_WARNING_OBJECT (mpeg2dec, "dest_value:%" GST_TIME_FORMAT,
|
|
|
|
GST_TIME_ARGS (*dest_value));
|
2004-03-15 19:32:25 +00:00
|
|
|
break;
|
2006-05-02 10:28:48 +00:00
|
|
|
} else if (info->sequence)
|
|
|
|
GST_WARNING_OBJECT (mpeg2dec,
|
|
|
|
"Cannot convert from BYTES to TIME since we don't know the bitrate at this point.");
|
2004-03-15 19:32:25 +00:00
|
|
|
default:
|
|
|
|
res = FALSE;
|
2002-05-26 21:59:22 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GST_FORMAT_TIME:
|
|
|
|
switch (*dest_format) {
|
2004-03-15 19:32:25 +00:00
|
|
|
case GST_FORMAT_BYTES:
|
|
|
|
if (info->sequence && info->sequence->byte_rate) {
|
2006-06-07 17:05:48 +00:00
|
|
|
*dest_value =
|
|
|
|
gst_util_uint64_scale_int (src_value, info->sequence->byte_rate,
|
|
|
|
GST_SECOND);
|
2004-03-15 19:32:25 +00:00
|
|
|
break;
|
2006-05-02 10:28:48 +00:00
|
|
|
} else if (info->sequence)
|
|
|
|
GST_WARNING_OBJECT (mpeg2dec,
|
|
|
|
"Cannot convert from TIME to BYTES since we don't know the bitrate at this point.");
|
2004-03-15 19:32:25 +00:00
|
|
|
default:
|
|
|
|
res = FALSE;
|
2002-05-26 21:59:22 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
res = FALSE;
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2002-12-05 00:29:11 +00:00
|
|
|
|
2002-05-26 21:59:22 +00:00
|
|
|
static gboolean
|
2005-07-19 20:51:16 +00:00
|
|
|
gst_mpeg2dec_src_convert (GstPad * pad, GstFormat src_format, gint64 src_value,
|
2004-03-14 22:34:30 +00:00
|
|
|
GstFormat * dest_format, gint64 * dest_value)
|
2002-05-26 21:59:22 +00:00
|
|
|
{
|
|
|
|
gboolean res = TRUE;
|
|
|
|
GstMpeg2dec *mpeg2dec;
|
2002-12-05 00:29:11 +00:00
|
|
|
const mpeg2_info_t *info;
|
|
|
|
guint64 scale = 1;
|
2004-03-14 22:34:30 +00:00
|
|
|
|
2005-07-19 20:51:16 +00:00
|
|
|
mpeg2dec = GST_MPEG2DEC (GST_PAD_PARENT (pad));
|
2002-05-26 21:59:22 +00:00
|
|
|
|
2002-12-26 22:46:26 +00:00
|
|
|
if (mpeg2dec->decoder == NULL)
|
|
|
|
return FALSE;
|
|
|
|
|
2005-07-19 20:51:16 +00:00
|
|
|
if (src_format == *dest_format) {
|
|
|
|
*dest_value = src_value;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2002-12-05 00:29:11 +00:00
|
|
|
info = mpeg2_info (mpeg2dec->decoder);
|
|
|
|
|
2002-05-26 21:59:22 +00:00
|
|
|
switch (src_format) {
|
|
|
|
case GST_FORMAT_BYTES:
|
|
|
|
switch (*dest_format) {
|
2004-03-15 19:32:25 +00:00
|
|
|
case GST_FORMAT_TIME:
|
|
|
|
default:
|
|
|
|
res = FALSE;
|
2002-05-26 21:59:22 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GST_FORMAT_TIME:
|
|
|
|
switch (*dest_format) {
|
2004-03-15 19:32:25 +00:00
|
|
|
case GST_FORMAT_BYTES:
|
|
|
|
scale = 6 * (mpeg2dec->width * mpeg2dec->height >> 2);
|
|
|
|
case GST_FORMAT_DEFAULT:
|
|
|
|
if (info->sequence && mpeg2dec->frame_period) {
|
2006-06-07 17:05:48 +00:00
|
|
|
*dest_value =
|
|
|
|
gst_util_uint64_scale_int (src_value, scale,
|
|
|
|
mpeg2dec->frame_period);
|
2004-03-15 19:32:25 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
res = FALSE;
|
2002-05-26 21:59:22 +00:00
|
|
|
}
|
|
|
|
break;
|
2003-05-24 10:15:28 +00:00
|
|
|
case GST_FORMAT_DEFAULT:
|
2002-05-26 21:59:22 +00:00
|
|
|
switch (*dest_format) {
|
2004-03-15 19:32:25 +00:00
|
|
|
case GST_FORMAT_TIME:
|
|
|
|
*dest_value = src_value * mpeg2dec->frame_period;
|
|
|
|
break;
|
|
|
|
case GST_FORMAT_BYTES:
|
|
|
|
*dest_value =
|
|
|
|
src_value * 6 * ((mpeg2dec->width * mpeg2dec->height) >> 2);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
res = FALSE;
|
2002-05-26 21:59:22 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
res = FALSE;
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:30 +00:00
|
|
|
static const GstQueryType *
|
|
|
|
gst_mpeg2dec_get_src_query_types (GstPad * pad)
|
2002-12-05 00:29:11 +00:00
|
|
|
{
|
2002-12-30 17:53:18 +00:00
|
|
|
static const GstQueryType types[] = {
|
|
|
|
GST_QUERY_POSITION,
|
2005-10-19 16:01:35 +00:00
|
|
|
GST_QUERY_DURATION,
|
2002-12-05 00:29:11 +00:00
|
|
|
0
|
|
|
|
};
|
2004-03-15 19:32:25 +00:00
|
|
|
|
2002-12-05 00:29:11 +00:00
|
|
|
return types;
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:30 +00:00
|
|
|
static gboolean
|
2005-07-19 20:51:16 +00:00
|
|
|
gst_mpeg2dec_src_query (GstPad * pad, GstQuery * query)
|
2002-05-26 21:59:22 +00:00
|
|
|
{
|
|
|
|
gboolean res = TRUE;
|
|
|
|
GstMpeg2dec *mpeg2dec;
|
|
|
|
|
2005-07-19 20:51:16 +00:00
|
|
|
mpeg2dec = GST_MPEG2DEC (GST_PAD_PARENT (pad));
|
2002-05-26 21:59:22 +00:00
|
|
|
|
2005-07-19 20:51:16 +00:00
|
|
|
switch (GST_QUERY_TYPE (query)) {
|
|
|
|
case GST_QUERY_POSITION:
|
2005-10-19 16:01:35 +00:00
|
|
|
{
|
|
|
|
GstFormat format;
|
|
|
|
gint64 cur;
|
|
|
|
|
|
|
|
/* save requested format */
|
|
|
|
gst_query_parse_position (query, &format, NULL);
|
|
|
|
|
|
|
|
/* and convert to the requested format */
|
2005-10-26 16:45:04 +00:00
|
|
|
if (!gst_mpeg2dec_src_convert (pad, GST_FORMAT_TIME,
|
|
|
|
mpeg2dec->next_time, &format, &cur))
|
|
|
|
goto error;
|
2005-10-19 16:01:35 +00:00
|
|
|
|
|
|
|
gst_query_set_position (query, format, cur);
|
|
|
|
|
|
|
|
GST_LOG_OBJECT (mpeg2dec,
|
|
|
|
"position query: we return %llu (format %u)", cur, format);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case GST_QUERY_DURATION:
|
2002-05-26 21:59:22 +00:00
|
|
|
{
|
2005-07-19 20:51:16 +00:00
|
|
|
GstFormat format;
|
|
|
|
GstFormat rformat;
|
2005-10-19 16:01:35 +00:00
|
|
|
gint64 total, total_bytes;
|
2005-07-19 20:51:16 +00:00
|
|
|
GstPad *peer;
|
2004-03-15 19:32:25 +00:00
|
|
|
|
2005-10-26 16:45:04 +00:00
|
|
|
if ((peer = gst_pad_get_peer (mpeg2dec->sinkpad)) == NULL)
|
|
|
|
goto error;
|
|
|
|
|
2006-05-02 10:28:48 +00:00
|
|
|
/* save requested format */
|
|
|
|
gst_query_parse_duration (query, &format, NULL);
|
|
|
|
|
2005-10-26 16:45:04 +00:00
|
|
|
/* send to peer */
|
|
|
|
if ((res = gst_pad_query (peer, query))) {
|
|
|
|
gst_object_unref (peer);
|
|
|
|
goto done;
|
|
|
|
} else {
|
|
|
|
GST_LOG_OBJECT (mpeg2dec, "query on peer pad failed, trying bytes");
|
|
|
|
}
|
|
|
|
|
2005-07-19 20:51:16 +00:00
|
|
|
/* query peer for total length in bytes */
|
2005-10-19 16:01:35 +00:00
|
|
|
gst_query_set_duration (query, GST_FORMAT_BYTES, -1);
|
2005-07-19 20:51:16 +00:00
|
|
|
|
2005-10-26 16:45:04 +00:00
|
|
|
if (!(res = gst_pad_query (peer, query))) {
|
2005-07-19 20:51:16 +00:00
|
|
|
GST_LOG_OBJECT (mpeg2dec, "query on peer pad failed");
|
2005-10-26 16:45:04 +00:00
|
|
|
gst_object_unref (peer);
|
2005-07-19 20:51:16 +00:00
|
|
|
goto error;
|
2002-05-26 21:59:22 +00:00
|
|
|
}
|
2005-07-19 20:51:16 +00:00
|
|
|
gst_object_unref (peer);
|
|
|
|
|
|
|
|
/* get the returned format */
|
2005-10-19 16:01:35 +00:00
|
|
|
gst_query_parse_duration (query, &rformat, &total_bytes);
|
2005-10-26 16:45:04 +00:00
|
|
|
GST_LOG_OBJECT (mpeg2dec, "peer pad returned total=%lld bytes",
|
|
|
|
total_bytes);
|
2005-07-19 20:51:16 +00:00
|
|
|
|
|
|
|
if (total_bytes != -1) {
|
2005-10-26 16:45:04 +00:00
|
|
|
if (!gst_mpeg2dec_sink_convert (pad, GST_FORMAT_BYTES, total_bytes,
|
|
|
|
&format, &total))
|
|
|
|
goto error;
|
2005-07-19 20:51:16 +00:00
|
|
|
} else {
|
|
|
|
total = -1;
|
2002-05-26 21:59:22 +00:00
|
|
|
}
|
2005-07-19 20:51:16 +00:00
|
|
|
|
2005-10-19 16:01:35 +00:00
|
|
|
gst_query_set_duration (query, format, total);
|
2005-07-19 20:51:16 +00:00
|
|
|
|
|
|
|
GST_LOG_OBJECT (mpeg2dec,
|
2005-10-19 16:01:35 +00:00
|
|
|
"position query: we return %llu (format %u)", total, format);
|
2002-05-26 21:59:22 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
2006-01-10 11:43:37 +00:00
|
|
|
res = gst_pad_query_default (pad, query);
|
2002-05-26 21:59:22 +00:00
|
|
|
break;
|
|
|
|
}
|
2005-10-26 16:45:04 +00:00
|
|
|
done:
|
2002-05-26 21:59:22 +00:00
|
|
|
return res;
|
2005-07-19 20:51:16 +00:00
|
|
|
|
|
|
|
error:
|
|
|
|
|
|
|
|
GST_DEBUG ("error handling query");
|
|
|
|
return FALSE;
|
2002-05-26 21:59:22 +00:00
|
|
|
}
|
|
|
|
|
2002-12-05 00:29:11 +00:00
|
|
|
|
2005-07-19 20:51:16 +00:00
|
|
|
#if 0
|
2004-03-14 22:34:30 +00:00
|
|
|
static const GstEventMask *
|
2005-07-19 20:51:16 +00:00
|
|
|
gst_mpeg2dec_get_event_masks (GstPad * pad)
|
2002-12-05 00:29:11 +00:00
|
|
|
{
|
|
|
|
static const GstEventMask masks[] = {
|
2004-03-14 22:34:30 +00:00
|
|
|
{GST_EVENT_SEEK, GST_SEEK_METHOD_SET | GST_SEEK_FLAG_FLUSH},
|
|
|
|
{GST_EVENT_NAVIGATION, GST_EVENT_FLAG_NONE},
|
|
|
|
{0,}
|
2002-12-05 00:29:11 +00:00
|
|
|
};
|
2004-03-15 19:32:25 +00:00
|
|
|
|
2002-12-05 00:29:11 +00:00
|
|
|
return masks;
|
|
|
|
}
|
2005-07-19 20:51:16 +00:00
|
|
|
#endif
|
2002-12-05 00:29:11 +00:00
|
|
|
|
2008-09-28 17:33:43 +00:00
|
|
|
#ifndef GST_DISABLE_INDEX
|
2004-03-14 22:34:30 +00:00
|
|
|
static gboolean
|
|
|
|
index_seek (GstPad * pad, GstEvent * event)
|
2002-12-23 00:32:36 +00:00
|
|
|
{
|
|
|
|
GstIndexEntry *entry;
|
2002-12-26 22:46:26 +00:00
|
|
|
GstMpeg2dec *mpeg2dec;
|
Various event updates and cleanups.
Original commit message from CVS:
* ext/amrnb/amrnbparse.c: (gst_amrnbparse_event),
(gst_amrnbparse_loop):
* ext/dv/gstdvdec.c: (gst_dvdec_handle_sink_event),
(gst_dvdec_handle_src_event), (gst_dvdec_decode_frame):
* ext/mad/gstid3tag.c: (gst_id3_tag_src_event),
(gst_id3_tag_sink_event), (gst_id3_tag_chain):
* ext/mad/gstmad.c: (gst_mad_src_query), (index_seek),
(normal_seek), (gst_mad_sink_event), (gst_mad_chain):
* ext/mpeg2dec/gstmpeg2dec.c:
* ext/shout2/gstshout2.c: (gst_shout2send_event):
* ext/sidplay/gstsiddec.cc:
* gst/avi/gstavidemux.c: (gst_avi_demux_handle_src_event),
(gst_avi_demux_send_event), (gst_avi_demux_stream_header),
(gst_avi_demux_handle_seek), (gst_avi_demux_process_next_entry):
* gst/goom/gstgoom.c: (gst_goom_event):
* gst/realmedia/rmdemux.c: (gst_rmdemux_sink_event),
(gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream):
* gst/wavparse/gstwavparse.c: (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_srcpad_event):
Various event updates and cleanups.
2005-07-27 18:37:25 +00:00
|
|
|
gdouble rate;
|
|
|
|
GstFormat format;
|
|
|
|
GstSeekFlags flags;
|
|
|
|
GstSeekType cur_type, stop_type;
|
|
|
|
gint64 cur, stop;
|
2002-12-26 22:46:26 +00:00
|
|
|
|
2005-07-19 20:51:16 +00:00
|
|
|
mpeg2dec = GST_MPEG2DEC (GST_PAD_PARENT (pad));
|
2004-03-14 22:34:30 +00:00
|
|
|
|
Various event updates and cleanups.
Original commit message from CVS:
* ext/amrnb/amrnbparse.c: (gst_amrnbparse_event),
(gst_amrnbparse_loop):
* ext/dv/gstdvdec.c: (gst_dvdec_handle_sink_event),
(gst_dvdec_handle_src_event), (gst_dvdec_decode_frame):
* ext/mad/gstid3tag.c: (gst_id3_tag_src_event),
(gst_id3_tag_sink_event), (gst_id3_tag_chain):
* ext/mad/gstmad.c: (gst_mad_src_query), (index_seek),
(normal_seek), (gst_mad_sink_event), (gst_mad_chain):
* ext/mpeg2dec/gstmpeg2dec.c:
* ext/shout2/gstshout2.c: (gst_shout2send_event):
* ext/sidplay/gstsiddec.cc:
* gst/avi/gstavidemux.c: (gst_avi_demux_handle_src_event),
(gst_avi_demux_send_event), (gst_avi_demux_stream_header),
(gst_avi_demux_handle_seek), (gst_avi_demux_process_next_entry):
* gst/goom/gstgoom.c: (gst_goom_event):
* gst/realmedia/rmdemux.c: (gst_rmdemux_sink_event),
(gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream):
* gst/wavparse/gstwavparse.c: (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_srcpad_event):
Various event updates and cleanups.
2005-07-27 18:37:25 +00:00
|
|
|
gst_event_parse_seek (event, &rate, &format, &flags,
|
|
|
|
&cur_type, &cur, &stop_type, &stop);
|
|
|
|
|
2002-12-23 00:32:36 +00:00
|
|
|
entry = gst_index_get_assoc_entry (mpeg2dec->index, mpeg2dec->index_id,
|
Various event updates and cleanups.
Original commit message from CVS:
* ext/amrnb/amrnbparse.c: (gst_amrnbparse_event),
(gst_amrnbparse_loop):
* ext/dv/gstdvdec.c: (gst_dvdec_handle_sink_event),
(gst_dvdec_handle_src_event), (gst_dvdec_decode_frame):
* ext/mad/gstid3tag.c: (gst_id3_tag_src_event),
(gst_id3_tag_sink_event), (gst_id3_tag_chain):
* ext/mad/gstmad.c: (gst_mad_src_query), (index_seek),
(normal_seek), (gst_mad_sink_event), (gst_mad_chain):
* ext/mpeg2dec/gstmpeg2dec.c:
* ext/shout2/gstshout2.c: (gst_shout2send_event):
* ext/sidplay/gstsiddec.cc:
* gst/avi/gstavidemux.c: (gst_avi_demux_handle_src_event),
(gst_avi_demux_send_event), (gst_avi_demux_stream_header),
(gst_avi_demux_handle_seek), (gst_avi_demux_process_next_entry):
* gst/goom/gstgoom.c: (gst_goom_event):
* gst/realmedia/rmdemux.c: (gst_rmdemux_sink_event),
(gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream):
* gst/wavparse/gstwavparse.c: (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_srcpad_event):
Various event updates and cleanups.
2005-07-27 18:37:25 +00:00
|
|
|
GST_INDEX_LOOKUP_BEFORE, GST_ASSOCIATION_FLAG_KEY_UNIT, format, cur);
|
2002-12-23 00:32:36 +00:00
|
|
|
|
Various event updates and cleanups.
Original commit message from CVS:
* ext/amrnb/amrnbparse.c: (gst_amrnbparse_event),
(gst_amrnbparse_loop):
* ext/dv/gstdvdec.c: (gst_dvdec_handle_sink_event),
(gst_dvdec_handle_src_event), (gst_dvdec_decode_frame):
* ext/mad/gstid3tag.c: (gst_id3_tag_src_event),
(gst_id3_tag_sink_event), (gst_id3_tag_chain):
* ext/mad/gstmad.c: (gst_mad_src_query), (index_seek),
(normal_seek), (gst_mad_sink_event), (gst_mad_chain):
* ext/mpeg2dec/gstmpeg2dec.c:
* ext/shout2/gstshout2.c: (gst_shout2send_event):
* ext/sidplay/gstsiddec.cc:
* gst/avi/gstavidemux.c: (gst_avi_demux_handle_src_event),
(gst_avi_demux_send_event), (gst_avi_demux_stream_header),
(gst_avi_demux_handle_seek), (gst_avi_demux_process_next_entry):
* gst/goom/gstgoom.c: (gst_goom_event):
* gst/realmedia/rmdemux.c: (gst_rmdemux_sink_event),
(gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream):
* gst/wavparse/gstwavparse.c: (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_srcpad_event):
Various event updates and cleanups.
2005-07-27 18:37:25 +00:00
|
|
|
if ((entry) && gst_pad_is_linked (mpeg2dec->sinkpad)) {
|
2002-12-27 22:26:15 +00:00
|
|
|
const GstFormat *peer_formats, *try_formats;
|
2004-03-14 22:34:30 +00:00
|
|
|
|
2004-05-07 16:17:25 +00:00
|
|
|
/* since we know the exact byteoffset of the frame, make sure to seek on bytes first */
|
2004-03-14 22:34:30 +00:00
|
|
|
const GstFormat try_all_formats[] = {
|
|
|
|
GST_FORMAT_BYTES,
|
|
|
|
GST_FORMAT_TIME,
|
|
|
|
0
|
2002-12-27 22:26:15 +00:00
|
|
|
};
|
2002-12-23 00:32:36 +00:00
|
|
|
|
2002-12-27 22:26:15 +00:00
|
|
|
try_formats = try_all_formats;
|
2005-07-19 20:51:16 +00:00
|
|
|
|
|
|
|
#if 0
|
2002-12-23 00:32:36 +00:00
|
|
|
peer_formats = gst_pad_get_formats (GST_PAD_PEER (mpeg2dec->sinkpad));
|
2005-07-19 20:51:16 +00:00
|
|
|
#else
|
|
|
|
peer_formats = try_all_formats; /* FIXE ME */
|
|
|
|
#endif
|
2002-12-23 00:32:36 +00:00
|
|
|
|
2002-12-27 22:26:15 +00:00
|
|
|
while (gst_formats_contains (peer_formats, *try_formats)) {
|
2002-12-23 00:32:36 +00:00
|
|
|
gint64 value;
|
2004-03-14 22:34:30 +00:00
|
|
|
|
2002-12-27 22:26:15 +00:00
|
|
|
if (gst_index_entry_assoc_map (entry, *try_formats, &value)) {
|
2004-03-15 19:32:25 +00:00
|
|
|
GstEvent *seek_event;
|
|
|
|
|
2005-09-05 17:24:20 +00:00
|
|
|
GST_DEBUG_OBJECT (mpeg2dec, "index %s %" G_GINT64_FORMAT
|
2004-03-15 19:32:25 +00:00
|
|
|
" -> %s %" G_GINT64_FORMAT,
|
Various event updates and cleanups.
Original commit message from CVS:
* ext/amrnb/amrnbparse.c: (gst_amrnbparse_event),
(gst_amrnbparse_loop):
* ext/dv/gstdvdec.c: (gst_dvdec_handle_sink_event),
(gst_dvdec_handle_src_event), (gst_dvdec_decode_frame):
* ext/mad/gstid3tag.c: (gst_id3_tag_src_event),
(gst_id3_tag_sink_event), (gst_id3_tag_chain):
* ext/mad/gstmad.c: (gst_mad_src_query), (index_seek),
(normal_seek), (gst_mad_sink_event), (gst_mad_chain):
* ext/mpeg2dec/gstmpeg2dec.c:
* ext/shout2/gstshout2.c: (gst_shout2send_event):
* ext/sidplay/gstsiddec.cc:
* gst/avi/gstavidemux.c: (gst_avi_demux_handle_src_event),
(gst_avi_demux_send_event), (gst_avi_demux_stream_header),
(gst_avi_demux_handle_seek), (gst_avi_demux_process_next_entry):
* gst/goom/gstgoom.c: (gst_goom_event):
* gst/realmedia/rmdemux.c: (gst_rmdemux_sink_event),
(gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream):
* gst/wavparse/gstwavparse.c: (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_srcpad_event):
Various event updates and cleanups.
2005-07-27 18:37:25 +00:00
|
|
|
gst_format_get_details (format)->nick,
|
|
|
|
cur, gst_format_get_details (*try_formats)->nick, value);
|
2004-03-15 19:32:25 +00:00
|
|
|
|
|
|
|
/* lookup succeeded, create the seek */
|
|
|
|
seek_event =
|
Various event updates and cleanups.
Original commit message from CVS:
* ext/amrnb/amrnbparse.c: (gst_amrnbparse_event),
(gst_amrnbparse_loop):
* ext/dv/gstdvdec.c: (gst_dvdec_handle_sink_event),
(gst_dvdec_handle_src_event), (gst_dvdec_decode_frame):
* ext/mad/gstid3tag.c: (gst_id3_tag_src_event),
(gst_id3_tag_sink_event), (gst_id3_tag_chain):
* ext/mad/gstmad.c: (gst_mad_src_query), (index_seek),
(normal_seek), (gst_mad_sink_event), (gst_mad_chain):
* ext/mpeg2dec/gstmpeg2dec.c:
* ext/shout2/gstshout2.c: (gst_shout2send_event):
* ext/sidplay/gstsiddec.cc:
* gst/avi/gstavidemux.c: (gst_avi_demux_handle_src_event),
(gst_avi_demux_send_event), (gst_avi_demux_stream_header),
(gst_avi_demux_handle_seek), (gst_avi_demux_process_next_entry):
* gst/goom/gstgoom.c: (gst_goom_event):
* gst/realmedia/rmdemux.c: (gst_rmdemux_sink_event),
(gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream):
* gst/wavparse/gstwavparse.c: (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_srcpad_event):
Various event updates and cleanups.
2005-07-27 18:37:25 +00:00
|
|
|
gst_event_new_seek (rate, *try_formats, flags, cur_type, value,
|
|
|
|
stop_type, stop);
|
2004-05-07 16:17:25 +00:00
|
|
|
/* do the seek */
|
Various event updates and cleanups.
Original commit message from CVS:
* ext/amrnb/amrnbparse.c: (gst_amrnbparse_event),
(gst_amrnbparse_loop):
* ext/dv/gstdvdec.c: (gst_dvdec_handle_sink_event),
(gst_dvdec_handle_src_event), (gst_dvdec_decode_frame):
* ext/mad/gstid3tag.c: (gst_id3_tag_src_event),
(gst_id3_tag_sink_event), (gst_id3_tag_chain):
* ext/mad/gstmad.c: (gst_mad_src_query), (index_seek),
(normal_seek), (gst_mad_sink_event), (gst_mad_chain):
* ext/mpeg2dec/gstmpeg2dec.c:
* ext/shout2/gstshout2.c: (gst_shout2send_event):
* ext/sidplay/gstsiddec.cc:
* gst/avi/gstavidemux.c: (gst_avi_demux_handle_src_event),
(gst_avi_demux_send_event), (gst_avi_demux_stream_header),
(gst_avi_demux_handle_seek), (gst_avi_demux_process_next_entry):
* gst/goom/gstgoom.c: (gst_goom_event):
* gst/realmedia/rmdemux.c: (gst_rmdemux_sink_event),
(gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream):
* gst/wavparse/gstwavparse.c: (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_srcpad_event):
Various event updates and cleanups.
2005-07-27 18:37:25 +00:00
|
|
|
if (gst_pad_push_event (mpeg2dec->sinkpad, seek_event)) {
|
2004-03-15 19:32:25 +00:00
|
|
|
/* seek worked, we're done, loop will exit */
|
2005-02-05 07:36:01 +00:00
|
|
|
#if 0
|
2004-03-15 19:32:25 +00:00
|
|
|
mpeg2dec->segment_start = GST_EVENT_SEEK_OFFSET (event);
|
2005-02-05 07:36:01 +00:00
|
|
|
#endif
|
2004-03-15 19:32:25 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
2002-12-23 00:32:36 +00:00
|
|
|
}
|
2002-12-27 22:26:15 +00:00
|
|
|
try_formats++;
|
2002-12-23 00:32:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
2008-09-28 17:33:43 +00:00
|
|
|
#endif
|
2002-12-26 22:46:26 +00:00
|
|
|
|
2004-03-14 22:34:30 +00:00
|
|
|
static gboolean
|
|
|
|
normal_seek (GstPad * pad, GstEvent * event)
|
2002-05-26 21:59:22 +00:00
|
|
|
{
|
Various event updates and cleanups.
Original commit message from CVS:
* ext/amrnb/amrnbparse.c: (gst_amrnbparse_event),
(gst_amrnbparse_loop):
* ext/dv/gstdvdec.c: (gst_dvdec_handle_sink_event),
(gst_dvdec_handle_src_event), (gst_dvdec_decode_frame):
* ext/mad/gstid3tag.c: (gst_id3_tag_src_event),
(gst_id3_tag_sink_event), (gst_id3_tag_chain):
* ext/mad/gstmad.c: (gst_mad_src_query), (index_seek),
(normal_seek), (gst_mad_sink_event), (gst_mad_chain):
* ext/mpeg2dec/gstmpeg2dec.c:
* ext/shout2/gstshout2.c: (gst_shout2send_event):
* ext/sidplay/gstsiddec.cc:
* gst/avi/gstavidemux.c: (gst_avi_demux_handle_src_event),
(gst_avi_demux_send_event), (gst_avi_demux_stream_header),
(gst_avi_demux_handle_seek), (gst_avi_demux_process_next_entry):
* gst/goom/gstgoom.c: (gst_goom_event):
* gst/realmedia/rmdemux.c: (gst_rmdemux_sink_event),
(gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream):
* gst/wavparse/gstwavparse.c: (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_srcpad_event):
Various event updates and cleanups.
2005-07-27 18:37:25 +00:00
|
|
|
gdouble rate;
|
|
|
|
GstFormat format, conv;
|
|
|
|
GstSeekFlags flags;
|
|
|
|
GstSeekType cur_type, stop_type;
|
|
|
|
gint64 cur, stop;
|
|
|
|
gint64 time_cur, bytes_cur;
|
|
|
|
gint64 time_stop, bytes_stop;
|
ext/mpeg2dec/gstmpeg2dec.c: Forward GstFlowReturn about everywhere.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_reset),
(gst_mpeg2dec_alloc_buffer), (gst_mpeg2dec_negotiate_format),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_src_query), (normal_seek),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
Forward GstFlowReturn about everywhere.
Handle seeking correctly.
2005-10-27 21:50:11 +00:00
|
|
|
gboolean res;
|
2002-05-26 21:59:22 +00:00
|
|
|
GstMpeg2dec *mpeg2dec;
|
ext/mpeg2dec/gstmpeg2dec.c: Forward GstFlowReturn about everywhere.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_reset),
(gst_mpeg2dec_alloc_buffer), (gst_mpeg2dec_negotiate_format),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_src_query), (normal_seek),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
Forward GstFlowReturn about everywhere.
Handle seeking correctly.
2005-10-27 21:50:11 +00:00
|
|
|
GstEvent *peer_event;
|
2002-05-26 21:59:22 +00:00
|
|
|
|
2005-07-19 20:51:16 +00:00
|
|
|
mpeg2dec = GST_MPEG2DEC (GST_PAD_PARENT (pad));
|
2002-05-26 21:59:22 +00:00
|
|
|
|
2005-07-19 20:51:16 +00:00
|
|
|
GST_DEBUG ("normal seek");
|
|
|
|
|
Various event updates and cleanups.
Original commit message from CVS:
* ext/amrnb/amrnbparse.c: (gst_amrnbparse_event),
(gst_amrnbparse_loop):
* ext/dv/gstdvdec.c: (gst_dvdec_handle_sink_event),
(gst_dvdec_handle_src_event), (gst_dvdec_decode_frame):
* ext/mad/gstid3tag.c: (gst_id3_tag_src_event),
(gst_id3_tag_sink_event), (gst_id3_tag_chain):
* ext/mad/gstmad.c: (gst_mad_src_query), (index_seek),
(normal_seek), (gst_mad_sink_event), (gst_mad_chain):
* ext/mpeg2dec/gstmpeg2dec.c:
* ext/shout2/gstshout2.c: (gst_shout2send_event):
* ext/sidplay/gstsiddec.cc:
* gst/avi/gstavidemux.c: (gst_avi_demux_handle_src_event),
(gst_avi_demux_send_event), (gst_avi_demux_stream_header),
(gst_avi_demux_handle_seek), (gst_avi_demux_process_next_entry):
* gst/goom/gstgoom.c: (gst_goom_event):
* gst/realmedia/rmdemux.c: (gst_rmdemux_sink_event),
(gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream):
* gst/wavparse/gstwavparse.c: (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_srcpad_event):
Various event updates and cleanups.
2005-07-27 18:37:25 +00:00
|
|
|
gst_event_parse_seek (event, &rate, &format, &flags,
|
|
|
|
&cur_type, &cur, &stop_type, &stop);
|
|
|
|
|
|
|
|
conv = GST_FORMAT_TIME;
|
ext/mpeg2dec/gstmpeg2dec.c: Forward GstFlowReturn about everywhere.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_reset),
(gst_mpeg2dec_alloc_buffer), (gst_mpeg2dec_negotiate_format),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_src_query), (normal_seek),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
Forward GstFlowReturn about everywhere.
Handle seeking correctly.
2005-10-27 21:50:11 +00:00
|
|
|
if (!gst_mpeg2dec_src_convert (pad, format, cur, &conv, &time_cur))
|
|
|
|
goto convert_failed;
|
|
|
|
if (!gst_mpeg2dec_src_convert (pad, format, stop, &conv, &time_stop))
|
|
|
|
goto convert_failed;
|
2002-05-26 21:59:22 +00:00
|
|
|
|
Various event updates and cleanups.
Original commit message from CVS:
* ext/amrnb/amrnbparse.c: (gst_amrnbparse_event),
(gst_amrnbparse_loop):
* ext/dv/gstdvdec.c: (gst_dvdec_handle_sink_event),
(gst_dvdec_handle_src_event), (gst_dvdec_decode_frame):
* ext/mad/gstid3tag.c: (gst_id3_tag_src_event),
(gst_id3_tag_sink_event), (gst_id3_tag_chain):
* ext/mad/gstmad.c: (gst_mad_src_query), (index_seek),
(normal_seek), (gst_mad_sink_event), (gst_mad_chain):
* ext/mpeg2dec/gstmpeg2dec.c:
* ext/shout2/gstshout2.c: (gst_shout2send_event):
* ext/sidplay/gstsiddec.cc:
* gst/avi/gstavidemux.c: (gst_avi_demux_handle_src_event),
(gst_avi_demux_send_event), (gst_avi_demux_stream_header),
(gst_avi_demux_handle_seek), (gst_avi_demux_process_next_entry):
* gst/goom/gstgoom.c: (gst_goom_event):
* gst/realmedia/rmdemux.c: (gst_rmdemux_sink_event),
(gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream):
* gst/wavparse/gstwavparse.c: (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_srcpad_event):
Various event updates and cleanups.
2005-07-27 18:37:25 +00:00
|
|
|
GST_DEBUG ("seek to time %" GST_TIME_FORMAT "-%" GST_TIME_FORMAT,
|
|
|
|
GST_TIME_ARGS (time_cur), GST_TIME_ARGS (time_stop));
|
2005-07-19 20:51:16 +00:00
|
|
|
|
ext/mpeg2dec/gstmpeg2dec.c: Forward GstFlowReturn about everywhere.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_reset),
(gst_mpeg2dec_alloc_buffer), (gst_mpeg2dec_negotiate_format),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_src_query), (normal_seek),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
Forward GstFlowReturn about everywhere.
Handle seeking correctly.
2005-10-27 21:50:11 +00:00
|
|
|
peer_event = gst_event_new_seek (rate, GST_FORMAT_TIME, flags,
|
|
|
|
cur_type, time_cur, stop_type, time_stop);
|
2002-05-26 21:59:22 +00:00
|
|
|
|
ext/mpeg2dec/gstmpeg2dec.c: Forward GstFlowReturn about everywhere.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_reset),
(gst_mpeg2dec_alloc_buffer), (gst_mpeg2dec_negotiate_format),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_src_query), (normal_seek),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
Forward GstFlowReturn about everywhere.
Handle seeking correctly.
2005-10-27 21:50:11 +00:00
|
|
|
/* try seek on time then */
|
|
|
|
if ((res = gst_pad_push_event (mpeg2dec->sinkpad, peer_event)))
|
|
|
|
goto done;
|
2005-07-19 20:51:16 +00:00
|
|
|
|
ext/mpeg2dec/gstmpeg2dec.c: Forward GstFlowReturn about everywhere.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_reset),
(gst_mpeg2dec_alloc_buffer), (gst_mpeg2dec_negotiate_format),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_src_query), (normal_seek),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
Forward GstFlowReturn about everywhere.
Handle seeking correctly.
2005-10-27 21:50:11 +00:00
|
|
|
/* else we try to seek on bytes */
|
Various event updates and cleanups.
Original commit message from CVS:
* ext/amrnb/amrnbparse.c: (gst_amrnbparse_event),
(gst_amrnbparse_loop):
* ext/dv/gstdvdec.c: (gst_dvdec_handle_sink_event),
(gst_dvdec_handle_src_event), (gst_dvdec_decode_frame):
* ext/mad/gstid3tag.c: (gst_id3_tag_src_event),
(gst_id3_tag_sink_event), (gst_id3_tag_chain):
* ext/mad/gstmad.c: (gst_mad_src_query), (index_seek),
(normal_seek), (gst_mad_sink_event), (gst_mad_chain):
* ext/mpeg2dec/gstmpeg2dec.c:
* ext/shout2/gstshout2.c: (gst_shout2send_event):
* ext/sidplay/gstsiddec.cc:
* gst/avi/gstavidemux.c: (gst_avi_demux_handle_src_event),
(gst_avi_demux_send_event), (gst_avi_demux_stream_header),
(gst_avi_demux_handle_seek), (gst_avi_demux_process_next_entry):
* gst/goom/gstgoom.c: (gst_goom_event):
* gst/realmedia/rmdemux.c: (gst_rmdemux_sink_event),
(gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream):
* gst/wavparse/gstwavparse.c: (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_srcpad_event):
Various event updates and cleanups.
2005-07-27 18:37:25 +00:00
|
|
|
conv = GST_FORMAT_BYTES;
|
|
|
|
if (!gst_mpeg2dec_sink_convert (pad, GST_FORMAT_TIME, time_cur,
|
2005-12-21 09:58:43 +00:00
|
|
|
&conv, &bytes_cur))
|
Various event updates and cleanups.
Original commit message from CVS:
* ext/amrnb/amrnbparse.c: (gst_amrnbparse_event),
(gst_amrnbparse_loop):
* ext/dv/gstdvdec.c: (gst_dvdec_handle_sink_event),
(gst_dvdec_handle_src_event), (gst_dvdec_decode_frame):
* ext/mad/gstid3tag.c: (gst_id3_tag_src_event),
(gst_id3_tag_sink_event), (gst_id3_tag_chain):
* ext/mad/gstmad.c: (gst_mad_src_query), (index_seek),
(normal_seek), (gst_mad_sink_event), (gst_mad_chain):
* ext/mpeg2dec/gstmpeg2dec.c:
* ext/shout2/gstshout2.c: (gst_shout2send_event):
* ext/sidplay/gstsiddec.cc:
* gst/avi/gstavidemux.c: (gst_avi_demux_handle_src_event),
(gst_avi_demux_send_event), (gst_avi_demux_stream_header),
(gst_avi_demux_handle_seek), (gst_avi_demux_process_next_entry):
* gst/goom/gstgoom.c: (gst_goom_event):
* gst/realmedia/rmdemux.c: (gst_rmdemux_sink_event),
(gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream):
* gst/wavparse/gstwavparse.c: (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_srcpad_event):
Various event updates and cleanups.
2005-07-27 18:37:25 +00:00
|
|
|
goto convert_failed;
|
|
|
|
if (!gst_mpeg2dec_sink_convert (pad, GST_FORMAT_TIME, time_stop,
|
2005-12-21 09:58:43 +00:00
|
|
|
&conv, &bytes_stop))
|
Various event updates and cleanups.
Original commit message from CVS:
* ext/amrnb/amrnbparse.c: (gst_amrnbparse_event),
(gst_amrnbparse_loop):
* ext/dv/gstdvdec.c: (gst_dvdec_handle_sink_event),
(gst_dvdec_handle_src_event), (gst_dvdec_decode_frame):
* ext/mad/gstid3tag.c: (gst_id3_tag_src_event),
(gst_id3_tag_sink_event), (gst_id3_tag_chain):
* ext/mad/gstmad.c: (gst_mad_src_query), (index_seek),
(normal_seek), (gst_mad_sink_event), (gst_mad_chain):
* ext/mpeg2dec/gstmpeg2dec.c:
* ext/shout2/gstshout2.c: (gst_shout2send_event):
* ext/sidplay/gstsiddec.cc:
* gst/avi/gstavidemux.c: (gst_avi_demux_handle_src_event),
(gst_avi_demux_send_event), (gst_avi_demux_stream_header),
(gst_avi_demux_handle_seek), (gst_avi_demux_process_next_entry):
* gst/goom/gstgoom.c: (gst_goom_event):
* gst/realmedia/rmdemux.c: (gst_rmdemux_sink_event),
(gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream):
* gst/wavparse/gstwavparse.c: (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_srcpad_event):
Various event updates and cleanups.
2005-07-27 18:37:25 +00:00
|
|
|
goto convert_failed;
|
|
|
|
|
ext/mpeg2dec/gstmpeg2dec.c: Forward GstFlowReturn about everywhere.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_reset),
(gst_mpeg2dec_alloc_buffer), (gst_mpeg2dec_negotiate_format),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_src_query), (normal_seek),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
Forward GstFlowReturn about everywhere.
Handle seeking correctly.
2005-10-27 21:50:11 +00:00
|
|
|
/* conversion succeeded, create the seek */
|
|
|
|
peer_event =
|
|
|
|
gst_event_new_seek (rate, GST_FORMAT_BYTES, flags,
|
|
|
|
cur_type, bytes_cur, stop_type, bytes_stop);
|
Various event updates and cleanups.
Original commit message from CVS:
* ext/amrnb/amrnbparse.c: (gst_amrnbparse_event),
(gst_amrnbparse_loop):
* ext/dv/gstdvdec.c: (gst_dvdec_handle_sink_event),
(gst_dvdec_handle_src_event), (gst_dvdec_decode_frame):
* ext/mad/gstid3tag.c: (gst_id3_tag_src_event),
(gst_id3_tag_sink_event), (gst_id3_tag_chain):
* ext/mad/gstmad.c: (gst_mad_src_query), (index_seek),
(normal_seek), (gst_mad_sink_event), (gst_mad_chain):
* ext/mpeg2dec/gstmpeg2dec.c:
* ext/shout2/gstshout2.c: (gst_shout2send_event):
* ext/sidplay/gstsiddec.cc:
* gst/avi/gstavidemux.c: (gst_avi_demux_handle_src_event),
(gst_avi_demux_send_event), (gst_avi_demux_stream_header),
(gst_avi_demux_handle_seek), (gst_avi_demux_process_next_entry):
* gst/goom/gstgoom.c: (gst_goom_event):
* gst/realmedia/rmdemux.c: (gst_rmdemux_sink_event),
(gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream):
* gst/wavparse/gstwavparse.c: (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_srcpad_event):
Various event updates and cleanups.
2005-07-27 18:37:25 +00:00
|
|
|
|
ext/mpeg2dec/gstmpeg2dec.c: Forward GstFlowReturn about everywhere.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_reset),
(gst_mpeg2dec_alloc_buffer), (gst_mpeg2dec_negotiate_format),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_src_query), (normal_seek),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
Forward GstFlowReturn about everywhere.
Handle seeking correctly.
2005-10-27 21:50:11 +00:00
|
|
|
/* do the seek */
|
|
|
|
res = gst_pad_push_event (mpeg2dec->sinkpad, peer_event);
|
2005-07-19 20:51:16 +00:00
|
|
|
|
ext/mpeg2dec/gstmpeg2dec.c: Forward GstFlowReturn about everywhere.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_reset),
(gst_mpeg2dec_alloc_buffer), (gst_mpeg2dec_negotiate_format),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_src_query), (normal_seek),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
Forward GstFlowReturn about everywhere.
Handle seeking correctly.
2005-10-27 21:50:11 +00:00
|
|
|
done:
|
2002-12-26 22:46:26 +00:00
|
|
|
return res;
|
Various event updates and cleanups.
Original commit message from CVS:
* ext/amrnb/amrnbparse.c: (gst_amrnbparse_event),
(gst_amrnbparse_loop):
* ext/dv/gstdvdec.c: (gst_dvdec_handle_sink_event),
(gst_dvdec_handle_src_event), (gst_dvdec_decode_frame):
* ext/mad/gstid3tag.c: (gst_id3_tag_src_event),
(gst_id3_tag_sink_event), (gst_id3_tag_chain):
* ext/mad/gstmad.c: (gst_mad_src_query), (index_seek),
(normal_seek), (gst_mad_sink_event), (gst_mad_chain):
* ext/mpeg2dec/gstmpeg2dec.c:
* ext/shout2/gstshout2.c: (gst_shout2send_event):
* ext/sidplay/gstsiddec.cc:
* gst/avi/gstavidemux.c: (gst_avi_demux_handle_src_event),
(gst_avi_demux_send_event), (gst_avi_demux_stream_header),
(gst_avi_demux_handle_seek), (gst_avi_demux_process_next_entry):
* gst/goom/gstgoom.c: (gst_goom_event):
* gst/realmedia/rmdemux.c: (gst_rmdemux_sink_event),
(gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream):
* gst/wavparse/gstwavparse.c: (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_srcpad_event):
Various event updates and cleanups.
2005-07-27 18:37:25 +00:00
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
convert_failed:
|
|
|
|
{
|
|
|
|
/* probably unsupported seek format */
|
ext/mpeg2dec/gstmpeg2dec.c: Forward GstFlowReturn about everywhere.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_reset),
(gst_mpeg2dec_alloc_buffer), (gst_mpeg2dec_negotiate_format),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_src_query), (normal_seek),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
Forward GstFlowReturn about everywhere.
Handle seeking correctly.
2005-10-27 21:50:11 +00:00
|
|
|
GST_DEBUG_OBJECT (mpeg2dec,
|
|
|
|
"failed to convert format %u into GST_FORMAT_TIME", format);
|
Various event updates and cleanups.
Original commit message from CVS:
* ext/amrnb/amrnbparse.c: (gst_amrnbparse_event),
(gst_amrnbparse_loop):
* ext/dv/gstdvdec.c: (gst_dvdec_handle_sink_event),
(gst_dvdec_handle_src_event), (gst_dvdec_decode_frame):
* ext/mad/gstid3tag.c: (gst_id3_tag_src_event),
(gst_id3_tag_sink_event), (gst_id3_tag_chain):
* ext/mad/gstmad.c: (gst_mad_src_query), (index_seek),
(normal_seek), (gst_mad_sink_event), (gst_mad_chain):
* ext/mpeg2dec/gstmpeg2dec.c:
* ext/shout2/gstshout2.c: (gst_shout2send_event):
* ext/sidplay/gstsiddec.cc:
* gst/avi/gstavidemux.c: (gst_avi_demux_handle_src_event),
(gst_avi_demux_send_event), (gst_avi_demux_stream_header),
(gst_avi_demux_handle_seek), (gst_avi_demux_process_next_entry):
* gst/goom/gstgoom.c: (gst_goom_event):
* gst/realmedia/rmdemux.c: (gst_rmdemux_sink_event),
(gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream):
* gst/wavparse/gstwavparse.c: (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_srcpad_event):
Various event updates and cleanups.
2005-07-27 18:37:25 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2002-12-26 22:46:26 +00:00
|
|
|
}
|
2004-03-14 22:34:30 +00:00
|
|
|
|
2005-07-19 20:51:16 +00:00
|
|
|
|
2004-03-14 22:34:30 +00:00
|
|
|
static gboolean
|
|
|
|
gst_mpeg2dec_src_event (GstPad * pad, GstEvent * event)
|
2002-12-26 22:46:26 +00:00
|
|
|
{
|
2005-10-26 16:45:04 +00:00
|
|
|
gboolean res;
|
2002-12-26 22:46:26 +00:00
|
|
|
GstMpeg2dec *mpeg2dec;
|
|
|
|
|
2005-07-19 20:51:16 +00:00
|
|
|
mpeg2dec = GST_MPEG2DEC (GST_PAD_PARENT (pad));
|
2002-12-26 22:46:26 +00:00
|
|
|
|
|
|
|
if (mpeg2dec->decoder == NULL)
|
ext/mpeg2dec/gstmpeg2dec.c: Forward GstFlowReturn about everywhere.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_reset),
(gst_mpeg2dec_alloc_buffer), (gst_mpeg2dec_negotiate_format),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_src_query), (normal_seek),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
Forward GstFlowReturn about everywhere.
Handle seeking correctly.
2005-10-27 21:50:11 +00:00
|
|
|
goto no_decoder;
|
2002-12-26 22:46:26 +00:00
|
|
|
|
|
|
|
switch (GST_EVENT_TYPE (event)) {
|
2004-03-14 22:34:30 +00:00
|
|
|
/* the all-formats seek logic */
|
2005-12-21 10:25:34 +00:00
|
|
|
case GST_EVENT_SEEK:{
|
|
|
|
gst_event_ref (event);
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
if (!(res = gst_pad_push_event (mpeg2dec->sinkpad, event))) {
|
2008-09-28 17:33:43 +00:00
|
|
|
#ifndef GST_DISABLE_INDEX
|
2005-12-21 10:25:34 +00:00
|
|
|
if (mpeg2dec->index)
|
|
|
|
res = index_seek (pad, event);
|
|
|
|
else
|
2008-09-28 17:33:43 +00:00
|
|
|
#endif
|
2005-12-21 10:25:34 +00:00
|
|
|
res = normal_seek (pad, event);
|
|
|
|
}
|
2005-10-26 16:45:04 +00:00
|
|
|
gst_event_unref (event);
|
2002-05-26 21:59:22 +00:00
|
|
|
break;
|
2005-12-21 10:25:34 +00:00
|
|
|
}
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
case GST_EVENT_QOS:
|
|
|
|
{
|
|
|
|
gdouble proportion;
|
|
|
|
GstClockTimeDiff diff;
|
|
|
|
GstClockTime timestamp;
|
|
|
|
|
|
|
|
gst_event_parse_qos (event, &proportion, &diff, ×tamp);
|
|
|
|
|
|
|
|
GST_OBJECT_LOCK (mpeg2dec);
|
|
|
|
mpeg2dec->proportion = proportion;
|
|
|
|
mpeg2dec->earliest_time = timestamp + diff;
|
|
|
|
GST_OBJECT_UNLOCK (mpeg2dec);
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (mpeg2dec,
|
|
|
|
"got QoS %" GST_TIME_FORMAT ", %" G_GINT64_FORMAT,
|
|
|
|
GST_TIME_ARGS (timestamp), diff);
|
|
|
|
|
|
|
|
res = gst_pad_push_event (mpeg2dec->sinkpad, event);
|
|
|
|
break;
|
|
|
|
}
|
2004-01-06 16:42:10 +00:00
|
|
|
case GST_EVENT_NAVIGATION:
|
|
|
|
/* Forward a navigation event unchanged */
|
2002-05-26 21:59:22 +00:00
|
|
|
default:
|
2005-10-26 16:45:04 +00:00
|
|
|
res = gst_pad_push_event (mpeg2dec->sinkpad, event);
|
2002-05-26 21:59:22 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return res;
|
ext/mpeg2dec/gstmpeg2dec.c: Forward GstFlowReturn about everywhere.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_reset),
(gst_mpeg2dec_alloc_buffer), (gst_mpeg2dec_negotiate_format),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_src_query), (normal_seek),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
Forward GstFlowReturn about everywhere.
Handle seeking correctly.
2005-10-27 21:50:11 +00:00
|
|
|
|
|
|
|
no_decoder:
|
|
|
|
{
|
|
|
|
GST_DEBUG_OBJECT (mpeg2dec, "no decoder, cannot handle event");
|
|
|
|
gst_event_unref (event);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2002-05-26 21:59:22 +00:00
|
|
|
}
|
|
|
|
|
2005-09-02 15:43:54 +00:00
|
|
|
static GstStateChangeReturn
|
|
|
|
gst_mpeg2dec_change_state (GstElement * element, GstStateChange transition)
|
2001-12-23 06:03:21 +00:00
|
|
|
{
|
2005-09-02 15:43:54 +00:00
|
|
|
GstStateChangeReturn ret;
|
2001-12-23 06:03:21 +00:00
|
|
|
GstMpeg2dec *mpeg2dec = GST_MPEG2DEC (element);
|
|
|
|
|
2005-09-02 15:43:54 +00:00
|
|
|
switch (transition) {
|
|
|
|
case GST_STATE_CHANGE_NULL_TO_READY:
|
2005-10-26 16:45:04 +00:00
|
|
|
mpeg2_accel (MPEG2_ACCEL_DETECT);
|
|
|
|
if ((mpeg2dec->decoder = mpeg2_init ()) == NULL)
|
|
|
|
goto init_failed;
|
|
|
|
mpeg2dec->info = mpeg2_info (mpeg2dec->decoder);
|
2001-12-23 06:03:21 +00:00
|
|
|
break;
|
2005-09-02 15:43:54 +00:00
|
|
|
case GST_STATE_CHANGE_READY_TO_PAUSED:
|
2005-02-05 07:36:01 +00:00
|
|
|
gst_mpeg2dec_reset (mpeg2dec);
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
gst_mpeg2dec_qos_reset (mpeg2dec);
|
2001-12-23 06:03:21 +00:00
|
|
|
break;
|
2005-09-02 15:43:54 +00:00
|
|
|
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
|
Various event updates and cleanups.
Original commit message from CVS:
* ext/amrnb/amrnbparse.c: (gst_amrnbparse_event),
(gst_amrnbparse_loop):
* ext/dv/gstdvdec.c: (gst_dvdec_handle_sink_event),
(gst_dvdec_handle_src_event), (gst_dvdec_decode_frame):
* ext/mad/gstid3tag.c: (gst_id3_tag_src_event),
(gst_id3_tag_sink_event), (gst_id3_tag_chain):
* ext/mad/gstmad.c: (gst_mad_src_query), (index_seek),
(normal_seek), (gst_mad_sink_event), (gst_mad_chain):
* ext/mpeg2dec/gstmpeg2dec.c:
* ext/shout2/gstshout2.c: (gst_shout2send_event):
* ext/sidplay/gstsiddec.cc:
* gst/avi/gstavidemux.c: (gst_avi_demux_handle_src_event),
(gst_avi_demux_send_event), (gst_avi_demux_stream_header),
(gst_avi_demux_handle_seek), (gst_avi_demux_process_next_entry):
* gst/goom/gstgoom.c: (gst_goom_event):
* gst/realmedia/rmdemux.c: (gst_rmdemux_sink_event),
(gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream):
* gst/wavparse/gstwavparse.c: (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_srcpad_event):
Various event updates and cleanups.
2005-07-27 18:37:25 +00:00
|
|
|
default:
|
2001-12-23 06:03:21 +00:00
|
|
|
break;
|
Various event updates and cleanups.
Original commit message from CVS:
* ext/amrnb/amrnbparse.c: (gst_amrnbparse_event),
(gst_amrnbparse_loop):
* ext/dv/gstdvdec.c: (gst_dvdec_handle_sink_event),
(gst_dvdec_handle_src_event), (gst_dvdec_decode_frame):
* ext/mad/gstid3tag.c: (gst_id3_tag_src_event),
(gst_id3_tag_sink_event), (gst_id3_tag_chain):
* ext/mad/gstmad.c: (gst_mad_src_query), (index_seek),
(normal_seek), (gst_mad_sink_event), (gst_mad_chain):
* ext/mpeg2dec/gstmpeg2dec.c:
* ext/shout2/gstshout2.c: (gst_shout2send_event):
* ext/sidplay/gstsiddec.cc:
* gst/avi/gstavidemux.c: (gst_avi_demux_handle_src_event),
(gst_avi_demux_send_event), (gst_avi_demux_stream_header),
(gst_avi_demux_handle_seek), (gst_avi_demux_process_next_entry):
* gst/goom/gstgoom.c: (gst_goom_event):
* gst/realmedia/rmdemux.c: (gst_rmdemux_sink_event),
(gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream):
* gst/wavparse/gstwavparse.c: (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_srcpad_event):
Various event updates and cleanups.
2005-07-27 18:37:25 +00:00
|
|
|
}
|
|
|
|
|
2005-09-02 15:43:54 +00:00
|
|
|
ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
|
Various event updates and cleanups.
Original commit message from CVS:
* ext/amrnb/amrnbparse.c: (gst_amrnbparse_event),
(gst_amrnbparse_loop):
* ext/dv/gstdvdec.c: (gst_dvdec_handle_sink_event),
(gst_dvdec_handle_src_event), (gst_dvdec_decode_frame):
* ext/mad/gstid3tag.c: (gst_id3_tag_src_event),
(gst_id3_tag_sink_event), (gst_id3_tag_chain):
* ext/mad/gstmad.c: (gst_mad_src_query), (index_seek),
(normal_seek), (gst_mad_sink_event), (gst_mad_chain):
* ext/mpeg2dec/gstmpeg2dec.c:
* ext/shout2/gstshout2.c: (gst_shout2send_event):
* ext/sidplay/gstsiddec.cc:
* gst/avi/gstavidemux.c: (gst_avi_demux_handle_src_event),
(gst_avi_demux_send_event), (gst_avi_demux_stream_header),
(gst_avi_demux_handle_seek), (gst_avi_demux_process_next_entry):
* gst/goom/gstgoom.c: (gst_goom_event):
* gst/realmedia/rmdemux.c: (gst_rmdemux_sink_event),
(gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream):
* gst/wavparse/gstwavparse.c: (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_srcpad_event):
Various event updates and cleanups.
2005-07-27 18:37:25 +00:00
|
|
|
|
2005-09-02 15:43:54 +00:00
|
|
|
switch (transition) {
|
|
|
|
case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
|
2001-12-23 06:03:21 +00:00
|
|
|
break;
|
2005-09-02 15:43:54 +00:00
|
|
|
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
gst_mpeg2dec_qos_reset (mpeg2dec);
|
2008-01-10 15:24:08 +00:00
|
|
|
clear_queued (mpeg2dec);
|
2001-12-23 06:03:21 +00:00
|
|
|
break;
|
2005-09-02 15:43:54 +00:00
|
|
|
case GST_STATE_CHANGE_READY_TO_NULL:
|
2005-10-26 16:45:04 +00:00
|
|
|
if (mpeg2dec->decoder) {
|
|
|
|
mpeg2_close (mpeg2dec->decoder);
|
|
|
|
mpeg2dec->decoder = NULL;
|
|
|
|
mpeg2dec->info = NULL;
|
|
|
|
}
|
2006-06-07 17:05:48 +00:00
|
|
|
clear_buffers (mpeg2dec);
|
2001-12-23 06:03:21 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
Various event updates and cleanups.
Original commit message from CVS:
* ext/amrnb/amrnbparse.c: (gst_amrnbparse_event),
(gst_amrnbparse_loop):
* ext/dv/gstdvdec.c: (gst_dvdec_handle_sink_event),
(gst_dvdec_handle_src_event), (gst_dvdec_decode_frame):
* ext/mad/gstid3tag.c: (gst_id3_tag_src_event),
(gst_id3_tag_sink_event), (gst_id3_tag_chain):
* ext/mad/gstmad.c: (gst_mad_src_query), (index_seek),
(normal_seek), (gst_mad_sink_event), (gst_mad_chain):
* ext/mpeg2dec/gstmpeg2dec.c:
* ext/shout2/gstshout2.c: (gst_shout2send_event):
* ext/sidplay/gstsiddec.cc:
* gst/avi/gstavidemux.c: (gst_avi_demux_handle_src_event),
(gst_avi_demux_send_event), (gst_avi_demux_stream_header),
(gst_avi_demux_handle_seek), (gst_avi_demux_process_next_entry):
* gst/goom/gstgoom.c: (gst_goom_event):
* gst/realmedia/rmdemux.c: (gst_rmdemux_sink_event),
(gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream):
* gst/wavparse/gstwavparse.c: (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_srcpad_event):
Various event updates and cleanups.
2005-07-27 18:37:25 +00:00
|
|
|
return ret;
|
2005-10-26 16:45:04 +00:00
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
init_failed:
|
|
|
|
{
|
|
|
|
GST_ELEMENT_ERROR (mpeg2dec, LIBRARY, INIT,
|
|
|
|
(NULL), ("Failed to initialize libmpeg2 library"));
|
|
|
|
return GST_STATE_CHANGE_FAILURE;
|
|
|
|
}
|
2001-12-23 06:03:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:30 +00:00
|
|
|
gst_mpeg2dec_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * pspec)
|
2001-12-23 06:03:21 +00:00
|
|
|
{
|
|
|
|
GstMpeg2dec *src;
|
|
|
|
|
|
|
|
g_return_if_fail (GST_IS_MPEG2DEC (object));
|
|
|
|
src = GST_MPEG2DEC (object);
|
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:30 +00:00
|
|
|
gst_mpeg2dec_get_property (GObject * object, guint prop_id, GValue * value,
|
|
|
|
GParamSpec * pspec)
|
2001-12-23 06:03:21 +00:00
|
|
|
{
|
2002-02-06 23:05:22 +00:00
|
|
|
GstMpeg2dec *mpeg2dec;
|
2001-12-23 06:03:21 +00:00
|
|
|
|
|
|
|
g_return_if_fail (GST_IS_MPEG2DEC (object));
|
2002-02-06 23:05:22 +00:00
|
|
|
mpeg2dec = GST_MPEG2DEC (object);
|
2001-12-23 06:03:21 +00:00
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2004-03-14 22:34:30 +00:00
|
|
|
plugin_init (GstPlugin * plugin)
|
2001-12-23 06:03:21 +00:00
|
|
|
{
|
2005-01-17 13:54:30 +00:00
|
|
|
if (!gst_element_register (plugin, "mpeg2dec", GST_RANK_SECONDARY,
|
2004-03-15 19:32:25 +00:00
|
|
|
GST_TYPE_MPEG2DEC))
|
2003-11-02 00:33:31 +00:00
|
|
|
return FALSE;
|
2001-12-23 06:03:21 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:30 +00:00
|
|
|
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
|
|
|
|
GST_VERSION_MINOR,
|
|
|
|
"mpeg2dec",
|
2006-04-01 09:54:39 +00:00
|
|
|
"LibMpeg2 decoder", plugin_init, VERSION, "GPL", GST_PACKAGE_NAME,
|
|
|
|
GST_PACKAGE_ORIGIN);
|