mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-10 03:19:40 +00:00
Add GstBaseVideoDecoder from gst-plugins-bad git.
This commit is contained in:
parent
d1332bc2e1
commit
ca3005055c
7 changed files with 2677 additions and 0 deletions
43
gst-libs/gst/video/Makefile.am
Normal file
43
gst-libs/gst/video/Makefile.am
Normal file
|
@ -0,0 +1,43 @@
|
|||
noinst_LTLIBRARIES = libgstbasevideo-@GST_MAJORMINOR@.la
|
||||
|
||||
libgstbasevideo_source_c = \
|
||||
gstbasevideocodec.c \
|
||||
gstbasevideodecoder.c \
|
||||
gstbasevideoutils.c \
|
||||
$(NULL)
|
||||
|
||||
libgstbasevideo_source_h = \
|
||||
gstbasevideocodec.h \
|
||||
gstbasevideodecoder.h \
|
||||
gstbasevideoutils.h \
|
||||
$(NULL)
|
||||
|
||||
libgstbasevideo_@GST_MAJORMINOR@includedir = \
|
||||
$(includedir)/gstreamer-@GST_MAJORMINOR@/gst/video
|
||||
|
||||
libgstbasevideo_@GST_MAJORMINOR@_la_SOURCES = \
|
||||
$(libgstbasevideo_source_c)
|
||||
|
||||
noinst_HEADERS = \
|
||||
$(libgstbasevideo_source_h)
|
||||
|
||||
libgstbasevideo_@GST_MAJORMINOR@_la_CFLAGS = \
|
||||
-DGST_USE_UNSTABLE_API \
|
||||
-I$(top_srcdir)/gst-libs \
|
||||
$(GST_CFLAGS) \
|
||||
$(GST_BASE_CFLAGS) \
|
||||
$(GST_PLUGINS_BASE_CFLAGS) \
|
||||
$(NULL)
|
||||
|
||||
libgstbasevideo_@GST_MAJORMINOR@_la_LIBADD = \
|
||||
$(GST_LIBS) \
|
||||
$(GST_BASE_LIBS) \
|
||||
$(GST_PLUGINS_BASE_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
libgstbasevideo_@GST_MAJORMINOR@_la_LDFLAGS = \
|
||||
$(GST_ALL_LDFLAGS) \
|
||||
$(NULL)
|
||||
|
||||
# Extra clean files so that maintainer-clean removes *everything*
|
||||
MAINTAINERCLEANFILES = Makefile.in
|
575
gst-libs/gst/video/gstbasevideocodec.c
Normal file
575
gst-libs/gst/video/gstbasevideocodec.c
Normal file
|
@ -0,0 +1,575 @@
|
|||
/* Schrodinger
|
||||
* Copyright (C) 2006 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
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "gstbasevideocodec.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
GST_DEBUG_CATEGORY (basevideocodec_debug);
|
||||
#define GST_CAT_DEFAULT basevideocodec_debug
|
||||
|
||||
/* GstBaseVideoCodec signals and args */
|
||||
enum
|
||||
{
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
ARG_0
|
||||
};
|
||||
|
||||
static void gst_base_video_codec_finalize (GObject * object);
|
||||
|
||||
//static const GstQueryType *gst_base_video_codec_get_query_types (GstPad *pad);
|
||||
//static gboolean gst_base_video_codec_src_query (GstPad *pad, GstQuery *query);
|
||||
//static gboolean gst_base_video_codec_sink_query (GstPad *pad, GstQuery *query);
|
||||
//static gboolean gst_base_video_codec_src_event (GstPad *pad, GstEvent *event);
|
||||
//static gboolean gst_base_video_codec_sink_event (GstPad *pad, GstEvent *event);
|
||||
static GstStateChangeReturn gst_base_video_codec_change_state (GstElement *
|
||||
element, GstStateChange transition);
|
||||
//static GstFlowReturn gst_base_video_codec_push_all (GstBaseVideoCodec *base_video_codec,
|
||||
// gboolean at_eos);
|
||||
|
||||
|
||||
GST_BOILERPLATE (GstBaseVideoCodec, gst_base_video_codec, GstElement,
|
||||
GST_TYPE_ELEMENT);
|
||||
|
||||
static void
|
||||
gst_base_video_codec_base_init (gpointer g_class)
|
||||
{
|
||||
GST_DEBUG_CATEGORY_INIT (basevideocodec_debug, "basevideocodec", 0,
|
||||
"Base Video Codec");
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
gst_base_video_codec_class_init (GstBaseVideoCodecClass * klass)
|
||||
{
|
||||
GObjectClass *gobject_class;
|
||||
GstElementClass *element_class;
|
||||
|
||||
gobject_class = G_OBJECT_CLASS (klass);
|
||||
element_class = GST_ELEMENT_CLASS (klass);
|
||||
|
||||
gobject_class->finalize = gst_base_video_codec_finalize;
|
||||
|
||||
element_class->change_state = gst_base_video_codec_change_state;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_base_video_codec_init (GstBaseVideoCodec * base_video_codec,
|
||||
GstBaseVideoCodecClass * klass)
|
||||
{
|
||||
GstPadTemplate *pad_template;
|
||||
|
||||
GST_DEBUG ("gst_base_video_codec_init");
|
||||
|
||||
pad_template =
|
||||
gst_element_class_get_pad_template (GST_ELEMENT_CLASS (klass), "sink");
|
||||
g_return_if_fail (pad_template != NULL);
|
||||
|
||||
base_video_codec->sinkpad = gst_pad_new_from_template (pad_template, "sink");
|
||||
//gst_pad_set_query_function (base_video_codec->sinkpad,
|
||||
// gst_base_video_codec_sink_query);
|
||||
gst_element_add_pad (GST_ELEMENT (base_video_codec),
|
||||
base_video_codec->sinkpad);
|
||||
|
||||
pad_template =
|
||||
gst_element_class_get_pad_template (GST_ELEMENT_CLASS (klass), "src");
|
||||
g_return_if_fail (pad_template != NULL);
|
||||
|
||||
base_video_codec->srcpad = gst_pad_new_from_template (pad_template, "src");
|
||||
gst_element_add_pad (GST_ELEMENT (base_video_codec),
|
||||
base_video_codec->srcpad);
|
||||
|
||||
base_video_codec->input_adapter = gst_adapter_new ();
|
||||
base_video_codec->output_adapter = gst_adapter_new ();
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
gst_base_video_codec_reset (GstBaseVideoCodec * base_video_codec)
|
||||
{
|
||||
GST_DEBUG ("reset");
|
||||
|
||||
base_video_codec->system_frame_number = 0;
|
||||
|
||||
//gst_segment_init (&base_video_codec->state.segment, GST_FORMAT_TIME);
|
||||
gst_adapter_clear (base_video_codec->input_adapter);
|
||||
gst_adapter_clear (base_video_codec->output_adapter);
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
gst_base_video_codec_finalize (GObject * object)
|
||||
{
|
||||
GstBaseVideoCodec *base_video_codec;
|
||||
|
||||
g_return_if_fail (GST_IS_BASE_VIDEO_CODEC (object));
|
||||
base_video_codec = GST_BASE_VIDEO_CODEC (object);
|
||||
|
||||
if (base_video_codec->input_adapter) {
|
||||
g_object_unref (base_video_codec->input_adapter);
|
||||
}
|
||||
if (base_video_codec->output_adapter) {
|
||||
g_object_unref (base_video_codec->output_adapter);
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
#ifdef unused
|
||||
static const GstQueryType *
|
||||
gst_base_video_codec_get_query_types (GstPad * pad)
|
||||
{
|
||||
static const GstQueryType query_types[] = {
|
||||
GST_QUERY_POSITION,
|
||||
GST_QUERY_DURATION,
|
||||
GST_QUERY_CONVERT,
|
||||
0
|
||||
};
|
||||
|
||||
return query_types;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
static gboolean
|
||||
gst_base_video_codec_src_convert (GstPad * pad,
|
||||
GstFormat src_format, gint64 src_value,
|
||||
GstFormat * dest_format, gint64 * dest_value)
|
||||
{
|
||||
gboolean res;
|
||||
GstBaseVideoCodec *dec;
|
||||
|
||||
if (src_format == *dest_format) {
|
||||
*dest_value = src_value;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
dec = GST_BASE_VIDEO_CODEC (gst_pad_get_parent (pad));
|
||||
|
||||
if (src_format == GST_FORMAT_DEFAULT && *dest_format == GST_FORMAT_TIME) {
|
||||
if (dec->fps_d != 0) {
|
||||
*dest_value = gst_util_uint64_scale (granulepos_to_frame (src_value),
|
||||
dec->fps_d * GST_SECOND, dec->fps_n);
|
||||
res = TRUE;
|
||||
} else {
|
||||
res = FALSE;
|
||||
}
|
||||
} else {
|
||||
GST_WARNING ("unhandled conversion from %d to %d", src_format,
|
||||
*dest_format);
|
||||
res = FALSE;
|
||||
}
|
||||
|
||||
gst_object_unref (dec);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_base_video_codec_sink_convert (GstPad * pad,
|
||||
GstFormat src_format, gint64 src_value,
|
||||
GstFormat * dest_format, gint64 * dest_value)
|
||||
{
|
||||
gboolean res = TRUE;
|
||||
GstBaseVideoCodec *dec;
|
||||
|
||||
if (src_format == *dest_format) {
|
||||
*dest_value = src_value;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
dec = GST_BASE_VIDEO_CODEC (gst_pad_get_parent (pad));
|
||||
|
||||
/* FIXME: check if we are in a decoding state */
|
||||
|
||||
switch (src_format) {
|
||||
case GST_FORMAT_DEFAULT:
|
||||
switch (*dest_format) {
|
||||
case GST_FORMAT_TIME:
|
||||
*dest_value = gst_util_uint64_scale (src_value,
|
||||
dec->fps_d * GST_SECOND, dec->fps_n);
|
||||
break;
|
||||
default:
|
||||
res = FALSE;
|
||||
}
|
||||
break;
|
||||
case GST_FORMAT_TIME:
|
||||
switch (*dest_format) {
|
||||
case GST_FORMAT_DEFAULT:
|
||||
{
|
||||
*dest_value = gst_util_uint64_scale (src_value,
|
||||
dec->fps_n, dec->fps_d * GST_SECOND);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
res = FALSE;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
res = FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
gst_object_unref (dec);
|
||||
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef unused
|
||||
static gboolean
|
||||
gst_base_video_codec_src_query (GstPad * pad, GstQuery * query)
|
||||
{
|
||||
GstBaseVideoCodec *base_codec;
|
||||
gboolean res = FALSE;
|
||||
|
||||
base_codec = GST_BASE_VIDEO_CODEC (gst_pad_get_parent (pad));
|
||||
|
||||
switch (GST_QUERY_TYPE (query)) {
|
||||
case GST_QUERY_POSITION:
|
||||
{
|
||||
GstFormat format;
|
||||
gint64 time;
|
||||
gint64 value;
|
||||
|
||||
gst_query_parse_position (query, &format, NULL);
|
||||
|
||||
time = gst_util_uint64_scale (base_codec->system_frame_number,
|
||||
base_codec->state.fps_n, base_codec->state.fps_d);
|
||||
time += base_codec->state.segment.time;
|
||||
GST_DEBUG ("query position %" GST_TIME_FORMAT, GST_TIME_ARGS (time));
|
||||
res = gst_base_video_encoded_video_convert (&base_codec->state,
|
||||
GST_FORMAT_TIME, time, &format, &value);
|
||||
if (!res)
|
||||
goto error;
|
||||
|
||||
gst_query_set_position (query, format, value);
|
||||
break;
|
||||
}
|
||||
case GST_QUERY_DURATION:
|
||||
res = gst_pad_query (GST_PAD_PEER (base_codec->sinkpad), query);
|
||||
if (!res)
|
||||
goto error;
|
||||
break;
|
||||
case GST_QUERY_CONVERT:
|
||||
{
|
||||
GstFormat src_fmt, dest_fmt;
|
||||
gint64 src_val, dest_val;
|
||||
|
||||
GST_DEBUG ("query convert");
|
||||
|
||||
gst_query_parse_convert (query, &src_fmt, &src_val, &dest_fmt, &dest_val);
|
||||
res = gst_base_video_encoded_video_convert (&base_codec->state,
|
||||
src_fmt, src_val, &dest_fmt, &dest_val);
|
||||
if (!res)
|
||||
goto error;
|
||||
gst_query_set_convert (query, src_fmt, src_val, dest_fmt, dest_val);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
res = gst_pad_query_default (pad, query);
|
||||
break;
|
||||
}
|
||||
done:
|
||||
gst_object_unref (base_codec);
|
||||
|
||||
return res;
|
||||
error:
|
||||
GST_DEBUG_OBJECT (base_codec, "query failed");
|
||||
goto done;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef unused
|
||||
static gboolean
|
||||
gst_base_video_codec_sink_query (GstPad * pad, GstQuery * query)
|
||||
{
|
||||
GstBaseVideoCodec *base_video_codec;
|
||||
gboolean res = FALSE;
|
||||
|
||||
base_video_codec = GST_BASE_VIDEO_CODEC (gst_pad_get_parent (pad));
|
||||
|
||||
switch (GST_QUERY_TYPE (query)) {
|
||||
case GST_QUERY_CONVERT:
|
||||
{
|
||||
GstFormat src_fmt, dest_fmt;
|
||||
gint64 src_val, dest_val;
|
||||
|
||||
gst_query_parse_convert (query, &src_fmt, &src_val, &dest_fmt, &dest_val);
|
||||
res = gst_base_video_encoded_video_convert (&base_video_codec->state,
|
||||
src_fmt, src_val, &dest_fmt, &dest_val);
|
||||
if (!res)
|
||||
goto error;
|
||||
gst_query_set_convert (query, src_fmt, src_val, dest_fmt, dest_val);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
res = gst_pad_query_default (pad, query);
|
||||
break;
|
||||
}
|
||||
done:
|
||||
gst_object_unref (base_video_codec);
|
||||
|
||||
return res;
|
||||
error:
|
||||
GST_DEBUG_OBJECT (base_video_codec, "query failed");
|
||||
goto done;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef unused
|
||||
static gboolean
|
||||
gst_base_video_codec_src_event (GstPad * pad, GstEvent * event)
|
||||
{
|
||||
GstBaseVideoCodec *base_video_codec;
|
||||
gboolean res = FALSE;
|
||||
|
||||
base_video_codec = GST_BASE_VIDEO_CODEC (gst_pad_get_parent (pad));
|
||||
|
||||
switch (GST_EVENT_TYPE (event)) {
|
||||
case GST_EVENT_SEEK:
|
||||
{
|
||||
GstFormat format, tformat;
|
||||
gdouble rate;
|
||||
GstEvent *real_seek;
|
||||
GstSeekFlags flags;
|
||||
GstSeekType cur_type, stop_type;
|
||||
gint64 cur, stop;
|
||||
gint64 tcur, tstop;
|
||||
|
||||
gst_event_parse_seek (event, &rate, &format, &flags, &cur_type,
|
||||
&cur, &stop_type, &stop);
|
||||
gst_event_unref (event);
|
||||
|
||||
tformat = GST_FORMAT_TIME;
|
||||
res = gst_base_video_encoded_video_convert (&base_video_codec->state,
|
||||
format, cur, &tformat, &tcur);
|
||||
if (!res)
|
||||
goto convert_error;
|
||||
res = gst_base_video_encoded_video_convert (&base_video_codec->state,
|
||||
format, stop, &tformat, &tstop);
|
||||
if (!res)
|
||||
goto convert_error;
|
||||
|
||||
real_seek = gst_event_new_seek (rate, GST_FORMAT_TIME,
|
||||
flags, cur_type, tcur, stop_type, tstop);
|
||||
|
||||
res = gst_pad_push_event (base_video_codec->sinkpad, real_seek);
|
||||
|
||||
break;
|
||||
}
|
||||
#if 0
|
||||
case GST_EVENT_QOS:
|
||||
{
|
||||
gdouble proportion;
|
||||
GstClockTimeDiff diff;
|
||||
GstClockTime timestamp;
|
||||
|
||||
gst_event_parse_qos (event, &proportion, &diff, ×tamp);
|
||||
|
||||
GST_OBJECT_LOCK (base_video_codec);
|
||||
base_video_codec->proportion = proportion;
|
||||
base_video_codec->earliest_time = timestamp + diff;
|
||||
GST_OBJECT_UNLOCK (base_video_codec);
|
||||
|
||||
GST_DEBUG_OBJECT (base_video_codec,
|
||||
"got QoS %" GST_TIME_FORMAT ", %" G_GINT64_FORMAT,
|
||||
GST_TIME_ARGS (timestamp), diff);
|
||||
|
||||
res = gst_pad_push_event (base_video_codec->sinkpad, event);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
default:
|
||||
res = gst_pad_push_event (base_video_codec->sinkpad, event);
|
||||
break;
|
||||
}
|
||||
done:
|
||||
gst_object_unref (base_video_codec);
|
||||
return res;
|
||||
|
||||
convert_error:
|
||||
GST_DEBUG_OBJECT (base_video_codec, "could not convert format");
|
||||
goto done;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef unused
|
||||
static gboolean
|
||||
gst_base_video_codec_sink_event (GstPad * pad, GstEvent * event)
|
||||
{
|
||||
GstBaseVideoCodec *base_video_codec;
|
||||
gboolean ret = FALSE;
|
||||
|
||||
base_video_codec = GST_BASE_VIDEO_CODEC (gst_pad_get_parent (pad));
|
||||
|
||||
switch (GST_EVENT_TYPE (event)) {
|
||||
case GST_EVENT_FLUSH_START:
|
||||
ret = gst_pad_push_event (base_video_codec->srcpad, event);
|
||||
break;
|
||||
case GST_EVENT_FLUSH_STOP:
|
||||
gst_base_video_codec_reset (base_video_codec);
|
||||
ret = gst_pad_push_event (base_video_codec->srcpad, event);
|
||||
break;
|
||||
case GST_EVENT_EOS:
|
||||
if (gst_base_video_codec_push_all (base_video_codec,
|
||||
FALSE) == GST_FLOW_ERROR) {
|
||||
gst_event_unref (event);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ret = gst_pad_push_event (base_video_codec->srcpad, event);
|
||||
break;
|
||||
case GST_EVENT_NEWSEGMENT:
|
||||
{
|
||||
gboolean update;
|
||||
GstFormat format;
|
||||
gdouble rate;
|
||||
gint64 start, stop, time;
|
||||
|
||||
gst_event_parse_new_segment (event, &update, &rate, &format, &start,
|
||||
&stop, &time);
|
||||
|
||||
if (format != GST_FORMAT_TIME)
|
||||
goto newseg_wrong_format;
|
||||
|
||||
if (rate <= 0.0)
|
||||
goto newseg_wrong_rate;
|
||||
|
||||
GST_DEBUG ("newsegment %" GST_TIME_FORMAT " %" GST_TIME_FORMAT,
|
||||
GST_TIME_ARGS (start), GST_TIME_ARGS (time));
|
||||
gst_segment_set_newsegment (&base_video_codec->state.segment, update,
|
||||
rate, format, start, stop, time);
|
||||
|
||||
ret = gst_pad_push_event (base_video_codec->srcpad, event);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
ret = gst_pad_push_event (base_video_codec->srcpad, event);
|
||||
break;
|
||||
}
|
||||
done:
|
||||
gst_object_unref (base_video_codec);
|
||||
return ret;
|
||||
|
||||
newseg_wrong_format:
|
||||
GST_DEBUG_OBJECT (base_video_codec, "received non TIME newsegment");
|
||||
gst_event_unref (event);
|
||||
goto done;
|
||||
|
||||
newseg_wrong_rate:
|
||||
GST_DEBUG_OBJECT (base_video_codec, "negative rates not supported");
|
||||
gst_event_unref (event);
|
||||
goto done;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static GstStateChangeReturn
|
||||
gst_base_video_codec_change_state (GstElement * element,
|
||||
GstStateChange transition)
|
||||
{
|
||||
GstBaseVideoCodec *base_video_codec = GST_BASE_VIDEO_CODEC (element);
|
||||
GstStateChangeReturn ret;
|
||||
|
||||
switch (transition) {
|
||||
case GST_STATE_CHANGE_NULL_TO_READY:
|
||||
break;
|
||||
case GST_STATE_CHANGE_READY_TO_PAUSED:
|
||||
gst_base_video_codec_reset (base_video_codec);
|
||||
break;
|
||||
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
ret = parent_class->change_state (element, transition);
|
||||
|
||||
switch (transition) {
|
||||
case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
|
||||
break;
|
||||
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
||||
gst_base_video_codec_reset (base_video_codec);
|
||||
break;
|
||||
case GST_STATE_CHANGE_READY_TO_NULL:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if 0
|
||||
guint64
|
||||
gst_base_video_codec_get_timestamp (GstBaseVideoCodec * base_video_codec,
|
||||
int picture_number)
|
||||
{
|
||||
if (picture_number < 0) {
|
||||
return base_video_codec->timestamp_offset -
|
||||
(gint64) gst_util_uint64_scale (-picture_number,
|
||||
base_video_codec->state.fps_d * GST_SECOND,
|
||||
base_video_codec->state.fps_n);
|
||||
} else {
|
||||
return base_video_codec->timestamp_offset +
|
||||
gst_util_uint64_scale (picture_number,
|
||||
base_video_codec->state.fps_d * GST_SECOND,
|
||||
base_video_codec->state.fps_n);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
GstVideoFrame *
|
||||
gst_base_video_codec_new_frame (GstBaseVideoCodec * base_video_codec)
|
||||
{
|
||||
GstVideoFrame *frame;
|
||||
|
||||
frame = g_malloc0 (sizeof (GstVideoFrame));
|
||||
|
||||
frame->system_frame_number = base_video_codec->system_frame_number;
|
||||
base_video_codec->system_frame_number++;
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
void
|
||||
gst_base_video_codec_free_frame (GstVideoFrame * frame)
|
||||
{
|
||||
if (frame->sink_buffer) {
|
||||
gst_buffer_unref (frame->sink_buffer);
|
||||
}
|
||||
#if 0
|
||||
if (frame->src_buffer) {
|
||||
gst_buffer_unref (frame->src_buffer);
|
||||
}
|
||||
#endif
|
||||
|
||||
g_free (frame);
|
||||
}
|
150
gst-libs/gst/video/gstbasevideocodec.h
Normal file
150
gst-libs/gst/video/gstbasevideocodec.h
Normal file
|
@ -0,0 +1,150 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 2008 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
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef _GST_BASE_VIDEO_CODEC_H_
|
||||
#define _GST_BASE_VIDEO_CODEC_H_
|
||||
|
||||
#ifndef GST_USE_UNSTABLE_API
|
||||
#warning "GstBaseVideoCodec is unstable API and may change in future."
|
||||
#warning "You can define GST_USE_UNSTABLE_API to avoid this warning."
|
||||
#endif
|
||||
|
||||
#include <gst/gst.h>
|
||||
#include <gst/video/gstbasevideoutils.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GST_TYPE_BASE_VIDEO_CODEC \
|
||||
(gst_base_video_codec_get_type())
|
||||
#define GST_BASE_VIDEO_CODEC(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_BASE_VIDEO_CODEC,GstBaseVideoCodec))
|
||||
#define GST_BASE_VIDEO_CODEC_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_BASE_VIDEO_CODEC,GstBaseVideoCodecClass))
|
||||
#define GST_BASE_VIDEO_CODEC_GET_CLASS(obj) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_BASE_VIDEO_CODEC,GstBaseVideoCodecClass))
|
||||
#define GST_IS_BASE_VIDEO_CODEC(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_BASE_VIDEO_CODEC))
|
||||
#define GST_IS_BASE_VIDEO_CODEC_CLASS(obj) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_BASE_VIDEO_CODEC))
|
||||
|
||||
/**
|
||||
* GST_BASE_VIDEO_CODEC_SINK_NAME:
|
||||
*
|
||||
* The name of the templates for the sink pad.
|
||||
*/
|
||||
#define GST_BASE_VIDEO_CODEC_SINK_NAME "sink"
|
||||
/**
|
||||
* GST_BASE_VIDEO_CODEC_SRC_NAME:
|
||||
*
|
||||
* The name of the templates for the source pad.
|
||||
*/
|
||||
#define GST_BASE_VIDEO_CODEC_SRC_NAME "src"
|
||||
|
||||
/**
|
||||
* GST_BASE_VIDEO_CODEC_SRC_PAD:
|
||||
* @obj: base video codec instance
|
||||
*
|
||||
* Gives the pointer to the source #GstPad object of the element.
|
||||
*/
|
||||
#define GST_BASE_VIDEO_CODEC_SRC_PAD(obj) (((GstBaseVideoCodec *) (obj))->srcpad)
|
||||
|
||||
/**
|
||||
* GST_BASE_VIDEO_CODEC_SINK_PAD:
|
||||
* @obj: base video codec instance
|
||||
*
|
||||
* Gives the pointer to the sink #GstPad object of the element.
|
||||
*/
|
||||
#define GST_BASE_VIDEO_CODEC_SINK_PAD(obj) (((GstBaseVideoCodec *) (obj))->sinkpad)
|
||||
|
||||
/**
|
||||
* GST_BASE_VIDEO_CODEC_FLOW_NEED_DATA:
|
||||
*
|
||||
*/
|
||||
#define GST_BASE_VIDEO_CODEC_FLOW_NEED_DATA GST_FLOW_CUSTOM_SUCCESS
|
||||
|
||||
typedef struct _GstBaseVideoCodec GstBaseVideoCodec;
|
||||
typedef struct _GstBaseVideoCodecClass GstBaseVideoCodecClass;
|
||||
|
||||
struct _GstBaseVideoCodec
|
||||
{
|
||||
GstElement element;
|
||||
|
||||
/*< private >*/
|
||||
GstPad *sinkpad;
|
||||
GstPad *srcpad;
|
||||
GstAdapter *input_adapter;
|
||||
GstAdapter *output_adapter;
|
||||
|
||||
#if 0
|
||||
/* FIXME need to move from subclasses */
|
||||
GstVideoState state;
|
||||
#endif
|
||||
|
||||
//int reorder_depth;
|
||||
|
||||
//gboolean have_sync;
|
||||
//gboolean discont;
|
||||
//gboolean started;
|
||||
|
||||
//GstVideoFrame *current_frame;
|
||||
//int distance_from_sync;
|
||||
|
||||
//gboolean sink_clipping;
|
||||
|
||||
//guint64 presentation_frame_number;
|
||||
guint64 system_frame_number;
|
||||
|
||||
//GstCaps *caps;
|
||||
//gboolean set_output_caps;
|
||||
|
||||
//GstClockTime buffer_timestamp;
|
||||
|
||||
GstClockTime timestamp_offset;
|
||||
};
|
||||
|
||||
struct _GstBaseVideoCodecClass
|
||||
{
|
||||
GstElementClass element_class;
|
||||
|
||||
gboolean (*start) (GstBaseVideoCodec *codec);
|
||||
gboolean (*stop) (GstBaseVideoCodec *codec);
|
||||
gboolean (*reset) (GstBaseVideoCodec *codec);
|
||||
GstFlowReturn (*parse_data) (GstBaseVideoCodec *codec, gboolean at_eos);
|
||||
int (*scan_for_sync) (GstAdapter *adapter, gboolean at_eos,
|
||||
int offset, int n);
|
||||
GstFlowReturn (*shape_output) (GstBaseVideoCodec *codec, GstVideoFrame *frame);
|
||||
GstCaps *(*get_caps) (GstBaseVideoCodec *codec);
|
||||
|
||||
};
|
||||
|
||||
GType gst_base_video_codec_get_type (void);
|
||||
|
||||
#if 0
|
||||
guint64 gst_base_video_codec_get_timestamp (GstBaseVideoCodec *codec,
|
||||
int picture_number);
|
||||
#endif
|
||||
|
||||
GstVideoFrame * gst_base_video_codec_new_frame (GstBaseVideoCodec *base_video_codec);
|
||||
void gst_base_video_codec_free_frame (GstVideoFrame *frame);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif
|
||||
|
1495
gst-libs/gst/video/gstbasevideodecoder.c
Normal file
1495
gst-libs/gst/video/gstbasevideodecoder.c
Normal file
File diff suppressed because it is too large
Load diff
177
gst-libs/gst/video/gstbasevideodecoder.h
Normal file
177
gst-libs/gst/video/gstbasevideodecoder.h
Normal file
|
@ -0,0 +1,177 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 2008 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
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef _GST_BASE_VIDEO_DECODER_H_
|
||||
#define _GST_BASE_VIDEO_DECODER_H_
|
||||
|
||||
#ifndef GST_USE_UNSTABLE_API
|
||||
#warning "GstBaseVideoDecoder is unstable API and may change in future."
|
||||
#warning "You can define GST_USE_UNSTABLE_API to avoid this warning."
|
||||
#endif
|
||||
|
||||
#include <gst/video/gstbasevideocodec.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GST_TYPE_BASE_VIDEO_DECODER \
|
||||
(gst_base_video_decoder_get_type())
|
||||
#define GST_BASE_VIDEO_DECODER(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_BASE_VIDEO_DECODER,GstBaseVideoDecoder))
|
||||
#define GST_BASE_VIDEO_DECODER_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_BASE_VIDEO_DECODER,GstBaseVideoDecoderClass))
|
||||
#define GST_BASE_VIDEO_DECODER_GET_CLASS(obj) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_BASE_VIDEO_DECODER,GstBaseVideoDecoderClass))
|
||||
#define GST_IS_BASE_VIDEO_DECODER(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_BASE_VIDEO_DECODER))
|
||||
#define GST_IS_BASE_VIDEO_DECODER_CLASS(obj) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_BASE_VIDEO_DECODER))
|
||||
|
||||
/**
|
||||
* GST_BASE_VIDEO_DECODER_SINK_NAME:
|
||||
*
|
||||
* The name of the templates for the sink pad.
|
||||
*/
|
||||
#define GST_BASE_VIDEO_DECODER_SINK_NAME "sink"
|
||||
/**
|
||||
* GST_BASE_VIDEO_DECODER_SRC_NAME:
|
||||
*
|
||||
* The name of the templates for the source pad.
|
||||
*/
|
||||
#define GST_BASE_VIDEO_DECODER_SRC_NAME "src"
|
||||
|
||||
/**
|
||||
* * GST_BASE_VIDEO_DECODER_FLOW_NEED_DATA:
|
||||
* *
|
||||
* */
|
||||
#define GST_BASE_VIDEO_DECODER_FLOW_NEED_DATA GST_FLOW_CUSTOM_SUCCESS
|
||||
|
||||
|
||||
typedef struct _GstBaseVideoDecoder GstBaseVideoDecoder;
|
||||
typedef struct _GstBaseVideoDecoderClass GstBaseVideoDecoderClass;
|
||||
|
||||
struct _GstBaseVideoDecoder
|
||||
{
|
||||
GstBaseVideoCodec base_video_codec;
|
||||
|
||||
/*< private >*/
|
||||
GstAdapter *input_adapter;
|
||||
GstAdapter *output_adapter;
|
||||
|
||||
GList *frames;
|
||||
|
||||
gboolean have_sync;
|
||||
gboolean discont;
|
||||
gboolean started;
|
||||
|
||||
GstVideoState state;
|
||||
GstSegment segment;
|
||||
|
||||
gboolean sink_clipping;
|
||||
|
||||
guint64 presentation_frame_number;
|
||||
guint64 system_frame_number;
|
||||
|
||||
GstCaps *caps;
|
||||
gboolean have_src_caps;
|
||||
|
||||
GstVideoFrame *current_frame;
|
||||
|
||||
int distance_from_sync;
|
||||
int reorder_depth;
|
||||
|
||||
GstClockTime buffer_timestamp;
|
||||
|
||||
GstClockTime timestamp_offset;
|
||||
|
||||
gdouble proportion;
|
||||
GstClockTime earliest_time;
|
||||
|
||||
//GstBuffer *codec_data;
|
||||
|
||||
guint64 input_offset;
|
||||
guint64 frame_offset;
|
||||
GstClockTime last_timestamp;
|
||||
|
||||
guint64 base_picture_number;
|
||||
|
||||
int field_index;
|
||||
|
||||
gboolean is_delta_unit;
|
||||
gboolean packetized;
|
||||
|
||||
GList *timestamps;
|
||||
gboolean have_segment;
|
||||
};
|
||||
|
||||
struct _GstBaseVideoDecoderClass
|
||||
{
|
||||
GstBaseVideoCodecClass base_video_codec_class;
|
||||
|
||||
gboolean (*set_format) (GstBaseVideoDecoder *coder, GstVideoFormat,
|
||||
int width, int height, int fps_n, int fps_d,
|
||||
int par_n, int par_d);
|
||||
gboolean (*start) (GstBaseVideoDecoder *coder);
|
||||
gboolean (*stop) (GstBaseVideoDecoder *coder);
|
||||
gboolean (*reset) (GstBaseVideoDecoder *coder);
|
||||
int (*scan_for_sync) (GstBaseVideoDecoder *decoder, gboolean at_eos,
|
||||
int offset, int n);
|
||||
GstFlowReturn (*parse_data) (GstBaseVideoDecoder *decoder, gboolean at_eos);
|
||||
GstFlowReturn (*finish) (GstBaseVideoDecoder *coder);
|
||||
GstFlowReturn (*handle_frame) (GstBaseVideoDecoder *coder, GstVideoFrame *frame,
|
||||
GstClockTimeDiff deadline);
|
||||
GstFlowReturn (*shape_output) (GstBaseVideoDecoder *coder, GstVideoFrame *frame);
|
||||
GstCaps *(*get_caps) (GstBaseVideoDecoder *coder);
|
||||
|
||||
};
|
||||
|
||||
GType gst_base_video_decoder_get_type (void);
|
||||
|
||||
int gst_base_video_decoder_get_width (GstBaseVideoDecoder *coder);
|
||||
int gst_base_video_decoder_get_height (GstBaseVideoDecoder *coder);
|
||||
|
||||
guint64 gst_base_video_decoder_get_timestamp_offset (GstBaseVideoDecoder *coder);
|
||||
|
||||
GstVideoFrame *gst_base_video_decoder_get_frame (GstBaseVideoDecoder *coder,
|
||||
int frame_number);
|
||||
GstVideoFrame *gst_base_video_decoder_get_oldest_frame (GstBaseVideoDecoder *coder);
|
||||
void gst_base_video_decoder_add_to_frame (GstBaseVideoDecoder *base_video_decoder,
|
||||
int n_bytes);
|
||||
GstFlowReturn gst_base_video_decoder_finish_frame (GstBaseVideoDecoder *base_video_decoder,
|
||||
GstVideoFrame *frame);
|
||||
GstFlowReturn gst_base_video_decoder_skip_frame (GstBaseVideoDecoder * base_video_decoder,
|
||||
GstVideoFrame * frame);
|
||||
GstFlowReturn gst_base_video_decoder_end_of_stream (GstBaseVideoDecoder *base_video_decoder,
|
||||
GstBuffer *buffer);
|
||||
GstFlowReturn
|
||||
gst_base_video_decoder_have_frame (GstBaseVideoDecoder *base_video_decoder);
|
||||
GstVideoState * gst_base_video_decoder_get_state (GstBaseVideoDecoder *base_video_decoder);
|
||||
void gst_base_video_decoder_set_state (GstBaseVideoDecoder *base_video_decoder,
|
||||
GstVideoState *state);
|
||||
void gst_base_video_decoder_lost_sync (GstBaseVideoDecoder *base_video_decoder);
|
||||
void gst_base_video_decoder_set_sync_point (GstBaseVideoDecoder *base_video_decoder);
|
||||
|
||||
void gst_base_video_decoder_set_src_caps (GstBaseVideoDecoder *base_video_decoder);
|
||||
|
||||
GstFlowReturn gst_base_video_decoder_alloc_src_frame (GstBaseVideoDecoder *base_video_decoder,
|
||||
GstVideoFrame *frame);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif
|
||||
|
137
gst-libs/gst/video/gstbasevideoutils.c
Normal file
137
gst-libs/gst/video/gstbasevideoutils.c
Normal file
|
@ -0,0 +1,137 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 2008 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
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "gstbasevideoutils.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
GST_DEBUG_CATEGORY_EXTERN (basevideocodec_debug);
|
||||
#define GST_CAT_DEFAULT basevideocodec_debug
|
||||
|
||||
|
||||
#if 0
|
||||
guint64
|
||||
gst_base_video_convert_bytes_to_frames (GstVideoState * state, guint64 bytes)
|
||||
{
|
||||
return gst_util_uint64_scale_int (bytes, 1, state->bytes_per_picture);
|
||||
}
|
||||
|
||||
guint64
|
||||
gst_base_video_convert_frames_to_bytes (GstVideoState * state, guint64 frames)
|
||||
{
|
||||
return frames * state->bytes_per_picture;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
gboolean
|
||||
gst_base_video_rawvideo_convert (GstVideoState * state,
|
||||
GstFormat src_format, gint64 src_value,
|
||||
GstFormat * dest_format, gint64 * dest_value)
|
||||
{
|
||||
gboolean res = FALSE;
|
||||
|
||||
if (src_format == *dest_format) {
|
||||
*dest_value = src_value;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (src_format == GST_FORMAT_BYTES &&
|
||||
*dest_format == GST_FORMAT_DEFAULT && state->bytes_per_picture != 0) {
|
||||
/* convert bytes to frames */
|
||||
*dest_value = gst_util_uint64_scale_int (src_value, 1,
|
||||
state->bytes_per_picture);
|
||||
res = TRUE;
|
||||
} else if (src_format == GST_FORMAT_DEFAULT &&
|
||||
*dest_format == GST_FORMAT_BYTES && state->bytes_per_picture != 0) {
|
||||
/* convert bytes to frames */
|
||||
*dest_value = src_value * state->bytes_per_picture;
|
||||
res = TRUE;
|
||||
} else if (src_format == GST_FORMAT_DEFAULT &&
|
||||
*dest_format == GST_FORMAT_TIME && state->fps_n != 0) {
|
||||
/* convert frames to time */
|
||||
/* FIXME add segment time? */
|
||||
*dest_value = gst_util_uint64_scale (src_value,
|
||||
GST_SECOND * state->fps_d, state->fps_n);
|
||||
res = TRUE;
|
||||
} else if (src_format == GST_FORMAT_TIME &&
|
||||
*dest_format == GST_FORMAT_DEFAULT && state->fps_d != 0) {
|
||||
/* convert time to frames */
|
||||
/* FIXME subtract segment time? */
|
||||
*dest_value = gst_util_uint64_scale (src_value, state->fps_n,
|
||||
GST_SECOND * state->fps_d);
|
||||
res = TRUE;
|
||||
}
|
||||
|
||||
/* FIXME add bytes <--> time */
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gst_base_video_encoded_video_convert (GstVideoState * state,
|
||||
GstFormat src_format, gint64 src_value,
|
||||
GstFormat * dest_format, gint64 * dest_value)
|
||||
{
|
||||
gboolean res = FALSE;
|
||||
|
||||
if (src_format == *dest_format) {
|
||||
*dest_value = src_value;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
GST_DEBUG ("src convert");
|
||||
|
||||
#if 0
|
||||
if (src_format == GST_FORMAT_DEFAULT && *dest_format == GST_FORMAT_TIME) {
|
||||
if (dec->fps_d != 0) {
|
||||
*dest_value = gst_util_uint64_scale (granulepos_to_frame (src_value),
|
||||
dec->fps_d * GST_SECOND, dec->fps_n);
|
||||
res = TRUE;
|
||||
} else {
|
||||
res = FALSE;
|
||||
}
|
||||
} else {
|
||||
GST_WARNING ("unhandled conversion from %d to %d", src_format,
|
||||
*dest_format);
|
||||
res = FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
GstClockTime
|
||||
gst_video_state_get_timestamp (const GstVideoState * state,
|
||||
GstSegment * segment, int frame_number)
|
||||
{
|
||||
if (frame_number < 0) {
|
||||
return segment->start -
|
||||
(gint64) gst_util_uint64_scale (-frame_number,
|
||||
state->fps_d * GST_SECOND, state->fps_n);
|
||||
} else {
|
||||
return segment->start +
|
||||
gst_util_uint64_scale (frame_number,
|
||||
state->fps_d * GST_SECOND, state->fps_n);
|
||||
}
|
||||
}
|
100
gst-libs/gst/video/gstbasevideoutils.h
Normal file
100
gst-libs/gst/video/gstbasevideoutils.h
Normal file
|
@ -0,0 +1,100 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 2008 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
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef _GST_BASE_VIDEO_UTILS_H_
|
||||
#define _GST_BASE_VIDEO_UTILS_H_
|
||||
|
||||
#ifndef GST_USE_UNSTABLE_API
|
||||
#warning "The base video utils API is unstable and may change in future."
|
||||
#warning "You can define GST_USE_UNSTABLE_API to avoid this warning."
|
||||
#endif
|
||||
|
||||
#include <gst/gst.h>
|
||||
#include <gst/video/video.h>
|
||||
#include <gst/base/gstadapter.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GstVideoState GstVideoState;
|
||||
typedef struct _GstVideoFrame GstVideoFrame;
|
||||
|
||||
struct _GstVideoState
|
||||
{
|
||||
GstVideoFormat format;
|
||||
int width, height;
|
||||
int fps_n, fps_d;
|
||||
int par_n, par_d;
|
||||
|
||||
gboolean have_interlaced;
|
||||
gboolean interlaced;
|
||||
gboolean top_field_first;
|
||||
|
||||
int clean_width, clean_height;
|
||||
int clean_offset_left, clean_offset_top;
|
||||
|
||||
int bytes_per_picture;
|
||||
|
||||
//GstSegment segment;
|
||||
|
||||
int picture_number;
|
||||
GstBuffer *codec_data;
|
||||
|
||||
};
|
||||
|
||||
struct _GstVideoFrame
|
||||
{
|
||||
GstClockTime decode_timestamp;
|
||||
GstClockTime presentation_timestamp;
|
||||
GstClockTime presentation_duration;
|
||||
|
||||
gint system_frame_number;
|
||||
gint decode_frame_number;
|
||||
gint presentation_frame_number;
|
||||
|
||||
int distance_from_sync;
|
||||
gboolean is_sync_point;
|
||||
gboolean is_eos;
|
||||
|
||||
GstBuffer *sink_buffer;
|
||||
GstBuffer *src_buffer;
|
||||
|
||||
int field_index;
|
||||
int n_fields;
|
||||
|
||||
void *coder_hook;
|
||||
};
|
||||
|
||||
gboolean gst_base_video_rawvideo_convert (GstVideoState *state,
|
||||
GstFormat src_format, gint64 src_value,
|
||||
GstFormat * dest_format, gint64 *dest_value);
|
||||
gboolean gst_base_video_encoded_video_convert (GstVideoState *state,
|
||||
GstFormat src_format, gint64 src_value,
|
||||
GstFormat * dest_format, gint64 *dest_value);
|
||||
|
||||
GstClockTime gst_video_state_get_timestamp (const GstVideoState *state,
|
||||
GstSegment *segment, int frame_number);
|
||||
|
||||
int gst_adapter_masked_scan_uint32_compat (GstAdapter *adapter,
|
||||
guint32 pattern, guint32 mask, guint offset, guint n);
|
||||
GstBuffer *gst_adapter_get_buffer (GstAdapter *adapter);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in a new issue