2004-01-30 20:23:24 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 2004 Benjamin Otte <in7y118@public.uni-hamburg.de>
|
2012-03-07 11:22:14 +00:00
|
|
|
* Copyright (c) 2012 Collabora Ltd.
|
|
|
|
* Author : Edward Hervey <edward@collabora.com>
|
|
|
|
* Author : Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>
|
2004-01-30 20:23:24 +00:00
|
|
|
*
|
|
|
|
* 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
|
2012-11-03 23:05:09 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2004-01-30 20:23:24 +00:00
|
|
|
*/
|
|
|
|
|
2006-03-01 16:24:37 +00:00
|
|
|
/**
|
|
|
|
* SECTION:element-theoradec
|
2017-01-23 19:36:11 +00:00
|
|
|
* @title: theoradec
|
2006-03-01 16:24:37 +00:00
|
|
|
* @see_also: theoraenc, oggdemux
|
|
|
|
*
|
|
|
|
* This element decodes theora streams into raw video
|
2019-08-23 16:28:16 +00:00
|
|
|
* [Theora](http://www.theora.org/) is a royalty-free
|
|
|
|
* video codec maintained by the [Xiph.org Foundation](http://www.xiph.org/),
|
|
|
|
* based on the VP3 codec.
|
2008-07-10 21:06:06 +00:00
|
|
|
*
|
2017-01-23 19:36:11 +00:00
|
|
|
* ## Example pipeline
|
2008-07-10 21:06:06 +00:00
|
|
|
* |[
|
2015-05-09 21:33:26 +00:00
|
|
|
* gst-launch-1.0 -v filesrc location=videotestsrc.ogg ! oggdemux ! theoradec ! videoconvert ! videoscale ! autovideosink
|
2017-01-23 19:36:11 +00:00
|
|
|
* ]|
|
|
|
|
* This example pipeline will decode an ogg stream and decodes the theora video in it.
|
2015-05-09 21:33:26 +00:00
|
|
|
* Refer to the theoraenc example to create the ogg file.
|
2017-01-23 19:36:11 +00:00
|
|
|
*
|
2006-03-01 16:24:37 +00:00
|
|
|
*/
|
|
|
|
|
2004-01-30 20:23:24 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2006-03-01 16:24:37 +00:00
|
|
|
#include "gsttheoradec.h"
|
2004-01-30 20:23:24 +00:00
|
|
|
#include <gst/tag/tag.h>
|
2009-09-10 09:39:18 +00:00
|
|
|
#include <gst/video/video.h>
|
2012-04-24 19:32:28 +00:00
|
|
|
#include <gst/video/gstvideometa.h>
|
|
|
|
#include <gst/video/gstvideopool.h>
|
2004-01-30 20:23:24 +00:00
|
|
|
|
2004-07-14 13:42:23 +00:00
|
|
|
#define GST_CAT_DEFAULT theoradec_debug
|
2016-02-20 11:31:43 +00:00
|
|
|
GST_DEBUG_CATEGORY_STATIC (theoradec_debug);
|
|
|
|
GST_DEBUG_CATEGORY_STATIC (CAT_PERFORMANCE);
|
2004-01-30 20:23:24 +00:00
|
|
|
|
2010-10-09 22:49:35 +00:00
|
|
|
#define THEORA_DEF_TELEMETRY_MV 0
|
|
|
|
#define THEORA_DEF_TELEMETRY_MBMODE 0
|
|
|
|
#define THEORA_DEF_TELEMETRY_QI 0
|
|
|
|
#define THEORA_DEF_TELEMETRY_BITS 0
|
|
|
|
|
2012-06-07 12:24:48 +00:00
|
|
|
/* This was removed from the base class, this is used as a
|
|
|
|
temporary return to signal the need to call _drop_frame,
|
|
|
|
and does not leave theoraenc. */
|
|
|
|
#define GST_CUSTOM_FLOW_DROP GST_FLOW_CUSTOM_SUCCESS_1
|
|
|
|
|
ext/theora/: Added cropping option to theora decoder.
Original commit message from CVS:
* ext/theora/theoradec.c: (gst_theora_dec_class_init),
(gst_theora_dec_init), (theora_get_formats),
(theora_dec_src_convert), (theora_dec_sink_convert),
(theora_dec_src_query), (theora_dec_src_event), (theora_dec_event),
(theora_dec_chain), (theora_dec_set_property),
(theora_dec_get_property):
* ext/theora/theoraenc.c: (gst_border_mode_get_type),
(gst_theora_enc_class_init), (gst_theora_enc_init),
(theora_enc_sink_link), (theora_enc_chain),
(theora_enc_set_property), (theora_enc_get_property):
Added cropping option to theora decoder.
Added border option to theora encoder.
2004-07-30 10:18:42 +00:00
|
|
|
enum
|
|
|
|
{
|
2010-07-04 18:08:25 +00:00
|
|
|
PROP_0,
|
2010-10-09 22:49:35 +00:00
|
|
|
PROP_TELEMETRY_MV,
|
|
|
|
PROP_TELEMETRY_MBMODE,
|
|
|
|
PROP_TELEMETRY_QI,
|
|
|
|
PROP_TELEMETRY_BITS
|
ext/theora/: Added cropping option to theora decoder.
Original commit message from CVS:
* ext/theora/theoradec.c: (gst_theora_dec_class_init),
(gst_theora_dec_init), (theora_get_formats),
(theora_dec_src_convert), (theora_dec_sink_convert),
(theora_dec_src_query), (theora_dec_src_event), (theora_dec_event),
(theora_dec_chain), (theora_dec_set_property),
(theora_dec_get_property):
* ext/theora/theoraenc.c: (gst_border_mode_get_type),
(gst_theora_enc_class_init), (gst_theora_enc_init),
(theora_enc_sink_link), (theora_enc_chain),
(theora_enc_set_property), (theora_enc_get_property):
Added cropping option to theora decoder.
Added border option to theora encoder.
2004-07-30 10:18:42 +00:00
|
|
|
};
|
|
|
|
|
2004-01-30 20:23:24 +00:00
|
|
|
static GstStaticPadTemplate theora_dec_src_factory =
|
2004-03-14 22:34:34 +00:00
|
|
|
GST_STATIC_PAD_TEMPLATE ("src",
|
|
|
|
GST_PAD_SRC,
|
|
|
|
GST_PAD_ALWAYS,
|
2012-04-24 19:32:28 +00:00
|
|
|
GST_STATIC_CAPS ("video/x-raw, "
|
|
|
|
"format = (string) { I420, Y42B, Y444 }, "
|
Convert elements to use fractions for their framerate.
Original commit message from CVS:
* ext/libvisual/visual.c: (gst_visual_src_setcaps), (get_buffer),
(gst_visual_chain):
* ext/ogg/gstogmparse.c: (gst_ogm_parse_chain):
* ext/theora/theoradec.c: (theora_handle_type_packet):
* ext/theora/theoraenc.c: (theora_enc_sink_setcaps),
(theora_enc_chain):
* gst-libs/gst/riff/riff-media.c: (gst_riff_create_video_caps):
* gst-libs/gst/video/video.c: (gst_video_frame_rate):
* gst-libs/gst/video/video.h:
* gst/ffmpegcolorspace/avcodec.h:
* gst/ffmpegcolorspace/gstffmpegcodecmap.c:
(gst_ffmpeg_caps_to_pixfmt):
* gst/ffmpegcolorspace/gstffmpegcolorspace.c:
(gst_ffmpegcsp_set_caps):
* gst/videorate/gstvideorate.c: (gst_videorate_transformcaps),
(gst_videorate_setcaps), (gst_videorate_blank_data),
(gst_videorate_chain):
* gst/videotestsrc/gstvideotestsrc.c:
(gst_videotestsrc_src_fixate), (gst_videotestsrc_getcaps),
(gst_videotestsrc_parse_caps), (gst_videotestsrc_setcaps),
(gst_videotestsrc_event), (gst_videotestsrc_create):
* gst/videotestsrc/gstvideotestsrc.h:
* sys/ximage/ximagesink.c: (gst_ximagesink_xcontext_get),
(gst_ximagesink_setcaps), (gst_ximagesink_change_state),
(gst_ximagesink_get_times), (gst_ximagesink_init):
* sys/ximage/ximagesink.h:
* sys/xvimage/xvimagesink.c: (gst_xvimagesink_get_xv_support),
(gst_xvimagesink_setcaps), (gst_xvimagesink_change_state),
(gst_xvimagesink_get_times), (gst_xvimagesink_init):
* sys/xvimage/xvimagesink.h:
Convert elements to use fractions for their framerate.
V4L elements to come later tonight.
2005-11-22 16:08:37 +00:00
|
|
|
"framerate = (fraction) [0/1, MAX], "
|
2004-03-15 19:32:28 +00:00
|
|
|
"width = (int) [ 1, MAX ], " "height = (int) [ 1, MAX ]")
|
2004-03-14 22:34:34 +00:00
|
|
|
);
|
2004-01-30 20:23:24 +00:00
|
|
|
|
|
|
|
static GstStaticPadTemplate theora_dec_sink_factory =
|
2004-03-14 22:34:34 +00:00
|
|
|
GST_STATIC_PAD_TEMPLATE ("sink",
|
|
|
|
GST_PAD_SINK,
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS ("video/x-theora")
|
|
|
|
);
|
2004-01-30 20:23:24 +00:00
|
|
|
|
2012-04-24 19:32:28 +00:00
|
|
|
#define gst_theora_dec_parent_class parent_class
|
|
|
|
G_DEFINE_TYPE (GstTheoraDec, gst_theora_dec, GST_TYPE_VIDEO_DECODER);
|
2020-12-11 17:46:20 +00:00
|
|
|
GST_ELEMENT_REGISTER_DEFINE (theoradec, "theoradec",
|
|
|
|
GST_RANK_PRIMARY, GST_TYPE_THEORA_DEC);
|
2004-03-14 22:34:34 +00:00
|
|
|
|
ext/theora/: Added cropping option to theora decoder.
Original commit message from CVS:
* ext/theora/theoradec.c: (gst_theora_dec_class_init),
(gst_theora_dec_init), (theora_get_formats),
(theora_dec_src_convert), (theora_dec_sink_convert),
(theora_dec_src_query), (theora_dec_src_event), (theora_dec_event),
(theora_dec_chain), (theora_dec_set_property),
(theora_dec_get_property):
* ext/theora/theoraenc.c: (gst_border_mode_get_type),
(gst_theora_enc_class_init), (gst_theora_enc_init),
(theora_enc_sink_link), (theora_enc_chain),
(theora_enc_set_property), (theora_enc_get_property):
Added cropping option to theora decoder.
Added border option to theora encoder.
2004-07-30 10:18:42 +00:00
|
|
|
static void theora_dec_get_property (GObject * object, guint prop_id,
|
|
|
|
GValue * value, GParamSpec * pspec);
|
|
|
|
static void theora_dec_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * pspec);
|
|
|
|
|
2012-03-07 11:22:14 +00:00
|
|
|
static gboolean theora_dec_start (GstVideoDecoder * decoder);
|
2013-08-15 11:15:05 +00:00
|
|
|
static gboolean theora_dec_stop (GstVideoDecoder * decoder);
|
2012-03-07 11:22:14 +00:00
|
|
|
static gboolean theora_dec_set_format (GstVideoDecoder * decoder,
|
|
|
|
GstVideoCodecState * state);
|
2013-08-15 11:15:05 +00:00
|
|
|
static gboolean theora_dec_flush (GstVideoDecoder * decoder);
|
2012-03-07 11:22:14 +00:00
|
|
|
static GstFlowReturn theora_dec_parse (GstVideoDecoder * decoder,
|
|
|
|
GstVideoCodecFrame * frame, GstAdapter * adapter, gboolean at_eos);
|
|
|
|
static GstFlowReturn theora_dec_handle_frame (GstVideoDecoder * decoder,
|
|
|
|
GstVideoCodecFrame * frame);
|
|
|
|
|
|
|
|
static GstFlowReturn theora_dec_decode_buffer (GstTheoraDec * dec,
|
|
|
|
GstBuffer * buf, GstVideoCodecFrame * frame);
|
2004-01-30 20:23:24 +00:00
|
|
|
|
2010-10-09 23:52:13 +00:00
|
|
|
static gboolean
|
|
|
|
gst_theora_dec_ctl_is_supported (int req)
|
|
|
|
{
|
|
|
|
/* should return TH_EFAULT or TH_EINVAL if supported, and TH_EIMPL if not */
|
|
|
|
return (th_decode_ctl (NULL, req, NULL, 0) != TH_EIMPL);
|
|
|
|
}
|
|
|
|
|
2004-01-30 20:23:24 +00:00
|
|
|
static void
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_theora_dec_class_init (GstTheoraDecClass * klass)
|
2004-01-30 20:23:24 +00:00
|
|
|
{
|
ext/theora/: Added cropping option to theora decoder.
Original commit message from CVS:
* ext/theora/theoradec.c: (gst_theora_dec_class_init),
(gst_theora_dec_init), (theora_get_formats),
(theora_dec_src_convert), (theora_dec_sink_convert),
(theora_dec_src_query), (theora_dec_src_event), (theora_dec_event),
(theora_dec_chain), (theora_dec_set_property),
(theora_dec_get_property):
* ext/theora/theoraenc.c: (gst_border_mode_get_type),
(gst_theora_enc_class_init), (gst_theora_enc_init),
(theora_enc_sink_link), (theora_enc_chain),
(theora_enc_set_property), (theora_enc_get_property):
Added cropping option to theora decoder.
Added border option to theora encoder.
2004-07-30 10:18:42 +00:00
|
|
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
2012-04-24 19:32:28 +00:00
|
|
|
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
2012-03-07 11:22:14 +00:00
|
|
|
GstVideoDecoderClass *video_decoder_class = GST_VIDEO_DECODER_CLASS (klass);
|
2004-01-30 20:23:24 +00:00
|
|
|
|
ext/theora/: Added cropping option to theora decoder.
Original commit message from CVS:
* ext/theora/theoradec.c: (gst_theora_dec_class_init),
(gst_theora_dec_init), (theora_get_formats),
(theora_dec_src_convert), (theora_dec_sink_convert),
(theora_dec_src_query), (theora_dec_src_event), (theora_dec_event),
(theora_dec_chain), (theora_dec_set_property),
(theora_dec_get_property):
* ext/theora/theoraenc.c: (gst_border_mode_get_type),
(gst_theora_enc_class_init), (gst_theora_enc_init),
(theora_enc_sink_link), (theora_enc_chain),
(theora_enc_set_property), (theora_enc_get_property):
Added cropping option to theora decoder.
Added border option to theora encoder.
2004-07-30 10:18:42 +00:00
|
|
|
gobject_class->set_property = theora_dec_set_property;
|
|
|
|
gobject_class->get_property = theora_dec_get_property;
|
|
|
|
|
2010-10-09 23:52:13 +00:00
|
|
|
if (gst_theora_dec_ctl_is_supported (TH_DECCTL_SET_TELEMETRY_MV)) {
|
|
|
|
g_object_class_install_property (gobject_class, PROP_TELEMETRY_MV,
|
|
|
|
g_param_spec_int ("visualize-motion-vectors",
|
|
|
|
"Visualize motion vectors",
|
|
|
|
"Show motion vector selection overlaid on image. "
|
|
|
|
"Value gives a mask for motion vector (MV) modes to show",
|
|
|
|
0, 0xffff, THEORA_DEF_TELEMETRY_MV,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gst_theora_dec_ctl_is_supported (TH_DECCTL_SET_TELEMETRY_MBMODE)) {
|
|
|
|
g_object_class_install_property (gobject_class, PROP_TELEMETRY_MBMODE,
|
|
|
|
g_param_spec_int ("visualize-macroblock-modes",
|
|
|
|
"Visualize macroblock modes",
|
|
|
|
"Show macroblock mode selection overlaid on image. "
|
|
|
|
"Value gives a mask for macroblock (MB) modes to show",
|
|
|
|
0, 0xffff, THEORA_DEF_TELEMETRY_MBMODE,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gst_theora_dec_ctl_is_supported (TH_DECCTL_SET_TELEMETRY_QI)) {
|
|
|
|
g_object_class_install_property (gobject_class, PROP_TELEMETRY_QI,
|
|
|
|
g_param_spec_int ("visualize-quantization-modes",
|
|
|
|
"Visualize adaptive quantization modes",
|
|
|
|
"Show adaptive quantization mode selection overlaid on image. "
|
|
|
|
"Value gives a mask for quantization (QI) modes to show",
|
|
|
|
0, 0xffff, THEORA_DEF_TELEMETRY_QI,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gst_theora_dec_ctl_is_supported (TH_DECCTL_SET_TELEMETRY_BITS)) {
|
|
|
|
/* FIXME: make this a boolean instead? The value scales the bars so
|
|
|
|
* they're less wide. Default is to use full width, and anything else
|
|
|
|
* doesn't seem particularly useful, since the smaller bars just disappear
|
|
|
|
* then (they almost disappear for a value of 2 already). */
|
|
|
|
g_object_class_install_property (gobject_class, PROP_TELEMETRY_BITS,
|
|
|
|
g_param_spec_int ("visualize-bit-usage",
|
|
|
|
"Visualize bitstream usage breakdown",
|
|
|
|
"Sets the bitstream breakdown visualization mode. "
|
|
|
|
"Values influence the width of the bit usage bars to show",
|
|
|
|
0, 0xff, THEORA_DEF_TELEMETRY_BITS,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
|
|
|
}
|
2010-10-09 22:49:35 +00:00
|
|
|
|
2016-03-03 07:46:24 +00:00
|
|
|
gst_element_class_add_static_pad_template (element_class,
|
|
|
|
&theora_dec_src_factory);
|
|
|
|
gst_element_class_add_static_pad_template (element_class,
|
|
|
|
&theora_dec_sink_factory);
|
|
|
|
gst_element_class_set_static_metadata (element_class, "Theora video decoder",
|
|
|
|
"Codec/Decoder/Video", "decode raw theora streams to raw YUV video",
|
2012-04-24 19:32:28 +00:00
|
|
|
"Benjamin Otte <otte@gnome.org>, Wim Taymans <wim@fluendo.com>");
|
|
|
|
|
2012-03-07 11:22:14 +00:00
|
|
|
video_decoder_class->start = GST_DEBUG_FUNCPTR (theora_dec_start);
|
2013-08-15 11:15:05 +00:00
|
|
|
video_decoder_class->stop = GST_DEBUG_FUNCPTR (theora_dec_stop);
|
|
|
|
video_decoder_class->flush = GST_DEBUG_FUNCPTR (theora_dec_flush);
|
2012-03-07 11:22:14 +00:00
|
|
|
video_decoder_class->set_format = GST_DEBUG_FUNCPTR (theora_dec_set_format);
|
|
|
|
video_decoder_class->parse = GST_DEBUG_FUNCPTR (theora_dec_parse);
|
|
|
|
video_decoder_class->handle_frame =
|
|
|
|
GST_DEBUG_FUNCPTR (theora_dec_handle_frame);
|
2004-07-14 13:42:23 +00:00
|
|
|
|
|
|
|
GST_DEBUG_CATEGORY_INIT (theoradec_debug, "theoradec", 0, "Theora decoder");
|
2016-03-09 09:56:52 +00:00
|
|
|
GST_DEBUG_CATEGORY_GET (CAT_PERFORMANCE, "GST_PERFORMANCE");
|
2004-01-30 20:23:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-04-24 19:32:28 +00:00
|
|
|
gst_theora_dec_init (GstTheoraDec * dec)
|
2004-01-30 20:23:24 +00:00
|
|
|
{
|
2010-10-09 22:49:35 +00:00
|
|
|
dec->telemetry_mv = THEORA_DEF_TELEMETRY_MV;
|
|
|
|
dec->telemetry_mbmode = THEORA_DEF_TELEMETRY_MBMODE;
|
|
|
|
dec->telemetry_qi = THEORA_DEF_TELEMETRY_QI;
|
|
|
|
dec->telemetry_bits = THEORA_DEF_TELEMETRY_BITS;
|
2012-03-07 11:22:14 +00:00
|
|
|
|
|
|
|
/* input is packetized,
|
|
|
|
* but is not marked that way so data gets parsed and keyframes marked */
|
2012-06-06 10:55:15 +00:00
|
|
|
gst_video_decoder_set_packetized (GST_VIDEO_DECODER (dec), FALSE);
|
2013-12-05 10:39:07 +00:00
|
|
|
gst_video_decoder_set_needs_format (GST_VIDEO_DECODER (dec), TRUE);
|
2015-08-15 10:40:55 +00:00
|
|
|
|
|
|
|
gst_video_decoder_set_use_default_pad_acceptcaps (GST_VIDEO_DECODER_CAST
|
|
|
|
(dec), TRUE);
|
|
|
|
GST_PAD_SET_ACCEPT_TEMPLATE (GST_VIDEO_DECODER_SINK_PAD (dec));
|
2004-01-30 20:23:24 +00:00
|
|
|
}
|
2004-02-03 16:15:16 +00:00
|
|
|
|
|
|
|
static gboolean
|
2012-03-07 11:22:14 +00:00
|
|
|
theora_dec_start (GstVideoDecoder * decoder)
|
2004-02-03 16:15:16 +00:00
|
|
|
{
|
2012-03-07 11:22:14 +00:00
|
|
|
GstTheoraDec *dec = GST_THEORA_DEC (decoder);
|
2005-05-09 10:56:13 +00:00
|
|
|
|
2012-03-07 11:22:14 +00:00
|
|
|
GST_DEBUG_OBJECT (dec, "start");
|
|
|
|
GST_DEBUG_OBJECT (dec, "Setting have_header to FALSE");
|
|
|
|
dec->have_header = FALSE;
|
ext/libvisual/visual.c: Small cleanups.
Original commit message from CVS:
* ext/libvisual/visual.c: (gst_visual_get_type),
(gst_visual_src_setcaps), (gst_vis_src_negotiate),
(gst_visual_chain):
Small cleanups.
* ext/theora/gsttheoradec.h:
* ext/theora/theoradec.c: (gst_theora_dec_init),
(gst_theora_dec_reset), (_theora_granule_time),
(theora_dec_src_convert), (theora_dec_sink_convert),
(theora_dec_src_query), (theora_dec_src_event),
(theora_dec_sink_event), (theora_handle_comment_packet),
(theora_handle_header_packet), (theora_dec_push),
(theora_handle_data_packet), (theora_dec_chain),
(theora_dec_change_state):
Add simple QoS.
2006-03-09 17:58:00 +00:00
|
|
|
|
2012-03-07 11:22:14 +00:00
|
|
|
return TRUE;
|
2004-02-03 16:15:16 +00:00
|
|
|
}
|
|
|
|
|
2004-01-30 20:23:24 +00:00
|
|
|
static gboolean
|
2013-08-15 11:15:05 +00:00
|
|
|
theora_dec_stop (GstVideoDecoder * decoder)
|
2004-01-30 20:23:24 +00:00
|
|
|
{
|
2012-03-07 11:22:14 +00:00
|
|
|
GstTheoraDec *dec = GST_THEORA_DEC (decoder);
|
|
|
|
|
2013-08-15 11:15:05 +00:00
|
|
|
GST_DEBUG_OBJECT (dec, "stop");
|
|
|
|
|
|
|
|
th_info_clear (&dec->info);
|
|
|
|
th_comment_clear (&dec->comment);
|
|
|
|
if (dec->setup) {
|
|
|
|
th_setup_free (dec->setup);
|
|
|
|
dec->setup = NULL;
|
|
|
|
}
|
|
|
|
if (dec->decoder) {
|
|
|
|
th_decode_free (dec->decoder);
|
|
|
|
dec->decoder = NULL;
|
|
|
|
}
|
ext/libvisual/visual.c: Small cleanups.
Original commit message from CVS:
* ext/libvisual/visual.c: (gst_visual_get_type),
(gst_visual_src_setcaps), (gst_vis_src_negotiate),
(gst_visual_chain):
Small cleanups.
* ext/theora/gsttheoradec.h:
* ext/theora/theoradec.c: (gst_theora_dec_init),
(gst_theora_dec_reset), (_theora_granule_time),
(theora_dec_src_convert), (theora_dec_sink_convert),
(theora_dec_src_query), (theora_dec_src_event),
(theora_dec_sink_event), (theora_handle_comment_packet),
(theora_handle_header_packet), (theora_dec_push),
(theora_handle_data_packet), (theora_dec_chain),
(theora_dec_change_state):
Add simple QoS.
2006-03-09 17:58:00 +00:00
|
|
|
|
2013-08-15 11:15:05 +00:00
|
|
|
if (dec->input_state) {
|
|
|
|
gst_video_codec_state_unref (dec->input_state);
|
|
|
|
dec->input_state = NULL;
|
2013-07-25 11:29:22 +00:00
|
|
|
}
|
2013-08-15 11:15:05 +00:00
|
|
|
if (dec->output_state) {
|
|
|
|
gst_video_codec_state_unref (dec->output_state);
|
|
|
|
dec->output_state = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
theora_dec_flush (GstVideoDecoder * decoder)
|
|
|
|
{
|
|
|
|
GstTheoraDec *dec = GST_THEORA_DEC (decoder);
|
|
|
|
|
|
|
|
dec->need_keyframe = TRUE;
|
2004-02-03 16:15:16 +00:00
|
|
|
|
2012-03-07 11:22:14 +00:00
|
|
|
return TRUE;
|
2005-05-09 10:56:13 +00:00
|
|
|
}
|
|
|
|
|
2012-03-07 11:22:14 +00:00
|
|
|
static GstFlowReturn
|
|
|
|
theora_dec_parse (GstVideoDecoder * decoder,
|
|
|
|
GstVideoCodecFrame * frame, GstAdapter * adapter, gboolean at_eos)
|
2004-01-30 20:23:24 +00:00
|
|
|
{
|
2012-03-07 11:22:14 +00:00
|
|
|
gint av;
|
|
|
|
const guint8 *data;
|
2004-01-30 20:23:24 +00:00
|
|
|
|
2012-03-07 11:22:14 +00:00
|
|
|
av = gst_adapter_available (adapter);
|
2004-01-30 20:23:24 +00:00
|
|
|
|
2013-03-31 16:28:09 +00:00
|
|
|
if (av > 0) {
|
|
|
|
data = gst_adapter_map (adapter, 1);
|
2017-03-03 13:12:26 +00:00
|
|
|
/* check for keyframe; must not be header packet (0x80 | 0x40) */
|
|
|
|
if (!(data[0] & 0xc0)) {
|
2013-03-31 16:28:09 +00:00
|
|
|
GST_VIDEO_CODEC_FRAME_SET_SYNC_POINT (frame);
|
2017-03-03 13:12:26 +00:00
|
|
|
GST_LOG_OBJECT (decoder, "Found keyframe");
|
|
|
|
}
|
2013-03-31 16:28:09 +00:00
|
|
|
gst_adapter_unmap (adapter);
|
|
|
|
}
|
ext/: Remove STREAM locks as they are taken in core now.
Original commit message from CVS:
* ext/ogg/gstoggdemux.c: (gst_ogg_pad_dispose),
(gst_ogg_pad_typefind), (gst_ogg_pad_submit_packet),
(gst_ogg_chain_new_stream), (gst_ogg_demux_perform_seek),
(gst_ogg_demux_chain), (gst_ogg_demux_loop),
(gst_ogg_demux_sink_activate):
* ext/theora/theoradec.c: (theora_dec_src_event),
(theora_handle_comment_packet), (theora_dec_chain),
(theora_dec_change_state):
* ext/vorbis/vorbisdec.c: (vorbis_dec_sink_event),
(vorbis_handle_data_packet), (vorbis_dec_chain),
(vorbis_dec_change_state):
Remove STREAM locks as they are taken in core now.
Never set bogus granulepos on vorbis/theora.
Fix leaks in theoradec tag parsing.
2005-05-25 12:04:37 +00:00
|
|
|
|
2012-03-07 11:22:14 +00:00
|
|
|
/* and pass along all */
|
|
|
|
gst_video_decoder_add_to_frame (decoder, av);
|
|
|
|
return gst_video_decoder_have_frame (decoder);
|
2005-07-01 17:13:02 +00:00
|
|
|
}
|
|
|
|
|
2004-01-30 20:23:24 +00:00
|
|
|
|
2008-10-13 11:36:13 +00:00
|
|
|
static gboolean
|
2012-03-07 11:22:14 +00:00
|
|
|
theora_dec_set_format (GstVideoDecoder * bdec, GstVideoCodecState * state)
|
2008-10-13 11:36:13 +00:00
|
|
|
{
|
|
|
|
GstTheoraDec *dec;
|
|
|
|
|
2012-03-07 11:22:14 +00:00
|
|
|
dec = GST_THEORA_DEC (bdec);
|
2008-10-13 11:36:13 +00:00
|
|
|
|
2012-03-07 11:22:14 +00:00
|
|
|
/* Keep a copy of the input state */
|
|
|
|
if (dec->input_state)
|
|
|
|
gst_video_codec_state_unref (dec->input_state);
|
|
|
|
dec->input_state = gst_video_codec_state_ref (state);
|
2008-10-13 11:36:13 +00:00
|
|
|
|
2012-03-07 11:22:14 +00:00
|
|
|
/* FIXME : Interesting, we always accept any kind of caps ? */
|
|
|
|
if (state->codec_data) {
|
|
|
|
GstBuffer *buffer;
|
2012-04-24 19:32:28 +00:00
|
|
|
GstMapInfo minfo;
|
2012-03-07 11:22:14 +00:00
|
|
|
guint8 *data;
|
|
|
|
guint size;
|
|
|
|
guint offset;
|
2008-10-13 11:36:13 +00:00
|
|
|
|
2012-03-07 11:22:14 +00:00
|
|
|
buffer = state->codec_data;
|
2012-04-24 19:32:28 +00:00
|
|
|
gst_buffer_map (buffer, &minfo, GST_MAP_READ);
|
2009-03-06 18:02:58 +00:00
|
|
|
|
2012-03-07 11:22:14 +00:00
|
|
|
offset = 0;
|
2012-04-24 19:32:28 +00:00
|
|
|
size = minfo.size;
|
|
|
|
data = (guint8 *) minfo.data;
|
2009-03-06 18:02:58 +00:00
|
|
|
|
2012-03-07 11:22:14 +00:00
|
|
|
while (size > 2) {
|
|
|
|
guint psize;
|
|
|
|
GstBuffer *buf;
|
2009-03-06 18:02:58 +00:00
|
|
|
|
2012-03-07 11:22:14 +00:00
|
|
|
psize = (data[0] << 8) | data[1];
|
|
|
|
/* skip header */
|
|
|
|
data += 2;
|
|
|
|
size -= 2;
|
|
|
|
offset += 2;
|
2009-03-06 18:02:58 +00:00
|
|
|
|
2012-03-07 11:22:14 +00:00
|
|
|
/* make sure we don't read too much */
|
|
|
|
psize = MIN (psize, size);
|
2009-03-06 18:02:58 +00:00
|
|
|
|
2012-04-24 19:32:28 +00:00
|
|
|
buf = gst_buffer_copy_region (buffer, GST_BUFFER_COPY_ALL, offset, psize);
|
2009-03-06 18:02:58 +00:00
|
|
|
|
2012-03-07 11:22:14 +00:00
|
|
|
/* first buffer is a discont buffer */
|
|
|
|
if (offset == 2)
|
|
|
|
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_DISCONT);
|
2009-03-06 18:02:58 +00:00
|
|
|
|
2012-03-07 11:22:14 +00:00
|
|
|
/* now feed it to the decoder we can ignore the error */
|
|
|
|
theora_dec_decode_buffer (dec, buf, NULL);
|
|
|
|
gst_buffer_unref (buf);
|
2009-03-06 18:02:58 +00:00
|
|
|
|
2012-03-07 11:22:14 +00:00
|
|
|
/* skip the data */
|
|
|
|
size -= psize;
|
|
|
|
data += psize;
|
|
|
|
offset += psize;
|
2009-03-06 18:02:58 +00:00
|
|
|
}
|
2012-04-24 19:32:28 +00:00
|
|
|
|
|
|
|
gst_buffer_unmap (buffer, &minfo);
|
2009-03-06 18:02:58 +00:00
|
|
|
}
|
|
|
|
|
2012-03-07 11:22:14 +00:00
|
|
|
GST_DEBUG_OBJECT (dec, "Done");
|
2008-10-13 11:36:13 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2005-03-31 09:43:49 +00:00
|
|
|
static GstFlowReturn
|
2005-04-28 16:21:19 +00:00
|
|
|
theora_handle_comment_packet (GstTheoraDec * dec, ogg_packet * packet)
|
2004-01-30 20:23:24 +00:00
|
|
|
{
|
2005-04-28 16:21:19 +00:00
|
|
|
gchar *encoder = NULL;
|
|
|
|
GstTagList *list;
|
|
|
|
|
ext/libvisual/visual.c: Small cleanups.
Original commit message from CVS:
* ext/libvisual/visual.c: (gst_visual_get_type),
(gst_visual_src_setcaps), (gst_vis_src_negotiate),
(gst_visual_chain):
Small cleanups.
* ext/theora/gsttheoradec.h:
* ext/theora/theoradec.c: (gst_theora_dec_init),
(gst_theora_dec_reset), (_theora_granule_time),
(theora_dec_src_convert), (theora_dec_sink_convert),
(theora_dec_src_query), (theora_dec_src_event),
(theora_dec_sink_event), (theora_handle_comment_packet),
(theora_handle_header_packet), (theora_dec_push),
(theora_handle_data_packet), (theora_dec_chain),
(theora_dec_change_state):
Add simple QoS.
2006-03-09 17:58:00 +00:00
|
|
|
GST_DEBUG_OBJECT (dec, "parsing comment packet");
|
2005-04-28 16:21:19 +00:00
|
|
|
|
ext/: ext/ogg/gstoggdemux.c (gst_ogg_demux_perform_seek) (gst_ogg_demux_read_chain, gst_ogg_demux_read_end_chain) ext...
Original commit message from CVS:
2005-05-09 Andy Wingo <wingo@pobox.com>
* ext/alsa/gstalsasink.h:
* ext/gnomevfs/gstgnomevfssrc.c:
(gst_gnomevfssrc_get_icy_metadata):
* ext/ogg/gstoggdemux.c (gst_ogg_demux_perform_seek)
(gst_ogg_demux_read_chain, gst_ogg_demux_read_end_chain)
* ext/theora/theoradec.c (theora_dec_src_query)
(theora_dec_src_event, theora_dec_sink_event)
(theora_handle_comment_packet, theora_handle_data_packet):
* ext/theora/theoraenc.c (theora_enc_chain):
* ext/vorbis/vorbisdec.c (vorbis_dec_src_event)
(vorbis_dec_sink_event, vorbis_handle_comment_packet):
* gst/audioconvert/gstaudioconvert.c (gst_audio_convert_getcaps):
* gst/typefind/gsttypefindfunctions.c (mp3_type_find)
(qt_type_find):
* gst/videotestsrc/videotestsrc.c (paint_setup_I420)
(paint_setup_YV12, paint_setup_YUY2, paint_setup_UYVY)
(paint_setup_YVYU, paint_setup_IYU2, paint_setup_Y41B)
(paint_setup_Y42B, paint_setup_Y800, paint_setup_IMC1)
(paint_setup_IMC2, paint_setup_IMC3, paint_setup_IMC4)
(paint_setup_YVU9, paint_setup_YUV9, paint_setup_xRGB8888)
(paint_setup_xBGR8888, paint_setup_RGBx8888)
(paint_setup_BGRx8888, paint_setup_RGB888, paint_setup_BGR888)
(paint_setup_RGB565, paint_setup_xRGB1555):
* gst/videotestsrc/videotestsrc.h:
* sys/ximage/ximagesink.c (gst_ximagesink_buffer_alloc):
* sys/xvimage/xvimagesink.c (gst_xvimagesink_get_xv_support)
(gst_xvimagesink_setcaps, gst_xvimagesink_buffer_alloc):
GCC4 fixes.
* ext/ogg/gstoggdemux.c (gst_ogg_demux_find_chains): Use the new
gst_pad_query_position. Fixes oggdemux.
2005-05-09 07:03:13 +00:00
|
|
|
list =
|
2012-04-24 19:32:28 +00:00
|
|
|
gst_tag_list_from_vorbiscomment (packet->packet, packet->bytes,
|
|
|
|
(guint8 *) "\201theora", 7, &encoder);
|
2005-04-28 16:21:19 +00:00
|
|
|
|
|
|
|
if (!list) {
|
|
|
|
GST_ERROR_OBJECT (dec, "couldn't decode comments");
|
2012-04-24 19:32:28 +00:00
|
|
|
list = gst_tag_list_new_empty ();
|
2005-04-28 16:21:19 +00:00
|
|
|
}
|
|
|
|
if (encoder) {
|
|
|
|
gst_tag_list_add (list, GST_TAG_MERGE_REPLACE,
|
|
|
|
GST_TAG_ENCODER, encoder, NULL);
|
|
|
|
g_free (encoder);
|
|
|
|
}
|
|
|
|
gst_tag_list_add (list, GST_TAG_MERGE_REPLACE,
|
|
|
|
GST_TAG_ENCODER_VERSION, dec->info.version_major,
|
|
|
|
GST_TAG_VIDEO_CODEC, "Theora", NULL);
|
|
|
|
|
2006-01-16 15:19:55 +00:00
|
|
|
if (dec->info.target_bitrate > 0) {
|
|
|
|
gst_tag_list_add (list, GST_TAG_MERGE_REPLACE,
|
|
|
|
GST_TAG_BITRATE, dec->info.target_bitrate,
|
|
|
|
GST_TAG_NOMINAL_BITRATE, dec->info.target_bitrate, NULL);
|
|
|
|
}
|
|
|
|
|
2012-08-09 14:09:46 +00:00
|
|
|
gst_video_decoder_merge_tags (GST_VIDEO_DECODER (dec),
|
|
|
|
list, GST_TAG_MERGE_REPLACE);
|
|
|
|
|
|
|
|
gst_tag_list_unref (list);
|
2005-04-28 16:21:19 +00:00
|
|
|
|
|
|
|
return GST_FLOW_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstFlowReturn
|
2012-05-22 22:49:49 +00:00
|
|
|
theora_handle_type_packet (GstTheoraDec * dec)
|
2005-04-28 16:21:19 +00:00
|
|
|
{
|
|
|
|
gint par_num, par_den;
|
2007-05-07 11:43:31 +00:00
|
|
|
GstFlowReturn ret = GST_FLOW_OK;
|
2012-03-07 11:22:14 +00:00
|
|
|
GstVideoCodecState *state;
|
|
|
|
GstVideoFormat fmt;
|
2024-02-23 11:14:18 +00:00
|
|
|
gint width, height;
|
2005-04-28 16:21:19 +00:00
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (dec, "fps %d/%d, PAR %d/%d",
|
|
|
|
dec->info.fps_numerator, dec->info.fps_denominator,
|
|
|
|
dec->info.aspect_numerator, dec->info.aspect_denominator);
|
|
|
|
|
|
|
|
/* calculate par
|
|
|
|
* the info.aspect_* values reflect PAR;
|
2010-02-08 10:21:35 +00:00
|
|
|
* 0:x and x:0 are allowed and can be interpreted as 1:1.
|
2008-04-30 17:06:45 +00:00
|
|
|
*/
|
2024-02-23 11:14:18 +00:00
|
|
|
par_num = GST_VIDEO_INFO_PAR_N (&dec->input_state->info);
|
|
|
|
par_den = GST_VIDEO_INFO_PAR_D (&dec->input_state->info);
|
2012-03-07 11:22:14 +00:00
|
|
|
|
|
|
|
/* If we have a default PAR, see if the decoder specified a different one */
|
|
|
|
if (par_num == 1 && par_den == 1 &&
|
|
|
|
(dec->info.aspect_numerator != 0 && dec->info.aspect_denominator != 0)) {
|
2008-10-13 11:36:13 +00:00
|
|
|
par_num = dec->info.aspect_numerator;
|
|
|
|
par_den = dec->info.aspect_denominator;
|
|
|
|
}
|
2005-04-28 16:21:19 +00:00
|
|
|
/* theora has:
|
|
|
|
*
|
2015-02-02 14:19:05 +00:00
|
|
|
* width/height : dimension of the encoded frame
|
2009-07-31 21:59:03 +00:00
|
|
|
* pic_width/pic_height : dimension of the visible part
|
|
|
|
* pic_x/pic_y : offset in encoded frame where visible part starts
|
2005-04-28 16:21:19 +00:00
|
|
|
*/
|
2009-07-31 21:59:03 +00:00
|
|
|
GST_DEBUG_OBJECT (dec, "dimension %dx%d, PAR %d/%d", dec->info.pic_width,
|
|
|
|
dec->info.pic_height, par_num, par_den);
|
2005-04-28 16:21:19 +00:00
|
|
|
GST_DEBUG_OBJECT (dec, "frame dimension %dx%d, offset %d:%d",
|
2009-07-31 21:59:03 +00:00
|
|
|
dec->info.pic_width, dec->info.pic_height,
|
|
|
|
dec->info.pic_x, dec->info.pic_y);
|
2007-03-12 23:29:07 +00:00
|
|
|
|
2012-03-07 11:22:14 +00:00
|
|
|
switch (dec->info.pixel_fmt) {
|
|
|
|
case TH_PF_420:
|
|
|
|
fmt = GST_VIDEO_FORMAT_I420;
|
|
|
|
break;
|
|
|
|
case TH_PF_422:
|
|
|
|
fmt = GST_VIDEO_FORMAT_Y42B;
|
|
|
|
break;
|
|
|
|
case TH_PF_444:
|
|
|
|
fmt = GST_VIDEO_FORMAT_Y444;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
goto unsupported_format;
|
2007-03-12 23:29:07 +00:00
|
|
|
}
|
2005-04-28 16:21:19 +00:00
|
|
|
|
2024-02-23 11:14:18 +00:00
|
|
|
width = dec->info.pic_width;
|
|
|
|
height = dec->info.pic_height;
|
2012-04-24 19:32:28 +00:00
|
|
|
|
2012-04-24 20:35:58 +00:00
|
|
|
/* Ensure correct offsets in chroma for formats that need it
|
|
|
|
* by rounding the offset. libtheora will add proper pixels,
|
|
|
|
* so no need to handle them ourselves. */
|
|
|
|
if (dec->info.pic_x & 1 && dec->info.pixel_fmt != TH_PF_444) {
|
2024-02-23 11:14:18 +00:00
|
|
|
width++;
|
2012-04-24 20:35:58 +00:00
|
|
|
}
|
|
|
|
if (dec->info.pic_y & 1 && dec->info.pixel_fmt == TH_PF_420) {
|
2024-02-23 11:14:18 +00:00
|
|
|
height++;
|
2012-04-24 20:35:58 +00:00
|
|
|
}
|
2005-04-28 16:21:19 +00:00
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (dec, "after fixup frame dimension %dx%d, offset %d:%d",
|
2024-02-23 11:14:18 +00:00
|
|
|
width, height, dec->info.pic_x, dec->info.pic_y);
|
2005-04-28 16:21:19 +00:00
|
|
|
|
2024-02-23 11:14:18 +00:00
|
|
|
if (width == 0 || height == 0)
|
2018-01-17 13:35:11 +00:00
|
|
|
goto invalid_dimensions;
|
|
|
|
|
2005-04-28 16:21:19 +00:00
|
|
|
/* done */
|
2009-07-31 21:59:03 +00:00
|
|
|
dec->decoder = th_decode_alloc (&dec->info, dec->setup);
|
2005-04-28 16:21:19 +00:00
|
|
|
|
2020-10-21 19:55:40 +00:00
|
|
|
if (dec->telemetry_mv &&
|
|
|
|
th_decode_ctl (dec->decoder, TH_DECCTL_SET_TELEMETRY_MV,
|
2010-10-09 23:52:13 +00:00
|
|
|
&dec->telemetry_mv, sizeof (dec->telemetry_mv)) != TH_EIMPL) {
|
2010-10-09 22:49:35 +00:00
|
|
|
GST_WARNING_OBJECT (dec, "Could not enable MV visualisation");
|
2010-10-09 23:52:13 +00:00
|
|
|
}
|
2020-10-21 19:55:40 +00:00
|
|
|
if (dec->telemetry_mbmode &&
|
|
|
|
th_decode_ctl (dec->decoder, TH_DECCTL_SET_TELEMETRY_MBMODE,
|
2010-10-09 23:52:13 +00:00
|
|
|
&dec->telemetry_mbmode, sizeof (dec->telemetry_mbmode)) != TH_EIMPL) {
|
2010-10-09 22:49:35 +00:00
|
|
|
GST_WARNING_OBJECT (dec, "Could not enable MB mode visualisation");
|
2010-10-09 23:52:13 +00:00
|
|
|
}
|
2020-10-21 19:55:40 +00:00
|
|
|
if (dec->telemetry_qi &&
|
|
|
|
th_decode_ctl (dec->decoder, TH_DECCTL_SET_TELEMETRY_QI,
|
2010-10-09 23:52:13 +00:00
|
|
|
&dec->telemetry_qi, sizeof (dec->telemetry_qi)) != TH_EIMPL) {
|
2010-10-09 22:49:35 +00:00
|
|
|
GST_WARNING_OBJECT (dec, "Could not enable QI mode visualisation");
|
2010-10-09 23:52:13 +00:00
|
|
|
}
|
2020-10-21 19:55:40 +00:00
|
|
|
if (dec->telemetry_bits &&
|
|
|
|
th_decode_ctl (dec->decoder, TH_DECCTL_SET_TELEMETRY_BITS,
|
2010-10-09 23:52:13 +00:00
|
|
|
&dec->telemetry_bits, sizeof (dec->telemetry_bits)) != TH_EIMPL) {
|
2010-10-09 22:49:35 +00:00
|
|
|
GST_WARNING_OBJECT (dec, "Could not enable BITS mode visualisation");
|
2010-10-09 23:52:13 +00:00
|
|
|
}
|
2010-10-09 22:49:35 +00:00
|
|
|
|
2012-03-07 11:22:14 +00:00
|
|
|
/* Create the output state */
|
2024-02-23 11:16:36 +00:00
|
|
|
if (dec->output_state)
|
|
|
|
gst_video_codec_state_unref (dec->output_state);
|
2012-03-07 11:22:14 +00:00
|
|
|
dec->output_state = state =
|
|
|
|
gst_video_decoder_set_output_state (GST_VIDEO_DECODER (dec), fmt,
|
2024-02-23 11:14:18 +00:00
|
|
|
width, height, dec->input_state);
|
2005-04-28 16:21:19 +00:00
|
|
|
|
2012-03-07 11:22:14 +00:00
|
|
|
/* FIXME : Do we still need to set fps/par now that we pass the reference input stream ? */
|
|
|
|
state->info.fps_n = dec->info.fps_numerator;
|
|
|
|
state->info.fps_d = dec->info.fps_denominator;
|
|
|
|
state->info.par_n = par_num;
|
|
|
|
state->info.par_d = par_den;
|
2008-11-04 18:17:24 +00:00
|
|
|
|
2012-04-24 20:05:53 +00:00
|
|
|
/* these values are for all versions of the colorspace specified in the
|
|
|
|
* theora info */
|
2012-03-07 11:22:14 +00:00
|
|
|
state->info.chroma_site = GST_VIDEO_CHROMA_SITE_JPEG;
|
2012-04-24 20:05:53 +00:00
|
|
|
state->info.colorimetry.range = GST_VIDEO_COLOR_RANGE_16_235;
|
|
|
|
state->info.colorimetry.matrix = GST_VIDEO_COLOR_MATRIX_BT601;
|
|
|
|
state->info.colorimetry.transfer = GST_VIDEO_TRANSFER_BT709;
|
|
|
|
switch (dec->info.colorspace) {
|
|
|
|
case TH_CS_ITU_REC_470M:
|
|
|
|
state->info.colorimetry.primaries = GST_VIDEO_COLOR_PRIMARIES_BT470M;
|
|
|
|
break;
|
|
|
|
case TH_CS_ITU_REC_470BG:
|
|
|
|
state->info.colorimetry.primaries = GST_VIDEO_COLOR_PRIMARIES_BT470BG;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
state->info.colorimetry.primaries = GST_VIDEO_COLOR_PRIMARIES_UNKNOWN;
|
|
|
|
break;
|
|
|
|
}
|
2012-03-07 11:22:14 +00:00
|
|
|
|
2017-11-11 06:45:42 +00:00
|
|
|
if (!gst_video_decoder_negotiate (GST_VIDEO_DECODER (dec)))
|
|
|
|
goto not_negotiated;
|
2012-07-18 13:35:05 +00:00
|
|
|
|
2012-03-07 11:22:14 +00:00
|
|
|
dec->have_header = TRUE;
|
2005-04-28 16:21:19 +00:00
|
|
|
|
2007-05-07 11:43:31 +00:00
|
|
|
return ret;
|
2012-03-07 11:22:14 +00:00
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
unsupported_format:
|
|
|
|
{
|
|
|
|
GST_ERROR_OBJECT (dec, "Invalid pixel format %d", dec->info.pixel_fmt);
|
|
|
|
return GST_FLOW_ERROR;
|
|
|
|
}
|
2017-11-11 06:45:42 +00:00
|
|
|
|
|
|
|
not_negotiated:
|
|
|
|
{
|
|
|
|
GST_ERROR_OBJECT (dec, "Failed to negotiate");
|
|
|
|
return GST_FLOW_NOT_NEGOTIATED;
|
|
|
|
}
|
2018-01-17 13:35:11 +00:00
|
|
|
|
|
|
|
invalid_dimensions:
|
|
|
|
{
|
|
|
|
GST_ERROR_OBJECT (dec, "Invalid dimensions (width:%d, height:%d)",
|
2024-02-23 11:14:18 +00:00
|
|
|
width, height);
|
2018-01-17 13:35:11 +00:00
|
|
|
return GST_FLOW_ERROR;
|
|
|
|
}
|
2005-04-28 16:21:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static GstFlowReturn
|
|
|
|
theora_handle_header_packet (GstTheoraDec * dec, ogg_packet * packet)
|
|
|
|
{
|
|
|
|
GstFlowReturn res;
|
2009-07-31 21:59:03 +00:00
|
|
|
int ret;
|
2005-04-28 16:21:19 +00:00
|
|
|
|
ext/libvisual/visual.c: Small cleanups.
Original commit message from CVS:
* ext/libvisual/visual.c: (gst_visual_get_type),
(gst_visual_src_setcaps), (gst_vis_src_negotiate),
(gst_visual_chain):
Small cleanups.
* ext/theora/gsttheoradec.h:
* ext/theora/theoradec.c: (gst_theora_dec_init),
(gst_theora_dec_reset), (_theora_granule_time),
(theora_dec_src_convert), (theora_dec_sink_convert),
(theora_dec_src_query), (theora_dec_src_event),
(theora_dec_sink_event), (theora_handle_comment_packet),
(theora_handle_header_packet), (theora_dec_push),
(theora_handle_data_packet), (theora_dec_chain),
(theora_dec_change_state):
Add simple QoS.
2006-03-09 17:58:00 +00:00
|
|
|
GST_DEBUG_OBJECT (dec, "parsing header packet");
|
2005-04-28 16:21:19 +00:00
|
|
|
|
2009-07-31 21:59:03 +00:00
|
|
|
ret = th_decode_headerin (&dec->info, &dec->comment, &dec->setup, packet);
|
|
|
|
if (ret < 0)
|
2005-04-28 16:21:19 +00:00
|
|
|
goto header_read_error;
|
|
|
|
|
Updated seek example.
Original commit message from CVS:
* docs/libs/tmpl/gstringbuffer.sgml:
* examples/seeking/seek.c: (make_vorbis_theora_pipeline),
(query_rates), (query_positions_elems), (query_positions_pads),
(update_scale), (do_seek):
Updated seek example.
* ext/ogg/gstoggdemux.c: (gst_ogg_pad_submit_packet),
(gst_ogg_pad_submit_page), (gst_ogg_demux_activate_chain),
(gst_ogg_demux_find_chains), (gst_ogg_demux_send_event),
(gst_ogg_demux_loop):
Push out correct discont values.
* ext/theora/theoradec.c: (theora_dec_src_convert),
(theora_dec_sink_convert), (theora_dec_src_getcaps),
(theora_dec_sink_event), (theora_handle_type_packet),
(theora_handle_header_packet), (theora_dec_push),
(theora_handle_data_packet), (theora_dec_chain),
(theora_dec_change_state):
Better timestamping.
* ext/vorbis/vorbisdec.c: (gst_vorbis_dec_init),
(vorbis_dec_sink_event), (vorbis_dec_push),
(vorbis_handle_data_packet), (vorbis_dec_chain):
* ext/vorbis/vorbisdec.h:
Better timestamping.
* gst-libs/gst/audio/gstbaseaudiosink.c:
(gst_base_audio_sink_get_time), (gst_base_audio_sink_get_times),
(gst_base_audio_sink_event), (gst_base_audio_sink_render):
Handle syncing on timestamps instead of sample offsets. Make
use of DISCONT values as described in design docs.
* gst-libs/gst/audio/gstbaseaudiosrc.c:
(gst_base_audio_src_get_time):
* gst-libs/gst/audio/gstringbuffer.c: (gst_ring_buffer_acquire),
(gst_ring_buffer_set_sample), (gst_ring_buffer_commit),
(gst_ring_buffer_read):
* gst-libs/gst/audio/gstringbuffer.h:
* sys/ximage/ximagesink.c: (gst_ximagesink_get_times),
(gst_ximagesink_show_frame):
* sys/xvimage/xvimagesink.c: (gst_xvimagesink_get_times):
Correcly convert buffer timestamp to stream time.
2005-07-16 14:47:27 +00:00
|
|
|
switch (packet->packet[0]) {
|
|
|
|
case 0x81:
|
2005-04-28 16:21:19 +00:00
|
|
|
res = theora_handle_comment_packet (dec, packet);
|
|
|
|
break;
|
Updated seek example.
Original commit message from CVS:
* docs/libs/tmpl/gstringbuffer.sgml:
* examples/seeking/seek.c: (make_vorbis_theora_pipeline),
(query_rates), (query_positions_elems), (query_positions_pads),
(update_scale), (do_seek):
Updated seek example.
* ext/ogg/gstoggdemux.c: (gst_ogg_pad_submit_packet),
(gst_ogg_pad_submit_page), (gst_ogg_demux_activate_chain),
(gst_ogg_demux_find_chains), (gst_ogg_demux_send_event),
(gst_ogg_demux_loop):
Push out correct discont values.
* ext/theora/theoradec.c: (theora_dec_src_convert),
(theora_dec_sink_convert), (theora_dec_src_getcaps),
(theora_dec_sink_event), (theora_handle_type_packet),
(theora_handle_header_packet), (theora_dec_push),
(theora_handle_data_packet), (theora_dec_chain),
(theora_dec_change_state):
Better timestamping.
* ext/vorbis/vorbisdec.c: (gst_vorbis_dec_init),
(vorbis_dec_sink_event), (vorbis_dec_push),
(vorbis_handle_data_packet), (vorbis_dec_chain):
* ext/vorbis/vorbisdec.h:
Better timestamping.
* gst-libs/gst/audio/gstbaseaudiosink.c:
(gst_base_audio_sink_get_time), (gst_base_audio_sink_get_times),
(gst_base_audio_sink_event), (gst_base_audio_sink_render):
Handle syncing on timestamps instead of sample offsets. Make
use of DISCONT values as described in design docs.
* gst-libs/gst/audio/gstbaseaudiosrc.c:
(gst_base_audio_src_get_time):
* gst-libs/gst/audio/gstringbuffer.c: (gst_ring_buffer_acquire),
(gst_ring_buffer_set_sample), (gst_ring_buffer_commit),
(gst_ring_buffer_read):
* gst-libs/gst/audio/gstringbuffer.h:
* sys/ximage/ximagesink.c: (gst_ximagesink_get_times),
(gst_ximagesink_show_frame):
* sys/xvimage/xvimagesink.c: (gst_xvimagesink_get_times):
Correcly convert buffer timestamp to stream time.
2005-07-16 14:47:27 +00:00
|
|
|
case 0x82:
|
2012-05-22 22:49:49 +00:00
|
|
|
res = theora_handle_type_packet (dec);
|
2005-04-28 16:21:19 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* ignore */
|
2021-10-17 12:12:11 +00:00
|
|
|
GST_WARNING_OBJECT (dec, "unknown theora header packet found");
|
Updated seek example.
Original commit message from CVS:
* docs/libs/tmpl/gstringbuffer.sgml:
* examples/seeking/seek.c: (make_vorbis_theora_pipeline),
(query_rates), (query_positions_elems), (query_positions_pads),
(update_scale), (do_seek):
Updated seek example.
* ext/ogg/gstoggdemux.c: (gst_ogg_pad_submit_packet),
(gst_ogg_pad_submit_page), (gst_ogg_demux_activate_chain),
(gst_ogg_demux_find_chains), (gst_ogg_demux_send_event),
(gst_ogg_demux_loop):
Push out correct discont values.
* ext/theora/theoradec.c: (theora_dec_src_convert),
(theora_dec_sink_convert), (theora_dec_src_getcaps),
(theora_dec_sink_event), (theora_handle_type_packet),
(theora_handle_header_packet), (theora_dec_push),
(theora_handle_data_packet), (theora_dec_chain),
(theora_dec_change_state):
Better timestamping.
* ext/vorbis/vorbisdec.c: (gst_vorbis_dec_init),
(vorbis_dec_sink_event), (vorbis_dec_push),
(vorbis_handle_data_packet), (vorbis_dec_chain):
* ext/vorbis/vorbisdec.h:
Better timestamping.
* gst-libs/gst/audio/gstbaseaudiosink.c:
(gst_base_audio_sink_get_time), (gst_base_audio_sink_get_times),
(gst_base_audio_sink_event), (gst_base_audio_sink_render):
Handle syncing on timestamps instead of sample offsets. Make
use of DISCONT values as described in design docs.
* gst-libs/gst/audio/gstbaseaudiosrc.c:
(gst_base_audio_src_get_time):
* gst-libs/gst/audio/gstringbuffer.c: (gst_ring_buffer_acquire),
(gst_ring_buffer_set_sample), (gst_ring_buffer_commit),
(gst_ring_buffer_read):
* gst-libs/gst/audio/gstringbuffer.h:
* sys/ximage/ximagesink.c: (gst_ximagesink_get_times),
(gst_ximagesink_show_frame):
* sys/xvimage/xvimagesink.c: (gst_xvimagesink_get_times):
Correcly convert buffer timestamp to stream time.
2005-07-16 14:47:27 +00:00
|
|
|
case 0x80:
|
|
|
|
/* nothing special, this is the identification header */
|
2005-04-28 16:21:19 +00:00
|
|
|
res = GST_FLOW_OK;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
header_read_error:
|
|
|
|
{
|
|
|
|
GST_ELEMENT_ERROR (GST_ELEMENT (dec), STREAM, DECODE,
|
|
|
|
(NULL), ("couldn't read header packet"));
|
|
|
|
return GST_FLOW_ERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-02 14:19:05 +00:00
|
|
|
#define MIN_NUM_HEADERS 3
|
|
|
|
static GstFlowReturn
|
|
|
|
theoradec_handle_header_caps (GstTheoraDec * dec)
|
|
|
|
{
|
|
|
|
GstFlowReturn result = GST_CUSTOM_FLOW_DROP;
|
|
|
|
GstCaps *caps;
|
|
|
|
GstStructure *s = NULL;
|
|
|
|
const GValue *array = NULL;
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (dec, "Looking for Theora headers in caps");
|
|
|
|
caps = gst_pad_get_current_caps (GST_VIDEO_DECODER_SINK_PAD (dec));
|
|
|
|
if (caps)
|
|
|
|
s = gst_caps_get_structure (caps, 0);
|
|
|
|
if (s)
|
|
|
|
array = gst_structure_get_value (s, "streamheader");
|
|
|
|
|
|
|
|
if (caps)
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
|
|
|
|
if (array && (gst_value_array_get_size (array) >= MIN_NUM_HEADERS)) {
|
|
|
|
const GValue *value = NULL;
|
|
|
|
GstBuffer *buf = NULL;
|
|
|
|
gint i = 0;
|
|
|
|
|
|
|
|
while (result == GST_CUSTOM_FLOW_DROP
|
|
|
|
&& i < gst_value_array_get_size (array)) {
|
|
|
|
value = gst_value_array_get_value (array, i);
|
|
|
|
buf = gst_value_get_buffer (value);
|
|
|
|
if (!buf)
|
|
|
|
goto null_buffer;
|
|
|
|
GST_LOG_OBJECT (dec, "Submitting header packet");
|
|
|
|
result = theora_dec_decode_buffer (dec, buf, NULL);
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
goto array_error;
|
|
|
|
|
|
|
|
done:
|
|
|
|
return (result !=
|
|
|
|
GST_CUSTOM_FLOW_DROP ? GST_FLOW_NOT_NEGOTIATED : GST_FLOW_OK);
|
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
array_error:
|
|
|
|
{
|
|
|
|
GST_WARNING_OBJECT (dec, "streamheader array not found");
|
|
|
|
result = GST_FLOW_ERROR;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
null_buffer:
|
|
|
|
{
|
|
|
|
GST_WARNING_OBJECT (dec, "streamheader with null buffer received");
|
|
|
|
result = GST_FLOW_ERROR;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-23 11:08:21 +00:00
|
|
|
/* Allocate output frame and copy image data */
|
2009-04-28 04:39:01 +00:00
|
|
|
static GstFlowReturn
|
2012-03-07 11:22:14 +00:00
|
|
|
theora_handle_image (GstTheoraDec * dec, th_ycbcr_buffer buf,
|
|
|
|
GstVideoCodecFrame * frame)
|
2009-04-28 04:39:01 +00:00
|
|
|
{
|
2012-03-07 11:22:14 +00:00
|
|
|
GstVideoDecoder *decoder = GST_VIDEO_DECODER (dec);
|
2009-09-10 09:39:18 +00:00
|
|
|
gint width, height, stride;
|
2009-04-28 04:39:01 +00:00
|
|
|
GstFlowReturn result;
|
2012-04-24 20:35:58 +00:00
|
|
|
gint i, comp;
|
2009-09-10 09:39:18 +00:00
|
|
|
guint8 *dest, *src;
|
2012-04-24 20:35:58 +00:00
|
|
|
GstVideoFrame vframe;
|
|
|
|
gint pic_width, pic_height;
|
|
|
|
gint offset_x, offset_y;
|
2009-04-28 04:39:01 +00:00
|
|
|
|
2012-07-23 08:19:16 +00:00
|
|
|
result = gst_video_decoder_allocate_output_frame (decoder, frame);
|
2009-04-28 04:39:01 +00:00
|
|
|
|
2009-09-10 09:39:18 +00:00
|
|
|
if (G_UNLIKELY (result != GST_FLOW_OK)) {
|
2009-04-28 04:30:04 +00:00
|
|
|
GST_DEBUG_OBJECT (dec, "could not get buffer, reason: %s",
|
|
|
|
gst_flow_get_name (result));
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2024-02-23 11:08:21 +00:00
|
|
|
/* we need to crop the hard way */
|
|
|
|
offset_x = dec->info.pic_x;
|
|
|
|
offset_y = dec->info.pic_y;
|
|
|
|
pic_width = dec->info.pic_width;
|
|
|
|
pic_height = dec->info.pic_height;
|
|
|
|
/* Ensure correct offsets in chroma for formats that need it
|
|
|
|
* by rounding the offset. libtheora will add proper pixels,
|
|
|
|
* so no need to handle them ourselves. */
|
|
|
|
if (offset_x & 1 && dec->info.pixel_fmt != TH_PF_444)
|
|
|
|
offset_x--;
|
|
|
|
if (offset_y & 1 && dec->info.pixel_fmt == TH_PF_420)
|
|
|
|
offset_y--;
|
2012-04-24 20:35:58 +00:00
|
|
|
|
|
|
|
/* if only libtheora would allow us to give it a destination frame */
|
2016-02-20 11:31:43 +00:00
|
|
|
GST_CAT_TRACE_OBJECT (CAT_PERFORMANCE, dec,
|
2012-04-24 20:35:58 +00:00
|
|
|
"doing unavoidable video frame copy");
|
2012-03-07 11:22:14 +00:00
|
|
|
|
2024-02-23 11:17:42 +00:00
|
|
|
if (G_UNLIKELY (!gst_video_frame_map (&vframe, &dec->output_state->info,
|
2012-04-24 20:35:58 +00:00
|
|
|
frame->output_buffer, GST_MAP_WRITE)))
|
|
|
|
goto invalid_frame;
|
2012-04-24 19:32:28 +00:00
|
|
|
|
2012-04-24 20:35:58 +00:00
|
|
|
for (comp = 0; comp < 3; comp++) {
|
|
|
|
width =
|
|
|
|
GST_VIDEO_FORMAT_INFO_SCALE_WIDTH (vframe.info.finfo, comp, pic_width);
|
|
|
|
height =
|
|
|
|
GST_VIDEO_FORMAT_INFO_SCALE_HEIGHT (vframe.info.finfo, comp,
|
|
|
|
pic_height);
|
|
|
|
stride = GST_VIDEO_FRAME_COMP_STRIDE (&vframe, comp);
|
|
|
|
dest = GST_VIDEO_FRAME_COMP_DATA (&vframe, comp);
|
2005-04-28 16:21:19 +00:00
|
|
|
|
2012-04-24 20:35:58 +00:00
|
|
|
src = buf[comp].data;
|
|
|
|
src += ((height == pic_height) ? offset_y : offset_y / 2)
|
|
|
|
* buf[comp].stride;
|
|
|
|
src += (width == pic_width) ? offset_x : offset_x / 2;
|
2005-04-28 16:21:19 +00:00
|
|
|
|
|
|
|
for (i = 0; i < height; i++) {
|
2009-09-10 09:39:18 +00:00
|
|
|
memcpy (dest, src, width);
|
2005-04-28 16:21:19 +00:00
|
|
|
|
2009-09-10 09:39:18 +00:00
|
|
|
dest += stride;
|
2012-04-24 20:35:58 +00:00
|
|
|
src += buf[comp].stride;
|
2005-04-28 16:21:19 +00:00
|
|
|
}
|
|
|
|
}
|
2012-04-24 20:35:58 +00:00
|
|
|
gst_video_frame_unmap (&vframe);
|
2012-04-24 19:32:28 +00:00
|
|
|
|
2009-09-10 09:39:18 +00:00
|
|
|
return GST_FLOW_OK;
|
2012-04-24 20:35:58 +00:00
|
|
|
invalid_frame:
|
|
|
|
{
|
|
|
|
GST_DEBUG_OBJECT (dec, "could not map video frame");
|
|
|
|
return GST_FLOW_ERROR;
|
|
|
|
}
|
2009-04-28 04:01:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static GstFlowReturn
|
|
|
|
theora_handle_data_packet (GstTheoraDec * dec, ogg_packet * packet,
|
2012-03-07 11:22:14 +00:00
|
|
|
GstVideoCodecFrame * frame)
|
2009-04-28 04:01:51 +00:00
|
|
|
{
|
|
|
|
/* normal data packet */
|
2009-07-31 21:59:03 +00:00
|
|
|
th_ycbcr_buffer buf;
|
2009-04-28 04:01:51 +00:00
|
|
|
gboolean keyframe;
|
|
|
|
GstFlowReturn result;
|
2009-07-31 21:59:03 +00:00
|
|
|
ogg_int64_t gp;
|
2009-04-28 04:01:51 +00:00
|
|
|
|
2015-02-02 14:19:05 +00:00
|
|
|
if (G_UNLIKELY (!dec->have_header)) {
|
|
|
|
result = theoradec_handle_header_caps (dec);
|
|
|
|
if (result != GST_FLOW_OK)
|
|
|
|
goto not_initialized;
|
|
|
|
}
|
2009-04-28 04:01:51 +00:00
|
|
|
|
2015-02-02 14:19:05 +00:00
|
|
|
/* the second most significant bit of the first data byte is cleared
|
2009-04-28 04:01:51 +00:00
|
|
|
* for keyframes. We can only check it if it's not a zero-length packet. */
|
|
|
|
keyframe = packet->bytes && ((packet->packet[0] & 0x40) == 0);
|
|
|
|
if (G_UNLIKELY (keyframe)) {
|
|
|
|
GST_DEBUG_OBJECT (dec, "we have a keyframe");
|
|
|
|
dec->need_keyframe = FALSE;
|
|
|
|
} else if (G_UNLIKELY (dec->need_keyframe)) {
|
|
|
|
goto dropping;
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (dec, "parsing data packet");
|
|
|
|
|
|
|
|
/* this does the decoding */
|
2009-07-31 21:59:03 +00:00
|
|
|
if (G_UNLIKELY (th_decode_packetin (dec->decoder, packet, &gp) < 0))
|
2009-04-28 04:01:51 +00:00
|
|
|
goto decode_error;
|
|
|
|
|
2012-03-07 11:22:14 +00:00
|
|
|
if (frame &&
|
|
|
|
(gst_video_decoder_get_max_decode_time (GST_VIDEO_DECODER (dec),
|
|
|
|
frame) < 0))
|
|
|
|
goto dropping_qos;
|
2009-04-28 04:01:51 +00:00
|
|
|
|
|
|
|
/* this does postprocessing and set up the decoded frame
|
|
|
|
* pointers in our yuv variable */
|
2009-07-31 21:59:03 +00:00
|
|
|
if (G_UNLIKELY (th_decode_ycbcr_out (dec->decoder, buf) < 0))
|
2009-04-28 04:01:51 +00:00
|
|
|
goto no_yuv;
|
|
|
|
|
2009-07-31 21:59:03 +00:00
|
|
|
if (G_UNLIKELY ((buf[0].width != dec->info.frame_width)
|
|
|
|
|| (buf[0].height != dec->info.frame_height)))
|
2009-04-28 04:01:51 +00:00
|
|
|
goto wrong_dimensions;
|
|
|
|
|
2012-03-07 11:22:14 +00:00
|
|
|
result = theora_handle_image (dec, buf, frame);
|
2005-04-28 16:21:19 +00:00
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
not_initialized:
|
|
|
|
{
|
|
|
|
GST_ELEMENT_ERROR (GST_ELEMENT (dec), STREAM, DECODE,
|
Updated seek example.
Original commit message from CVS:
* docs/libs/tmpl/gstringbuffer.sgml:
* examples/seeking/seek.c: (make_vorbis_theora_pipeline),
(query_rates), (query_positions_elems), (query_positions_pads),
(update_scale), (do_seek):
Updated seek example.
* ext/ogg/gstoggdemux.c: (gst_ogg_pad_submit_packet),
(gst_ogg_pad_submit_page), (gst_ogg_demux_activate_chain),
(gst_ogg_demux_find_chains), (gst_ogg_demux_send_event),
(gst_ogg_demux_loop):
Push out correct discont values.
* ext/theora/theoradec.c: (theora_dec_src_convert),
(theora_dec_sink_convert), (theora_dec_src_getcaps),
(theora_dec_sink_event), (theora_handle_type_packet),
(theora_handle_header_packet), (theora_dec_push),
(theora_handle_data_packet), (theora_dec_chain),
(theora_dec_change_state):
Better timestamping.
* ext/vorbis/vorbisdec.c: (gst_vorbis_dec_init),
(vorbis_dec_sink_event), (vorbis_dec_push),
(vorbis_handle_data_packet), (vorbis_dec_chain):
* ext/vorbis/vorbisdec.h:
Better timestamping.
* gst-libs/gst/audio/gstbaseaudiosink.c:
(gst_base_audio_sink_get_time), (gst_base_audio_sink_get_times),
(gst_base_audio_sink_event), (gst_base_audio_sink_render):
Handle syncing on timestamps instead of sample offsets. Make
use of DISCONT values as described in design docs.
* gst-libs/gst/audio/gstbaseaudiosrc.c:
(gst_base_audio_src_get_time):
* gst-libs/gst/audio/gstringbuffer.c: (gst_ring_buffer_acquire),
(gst_ring_buffer_set_sample), (gst_ring_buffer_commit),
(gst_ring_buffer_read):
* gst-libs/gst/audio/gstringbuffer.h:
* sys/ximage/ximagesink.c: (gst_ximagesink_get_times),
(gst_ximagesink_show_frame):
* sys/xvimage/xvimagesink.c: (gst_xvimagesink_get_times):
Correcly convert buffer timestamp to stream time.
2005-07-16 14:47:27 +00:00
|
|
|
(NULL), ("no header sent yet"));
|
2005-04-28 16:21:19 +00:00
|
|
|
return GST_FLOW_ERROR;
|
|
|
|
}
|
|
|
|
dropping:
|
|
|
|
{
|
|
|
|
GST_WARNING_OBJECT (dec, "dropping frame because we need a keyframe");
|
2012-06-14 13:24:06 +00:00
|
|
|
return GST_CUSTOM_FLOW_DROP;
|
2005-04-28 16:21:19 +00:00
|
|
|
}
|
ext/libvisual/visual.c: Small cleanups.
Original commit message from CVS:
* ext/libvisual/visual.c: (gst_visual_get_type),
(gst_visual_src_setcaps), (gst_vis_src_negotiate),
(gst_visual_chain):
Small cleanups.
* ext/theora/gsttheoradec.h:
* ext/theora/theoradec.c: (gst_theora_dec_init),
(gst_theora_dec_reset), (_theora_granule_time),
(theora_dec_src_convert), (theora_dec_sink_convert),
(theora_dec_src_query), (theora_dec_src_event),
(theora_dec_sink_event), (theora_handle_comment_packet),
(theora_handle_header_packet), (theora_dec_push),
(theora_handle_data_packet), (theora_dec_chain),
(theora_dec_change_state):
Add simple QoS.
2006-03-09 17:58:00 +00:00
|
|
|
dropping_qos:
|
|
|
|
{
|
|
|
|
GST_WARNING_OBJECT (dec, "dropping frame because of QoS");
|
2012-06-07 12:24:48 +00:00
|
|
|
return GST_CUSTOM_FLOW_DROP;
|
ext/libvisual/visual.c: Small cleanups.
Original commit message from CVS:
* ext/libvisual/visual.c: (gst_visual_get_type),
(gst_visual_src_setcaps), (gst_vis_src_negotiate),
(gst_visual_chain):
Small cleanups.
* ext/theora/gsttheoradec.h:
* ext/theora/theoradec.c: (gst_theora_dec_init),
(gst_theora_dec_reset), (_theora_granule_time),
(theora_dec_src_convert), (theora_dec_sink_convert),
(theora_dec_src_query), (theora_dec_src_event),
(theora_dec_sink_event), (theora_handle_comment_packet),
(theora_handle_header_packet), (theora_dec_push),
(theora_handle_data_packet), (theora_dec_chain),
(theora_dec_change_state):
Add simple QoS.
2006-03-09 17:58:00 +00:00
|
|
|
}
|
|
|
|
decode_error:
|
2005-04-28 16:21:19 +00:00
|
|
|
{
|
|
|
|
GST_ELEMENT_ERROR (GST_ELEMENT (dec), STREAM, DECODE,
|
ext/libvisual/visual.c: Small cleanups.
Original commit message from CVS:
* ext/libvisual/visual.c: (gst_visual_get_type),
(gst_visual_src_setcaps), (gst_vis_src_negotiate),
(gst_visual_chain):
Small cleanups.
* ext/theora/gsttheoradec.h:
* ext/theora/theoradec.c: (gst_theora_dec_init),
(gst_theora_dec_reset), (_theora_granule_time),
(theora_dec_src_convert), (theora_dec_sink_convert),
(theora_dec_src_query), (theora_dec_src_event),
(theora_dec_sink_event), (theora_handle_comment_packet),
(theora_handle_header_packet), (theora_dec_push),
(theora_handle_data_packet), (theora_dec_chain),
(theora_dec_change_state):
Add simple QoS.
2006-03-09 17:58:00 +00:00
|
|
|
(NULL), ("theora decoder did not decode data packet"));
|
2005-04-28 16:21:19 +00:00
|
|
|
return GST_FLOW_ERROR;
|
|
|
|
}
|
ext/libvisual/visual.c: Small cleanups.
Original commit message from CVS:
* ext/libvisual/visual.c: (gst_visual_get_type),
(gst_visual_src_setcaps), (gst_vis_src_negotiate),
(gst_visual_chain):
Small cleanups.
* ext/theora/gsttheoradec.h:
* ext/theora/theoradec.c: (gst_theora_dec_init),
(gst_theora_dec_reset), (_theora_granule_time),
(theora_dec_src_convert), (theora_dec_sink_convert),
(theora_dec_src_query), (theora_dec_src_event),
(theora_dec_sink_event), (theora_handle_comment_packet),
(theora_handle_header_packet), (theora_dec_push),
(theora_handle_data_packet), (theora_dec_chain),
(theora_dec_change_state):
Add simple QoS.
2006-03-09 17:58:00 +00:00
|
|
|
no_yuv:
|
2005-04-28 16:21:19 +00:00
|
|
|
{
|
|
|
|
GST_ELEMENT_ERROR (GST_ELEMENT (dec), STREAM, DECODE,
|
|
|
|
(NULL), ("couldn't read out YUV image"));
|
|
|
|
return GST_FLOW_ERROR;
|
|
|
|
}
|
|
|
|
wrong_dimensions:
|
|
|
|
{
|
ext/libvisual/visual.c: Small cleanups.
Original commit message from CVS:
* ext/libvisual/visual.c: (gst_visual_get_type),
(gst_visual_src_setcaps), (gst_vis_src_negotiate),
(gst_visual_chain):
Small cleanups.
* ext/theora/gsttheoradec.h:
* ext/theora/theoradec.c: (gst_theora_dec_init),
(gst_theora_dec_reset), (_theora_granule_time),
(theora_dec_src_convert), (theora_dec_sink_convert),
(theora_dec_src_query), (theora_dec_src_event),
(theora_dec_sink_event), (theora_handle_comment_packet),
(theora_handle_header_packet), (theora_dec_push),
(theora_handle_data_packet), (theora_dec_chain),
(theora_dec_change_state):
Add simple QoS.
2006-03-09 17:58:00 +00:00
|
|
|
GST_ELEMENT_ERROR (GST_ELEMENT (dec), STREAM, FORMAT,
|
2005-04-28 16:21:19 +00:00
|
|
|
(NULL), ("dimensions of image do not match header"));
|
|
|
|
return GST_FLOW_ERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstFlowReturn
|
2012-03-07 11:22:14 +00:00
|
|
|
theora_dec_decode_buffer (GstTheoraDec * dec, GstBuffer * buf,
|
|
|
|
GstVideoCodecFrame * frame)
|
2005-04-28 16:21:19 +00:00
|
|
|
{
|
2004-01-30 20:23:24 +00:00
|
|
|
ogg_packet packet;
|
2005-03-31 09:43:49 +00:00
|
|
|
GstFlowReturn result = GST_FLOW_OK;
|
2012-04-24 19:32:28 +00:00
|
|
|
GstMapInfo minfo;
|
2004-01-30 20:23:24 +00:00
|
|
|
|
|
|
|
/* make ogg_packet out of the buffer */
|
2012-04-24 19:32:28 +00:00
|
|
|
gst_buffer_map (buf, &minfo, GST_MAP_READ);
|
|
|
|
packet.packet = minfo.data;
|
|
|
|
packet.bytes = minfo.size;
|
2009-12-08 16:23:53 +00:00
|
|
|
packet.granulepos = -1;
|
Updated seek example.
Original commit message from CVS:
* docs/libs/tmpl/gstringbuffer.sgml:
* examples/seeking/seek.c: (make_vorbis_theora_pipeline),
(query_rates), (query_positions_elems), (query_positions_pads),
(update_scale), (do_seek):
Updated seek example.
* ext/ogg/gstoggdemux.c: (gst_ogg_pad_submit_packet),
(gst_ogg_pad_submit_page), (gst_ogg_demux_activate_chain),
(gst_ogg_demux_find_chains), (gst_ogg_demux_send_event),
(gst_ogg_demux_loop):
Push out correct discont values.
* ext/theora/theoradec.c: (theora_dec_src_convert),
(theora_dec_sink_convert), (theora_dec_src_getcaps),
(theora_dec_sink_event), (theora_handle_type_packet),
(theora_handle_header_packet), (theora_dec_push),
(theora_handle_data_packet), (theora_dec_chain),
(theora_dec_change_state):
Better timestamping.
* ext/vorbis/vorbisdec.c: (gst_vorbis_dec_init),
(vorbis_dec_sink_event), (vorbis_dec_push),
(vorbis_handle_data_packet), (vorbis_dec_chain):
* ext/vorbis/vorbisdec.h:
Better timestamping.
* gst-libs/gst/audio/gstbaseaudiosink.c:
(gst_base_audio_sink_get_time), (gst_base_audio_sink_get_times),
(gst_base_audio_sink_event), (gst_base_audio_sink_render):
Handle syncing on timestamps instead of sample offsets. Make
use of DISCONT values as described in design docs.
* gst-libs/gst/audio/gstbaseaudiosrc.c:
(gst_base_audio_src_get_time):
* gst-libs/gst/audio/gstringbuffer.c: (gst_ring_buffer_acquire),
(gst_ring_buffer_set_sample), (gst_ring_buffer_commit),
(gst_ring_buffer_read):
* gst-libs/gst/audio/gstringbuffer.h:
* sys/ximage/ximagesink.c: (gst_ximagesink_get_times),
(gst_ximagesink_show_frame):
* sys/xvimage/xvimagesink.c: (gst_xvimagesink_get_times):
Correcly convert buffer timestamp to stream time.
2005-07-16 14:47:27 +00:00
|
|
|
packet.packetno = 0; /* we don't really care */
|
|
|
|
packet.b_o_s = dec->have_header ? 0 : 1;
|
ext/libvisual/visual.c: Small cleanups.
Original commit message from CVS:
* ext/libvisual/visual.c: (gst_visual_get_type),
(gst_visual_src_setcaps), (gst_vis_src_negotiate),
(gst_visual_chain):
Small cleanups.
* ext/theora/gsttheoradec.h:
* ext/theora/theoradec.c: (gst_theora_dec_init),
(gst_theora_dec_reset), (_theora_granule_time),
(theora_dec_src_convert), (theora_dec_sink_convert),
(theora_dec_src_query), (theora_dec_src_event),
(theora_dec_sink_event), (theora_handle_comment_packet),
(theora_handle_header_packet), (theora_dec_push),
(theora_handle_data_packet), (theora_dec_chain),
(theora_dec_change_state):
Add simple QoS.
2006-03-09 17:58:00 +00:00
|
|
|
/* EOS does not matter for the decoder */
|
2004-02-03 16:15:16 +00:00
|
|
|
packet.e_o_s = 0;
|
2004-06-11 17:34:32 +00:00
|
|
|
|
2008-10-14 11:13:59 +00:00
|
|
|
GST_LOG_OBJECT (dec, "decode buffer of size %ld", packet.bytes);
|
2008-10-13 11:36:13 +00:00
|
|
|
|
2012-03-07 11:22:14 +00:00
|
|
|
GST_DEBUG_OBJECT (dec, "header=%02x", packet.bytes ? packet.packet[0] : -1);
|
2004-08-09 13:16:04 +00:00
|
|
|
|
2006-10-06 12:57:10 +00:00
|
|
|
/* switch depending on packet type. A zero byte packet is always a data
|
|
|
|
* packet; we don't dereference it in that case. */
|
|
|
|
if (packet.bytes && packet.packet[0] & 0x80) {
|
2015-02-02 11:23:51 +00:00
|
|
|
/* header packets are not meant to be displayed - return FLOW_DROP */
|
Updated seek example.
Original commit message from CVS:
* docs/libs/tmpl/gstringbuffer.sgml:
* examples/seeking/seek.c: (make_vorbis_theora_pipeline),
(query_rates), (query_positions_elems), (query_positions_pads),
(update_scale), (do_seek):
Updated seek example.
* ext/ogg/gstoggdemux.c: (gst_ogg_pad_submit_packet),
(gst_ogg_pad_submit_page), (gst_ogg_demux_activate_chain),
(gst_ogg_demux_find_chains), (gst_ogg_demux_send_event),
(gst_ogg_demux_loop):
Push out correct discont values.
* ext/theora/theoradec.c: (theora_dec_src_convert),
(theora_dec_sink_convert), (theora_dec_src_getcaps),
(theora_dec_sink_event), (theora_handle_type_packet),
(theora_handle_header_packet), (theora_dec_push),
(theora_handle_data_packet), (theora_dec_chain),
(theora_dec_change_state):
Better timestamping.
* ext/vorbis/vorbisdec.c: (gst_vorbis_dec_init),
(vorbis_dec_sink_event), (vorbis_dec_push),
(vorbis_handle_data_packet), (vorbis_dec_chain):
* ext/vorbis/vorbisdec.h:
Better timestamping.
* gst-libs/gst/audio/gstbaseaudiosink.c:
(gst_base_audio_sink_get_time), (gst_base_audio_sink_get_times),
(gst_base_audio_sink_event), (gst_base_audio_sink_render):
Handle syncing on timestamps instead of sample offsets. Make
use of DISCONT values as described in design docs.
* gst-libs/gst/audio/gstbaseaudiosrc.c:
(gst_base_audio_src_get_time):
* gst-libs/gst/audio/gstringbuffer.c: (gst_ring_buffer_acquire),
(gst_ring_buffer_set_sample), (gst_ring_buffer_commit),
(gst_ring_buffer_read):
* gst-libs/gst/audio/gstringbuffer.h:
* sys/ximage/ximagesink.c: (gst_ximagesink_get_times),
(gst_ximagesink_show_frame):
* sys/xvimage/xvimagesink.c: (gst_xvimagesink_get_times):
Correcly convert buffer timestamp to stream time.
2005-07-16 14:47:27 +00:00
|
|
|
if (dec->have_header) {
|
2004-10-18 15:49:00 +00:00
|
|
|
GST_WARNING_OBJECT (GST_OBJECT (dec), "Ignoring header");
|
2012-08-07 20:58:21 +00:00
|
|
|
result = GST_CUSTOM_FLOW_DROP;
|
2004-11-26 12:25:44 +00:00
|
|
|
goto done;
|
2004-10-18 15:49:00 +00:00
|
|
|
}
|
2015-02-02 11:23:51 +00:00
|
|
|
if ((result = theora_handle_header_packet (dec, &packet)) != GST_FLOW_OK)
|
|
|
|
goto done;
|
|
|
|
result = GST_CUSTOM_FLOW_DROP;
|
2004-01-30 20:23:24 +00:00
|
|
|
} else {
|
2012-03-07 11:22:14 +00:00
|
|
|
result = theora_handle_data_packet (dec, &packet, frame);
|
2004-01-30 20:23:24 +00:00
|
|
|
}
|
2005-04-28 16:21:19 +00:00
|
|
|
|
2004-11-26 12:25:44 +00:00
|
|
|
done:
|
2012-04-24 19:32:28 +00:00
|
|
|
gst_buffer_unmap (buf, &minfo);
|
|
|
|
|
2005-03-31 09:43:49 +00:00
|
|
|
return result;
|
2004-01-30 20:23:24 +00:00
|
|
|
}
|
|
|
|
|
2006-11-02 15:06:36 +00:00
|
|
|
static GstFlowReturn
|
2012-03-07 11:22:14 +00:00
|
|
|
theora_dec_handle_frame (GstVideoDecoder * bdec, GstVideoCodecFrame * frame)
|
2006-11-02 15:06:36 +00:00
|
|
|
{
|
|
|
|
GstTheoraDec *dec;
|
|
|
|
GstFlowReturn res;
|
|
|
|
|
2012-03-07 11:22:14 +00:00
|
|
|
dec = GST_THEORA_DEC (bdec);
|
2006-11-02 15:06:36 +00:00
|
|
|
|
2012-03-07 11:22:14 +00:00
|
|
|
res = theora_dec_decode_buffer (dec, frame->input_buffer, frame);
|
2012-06-07 12:24:48 +00:00
|
|
|
switch (res) {
|
|
|
|
case GST_FLOW_OK:
|
|
|
|
res = gst_video_decoder_finish_frame (bdec, frame);
|
|
|
|
break;
|
|
|
|
case GST_CUSTOM_FLOW_DROP:
|
|
|
|
res = gst_video_decoder_drop_frame (bdec, frame);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
gst_video_codec_frame_unref (frame);
|
|
|
|
break;
|
|
|
|
}
|
2006-11-02 15:06:36 +00:00
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
ext/theora/: Added cropping option to theora decoder.
Original commit message from CVS:
* ext/theora/theoradec.c: (gst_theora_dec_class_init),
(gst_theora_dec_init), (theora_get_formats),
(theora_dec_src_convert), (theora_dec_sink_convert),
(theora_dec_src_query), (theora_dec_src_event), (theora_dec_event),
(theora_dec_chain), (theora_dec_set_property),
(theora_dec_get_property):
* ext/theora/theoraenc.c: (gst_border_mode_get_type),
(gst_theora_enc_class_init), (gst_theora_enc_init),
(theora_enc_sink_link), (theora_enc_chain),
(theora_enc_set_property), (theora_enc_get_property):
Added cropping option to theora decoder.
Added border option to theora encoder.
2004-07-30 10:18:42 +00:00
|
|
|
static void
|
|
|
|
theora_dec_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
|
|
|
GstTheoraDec *dec = GST_THEORA_DEC (object);
|
|
|
|
|
|
|
|
switch (prop_id) {
|
2010-10-09 22:49:35 +00:00
|
|
|
case PROP_TELEMETRY_MV:
|
|
|
|
dec->telemetry_mv = g_value_get_int (value);
|
|
|
|
break;
|
|
|
|
case PROP_TELEMETRY_MBMODE:
|
|
|
|
dec->telemetry_mbmode = g_value_get_int (value);
|
|
|
|
break;
|
|
|
|
case PROP_TELEMETRY_QI:
|
|
|
|
dec->telemetry_qi = g_value_get_int (value);
|
|
|
|
break;
|
|
|
|
case PROP_TELEMETRY_BITS:
|
|
|
|
dec->telemetry_bits = g_value_get_int (value);
|
|
|
|
break;
|
ext/theora/: Added cropping option to theora decoder.
Original commit message from CVS:
* ext/theora/theoradec.c: (gst_theora_dec_class_init),
(gst_theora_dec_init), (theora_get_formats),
(theora_dec_src_convert), (theora_dec_sink_convert),
(theora_dec_src_query), (theora_dec_src_event), (theora_dec_event),
(theora_dec_chain), (theora_dec_set_property),
(theora_dec_get_property):
* ext/theora/theoraenc.c: (gst_border_mode_get_type),
(gst_theora_enc_class_init), (gst_theora_enc_init),
(theora_enc_sink_link), (theora_enc_chain),
(theora_enc_set_property), (theora_enc_get_property):
Added cropping option to theora decoder.
Added border option to theora encoder.
2004-07-30 10:18:42 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
theora_dec_get_property (GObject * object, guint prop_id,
|
|
|
|
GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
|
|
|
GstTheoraDec *dec = GST_THEORA_DEC (object);
|
|
|
|
|
|
|
|
switch (prop_id) {
|
2010-10-09 22:49:35 +00:00
|
|
|
case PROP_TELEMETRY_MV:
|
|
|
|
g_value_set_int (value, dec->telemetry_mv);
|
|
|
|
break;
|
|
|
|
case PROP_TELEMETRY_MBMODE:
|
|
|
|
g_value_set_int (value, dec->telemetry_mbmode);
|
|
|
|
break;
|
|
|
|
case PROP_TELEMETRY_QI:
|
|
|
|
g_value_set_int (value, dec->telemetry_qi);
|
|
|
|
break;
|
|
|
|
case PROP_TELEMETRY_BITS:
|
|
|
|
g_value_set_int (value, dec->telemetry_bits);
|
|
|
|
break;
|
ext/theora/: Added cropping option to theora decoder.
Original commit message from CVS:
* ext/theora/theoradec.c: (gst_theora_dec_class_init),
(gst_theora_dec_init), (theora_get_formats),
(theora_dec_src_convert), (theora_dec_sink_convert),
(theora_dec_src_query), (theora_dec_src_event), (theora_dec_event),
(theora_dec_chain), (theora_dec_set_property),
(theora_dec_get_property):
* ext/theora/theoraenc.c: (gst_border_mode_get_type),
(gst_theora_enc_class_init), (gst_theora_enc_init),
(theora_enc_sink_link), (theora_enc_chain),
(theora_enc_set_property), (theora_enc_get_property):
Added cropping option to theora decoder.
Added border option to theora encoder.
2004-07-30 10:18:42 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|