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"
|
|
|
|
|
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
|
|
|
|
#if MPEG2_RELEASE < MPEG2_VERSION(0,3,2)
|
|
|
|
*/
|
|
|
|
#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
|
|
|
|
|
2003-07-25 02:04:01 +00:00
|
|
|
GST_DEBUG_CATEGORY_EXTERN (GST_CAT_SEEK);
|
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
|
|
|
|
2004-05-05 09:13:42 +00:00
|
|
|
/* table with framerates expressed as fractions */
|
|
|
|
static gdouble fpss[] = { 24.0 / 1.001, 24.0, 25.0,
|
|
|
|
30.0 / 1.001, 30.0, 50.0,
|
|
|
|
60.0 / 1.001, 60.0, 0
|
|
|
|
};
|
|
|
|
|
|
|
|
/* frame periods */
|
|
|
|
static guint frame_periods[] = {
|
|
|
|
1126125, 1125000, 1080000, 900900, 900000, 540000, 450450, 450000, 0
|
|
|
|
};
|
|
|
|
|
2001-12-23 06:03:21 +00:00
|
|
|
/* elementfactory information */
|
|
|
|
static GstElementDetails gst_mpeg2dec_details = {
|
|
|
|
"mpeg1 and mpeg2 video decoder",
|
2003-11-16 22:02:04 +00:00
|
|
|
"Codec/Decoder/Video",
|
2001-12-23 06:03:21 +00:00
|
|
|
"Uses libmpeg2 to decode MPEG video streams",
|
2002-12-19 07:45:11 +00:00
|
|
|
"Wim Taymans <wim.taymans@chello.be>",
|
2001-12-23 06:03:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Mpeg2dec signals and args */
|
2004-03-14 22:34:30 +00:00
|
|
|
enum
|
|
|
|
{
|
2001-12-23 06:03:21 +00:00
|
|
|
/* FILL ME */
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
2004-03-14 22:34:30 +00:00
|
|
|
enum
|
|
|
|
{
|
2004-05-21 23:28:57 +00:00
|
|
|
ARG_0
|
|
|
|
/* FILL ME */
|
2001-12-23 06:03:21 +00:00
|
|
|
};
|
|
|
|
|
2004-05-05 09:13:42 +00:00
|
|
|
/*
|
|
|
|
* We can't use fractions in static pad templates, so
|
|
|
|
* we do something manual...
|
|
|
|
*/
|
|
|
|
static GstPadTemplate *
|
|
|
|
src_templ (void)
|
|
|
|
{
|
|
|
|
static GstPadTemplate *templ = NULL;
|
|
|
|
|
|
|
|
if (!templ) {
|
|
|
|
GstCaps *caps;
|
|
|
|
GstStructure *structure;
|
|
|
|
GValue list = { 0 }
|
2005-01-17 13:54:30 +00:00
|
|
|
, fps = {
|
2004-05-05 09:13:42 +00:00
|
|
|
0}
|
|
|
|
, fmt = {
|
|
|
|
0};
|
|
|
|
char *fmts[] = { "YV12", "I420", "Y42B", NULL };
|
|
|
|
guint n;
|
|
|
|
|
|
|
|
caps = gst_caps_new_simple ("video/x-raw-yuv",
|
|
|
|
"format", GST_TYPE_FOURCC,
|
|
|
|
GST_MAKE_FOURCC ('I', '4', '2', '0'),
|
|
|
|
"width", GST_TYPE_INT_RANGE, 16, 4096,
|
|
|
|
"height", GST_TYPE_INT_RANGE, 16, 4096, NULL);
|
|
|
|
|
|
|
|
structure = gst_caps_get_structure (caps, 0);
|
|
|
|
|
|
|
|
g_value_init (&list, GST_TYPE_LIST);
|
|
|
|
g_value_init (&fps, G_TYPE_DOUBLE);
|
|
|
|
for (n = 0; fpss[n] != 0; n++) {
|
|
|
|
g_value_set_double (&fps, fpss[n]);
|
|
|
|
gst_value_list_append_value (&list, &fps);
|
|
|
|
}
|
|
|
|
gst_structure_set_value (structure, "framerate", &list);
|
|
|
|
g_value_unset (&list);
|
|
|
|
g_value_unset (&fps);
|
|
|
|
|
|
|
|
g_value_init (&list, GST_TYPE_LIST);
|
|
|
|
g_value_init (&fmt, GST_TYPE_FOURCC);
|
|
|
|
for (n = 0; fmts[n] != NULL; n++) {
|
|
|
|
gst_value_set_fourcc (&fmt, GST_STR_FOURCC (fmts[n]));
|
|
|
|
gst_value_list_append_value (&list, &fmt);
|
|
|
|
}
|
|
|
|
gst_structure_set_value (structure, "format", &list);
|
|
|
|
g_value_unset (&list);
|
|
|
|
g_value_unset (&fmt);
|
|
|
|
|
|
|
|
templ = gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, caps);
|
|
|
|
}
|
|
|
|
return templ;
|
|
|
|
}
|
2001-12-23 06:03:21 +00:00
|
|
|
|
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
|
|
|
);
|
|
|
|
|
|
|
|
static void gst_mpeg2dec_base_init (gpointer g_class);
|
|
|
|
static void gst_mpeg2dec_class_init (GstMpeg2decClass * klass);
|
|
|
|
static void gst_mpeg2dec_init (GstMpeg2dec * mpeg2dec);
|
|
|
|
|
|
|
|
static void gst_mpeg2dec_dispose (GObject * object);
|
|
|
|
|
|
|
|
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);
|
|
|
|
static void gst_mpeg2dec_set_index (GstElement * element, GstIndex * index);
|
|
|
|
static GstIndex *gst_mpeg2dec_get_index (GstElement * element);
|
|
|
|
|
|
|
|
static const GstFormat *gst_mpeg2dec_get_src_formats (GstPad * pad);
|
|
|
|
static const GstEventMask *gst_mpeg2dec_get_src_event_masks (GstPad * pad);
|
|
|
|
static gboolean gst_mpeg2dec_src_event (GstPad * pad, GstEvent * event);
|
|
|
|
static const GstQueryType *gst_mpeg2dec_get_src_query_types (GstPad * pad);
|
|
|
|
static gboolean gst_mpeg2dec_src_query (GstPad * pad, GstQueryType type,
|
|
|
|
GstFormat * format, gint64 * value);
|
|
|
|
|
|
|
|
static const GstFormat *gst_mpeg2dec_get_sink_formats (GstPad * pad);
|
|
|
|
static gboolean gst_mpeg2dec_convert_sink (GstPad * pad, GstFormat src_format,
|
|
|
|
gint64 src_value, GstFormat * dest_format, gint64 * dest_value);
|
|
|
|
static gboolean gst_mpeg2dec_convert_src (GstPad * pad, GstFormat src_format,
|
|
|
|
gint64 src_value, GstFormat * dest_format, gint64 * dest_value);
|
|
|
|
|
|
|
|
static GstElementStateReturn gst_mpeg2dec_change_state (GstElement * element);
|
|
|
|
|
|
|
|
static void gst_mpeg2dec_chain (GstPad * pad, GstData * _data);
|
2001-12-23 06:03:21 +00:00
|
|
|
|
|
|
|
static GstElementClass *parent_class = NULL;
|
2004-03-14 22:34:30 +00:00
|
|
|
|
2005-01-17 13:54:30 +00:00
|
|
|
static GstBuffer *crop_buffer (GstMpeg2dec * mpeg2dec, GstBuffer * input);
|
2005-02-04 13:43:28 +00:00
|
|
|
static gboolean check_buffer (GstMpeg2dec * mpeg2dec, GstBuffer * buf);
|
|
|
|
static gboolean free_buffer (GstMpeg2dec * mpeg2dec, GstBuffer * buf);
|
|
|
|
static void free_all_buffers (GstMpeg2dec * mpeg2dec);
|
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);
|
|
|
|
|
2004-05-05 09:13:42 +00:00
|
|
|
gst_element_class_add_pad_template (element_class, src_templ ());
|
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
|
|
|
|
2004-03-14 22:34:30 +00:00
|
|
|
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
|
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;
|
|
|
|
gobject_class->dispose = gst_mpeg2dec_dispose;
|
2001-12-23 06:03:21 +00:00
|
|
|
|
|
|
|
gstelement_class->change_state = gst_mpeg2dec_change_state;
|
2004-03-14 22:34:30 +00:00
|
|
|
gstelement_class->set_index = gst_mpeg2dec_set_index;
|
|
|
|
gstelement_class->get_index = gst_mpeg2dec_get_index;
|
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
|
|
|
{
|
2005-02-04 13:43:28 +00:00
|
|
|
int i;
|
|
|
|
|
2002-12-05 00:29:11 +00:00
|
|
|
/* create the sink and src pads */
|
2004-03-14 22:34:30 +00:00
|
|
|
mpeg2dec->sinkpad =
|
|
|
|
gst_pad_new_from_template (gst_static_pad_template_get
|
|
|
|
(&sink_template_factory), "sink");
|
2002-12-05 00:29:11 +00:00
|
|
|
gst_element_add_pad (GST_ELEMENT (mpeg2dec), mpeg2dec->sinkpad);
|
2004-03-14 22:34:30 +00:00
|
|
|
gst_pad_set_chain_function (mpeg2dec->sinkpad,
|
|
|
|
GST_DEBUG_FUNCPTR (gst_mpeg2dec_chain));
|
|
|
|
gst_pad_set_formats_function (mpeg2dec->sinkpad,
|
|
|
|
GST_DEBUG_FUNCPTR (gst_mpeg2dec_get_sink_formats));
|
|
|
|
gst_pad_set_convert_function (mpeg2dec->sinkpad,
|
|
|
|
GST_DEBUG_FUNCPTR (gst_mpeg2dec_convert_sink));
|
|
|
|
|
2004-05-05 09:13:42 +00:00
|
|
|
mpeg2dec->srcpad = gst_pad_new_from_template (src_templ (), "src");
|
2002-12-05 00:29:11 +00:00
|
|
|
gst_element_add_pad (GST_ELEMENT (mpeg2dec), mpeg2dec->srcpad);
|
2004-01-02 07:09:23 +00:00
|
|
|
gst_pad_use_explicit_caps (mpeg2dec->srcpad);
|
2004-03-14 22:34:30 +00:00
|
|
|
gst_pad_set_formats_function (mpeg2dec->srcpad,
|
|
|
|
GST_DEBUG_FUNCPTR (gst_mpeg2dec_get_src_formats));
|
|
|
|
gst_pad_set_event_mask_function (mpeg2dec->srcpad,
|
|
|
|
GST_DEBUG_FUNCPTR (gst_mpeg2dec_get_src_event_masks));
|
|
|
|
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));
|
|
|
|
gst_pad_set_convert_function (mpeg2dec->srcpad,
|
|
|
|
GST_DEBUG_FUNCPTR (gst_mpeg2dec_convert_src));
|
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 =
|
|
|
|
gst_pad_new_from_template (gst_static_pad_template_get
|
|
|
|
(&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
|
|
|
|
2002-12-23 00:32:36 +00:00
|
|
|
/* initialize the mpeg2dec acceleration */
|
2002-12-19 20:05:10 +00:00
|
|
|
mpeg2_accel (MPEG2_ACCEL_DETECT);
|
2002-12-26 22:46:26 +00:00
|
|
|
mpeg2dec->closed = TRUE;
|
2002-12-27 04:04:04 +00:00
|
|
|
mpeg2dec->have_fbuf = FALSE;
|
2005-02-04 13:43:28 +00:00
|
|
|
mpeg2dec->offset = 0;
|
|
|
|
|
|
|
|
for (i = 0; i < GST_MPEG2DEC_NUM_BUFS; i++)
|
|
|
|
mpeg2dec->buffers[i] = NULL;
|
2001-12-23 06:03:21 +00:00
|
|
|
|
2002-12-05 00:29:11 +00:00
|
|
|
GST_FLAG_SET (GST_ELEMENT (mpeg2dec), GST_ELEMENT_EVENT_AWARE);
|
2001-12-23 06:03:21 +00:00
|
|
|
}
|
|
|
|
|
2002-12-05 00:29:11 +00:00
|
|
|
static void
|
2004-03-14 22:34:30 +00:00
|
|
|
gst_mpeg2dec_close_decoder (GstMpeg2dec * mpeg2dec)
|
2001-12-23 06:03:21 +00:00
|
|
|
{
|
2002-12-23 00:32:36 +00:00
|
|
|
if (!mpeg2dec->closed) {
|
2002-12-05 00:29:11 +00:00
|
|
|
mpeg2_close (mpeg2dec->decoder);
|
2005-02-04 13:43:28 +00:00
|
|
|
free_all_buffers (mpeg2dec);
|
2002-12-23 00:32:36 +00:00
|
|
|
mpeg2dec->closed = TRUE;
|
2002-12-26 22:46:26 +00:00
|
|
|
mpeg2dec->decoder = NULL;
|
2002-12-23 00:32:36 +00:00
|
|
|
}
|
2002-12-26 22:46:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:30 +00:00
|
|
|
gst_mpeg2dec_open_decoder (GstMpeg2dec * mpeg2dec)
|
2002-12-26 22:46:26 +00:00
|
|
|
{
|
|
|
|
gst_mpeg2dec_close_decoder (mpeg2dec);
|
|
|
|
mpeg2dec->decoder = mpeg2_init ();
|
|
|
|
mpeg2dec->closed = FALSE;
|
2002-12-27 04:04:04 +00:00
|
|
|
mpeg2dec->have_fbuf = FALSE;
|
2002-12-26 22:46:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:30 +00:00
|
|
|
gst_mpeg2dec_dispose (GObject * object)
|
2002-12-26 22:46:26 +00:00
|
|
|
{
|
|
|
|
GstMpeg2dec *mpeg2dec = GST_MPEG2DEC (object);
|
|
|
|
|
|
|
|
gst_mpeg2dec_close_decoder (mpeg2dec);
|
2001-12-23 06:03:21 +00:00
|
|
|
|
2002-12-05 00:29:11 +00:00
|
|
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
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
|
|
|
}
|
2001-12-23 06:03:21 +00:00
|
|
|
|
2005-02-04 13:43:28 +00:00
|
|
|
static gboolean
|
|
|
|
put_buffer (GstMpeg2dec * mpeg2dec, GstBuffer * buf)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < GST_MPEG2DEC_NUM_BUFS; i++) {
|
|
|
|
if (mpeg2dec->buffers[i] == NULL) {
|
|
|
|
GST_DEBUG_OBJECT (mpeg2dec, "Placing %p at slot %d", buf, i);
|
|
|
|
mpeg2dec->buffers[i] = buf;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
check_buffer (GstMpeg2dec * mpeg2dec, GstBuffer * buf)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < GST_MPEG2DEC_NUM_BUFS; i++)
|
|
|
|
if (mpeg2dec->buffers[i] == buf)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
free_buffer (GstMpeg2dec * mpeg2dec, GstBuffer * buf)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < GST_MPEG2DEC_NUM_BUFS; i++) {
|
|
|
|
if (mpeg2dec->buffers[i] == buf) {
|
|
|
|
GST_DEBUG_OBJECT (mpeg2dec, "Releasing %p at slot %d", buf, i);
|
|
|
|
gst_buffer_unref (buf);
|
|
|
|
mpeg2dec->buffers[i] = NULL;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
free_all_buffers (GstMpeg2dec * mpeg2dec)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < GST_MPEG2DEC_NUM_BUFS; i++) {
|
|
|
|
if (mpeg2dec->buffers[i] != NULL) {
|
|
|
|
gst_buffer_unref (mpeg2dec->buffers[i]);
|
|
|
|
mpeg2dec->buffers[i] = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-01-17 13:54:30 +00:00
|
|
|
|
|
|
|
static GstBuffer *
|
|
|
|
crop_buffer (GstMpeg2dec * mpeg2dec, GstBuffer * input)
|
|
|
|
{
|
|
|
|
unsigned char *in_data;
|
|
|
|
unsigned char *out_data;
|
|
|
|
uint h_subsample;
|
|
|
|
uint v_subsample;
|
|
|
|
uint line;
|
|
|
|
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)) {
|
|
|
|
/* If we don't know about the format, we just return the original
|
|
|
|
* buffer.
|
|
|
|
*/
|
|
|
|
if (mpeg2dec->format == MPEG2DEC_FORMAT_I422 ||
|
|
|
|
mpeg2dec->format == MPEG2DEC_FORMAT_I420 ||
|
|
|
|
mpeg2dec->format == MPEG2DEC_FORMAT_YV12) {
|
|
|
|
/*FIXME: I have tried to use gst_buffer_copy_on_write, but it
|
|
|
|
* still have some artifact, so I'me allocating new buffer
|
|
|
|
* for each frame decoded...
|
|
|
|
*/
|
|
|
|
if (mpeg2dec->format == MPEG2DEC_FORMAT_I422) {
|
|
|
|
outbuf =
|
|
|
|
gst_buffer_new_and_alloc (mpeg2dec->width * mpeg2dec->height * 2);
|
|
|
|
h_subsample = 2;
|
|
|
|
v_subsample = 1;
|
|
|
|
} else {
|
|
|
|
outbuf =
|
|
|
|
gst_buffer_new_and_alloc (mpeg2dec->width * mpeg2dec->height * 1.5);
|
|
|
|
h_subsample = 2;
|
|
|
|
v_subsample = 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (input);
|
|
|
|
GST_BUFFER_OFFSET (outbuf) = GST_BUFFER_OFFSET (input);
|
|
|
|
GST_BUFFER_DURATION (outbuf) = GST_BUFFER_DURATION (input);
|
|
|
|
|
|
|
|
/* 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 / v_subsample; line++) {
|
|
|
|
memcpy (out_data, in_data, mpeg2dec->width / h_subsample);
|
|
|
|
memcpy (out_data +
|
|
|
|
mpeg2dec->width * mpeg2dec->height / (v_subsample * h_subsample),
|
|
|
|
in_data +
|
|
|
|
mpeg2dec->decoded_width * mpeg2dec->decoded_height / (v_subsample *
|
|
|
|
h_subsample), mpeg2dec->width / h_subsample);
|
|
|
|
out_data += mpeg2dec->width / h_subsample;
|
|
|
|
in_data += mpeg2dec->decoded_width / h_subsample;
|
|
|
|
}
|
|
|
|
|
|
|
|
gst_buffer_unref (input);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return outbuf;
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:30 +00:00
|
|
|
static GstBuffer *
|
2005-02-04 13:43:28 +00:00
|
|
|
gst_mpeg2dec_alloc_buffer (GstMpeg2dec * mpeg2dec, gint64 offset)
|
2002-12-05 00:29:11 +00:00
|
|
|
{
|
|
|
|
GstBuffer *outbuf = NULL;
|
2005-01-17 13:54:30 +00:00
|
|
|
gint size = mpeg2dec->decoded_width * mpeg2dec->decoded_height;
|
2002-12-05 00:29:11 +00:00
|
|
|
guint8 *buf[3], *out;
|
2001-12-23 06:03:21 +00:00
|
|
|
|
2004-03-31 06:31:47 +00:00
|
|
|
if (mpeg2dec->format == MPEG2DEC_FORMAT_I422) {
|
2004-07-15 19:02:13 +00:00
|
|
|
outbuf =
|
|
|
|
gst_pad_alloc_buffer (mpeg2dec->srcpad, GST_BUFFER_OFFSET_NONE,
|
|
|
|
size * 2);
|
2001-12-23 06:03:21 +00:00
|
|
|
|
2005-02-04 13:43:28 +00:00
|
|
|
if (!outbuf) {
|
|
|
|
GST_ELEMENT_ERROR (mpeg2dec, RESOURCE, FAILED, (NULL),
|
|
|
|
("Failed to allocate memory for buffer"));
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2004-03-31 06:31:47 +00:00
|
|
|
out = GST_BUFFER_DATA (outbuf);
|
2001-12-23 06:03:21 +00:00
|
|
|
|
2004-03-31 06:31:47 +00:00
|
|
|
buf[0] = out;
|
2002-12-05 00:29:11 +00:00
|
|
|
buf[1] = buf[0] + size;
|
2004-03-31 06:31:47 +00:00
|
|
|
buf[2] = buf[1] + size / 2;
|
|
|
|
|
2004-03-14 22:34:30 +00:00
|
|
|
} else {
|
2004-07-15 19:02:13 +00:00
|
|
|
outbuf =
|
|
|
|
gst_pad_alloc_buffer (mpeg2dec->srcpad, GST_BUFFER_OFFSET_NONE,
|
|
|
|
(size * 3) / 2);
|
2004-03-31 06:31:47 +00:00
|
|
|
|
|
|
|
out = GST_BUFFER_DATA (outbuf);
|
|
|
|
|
|
|
|
buf[0] = out;
|
|
|
|
if (mpeg2dec->format == MPEG2DEC_FORMAT_I420) {
|
|
|
|
buf[0] = out;
|
|
|
|
buf[1] = buf[0] + size;
|
|
|
|
buf[2] = buf[1] + size / 4;
|
|
|
|
} else {
|
|
|
|
buf[0] = out;
|
|
|
|
buf[2] = buf[0] + size;
|
|
|
|
buf[1] = buf[2] + size / 4;
|
|
|
|
}
|
2001-12-23 06:03:21 +00:00
|
|
|
}
|
|
|
|
|
2005-02-04 13:43:28 +00:00
|
|
|
if (!put_buffer (mpeg2dec, outbuf)) {
|
|
|
|
GST_ELEMENT_ERROR (mpeg2dec, LIBRARY, TOO_LAZY, (NULL),
|
|
|
|
("No free slot. libmpeg2 did not discard buffers."));
|
|
|
|
return NULL;
|
|
|
|
}
|
2004-04-01 11:48:27 +00:00
|
|
|
|
|
|
|
mpeg2_custom_fbuf (mpeg2dec->decoder, 1);
|
2002-12-05 00:29:11 +00:00
|
|
|
mpeg2_set_buf (mpeg2dec->decoder, buf, outbuf);
|
2001-12-23 06:03:21 +00:00
|
|
|
|
2002-12-23 00:32:36 +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;
|
2001-12-23 06:03:21 +00:00
|
|
|
|
2002-12-26 22:46:26 +00:00
|
|
|
return outbuf;
|
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;
|
2004-03-31 06:31:47 +00:00
|
|
|
guint32 fourcc, myFourcc;
|
2004-01-02 10:06:22 +00:00
|
|
|
gboolean ret;
|
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
|
|
|
|
2003-07-24 03:02:06 +00:00
|
|
|
if (!GST_PAD_IS_LINKED (mpeg2dec->srcpad)) {
|
|
|
|
mpeg2dec->format = MPEG2DEC_FORMAT_I420;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2004-03-31 06:31:47 +00:00
|
|
|
info = mpeg2_info (mpeg2dec->decoder);
|
|
|
|
sequence = info->sequence;
|
|
|
|
|
|
|
|
if (sequence->width != sequence->chroma_width &&
|
|
|
|
sequence->height != sequence->chroma_height)
|
|
|
|
myFourcc = GST_STR_FOURCC ("I420");
|
|
|
|
else if (sequence->width == sequence->chroma_width ||
|
|
|
|
sequence->height == sequence->chroma_height)
|
|
|
|
myFourcc = GST_STR_FOURCC ("Y42B");
|
|
|
|
else {
|
|
|
|
g_warning ("mpeg2dec: 4:4:4 format not yet supported");
|
|
|
|
return (FALSE);
|
|
|
|
}
|
|
|
|
|
2004-01-02 10:06:22 +00:00
|
|
|
caps = gst_caps_new_simple ("video/x-raw-yuv",
|
2004-03-31 06:31:47 +00:00
|
|
|
"format", GST_TYPE_FOURCC, myFourcc,
|
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,
|
2004-05-05 09:13:42 +00:00
|
|
|
"framerate", G_TYPE_DOUBLE, mpeg2dec->frame_rate, NULL);
|
2003-12-22 01:47:08 +00:00
|
|
|
|
2004-01-02 07:09:23 +00:00
|
|
|
ret = gst_pad_set_explicit_caps (mpeg2dec->srcpad, caps);
|
2004-03-14 22:34:30 +00:00
|
|
|
if (!ret)
|
|
|
|
return FALSE;
|
2003-12-22 01:47:08 +00:00
|
|
|
|
|
|
|
/* it worked, try to find what it was again */
|
2004-03-14 22:34:30 +00:00
|
|
|
gst_structure_get_fourcc (gst_caps_get_structure (caps, 0),
|
2003-12-22 01:47:08 +00:00
|
|
|
"format", &fourcc);
|
2004-03-14 22:34:30 +00:00
|
|
|
|
2004-03-31 06:31:47 +00:00
|
|
|
if (fourcc == GST_STR_FOURCC ("Y42B")) {
|
|
|
|
mpeg2dec->format = MPEG2DEC_FORMAT_I422;
|
|
|
|
} else if (fourcc == GST_STR_FOURCC ("I420")) {
|
2003-12-22 01:47:08 +00:00
|
|
|
mpeg2dec->format = MPEG2DEC_FORMAT_I420;
|
|
|
|
} else {
|
|
|
|
mpeg2dec->format = MPEG2DEC_FORMAT_YV12;
|
2001-12-23 06:03:21 +00:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
2005-02-04 13:43:28 +00:00
|
|
|
static gboolean
|
|
|
|
handle_sequence (GstMpeg2dec * mpeg2dec, const mpeg2_info_t * info)
|
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
mpeg2dec->width = info->sequence->picture_width;
|
|
|
|
mpeg2dec->height = info->sequence->picture_height;
|
|
|
|
mpeg2dec->pixel_width = info->sequence->pixel_width;
|
|
|
|
mpeg2dec->pixel_height = info->sequence->pixel_height;
|
|
|
|
mpeg2dec->decoded_width = info->sequence->width;
|
|
|
|
mpeg2dec->decoded_height = info->sequence->height;
|
|
|
|
mpeg2dec->total_frames = 0;
|
|
|
|
|
|
|
|
/* find framerate */
|
|
|
|
for (i = 0; i < 9; i++) {
|
|
|
|
if (info->sequence->frame_period == frame_periods[i]) {
|
|
|
|
mpeg2dec->frame_rate = fpss[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mpeg2dec->frame_period = info->sequence->frame_period * GST_USECOND / 27;
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (mpeg2dec,
|
|
|
|
"sequence flags: %d, frame period: %d (%g), frame rate: %g",
|
|
|
|
info->sequence->flags, info->sequence->frame_period,
|
|
|
|
(double) (mpeg2dec->frame_period) / GST_SECOND, mpeg2dec->frame_rate);
|
|
|
|
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);
|
|
|
|
|
|
|
|
if (!gst_mpeg2dec_negotiate_format (mpeg2dec)) {
|
|
|
|
GST_ELEMENT_ERROR (mpeg2dec, CORE, NEGOTIATION, (NULL), (NULL));
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!mpeg2dec->have_fbuf) {
|
|
|
|
/* alloc 2 buffers */
|
|
|
|
if (!gst_mpeg2dec_alloc_buffer (mpeg2dec, mpeg2dec->offset) ||
|
|
|
|
!gst_mpeg2dec_alloc_buffer (mpeg2dec, mpeg2dec->offset))
|
|
|
|
return FALSE;
|
|
|
|
mpeg2dec->have_fbuf = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
mpeg2dec->need_sequence = FALSE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
handle_picture (GstMpeg2dec * mpeg2dec, const mpeg2_info_t * info)
|
|
|
|
{
|
|
|
|
gboolean key_frame = FALSE;
|
|
|
|
GstBuffer *outbuf;
|
|
|
|
|
|
|
|
if (info->current_picture) {
|
|
|
|
key_frame =
|
|
|
|
(info->current_picture->flags & PIC_MASK_CODING_TYPE) ==
|
|
|
|
PIC_FLAG_CODING_TYPE_I;
|
|
|
|
}
|
|
|
|
outbuf = gst_mpeg2dec_alloc_buffer (mpeg2dec, mpeg2dec->offset);
|
|
|
|
if (!outbuf)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (mpeg2dec, "picture %s, outbuf %p, offset %"
|
|
|
|
G_GINT64_FORMAT,
|
|
|
|
key_frame ? ", kf," : " ", outbuf, GST_BUFFER_OFFSET (outbuf)
|
|
|
|
);
|
|
|
|
|
|
|
|
if (mpeg2dec->discont_state == MPEG2DEC_DISC_NEW_PICTURE && key_frame)
|
|
|
|
mpeg2dec->discont_state = MPEG2DEC_DISC_NEW_KEYFRAME;
|
|
|
|
|
|
|
|
if (!GST_PAD_IS_USABLE (mpeg2dec->srcpad))
|
|
|
|
mpeg2_skip (mpeg2dec->decoder, 1);
|
|
|
|
else
|
|
|
|
mpeg2_skip (mpeg2dec->decoder, 0);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
handle_slice (GstMpeg2dec * mpeg2dec, const mpeg2_info_t * info)
|
|
|
|
{
|
|
|
|
GstBuffer *outbuf = NULL;
|
|
|
|
gboolean skip = FALSE;
|
|
|
|
|
|
|
|
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));
|
|
|
|
|
|
|
|
if (info->display_fbuf && info->display_fbuf->id) {
|
|
|
|
const mpeg2_picture_t *picture;
|
|
|
|
gboolean key_frame = FALSE;
|
|
|
|
|
|
|
|
outbuf = GST_BUFFER (info->display_fbuf->id);
|
|
|
|
if (!check_buffer (mpeg2dec, outbuf)) {
|
|
|
|
GST_ELEMENT_ERROR (mpeg2dec, RESOURCE, FAILED, (NULL),
|
|
|
|
("libmpeg2 reported invalid buffer %p", outbuf));
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gst_buffer_ref (outbuf);
|
|
|
|
|
|
|
|
picture = info->display_picture;
|
|
|
|
|
|
|
|
key_frame =
|
|
|
|
(picture->flags & PIC_MASK_CODING_TYPE) == PIC_FLAG_CODING_TYPE_I;
|
|
|
|
GST_DEBUG_OBJECT (mpeg2dec, "picture keyframe %d", key_frame);
|
|
|
|
|
|
|
|
if (key_frame) {
|
|
|
|
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_KEY_UNIT);
|
|
|
|
}
|
|
|
|
if (mpeg2dec->discont_state == MPEG2DEC_DISC_NEW_KEYFRAME && key_frame)
|
|
|
|
mpeg2dec->discont_state = MPEG2DEC_DISC_NONE;
|
|
|
|
|
|
|
|
#if MPEG2_RELEASE < MPEG2_VERSION(0,4,0)
|
|
|
|
if (picture->flags & PIC_FLAG_PTS) {
|
|
|
|
GstClockTime time = MPEG_TIME_TO_GST_TIME (picture->pts);
|
|
|
|
#else
|
|
|
|
if (picture->flags & PIC_FLAG_TAGS) {
|
|
|
|
GstClockTime time =
|
|
|
|
MPEG_TIME_TO_GST_TIME ((GstClockTime) (picture->
|
|
|
|
tag2) << 32 | picture->tag);
|
|
|
|
#endif
|
|
|
|
GST_DEBUG_OBJECT (mpeg2dec,
|
|
|
|
"picture had pts %" GST_TIME_FORMAT ", we had %"
|
|
|
|
GST_TIME_FORMAT, GST_TIME_ARGS (time),
|
|
|
|
GST_TIME_ARGS (mpeg2dec->next_time));
|
|
|
|
GST_BUFFER_TIMESTAMP (outbuf) = mpeg2dec->next_time = time;
|
|
|
|
} else {
|
|
|
|
GST_DEBUG_OBJECT (mpeg2dec,
|
|
|
|
"picture didn't have pts. Using %" GST_TIME_FORMAT,
|
|
|
|
GST_TIME_ARGS (mpeg2dec->next_time));
|
|
|
|
GST_BUFFER_TIMESTAMP (outbuf) = mpeg2dec->next_time;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 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);
|
|
|
|
|
|
|
|
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)));
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (picture->flags & PIC_FLAG_SKIP) {
|
|
|
|
GST_DEBUG_OBJECT (mpeg2dec, "dropping buffer because of skip flag");
|
|
|
|
gst_buffer_unref (outbuf);
|
|
|
|
} else if (!GST_PAD_IS_USABLE (mpeg2dec->srcpad)) {
|
|
|
|
GST_DEBUG_OBJECT (mpeg2dec, "dropping buffer, pad not usable");
|
|
|
|
gst_buffer_unref (outbuf);
|
|
|
|
} else if (mpeg2dec->discont_state != MPEG2DEC_DISC_NONE) {
|
|
|
|
GST_DEBUG_OBJECT (mpeg2dec, "dropping buffer, discont state %d",
|
|
|
|
mpeg2dec->discont_state);
|
|
|
|
gst_buffer_unref (outbuf);
|
|
|
|
} else if (mpeg2dec->next_time < mpeg2dec->segment_start) {
|
|
|
|
GST_DEBUG_OBJECT (mpeg2dec, "dropping buffer, next_time %"
|
|
|
|
GST_TIME_FORMAT " < segment_start %" GST_TIME_FORMAT,
|
|
|
|
GST_TIME_ARGS (mpeg2dec->next_time),
|
|
|
|
GST_TIME_ARGS (mpeg2dec->segment_start));
|
|
|
|
gst_buffer_unref (outbuf);
|
|
|
|
} else if (skip) {
|
|
|
|
GST_DEBUG_OBJECT (mpeg2dec, "dropping buffer, asked to skip");
|
|
|
|
gst_buffer_unref (outbuf);
|
|
|
|
} else {
|
|
|
|
GST_LOG_OBJECT (mpeg2dec, "pushing buffer, timestamp %"
|
|
|
|
GST_TIME_FORMAT ", duration %" GST_TIME_FORMAT,
|
|
|
|
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (outbuf)),
|
|
|
|
GST_TIME_ARGS (GST_BUFFER_DURATION (outbuf)));
|
|
|
|
|
|
|
|
if ((mpeg2dec->decoded_height > mpeg2dec->height) ||
|
|
|
|
(mpeg2dec->decoded_width > mpeg2dec->width))
|
|
|
|
outbuf = crop_buffer (mpeg2dec, outbuf);
|
|
|
|
|
|
|
|
if (info->current_picture
|
|
|
|
&& (info->current_picture->flags & PIC_MASK_CODING_TYPE) ==
|
|
|
|
PIC_FLAG_CODING_TYPE_I) {
|
|
|
|
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_KEY_UNIT);
|
|
|
|
} else {
|
|
|
|
GST_BUFFER_FLAG_UNSET (outbuf, GST_BUFFER_KEY_UNIT);
|
|
|
|
}
|
|
|
|
gst_pad_push (mpeg2dec->srcpad, GST_DATA (outbuf));
|
|
|
|
}
|
|
|
|
} else if (info->display_fbuf && !info->display_fbuf->id) {
|
|
|
|
GST_ELEMENT_ERROR (mpeg2dec, LIBRARY, TOO_LAZY, (NULL),
|
|
|
|
("libmpeg2 reported invalid buffer %p", info->discard_fbuf->id));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (info->discard_fbuf && info->discard_fbuf->id) {
|
|
|
|
if (free_buffer (mpeg2dec, GST_BUFFER (info->discard_fbuf->id))) {
|
|
|
|
GST_DEBUG_OBJECT (mpeg2dec, "Discarded buffer %p",
|
|
|
|
info->discard_fbuf->id);
|
|
|
|
} else {
|
|
|
|
GST_ELEMENT_ERROR (mpeg2dec, LIBRARY, TOO_LAZY, (NULL),
|
|
|
|
("libmpeg2 reported invalid buffer %p", info->discard_fbuf->id));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2002-12-27 04:04:04 +00:00
|
|
|
static void
|
2004-03-14 22:34:30 +00:00
|
|
|
gst_mpeg2dec_flush_decoder (GstMpeg2dec * mpeg2dec)
|
2002-12-27 04:04:04 +00:00
|
|
|
{
|
|
|
|
if (mpeg2dec->decoder) {
|
|
|
|
const mpeg2_info_t *info = mpeg2_info (mpeg2dec->decoder);
|
2004-05-07 16:17:25 +00:00
|
|
|
mpeg2_state_t state;
|
2002-12-27 04:04:04 +00:00
|
|
|
|
2005-02-04 13:43:28 +00:00
|
|
|
/*
|
|
|
|
* iterate the decoder and free buffers
|
|
|
|
*/
|
2002-12-27 04:04:04 +00:00
|
|
|
do {
|
|
|
|
state = mpeg2_parse (mpeg2dec->decoder);
|
2005-02-04 13:43:28 +00:00
|
|
|
switch (state) {
|
|
|
|
case STATE_PICTURE:
|
|
|
|
mpeg2_skip (mpeg2dec->decoder, 1);
|
|
|
|
break;
|
|
|
|
case STATE_END:
|
|
|
|
#if MPEG2_RELEASE >= MPEG2_VERSION (0, 4, 0)
|
|
|
|
case STATE_INVALID_END:
|
|
|
|
#endif
|
|
|
|
case STATE_SLICE:
|
|
|
|
if (info->discard_fbuf && info->discard_fbuf->id) {
|
|
|
|
if (free_buffer (mpeg2dec, GST_BUFFER (info->discard_fbuf->id))) {
|
|
|
|
GST_DEBUG_OBJECT (mpeg2dec, "Discarded buffer %p",
|
|
|
|
info->discard_fbuf->id);
|
|
|
|
} else {
|
|
|
|
GST_ELEMENT_ERROR (mpeg2dec, LIBRARY, TOO_LAZY, (NULL),
|
|
|
|
("libmpeg2 reported invalid buffer %p",
|
|
|
|
info->discard_fbuf->id));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case STATE_INVALID:
|
|
|
|
GST_WARNING_OBJECT (mpeg2dec, "Decoding error");
|
|
|
|
/*
|
|
|
|
* We need to close the decoder here, according to docs
|
|
|
|
*/
|
|
|
|
gst_mpeg2dec_close_decoder (mpeg2dec);
|
|
|
|
gst_mpeg2dec_open_decoder (mpeg2dec);
|
|
|
|
return;
|
|
|
|
default:
|
|
|
|
break;
|
2002-12-27 04:04:04 +00:00
|
|
|
}
|
2004-03-14 22:34:30 +00:00
|
|
|
}
|
2003-10-07 10:08:30 +00:00
|
|
|
while (state != STATE_BUFFER && state != -1);
|
2002-12-27 04:04:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-12-23 06:03:21 +00:00
|
|
|
static void
|
2004-03-14 22:34:30 +00:00
|
|
|
gst_mpeg2dec_chain (GstPad * pad, GstData * _data)
|
2001-12-23 06:03:21 +00:00
|
|
|
{
|
2003-10-08 16:08:10 +00:00
|
|
|
GstBuffer *buf = GST_BUFFER (_data);
|
2001-12-23 06:03:21 +00:00
|
|
|
GstMpeg2dec *mpeg2dec = GST_MPEG2DEC (gst_pad_get_parent (pad));
|
|
|
|
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;
|
2001-12-23 06:03:21 +00:00
|
|
|
|
|
|
|
if (GST_IS_EVENT (buf)) {
|
2002-05-26 21:59:22 +00:00
|
|
|
GstEvent *event = GST_EVENT (buf);
|
2001-12-23 06:03:21 +00:00
|
|
|
|
2002-06-02 11:57:12 +00:00
|
|
|
switch (GST_EVENT_TYPE (event)) {
|
2001-12-23 06:03:21 +00:00
|
|
|
case GST_EVENT_DISCONTINUOUS:
|
2002-05-26 21:59:22 +00:00
|
|
|
{
|
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 time;
|
|
|
|
|
|
|
|
if (!gst_event_discont_get_value (event, GST_FORMAT_TIME, &time)
|
|
|
|
|| !GST_CLOCK_TIME_IS_VALID (time)) {
|
|
|
|
GST_WARNING_OBJECT (mpeg2dec,
|
|
|
|
"No new time offset in discont event %p", event);
|
|
|
|
} else {
|
|
|
|
mpeg2dec->next_time = time;
|
|
|
|
GST_DEBUG_OBJECT (mpeg2dec,
|
|
|
|
"discont, reset next_time to %" G_GUINT64_FORMAT " (%"
|
|
|
|
GST_TIME_FORMAT ")", mpeg2dec->next_time,
|
|
|
|
GST_TIME_ARGS (mpeg2dec->next_time));
|
|
|
|
}
|
|
|
|
|
2004-03-15 19:32:25 +00:00
|
|
|
mpeg2dec->discont_state = MPEG2DEC_DISC_NEW_PICTURE;
|
|
|
|
gst_mpeg2dec_flush_decoder (mpeg2dec);
|
|
|
|
gst_pad_event_default (pad, event);
|
|
|
|
return;
|
2002-05-26 21:59:22 +00:00
|
|
|
}
|
2005-02-04 13:43:28 +00:00
|
|
|
case GST_EVENT_FLUSH:
|
|
|
|
{
|
|
|
|
mpeg2dec->discont_state = MPEG2DEC_DISC_NEW_PICTURE;
|
|
|
|
gst_mpeg2dec_flush_decoder (mpeg2dec);
|
|
|
|
gst_pad_event_default (pad, event);
|
|
|
|
return;
|
|
|
|
}
|
2001-12-23 06:03:21 +00:00
|
|
|
case GST_EVENT_EOS:
|
2004-03-15 19:32:25 +00:00
|
|
|
if (mpeg2dec->index && mpeg2dec->closed) {
|
|
|
|
gst_index_commit (mpeg2dec->index, mpeg2dec->index_id);
|
|
|
|
}
|
2001-12-23 06:03:21 +00:00
|
|
|
default:
|
2004-07-07 16:49:49 +00:00
|
|
|
GST_DEBUG_OBJECT (mpeg2dec, "Got event of type %d on sink pad",
|
|
|
|
GST_EVENT_TYPE (event));
|
2004-03-15 19:32:25 +00:00
|
|
|
gst_pad_event_default (pad, event);
|
|
|
|
return;
|
2001-12-23 06:03:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
size = GST_BUFFER_SIZE (buf);
|
|
|
|
data = GST_BUFFER_DATA (buf);
|
|
|
|
pts = GST_BUFFER_TIMESTAMP (buf);
|
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
|
|
|
|
2002-12-05 00:29:11 +00:00
|
|
|
info = mpeg2_info (mpeg2dec->decoder);
|
|
|
|
end = data + size;
|
|
|
|
|
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
|
|
|
if (pts != GST_CLOCK_TIME_NONE) {
|
2004-07-07 16:49:49 +00:00
|
|
|
gint64 mpeg_pts = GST_TIME_TO_MPEG_TIME (pts);
|
2002-12-05 00:29:11 +00:00
|
|
|
|
2004-07-07 16:49:49 +00:00
|
|
|
GST_DEBUG_OBJECT (mpeg2dec,
|
|
|
|
"have pts: %" G_GINT64_FORMAT " (%" GST_TIME_FORMAT ")", mpeg_pts,
|
|
|
|
GST_TIME_ARGS (MPEG_TIME_TO_GST_TIME (mpeg_pts)));
|
2002-12-05 00:29:11 +00:00
|
|
|
|
2004-01-03 22:17:16 +00:00
|
|
|
#if MPEG2_RELEASE >= MPEG2_VERSION(0,4,0)
|
2004-03-14 22:34:30 +00:00
|
|
|
mpeg2_tag_picture (mpeg2dec->decoder, mpeg_pts & 0xffffffff,
|
2004-03-15 19:32:25 +00:00
|
|
|
mpeg_pts >> 32);
|
2004-01-03 22:17:16 +00:00
|
|
|
#else
|
2002-12-05 00:29:11 +00:00
|
|
|
mpeg2_pts (mpeg2dec->decoder, mpeg_pts);
|
2004-01-03 22:17:16 +00:00
|
|
|
#endif
|
2004-03-14 22:34:30 +00:00
|
|
|
} else {
|
2004-04-01 11:48:27 +00:00
|
|
|
GST_LOG ("no pts");
|
2002-06-02 11:57:12 +00:00
|
|
|
}
|
2001-12-23 06:03:21 +00:00
|
|
|
|
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 mpeg2_buffer");
|
2002-12-05 00:29:11 +00:00
|
|
|
mpeg2_buffer (mpeg2dec->decoder, 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
|
|
|
GST_LOG_OBJECT (mpeg2dec, "calling mpeg2_buffer done");
|
2002-12-05 00:29:11 +00:00
|
|
|
|
2005-02-04 13:43:28 +00:00
|
|
|
mpeg2dec->offset = GST_BUFFER_OFFSET (buf);
|
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);
|
2002-12-05 00:29:11 +00:00
|
|
|
switch (state) {
|
|
|
|
case STATE_SEQUENCE:
|
2005-02-04 13:43:28 +00:00
|
|
|
if (!handle_sequence (mpeg2dec, info)) {
|
|
|
|
gst_mpeg2dec_flush_decoder (mpeg2dec);
|
2004-03-15 19:32:25 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mpeg2dec->pending_event) {
|
|
|
|
done =
|
|
|
|
GST_EVENT_SEEK_FLAGS (mpeg2dec->
|
|
|
|
pending_event) & GST_SEEK_FLAG_FLUSH;
|
|
|
|
|
|
|
|
gst_mpeg2dec_src_event (mpeg2dec->srcpad, mpeg2dec->pending_event);
|
|
|
|
mpeg2dec->pending_event = NULL;
|
|
|
|
}
|
|
|
|
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");
|
2002-12-05 00:29:11 +00:00
|
|
|
case STATE_GOP:
|
2004-03-15 19:32:25 +00:00
|
|
|
break;
|
2002-12-05 00:29:11 +00:00
|
|
|
case STATE_PICTURE:
|
|
|
|
{
|
2005-02-04 13:43:28 +00:00
|
|
|
if (!handle_picture (mpeg2dec, info)) {
|
|
|
|
gst_mpeg2dec_flush_decoder (mpeg2dec);
|
|
|
|
goto exit;
|
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:
|
|
|
|
#endif
|
2002-12-05 00:29:11 +00:00
|
|
|
case STATE_END:
|
2005-02-04 13:43:28 +00:00
|
|
|
mpeg2dec->need_sequence = TRUE;
|
|
|
|
case STATE_SLICE:
|
|
|
|
if (!handle_slice (mpeg2dec, info)) {
|
|
|
|
gst_mpeg2dec_flush_decoder (mpeg2dec);
|
|
|
|
goto exit;
|
2004-03-15 19:32:25 +00:00
|
|
|
}
|
2005-02-04 13:43:28 +00:00
|
|
|
if (state != STATE_SLICE)
|
|
|
|
gst_mpeg2dec_flush_decoder (mpeg2dec);
|
2004-04-01 11:48:27 +00:00
|
|
|
|
2004-03-15 19:32:25 +00:00
|
|
|
break;
|
2003-10-06 12:16:21 +00:00
|
|
|
case STATE_BUFFER:
|
2003-10-07 10:08:30 +00:00
|
|
|
case -1:
|
2005-02-04 13:43:28 +00:00
|
|
|
/* need more data */
|
2004-03-15 19:32:25 +00:00
|
|
|
done = TRUE;
|
|
|
|
break;
|
|
|
|
/* error */
|
2002-12-05 00:29:11 +00:00
|
|
|
case STATE_INVALID:
|
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_WARNING_OBJECT (mpeg2dec, "Decoding error");
|
2005-02-04 13:43:28 +00:00
|
|
|
/*
|
|
|
|
* We need to close the decoder here, according to docs
|
|
|
|
*/
|
|
|
|
gst_mpeg2dec_close_decoder (mpeg2dec);
|
|
|
|
gst_mpeg2dec_open_decoder (mpeg2dec);
|
|
|
|
goto exit;
|
|
|
|
|
2004-03-15 19:32:25 +00:00
|
|
|
break;
|
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);
|
2004-03-15 19:32:25 +00:00
|
|
|
break;
|
2002-12-05 00:29:11 +00:00
|
|
|
}
|
2002-12-19 07:45:11 +00:00
|
|
|
|
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) {
|
|
|
|
if (GST_PAD_IS_USABLE (mpeg2dec->userdatapad)) {
|
2004-03-15 19:32:25 +00:00
|
|
|
GstBuffer *udbuf = gst_buffer_new_and_alloc (info->user_data_len);
|
2002-12-19 21:05:57 +00:00
|
|
|
|
2004-03-15 19:32:25 +00:00
|
|
|
memcpy (GST_BUFFER_DATA (udbuf), info->user_data, info->user_data_len);
|
2002-12-19 21:05:57 +00:00
|
|
|
|
2004-03-15 19:32:25 +00:00
|
|
|
gst_pad_push (mpeg2dec->userdatapad, GST_DATA (udbuf));
|
2002-12-19 21:05:57 +00:00
|
|
|
}
|
|
|
|
}
|
2004-03-13 00:19:26 +00:00
|
|
|
#endif
|
2002-12-05 00:29:11 +00:00
|
|
|
}
|
2002-12-27 04:04:04 +00:00
|
|
|
exit:
|
2004-03-14 22:34:30 +00:00
|
|
|
gst_buffer_unref (buf);
|
2001-12-23 06:03:21 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:30 +00:00
|
|
|
static const GstFormat *
|
|
|
|
gst_mpeg2dec_get_sink_formats (GstPad * pad)
|
2002-12-05 00:29:11 +00:00
|
|
|
{
|
|
|
|
static const GstFormat formats[] = {
|
|
|
|
GST_FORMAT_BYTES,
|
|
|
|
GST_FORMAT_TIME,
|
|
|
|
0
|
|
|
|
};
|
2004-03-15 19:32:25 +00:00
|
|
|
|
2002-12-05 00:29:11 +00:00
|
|
|
return formats;
|
|
|
|
}
|
|
|
|
|
2002-05-26 21:59:22 +00:00
|
|
|
static gboolean
|
2004-03-14 22:34:30 +00:00
|
|
|
gst_mpeg2dec_convert_sink (GstPad * pad, GstFormat src_format, gint64 src_value,
|
|
|
|
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
|
|
|
|
2002-05-26 21:59:22 +00:00
|
|
|
mpeg2dec = GST_MPEG2DEC (gst_pad_get_parent (pad));
|
|
|
|
|
2002-12-26 22:46:26 +00:00
|
|
|
if (mpeg2dec->decoder == NULL)
|
|
|
|
return FALSE;
|
|
|
|
|
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) {
|
|
|
|
*dest_value = GST_SECOND * src_value / info->sequence->byte_rate;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
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) {
|
|
|
|
*dest_value = src_value * info->sequence->byte_rate / GST_SECOND;
|
|
|
|
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 GstFormat *
|
|
|
|
gst_mpeg2dec_get_src_formats (GstPad * pad)
|
2002-12-05 00:29:11 +00:00
|
|
|
{
|
|
|
|
static const GstFormat formats[] = {
|
|
|
|
GST_FORMAT_BYTES,
|
|
|
|
GST_FORMAT_TIME,
|
2003-05-24 10:15:28 +00:00
|
|
|
GST_FORMAT_DEFAULT,
|
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 formats;
|
|
|
|
}
|
|
|
|
|
2002-05-26 21:59:22 +00:00
|
|
|
static gboolean
|
2004-03-14 22:34:30 +00:00
|
|
|
gst_mpeg2dec_convert_src (GstPad * pad, GstFormat src_format, gint64 src_value,
|
|
|
|
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
|
|
|
|
2002-05-26 21:59:22 +00:00
|
|
|
mpeg2dec = GST_MPEG2DEC (gst_pad_get_parent (pad));
|
|
|
|
|
2002-12-26 22:46:26 +00:00
|
|
|
if (mpeg2dec->decoder == NULL)
|
|
|
|
return FALSE;
|
|
|
|
|
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) {
|
|
|
|
*dest_value = src_value * scale / mpeg2dec->frame_period;
|
|
|
|
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_TOTAL,
|
|
|
|
GST_QUERY_POSITION,
|
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
|
|
|
|
gst_mpeg2dec_src_query (GstPad * pad, GstQueryType type,
|
|
|
|
GstFormat * format, gint64 * value)
|
2002-05-26 21:59:22 +00:00
|
|
|
{
|
|
|
|
gboolean res = TRUE;
|
|
|
|
GstMpeg2dec *mpeg2dec;
|
ext/mpeg2dec/gstmpeg2dec.c: Don't send things to NULL PAD_PEERs
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c:
Don't send things to NULL PAD_PEERs
* gst/deinterlace/gstdeinterlace.c: (gst_deinterlace_chain):
Copy-on-write the incoming buffer.
* gst/mpegstream/gstdvddemux.h:
* gst/mpegstream/gstmpegclock.h:
* gst/mpegstream/gstmpegdemux.c: (gst_mpeg_demux_parse_syshead),
(normal_seek), (gst_mpeg_demux_handle_src_event):
* gst/mpegstream/gstmpegdemux.h:
* gst/mpegstream/gstmpegpacketize.h:
* gst/mpegstream/gstmpegparse.c:
(gst_mpeg_parse_update_streaminfo), (gst_mpeg_parse_reset),
(gst_mpeg_parse_handle_discont), (gst_mpeg_parse_parse_packhead),
(gst_mpeg_parse_loop), (gst_mpeg_parse_get_rate),
(gst_mpeg_parse_convert_src), (gst_mpeg_parse_handle_src_query),
(gst_mpeg_parse_handle_src_event), (gst_mpeg_parse_change_state):
* gst/mpegstream/gstmpegparse.h:
* gst/mpegstream/gstrfc2250enc.h:
Various changes to the way time is computed that make seeking and
total time estimation much better here.
Use G_BEGIN/END_DECLS instead of __cplusplus
* gst/videocrop/gstvideocrop.c: (gst_video_crop_chain):
Use gst_buffer_stamp instead of only copying the TIMESTAMP
2005-02-01 16:40:10 +00:00
|
|
|
static const GstFormat *formats = NULL;
|
2002-05-26 21:59:22 +00:00
|
|
|
|
|
|
|
mpeg2dec = GST_MPEG2DEC (gst_pad_get_parent (pad));
|
|
|
|
|
|
|
|
switch (type) {
|
2002-12-30 17:53:18 +00:00
|
|
|
case GST_QUERY_TOTAL:
|
2002-05-26 21:59:22 +00:00
|
|
|
{
|
|
|
|
switch (*format) {
|
2004-03-15 19:32:25 +00:00
|
|
|
case GST_FORMAT_TIME:
|
|
|
|
case GST_FORMAT_BYTES:
|
|
|
|
case GST_FORMAT_DEFAULT:
|
|
|
|
{
|
|
|
|
res = FALSE;
|
|
|
|
|
|
|
|
/* get our peer formats */
|
ext/mpeg2dec/gstmpeg2dec.c: Don't send things to NULL PAD_PEERs
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c:
Don't send things to NULL PAD_PEERs
* gst/deinterlace/gstdeinterlace.c: (gst_deinterlace_chain):
Copy-on-write the incoming buffer.
* gst/mpegstream/gstdvddemux.h:
* gst/mpegstream/gstmpegclock.h:
* gst/mpegstream/gstmpegdemux.c: (gst_mpeg_demux_parse_syshead),
(normal_seek), (gst_mpeg_demux_handle_src_event):
* gst/mpegstream/gstmpegdemux.h:
* gst/mpegstream/gstmpegpacketize.h:
* gst/mpegstream/gstmpegparse.c:
(gst_mpeg_parse_update_streaminfo), (gst_mpeg_parse_reset),
(gst_mpeg_parse_handle_discont), (gst_mpeg_parse_parse_packhead),
(gst_mpeg_parse_loop), (gst_mpeg_parse_get_rate),
(gst_mpeg_parse_convert_src), (gst_mpeg_parse_handle_src_query),
(gst_mpeg_parse_handle_src_event), (gst_mpeg_parse_change_state):
* gst/mpegstream/gstmpegparse.h:
* gst/mpegstream/gstrfc2250enc.h:
Various changes to the way time is computed that make seeking and
total time estimation much better here.
Use G_BEGIN/END_DECLS instead of __cplusplus
* gst/videocrop/gstvideocrop.c: (gst_video_crop_chain):
Use gst_buffer_stamp instead of only copying the TIMESTAMP
2005-02-01 16:40:10 +00:00
|
|
|
if (GST_PAD_PEER (mpeg2dec->sinkpad))
|
|
|
|
formats = gst_pad_get_formats (GST_PAD_PEER (mpeg2dec->sinkpad));
|
2004-03-15 19:32:25 +00:00
|
|
|
|
|
|
|
/* while we did not exhaust our seek formats without result */
|
ext/mpeg2dec/gstmpeg2dec.c: Don't send things to NULL PAD_PEERs
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c:
Don't send things to NULL PAD_PEERs
* gst/deinterlace/gstdeinterlace.c: (gst_deinterlace_chain):
Copy-on-write the incoming buffer.
* gst/mpegstream/gstdvddemux.h:
* gst/mpegstream/gstmpegclock.h:
* gst/mpegstream/gstmpegdemux.c: (gst_mpeg_demux_parse_syshead),
(normal_seek), (gst_mpeg_demux_handle_src_event):
* gst/mpegstream/gstmpegdemux.h:
* gst/mpegstream/gstmpegpacketize.h:
* gst/mpegstream/gstmpegparse.c:
(gst_mpeg_parse_update_streaminfo), (gst_mpeg_parse_reset),
(gst_mpeg_parse_handle_discont), (gst_mpeg_parse_parse_packhead),
(gst_mpeg_parse_loop), (gst_mpeg_parse_get_rate),
(gst_mpeg_parse_convert_src), (gst_mpeg_parse_handle_src_query),
(gst_mpeg_parse_handle_src_event), (gst_mpeg_parse_change_state):
* gst/mpegstream/gstmpegparse.h:
* gst/mpegstream/gstrfc2250enc.h:
Various changes to the way time is computed that make seeking and
total time estimation much better here.
Use G_BEGIN/END_DECLS instead of __cplusplus
* gst/videocrop/gstvideocrop.c: (gst_video_crop_chain):
Use gst_buffer_stamp instead of only copying the TIMESTAMP
2005-02-01 16:40:10 +00:00
|
|
|
while (formats && *formats && !res) {
|
2004-03-15 19:32:25 +00:00
|
|
|
GstFormat peer_format;
|
|
|
|
gint64 peer_value;
|
|
|
|
|
|
|
|
peer_format = *formats;
|
|
|
|
|
|
|
|
/* do the probe */
|
|
|
|
if (gst_pad_query (GST_PAD_PEER (mpeg2dec->sinkpad),
|
|
|
|
GST_QUERY_TOTAL, &peer_format, &peer_value)) {
|
|
|
|
GstFormat conv_format;
|
|
|
|
|
|
|
|
/* convert to TIME */
|
|
|
|
conv_format = GST_FORMAT_TIME;
|
|
|
|
res = gst_pad_convert (mpeg2dec->sinkpad,
|
|
|
|
peer_format, peer_value, &conv_format, value);
|
|
|
|
/* and to final format */
|
|
|
|
res &= gst_pad_convert (pad,
|
|
|
|
GST_FORMAT_TIME, *value, format, value);
|
|
|
|
}
|
|
|
|
formats++;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
res = FALSE;
|
|
|
|
break;
|
2002-05-26 21:59:22 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2002-12-30 17:53:18 +00:00
|
|
|
case GST_QUERY_POSITION:
|
2002-05-26 21:59:22 +00:00
|
|
|
{
|
|
|
|
switch (*format) {
|
2004-03-15 19:32:25 +00:00
|
|
|
default:
|
|
|
|
res = gst_pad_convert (pad,
|
|
|
|
GST_FORMAT_TIME, mpeg2dec->next_time, format, value);
|
|
|
|
break;
|
2002-05-26 21:59:22 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
res = FALSE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2002-12-05 00:29:11 +00:00
|
|
|
|
2004-03-14 22:34:30 +00:00
|
|
|
static const GstEventMask *
|
|
|
|
gst_mpeg2dec_get_src_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;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
mpeg2dec = GST_MPEG2DEC (gst_pad_get_parent (pad));
|
2004-03-14 22:34:30 +00:00
|
|
|
|
2002-12-23 00:32:36 +00:00
|
|
|
entry = gst_index_get_assoc_entry (mpeg2dec->index, mpeg2dec->index_id,
|
2004-03-14 22:34:30 +00:00
|
|
|
GST_INDEX_LOOKUP_BEFORE, GST_ASSOCIATION_FLAG_KEY_UNIT,
|
|
|
|
GST_EVENT_SEEK_FORMAT (event), GST_EVENT_SEEK_OFFSET (event));
|
2002-12-23 00:32:36 +00:00
|
|
|
|
ext/mpeg2dec/gstmpeg2dec.c: Don't send things to NULL PAD_PEERs
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c:
Don't send things to NULL PAD_PEERs
* gst/deinterlace/gstdeinterlace.c: (gst_deinterlace_chain):
Copy-on-write the incoming buffer.
* gst/mpegstream/gstdvddemux.h:
* gst/mpegstream/gstmpegclock.h:
* gst/mpegstream/gstmpegdemux.c: (gst_mpeg_demux_parse_syshead),
(normal_seek), (gst_mpeg_demux_handle_src_event):
* gst/mpegstream/gstmpegdemux.h:
* gst/mpegstream/gstmpegpacketize.h:
* gst/mpegstream/gstmpegparse.c:
(gst_mpeg_parse_update_streaminfo), (gst_mpeg_parse_reset),
(gst_mpeg_parse_handle_discont), (gst_mpeg_parse_parse_packhead),
(gst_mpeg_parse_loop), (gst_mpeg_parse_get_rate),
(gst_mpeg_parse_convert_src), (gst_mpeg_parse_handle_src_query),
(gst_mpeg_parse_handle_src_event), (gst_mpeg_parse_change_state):
* gst/mpegstream/gstmpegparse.h:
* gst/mpegstream/gstrfc2250enc.h:
Various changes to the way time is computed that make seeking and
total time estimation much better here.
Use G_BEGIN/END_DECLS instead of __cplusplus
* gst/videocrop/gstvideocrop.c: (gst_video_crop_chain):
Use gst_buffer_stamp instead of only copying the TIMESTAMP
2005-02-01 16:40:10 +00:00
|
|
|
if ((entry) && GST_PAD_PEER (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;
|
2002-12-23 00:32:36 +00:00
|
|
|
peer_formats = gst_pad_get_formats (GST_PAD_PEER (mpeg2dec->sinkpad));
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
GST_CAT_DEBUG (GST_CAT_SEEK, "index %s %" G_GINT64_FORMAT
|
|
|
|
" -> %s %" G_GINT64_FORMAT,
|
|
|
|
gst_format_get_details (GST_EVENT_SEEK_FORMAT (event))->nick,
|
|
|
|
GST_EVENT_SEEK_OFFSET (event),
|
|
|
|
gst_format_get_details (*try_formats)->nick, value);
|
|
|
|
|
|
|
|
/* lookup succeeded, create the seek */
|
|
|
|
seek_event =
|
|
|
|
gst_event_new_seek (*try_formats | GST_SEEK_METHOD_SET |
|
|
|
|
GST_SEEK_FLAG_FLUSH, value);
|
2004-05-07 16:17:25 +00:00
|
|
|
/* do the seek */
|
2004-03-15 19:32:25 +00:00
|
|
|
if (gst_pad_send_event (GST_PAD_PEER (mpeg2dec->sinkpad), seek_event)) {
|
|
|
|
/* seek worked, we're done, loop will exit */
|
|
|
|
gst_mpeg2dec_flush_decoder (mpeg2dec);
|
|
|
|
mpeg2dec->segment_start = GST_EVENT_SEEK_OFFSET (event);
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2002-12-26 22:46:26 +00:00
|
|
|
gint64 src_offset;
|
|
|
|
gboolean flush;
|
|
|
|
GstFormat format;
|
ext/mpeg2dec/gstmpeg2dec.c: Don't send things to NULL PAD_PEERs
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c:
Don't send things to NULL PAD_PEERs
* gst/deinterlace/gstdeinterlace.c: (gst_deinterlace_chain):
Copy-on-write the incoming buffer.
* gst/mpegstream/gstdvddemux.h:
* gst/mpegstream/gstmpegclock.h:
* gst/mpegstream/gstmpegdemux.c: (gst_mpeg_demux_parse_syshead),
(normal_seek), (gst_mpeg_demux_handle_src_event):
* gst/mpegstream/gstmpegdemux.h:
* gst/mpegstream/gstmpegpacketize.h:
* gst/mpegstream/gstmpegparse.c:
(gst_mpeg_parse_update_streaminfo), (gst_mpeg_parse_reset),
(gst_mpeg_parse_handle_discont), (gst_mpeg_parse_parse_packhead),
(gst_mpeg_parse_loop), (gst_mpeg_parse_get_rate),
(gst_mpeg_parse_convert_src), (gst_mpeg_parse_handle_src_query),
(gst_mpeg_parse_handle_src_event), (gst_mpeg_parse_change_state):
* gst/mpegstream/gstmpegparse.h:
* gst/mpegstream/gstrfc2250enc.h:
Various changes to the way time is computed that make seeking and
total time estimation much better here.
Use G_BEGIN/END_DECLS instead of __cplusplus
* gst/videocrop/gstvideocrop.c: (gst_video_crop_chain):
Use gst_buffer_stamp instead of only copying the TIMESTAMP
2005-02-01 16:40:10 +00:00
|
|
|
const GstFormat *peer_formats = NULL;
|
2002-12-26 22:46:26 +00:00
|
|
|
gboolean res = FALSE;
|
2002-05-26 21:59:22 +00:00
|
|
|
GstMpeg2dec *mpeg2dec;
|
|
|
|
|
|
|
|
mpeg2dec = GST_MPEG2DEC (gst_pad_get_parent (pad));
|
|
|
|
|
2002-12-26 22:46:26 +00:00
|
|
|
format = GST_FORMAT_TIME;
|
2002-05-26 21:59:22 +00:00
|
|
|
|
2002-12-26 22:46:26 +00:00
|
|
|
/* first bring the src_format to TIME */
|
|
|
|
if (!gst_pad_convert (pad,
|
2004-03-15 19:32:25 +00:00
|
|
|
GST_EVENT_SEEK_FORMAT (event), GST_EVENT_SEEK_OFFSET (event),
|
|
|
|
&format, &src_offset)) {
|
2002-12-26 22:46:26 +00:00
|
|
|
/* didn't work, probably unsupported seek format then */
|
|
|
|
return res;
|
|
|
|
}
|
2002-05-26 21:59:22 +00:00
|
|
|
|
2002-12-26 22:46:26 +00:00
|
|
|
/* shave off the flush flag, we'll need it later */
|
|
|
|
flush = GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_FLUSH;
|
2002-05-26 21:59:22 +00:00
|
|
|
|
2002-12-26 22:46:26 +00:00
|
|
|
/* get our peer formats */
|
ext/mpeg2dec/gstmpeg2dec.c: Don't send things to NULL PAD_PEERs
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c:
Don't send things to NULL PAD_PEERs
* gst/deinterlace/gstdeinterlace.c: (gst_deinterlace_chain):
Copy-on-write the incoming buffer.
* gst/mpegstream/gstdvddemux.h:
* gst/mpegstream/gstmpegclock.h:
* gst/mpegstream/gstmpegdemux.c: (gst_mpeg_demux_parse_syshead),
(normal_seek), (gst_mpeg_demux_handle_src_event):
* gst/mpegstream/gstmpegdemux.h:
* gst/mpegstream/gstmpegpacketize.h:
* gst/mpegstream/gstmpegparse.c:
(gst_mpeg_parse_update_streaminfo), (gst_mpeg_parse_reset),
(gst_mpeg_parse_handle_discont), (gst_mpeg_parse_parse_packhead),
(gst_mpeg_parse_loop), (gst_mpeg_parse_get_rate),
(gst_mpeg_parse_convert_src), (gst_mpeg_parse_handle_src_query),
(gst_mpeg_parse_handle_src_event), (gst_mpeg_parse_change_state):
* gst/mpegstream/gstmpegparse.h:
* gst/mpegstream/gstrfc2250enc.h:
Various changes to the way time is computed that make seeking and
total time estimation much better here.
Use G_BEGIN/END_DECLS instead of __cplusplus
* gst/videocrop/gstvideocrop.c: (gst_video_crop_chain):
Use gst_buffer_stamp instead of only copying the TIMESTAMP
2005-02-01 16:40:10 +00:00
|
|
|
if (GST_PAD_PEER (mpeg2dec->sinkpad))
|
|
|
|
peer_formats = gst_pad_get_formats (GST_PAD_PEER (mpeg2dec->sinkpad));
|
2002-12-05 00:29:11 +00:00
|
|
|
|
2002-12-26 22:46:26 +00:00
|
|
|
/* while we did not exhaust our seek formats without result */
|
|
|
|
while (peer_formats && *peer_formats) {
|
|
|
|
gint64 desired_offset;
|
2002-05-26 21:59:22 +00:00
|
|
|
|
2002-12-26 22:46:26 +00:00
|
|
|
format = *peer_formats;
|
2002-05-26 21:59:22 +00:00
|
|
|
|
2002-12-26 22:46:26 +00:00
|
|
|
/* try to convert requested format to one we can seek with on the sinkpad */
|
2004-03-14 22:34:30 +00:00
|
|
|
if (gst_pad_convert (mpeg2dec->sinkpad, GST_FORMAT_TIME, src_offset,
|
2004-03-15 19:32:25 +00:00
|
|
|
&format, &desired_offset)) {
|
2002-12-26 22:46:26 +00:00
|
|
|
GstEvent *seek_event;
|
|
|
|
|
|
|
|
/* conversion succeeded, create the seek */
|
2004-03-14 22:34:30 +00:00
|
|
|
seek_event =
|
2004-03-15 19:32:25 +00:00
|
|
|
gst_event_new_seek (format | GST_SEEK_METHOD_SET | flush,
|
|
|
|
desired_offset);
|
2002-12-26 22:46:26 +00:00
|
|
|
/* do the seekk */
|
|
|
|
if (gst_pad_send_event (GST_PAD_PEER (mpeg2dec->sinkpad), seek_event)) {
|
2004-03-15 19:32:25 +00:00
|
|
|
/* seek worked, we're done, loop will exit */
|
|
|
|
mpeg2dec->segment_start = GST_EVENT_SEEK_OFFSET (event);
|
|
|
|
res = TRUE;
|
|
|
|
break;
|
2002-12-26 22:46:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
peer_formats++;
|
|
|
|
}
|
|
|
|
/* at this point, either the seek worked and res = TRUE or res == FALSE and the seek
|
|
|
|
* failed */
|
|
|
|
if (res && flush) {
|
|
|
|
/* if we need to flush, iterate until the buffer is empty */
|
2002-12-27 04:04:04 +00:00
|
|
|
gst_mpeg2dec_flush_decoder (mpeg2dec);
|
2002-12-26 22:46:26 +00:00
|
|
|
}
|
2002-05-26 21:59:22 +00:00
|
|
|
|
2002-12-26 22:46:26 +00:00
|
|
|
return res;
|
|
|
|
}
|
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
|
|
|
{
|
|
|
|
gboolean res = TRUE;
|
|
|
|
GstMpeg2dec *mpeg2dec;
|
|
|
|
|
|
|
|
mpeg2dec = GST_MPEG2DEC (gst_pad_get_parent (pad));
|
|
|
|
|
|
|
|
if (mpeg2dec->decoder == NULL)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
switch (GST_EVENT_TYPE (event)) {
|
2004-03-14 22:34:30 +00:00
|
|
|
/* the all-formats seek logic */
|
2002-12-26 22:46:26 +00:00
|
|
|
case GST_EVENT_SEEK:
|
|
|
|
if (mpeg2dec->need_sequence) {
|
2004-03-15 19:32:25 +00:00
|
|
|
mpeg2dec->pending_event = event;
|
|
|
|
return TRUE;
|
2004-03-14 22:34:30 +00:00
|
|
|
} else {
|
2004-03-15 19:32:25 +00:00
|
|
|
if (mpeg2dec->index)
|
|
|
|
res = index_seek (pad, event);
|
|
|
|
else
|
|
|
|
res = normal_seek (pad, event);
|
2004-03-14 22:34:30 +00:00
|
|
|
|
2004-03-15 19:32:25 +00:00
|
|
|
if (res)
|
|
|
|
mpeg2dec->discont_state = MPEG2DEC_DISC_NEW_PICTURE;
|
2002-05-26 21:59:22 +00:00
|
|
|
}
|
|
|
|
break;
|
2004-01-06 16:42:10 +00:00
|
|
|
case GST_EVENT_NAVIGATION:
|
|
|
|
/* Forward a navigation event unchanged */
|
ext/mpeg2dec/gstmpeg2dec.c: Don't send things to NULL PAD_PEERs
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c:
Don't send things to NULL PAD_PEERs
* gst/deinterlace/gstdeinterlace.c: (gst_deinterlace_chain):
Copy-on-write the incoming buffer.
* gst/mpegstream/gstdvddemux.h:
* gst/mpegstream/gstmpegclock.h:
* gst/mpegstream/gstmpegdemux.c: (gst_mpeg_demux_parse_syshead),
(normal_seek), (gst_mpeg_demux_handle_src_event):
* gst/mpegstream/gstmpegdemux.h:
* gst/mpegstream/gstmpegpacketize.h:
* gst/mpegstream/gstmpegparse.c:
(gst_mpeg_parse_update_streaminfo), (gst_mpeg_parse_reset),
(gst_mpeg_parse_handle_discont), (gst_mpeg_parse_parse_packhead),
(gst_mpeg_parse_loop), (gst_mpeg_parse_get_rate),
(gst_mpeg_parse_convert_src), (gst_mpeg_parse_handle_src_query),
(gst_mpeg_parse_handle_src_event), (gst_mpeg_parse_change_state):
* gst/mpegstream/gstmpegparse.h:
* gst/mpegstream/gstrfc2250enc.h:
Various changes to the way time is computed that make seeking and
total time estimation much better here.
Use G_BEGIN/END_DECLS instead of __cplusplus
* gst/videocrop/gstvideocrop.c: (gst_video_crop_chain):
Use gst_buffer_stamp instead of only copying the TIMESTAMP
2005-02-01 16:40:10 +00:00
|
|
|
if (GST_PAD_PEER (mpeg2dec->sinkpad))
|
|
|
|
return gst_pad_send_event (GST_PAD_PEER (mpeg2dec->sinkpad), event);
|
|
|
|
|
|
|
|
res = FALSE;
|
|
|
|
break;
|
2002-05-26 21:59:22 +00:00
|
|
|
default:
|
|
|
|
res = FALSE;
|
|
|
|
break;
|
|
|
|
}
|
2002-07-09 17:39:18 +00:00
|
|
|
gst_event_unref (event);
|
2002-05-26 21:59:22 +00:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2001-12-23 06:03:21 +00:00
|
|
|
static GstElementStateReturn
|
2004-03-14 22:34:30 +00:00
|
|
|
gst_mpeg2dec_change_state (GstElement * element)
|
2001-12-23 06:03:21 +00:00
|
|
|
{
|
|
|
|
GstMpeg2dec *mpeg2dec = GST_MPEG2DEC (element);
|
|
|
|
|
2004-03-14 22:34:30 +00:00
|
|
|
switch (GST_STATE_TRANSITION (element)) {
|
2001-12-23 06:03:21 +00:00
|
|
|
case GST_STATE_NULL_TO_READY:
|
|
|
|
break;
|
|
|
|
case GST_STATE_READY_TO_PAUSED:
|
|
|
|
{
|
|
|
|
mpeg2dec->next_time = 0;
|
|
|
|
|
|
|
|
/* reset the initial video state */
|
2002-12-05 00:29:11 +00:00
|
|
|
mpeg2dec->format = MPEG2DEC_FORMAT_NONE;
|
2001-12-23 06:03:21 +00:00
|
|
|
mpeg2dec->width = -1;
|
|
|
|
mpeg2dec->height = -1;
|
2002-12-26 22:46:26 +00:00
|
|
|
mpeg2dec->segment_start = 0;
|
|
|
|
mpeg2dec->segment_end = -1;
|
|
|
|
mpeg2dec->discont_state = MPEG2DEC_DISC_NEW_PICTURE;
|
2002-12-05 00:29:11 +00:00
|
|
|
mpeg2dec->frame_period = 0;
|
2002-12-26 22:46:26 +00:00
|
|
|
gst_mpeg2dec_open_decoder (mpeg2dec);
|
|
|
|
mpeg2dec->need_sequence = TRUE;
|
2001-12-23 06:03:21 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case GST_STATE_PAUSED_TO_PLAYING:
|
|
|
|
break;
|
|
|
|
case GST_STATE_PLAYING_TO_PAUSED:
|
|
|
|
break;
|
|
|
|
case GST_STATE_PAUSED_TO_READY:
|
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_mpeg2dec_flush_decoder (mpeg2dec);
|
2002-12-26 22:46:26 +00:00
|
|
|
gst_mpeg2dec_close_decoder (mpeg2dec);
|
2001-12-23 06:03:21 +00:00
|
|
|
break;
|
|
|
|
case GST_STATE_READY_TO_NULL:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2002-12-26 22:46:26 +00:00
|
|
|
return GST_ELEMENT_CLASS (parent_class)->change_state (element);
|
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;
|
|
|
|
|
|
|
|
/* it's not null if we got it, but it might not be ours */
|
|
|
|
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
|
|
|
|
|
|
|
/* it's not null if we got it, but it might not be ours */
|
|
|
|
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",
|
|
|
|
"LibMpeg2 decoder", plugin_init, VERSION, "GPL", GST_PACKAGE, GST_ORIGIN)
|