2002-03-20 21:45:03 +00:00
|
|
|
/* GStreamer
|
2001-12-23 06:03:21 +00:00
|
|
|
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2003-06-29 19:46:09 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
2001-12-23 06:03:21 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include <inttypes.h>
|
|
|
|
|
|
|
|
#include "gstmpeg2dec.h"
|
|
|
|
|
2006-11-21 12:15:58 +00:00
|
|
|
/* 16byte-aligns a buffer for libmpeg2 */
|
2006-11-03 09:52:12 +00:00
|
|
|
#define ALIGN_16(p) ((void *)(((uintptr_t)(p) + 15) & ~((uintptr_t)15)))
|
|
|
|
|
2003-09-11 17:13:24 +00:00
|
|
|
/* mpeg2dec changed a struct name after 0.3.1, here's a workaround */
|
|
|
|
/* mpeg2dec also only defined MPEG2_RELEASE after 0.3.1
|
2005-07-19 20:51:16 +00:00
|
|
|
#if MPEG2_RELEASE < MPEG2_VERSION(0,3,2)
|
2003-09-11 17:13:24 +00:00
|
|
|
*/
|
|
|
|
#ifndef MPEG2_RELEASE
|
2004-01-03 23:45:32 +00:00
|
|
|
#define MPEG2_VERSION(a,b,c) ((((a)&0xff)<<16)|(((b)&0xff)<<8)|((c)&0xff))
|
|
|
|
#define MPEG2_RELEASE MPEG2_VERSION(0,3,1)
|
2003-09-11 17:13:24 +00:00
|
|
|
typedef picture_t mpeg2_picture_t;
|
2003-10-06 12:16:21 +00:00
|
|
|
typedef gint mpeg2_state_t;
|
2004-03-14 22:34:30 +00:00
|
|
|
|
2003-10-07 10:08:30 +00:00
|
|
|
#define STATE_BUFFER 0
|
2003-09-11 17:13:24 +00:00
|
|
|
#endif
|
|
|
|
|
2004-04-01 11:48:27 +00:00
|
|
|
GST_DEBUG_CATEGORY_STATIC (mpeg2dec_debug);
|
|
|
|
#define GST_CAT_DEFAULT (mpeg2dec_debug)
|
2003-07-25 02:04:01 +00:00
|
|
|
|
2007-03-02 13:01:48 +00:00
|
|
|
/* Send a warning message about decoding errors after receiving this many
|
|
|
|
* STATE_INVALID return values from mpeg2_parse. -1 means never.
|
2006-02-27 14:49:05 +00:00
|
|
|
*/
|
2007-03-02 13:01:48 +00:00
|
|
|
#define WARN_THRESHOLD (5)
|
2006-02-27 14:49:05 +00:00
|
|
|
|
2003-12-22 01:47:08 +00:00
|
|
|
static GstStaticPadTemplate sink_template_factory =
|
2004-03-14 22:34:30 +00:00
|
|
|
GST_STATIC_PAD_TEMPLATE ("sink",
|
|
|
|
GST_PAD_SINK,
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS ("video/mpeg, "
|
2004-03-15 19:32:25 +00:00
|
|
|
"mpegversion = (int) [ 1, 2 ], " "systemstream = (boolean) false")
|
2004-03-14 22:34:30 +00:00
|
|
|
);
|
|
|
|
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
static GstStaticPadTemplate src_template_factory =
|
|
|
|
GST_STATIC_PAD_TEMPLATE ("src",
|
|
|
|
GST_PAD_SRC,
|
|
|
|
GST_PAD_ALWAYS,
|
2012-04-13 23:06:52 +00:00
|
|
|
GST_STATIC_CAPS ("video/x-raw-yuv, "
|
|
|
|
"format = (fourcc) { YV12, I420, Y42B, Y444 }, "
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
"width = (int) [ 16, 4096 ], "
|
|
|
|
"height = (int) [ 16, 4096 ], "
|
2006-11-15 13:57:21 +00:00
|
|
|
"framerate = (fraction) [ 0/1, 2147483647/1 ]")
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
);
|
|
|
|
|
2012-04-13 23:06:52 +00:00
|
|
|
GST_BOILERPLATE (GstMpeg2dec, gst_mpeg2dec, GstVideoDecoder,
|
|
|
|
GST_TYPE_VIDEO_DECODER);
|
2004-03-14 22:34:30 +00:00
|
|
|
|
2012-04-13 23:06:52 +00:00
|
|
|
static void gst_mpeg2dec_finalize (GObject * object);
|
2004-03-14 22:34:30 +00:00
|
|
|
|
2012-04-13 23:06:52 +00:00
|
|
|
/* GstVideoDecoder base class method */
|
|
|
|
static gboolean gst_mpeg2dec_open (GstVideoDecoder * decoder);
|
|
|
|
static gboolean gst_mpeg2dec_close (GstVideoDecoder * decoder);
|
|
|
|
static gboolean gst_mpeg2dec_start (GstVideoDecoder * decoder);
|
2012-05-01 14:12:42 +00:00
|
|
|
static gboolean gst_mpeg2dec_stop (GstVideoDecoder * decoder);
|
2012-04-13 23:06:52 +00:00
|
|
|
static gboolean gst_mpeg2dec_set_format (GstVideoDecoder * decoder,
|
|
|
|
GstVideoCodecState * state);
|
|
|
|
static gboolean gst_mpeg2dec_reset (GstVideoDecoder * decoder, gboolean hard);
|
|
|
|
static GstFlowReturn gst_mpeg2dec_finish (GstVideoDecoder * decoder);
|
|
|
|
static GstFlowReturn gst_mpeg2dec_handle_frame (GstVideoDecoder * decoder,
|
|
|
|
GstVideoCodecFrame * frame);
|
|
|
|
|
|
|
|
/* GstElement overload */
|
|
|
|
static void gst_mpeg2dec_set_index (GstElement * element, GstIndex * index);
|
|
|
|
static GstIndex *gst_mpeg2dec_get_index (GstElement * element);
|
2005-07-19 20:51:16 +00:00
|
|
|
|
2012-05-01 18:49:03 +00:00
|
|
|
static void gst_mpeg2dec_clear_buffers (GstMpeg2dec * mpeg2dec);
|
2012-04-13 23:06:52 +00:00
|
|
|
static gboolean gst_mpeg2dec_crop_buffer (GstMpeg2dec * dec, GstBuffer ** buf);
|
2006-06-07 17:05:48 +00:00
|
|
|
|
2005-07-19 20:51:16 +00:00
|
|
|
|
2012-04-13 23:06:52 +00:00
|
|
|
static void
|
|
|
|
gst_mpeg2dec_base_init (gpointer g_class)
|
|
|
|
{
|
|
|
|
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
|
2001-12-23 06:03:21 +00:00
|
|
|
|
2012-04-13 23:06:52 +00:00
|
|
|
gst_element_class_add_static_pad_template (element_class,
|
|
|
|
&src_template_factory);
|
|
|
|
gst_element_class_add_static_pad_template (element_class,
|
|
|
|
&sink_template_factory);
|
|
|
|
gst_element_class_set_details_simple (element_class,
|
|
|
|
"mpeg1 and mpeg2 video decoder", "Codec/Decoder/Video",
|
|
|
|
"Uses libmpeg2 to decode MPEG video streams",
|
|
|
|
"Wim Taymans <wim.taymans@chello.be>");
|
|
|
|
}
|
2003-11-02 00:33:31 +00:00
|
|
|
|
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
|
|
|
{
|
2012-04-13 23:06:52 +00:00
|
|
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
|
|
|
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
|
|
|
GstVideoDecoderClass *video_decoder_class = GST_VIDEO_DECODER_CLASS (klass);
|
2001-12-23 06:03:21 +00:00
|
|
|
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
gobject_class->finalize = gst_mpeg2dec_finalize;
|
2001-12-23 06:03:21 +00:00
|
|
|
|
2012-04-13 23:06:52 +00:00
|
|
|
video_decoder_class->open = GST_DEBUG_FUNCPTR (gst_mpeg2dec_open);
|
|
|
|
video_decoder_class->close = GST_DEBUG_FUNCPTR (gst_mpeg2dec_close);
|
|
|
|
video_decoder_class->start = GST_DEBUG_FUNCPTR (gst_mpeg2dec_start);
|
2012-05-01 14:12:42 +00:00
|
|
|
video_decoder_class->stop = GST_DEBUG_FUNCPTR (gst_mpeg2dec_stop);
|
2012-04-13 23:06:52 +00:00
|
|
|
video_decoder_class->reset = GST_DEBUG_FUNCPTR (gst_mpeg2dec_reset);
|
|
|
|
video_decoder_class->set_format = GST_DEBUG_FUNCPTR (gst_mpeg2dec_set_format);
|
|
|
|
video_decoder_class->handle_frame =
|
|
|
|
GST_DEBUG_FUNCPTR (gst_mpeg2dec_handle_frame);
|
|
|
|
video_decoder_class->finish = GST_DEBUG_FUNCPTR (gst_mpeg2dec_finish);
|
2011-09-30 15:38:07 +00:00
|
|
|
|
2012-04-13 23:06:52 +00:00
|
|
|
element_class->set_index = gst_mpeg2dec_set_index;
|
|
|
|
element_class->get_index = gst_mpeg2dec_get_index;
|
2011-09-30 15:38:07 +00:00
|
|
|
|
|
|
|
GST_DEBUG_CATEGORY_INIT (mpeg2dec_debug, "mpeg2dec", 0,
|
2012-04-13 23:06:52 +00:00
|
|
|
"MPEG-2 Video Decoder");
|
2001-12-23 06:03:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-04-13 23:06:52 +00:00
|
|
|
gst_mpeg2dec_init (GstMpeg2dec * mpeg2dec, GstMpeg2decClass * klass)
|
2001-12-23 06:03:21 +00:00
|
|
|
{
|
2006-11-21 12:15:58 +00:00
|
|
|
mpeg2dec->can_allocate_aligned = TRUE;
|
2012-04-13 23:06:52 +00:00
|
|
|
gst_video_decoder_set_packetized (GST_VIDEO_DECODER (mpeg2dec), TRUE);
|
2006-02-27 14:49:05 +00:00
|
|
|
|
2002-12-23 00:32:36 +00:00
|
|
|
/* initialize the mpeg2dec acceleration */
|
2002-12-26 22:46:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
gst_mpeg2dec_finalize (GObject * object)
|
2002-12-26 22:46:26 +00:00
|
|
|
{
|
|
|
|
GstMpeg2dec *mpeg2dec = GST_MPEG2DEC (object);
|
|
|
|
|
2012-04-13 23:06:52 +00:00
|
|
|
if (mpeg2dec->index) {
|
|
|
|
gst_object_unref (mpeg2dec->index);
|
|
|
|
mpeg2dec->index = NULL;
|
|
|
|
mpeg2dec->index_id = 0;
|
|
|
|
}
|
|
|
|
|
2005-10-26 16:45:04 +00:00
|
|
|
if (mpeg2dec->decoder) {
|
|
|
|
GST_DEBUG_OBJECT (mpeg2dec, "closing decoder");
|
|
|
|
mpeg2_close (mpeg2dec->decoder);
|
|
|
|
mpeg2dec->decoder = NULL;
|
|
|
|
}
|
2012-04-13 23:06:52 +00:00
|
|
|
|
2012-05-01 18:49:03 +00:00
|
|
|
gst_mpeg2dec_clear_buffers (mpeg2dec);
|
2006-11-03 09:52:12 +00:00
|
|
|
g_free (mpeg2dec->dummybuf[3]);
|
|
|
|
mpeg2dec->dummybuf[3] = NULL;
|
2001-12-23 06:03:21 +00:00
|
|
|
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
2001-12-23 06:03:21 +00:00
|
|
|
}
|
|
|
|
|
2012-04-13 23:06:52 +00:00
|
|
|
static gboolean
|
|
|
|
gst_mpeg2dec_open (GstVideoDecoder * decoder)
|
|
|
|
{
|
|
|
|
GstMpeg2dec *mpeg2dec = GST_MPEG2DEC (decoder);
|
|
|
|
|
|
|
|
mpeg2_accel (MPEG2_ACCEL_DETECT);
|
|
|
|
if ((mpeg2dec->decoder = mpeg2_init ()) == NULL)
|
|
|
|
return FALSE;
|
|
|
|
mpeg2dec->info = mpeg2_info (mpeg2dec->decoder);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_mpeg2dec_close (GstVideoDecoder * decoder)
|
|
|
|
{
|
|
|
|
GstMpeg2dec *mpeg2dec = GST_MPEG2DEC (decoder);
|
|
|
|
|
|
|
|
if (mpeg2dec->decoder) {
|
|
|
|
mpeg2_close (mpeg2dec->decoder);
|
|
|
|
mpeg2dec->decoder = NULL;
|
|
|
|
mpeg2dec->info = NULL;
|
|
|
|
}
|
2012-05-01 18:49:03 +00:00
|
|
|
gst_mpeg2dec_clear_buffers (mpeg2dec);
|
2012-04-13 23:06:52 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_mpeg2dec_start (GstVideoDecoder * decoder)
|
|
|
|
{
|
|
|
|
return gst_mpeg2dec_reset (decoder, TRUE);
|
|
|
|
}
|
|
|
|
|
2012-05-01 14:12:42 +00:00
|
|
|
static gboolean
|
|
|
|
gst_mpeg2dec_stop (GstVideoDecoder * decoder)
|
|
|
|
{
|
|
|
|
GstMpeg2dec *mpeg2dec = GST_MPEG2DEC (decoder);
|
|
|
|
|
|
|
|
if (mpeg2dec->input_state) {
|
|
|
|
gst_video_codec_state_unref (mpeg2dec->input_state);
|
|
|
|
mpeg2dec->input_state = NULL;
|
|
|
|
}
|
|
|
|
return gst_mpeg2dec_reset (decoder, TRUE);
|
|
|
|
}
|
|
|
|
|
2012-04-13 23:06:52 +00:00
|
|
|
static gboolean
|
|
|
|
gst_mpeg2dec_set_format (GstVideoDecoder * decoder, GstVideoCodecState * state)
|
|
|
|
{
|
|
|
|
GstMpeg2dec *mpeg2dec = GST_MPEG2DEC (decoder);
|
|
|
|
GstStructure *s;
|
|
|
|
|
|
|
|
/* Save input state to be used as reference for output state */
|
|
|
|
if (mpeg2dec->input_state)
|
|
|
|
gst_video_codec_state_unref (mpeg2dec->input_state);
|
|
|
|
mpeg2dec->input_state = gst_video_codec_state_ref (state);
|
|
|
|
|
|
|
|
s = gst_caps_get_structure (state->caps, 0);
|
|
|
|
|
|
|
|
/* parse the par, this overrides the encoded par */
|
|
|
|
mpeg2dec->have_par = gst_structure_get_fraction (s, "pixel-aspect-ratio",
|
|
|
|
&mpeg2dec->pixel_width, &mpeg2dec->pixel_height);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_mpeg2dec_reset (GstVideoDecoder * decoder, gboolean hard)
|
2005-02-05 07:36:01 +00:00
|
|
|
{
|
2012-04-13 23:06:52 +00:00
|
|
|
GstMpeg2dec *mpeg2dec = GST_MPEG2DEC (decoder);
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (mpeg2dec, "%s", hard ? "hard" : "soft");
|
|
|
|
|
|
|
|
GST_OBJECT_LOCK (mpeg2dec);
|
|
|
|
if (mpeg2dec->index) {
|
|
|
|
gst_object_unref (mpeg2dec->index);
|
|
|
|
mpeg2dec->index = NULL;
|
|
|
|
mpeg2dec->index_id = 0;
|
|
|
|
}
|
|
|
|
GST_OBJECT_UNLOCK (mpeg2dec);
|
|
|
|
|
2005-02-05 07:36:01 +00:00
|
|
|
/* reset the initial video state */
|
2012-04-13 23:06:52 +00:00
|
|
|
mpeg2dec->width = -1;
|
|
|
|
mpeg2dec->height = -1;
|
2005-02-05 07:36:01 +00:00
|
|
|
mpeg2dec->discont_state = MPEG2DEC_DISC_NEW_PICTURE;
|
|
|
|
mpeg2dec->frame_period = 0;
|
2006-06-07 17:05:48 +00:00
|
|
|
mpeg2dec->next_time = -1;
|
2005-10-26 16:45:04 +00:00
|
|
|
mpeg2dec->offset = 0;
|
2006-11-21 12:15:58 +00:00
|
|
|
mpeg2dec->can_allocate_aligned = TRUE;
|
2012-04-13 23:06:52 +00:00
|
|
|
mpeg2_reset (mpeg2dec->decoder, hard);
|
|
|
|
mpeg2_skip (mpeg2dec->decoder, 1);
|
|
|
|
|
2012-05-01 18:49:03 +00:00
|
|
|
gst_mpeg2dec_clear_buffers (mpeg2dec);
|
2012-04-13 23:06:52 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstFlowReturn
|
|
|
|
gst_mpeg2dec_finish (GstVideoDecoder * decoder)
|
|
|
|
{
|
|
|
|
GstMpeg2dec *mpeg2dec = GST_MPEG2DEC (decoder);
|
|
|
|
|
|
|
|
if (mpeg2dec->index && mpeg2dec->closed) {
|
|
|
|
gst_index_commit (mpeg2dec->index, mpeg2dec->index_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
return GST_FLOW_OK;
|
2005-02-05 07:36:01 +00:00
|
|
|
}
|
2005-10-26 16:45:04 +00:00
|
|
|
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
static void
|
2012-04-13 23:06:52 +00:00
|
|
|
gst_mpeg2dec_set_index (GstElement * element, GstIndex * index)
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
{
|
2012-04-13 23:06:52 +00:00
|
|
|
GstMpeg2dec *mpeg2dec = GST_MPEG2DEC (element);
|
|
|
|
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
GST_OBJECT_LOCK (mpeg2dec);
|
2012-04-13 23:06:52 +00:00
|
|
|
if (mpeg2dec->index)
|
|
|
|
gst_object_unref (mpeg2dec->index);
|
|
|
|
mpeg2dec->index = NULL;
|
|
|
|
mpeg2dec->index_id = 0;
|
|
|
|
if (index) {
|
|
|
|
mpeg2dec->index = gst_object_ref (index);
|
|
|
|
}
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
GST_OBJECT_UNLOCK (mpeg2dec);
|
2012-04-13 23:06:52 +00:00
|
|
|
/* object lock might be taken again */
|
|
|
|
if (index)
|
|
|
|
gst_index_get_writer_id (index, GST_OBJECT (element), &mpeg2dec->index_id);
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
}
|
|
|
|
|
2012-04-13 23:06:52 +00:00
|
|
|
static GstIndex *
|
|
|
|
gst_mpeg2dec_get_index (GstElement * element)
|
2005-01-17 13:54:30 +00:00
|
|
|
{
|
2012-04-13 23:06:52 +00:00
|
|
|
GstMpeg2dec *mpeg2dec = GST_MPEG2DEC (element);
|
2012-04-02 13:21:36 +00:00
|
|
|
|
2012-04-13 23:06:52 +00:00
|
|
|
return (mpeg2dec->index) ? gst_object_ref (mpeg2dec->index) : NULL;
|
|
|
|
}
|
2012-04-02 13:21:36 +00:00
|
|
|
|
2012-04-13 23:06:52 +00:00
|
|
|
static GstFlowReturn
|
|
|
|
gst_mpeg2dec_crop_buffer (GstMpeg2dec * dec, GstBuffer ** buf)
|
|
|
|
{
|
|
|
|
GstVideoInfo *info;
|
|
|
|
GstVideoFormat format;
|
|
|
|
GstBuffer *inbuf = *buf;
|
|
|
|
GstBuffer *outbuf;
|
|
|
|
guint c;
|
|
|
|
|
|
|
|
info = &gst_video_decoder_get_output_state (GST_VIDEO_DECODER (dec))->info;
|
|
|
|
format = GST_VIDEO_INFO_FORMAT (info);
|
|
|
|
|
|
|
|
GST_LOG_OBJECT (dec, "Copying input buffer %ux%u (%u) to output buffer "
|
|
|
|
"%ux%u (%u)", dec->decoded_width, dec->decoded_height,
|
|
|
|
GST_BUFFER_SIZE (inbuf), info->width, info->height, info->size);
|
|
|
|
|
|
|
|
outbuf = gst_video_decoder_alloc_output_buffer (GST_VIDEO_DECODER (dec));
|
|
|
|
|
|
|
|
for (c = 0; c < 3; c++) {
|
|
|
|
const guint8 *src;
|
|
|
|
guint8 *dest;
|
|
|
|
guint stride_in, stride_out;
|
|
|
|
guint c_height, c_width, line;
|
|
|
|
|
|
|
|
src =
|
|
|
|
GST_BUFFER_DATA (inbuf) +
|
|
|
|
gst_video_format_get_component_offset (format, c, dec->decoded_width,
|
|
|
|
dec->decoded_height);
|
|
|
|
dest =
|
|
|
|
GST_BUFFER_DATA (outbuf) +
|
|
|
|
gst_video_format_get_component_offset (format, c, info->width,
|
|
|
|
dec->height);
|
|
|
|
stride_out = gst_video_format_get_row_stride (format, c, info->width);
|
|
|
|
stride_in = gst_video_format_get_row_stride (format, c, dec->decoded_width);
|
|
|
|
c_height = gst_video_format_get_component_height (format, c, info->height);
|
|
|
|
c_width = gst_video_format_get_component_width (format, c, info->width);
|
|
|
|
|
|
|
|
GST_DEBUG ("stride_in:%d _out:%d c_width:%d c_height:%d",
|
|
|
|
stride_in, stride_out, c_width, c_height);
|
|
|
|
|
|
|
|
if (stride_in == stride_out && stride_in == c_width) {
|
|
|
|
/* FAST PATH */
|
|
|
|
memcpy (dest, src, c_height * stride_out);
|
|
|
|
dest += stride_out * c_height;
|
|
|
|
src += stride_out * c_height;
|
|
|
|
} else {
|
|
|
|
for (line = 0; line < c_height; line++) {
|
|
|
|
memcpy (dest, src, c_width);
|
|
|
|
dest += stride_out;
|
|
|
|
src += stride_in;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-04-02 13:21:36 +00:00
|
|
|
|
2012-04-13 23:06:52 +00:00
|
|
|
gst_buffer_unref (*buf);
|
|
|
|
*buf = outbuf;
|
2012-04-02 13:21:36 +00:00
|
|
|
|
2012-04-13 23:06:52 +00:00
|
|
|
return GST_FLOW_OK;
|
|
|
|
}
|
2012-04-02 13:21:36 +00:00
|
|
|
|
2012-04-13 23:06:52 +00:00
|
|
|
static void
|
|
|
|
gst_mpeg2dec_alloc_sized_buf (GstMpeg2dec * mpeg2dec, guint size,
|
|
|
|
GstBuffer ** obuf)
|
|
|
|
{
|
|
|
|
if (mpeg2dec->can_allocate_aligned
|
|
|
|
&& mpeg2dec->decoded_width == mpeg2dec->width
|
|
|
|
&& mpeg2dec->decoded_height == mpeg2dec->height) {
|
|
|
|
|
|
|
|
*obuf =
|
|
|
|
gst_video_decoder_alloc_output_buffer (GST_VIDEO_DECODER (mpeg2dec));
|
|
|
|
|
|
|
|
/* libmpeg2 needs 16 byte aligned buffers... test for this here
|
|
|
|
* and if it fails only a single time create our own buffers from
|
|
|
|
* there on below that are correctly aligned */
|
|
|
|
if (((uintptr_t) GST_BUFFER_DATA (*obuf)) % 16 == 0) {
|
|
|
|
GST_LOG_OBJECT (mpeg2dec, "return 16 byte aligned buffer");
|
|
|
|
return;
|
|
|
|
}
|
2012-04-02 13:21:36 +00:00
|
|
|
|
2012-04-13 23:06:52 +00:00
|
|
|
GST_DEBUG_OBJECT (mpeg2dec,
|
|
|
|
"can't get 16 byte aligned buffers, creating our own ones");
|
|
|
|
gst_buffer_unref (*obuf);
|
|
|
|
mpeg2dec->can_allocate_aligned = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* can't use gst_pad_alloc_buffer() here because the output buffer will
|
|
|
|
* either be cropped later or be bigger than expected (for the alignment),
|
|
|
|
* and basetransform-based elements will complain about the wrong unit size
|
|
|
|
* when not operating in passthrough mode */
|
|
|
|
*obuf = gst_buffer_new_and_alloc (size + 15);
|
|
|
|
GST_BUFFER_DATA (*obuf) = (guint8 *) ALIGN_16 (GST_BUFFER_DATA (*obuf));
|
|
|
|
GST_BUFFER_SIZE (*obuf) = size;
|
|
|
|
}
|
2012-04-02 13:21:36 +00:00
|
|
|
|
2012-05-01 18:49:03 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
GstBuffer *buffer;
|
|
|
|
gint id;
|
|
|
|
} GstMpeg2DecBuffer;
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_mpeg2dec_clear_buffers (GstMpeg2dec * mpeg2dec)
|
|
|
|
{
|
|
|
|
GList *l;
|
|
|
|
while ((l = g_list_first (mpeg2dec->buffers))) {
|
|
|
|
GstMpeg2DecBuffer *mbuf = l->data;
|
|
|
|
gst_buffer_unref (mbuf->buffer);
|
|
|
|
g_slice_free (GstMpeg2DecBuffer, mbuf);
|
|
|
|
mpeg2dec->buffers = g_list_delete_link (mpeg2dec->buffers, l);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_mpeg2dec_save_buffer (GstMpeg2dec * mpeg2dec, GstBuffer * buffer, gint id)
|
|
|
|
{
|
|
|
|
GstMpeg2DecBuffer *mbuf;
|
|
|
|
|
|
|
|
mbuf = g_slice_new0 (GstMpeg2DecBuffer);
|
|
|
|
mbuf->buffer = gst_buffer_ref (buffer);
|
|
|
|
mbuf->id = id;
|
|
|
|
|
|
|
|
mpeg2dec->buffers = g_list_prepend (mpeg2dec->buffers, mbuf);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
gst_mpeg2dec_buffer_compare (GstMpeg2DecBuffer * mbuf, gconstpointer id)
|
|
|
|
{
|
|
|
|
if (mbuf->id == GPOINTER_TO_INT (id))
|
|
|
|
return 0;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_mpeg2dec_discard_buffer (GstMpeg2dec * mpeg2dec, gint id)
|
|
|
|
{
|
|
|
|
GList *l = g_list_find_custom (mpeg2dec->buffers, GINT_TO_POINTER (id),
|
|
|
|
(GCompareFunc) gst_mpeg2dec_buffer_compare);
|
|
|
|
|
|
|
|
if (l) {
|
|
|
|
GstMpeg2DecBuffer *mbuf = l->data;
|
|
|
|
gst_buffer_unref (mbuf->buffer);
|
|
|
|
g_slice_free (GstMpeg2DecBuffer, mbuf);
|
|
|
|
mpeg2dec->buffers = g_list_delete_link (mpeg2dec->buffers, l);
|
|
|
|
} else {
|
|
|
|
GST_WARNING ("Could not find buffer %u, will be leaked until next reset");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-13 23:06:52 +00:00
|
|
|
static void
|
|
|
|
gst_mpeg2dec_alloc_buffer (GstMpeg2dec * mpeg2dec, gint64 offset,
|
|
|
|
GstVideoCodecFrame * frame)
|
|
|
|
{
|
|
|
|
guint8 *buf[3];
|
2012-04-02 13:21:36 +00:00
|
|
|
|
2012-04-13 23:06:52 +00:00
|
|
|
gst_mpeg2dec_alloc_sized_buf (mpeg2dec, mpeg2dec->size,
|
|
|
|
&frame->output_buffer);
|
2012-04-02 13:21:36 +00:00
|
|
|
|
2012-04-13 23:06:52 +00:00
|
|
|
buf[0] = GST_BUFFER_DATA (frame->output_buffer);
|
|
|
|
buf[1] = buf[0] + mpeg2dec->u_offs;
|
|
|
|
buf[2] = buf[0] + mpeg2dec->v_offs;
|
2012-04-02 13:21:36 +00:00
|
|
|
|
2012-04-13 23:06:52 +00:00
|
|
|
GST_DEBUG_OBJECT (mpeg2dec, "set_buf: %p %p %p, frame %i",
|
|
|
|
buf[0], buf[1], buf[2], frame->system_frame_number);
|
2005-01-17 13:54:30 +00:00
|
|
|
|
2012-04-13 23:06:52 +00:00
|
|
|
mpeg2_set_buf (mpeg2dec->decoder, buf,
|
|
|
|
GINT_TO_POINTER (frame->system_frame_number));
|
2012-05-01 18:49:03 +00:00
|
|
|
gst_mpeg2dec_save_buffer (mpeg2dec, frame->output_buffer,
|
|
|
|
frame->system_frame_number);
|
2010-12-29 21:42:36 +00:00
|
|
|
|
2012-04-13 23:06:52 +00:00
|
|
|
/* we store the original byteoffset of this picture in the stream here
|
|
|
|
* because we need it for indexing */
|
|
|
|
GST_BUFFER_OFFSET (frame->output_buffer) = offset;
|
2005-01-17 13:54:30 +00:00
|
|
|
}
|
|
|
|
|
2012-04-13 23:06:52 +00:00
|
|
|
static gboolean
|
|
|
|
gst_mpeg2dec_negotiate_format (GstMpeg2dec * mpeg2dec)
|
2002-12-05 00:29:11 +00:00
|
|
|
{
|
2012-04-13 23:06:52 +00:00
|
|
|
GstVideoCodecState *new_state;
|
|
|
|
GstVideoFormat format;
|
|
|
|
const mpeg2_info_t *info;
|
|
|
|
const mpeg2_sequence_t *sequence;
|
|
|
|
gboolean ret = FALSE;
|
2012-03-15 19:38:50 +00:00
|
|
|
|
2012-04-13 23:06:52 +00:00
|
|
|
info = mpeg2_info (mpeg2dec->decoder);
|
|
|
|
sequence = info->sequence;
|
|
|
|
|
|
|
|
if (sequence->width != sequence->chroma_width &&
|
|
|
|
sequence->height != sequence->chroma_height) {
|
|
|
|
format = GST_VIDEO_FORMAT_I420;
|
|
|
|
} else if ((sequence->width == sequence->chroma_width &&
|
|
|
|
sequence->height != sequence->chroma_height) ||
|
|
|
|
(sequence->width != sequence->chroma_width &&
|
|
|
|
sequence->height == sequence->chroma_height)) {
|
|
|
|
format = GST_VIDEO_FORMAT_Y42B;
|
2005-10-26 16:45:04 +00:00
|
|
|
} else {
|
2012-04-13 23:06:52 +00:00
|
|
|
format = GST_VIDEO_FORMAT_Y444;
|
2004-03-31 06:31:47 +00:00
|
|
|
}
|
|
|
|
|
2012-04-13 23:06:52 +00:00
|
|
|
new_state = gst_video_decoder_set_output_state (GST_VIDEO_DECODER (mpeg2dec),
|
|
|
|
format, mpeg2dec->width, mpeg2dec->height, mpeg2dec->input_state);
|
2011-11-04 09:45:47 +00:00
|
|
|
|
2012-04-13 23:06:52 +00:00
|
|
|
/* Ensure interlace caps are set, needed if not using mpegvideoparse */
|
|
|
|
if (mpeg2dec->interlaced)
|
|
|
|
new_state->info.interlace_mode = GST_VIDEO_INTERLACE_MODE_INTERLEAVED;
|
2006-06-19 15:16:43 +00:00
|
|
|
|
2012-04-13 23:06:52 +00:00
|
|
|
mpeg2dec->size = gst_video_format_get_size (format,
|
|
|
|
mpeg2dec->decoded_width, mpeg2dec->decoded_height);
|
|
|
|
mpeg2dec->u_offs = gst_video_format_get_component_offset (format, 1,
|
|
|
|
mpeg2dec->decoded_width, mpeg2dec->decoded_height);
|
|
|
|
mpeg2dec->v_offs = gst_video_format_get_component_offset (format, 2,
|
|
|
|
mpeg2dec->decoded_width, mpeg2dec->decoded_height);
|
2006-06-19 15:16:43 +00:00
|
|
|
|
2012-04-13 23:06:52 +00:00
|
|
|
if (mpeg2dec->pixel_width == 0 || mpeg2dec->pixel_height == 0) {
|
|
|
|
GValue par = { 0, };
|
|
|
|
GValue dar = { 0, };
|
|
|
|
GValue dimensions = { 0, };
|
2012-04-02 13:21:36 +00:00
|
|
|
|
2012-04-13 23:06:52 +00:00
|
|
|
/* assume display aspect ratio (DAR) of 4:3 */
|
|
|
|
g_value_init (&dar, GST_TYPE_FRACTION);
|
|
|
|
gst_value_set_fraction (&dar, 4, 3);
|
|
|
|
g_value_init (&dimensions, GST_TYPE_FRACTION);
|
|
|
|
gst_value_set_fraction (&dimensions, mpeg2dec->height, mpeg2dec->width);
|
2012-03-15 19:38:50 +00:00
|
|
|
|
2012-04-13 23:06:52 +00:00
|
|
|
g_value_init (&par, GST_TYPE_FRACTION);
|
|
|
|
if (!gst_value_fraction_multiply (&par, &dar, &dimensions)) {
|
|
|
|
gst_value_set_fraction (&dimensions, 1, 1);
|
|
|
|
}
|
2006-06-19 15:16:43 +00:00
|
|
|
|
2012-04-13 23:06:52 +00:00
|
|
|
mpeg2dec->pixel_width = gst_value_get_fraction_numerator (&par);
|
|
|
|
mpeg2dec->pixel_height = gst_value_get_fraction_denominator (&par);
|
2003-12-22 01:47:08 +00:00
|
|
|
|
2012-04-13 23:06:52 +00:00
|
|
|
GST_WARNING_OBJECT (mpeg2dec, "Unknown pixel-aspect-ratio, assuming %d:%d",
|
|
|
|
mpeg2dec->pixel_width, mpeg2dec->pixel_height);
|
2003-02-02 20:03:10 +00:00
|
|
|
|
2012-04-13 23:06:52 +00:00
|
|
|
g_value_unset (&par);
|
|
|
|
g_value_unset (&dar);
|
|
|
|
g_value_unset (&dimensions);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (new_state) {
|
|
|
|
gst_video_codec_state_unref (new_state);
|
|
|
|
ret = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
2001-12-23 06:03:21 +00:00
|
|
|
}
|
|
|
|
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
static void
|
|
|
|
init_dummybuf (GstMpeg2dec * mpeg2dec)
|
|
|
|
{
|
2006-11-03 09:52:12 +00:00
|
|
|
g_free (mpeg2dec->dummybuf[3]);
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
|
2006-11-21 12:15:58 +00:00
|
|
|
/* libmpeg2 needs 16 byte aligned buffers... care for this here */
|
2006-11-03 09:52:12 +00:00
|
|
|
mpeg2dec->dummybuf[3] = g_malloc0 (mpeg2dec->size + 15);
|
|
|
|
mpeg2dec->dummybuf[0] = ALIGN_16 (mpeg2dec->dummybuf[3]);
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
mpeg2dec->dummybuf[1] = mpeg2dec->dummybuf[0] + mpeg2dec->u_offs;
|
2006-09-15 16:14:15 +00:00
|
|
|
mpeg2dec->dummybuf[2] = mpeg2dec->dummybuf[0] + mpeg2dec->v_offs;
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
}
|
|
|
|
|
ext/mpeg2dec/gstmpeg2dec.c: Forward GstFlowReturn about everywhere.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_reset),
(gst_mpeg2dec_alloc_buffer), (gst_mpeg2dec_negotiate_format),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_src_query), (normal_seek),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
Forward GstFlowReturn about everywhere.
Handle seeking correctly.
2005-10-27 21:50:11 +00:00
|
|
|
static GstFlowReturn
|
2005-02-04 13:43:28 +00:00
|
|
|
handle_sequence (GstMpeg2dec * mpeg2dec, const mpeg2_info_t * info)
|
|
|
|
{
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
GstFlowReturn ret = GST_FLOW_OK;
|
2012-04-13 23:06:52 +00:00
|
|
|
GstClockTime latency;
|
2005-02-04 13:43:28 +00:00
|
|
|
|
2012-04-13 23:06:52 +00:00
|
|
|
if (info->sequence->frame_period == 0) {
|
|
|
|
GST_WARNING_OBJECT (mpeg2dec, "Frame period is 0!");
|
|
|
|
ret = GST_FLOW_ERROR;
|
|
|
|
goto done;
|
2008-02-04 14:27:32 +00:00
|
|
|
}
|
|
|
|
|
2012-04-13 23:06:52 +00:00
|
|
|
mpeg2dec->width = info->sequence->picture_width;
|
|
|
|
mpeg2dec->height = info->sequence->picture_height;
|
|
|
|
mpeg2dec->decoded_width = info->sequence->width;
|
|
|
|
mpeg2dec->decoded_height = info->sequence->height;
|
2011-09-30 15:38:07 +00:00
|
|
|
|
2012-04-13 23:06:52 +00:00
|
|
|
/* don't take the sequence PAR if we already have one from the sink caps */
|
|
|
|
if (!mpeg2dec->have_par) {
|
|
|
|
mpeg2dec->pixel_width = info->sequence->pixel_width;
|
|
|
|
mpeg2dec->pixel_height = info->sequence->pixel_height;
|
2008-10-14 12:51:41 +00:00
|
|
|
}
|
|
|
|
|
2012-04-13 23:06:52 +00:00
|
|
|
/* mpeg2 video can only be from 16x16 to 4096x4096. Everything
|
|
|
|
* else is a corrupted files */
|
|
|
|
if (mpeg2dec->width > 4096 || mpeg2dec->width < 16 ||
|
|
|
|
mpeg2dec->height > 4096 || mpeg2dec->height < 16) {
|
|
|
|
GST_ERROR_OBJECT (mpeg2dec, "Invalid frame dimensions: %d x %d",
|
|
|
|
mpeg2dec->width, mpeg2dec->height);
|
|
|
|
return GST_FLOW_ERROR;
|
2008-07-13 10:13:06 +00:00
|
|
|
}
|
|
|
|
|
2006-11-15 13:57:21 +00:00
|
|
|
/* set framerate */
|
2012-04-13 23:06:52 +00:00
|
|
|
mpeg2dec->fps_n = 27000000;
|
|
|
|
mpeg2dec->fps_d = info->sequence->frame_period;
|
|
|
|
mpeg2dec->frame_period = info->sequence->frame_period * GST_USECOND / 27;
|
|
|
|
|
|
|
|
/* Mpeg2dec has 1 frame latency to produce a picture and 1 frame latency in
|
|
|
|
* it's parser */
|
|
|
|
latency = 2 * mpeg2dec->frame_period;
|
|
|
|
gst_video_decoder_set_latency (GST_VIDEO_DECODER (mpeg2dec), latency,
|
|
|
|
latency);
|
|
|
|
|
|
|
|
mpeg2dec->interlaced =
|
|
|
|
!(info->sequence->flags & SEQ_FLAG_PROGRESSIVE_SEQUENCE);
|
2009-05-12 09:44:13 +00:00
|
|
|
|
2005-02-04 13:43:28 +00:00
|
|
|
GST_DEBUG_OBJECT (mpeg2dec,
|
2005-11-23 00:12:24 +00:00
|
|
|
"sequence flags: %d, frame period: %d (%g), frame rate: %d/%d",
|
2012-04-13 23:06:52 +00:00
|
|
|
info->sequence->flags, info->sequence->frame_period,
|
|
|
|
(double) (mpeg2dec->frame_period) / GST_SECOND, mpeg2dec->fps_n,
|
|
|
|
mpeg2dec->fps_d);
|
2005-02-04 13:43:28 +00:00
|
|
|
GST_DEBUG_OBJECT (mpeg2dec, "profile: %02x, colour_primaries: %d",
|
2012-04-13 23:06:52 +00:00
|
|
|
info->sequence->profile_level_id, info->sequence->colour_primaries);
|
2005-02-04 13:43:28 +00:00
|
|
|
GST_DEBUG_OBJECT (mpeg2dec, "transfer chars: %d, matrix coef: %d",
|
2012-04-13 23:06:52 +00:00
|
|
|
info->sequence->transfer_characteristics,
|
|
|
|
info->sequence->matrix_coefficients);
|
2009-05-12 09:44:13 +00:00
|
|
|
GST_DEBUG_OBJECT (mpeg2dec,
|
|
|
|
"FLAGS: CONSTRAINED_PARAMETERS:%d, PROGRESSIVE_SEQUENCE:%d",
|
2012-04-13 23:06:52 +00:00
|
|
|
info->sequence->flags & SEQ_FLAG_CONSTRAINED_PARAMETERS,
|
|
|
|
info->sequence->flags & SEQ_FLAG_PROGRESSIVE_SEQUENCE);
|
2009-05-12 09:44:13 +00:00
|
|
|
GST_DEBUG_OBJECT (mpeg2dec, "FLAGS: LOW_DELAY:%d, COLOUR_DESCRIPTION:%d",
|
2012-04-13 23:06:52 +00:00
|
|
|
info->sequence->flags & SEQ_FLAG_LOW_DELAY,
|
|
|
|
info->sequence->flags & SEQ_FLAG_COLOUR_DESCRIPTION);
|
2005-10-26 16:45:04 +00:00
|
|
|
|
2012-04-13 23:06:52 +00:00
|
|
|
if (!gst_mpeg2dec_negotiate_format (mpeg2dec))
|
|
|
|
goto negotiate_failed;
|
2012-04-02 13:21:36 +00:00
|
|
|
|
2011-09-30 15:38:07 +00:00
|
|
|
mpeg2_custom_fbuf (mpeg2dec->decoder, 1);
|
2012-04-13 23:06:52 +00:00
|
|
|
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
init_dummybuf (mpeg2dec);
|
2005-02-04 13:43:28 +00:00
|
|
|
|
2011-02-17 16:06:51 +00:00
|
|
|
/* Pump in some null buffers, because otherwise libmpeg2 doesn't
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
* initialise the discard_fbuf->id */
|
|
|
|
mpeg2_set_buf (mpeg2dec->decoder, mpeg2dec->dummybuf, NULL);
|
|
|
|
mpeg2_set_buf (mpeg2dec->decoder, mpeg2dec->dummybuf, NULL);
|
|
|
|
mpeg2_set_buf (mpeg2dec->decoder, mpeg2dec->dummybuf, NULL);
|
2012-05-01 18:49:03 +00:00
|
|
|
gst_mpeg2dec_clear_buffers (mpeg2dec);
|
2005-10-27 17:26:13 +00:00
|
|
|
|
ext/mpeg2dec/gstmpeg2dec.c: Forward GstFlowReturn about everywhere.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_reset),
(gst_mpeg2dec_alloc_buffer), (gst_mpeg2dec_negotiate_format),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_src_query), (normal_seek),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
Forward GstFlowReturn about everywhere.
Handle seeking correctly.
2005-10-27 21:50:11 +00:00
|
|
|
done:
|
|
|
|
return ret;
|
2005-10-26 16:45:04 +00:00
|
|
|
|
2012-04-13 23:06:52 +00:00
|
|
|
negotiate_failed:
|
2005-10-26 16:45:04 +00:00
|
|
|
{
|
2012-04-13 23:06:52 +00:00
|
|
|
GST_ELEMENT_ERROR (mpeg2dec, CORE, NEGOTIATION, (NULL), (NULL));
|
|
|
|
ret = GST_FLOW_NOT_NEGOTIATED;
|
ext/mpeg2dec/gstmpeg2dec.c: Forward GstFlowReturn about everywhere.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_reset),
(gst_mpeg2dec_alloc_buffer), (gst_mpeg2dec_negotiate_format),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_src_query), (normal_seek),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
Forward GstFlowReturn about everywhere.
Handle seeking correctly.
2005-10-27 21:50:11 +00:00
|
|
|
goto done;
|
2005-10-26 16:45:04 +00:00
|
|
|
}
|
2005-02-04 13:43:28 +00:00
|
|
|
}
|
|
|
|
|
ext/mpeg2dec/gstmpeg2dec.c: Forward GstFlowReturn about everywhere.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_reset),
(gst_mpeg2dec_alloc_buffer), (gst_mpeg2dec_negotiate_format),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_src_query), (normal_seek),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
Forward GstFlowReturn about everywhere.
Handle seeking correctly.
2005-10-27 21:50:11 +00:00
|
|
|
static GstFlowReturn
|
2012-04-13 23:06:52 +00:00
|
|
|
handle_picture (GstMpeg2dec * mpeg2dec, const mpeg2_info_t * info,
|
|
|
|
GstVideoCodecFrame * frame)
|
2005-02-04 13:43:28 +00:00
|
|
|
{
|
2012-04-13 23:06:52 +00:00
|
|
|
GstFlowReturn ret = GST_FLOW_OK;
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
gint type;
|
2012-04-13 23:06:52 +00:00
|
|
|
const gchar *type_str = NULL;
|
|
|
|
gboolean key_frame = FALSE;
|
|
|
|
const mpeg2_picture_t *picture = info->current_picture;
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
|
2012-04-13 23:06:52 +00:00
|
|
|
gst_mpeg2dec_alloc_buffer (mpeg2dec, mpeg2dec->offset, frame);
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
|
2012-04-13 23:06:52 +00:00
|
|
|
type = picture->flags & PIC_MASK_CODING_TYPE;
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
switch (type) {
|
|
|
|
case PIC_FLAG_CODING_TYPE_I:
|
2012-04-13 23:06:52 +00:00
|
|
|
key_frame = TRUE;
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
mpeg2_skip (mpeg2dec->decoder, 0);
|
2012-04-13 23:06:52 +00:00
|
|
|
type_str = "I";
|
|
|
|
break;
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
case PIC_FLAG_CODING_TYPE_P:
|
2012-04-13 23:06:52 +00:00
|
|
|
type_str = "P";
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
break;
|
|
|
|
case PIC_FLAG_CODING_TYPE_B:
|
2012-04-13 23:06:52 +00:00
|
|
|
type_str = "B";
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
break;
|
|
|
|
default:
|
2012-05-01 18:46:31 +00:00
|
|
|
gst_video_codec_frame_ref (frame);
|
2012-04-13 23:06:52 +00:00
|
|
|
gst_video_decoder_drop_frame (GST_VIDEO_DECODER (mpeg2dec), frame);
|
|
|
|
GST_VIDEO_DECODER_ERROR (mpeg2dec, 1, STREAM, DECODE,
|
|
|
|
("decoding error"), ("Invalid picture type"), ret);
|
|
|
|
return ret;
|
2005-02-04 13:43:28 +00:00
|
|
|
}
|
|
|
|
|
2012-04-13 23:06:52 +00:00
|
|
|
GST_DEBUG_OBJECT (mpeg2dec, "handle picture type %s", type_str);
|
|
|
|
GST_DEBUG_OBJECT (mpeg2dec, "picture %s, frame %i, offset %" G_GINT64_FORMAT,
|
|
|
|
key_frame ? ", kf," : " ", frame->system_frame_number,
|
|
|
|
GST_BUFFER_OFFSET (frame->output_buffer));
|
2012-04-01 18:19:36 +00:00
|
|
|
|
2012-04-13 23:06:52 +00:00
|
|
|
if (picture->flags & PIC_FLAG_TOP_FIELD_FIRST) {
|
|
|
|
GST_VIDEO_CODEC_FRAME_FLAG_SET (frame, GST_VIDEO_CODEC_FRAME_FLAG_TFF);
|
2012-04-01 18:19:36 +00:00
|
|
|
}
|
2012-04-13 23:06:52 +00:00
|
|
|
#if MPEG2_RELEASE >= MPEG2_VERSION(0,5,0)
|
|
|
|
/* repeat field introduced in 0.5.0 */
|
|
|
|
if (picture->flags & PIC_FLAG_REPEAT_FIRST_FIELD) {
|
|
|
|
GST_VIDEO_CODEC_FRAME_FLAG_SET (frame, GST_VIDEO_CODEC_FRAME_FLAG_RFF);
|
|
|
|
}
|
|
|
|
#endif
|
2012-04-01 18:19:36 +00:00
|
|
|
|
2012-04-13 23:06:52 +00:00
|
|
|
if (mpeg2dec->discont_state == MPEG2DEC_DISC_NEW_PICTURE && key_frame) {
|
2005-02-04 13:43:28 +00:00
|
|
|
mpeg2dec->discont_state = MPEG2DEC_DISC_NEW_KEYFRAME;
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
}
|
2005-02-04 13:43:28 +00:00
|
|
|
|
2012-04-13 23:06:52 +00:00
|
|
|
GST_DEBUG_OBJECT (mpeg2dec,
|
|
|
|
"picture: %s %s %s %s %s fields:%d off:%" G_GINT64_FORMAT " ts:%"
|
|
|
|
GST_TIME_FORMAT,
|
|
|
|
(picture->flags & PIC_FLAG_PROGRESSIVE_FRAME ? "prog" : " "),
|
|
|
|
(picture->flags & PIC_FLAG_TOP_FIELD_FIRST ? "tff" : " "),
|
|
|
|
#if MPEG2_RELEASE >= MPEG2_VERSION(0,5,0)
|
|
|
|
(picture->flags & PIC_FLAG_REPEAT_FIRST_FIELD ? "rff" : " "),
|
|
|
|
#else
|
|
|
|
"unknown rff",
|
|
|
|
#endif
|
|
|
|
(picture->flags & PIC_FLAG_SKIP ? "skip" : " "),
|
|
|
|
(picture->flags & PIC_FLAG_COMPOSITE_DISPLAY ? "composite" : " "),
|
|
|
|
picture->nb_fields, mpeg2dec->offset, GST_TIME_ARGS (frame->pts));
|
|
|
|
|
|
|
|
return GST_FLOW_OK;
|
2008-01-10 15:24:08 +00:00
|
|
|
}
|
|
|
|
|
ext/mpeg2dec/gstmpeg2dec.c: Forward GstFlowReturn about everywhere.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_reset),
(gst_mpeg2dec_alloc_buffer), (gst_mpeg2dec_negotiate_format),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_src_query), (normal_seek),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
Forward GstFlowReturn about everywhere.
Handle seeking correctly.
2005-10-27 21:50:11 +00:00
|
|
|
static GstFlowReturn
|
2005-02-04 13:43:28 +00:00
|
|
|
handle_slice (GstMpeg2dec * mpeg2dec, const mpeg2_info_t * info)
|
|
|
|
{
|
ext/mpeg2dec/gstmpeg2dec.c: Forward GstFlowReturn about everywhere.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_reset),
(gst_mpeg2dec_alloc_buffer), (gst_mpeg2dec_negotiate_format),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_src_query), (normal_seek),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
Forward GstFlowReturn about everywhere.
Handle seeking correctly.
2005-10-27 21:50:11 +00:00
|
|
|
GstFlowReturn ret = GST_FLOW_OK;
|
2012-04-13 23:06:52 +00:00
|
|
|
GstVideoCodecFrame *frame;
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
const mpeg2_picture_t *picture;
|
|
|
|
gboolean key_frame = FALSE;
|
2005-10-19 16:01:35 +00:00
|
|
|
|
2005-02-04 13:43:28 +00:00
|
|
|
GST_DEBUG_OBJECT (mpeg2dec, "picture slice/end %p %p %p %p",
|
2012-04-13 23:06:52 +00:00
|
|
|
info->display_fbuf, info->display_picture, info->current_picture,
|
|
|
|
info->display_fbuf->id);
|
2005-02-04 13:43:28 +00:00
|
|
|
|
2012-04-13 23:06:52 +00:00
|
|
|
frame = gst_video_decoder_get_frame (GST_VIDEO_DECODER (mpeg2dec),
|
|
|
|
GPOINTER_TO_INT (info->display_fbuf->id));
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
picture = info->display_picture;
|
|
|
|
key_frame = (picture->flags & PIC_MASK_CODING_TYPE) == PIC_FLAG_CODING_TYPE_I;
|
2005-10-27 17:26:13 +00:00
|
|
|
|
2012-04-13 23:06:52 +00:00
|
|
|
if (G_UNLIKELY (!frame)) {
|
|
|
|
GST_WARNING ("display buffer does not have a valid frame");
|
|
|
|
return GST_FLOW_ERROR;
|
|
|
|
}
|
|
|
|
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
GST_DEBUG_OBJECT (mpeg2dec, "picture flags: %d, type: %d, keyframe: %d",
|
|
|
|
picture->flags, picture->flags & PIC_MASK_CODING_TYPE, key_frame);
|
2005-02-04 13:43:28 +00:00
|
|
|
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
if (key_frame) {
|
|
|
|
mpeg2_skip (mpeg2dec->decoder, 0);
|
|
|
|
}
|
2005-10-27 17:26:13 +00:00
|
|
|
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
if (mpeg2dec->discont_state == MPEG2DEC_DISC_NEW_KEYFRAME && key_frame)
|
|
|
|
mpeg2dec->discont_state = MPEG2DEC_DISC_NONE;
|
2005-02-04 13:43:28 +00:00
|
|
|
|
2012-04-13 23:06:52 +00:00
|
|
|
if (mpeg2dec->index) {
|
|
|
|
gst_index_add_association (mpeg2dec->index, mpeg2dec->index_id,
|
|
|
|
(key_frame ? GST_ASSOCIATION_FLAG_KEY_UNIT :
|
|
|
|
GST_ASSOCIATION_FLAG_DELTA_UNIT),
|
|
|
|
GST_FORMAT_BYTES, GST_BUFFER_OFFSET (frame->output_buffer),
|
|
|
|
GST_FORMAT_TIME, frame->pts, 0);
|
2006-10-10 16:58:32 +00:00
|
|
|
}
|
2005-10-27 17:26:13 +00:00
|
|
|
|
2012-04-13 23:06:52 +00:00
|
|
|
if (picture->flags & PIC_FLAG_SKIP) {
|
|
|
|
GST_DEBUG_OBJECT (mpeg2dec, "dropping buffer because of skip flag");
|
|
|
|
gst_video_decoder_drop_frame (GST_VIDEO_DECODER (mpeg2dec), frame);
|
|
|
|
mpeg2_skip (mpeg2dec->decoder, 1);
|
|
|
|
return GST_FLOW_OK;
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
}
|
2005-02-04 13:43:28 +00:00
|
|
|
|
2012-04-13 23:06:52 +00:00
|
|
|
if (mpeg2dec->discont_state != MPEG2DEC_DISC_NONE) {
|
|
|
|
GST_DEBUG_OBJECT (mpeg2dec, "dropping buffer, discont state %d",
|
|
|
|
mpeg2dec->discont_state);
|
|
|
|
gst_video_decoder_drop_frame (GST_VIDEO_DECODER (mpeg2dec), frame);
|
|
|
|
return GST_FLOW_OK;
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
}
|
2009-05-12 09:44:13 +00:00
|
|
|
|
2012-04-13 23:06:52 +00:00
|
|
|
/* do cropping if the target region is smaller than the input one */
|
|
|
|
if (mpeg2dec->decoded_width != mpeg2dec->width ||
|
|
|
|
mpeg2dec->decoded_height != mpeg2dec->height) {
|
|
|
|
if (gst_video_decoder_get_max_decode_time (GST_VIDEO_DECODER (mpeg2dec),
|
|
|
|
frame) < 0) {
|
|
|
|
GST_DEBUG_OBJECT (mpeg2dec, "dropping buffer crop, too late");
|
|
|
|
gst_video_decoder_drop_frame (GST_VIDEO_DECODER (mpeg2dec), frame);
|
|
|
|
return GST_FLOW_OK;
|
2011-09-05 10:11:52 +00:00
|
|
|
}
|
|
|
|
|
2012-04-13 23:06:52 +00:00
|
|
|
ret = gst_mpeg2dec_crop_buffer (mpeg2dec, &frame->output_buffer);
|
2010-12-29 21:42:36 +00:00
|
|
|
}
|
2006-07-10 11:52:58 +00:00
|
|
|
|
2012-04-13 23:06:52 +00:00
|
|
|
GST_DEBUG_OBJECT (mpeg2dec, "cropping buffer");
|
|
|
|
gst_video_decoder_finish_frame (GST_VIDEO_DECODER (mpeg2dec), frame);
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
|
2012-04-13 23:06:52 +00:00
|
|
|
return ret;
|
2005-02-04 13:43:28 +00:00
|
|
|
}
|
|
|
|
|
2005-07-19 20:51:16 +00:00
|
|
|
static GstFlowReturn
|
2012-04-13 23:06:52 +00:00
|
|
|
gst_mpeg2dec_handle_frame (GstVideoDecoder * decoder,
|
|
|
|
GstVideoCodecFrame * frame)
|
2001-12-23 06:03:21 +00:00
|
|
|
{
|
2012-04-13 23:06:52 +00:00
|
|
|
GstMpeg2dec *mpeg2dec = GST_MPEG2DEC (decoder);
|
|
|
|
GstBuffer *buf = frame->input_buffer;
|
|
|
|
guint32 size;
|
|
|
|
guint8 *data, *end;
|
2002-12-05 00:29:11 +00:00
|
|
|
const mpeg2_info_t *info;
|
2003-10-06 12:16:21 +00:00
|
|
|
mpeg2_state_t state;
|
2002-12-05 00:29:11 +00:00
|
|
|
gboolean done = FALSE;
|
ext/mpeg2dec/gstmpeg2dec.c: Forward GstFlowReturn about everywhere.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_reset),
(gst_mpeg2dec_alloc_buffer), (gst_mpeg2dec_negotiate_format),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_src_query), (normal_seek),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
Forward GstFlowReturn about everywhere.
Handle seeking correctly.
2005-10-27 21:50:11 +00:00
|
|
|
GstFlowReturn ret = GST_FLOW_OK;
|
2001-12-23 06:03:21 +00:00
|
|
|
|
2004-07-07 16:49:49 +00:00
|
|
|
GST_LOG_OBJECT (mpeg2dec, "received buffer, timestamp %"
|
|
|
|
GST_TIME_FORMAT ", duration %" GST_TIME_FORMAT,
|
2012-04-13 23:06:52 +00:00
|
|
|
GST_TIME_ARGS (frame->pts), GST_TIME_ARGS (frame->duration));
|
|
|
|
|
|
|
|
size = GST_BUFFER_SIZE (buf);
|
|
|
|
data = GST_BUFFER_DATA (buf);
|
2001-12-23 06:03:21 +00:00
|
|
|
|
2005-10-26 16:45:04 +00:00
|
|
|
info = mpeg2dec->info;
|
2012-04-13 23:06:52 +00:00
|
|
|
end = data + size;
|
2002-12-05 00:29:11 +00:00
|
|
|
|
2005-02-04 13:43:28 +00:00
|
|
|
mpeg2dec->offset = GST_BUFFER_OFFSET (buf);
|
2005-10-26 16:45:04 +00:00
|
|
|
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
GST_LOG_OBJECT (mpeg2dec, "calling mpeg2_buffer");
|
2012-04-13 23:06:52 +00:00
|
|
|
mpeg2_buffer (mpeg2dec->decoder, data, end);
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
GST_LOG_OBJECT (mpeg2dec, "calling mpeg2_buffer done");
|
|
|
|
|
2002-12-05 00:29:11 +00:00
|
|
|
while (!done) {
|
ext/a52dec/gsta52dec.c: Add some debug output. Check that a discont has a valid time associated.
Original commit message from CVS:
* ext/a52dec/gsta52dec.c: (gst_a52dec_push),
(gst_a52dec_handle_event), (gst_a52dec_chain):
Add some debug output. Check that a discont has a valid
time associated.
* ext/alsa/gstalsasink.c: (gst_alsa_sink_check_event),
(gst_alsa_sink_loop):
Ignore TAG events. A little extra debug for broken timestamps.
* ext/dvdnav/dvdnavsrc.c: (dvdnavsrc_init), (dvdnavsrc_loop),
(dvdnavsrc_change_state):
Ensure we send a discont to engage the link before we send any
other events.
* ext/dvdread/dvdreadsrc.c: (dvdreadsrc_init),
(dvdreadsrc_finalize), (_close), (_open), (_seek_title),
(_seek_chapter), (seek_sector), (dvdreadsrc_get),
(dvdreadsrc_uri_get_uri), (dvdreadsrc_uri_set_uri):
Handle URI of the form dvd://title[,chapter[,angle]]. Currently only
dvd://title works in totem because typefinding sends a seek that ends
up going back to chapter 1 regardless.
* ext/mpeg2dec/gstmpeg2dec.c:
* ext/mpeg2dec/gstmpeg2dec.h:
Output correct timestamps and handle disconts.
* ext/ogg/gstoggdemux.c: (get_relative):
Small guard against a null dereference.
* ext/pango/gsttextoverlay.c: (gst_textoverlay_finalize),
(gst_textoverlay_set_property):
Free memory when done. Don't call gst_event_filler_get_duration on
EOS events. Use GST_LOG and GST_WARNING instead of g_message and
g_warning.
* ext/smoothwave/gstsmoothwave.c: (gst_smoothwave_init),
(draw_line), (gst_smoothwave_dispose), (gst_sw_sinklink),
(gst_sw_srclink), (gst_smoothwave_chain):
Draw solid lines, prettier colours.
* gst/mpeg2sub/gstmpeg2subt.c: (gst_mpeg2subt_init):
Add a default palette that'll work for some movies.
* gst/mpegstream/gstdvddemux.c: (gst_dvd_demux_init),
(gst_dvd_demux_handle_dvd_event), (gst_dvd_demux_send_discont),
(gst_dvd_demux_send_subbuffer), (gst_dvd_demux_reset):
* gst/mpegstream/gstdvddemux.h:
* gst/mpegstream/gstmpegdemux.c: (gst_mpeg_demux_send_discont),
(gst_mpeg_demux_parse_syshead), (gst_mpeg_demux_parse_pes):
* gst/mpegstream/gstmpegparse.c: (gst_mpeg_parse_init),
(gst_mpeg_parse_handle_discont), (gst_mpeg_parse_parse_packhead):
* gst/mpegstream/gstmpegparse.h:
Use PTM/NAV events when for timestamp adjustment when connected to
dvdnavsrc. Don't use many discont events where one suffices.
* gst/playback/gstplaybasebin.c: (group_destroy),
(gen_preroll_element), (gst_play_base_bin_add_element):
* gst/playback/gstplaybasebin.h:
Make sure we remove subtitles from the same bin we put them in.
* gst/subparse/gstsubparse.c: (convert_encoding), (parse_subrip),
(gst_subparse_buffer_format_autodetect),
(gst_subparse_change_state):
Fix some memleaks and invalid accesses.
* gst/typefind/gsttypefindfunctions.c: (ogganx_type_find),
(oggskel_type_find), (cmml_type_find), (plugin_init):
Some typefind functions for Annodex v3.0 files
* gst/wavparse/gstwavparse.h:
GstRiffReadClass is the correct parent class.
2005-01-25 15:34:08 +00:00
|
|
|
GST_LOG_OBJECT (mpeg2dec, "calling parse");
|
2002-12-05 00:29:11 +00:00
|
|
|
state = mpeg2_parse (mpeg2dec->decoder);
|
2004-07-07 16:49:49 +00:00
|
|
|
GST_DEBUG_OBJECT (mpeg2dec, "parse state %d", state);
|
2005-10-26 16:45:04 +00:00
|
|
|
|
2002-12-05 00:29:11 +00:00
|
|
|
switch (state) {
|
2008-11-24 09:51:39 +00:00
|
|
|
#if MPEG2_RELEASE >= MPEG2_VERSION (0, 5, 0)
|
|
|
|
case STATE_SEQUENCE_MODIFIED:
|
|
|
|
GST_DEBUG_OBJECT (mpeg2dec, "sequence modified");
|
|
|
|
/* fall through */
|
|
|
|
#endif
|
2002-12-05 00:29:11 +00:00
|
|
|
case STATE_SEQUENCE:
|
ext/mpeg2dec/gstmpeg2dec.c: Forward GstFlowReturn about everywhere.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_reset),
(gst_mpeg2dec_alloc_buffer), (gst_mpeg2dec_negotiate_format),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_src_query), (normal_seek),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
Forward GstFlowReturn about everywhere.
Handle seeking correctly.
2005-10-27 21:50:11 +00:00
|
|
|
ret = handle_sequence (mpeg2dec, info);
|
2008-02-04 14:27:32 +00:00
|
|
|
/* if there is an error handling the sequence
|
|
|
|
* reset the decoder, maybe something more elegant
|
|
|
|
* could be done.
|
|
|
|
*/
|
|
|
|
if (ret == GST_FLOW_ERROR) {
|
2012-04-13 23:06:52 +00:00
|
|
|
GST_VIDEO_DECODER_ERROR (decoder, 1, STREAM, DECODE,
|
|
|
|
("decoding error"), ("Bad sequence header"), ret);
|
2012-05-01 18:46:31 +00:00
|
|
|
gst_video_decoder_drop_frame (decoder, frame);
|
2012-04-13 23:06:52 +00:00
|
|
|
gst_mpeg2dec_reset (decoder, 0);
|
|
|
|
goto done;
|
2008-02-04 14:27:32 +00:00
|
|
|
}
|
2004-03-15 19:32:25 +00:00
|
|
|
break;
|
2002-12-05 00:29:11 +00:00
|
|
|
case STATE_SEQUENCE_REPEATED:
|
2004-07-07 16:49:49 +00:00
|
|
|
GST_DEBUG_OBJECT (mpeg2dec, "sequence repeated");
|
2005-10-26 16:45:04 +00:00
|
|
|
break;
|
2002-12-05 00:29:11 +00:00
|
|
|
case STATE_GOP:
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
GST_DEBUG_OBJECT (mpeg2dec, "gop");
|
2004-03-15 19:32:25 +00:00
|
|
|
break;
|
2002-12-05 00:29:11 +00:00
|
|
|
case STATE_PICTURE:
|
2012-04-13 23:06:52 +00:00
|
|
|
ret = handle_picture (mpeg2dec, info, frame);
|
2004-03-15 19:32:25 +00:00
|
|
|
break;
|
2002-12-05 00:29:11 +00:00
|
|
|
case STATE_SLICE_1ST:
|
ext/a52dec/gsta52dec.c: Add some debug output. Check that a discont has a valid time associated.
Original commit message from CVS:
* ext/a52dec/gsta52dec.c: (gst_a52dec_push),
(gst_a52dec_handle_event), (gst_a52dec_chain):
Add some debug output. Check that a discont has a valid
time associated.
* ext/alsa/gstalsasink.c: (gst_alsa_sink_check_event),
(gst_alsa_sink_loop):
Ignore TAG events. A little extra debug for broken timestamps.
* ext/dvdnav/dvdnavsrc.c: (dvdnavsrc_init), (dvdnavsrc_loop),
(dvdnavsrc_change_state):
Ensure we send a discont to engage the link before we send any
other events.
* ext/dvdread/dvdreadsrc.c: (dvdreadsrc_init),
(dvdreadsrc_finalize), (_close), (_open), (_seek_title),
(_seek_chapter), (seek_sector), (dvdreadsrc_get),
(dvdreadsrc_uri_get_uri), (dvdreadsrc_uri_set_uri):
Handle URI of the form dvd://title[,chapter[,angle]]. Currently only
dvd://title works in totem because typefinding sends a seek that ends
up going back to chapter 1 regardless.
* ext/mpeg2dec/gstmpeg2dec.c:
* ext/mpeg2dec/gstmpeg2dec.h:
Output correct timestamps and handle disconts.
* ext/ogg/gstoggdemux.c: (get_relative):
Small guard against a null dereference.
* ext/pango/gsttextoverlay.c: (gst_textoverlay_finalize),
(gst_textoverlay_set_property):
Free memory when done. Don't call gst_event_filler_get_duration on
EOS events. Use GST_LOG and GST_WARNING instead of g_message and
g_warning.
* ext/smoothwave/gstsmoothwave.c: (gst_smoothwave_init),
(draw_line), (gst_smoothwave_dispose), (gst_sw_sinklink),
(gst_sw_srclink), (gst_smoothwave_chain):
Draw solid lines, prettier colours.
* gst/mpeg2sub/gstmpeg2subt.c: (gst_mpeg2subt_init):
Add a default palette that'll work for some movies.
* gst/mpegstream/gstdvddemux.c: (gst_dvd_demux_init),
(gst_dvd_demux_handle_dvd_event), (gst_dvd_demux_send_discont),
(gst_dvd_demux_send_subbuffer), (gst_dvd_demux_reset):
* gst/mpegstream/gstdvddemux.h:
* gst/mpegstream/gstmpegdemux.c: (gst_mpeg_demux_send_discont),
(gst_mpeg_demux_parse_syshead), (gst_mpeg_demux_parse_pes):
* gst/mpegstream/gstmpegparse.c: (gst_mpeg_parse_init),
(gst_mpeg_parse_handle_discont), (gst_mpeg_parse_parse_packhead):
* gst/mpegstream/gstmpegparse.h:
Use PTM/NAV events when for timestamp adjustment when connected to
dvdnavsrc. Don't use many discont events where one suffices.
* gst/playback/gstplaybasebin.c: (group_destroy),
(gen_preroll_element), (gst_play_base_bin_add_element):
* gst/playback/gstplaybasebin.h:
Make sure we remove subtitles from the same bin we put them in.
* gst/subparse/gstsubparse.c: (convert_encoding), (parse_subrip),
(gst_subparse_buffer_format_autodetect),
(gst_subparse_change_state):
Fix some memleaks and invalid accesses.
* gst/typefind/gsttypefindfunctions.c: (ogganx_type_find),
(oggskel_type_find), (cmml_type_find), (plugin_init):
Some typefind functions for Annodex v3.0 files
* gst/wavparse/gstwavparse.h:
GstRiffReadClass is the correct parent class.
2005-01-25 15:34:08 +00:00
|
|
|
GST_LOG_OBJECT (mpeg2dec, "1st slice of frame encountered");
|
2004-03-15 19:32:25 +00:00
|
|
|
break;
|
2002-12-05 00:29:11 +00:00
|
|
|
case STATE_PICTURE_2ND:
|
ext/a52dec/gsta52dec.c: Add some debug output. Check that a discont has a valid time associated.
Original commit message from CVS:
* ext/a52dec/gsta52dec.c: (gst_a52dec_push),
(gst_a52dec_handle_event), (gst_a52dec_chain):
Add some debug output. Check that a discont has a valid
time associated.
* ext/alsa/gstalsasink.c: (gst_alsa_sink_check_event),
(gst_alsa_sink_loop):
Ignore TAG events. A little extra debug for broken timestamps.
* ext/dvdnav/dvdnavsrc.c: (dvdnavsrc_init), (dvdnavsrc_loop),
(dvdnavsrc_change_state):
Ensure we send a discont to engage the link before we send any
other events.
* ext/dvdread/dvdreadsrc.c: (dvdreadsrc_init),
(dvdreadsrc_finalize), (_close), (_open), (_seek_title),
(_seek_chapter), (seek_sector), (dvdreadsrc_get),
(dvdreadsrc_uri_get_uri), (dvdreadsrc_uri_set_uri):
Handle URI of the form dvd://title[,chapter[,angle]]. Currently only
dvd://title works in totem because typefinding sends a seek that ends
up going back to chapter 1 regardless.
* ext/mpeg2dec/gstmpeg2dec.c:
* ext/mpeg2dec/gstmpeg2dec.h:
Output correct timestamps and handle disconts.
* ext/ogg/gstoggdemux.c: (get_relative):
Small guard against a null dereference.
* ext/pango/gsttextoverlay.c: (gst_textoverlay_finalize),
(gst_textoverlay_set_property):
Free memory when done. Don't call gst_event_filler_get_duration on
EOS events. Use GST_LOG and GST_WARNING instead of g_message and
g_warning.
* ext/smoothwave/gstsmoothwave.c: (gst_smoothwave_init),
(draw_line), (gst_smoothwave_dispose), (gst_sw_sinklink),
(gst_sw_srclink), (gst_smoothwave_chain):
Draw solid lines, prettier colours.
* gst/mpeg2sub/gstmpeg2subt.c: (gst_mpeg2subt_init):
Add a default palette that'll work for some movies.
* gst/mpegstream/gstdvddemux.c: (gst_dvd_demux_init),
(gst_dvd_demux_handle_dvd_event), (gst_dvd_demux_send_discont),
(gst_dvd_demux_send_subbuffer), (gst_dvd_demux_reset):
* gst/mpegstream/gstdvddemux.h:
* gst/mpegstream/gstmpegdemux.c: (gst_mpeg_demux_send_discont),
(gst_mpeg_demux_parse_syshead), (gst_mpeg_demux_parse_pes):
* gst/mpegstream/gstmpegparse.c: (gst_mpeg_parse_init),
(gst_mpeg_parse_handle_discont), (gst_mpeg_parse_parse_packhead):
* gst/mpegstream/gstmpegparse.h:
Use PTM/NAV events when for timestamp adjustment when connected to
dvdnavsrc. Don't use many discont events where one suffices.
* gst/playback/gstplaybasebin.c: (group_destroy),
(gen_preroll_element), (gst_play_base_bin_add_element):
* gst/playback/gstplaybasebin.h:
Make sure we remove subtitles from the same bin we put them in.
* gst/subparse/gstsubparse.c: (convert_encoding), (parse_subrip),
(gst_subparse_buffer_format_autodetect),
(gst_subparse_change_state):
Fix some memleaks and invalid accesses.
* gst/typefind/gsttypefindfunctions.c: (ogganx_type_find),
(oggskel_type_find), (cmml_type_find), (plugin_init):
Some typefind functions for Annodex v3.0 files
* gst/wavparse/gstwavparse.h:
GstRiffReadClass is the correct parent class.
2005-01-25 15:34:08 +00:00
|
|
|
GST_LOG_OBJECT (mpeg2dec,
|
|
|
|
"Second picture header encountered. Decoding 2nd field");
|
2004-03-15 19:32:25 +00:00
|
|
|
break;
|
2004-01-14 06:41:52 +00:00
|
|
|
#if MPEG2_RELEASE >= MPEG2_VERSION (0, 4, 0)
|
|
|
|
case STATE_INVALID_END:
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
GST_DEBUG_OBJECT (mpeg2dec, "invalid end");
|
2004-01-14 06:41:52 +00:00
|
|
|
#endif
|
2002-12-05 00:29:11 +00:00
|
|
|
case STATE_END:
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
GST_DEBUG_OBJECT (mpeg2dec, "end");
|
2005-02-04 13:43:28 +00:00
|
|
|
case STATE_SLICE:
|
2012-04-13 23:06:52 +00:00
|
|
|
if (info->display_fbuf && info->display_fbuf->id) {
|
|
|
|
ret = handle_slice (mpeg2dec, info);
|
|
|
|
} else {
|
|
|
|
GST_DEBUG_OBJECT (mpeg2dec, "no picture to display");
|
|
|
|
}
|
2012-05-01 18:49:03 +00:00
|
|
|
if (info->discard_fbuf && info->discard_fbuf->id)
|
|
|
|
gst_mpeg2dec_discard_buffer (mpeg2dec,
|
|
|
|
GPOINTER_TO_INT (info->discard_fbuf->id));
|
2012-04-13 23:06:52 +00:00
|
|
|
if (state != STATE_SLICE) {
|
2012-05-01 18:49:03 +00:00
|
|
|
gst_mpeg2dec_clear_buffers (mpeg2dec);
|
2012-04-13 23:06:52 +00:00
|
|
|
}
|
2004-03-15 19:32:25 +00:00
|
|
|
break;
|
2003-10-06 12:16:21 +00:00
|
|
|
case STATE_BUFFER:
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
done = TRUE;
|
2004-03-15 19:32:25 +00:00
|
|
|
break;
|
|
|
|
/* error */
|
2002-12-05 00:29:11 +00:00
|
|
|
case STATE_INVALID:
|
2012-04-13 23:06:52 +00:00
|
|
|
GST_VIDEO_DECODER_ERROR (decoder, 1, STREAM, DECODE,
|
|
|
|
("decoding error"), ("Reached libmpeg2 invalid state"), ret);
|
2011-08-22 16:49:14 +00:00
|
|
|
continue;
|
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);
|
2012-04-13 23:06:52 +00:00
|
|
|
ret = GST_FLOW_OK;
|
2012-05-01 18:46:31 +00:00
|
|
|
gst_video_codec_frame_unref (frame);
|
2012-04-13 23:06:52 +00:00
|
|
|
goto done;
|
2002-12-05 00:29:11 +00:00
|
|
|
}
|
2002-12-19 07:45:11 +00:00
|
|
|
|
ext/mpeg2dec/gstmpeg2dec.c: Forward GstFlowReturn about everywhere.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_reset),
(gst_mpeg2dec_alloc_buffer), (gst_mpeg2dec_negotiate_format),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_src_query), (normal_seek),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
Forward GstFlowReturn about everywhere.
Handle seeking correctly.
2005-10-27 21:50:11 +00:00
|
|
|
if (ret != GST_FLOW_OK) {
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
GST_DEBUG_OBJECT (mpeg2dec, "exit loop, reason %s",
|
|
|
|
gst_flow_get_name (ret));
|
ext/mpeg2dec/gstmpeg2dec.c: Forward GstFlowReturn about everywhere.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_reset),
(gst_mpeg2dec_alloc_buffer), (gst_mpeg2dec_negotiate_format),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_src_query), (normal_seek),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
Forward GstFlowReturn about everywhere.
Handle seeking correctly.
2005-10-27 21:50:11 +00:00
|
|
|
break;
|
|
|
|
}
|
2002-12-05 00:29:11 +00:00
|
|
|
}
|
2005-07-19 20:51:16 +00:00
|
|
|
|
2012-05-01 18:46:31 +00:00
|
|
|
gst_video_codec_frame_unref (frame);
|
|
|
|
|
ext/mpeg2dec/gstmpeg2dec.*: Fix padtemplate as we can now do fractional framerates.
Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_base_init),
(gst_mpeg2dec_class_init), (gst_mpeg2dec_init),
(gst_mpeg2dec_finalize), (gst_mpeg2dec_reset),
(gst_mpeg2dec_qos_reset), (gst_mpeg2dec_alloc_buffer),
(gst_mpeg2dec_negotiate_format), (init_dummybuf),
(handle_sequence), (handle_picture), (handle_slice),
(gst_mpeg2dec_chain), (gst_mpeg2dec_sink_event),
(gst_mpeg2dec_src_event), (gst_mpeg2dec_change_state):
* ext/mpeg2dec/gstmpeg2dec.h:
Fix padtemplate as we can now do fractional framerates.
Small cleanups.
Use GstSegment.
Add simple frame dropping QoS.
Precalc buffer output sizes and UV offsets.
Always give libmpeg2 a valid fbuf when it wants one.
don't trust libmpeg to discard our buffers but manage it
ourselves.
Fixes #343627, #327350, #335288
2006-06-07 16:15:42 +00:00
|
|
|
done:
|
|
|
|
return ret;
|
2001-12-23 06:03:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2004-03-14 22:34:30 +00:00
|
|
|
plugin_init (GstPlugin * plugin)
|
2001-12-23 06:03:21 +00:00
|
|
|
{
|
2009-05-13 17:32:16 +00:00
|
|
|
if (!gst_element_register (plugin, "mpeg2dec", GST_RANK_PRIMARY,
|
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,
|
2012-04-13 23:06:52 +00:00
|
|
|
"mpeg2dec",
|
2006-04-01 09:54:39 +00:00
|
|
|
"LibMpeg2 decoder", plugin_init, VERSION, "GPL", GST_PACKAGE_NAME,
|
|
|
|
GST_PACKAGE_ORIGIN);
|