2010-10-09 22:08:39 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 2010 David Schleef <ds@schleef.org>
|
|
|
|
*
|
|
|
|
* 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 20:38:00 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2010-10-09 22:08:39 +00:00
|
|
|
*/
|
|
|
|
/**
|
2020-07-10 14:26:27 +00:00
|
|
|
* SECTION:element-diracparse
|
2017-03-08 18:01:13 +00:00
|
|
|
* @title: gstdiracparse
|
2010-10-09 22:08:39 +00:00
|
|
|
*
|
|
|
|
* The gstdiracparse element does FIXME stuff.
|
|
|
|
*
|
2017-03-08 18:01:13 +00:00
|
|
|
* ## Example launch line
|
2010-10-09 22:08:39 +00:00
|
|
|
* |[
|
2015-12-14 02:09:46 +00:00
|
|
|
* gst-launch-1.0 -v fakesrc ! gstdiracparse ! FIXME ! fakesink
|
2010-10-09 22:08:39 +00:00
|
|
|
* ]|
|
|
|
|
* FIXME Describe what the pipeline does.
|
2017-03-08 18:01:13 +00:00
|
|
|
*
|
2010-10-09 22:08:39 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <gst/gst.h>
|
2013-12-16 09:13:36 +00:00
|
|
|
#include <gst/base/base.h>
|
|
|
|
#include <gst/pbutils/pbutils.h>
|
2011-07-04 23:18:18 +00:00
|
|
|
#include <string.h>
|
2021-02-25 14:22:15 +00:00
|
|
|
#include "gstvideoparserselements.h"
|
2010-10-09 22:08:39 +00:00
|
|
|
#include "gstdiracparse.h"
|
2011-07-04 23:18:18 +00:00
|
|
|
#include "dirac_parse.h"
|
2010-10-09 22:08:39 +00:00
|
|
|
|
|
|
|
/* prototypes */
|
|
|
|
|
|
|
|
|
|
|
|
static void gst_dirac_parse_set_property (GObject * object,
|
|
|
|
guint property_id, const GValue * value, GParamSpec * pspec);
|
|
|
|
static void gst_dirac_parse_get_property (GObject * object,
|
|
|
|
guint property_id, GValue * value, GParamSpec * pspec);
|
|
|
|
static void gst_dirac_parse_dispose (GObject * object);
|
|
|
|
static void gst_dirac_parse_finalize (GObject * object);
|
|
|
|
|
|
|
|
static gboolean gst_dirac_parse_start (GstBaseParse * parse);
|
|
|
|
static gboolean gst_dirac_parse_stop (GstBaseParse * parse);
|
|
|
|
static gboolean gst_dirac_parse_set_sink_caps (GstBaseParse * parse,
|
|
|
|
GstCaps * caps);
|
2011-11-25 11:48:58 +00:00
|
|
|
static GstCaps *gst_dirac_parse_get_sink_caps (GstBaseParse * parse,
|
|
|
|
GstCaps * filter);
|
2012-02-13 17:44:01 +00:00
|
|
|
static GstFlowReturn gst_dirac_parse_handle_frame (GstBaseParse * parse,
|
|
|
|
GstBaseParseFrame * frame, gint * skipsize);
|
2010-10-09 22:08:39 +00:00
|
|
|
static gboolean gst_dirac_parse_convert (GstBaseParse * parse,
|
|
|
|
GstFormat src_format, gint64 src_value, GstFormat dest_format,
|
|
|
|
gint64 * dest_value);
|
|
|
|
static GstFlowReturn gst_dirac_parse_pre_push_frame (GstBaseParse * parse,
|
|
|
|
GstBaseParseFrame * frame);
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0
|
|
|
|
};
|
|
|
|
|
|
|
|
/* pad templates */
|
|
|
|
|
|
|
|
static GstStaticPadTemplate gst_dirac_parse_sink_template =
|
|
|
|
GST_STATIC_PAD_TEMPLATE ("sink",
|
|
|
|
GST_PAD_SINK,
|
|
|
|
GST_PAD_ALWAYS,
|
2011-09-07 09:22:07 +00:00
|
|
|
GST_STATIC_CAPS ("video/x-dirac")
|
2010-10-09 22:08:39 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
static GstStaticPadTemplate gst_dirac_parse_src_template =
|
|
|
|
GST_STATIC_PAD_TEMPLATE ("src",
|
|
|
|
GST_PAD_SRC,
|
|
|
|
GST_PAD_ALWAYS,
|
2011-09-07 09:24:14 +00:00
|
|
|
GST_STATIC_CAPS ("video/x-dirac, parsed=(boolean)TRUE, "
|
|
|
|
"width=(int)[1,MAX], height=(int)[1,MAX], "
|
|
|
|
"framerate=(fraction)[0/1,MAX], "
|
|
|
|
"pixel-aspect-ratio=(fraction)[0/1,MAX], "
|
2012-09-03 11:41:33 +00:00
|
|
|
"interlace-mode=(string) { progressive, interleaved }, "
|
2012-09-03 11:33:51 +00:00
|
|
|
"profile=(string){ vc2-low-delay, vc2-simple, vc2-main, main }, "
|
|
|
|
"level=(string) { 0, 1, 128}")
|
2010-10-09 22:08:39 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
/* class initialization */
|
|
|
|
|
2011-11-24 11:01:48 +00:00
|
|
|
#define parent_class gst_dirac_parse_parent_class
|
|
|
|
G_DEFINE_TYPE (GstDiracParse, gst_dirac_parse, GST_TYPE_BASE_PARSE);
|
2021-02-25 14:22:15 +00:00
|
|
|
GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (diracparse, "diracparse", GST_RANK_NONE,
|
|
|
|
GST_TYPE_DIRAC_PARSE, videoparsers_element_init (plugin));
|
2010-10-09 22:08:39 +00:00
|
|
|
|
|
|
|
static void
|
2011-11-24 11:01:48 +00:00
|
|
|
gst_dirac_parse_class_init (GstDiracParseClass * klass)
|
2010-10-09 22:08:39 +00:00
|
|
|
{
|
2011-11-24 11:01:48 +00:00
|
|
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
|
|
|
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
|
|
|
GstBaseParseClass *base_parse_class = GST_BASE_PARSE_CLASS (klass);
|
|
|
|
|
|
|
|
gobject_class->set_property = gst_dirac_parse_set_property;
|
|
|
|
gobject_class->get_property = gst_dirac_parse_get_property;
|
|
|
|
gobject_class->dispose = gst_dirac_parse_dispose;
|
|
|
|
gobject_class->finalize = gst_dirac_parse_finalize;
|
2010-10-09 22:08:39 +00:00
|
|
|
|
2016-03-04 06:50:26 +00:00
|
|
|
gst_element_class_add_static_pad_template (element_class,
|
|
|
|
&gst_dirac_parse_src_template);
|
|
|
|
gst_element_class_add_static_pad_template (element_class,
|
|
|
|
&gst_dirac_parse_sink_template);
|
2010-10-09 22:08:39 +00:00
|
|
|
|
2012-10-17 16:34:26 +00:00
|
|
|
gst_element_class_set_static_metadata (element_class, "Dirac parser",
|
2011-03-11 13:37:06 +00:00
|
|
|
"Codec/Parser/Video", "Parses Dirac streams",
|
|
|
|
"David Schleef <ds@schleef.org>");
|
2010-10-09 22:08:39 +00:00
|
|
|
|
|
|
|
base_parse_class->start = GST_DEBUG_FUNCPTR (gst_dirac_parse_start);
|
|
|
|
base_parse_class->stop = GST_DEBUG_FUNCPTR (gst_dirac_parse_stop);
|
|
|
|
base_parse_class->set_sink_caps =
|
|
|
|
GST_DEBUG_FUNCPTR (gst_dirac_parse_set_sink_caps);
|
2011-11-24 09:08:27 +00:00
|
|
|
base_parse_class->get_sink_caps =
|
|
|
|
GST_DEBUG_FUNCPTR (gst_dirac_parse_get_sink_caps);
|
2012-02-13 17:44:01 +00:00
|
|
|
base_parse_class->handle_frame =
|
|
|
|
GST_DEBUG_FUNCPTR (gst_dirac_parse_handle_frame);
|
2010-10-09 22:08:39 +00:00
|
|
|
base_parse_class->convert = GST_DEBUG_FUNCPTR (gst_dirac_parse_convert);
|
|
|
|
base_parse_class->pre_push_frame =
|
|
|
|
GST_DEBUG_FUNCPTR (gst_dirac_parse_pre_push_frame);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-11-24 11:01:48 +00:00
|
|
|
gst_dirac_parse_init (GstDiracParse * diracparse)
|
2010-10-09 22:08:39 +00:00
|
|
|
{
|
|
|
|
gst_base_parse_set_min_frame_size (GST_BASE_PARSE (diracparse), 13);
|
2012-09-13 05:58:04 +00:00
|
|
|
gst_base_parse_set_pts_interpolation (GST_BASE_PARSE (diracparse), FALSE);
|
2013-12-04 08:13:31 +00:00
|
|
|
GST_PAD_SET_ACCEPT_INTERSECT (GST_BASE_PARSE_SINK_PAD (diracparse));
|
2015-08-14 14:43:18 +00:00
|
|
|
GST_PAD_SET_ACCEPT_TEMPLATE (GST_BASE_PARSE_SINK_PAD (diracparse));
|
2010-10-09 22:08:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gst_dirac_parse_set_property (GObject * object, guint property_id,
|
|
|
|
const GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GST_IS_DIRAC_PARSE (object));
|
|
|
|
|
|
|
|
switch (property_id) {
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gst_dirac_parse_get_property (GObject * object, guint property_id,
|
|
|
|
GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GST_IS_DIRAC_PARSE (object));
|
|
|
|
|
|
|
|
switch (property_id) {
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gst_dirac_parse_dispose (GObject * object)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GST_IS_DIRAC_PARSE (object));
|
|
|
|
|
|
|
|
/* clean up as possible. may be called multiple times */
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gst_dirac_parse_finalize (GObject * object)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GST_IS_DIRAC_PARSE (object));
|
|
|
|
|
|
|
|
/* clean up object here */
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_dirac_parse_start (GstBaseParse * parse)
|
|
|
|
{
|
2013-12-16 09:13:36 +00:00
|
|
|
GstDiracParse *diracparse = GST_DIRAC_PARSE (parse);
|
|
|
|
|
2011-07-04 23:18:18 +00:00
|
|
|
gst_base_parse_set_min_frame_size (parse, 13);
|
|
|
|
|
2013-12-16 09:13:36 +00:00
|
|
|
diracparse->sent_codec_tag = FALSE;
|
|
|
|
|
2010-10-09 22:08:39 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_dirac_parse_stop (GstBaseParse * parse)
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_dirac_parse_set_sink_caps (GstBaseParse * parse, GstCaps * caps)
|
|
|
|
{
|
|
|
|
/* Called when sink caps are set */
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2012-09-03 11:33:51 +00:00
|
|
|
static const gchar *
|
|
|
|
get_profile_name (int profile)
|
|
|
|
{
|
|
|
|
switch (profile) {
|
|
|
|
case 0:
|
|
|
|
return "vc2-low-delay";
|
|
|
|
case 1:
|
|
|
|
return "vc2-simple";
|
|
|
|
case 2:
|
|
|
|
return "vc2-main";
|
2012-09-03 12:58:16 +00:00
|
|
|
case 8:
|
2012-09-03 11:33:51 +00:00
|
|
|
return "main";
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return "unknown";
|
|
|
|
}
|
|
|
|
|
|
|
|
static const gchar *
|
|
|
|
get_level_name (int level)
|
|
|
|
{
|
|
|
|
switch (level) {
|
|
|
|
case 0:
|
|
|
|
return "0";
|
|
|
|
case 1:
|
|
|
|
return "1";
|
|
|
|
case 128:
|
|
|
|
return "128";
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* need to add it to template caps, so return 0 for now */
|
|
|
|
GST_WARNING ("unhandled dirac level %u", level);
|
|
|
|
return "0";
|
|
|
|
}
|
|
|
|
|
2012-02-13 17:44:01 +00:00
|
|
|
static GstFlowReturn
|
|
|
|
gst_dirac_parse_handle_frame (GstBaseParse * parse,
|
|
|
|
GstBaseParseFrame * frame, gint * skipsize)
|
2010-10-09 22:08:39 +00:00
|
|
|
{
|
|
|
|
int off;
|
|
|
|
guint32 next_header;
|
2012-01-25 15:20:41 +00:00
|
|
|
GstMapInfo map;
|
2011-07-04 23:18:18 +00:00
|
|
|
guint8 *data;
|
2011-11-24 11:01:48 +00:00
|
|
|
gsize size;
|
2011-07-04 23:18:18 +00:00
|
|
|
gboolean have_picture = FALSE;
|
|
|
|
int offset;
|
2012-02-13 17:44:01 +00:00
|
|
|
guint framesize = 0;
|
2010-10-09 22:08:39 +00:00
|
|
|
|
2012-01-25 15:20:41 +00:00
|
|
|
gst_buffer_map (frame->buffer, &map, GST_MAP_READ);
|
|
|
|
data = map.data;
|
|
|
|
size = map.size;
|
2011-07-04 23:18:18 +00:00
|
|
|
|
2012-02-13 17:44:01 +00:00
|
|
|
if (G_UNLIKELY (size < 13)) {
|
|
|
|
*skipsize = 1;
|
2011-11-24 11:01:48 +00:00
|
|
|
goto out;
|
2012-02-13 17:44:01 +00:00
|
|
|
}
|
2010-10-09 22:08:39 +00:00
|
|
|
|
2011-11-27 19:24:39 +00:00
|
|
|
GST_DEBUG ("%" G_GSIZE_FORMAT ": %02x %02x %02x %02x", size, data[0], data[1],
|
|
|
|
data[2], data[3]);
|
2010-10-09 22:08:39 +00:00
|
|
|
|
2011-07-04 23:18:18 +00:00
|
|
|
if (GST_READ_UINT32_BE (data) != 0x42424344) {
|
2011-11-24 11:01:48 +00:00
|
|
|
GstByteReader reader;
|
|
|
|
|
|
|
|
gst_byte_reader_init (&reader, data, size);
|
2011-07-04 23:18:18 +00:00
|
|
|
off = gst_byte_reader_masked_scan_uint32 (&reader, 0xffffffff,
|
2011-11-24 11:01:48 +00:00
|
|
|
0x42424344, 0, size);
|
2011-07-04 23:18:18 +00:00
|
|
|
|
|
|
|
if (off < 0) {
|
2011-11-24 11:01:48 +00:00
|
|
|
*skipsize = size - 3;
|
|
|
|
goto out;
|
2011-07-04 23:18:18 +00:00
|
|
|
}
|
2010-10-09 22:08:39 +00:00
|
|
|
|
2011-07-04 23:18:18 +00:00
|
|
|
GST_LOG_OBJECT (parse, "possible sync at buffer offset %d", off);
|
2010-10-09 22:08:39 +00:00
|
|
|
|
2011-07-04 23:18:18 +00:00
|
|
|
GST_DEBUG ("skipping %d", off);
|
2010-10-09 22:08:39 +00:00
|
|
|
*skipsize = off;
|
2011-11-24 11:01:48 +00:00
|
|
|
goto out;
|
2010-10-09 22:08:39 +00:00
|
|
|
}
|
|
|
|
|
2011-07-04 23:18:18 +00:00
|
|
|
/* have sync, parse chunks */
|
2010-10-09 22:08:39 +00:00
|
|
|
|
2011-07-04 23:18:18 +00:00
|
|
|
offset = 0;
|
|
|
|
while (!have_picture) {
|
|
|
|
GST_DEBUG ("offset %d:", offset);
|
|
|
|
|
|
|
|
if (offset + 13 >= size) {
|
2012-02-13 17:44:01 +00:00
|
|
|
framesize = offset + 13;
|
2011-11-24 11:01:48 +00:00
|
|
|
goto out;
|
2011-07-04 23:18:18 +00:00
|
|
|
}
|
2010-10-09 22:08:39 +00:00
|
|
|
|
2011-07-04 23:18:18 +00:00
|
|
|
GST_DEBUG ("chunk type %02x", data[offset + 4]);
|
2010-10-09 22:08:39 +00:00
|
|
|
|
2011-07-04 23:18:18 +00:00
|
|
|
if (GST_READ_UINT32_BE (data + offset) != 0x42424344) {
|
|
|
|
GST_DEBUG ("bad header");
|
|
|
|
*skipsize = 3;
|
2011-11-24 11:01:48 +00:00
|
|
|
goto out;
|
2011-07-04 23:18:18 +00:00
|
|
|
}
|
2010-10-09 22:08:39 +00:00
|
|
|
|
2011-07-04 23:18:18 +00:00
|
|
|
next_header = GST_READ_UINT32_BE (data + offset + 5);
|
|
|
|
GST_DEBUG ("next_header %d", next_header);
|
|
|
|
if (next_header == 0)
|
|
|
|
next_header = 13;
|
2010-10-09 22:08:39 +00:00
|
|
|
|
2011-07-04 23:18:18 +00:00
|
|
|
if (SCHRO_PARSE_CODE_IS_PICTURE (data[offset + 4])) {
|
|
|
|
have_picture = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
offset += next_header;
|
|
|
|
if (offset >= size) {
|
2012-02-13 17:44:01 +00:00
|
|
|
framesize = offset;
|
2011-11-24 11:01:48 +00:00
|
|
|
goto out;
|
2010-10-09 22:08:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-25 15:20:41 +00:00
|
|
|
gst_buffer_unmap (frame->buffer, &map);
|
2011-11-24 11:01:48 +00:00
|
|
|
|
2012-02-13 17:44:01 +00:00
|
|
|
framesize = offset;
|
|
|
|
GST_DEBUG ("framesize %d", framesize);
|
2011-07-04 23:18:18 +00:00
|
|
|
|
2012-02-13 17:44:01 +00:00
|
|
|
g_assert (framesize <= size);
|
2011-07-04 23:18:18 +00:00
|
|
|
|
|
|
|
if (data[4] == SCHRO_PARSE_CODE_SEQUENCE_HEADER) {
|
|
|
|
GstCaps *caps;
|
2012-02-13 17:44:01 +00:00
|
|
|
GstDiracParse *diracparse = GST_DIRAC_PARSE (parse);
|
2011-07-04 23:18:18 +00:00
|
|
|
DiracSequenceHeader sequence_header;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = dirac_sequence_header_parse (&sequence_header, data + 13, size - 13);
|
|
|
|
if (ret) {
|
|
|
|
memcpy (&diracparse->sequence_header, &sequence_header,
|
|
|
|
sizeof (sequence_header));
|
|
|
|
caps = gst_caps_new_simple ("video/x-dirac",
|
|
|
|
"width", G_TYPE_INT, sequence_header.width,
|
|
|
|
"height", G_TYPE_INT, sequence_header.height,
|
|
|
|
"framerate", GST_TYPE_FRACTION,
|
|
|
|
sequence_header.frame_rate_numerator,
|
|
|
|
sequence_header.frame_rate_denominator,
|
|
|
|
"pixel-aspect-ratio", GST_TYPE_FRACTION,
|
|
|
|
sequence_header.aspect_ratio_numerator,
|
|
|
|
sequence_header.aspect_ratio_denominator,
|
2012-09-03 11:41:33 +00:00
|
|
|
"interlace-mode", G_TYPE_STRING,
|
|
|
|
sequence_header.interlaced ? "interleaved" : "progressive",
|
2012-09-03 11:33:51 +00:00
|
|
|
"profile", G_TYPE_STRING, get_profile_name (sequence_header.profile),
|
|
|
|
"level", G_TYPE_STRING, get_level_name (sequence_header.level), NULL);
|
2011-07-04 23:18:18 +00:00
|
|
|
gst_pad_set_caps (GST_BASE_PARSE_SRC_PAD (parse), caps);
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
|
|
|
|
gst_base_parse_set_frame_rate (parse,
|
|
|
|
sequence_header.frame_rate_numerator,
|
|
|
|
sequence_header.frame_rate_denominator, 0, 0);
|
|
|
|
}
|
2010-10-09 22:08:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gst_base_parse_set_min_frame_size (parse, 13);
|
|
|
|
|
2012-02-13 17:44:01 +00:00
|
|
|
return gst_base_parse_finish_frame (parse, frame, framesize);
|
|
|
|
|
|
|
|
out:
|
|
|
|
gst_buffer_unmap (frame->buffer, &map);
|
|
|
|
if (framesize)
|
|
|
|
gst_base_parse_set_min_frame_size (parse, framesize);
|
2010-10-09 22:08:39 +00:00
|
|
|
return GST_FLOW_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_dirac_parse_convert (GstBaseParse * parse, GstFormat src_format,
|
|
|
|
gint64 src_value, GstFormat dest_format, gint64 * dest_value)
|
|
|
|
{
|
|
|
|
/* Convert between formats */
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstFlowReturn
|
|
|
|
gst_dirac_parse_pre_push_frame (GstBaseParse * parse, GstBaseParseFrame * frame)
|
|
|
|
{
|
2013-12-16 09:13:36 +00:00
|
|
|
GstDiracParse *diracparse = GST_DIRAC_PARSE (parse);
|
|
|
|
|
|
|
|
if (!diracparse->sent_codec_tag) {
|
|
|
|
GstTagList *taglist;
|
|
|
|
GstCaps *caps;
|
|
|
|
|
|
|
|
/* codec tag */
|
|
|
|
caps = gst_pad_get_current_caps (GST_BASE_PARSE_SRC_PAD (parse));
|
2015-12-15 17:10:00 +00:00
|
|
|
if (G_UNLIKELY (caps == NULL)) {
|
|
|
|
if (GST_PAD_IS_FLUSHING (GST_BASE_PARSE_SRC_PAD (parse))) {
|
|
|
|
GST_INFO_OBJECT (parse, "Src pad is flushing");
|
|
|
|
return GST_FLOW_FLUSHING;
|
|
|
|
} else {
|
|
|
|
GST_INFO_OBJECT (parse, "Src pad is not negotiated!");
|
|
|
|
return GST_FLOW_NOT_NEGOTIATED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
taglist = gst_tag_list_new_empty ();
|
2013-12-16 09:13:36 +00:00
|
|
|
gst_pb_utils_add_codec_description_to_tag_list (taglist,
|
|
|
|
GST_TAG_VIDEO_CODEC, caps);
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
|
2015-03-17 21:55:26 +00:00
|
|
|
gst_base_parse_merge_tags (parse, taglist, GST_TAG_MERGE_REPLACE);
|
|
|
|
gst_tag_list_unref (taglist);
|
2013-12-16 09:13:36 +00:00
|
|
|
|
|
|
|
/* also signals the end of first-frame processing */
|
|
|
|
diracparse->sent_codec_tag = TRUE;
|
|
|
|
}
|
2010-10-09 22:08:39 +00:00
|
|
|
|
|
|
|
return GST_FLOW_OK;
|
|
|
|
}
|
2011-11-24 09:08:27 +00:00
|
|
|
|
2013-12-04 08:00:43 +00:00
|
|
|
static void
|
|
|
|
remove_fields (GstCaps * caps)
|
|
|
|
{
|
|
|
|
guint i, n;
|
|
|
|
|
|
|
|
n = gst_caps_get_size (caps);
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
GstStructure *s = gst_caps_get_structure (caps, i);
|
|
|
|
|
|
|
|
gst_structure_remove_field (s, "parsed");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-24 09:08:27 +00:00
|
|
|
static GstCaps *
|
2011-11-25 11:48:58 +00:00
|
|
|
gst_dirac_parse_get_sink_caps (GstBaseParse * parse, GstCaps * filter)
|
2011-11-24 09:08:27 +00:00
|
|
|
{
|
2012-06-05 07:30:00 +00:00
|
|
|
GstCaps *peercaps, *templ;
|
2011-11-24 09:08:27 +00:00
|
|
|
GstCaps *res;
|
|
|
|
|
2012-06-05 07:30:00 +00:00
|
|
|
templ = gst_pad_get_pad_template_caps (GST_BASE_PARSE_SINK_PAD (parse));
|
2013-12-04 08:03:45 +00:00
|
|
|
if (filter) {
|
|
|
|
GstCaps *fcopy = gst_caps_copy (filter);
|
|
|
|
/* Remove the fields we convert */
|
|
|
|
remove_fields (fcopy);
|
|
|
|
peercaps = gst_pad_peer_query_caps (GST_BASE_PARSE_SRC_PAD (parse), fcopy);
|
|
|
|
gst_caps_unref (fcopy);
|
|
|
|
} else
|
|
|
|
peercaps = gst_pad_peer_query_caps (GST_BASE_PARSE_SRC_PAD (parse), NULL);
|
2012-06-05 07:30:00 +00:00
|
|
|
|
2011-11-24 09:08:27 +00:00
|
|
|
if (peercaps) {
|
|
|
|
/* Remove the parsed field */
|
|
|
|
peercaps = gst_caps_make_writable (peercaps);
|
2013-12-04 08:00:43 +00:00
|
|
|
remove_fields (peercaps);
|
2011-11-24 09:08:27 +00:00
|
|
|
|
2012-06-05 07:30:00 +00:00
|
|
|
res = gst_caps_intersect_full (peercaps, templ, GST_CAPS_INTERSECT_FIRST);
|
2011-11-24 09:08:27 +00:00
|
|
|
gst_caps_unref (peercaps);
|
2013-12-04 08:13:31 +00:00
|
|
|
gst_caps_unref (templ);
|
2011-11-24 09:08:27 +00:00
|
|
|
} else {
|
2012-06-05 07:30:00 +00:00
|
|
|
res = templ;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (filter) {
|
|
|
|
GstCaps *intersection;
|
|
|
|
|
|
|
|
intersection =
|
|
|
|
gst_caps_intersect_full (filter, res, GST_CAPS_INTERSECT_FIRST);
|
|
|
|
gst_caps_unref (res);
|
|
|
|
res = intersection;
|
2011-11-24 09:08:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|