mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-09-02 10:13:51 +00:00
basevideo: Remove old video base classes
This commit is contained in:
parent
399683d292
commit
64344a6c63
9 changed files with 0 additions and 4771 deletions
|
@ -4,20 +4,12 @@ lib_LTLIBRARIES = libgstbasevideo-@GST_API_VERSION@.la
|
||||||
CLEANFILES = $(BUILT_SOURCES)
|
CLEANFILES = $(BUILT_SOURCES)
|
||||||
|
|
||||||
libgstbasevideo_@GST_API_VERSION@_la_SOURCES = \
|
libgstbasevideo_@GST_API_VERSION@_la_SOURCES = \
|
||||||
gstbasevideocodec.c \
|
|
||||||
gstbasevideoutils.c \
|
|
||||||
gstbasevideodecoder.c \
|
|
||||||
gstbasevideoencoder.c \
|
|
||||||
gstsurfacemeta.c \
|
gstsurfacemeta.c \
|
||||||
gstsurfaceconverter.c \
|
gstsurfaceconverter.c \
|
||||||
videocontext.c
|
videocontext.c
|
||||||
|
|
||||||
libgstbasevideo_@GST_API_VERSION@includedir = $(includedir)/gstreamer-@GST_API_VERSION@/gst/video
|
libgstbasevideo_@GST_API_VERSION@includedir = $(includedir)/gstreamer-@GST_API_VERSION@/gst/video
|
||||||
libgstbasevideo_@GST_API_VERSION@include_HEADERS = \
|
libgstbasevideo_@GST_API_VERSION@include_HEADERS = \
|
||||||
gstbasevideocodec.h \
|
|
||||||
gstbasevideoutils.h \
|
|
||||||
gstbasevideodecoder.h \
|
|
||||||
gstbasevideoencoder.h \
|
|
||||||
gstsurfacemeta.h \
|
gstsurfacemeta.h \
|
||||||
gstsurfaceconverter.h \
|
gstsurfaceconverter.h \
|
||||||
videocontext.h
|
videocontext.h
|
||||||
|
|
|
@ -1,343 +0,0 @@
|
||||||
/* GStreamer
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* SECTION:gstbasevideocodec
|
|
||||||
* @short_description: Base class and objects for video codecs
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
#include "config.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
|
||||||
* SECTION:gstbasevideocodec
|
|
||||||
* @short_description: Base class for video codecs
|
|
||||||
* @see_also: #GstBaseVideoDecoder , #GstBaseVideoEncoder
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* FIXME 0.11: suppress warnings for deprecated API such as GStaticRecMutex
|
|
||||||
* with newer GLib versions (>= 2.31.0) */
|
|
||||||
#define GLIB_DISABLE_DEPRECATION_WARNINGS
|
|
||||||
|
|
||||||
#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 GstStateChangeReturn gst_base_video_codec_change_state (GstElement *
|
|
||||||
element, GstStateChange transition);
|
|
||||||
|
|
||||||
static GstElementClass *parent_class = NULL;
|
|
||||||
|
|
||||||
G_DEFINE_BOXED_TYPE (GstVideoFrameState, gst_video_frame_state,
|
|
||||||
(GBoxedCopyFunc) gst_video_frame_state_ref,
|
|
||||||
(GBoxedFreeFunc) gst_video_frame_state_unref);
|
|
||||||
|
|
||||||
/* NOTE (Edward): Do not use G_DEFINE_* because we need to have
|
|
||||||
* a GClassInitFunc called with the target class (which the macros
|
|
||||||
* don't handle).
|
|
||||||
*/
|
|
||||||
static void gst_base_video_codec_class_init (GstBaseVideoCodecClass * klass);
|
|
||||||
static void gst_base_video_codec_init (GstBaseVideoCodec * dec,
|
|
||||||
GstBaseVideoCodecClass * klass);
|
|
||||||
|
|
||||||
GType
|
|
||||||
gst_base_video_codec_get_type (void)
|
|
||||||
{
|
|
||||||
static volatile gsize base_video_codec_type = 0;
|
|
||||||
|
|
||||||
if (g_once_init_enter (&base_video_codec_type)) {
|
|
||||||
GType _type;
|
|
||||||
static const GTypeInfo base_video_codec_info = {
|
|
||||||
sizeof (GstBaseVideoCodecClass),
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
(GClassInitFunc) gst_base_video_codec_class_init,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
sizeof (GstBaseVideoCodec),
|
|
||||||
0,
|
|
||||||
(GInstanceInitFunc) gst_base_video_codec_init,
|
|
||||||
};
|
|
||||||
|
|
||||||
_type = g_type_register_static (GST_TYPE_ELEMENT,
|
|
||||||
"GstBaseVideoCodec", &base_video_codec_info, G_TYPE_FLAG_ABSTRACT);
|
|
||||||
g_once_init_leave (&base_video_codec_type, _type);
|
|
||||||
}
|
|
||||||
return base_video_codec_type;
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
parent_class = g_type_class_peek_parent (klass);
|
|
||||||
|
|
||||||
gobject_class->finalize = gst_base_video_codec_finalize;
|
|
||||||
|
|
||||||
element_class->change_state = gst_base_video_codec_change_state;
|
|
||||||
|
|
||||||
GST_DEBUG_CATEGORY_INIT (basevideocodec_debug, "basevideocodec", 0,
|
|
||||||
"Base Video Codec");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_base_video_codec_init (GstBaseVideoCodec * base_video_codec,
|
|
||||||
GstBaseVideoCodecClass * klass)
|
|
||||||
{
|
|
||||||
GstPadTemplate *pad_template;
|
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (base_video_codec, "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_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);
|
|
||||||
|
|
||||||
gst_segment_init (&base_video_codec->segment, GST_FORMAT_TIME);
|
|
||||||
|
|
||||||
g_rec_mutex_init (&base_video_codec->stream_lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_base_video_codec_reset (GstBaseVideoCodec * base_video_codec)
|
|
||||||
{
|
|
||||||
GList *g;
|
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (base_video_codec, "reset");
|
|
||||||
|
|
||||||
GST_BASE_VIDEO_CODEC_STREAM_LOCK (base_video_codec);
|
|
||||||
for (g = base_video_codec->frames; g; g = g_list_next (g)) {
|
|
||||||
gst_video_frame_state_unref ((GstVideoFrameState *) g->data);
|
|
||||||
}
|
|
||||||
g_list_free (base_video_codec->frames);
|
|
||||||
base_video_codec->frames = NULL;
|
|
||||||
|
|
||||||
base_video_codec->bytes = 0;
|
|
||||||
base_video_codec->time = 0;
|
|
||||||
|
|
||||||
gst_buffer_replace (&base_video_codec->state.codec_data, NULL);
|
|
||||||
gst_caps_replace (&base_video_codec->state.caps, NULL);
|
|
||||||
memset (&base_video_codec->state, 0, sizeof (GstVideoState));
|
|
||||||
base_video_codec->state.format = GST_VIDEO_FORMAT_UNKNOWN;
|
|
||||||
GST_BASE_VIDEO_CODEC_STREAM_UNLOCK (base_video_codec);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_base_video_codec_finalize (GObject * object)
|
|
||||||
{
|
|
||||||
GstBaseVideoCodec *base_video_codec = GST_BASE_VIDEO_CODEC (object);
|
|
||||||
|
|
||||||
g_rec_mutex_clear (&base_video_codec->stream_lock);
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gst_base_video_codec_append_frame:
|
|
||||||
* @codec: a #GstBaseVideoCodec
|
|
||||||
* @frame: the #GstVideoFrameState to append
|
|
||||||
*
|
|
||||||
* Appends a frame to the list of frames handled by the codec.
|
|
||||||
*
|
|
||||||
* Note: This should normally not be used by implementations.
|
|
||||||
**/
|
|
||||||
void
|
|
||||||
gst_base_video_codec_append_frame (GstBaseVideoCodec * codec,
|
|
||||||
GstVideoFrameState * frame)
|
|
||||||
{
|
|
||||||
g_return_if_fail (frame != NULL);
|
|
||||||
|
|
||||||
gst_video_frame_state_ref (frame);
|
|
||||||
codec->frames = g_list_append (codec->frames, frame);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
gst_base_video_codec_remove_frame (GstBaseVideoCodec * codec,
|
|
||||||
GstVideoFrameState * frame)
|
|
||||||
{
|
|
||||||
GList *link;
|
|
||||||
|
|
||||||
g_return_if_fail (frame != NULL);
|
|
||||||
|
|
||||||
link = g_list_find (codec->frames, frame);
|
|
||||||
if (link) {
|
|
||||||
gst_video_frame_state_unref ((GstVideoFrameState *) link->data);
|
|
||||||
codec->frames = g_list_delete_link (codec->frames, link);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
_gst_video_frame_state_free (GstVideoFrameState * frame)
|
|
||||||
{
|
|
||||||
g_return_if_fail (frame != NULL);
|
|
||||||
|
|
||||||
GST_LOG ("Freeing frame %p (sfn:%d)", frame, frame->system_frame_number);
|
|
||||||
|
|
||||||
if (frame->sink_buffer) {
|
|
||||||
gst_buffer_unref (frame->sink_buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (frame->src_buffer) {
|
|
||||||
gst_buffer_unref (frame->src_buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_list_foreach (frame->events, (GFunc) gst_event_unref, NULL);
|
|
||||||
g_list_free (frame->events);
|
|
||||||
|
|
||||||
if (frame->coder_hook_destroy_notify && frame->coder_hook)
|
|
||||||
frame->coder_hook_destroy_notify (frame->coder_hook);
|
|
||||||
|
|
||||||
g_slice_free (GstVideoFrameState, frame);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gst_base_video_codec_new_frame:
|
|
||||||
* @base_video_codec: a #GstBaseVideoCodec
|
|
||||||
*
|
|
||||||
* Creates a new #GstVideoFrameState for usage in decoders or encoders.
|
|
||||||
*
|
|
||||||
* Returns: (transfer full): The new #GstVideoFrameState, call
|
|
||||||
* #gst_video_frame_state_unref() when done with it.
|
|
||||||
*/
|
|
||||||
GstVideoFrameState *
|
|
||||||
gst_base_video_codec_new_frame (GstBaseVideoCodec * base_video_codec)
|
|
||||||
{
|
|
||||||
GstVideoFrameState *frame;
|
|
||||||
|
|
||||||
frame = g_slice_new0 (GstVideoFrameState);
|
|
||||||
|
|
||||||
frame->ref_count = 1;
|
|
||||||
|
|
||||||
GST_BASE_VIDEO_CODEC_STREAM_LOCK (base_video_codec);
|
|
||||||
frame->system_frame_number = base_video_codec->system_frame_number;
|
|
||||||
base_video_codec->system_frame_number++;
|
|
||||||
GST_BASE_VIDEO_CODEC_STREAM_UNLOCK (base_video_codec);
|
|
||||||
|
|
||||||
GST_LOG_OBJECT (base_video_codec, "Created new frame %p (sfn:%d)",
|
|
||||||
frame, frame->system_frame_number);
|
|
||||||
|
|
||||||
return frame;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gst_video_frame_state_ref:
|
|
||||||
* @frame: a #GstVideoFrameState
|
|
||||||
*
|
|
||||||
* Increases the refcount of the given frame by one.
|
|
||||||
*
|
|
||||||
* Returns: @buf
|
|
||||||
*/
|
|
||||||
GstVideoFrameState *
|
|
||||||
gst_video_frame_state_ref (GstVideoFrameState * frame)
|
|
||||||
{
|
|
||||||
g_return_val_if_fail (frame != NULL, NULL);
|
|
||||||
|
|
||||||
g_atomic_int_inc (&frame->ref_count);
|
|
||||||
|
|
||||||
return frame;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gst_video_frame_state_unref:
|
|
||||||
* @frame: a #GstVideoFrameState
|
|
||||||
*
|
|
||||||
* Decreases the refcount of the frame. If the refcount reaches 0, the frame
|
|
||||||
* will be freed.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
gst_video_frame_state_unref (GstVideoFrameState * frame)
|
|
||||||
{
|
|
||||||
g_return_if_fail (frame != NULL);
|
|
||||||
g_return_if_fail (frame->ref_count > 0);
|
|
||||||
|
|
||||||
if (g_atomic_int_dec_and_test (&frame->ref_count)) {
|
|
||||||
_gst_video_frame_state_free (frame);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,289 +0,0 @@
|
||||||
/* 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/base/gstadapter.h>
|
|
||||||
#include <gst/video/video.h>
|
|
||||||
#include <gst/video/gstvideopool.h>
|
|
||||||
#include <gst/video/gstvideometa.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:
|
|
||||||
*
|
|
||||||
* Returned while parsing to indicate more data is needed.
|
|
||||||
*/
|
|
||||||
#define GST_BASE_VIDEO_CODEC_FLOW_NEED_DATA GST_FLOW_CUSTOM_SUCCESS
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GST_BASE_VIDEO_CODEC_STREAM_LOCK:
|
|
||||||
* @codec: video codec instance
|
|
||||||
*
|
|
||||||
* Obtain a lock to protect the codec function from concurrent access.
|
|
||||||
*
|
|
||||||
* Since: 0.10.22
|
|
||||||
*/
|
|
||||||
#define GST_BASE_VIDEO_CODEC_STREAM_LOCK(codec) g_rec_mutex_lock (&GST_BASE_VIDEO_CODEC (codec)->stream_lock)
|
|
||||||
/**
|
|
||||||
* GST_BASE_VIDEO_CODEC_STREAM_UNLOCK:
|
|
||||||
* @codec: video codec instance
|
|
||||||
*
|
|
||||||
* Release the lock that protects the codec function from concurrent access.
|
|
||||||
*
|
|
||||||
* Since: 0.10.22
|
|
||||||
*/
|
|
||||||
#define GST_BASE_VIDEO_CODEC_STREAM_UNLOCK(codec) g_rec_mutex_unlock (&GST_BASE_VIDEO_CODEC (codec)->stream_lock)
|
|
||||||
|
|
||||||
typedef struct _GstVideoState GstVideoState;
|
|
||||||
typedef struct _GstVideoFrameState GstVideoFrameState;
|
|
||||||
typedef struct _GstBaseVideoCodec GstBaseVideoCodec;
|
|
||||||
typedef struct _GstBaseVideoCodecClass GstBaseVideoCodecClass;
|
|
||||||
|
|
||||||
/* GstVideoState is only used on the compressed video pad */
|
|
||||||
/**
|
|
||||||
* GstVideoState:
|
|
||||||
* @width: Width in pixels (including borders)
|
|
||||||
* @height: Height in pixels (including borders)
|
|
||||||
* @fps_n: Numerator of framerate
|
|
||||||
* @fps_d: Denominator of framerate
|
|
||||||
* @par_n: Numerator of Pixel Aspect Ratio
|
|
||||||
* @par_d: Denominator of Pixel Aspect Ratio
|
|
||||||
* @have_interlaced: The content of the @interlaced field is present and valid
|
|
||||||
* @interlaced: %TRUE if the stream is interlaced
|
|
||||||
* @top_field_first: %TRUE if the interlaced frame is top-field-first
|
|
||||||
* @clean_width: Useful width of video in pixels (i.e. without borders)
|
|
||||||
* @clean_height: Useful height of video in pixels (i.e. without borders)
|
|
||||||
* @clean_offset_left: Horizontal offset (from the left) of useful region in pixels
|
|
||||||
* @clean_offset_top: Vertical offset (from the top) of useful region in pixels
|
|
||||||
* @bytes_per_picture: Size in bytes of each picture
|
|
||||||
* @codec_data: Optional Codec Data for the stream
|
|
||||||
*
|
|
||||||
* Information about compressed video stream.
|
|
||||||
* FIXME: Re-use GstVideoInfo for more fields.
|
|
||||||
*/
|
|
||||||
struct _GstVideoState
|
|
||||||
{
|
|
||||||
GstCaps *caps;
|
|
||||||
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;
|
|
||||||
|
|
||||||
GstBuffer *codec_data;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GstVideoFrameState:
|
|
||||||
* @decode_timestamp: Decoding timestamp (aka DTS)
|
|
||||||
* @presentation_timestamp: Presentation timestamp (aka PTS)
|
|
||||||
* @presentation_duration: Duration of frame
|
|
||||||
* @system_frame_number: unique ID attributed when #GstVideoFrameState is
|
|
||||||
* created
|
|
||||||
* @decode_frame_number: Decoded frame number, increases in decoding order
|
|
||||||
* @presentation_frame_number: Presentation frame number, increases in
|
|
||||||
* presentation order.
|
|
||||||
* @distance_from_sync: Distance of the frame from a sync point, in number
|
|
||||||
* of frames.
|
|
||||||
* @is_sync_point: #TRUE if the frame is a synchronization point (like a
|
|
||||||
* keyframe)
|
|
||||||
* @is_eos: #TRUE if the frame is the last one of a segment.
|
|
||||||
* @decode_only: If #TRUE, the frame is only meant to be decoded but not
|
|
||||||
* pushed downstream
|
|
||||||
* @sink_buffer: input buffer
|
|
||||||
* @src_buffer: output buffer
|
|
||||||
* @field_index: Number of fields since beginning of stream
|
|
||||||
* @n_fields: Number of fields present in frame (default 2)
|
|
||||||
* @coder_hook: Private data called with @coder_hook_destroy_notify
|
|
||||||
* @coder_hook_destroy_notify: Called when frame is destroyed
|
|
||||||
* @deadline: Target clock time for display (running time)
|
|
||||||
* @force_keyframe: For encoders, if #TRUE a keyframe must be generated
|
|
||||||
* @force_keyframe_headers: For encoders, if #TRUE new headers must be generated
|
|
||||||
* @events: List of #GstEvent that must be pushed before the next @src_buffer
|
|
||||||
*
|
|
||||||
* State of a video frame going through the codec
|
|
||||||
**/
|
|
||||||
|
|
||||||
struct _GstVideoFrameState
|
|
||||||
{
|
|
||||||
/*< private >*/
|
|
||||||
gint ref_count;
|
|
||||||
|
|
||||||
/*< public >*/
|
|
||||||
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;
|
|
||||||
|
|
||||||
/* Frames that should not be pushed downstream and are
|
|
||||||
* not meant for display */
|
|
||||||
gboolean decode_only;
|
|
||||||
|
|
||||||
GstBuffer *sink_buffer;
|
|
||||||
GstBuffer *src_buffer;
|
|
||||||
|
|
||||||
int field_index;
|
|
||||||
int n_fields;
|
|
||||||
|
|
||||||
void *coder_hook;
|
|
||||||
GDestroyNotify coder_hook_destroy_notify;
|
|
||||||
|
|
||||||
GstClockTime deadline;
|
|
||||||
|
|
||||||
gboolean force_keyframe;
|
|
||||||
gboolean force_keyframe_headers;
|
|
||||||
|
|
||||||
/* Events that should be pushed downstream *before*
|
|
||||||
* the next src_buffer */
|
|
||||||
GList *events;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GstBaseVideoCodec:
|
|
||||||
*
|
|
||||||
* The opaque #GstBaseVideoCodec data structure.
|
|
||||||
*/
|
|
||||||
struct _GstBaseVideoCodec
|
|
||||||
{
|
|
||||||
/*< private >*/
|
|
||||||
GstElement element;
|
|
||||||
|
|
||||||
/*< protected >*/
|
|
||||||
GstPad *sinkpad;
|
|
||||||
GstPad *srcpad;
|
|
||||||
|
|
||||||
/* protects all data processing, i.e. is locked
|
|
||||||
* in the chain function, finish_frame and when
|
|
||||||
* processing serialized events */
|
|
||||||
GRecMutex stream_lock;
|
|
||||||
|
|
||||||
guint64 system_frame_number;
|
|
||||||
|
|
||||||
GList *frames; /* Protected with OBJECT_LOCK */
|
|
||||||
GstVideoState state; /* Compressed video pad */
|
|
||||||
GstVideoInfo info; /* Raw video pad */
|
|
||||||
GstSegment segment;
|
|
||||||
|
|
||||||
/* QoS properties */
|
|
||||||
gdouble proportion;
|
|
||||||
GstClockTime earliest_time;
|
|
||||||
gboolean discont;
|
|
||||||
|
|
||||||
gint64 bytes;
|
|
||||||
gint64 time;
|
|
||||||
|
|
||||||
/* FIXME before moving to base */
|
|
||||||
void *padding[GST_PADDING_LARGE];
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GstBaseVideoCodecClass:
|
|
||||||
*
|
|
||||||
* The opaque #GstBaseVideoCodecClass data structure.
|
|
||||||
*/
|
|
||||||
struct _GstBaseVideoCodecClass
|
|
||||||
{
|
|
||||||
/*< private >*/
|
|
||||||
GstElementClass element_class;
|
|
||||||
|
|
||||||
/* FIXME before moving to base */
|
|
||||||
void *padding[GST_PADDING_LARGE];
|
|
||||||
};
|
|
||||||
|
|
||||||
GType gst_video_frame_state_get_type (void);
|
|
||||||
GType gst_base_video_codec_get_type (void);
|
|
||||||
|
|
||||||
void gst_base_video_codec_append_frame (GstBaseVideoCodec *codec, GstVideoFrameState *frame);
|
|
||||||
void gst_base_video_codec_remove_frame (GstBaseVideoCodec *codec, GstVideoFrameState *frame);
|
|
||||||
|
|
||||||
GstVideoFrameState * gst_base_video_codec_new_frame (GstBaseVideoCodec *base_video_codec);
|
|
||||||
|
|
||||||
GstVideoFrameState * gst_video_frame_state_ref (GstVideoFrameState * frame);
|
|
||||||
void gst_video_frame_state_unref (GstVideoFrameState * frame);
|
|
||||||
|
|
||||||
G_END_DECLS
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,291 +0,0 @@
|
||||||
/* GStreamer
|
|
||||||
* Copyright (C) 2008 David Schleef <ds@schleef.org>
|
|
||||||
* Copyright (C) 2011 Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>.
|
|
||||||
* Copyright (C) 2011 Nokia Corporation. All rights reserved.
|
|
||||||
* Contact: Stefan Kost <stefan.kost@nokia.com>
|
|
||||||
*
|
|
||||||
* 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:
|
|
||||||
*
|
|
||||||
* Returned while parsing to indicate more data is needed.
|
|
||||||
**/
|
|
||||||
#define GST_BASE_VIDEO_DECODER_FLOW_NEED_DATA GST_FLOW_CUSTOM_SUCCESS
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GST_BASE_VIDEO_DECODER_FLOW_DROPPED:
|
|
||||||
*
|
|
||||||
* Returned when the event/buffer should be dropped.
|
|
||||||
*/
|
|
||||||
#define GST_BASE_VIDEO_DECODER_FLOW_DROPPED GST_FLOW_CUSTOM_SUCCESS_1
|
|
||||||
|
|
||||||
typedef struct _GstBaseVideoDecoder GstBaseVideoDecoder;
|
|
||||||
typedef struct _GstBaseVideoDecoderClass GstBaseVideoDecoderClass;
|
|
||||||
|
|
||||||
|
|
||||||
/* do not use this one, use macro below */
|
|
||||||
GstFlowReturn _gst_base_video_decoder_error (GstBaseVideoDecoder *dec, gint weight,
|
|
||||||
GQuark domain, gint code,
|
|
||||||
gchar *txt, gchar *debug,
|
|
||||||
const gchar *file, const gchar *function,
|
|
||||||
gint line);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GST_BASE_VIDEO_DECODER_ERROR:
|
|
||||||
* @el: the base video decoder element that generates the error
|
|
||||||
* @weight: element defined weight of the error, added to error count
|
|
||||||
* @domain: like CORE, LIBRARY, RESOURCE or STREAM (see #gstreamer-GstGError)
|
|
||||||
* @code: error code defined for that domain (see #gstreamer-GstGError)
|
|
||||||
* @text: the message to display (format string and args enclosed in
|
|
||||||
* parentheses)
|
|
||||||
* @debug: debugging information for the message (format string and args
|
|
||||||
* enclosed in parentheses)
|
|
||||||
* @ret: variable to receive return value
|
|
||||||
*
|
|
||||||
* Utility function that video decoder elements can use in case they encountered
|
|
||||||
* a data processing error that may be fatal for the current "data unit" but
|
|
||||||
* need not prevent subsequent decoding. Such errors are counted and if there
|
|
||||||
* are too many, as configured in the context's max_errors, the pipeline will
|
|
||||||
* post an error message and the application will be requested to stop further
|
|
||||||
* media processing. Otherwise, it is considered a "glitch" and only a warning
|
|
||||||
* is logged. In either case, @ret is set to the proper value to
|
|
||||||
* return to upstream/caller (indicating either GST_FLOW_ERROR or GST_FLOW_OK).
|
|
||||||
*/
|
|
||||||
#define GST_BASE_VIDEO_DECODER_ERROR(el, w, domain, code, text, debug, ret) \
|
|
||||||
G_STMT_START { \
|
|
||||||
gchar *__txt = _gst_element_error_printf text; \
|
|
||||||
gchar *__dbg = _gst_element_error_printf debug; \
|
|
||||||
GstBaseVideoDecoder *dec = GST_BASE_VIDEO_DECODER (el); \
|
|
||||||
ret = _gst_base_video_decoder_error (dec, w, GST_ ## domain ## _ERROR, \
|
|
||||||
GST_ ## domain ## _ERROR_ ## code, __txt, __dbg, __FILE__, \
|
|
||||||
GST_FUNCTION, __LINE__); \
|
|
||||||
} G_STMT_END
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GstBaseVideoDecoder:
|
|
||||||
*
|
|
||||||
* The opaque #GstBaseVideoDecoder data structure.
|
|
||||||
*/
|
|
||||||
struct _GstBaseVideoDecoder
|
|
||||||
{
|
|
||||||
/*< private >*/
|
|
||||||
GstBaseVideoCodec base_video_codec;
|
|
||||||
|
|
||||||
/*< protected >*/
|
|
||||||
gboolean sink_clipping;
|
|
||||||
gboolean do_byte_time;
|
|
||||||
gboolean packetized;
|
|
||||||
gint max_errors;
|
|
||||||
|
|
||||||
/* parse tracking */
|
|
||||||
/* input data */
|
|
||||||
GstAdapter *input_adapter;
|
|
||||||
/* assembles current frame */
|
|
||||||
GstAdapter *output_adapter;
|
|
||||||
|
|
||||||
/*< private >*/
|
|
||||||
/* FIXME move to real private part ?
|
|
||||||
* (and introduce a context ?) */
|
|
||||||
/* ... being tracked here;
|
|
||||||
* only available during parsing */
|
|
||||||
/* FIXME remove and add parameter to method */
|
|
||||||
GstVideoFrameState *current_frame;
|
|
||||||
/* events that should apply to the current frame */
|
|
||||||
GList *current_frame_events;
|
|
||||||
/* relative offset of input data */
|
|
||||||
guint64 input_offset;
|
|
||||||
/* relative offset of frame */
|
|
||||||
guint64 frame_offset;
|
|
||||||
/* tracking ts and offsets */
|
|
||||||
GList *timestamps;
|
|
||||||
/* whether parsing is in sync */
|
|
||||||
gboolean have_sync;
|
|
||||||
|
|
||||||
/* maybe sort-of protected ? */
|
|
||||||
|
|
||||||
/* combine to yield (presentation) ts */
|
|
||||||
GstClockTime timestamp_offset;
|
|
||||||
int field_index;
|
|
||||||
|
|
||||||
/* last outgoing ts */
|
|
||||||
GstClockTime last_timestamp;
|
|
||||||
gint error_count;
|
|
||||||
|
|
||||||
/* reverse playback */
|
|
||||||
/* collect input */
|
|
||||||
GList *gather;
|
|
||||||
/* to-be-parsed */
|
|
||||||
GList *parse;
|
|
||||||
/* collected parsed frames */
|
|
||||||
GList *parse_gather;
|
|
||||||
/* frames to be handled == decoded */
|
|
||||||
GList *decode;
|
|
||||||
/* collected output */
|
|
||||||
GList *queued;
|
|
||||||
gboolean process;
|
|
||||||
|
|
||||||
/* no comment ... */
|
|
||||||
guint64 base_picture_number;
|
|
||||||
int reorder_depth;
|
|
||||||
int distance_from_sync;
|
|
||||||
|
|
||||||
/* Raw video bufferpool */
|
|
||||||
GstBufferPool *pool;
|
|
||||||
/* Indicates whether downstream can handle
|
|
||||||
* GST_META_API_VIDEO_CROP */
|
|
||||||
gboolean use_cropping;
|
|
||||||
|
|
||||||
/* qos messages: frames dropped/processed */
|
|
||||||
guint dropped;
|
|
||||||
guint processed;
|
|
||||||
|
|
||||||
/* FIXME before moving to base */
|
|
||||||
void *padding[GST_PADDING_LARGE];
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GstBaseVideoDecoderClass:
|
|
||||||
* @start: Optional.
|
|
||||||
* Called when the element starts processing.
|
|
||||||
* Allows opening external resources.
|
|
||||||
* @stop: Optional.
|
|
||||||
* Called when the element stops processing.
|
|
||||||
* Allows closing external resources.
|
|
||||||
* @set_format: Notifies subclass of incoming data format (caps).
|
|
||||||
* @scan_for_sync: Optional.
|
|
||||||
* Allows subclass to obtain sync for subsequent parsing
|
|
||||||
* by custom means (above an beyond scanning for specific
|
|
||||||
* marker and mask).
|
|
||||||
* @parse_data: Required for non-packetized input.
|
|
||||||
* Allows chopping incoming data into manageable units (frames)
|
|
||||||
* for subsequent decoding.
|
|
||||||
* @reset: Optional.
|
|
||||||
* Allows subclass (codec) to perform post-seek semantics reset.
|
|
||||||
* @handle_frame: Provides input data frame to subclass.
|
|
||||||
* @finish: Optional.
|
|
||||||
* Called to request subclass to dispatch any pending remaining
|
|
||||||
* data (e.g. at EOS).
|
|
||||||
*
|
|
||||||
* Subclasses can override any of the available virtual methods or not, as
|
|
||||||
* needed. At minimum @handle_frame needs to be overridden, and @set_format
|
|
||||||
* and likely as well. If non-packetized input is supported or expected,
|
|
||||||
* @parse needs to be overridden as well.
|
|
||||||
*/
|
|
||||||
struct _GstBaseVideoDecoderClass
|
|
||||||
{
|
|
||||||
/*< private >*/
|
|
||||||
GstBaseVideoCodecClass base_video_codec_class;
|
|
||||||
|
|
||||||
/*< public >*/
|
|
||||||
gboolean (*start) (GstBaseVideoDecoder *coder);
|
|
||||||
|
|
||||||
gboolean (*stop) (GstBaseVideoDecoder *coder);
|
|
||||||
|
|
||||||
int (*scan_for_sync) (GstBaseVideoDecoder *decoder, gboolean at_eos,
|
|
||||||
int offset, int n);
|
|
||||||
|
|
||||||
GstFlowReturn (*parse_data) (GstBaseVideoDecoder *decoder, gboolean at_eos);
|
|
||||||
|
|
||||||
gboolean (*set_format) (GstBaseVideoDecoder *coder, GstVideoState * state);
|
|
||||||
|
|
||||||
gboolean (*reset) (GstBaseVideoDecoder *coder);
|
|
||||||
|
|
||||||
GstFlowReturn (*finish) (GstBaseVideoDecoder *coder);
|
|
||||||
|
|
||||||
GstFlowReturn (*handle_frame) (GstBaseVideoDecoder *coder, GstVideoFrameState *frame);
|
|
||||||
|
|
||||||
|
|
||||||
/*< private >*/
|
|
||||||
guint32 capture_mask;
|
|
||||||
guint32 capture_pattern;
|
|
||||||
|
|
||||||
/* FIXME before moving to base */
|
|
||||||
void *padding[GST_PADDING_LARGE];
|
|
||||||
};
|
|
||||||
|
|
||||||
void gst_base_video_decoder_class_set_capture_pattern (GstBaseVideoDecoderClass *base_video_decoder_class,
|
|
||||||
guint32 mask, guint32 pattern);
|
|
||||||
|
|
||||||
GstVideoFrameState *gst_base_video_decoder_get_frame (GstBaseVideoDecoder *coder,
|
|
||||||
int frame_number);
|
|
||||||
GstVideoFrameState *gst_base_video_decoder_get_oldest_frame (GstBaseVideoDecoder *coder);
|
|
||||||
|
|
||||||
void gst_base_video_decoder_add_to_frame (GstBaseVideoDecoder *base_video_decoder,
|
|
||||||
int n_bytes);
|
|
||||||
void gst_base_video_decoder_lost_sync (GstBaseVideoDecoder *base_video_decoder);
|
|
||||||
GstFlowReturn gst_base_video_decoder_have_frame (GstBaseVideoDecoder *base_video_decoder);
|
|
||||||
|
|
||||||
void gst_base_video_decoder_set_sync_point (GstBaseVideoDecoder *base_video_decoder);
|
|
||||||
gboolean gst_base_video_decoder_set_src_caps (GstBaseVideoDecoder *base_video_decoder);
|
|
||||||
GstBuffer *gst_base_video_decoder_alloc_src_buffer (GstBaseVideoDecoder * base_video_decoder);
|
|
||||||
GstFlowReturn gst_base_video_decoder_alloc_src_frame (GstBaseVideoDecoder *base_video_decoder,
|
|
||||||
GstVideoFrameState *frame);
|
|
||||||
GstVideoState *gst_base_video_decoder_get_state (GstBaseVideoDecoder *base_video_decoder);
|
|
||||||
GstClockTimeDiff gst_base_video_decoder_get_max_decode_time (
|
|
||||||
GstBaseVideoDecoder *base_video_decoder,
|
|
||||||
GstVideoFrameState *frame);
|
|
||||||
GstFlowReturn gst_base_video_decoder_finish_frame (GstBaseVideoDecoder *base_video_decoder,
|
|
||||||
GstVideoFrameState *frame);
|
|
||||||
GstFlowReturn gst_base_video_decoder_drop_frame (GstBaseVideoDecoder *dec,
|
|
||||||
GstVideoFrameState *frame);
|
|
||||||
|
|
||||||
GType gst_base_video_decoder_get_type (void);
|
|
||||||
|
|
||||||
G_END_DECLS
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,185 +0,0 @@
|
||||||
/* GStreamer
|
|
||||||
* Copyright (C) 2008 David Schleef <ds@schleef.org>
|
|
||||||
* Copyright (C) 2011 Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>.
|
|
||||||
* Copyright (C) 2011 Nokia Corporation. All rights reserved.
|
|
||||||
* Contact: Stefan Kost <stefan.kost@nokia.com>
|
|
||||||
*
|
|
||||||
* 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_ENCODER_H_
|
|
||||||
#define _GST_BASE_VIDEO_ENCODER_H_
|
|
||||||
|
|
||||||
#ifndef GST_USE_UNSTABLE_API
|
|
||||||
#warning "GstBaseVideoEncoder 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_ENCODER \
|
|
||||||
(gst_base_video_encoder_get_type())
|
|
||||||
#define GST_BASE_VIDEO_ENCODER(obj) \
|
|
||||||
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_BASE_VIDEO_ENCODER,GstBaseVideoEncoder))
|
|
||||||
#define GST_BASE_VIDEO_ENCODER_CLASS(klass) \
|
|
||||||
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_BASE_VIDEO_ENCODER,GstBaseVideoEncoderClass))
|
|
||||||
#define GST_BASE_VIDEO_ENCODER_GET_CLASS(obj) \
|
|
||||||
(G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_BASE_VIDEO_ENCODER,GstBaseVideoEncoderClass))
|
|
||||||
#define GST_IS_BASE_VIDEO_ENCODER(obj) \
|
|
||||||
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_BASE_VIDEO_ENCODER))
|
|
||||||
#define GST_IS_BASE_VIDEO_ENCODER_CLASS(obj) \
|
|
||||||
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_BASE_VIDEO_ENCODER))
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GST_BASE_VIDEO_ENCODER_SINK_NAME:
|
|
||||||
*
|
|
||||||
* The name of the templates for the sink pad.
|
|
||||||
*/
|
|
||||||
#define GST_BASE_VIDEO_ENCODER_SINK_NAME "sink"
|
|
||||||
/**
|
|
||||||
* GST_BASE_VIDEO_ENCODER_SRC_NAME:
|
|
||||||
*
|
|
||||||
* The name of the templates for the source pad.
|
|
||||||
*/
|
|
||||||
#define GST_BASE_VIDEO_ENCODER_SRC_NAME "src"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GST_BASE_VIDEO_ENCODER_FLOW_DROPPED:
|
|
||||||
*
|
|
||||||
* Returned when the event/buffer should be dropped.
|
|
||||||
*/
|
|
||||||
#define GST_BASE_VIDEO_ENCODER_FLOW_DROPPED GST_FLOW_CUSTOM_SUCCESS_1
|
|
||||||
|
|
||||||
typedef struct _GstBaseVideoEncoder GstBaseVideoEncoder;
|
|
||||||
typedef struct _GstBaseVideoEncoderClass GstBaseVideoEncoderClass;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GstBaseVideoEncoder:
|
|
||||||
*
|
|
||||||
* The opaque #GstBaseVideoEncoder data structure.
|
|
||||||
*/
|
|
||||||
struct _GstBaseVideoEncoder
|
|
||||||
{
|
|
||||||
/*< private >*/
|
|
||||||
GstBaseVideoCodec base_video_codec;
|
|
||||||
|
|
||||||
/*< protected >*/
|
|
||||||
gboolean sink_clipping;
|
|
||||||
|
|
||||||
guint64 presentation_frame_number;
|
|
||||||
int distance_from_sync;
|
|
||||||
|
|
||||||
/*< private >*/
|
|
||||||
/* FIXME move to real private part ?
|
|
||||||
* (and introduce a context ?) */
|
|
||||||
gboolean drained;
|
|
||||||
gboolean at_eos;
|
|
||||||
|
|
||||||
gint64 min_latency;
|
|
||||||
gint64 max_latency;
|
|
||||||
|
|
||||||
GList *current_frame_events;
|
|
||||||
|
|
||||||
GstBuffer *headers;
|
|
||||||
|
|
||||||
GList *force_key_unit; /* List of pending forced keyunits */
|
|
||||||
|
|
||||||
void *padding[GST_PADDING_LARGE];
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GstBaseVideoEncoderClass:
|
|
||||||
* @start: Optional.
|
|
||||||
* Called when the element starts processing.
|
|
||||||
* Allows opening external resources.
|
|
||||||
* @stop: Optional.
|
|
||||||
* Called when the element stops processing.
|
|
||||||
* Allows closing external resources.
|
|
||||||
* @set_format: Optional.
|
|
||||||
* Notifies subclass of incoming data format.
|
|
||||||
* GstVideoInfo fields have already been
|
|
||||||
* set according to provided caps.
|
|
||||||
* @handle_frame: Provides input frame to subclass.
|
|
||||||
* @reset: Optional.
|
|
||||||
* Allows subclass (codec) to perform post-seek semantics reset.
|
|
||||||
* @finish: Optional.
|
|
||||||
* Called to request subclass to dispatch any pending remaining
|
|
||||||
* data (e.g. at EOS).
|
|
||||||
* @shape_output: Optional.
|
|
||||||
* Allows subclass to push frame downstream in whatever
|
|
||||||
* shape or form it deems appropriate. If not provided,
|
|
||||||
* provided encoded frame data is simply pushed downstream.
|
|
||||||
* @event: Optional.
|
|
||||||
* Event handler on the sink pad. This function should return
|
|
||||||
* TRUE if the event was handled and should be discarded
|
|
||||||
* (i.e. not unref'ed).
|
|
||||||
*
|
|
||||||
* Subclasses can override any of the available virtual methods or not, as
|
|
||||||
* needed. At minimum @handle_frame needs to be overridden, and @set_format
|
|
||||||
* and @get_caps are likely needed as well.
|
|
||||||
*/
|
|
||||||
struct _GstBaseVideoEncoderClass
|
|
||||||
{
|
|
||||||
/*< private >*/
|
|
||||||
GstBaseVideoCodecClass base_video_codec_class;
|
|
||||||
|
|
||||||
/*< public >*/
|
|
||||||
/* virtual methods for subclasses */
|
|
||||||
|
|
||||||
gboolean (*start) (GstBaseVideoEncoder *coder);
|
|
||||||
|
|
||||||
gboolean (*stop) (GstBaseVideoEncoder *coder);
|
|
||||||
|
|
||||||
gboolean (*set_format) (GstBaseVideoEncoder *coder,
|
|
||||||
GstVideoInfo *info);
|
|
||||||
|
|
||||||
GstFlowReturn (*handle_frame) (GstBaseVideoEncoder *coder,
|
|
||||||
GstVideoFrameState *frame);
|
|
||||||
|
|
||||||
gboolean (*reset) (GstBaseVideoEncoder *coder);
|
|
||||||
GstFlowReturn (*finish) (GstBaseVideoEncoder *coder);
|
|
||||||
|
|
||||||
GstFlowReturn (*shape_output) (GstBaseVideoEncoder *coder,
|
|
||||||
GstVideoFrameState *frame);
|
|
||||||
|
|
||||||
gboolean (*event) (GstBaseVideoEncoder *coder,
|
|
||||||
GstEvent *event);
|
|
||||||
|
|
||||||
/*< private >*/
|
|
||||||
/* FIXME before moving to base */
|
|
||||||
gpointer _gst_reserved[GST_PADDING_LARGE];
|
|
||||||
};
|
|
||||||
|
|
||||||
GType gst_base_video_encoder_get_type (void);
|
|
||||||
|
|
||||||
const GstVideoState* gst_base_video_encoder_get_state (GstBaseVideoEncoder *base_video_encoder);
|
|
||||||
|
|
||||||
GstVideoFrameState* gst_base_video_encoder_get_oldest_frame (GstBaseVideoEncoder *coder);
|
|
||||||
GstFlowReturn gst_base_video_encoder_finish_frame (GstBaseVideoEncoder *base_video_encoder,
|
|
||||||
GstVideoFrameState *frame);
|
|
||||||
|
|
||||||
void gst_base_video_encoder_set_latency (GstBaseVideoEncoder *base_video_encoder,
|
|
||||||
GstClockTime min_latency, GstClockTime max_latency);
|
|
||||||
void gst_base_video_encoder_set_latency_fields (GstBaseVideoEncoder *base_video_encoder,
|
|
||||||
int n_fields);
|
|
||||||
void gst_base_video_encoder_set_headers (GstBaseVideoEncoder *base_video_encoder,
|
|
||||||
GstBuffer *headers);
|
|
||||||
G_END_DECLS
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -1,159 +0,0 @@
|
||||||
/* 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
|
|
||||||
|
|
||||||
|
|
||||||
gboolean
|
|
||||||
gst_base_video_rawvideo_convert (GstVideoState * state,
|
|
||||||
GstFormat src_format, gint64 src_value,
|
|
||||||
GstFormat * dest_format, gint64 * dest_value)
|
|
||||||
{
|
|
||||||
gboolean res = FALSE;
|
|
||||||
|
|
||||||
g_return_val_if_fail (dest_format != NULL, FALSE);
|
|
||||||
g_return_val_if_fail (dest_value != NULL, FALSE);
|
|
||||||
|
|
||||||
if (src_format == *dest_format || src_value == 0 || src_value == -1) {
|
|
||||||
*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;
|
|
||||||
} else if (src_format == GST_FORMAT_TIME &&
|
|
||||||
*dest_format == GST_FORMAT_BYTES && state->fps_d != 0 &&
|
|
||||||
state->bytes_per_picture != 0) {
|
|
||||||
/* convert time to frames */
|
|
||||||
/* FIXME subtract segment time? */
|
|
||||||
*dest_value = gst_util_uint64_scale (src_value,
|
|
||||||
state->fps_n * state->bytes_per_picture, GST_SECOND * state->fps_d);
|
|
||||||
res = TRUE;
|
|
||||||
} else if (src_format == GST_FORMAT_BYTES &&
|
|
||||||
*dest_format == GST_FORMAT_TIME && state->fps_n != 0 &&
|
|
||||||
state->bytes_per_picture != 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 * state->bytes_per_picture);
|
|
||||||
res = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
gboolean
|
|
||||||
gst_base_video_encoded_video_convert (GstVideoState * state,
|
|
||||||
gint64 bytes, gint64 time, GstFormat src_format,
|
|
||||||
gint64 src_value, GstFormat * dest_format, gint64 * dest_value)
|
|
||||||
{
|
|
||||||
gboolean res = FALSE;
|
|
||||||
|
|
||||||
g_return_val_if_fail (dest_format != NULL, FALSE);
|
|
||||||
g_return_val_if_fail (dest_value != NULL, FALSE);
|
|
||||||
|
|
||||||
if (G_UNLIKELY (src_format == *dest_format || src_value == 0 ||
|
|
||||||
src_value == -1)) {
|
|
||||||
if (dest_value)
|
|
||||||
*dest_value = src_value;
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bytes <= 0 || time <= 0) {
|
|
||||||
GST_DEBUG ("not enough metadata yet to convert");
|
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (src_format) {
|
|
||||||
case GST_FORMAT_BYTES:
|
|
||||||
switch (*dest_format) {
|
|
||||||
case GST_FORMAT_TIME:
|
|
||||||
*dest_value = gst_util_uint64_scale (src_value, time, bytes);
|
|
||||||
res = TRUE;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
res = FALSE;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GST_FORMAT_TIME:
|
|
||||||
switch (*dest_format) {
|
|
||||||
case GST_FORMAT_BYTES:
|
|
||||||
*dest_value = gst_util_uint64_scale (src_value, bytes, time);
|
|
||||||
res = TRUE;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
res = FALSE;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
GST_DEBUG ("unhandled conversion from %d to %d", src_format,
|
|
||||||
*dest_format);
|
|
||||||
res = FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
exit:
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,46 +0,0 @@
|
||||||
/* 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 "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/video.h>
|
|
||||||
#include "gstbasevideocodec.h"
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
|
||||||
|
|
||||||
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,
|
|
||||||
gint64 bytes, gint64 time, 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);
|
|
||||||
|
|
||||||
G_END_DECLS
|
|
||||||
|
|
||||||
#endif
|
|
Loading…
Reference in a new issue