mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-17 03:35:21 +00:00
video: Base classes for video decoders and encoders
This commit is contained in:
parent
a22545134d
commit
f6cfd763e4
12 changed files with 5714 additions and 2 deletions
|
@ -228,6 +228,9 @@
|
|||
<xi:include href="xml/gstvideooverlaycomposition.xml" />
|
||||
<xi:include href="xml/gstvideofilter.xml" />
|
||||
<xi:include href="xml/gstvideosink.xml" />
|
||||
<xi:include href="xml/gstvideodecoder.xml" />
|
||||
<xi:include href="xml/gstvideoencoder.xml" />
|
||||
<xi:include href="xml/gstvideoutils.xml" />
|
||||
</chapter>
|
||||
</part>
|
||||
|
||||
|
|
|
@ -2302,6 +2302,7 @@ GST_VIDEO_FORMAT_INFO_IS_GRAY
|
|||
GST_VIDEO_FORMAT_INFO_IS_LE
|
||||
GST_VIDEO_FORMAT_INFO_IS_RGB
|
||||
GST_VIDEO_FORMAT_INFO_IS_YUV
|
||||
GST_VIDEO_FORMAT_INFO_IS_COMPLEX
|
||||
GST_VIDEO_FORMAT_INFO_NAME
|
||||
GST_VIDEO_FORMAT_INFO_N_COMPONENTS
|
||||
GST_VIDEO_FORMAT_INFO_N_PLANES
|
||||
|
@ -2509,6 +2510,123 @@ GST_IS_VIDEO_SINK_CLASS
|
|||
gst_video_sink_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>gstvideodecoder</FILE>
|
||||
<TITLE>GstVideoDecoder</TITLE>
|
||||
GST_VIDEO_DECODER_ERROR
|
||||
GST_VIDEO_DECODER_FLOW_DROPPED
|
||||
GST_VIDEO_DECODER_FLOW_NEED_DATA
|
||||
GST_VIDEO_DECODER_MAX_ERRORS
|
||||
GST_VIDEO_DECODER_SINK_NAME
|
||||
GST_VIDEO_DECODER_SINK_PAD
|
||||
GST_VIDEO_DECODER_SRC_NAME
|
||||
GST_VIDEO_DECODER_SRC_PAD
|
||||
GST_VIDEO_DECODER_STREAM_LOCK
|
||||
GST_VIDEO_DECODER_STREAM_UNLOCK
|
||||
GST_VIDEO_DECODER_INPUT_SEGMENT
|
||||
GST_VIDEO_DECODER_OUTPUT_SEGMENT
|
||||
GstVideoDecoder
|
||||
GstVideoDecoderClass
|
||||
gst_video_decoder_add_to_frame
|
||||
gst_video_decoder_alloc_output_buffer
|
||||
gst_video_decoder_alloc_output_frame
|
||||
gst_video_decoder_drop_frame
|
||||
gst_video_decoder_finish_frame
|
||||
gst_video_decoder_get_frame
|
||||
gst_video_decoder_get_max_decode_time
|
||||
gst_video_decoder_get_max_errors
|
||||
gst_video_decoder_get_oldest_frame
|
||||
gst_video_decoder_get_packetized
|
||||
gst_video_decoder_have_frame
|
||||
gst_video_decoder_get_latency
|
||||
gst_video_decoder_set_latency
|
||||
gst_video_decoder_get_estimate_rate
|
||||
gst_video_decoder_get_output_state
|
||||
gst_video_decoder_set_estimate_rate
|
||||
gst_video_decoder_set_output_state
|
||||
gst_video_decoder_set_max_errors
|
||||
gst_video_decoder_set_packetized
|
||||
<SUBSECTION Standard>
|
||||
GST_IS_VIDEO_DECODER
|
||||
GST_IS_VIDEO_DECODER_CLASS
|
||||
GST_TYPE_VIDEO_DECODER
|
||||
GST_VIDEO_DECODER
|
||||
GST_VIDEO_DECODER_CLASS
|
||||
GST_VIDEO_DECODER_GET_CLASS
|
||||
GstVideoDecoderPrivate
|
||||
gst_video_decoder_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>gstvideoencoder</FILE>
|
||||
<TITLE>GstVideoEncoder</TITLE>
|
||||
GST_VIDEO_ENCODER_CAST
|
||||
GST_VIDEO_ENCODER_FLOW_DROPPED
|
||||
GST_VIDEO_ENCODER_FLOW_NEED_DATA
|
||||
GST_VIDEO_ENCODER_SINK_NAME
|
||||
GST_VIDEO_ENCODER_SINK_PAD
|
||||
GST_VIDEO_ENCODER_SRC_NAME
|
||||
GST_VIDEO_ENCODER_SRC_PAD
|
||||
GST_VIDEO_ENCODER_INPUT_SEGMENT
|
||||
GST_VIDEO_ENCODER_OUTPUT_SEGMENT
|
||||
GST_VIDEO_ENCODER_STREAM_LOCK
|
||||
GST_VIDEO_ENCODER_STREAM_UNLOCK
|
||||
GstVideoEncoder
|
||||
GstVideoEncoderClass
|
||||
gst_video_encoder_finish_frame
|
||||
gst_video_encoder_get_frame
|
||||
gst_video_encoder_get_oldest_frame
|
||||
gst_video_encoder_set_headers
|
||||
gst_video_encoder_get_latency
|
||||
gst_video_encoder_set_latency
|
||||
gst_video_encoder_get_discont
|
||||
gst_video_encoder_set_discont
|
||||
gst_video_encoder_set_output_state
|
||||
gst_video_encoder_get_output_state
|
||||
gst_video_encoder_proxy_getcaps
|
||||
<SUBSECTION Standard>
|
||||
GST_IS_VIDEO_ENCODER
|
||||
GST_IS_VIDEO_ENCODER_CLASS
|
||||
GST_TYPE_VIDEO_ENCODER
|
||||
GST_VIDEO_ENCODER
|
||||
GST_VIDEO_ENCODER_CLASS
|
||||
GST_VIDEO_ENCODER_GET_CLASS
|
||||
GstVideoEncoderPrivate
|
||||
gst_video_encoder_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>gstvideoutils</FILE>
|
||||
GstVideoCodecFrame
|
||||
GstVideoCodecFrameFlags
|
||||
GST_VIDEO_CODEC_FRAME_FLAGS
|
||||
GST_VIDEO_CODEC_FRAME_FLAG_IS_SET
|
||||
GST_VIDEO_CODEC_FRAME_FLAG_SET
|
||||
GST_VIDEO_CODEC_FRAME_FLAG_UNSET
|
||||
GST_VIDEO_CODEC_FRAME_IS_DECODE_ONLY
|
||||
GST_VIDEO_CODEC_FRAME_IS_FORCE_KEYFRAME
|
||||
GST_VIDEO_CODEC_FRAME_IS_FORCE_KEYFRAME_HEADERS
|
||||
GST_VIDEO_CODEC_FRAME_IS_SYNC_POINT
|
||||
GST_VIDEO_CODEC_FRAME_SET_DECODE_ONLY
|
||||
GST_VIDEO_CODEC_FRAME_SET_FORCE_KEYFRAME
|
||||
GST_VIDEO_CODEC_FRAME_SET_FORCE_KEYFRAME_HEADERS
|
||||
GST_VIDEO_CODEC_FRAME_SET_SYNC_POINT
|
||||
GST_VIDEO_CODEC_FRAME_UNSET_FORCE_KEYFRAME
|
||||
GST_VIDEO_CODEC_FRAME_UNSET_FORCE_KEYFRAME_HEADERS
|
||||
GST_VIDEO_CODEC_FRAME_UNSET_SYNC_POINT
|
||||
gst_video_codec_frame_ref
|
||||
gst_video_codec_frame_unref
|
||||
gst_video_codec_frame_set_hook
|
||||
GstVideoCodecState
|
||||
gst_video_codec_state_ref
|
||||
gst_video_codec_state_unref
|
||||
<SUBSECTION Standard>
|
||||
GST_TYPE_VIDEO_CODEC_FRAME
|
||||
GST_TYPE_VIDEO_CODEC_STATE
|
||||
gst_video_codec_frame_get_type
|
||||
gst_video_codec_state_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>gstdiscoverer</FILE>
|
||||
<INCLUDE>gst/pbutils/pbutils.h</INCLUDE>
|
||||
|
|
|
@ -63,6 +63,13 @@ gst_video_sink_get_type
|
|||
#include <gst/video/video-overlay-composition.h>
|
||||
gst_video_overlay_rectangle_get_type
|
||||
gst_video_overlay_composition_get_type
|
||||
#include <gst/video/gstvideodecoder.h>
|
||||
gst_video_decoder_get_type
|
||||
#include <gst/video/gstvideoencoder.h>
|
||||
gst_video_encoder_get_type
|
||||
#include <gst/video/gstvideoutils.h>
|
||||
gst_video_codec_frame_get_type
|
||||
gst_video_codec_state_get_type
|
||||
|
||||
#include <gst/pbutils/pbutils.h>
|
||||
gst_discoverer_get_type
|
||||
|
|
|
@ -20,13 +20,17 @@ CLEANFILES = $(BUILT_SOURCES)
|
|||
# video-blend.h should be disted but not installed into the includedir
|
||||
libgstvideo_@GST_MAJORMINOR@_la_SOURCES = \
|
||||
video.c gstvideosink.c gstvideofilter.c convertframe.c \
|
||||
video-blend.c video-blend.h video-overlay-composition.c
|
||||
video-blend.c video-blend.h video-overlay-composition.c \
|
||||
gstvideodecoder.c gstvideoencoder.c \
|
||||
gstvideoutils.c
|
||||
nodist_libgstvideo_@GST_MAJORMINOR@_la_SOURCES = \
|
||||
$(built_sources) $(built_headers) \
|
||||
$(ORC_NODIST_SOURCES)
|
||||
libgstvideo_@GST_MAJORMINOR@includedir = $(includedir)/gstreamer-@GST_MAJORMINOR@/gst/video
|
||||
libgstvideo_@GST_MAJORMINOR@include_HEADERS = \
|
||||
video.h gstvideosink.h gstvideofilter.h video-overlay-composition.h
|
||||
video.h gstvideosink.h gstvideofilter.h video-overlay-composition.h \
|
||||
gstvideodecoder.h gstvideoencoder.h \
|
||||
gstvideoutils.h
|
||||
nodist_libgstvideo_@GST_MAJORMINOR@include_HEADERS = $(built_headers)
|
||||
|
||||
libgstvideo_@GST_MAJORMINOR@_la_CFLAGS = \
|
||||
|
@ -63,6 +67,7 @@ GstVideo-@GST_MAJORMINOR@.gir: $(INTROSPECTION_SCANNER) libgstvideo-@GST_MAJORMI
|
|||
$(INTROSPECTION_SCANNER) -v --namespace GstVideo \
|
||||
--nsversion=@GST_MAJORMINOR@ \
|
||||
--strip-prefix=Gst \
|
||||
--warn-all \
|
||||
$(gir_cincludes) \
|
||||
-I$(top_srcdir)/gst-libs \
|
||||
-I$(top_builddir)/gst-libs \
|
||||
|
|
51
gst-libs/gst/video/TODO
Normal file
51
gst-libs/gst/video/TODO
Normal file
|
@ -0,0 +1,51 @@
|
|||
Base Video Classes TODO
|
||||
|
||||
Main goal:
|
||||
|
||||
Make the video encoder/decoder base classes more consistent with the
|
||||
other GStreamer API, especially with the audio encoder/decoder base
|
||||
classes.
|
||||
|
||||
API:
|
||||
|
||||
The API should be named similar, the base classes should be used
|
||||
similar by the sub-classes, the behaviour of the base classes should
|
||||
be similar.
|
||||
Currently there are many, mostly small, differences between the audio
|
||||
and video base classes API. Things like GstVideoState should be merged
|
||||
with the stuff we have in 0.11 to make the API the same in 0.11 and
|
||||
0.10 as far as possible, things like GstVideoInfo might make sense to
|
||||
be backported (at least partially).
|
||||
|
||||
|
||||
Specifics:
|
||||
* Use a GInstancePrivate for extensability.
|
||||
|
||||
* Try to move more common video objects to video.[ch]
|
||||
|
||||
Known bugs:
|
||||
https://bugzilla.gnome.org/show_bug.cgi?id=664127
|
||||
[basevideodecoder] Add separate drain vfunc and differentiate
|
||||
between hard/soft reset in reset vfunc
|
||||
|
||||
https://bugzilla.gnome.org/show_bug.cgi?id=660770
|
||||
Doesn't support handling of "partial" frames
|
||||
|
||||
https://bugzilla.gnome.org/show_bug.cgi?id=654294
|
||||
Impossible to flush pending frames in ::set_format
|
||||
|
||||
https://bugzilla.gnome.org/show_bug.cgi?id=658241
|
||||
add API to handle QoS events and dropping logic
|
||||
|
||||
https://bugzilla.gnome.org/show_bug.cgi?id=667653
|
||||
Autodetect multicore/multithread processors
|
||||
|
||||
https://bugzilla.gnome.org/show_bug.cgi?id=617021
|
||||
Add support for QoS messages to -bad decoders and other elements
|
||||
|
||||
|
||||
Peripheral issues
|
||||
https://bugzilla.gnome.org/show_bug.cgi?id=663262
|
||||
theoraenc: spurious encoder resets due to unstable upstream
|
||||
timestamps cause quality issues
|
||||
=> Investigate how to specify/handle variable framerates.
|
2696
gst-libs/gst/video/gstvideodecoder.c
Normal file
2696
gst-libs/gst/video/gstvideodecoder.c
Normal file
File diff suppressed because it is too large
Load diff
369
gst-libs/gst/video/gstvideodecoder.h
Normal file
369
gst-libs/gst/video/gstvideodecoder.h
Normal file
|
@ -0,0 +1,369 @@
|
|||
/* 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>
|
||||
* Copyright (C) 2012 Collabora Ltd.
|
||||
* Author : Edward Hervey <edward@collabora.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_VIDEO_DECODER_H_
|
||||
#define _GST_VIDEO_DECODER_H_
|
||||
|
||||
#include <gst/base/gstadapter.h>
|
||||
#include <gst/video/gstvideoutils.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GST_TYPE_VIDEO_DECODER \
|
||||
(gst_video_decoder_get_type())
|
||||
#define GST_VIDEO_DECODER(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_VIDEO_DECODER,GstVideoDecoder))
|
||||
#define GST_VIDEO_DECODER_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_VIDEO_DECODER,GstVideoDecoderClass))
|
||||
#define GST_VIDEO_DECODER_GET_CLASS(obj) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_VIDEO_DECODER,GstVideoDecoderClass))
|
||||
#define GST_IS_VIDEO_DECODER(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_VIDEO_DECODER))
|
||||
#define GST_IS_VIDEO_DECODER_CLASS(obj) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_VIDEO_DECODER))
|
||||
|
||||
/**
|
||||
* GST_VIDEO_DECODER_SINK_NAME:
|
||||
*
|
||||
* The name of the templates for the sink pad.
|
||||
*
|
||||
* Since: 0.10.36
|
||||
*/
|
||||
#define GST_VIDEO_DECODER_SINK_NAME "sink"
|
||||
/**
|
||||
* GST_VIDEO_DECODER_SRC_NAME:
|
||||
*
|
||||
* The name of the templates for the source pad.
|
||||
*
|
||||
* Since: 0.10.36
|
||||
*/
|
||||
#define GST_VIDEO_DECODER_SRC_NAME "src"
|
||||
|
||||
/**
|
||||
* GST_VIDEO_DECODER_SRC_PAD:
|
||||
* @obj: a #GstVideoDecoder
|
||||
*
|
||||
* Gives the pointer to the source #GstPad object of the element.
|
||||
*
|
||||
* Since: 0.10.36
|
||||
*/
|
||||
#define GST_VIDEO_DECODER_SRC_PAD(obj) (((GstVideoDecoder *) (obj))->srcpad)
|
||||
|
||||
/**
|
||||
* GST_VIDEO_DECODER_SINK_PAD:
|
||||
* @obj: a #GstVideoDecoder
|
||||
*
|
||||
* Gives the pointer to the sink #GstPad object of the element.
|
||||
*
|
||||
* Since: 0.10.36
|
||||
*/
|
||||
#define GST_VIDEO_DECODER_SINK_PAD(obj) (((GstVideoDecoder *) (obj))->sinkpad)
|
||||
/**
|
||||
* GST_VIDEO_DECODER_FLOW_NEED_DATA:
|
||||
*
|
||||
* Returned while parsing to indicate more data is needed.
|
||||
*
|
||||
* Since: 0.10.36
|
||||
**/
|
||||
#define GST_VIDEO_DECODER_FLOW_NEED_DATA GST_FLOW_CUSTOM_SUCCESS
|
||||
|
||||
/**
|
||||
* GST_VIDEO_DECODER_FLOW_DROPPED:
|
||||
*
|
||||
* Returned when the event/buffer should be dropped.
|
||||
*
|
||||
* Since: 0.10.36
|
||||
*/
|
||||
#define GST_VIDEO_DECODER_FLOW_DROPPED GST_FLOW_CUSTOM_SUCCESS_1
|
||||
|
||||
/**
|
||||
* GST_VIDEO_DECODER_INPUT_SEGMENT:
|
||||
* @obj: base decoder instance
|
||||
*
|
||||
* Gives the segment of the element.
|
||||
*
|
||||
* Since: 0.10.36
|
||||
*/
|
||||
#define GST_VIDEO_DECODER_INPUT_SEGMENT(obj) (GST_VIDEO_DECODER_CAST (obj)->input_segment)
|
||||
|
||||
/**
|
||||
* GST_VIDEO_DECODER_OUTPUT_SEGMENT:
|
||||
* @obj: base decoder instance
|
||||
*
|
||||
* Gives the segment of the element.
|
||||
*
|
||||
* Since: 0.10.36
|
||||
*/
|
||||
#define GST_VIDEO_DECODER_OUTPUT_SEGMENT(obj) (GST_VIDEO_DECODER_CAST (obj)->output_segment)
|
||||
|
||||
/**
|
||||
* GST_VIDEO_DECODER_STREAM_LOCK:
|
||||
* @decoder: video decoder instance
|
||||
*
|
||||
* Obtain a lock to protect the decoder function from concurrent access.
|
||||
*
|
||||
* Since: 0.10.36
|
||||
*/
|
||||
#define GST_VIDEO_DECODER_STREAM_LOCK(decoder) g_static_rec_mutex_lock (&GST_VIDEO_DECODER (decoder)->stream_lock)
|
||||
|
||||
/**
|
||||
* GST_VIDEO_DECODER_STREAM_UNLOCK:
|
||||
* @decoder: video decoder instance
|
||||
*
|
||||
* Release the lock that protects the decoder function from concurrent access.
|
||||
*
|
||||
* Since: 0.10.36
|
||||
*/
|
||||
#define GST_VIDEO_DECODER_STREAM_UNLOCK(decoder) g_static_rec_mutex_unlock (&GST_VIDEO_DECODER (decoder)->stream_lock)
|
||||
|
||||
typedef struct _GstVideoDecoder GstVideoDecoder;
|
||||
typedef struct _GstVideoDecoderClass GstVideoDecoderClass;
|
||||
typedef struct _GstVideoDecoderPrivate GstVideoDecoderPrivate;
|
||||
|
||||
|
||||
/* do not use this one, use macro below */
|
||||
GstFlowReturn _gst_video_decoder_error (GstVideoDecoder *dec, gint weight,
|
||||
GQuark domain, gint code,
|
||||
gchar *txt, gchar *debug,
|
||||
const gchar *file, const gchar *function,
|
||||
gint line);
|
||||
|
||||
/**
|
||||
* GST_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).
|
||||
*
|
||||
* Since: 0.10.36
|
||||
*/
|
||||
#define GST_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; \
|
||||
GstVideoDecoder *dec = GST_VIDEO_DECODER (el); \
|
||||
ret = _gst_video_decoder_error (dec, w, GST_ ## domain ## _ERROR, \
|
||||
GST_ ## domain ## _ERROR_ ## code, __txt, __dbg, __FILE__, \
|
||||
GST_FUNCTION, __LINE__); \
|
||||
} G_STMT_END
|
||||
|
||||
/**
|
||||
* GST_VIDEO_DECODER_MAX_ERRORS:
|
||||
*
|
||||
* Default maximum number of errors tolerated before signaling error.
|
||||
*
|
||||
* Since: 0.10.36
|
||||
*/
|
||||
#define GST_VIDEO_DECODER_MAX_ERRORS 10
|
||||
|
||||
|
||||
/**
|
||||
* GstVideoDecoder:
|
||||
*
|
||||
* The opaque #GstVideoDecoder data structure.
|
||||
*
|
||||
* Since: 0.10.36
|
||||
*/
|
||||
struct _GstVideoDecoder
|
||||
{
|
||||
/*< 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 */
|
||||
GStaticRecMutex stream_lock;
|
||||
|
||||
/* MT-protected (with STREAM_LOCK) */
|
||||
GstSegment input_segment;
|
||||
GstSegment output_segment;
|
||||
|
||||
GstVideoDecoderPrivate *priv;
|
||||
|
||||
/* FIXME before moving to base */
|
||||
void *padding[GST_PADDING_LARGE];
|
||||
};
|
||||
|
||||
/**
|
||||
* GstVideoDecoderClass:
|
||||
* @open: Optional.
|
||||
* Called when the element changes to GST_STATE_READY.
|
||||
* Allows opening external resources.
|
||||
* @close: Optional.
|
||||
* Called when the element changes to GST_STATE_NULL.
|
||||
* Allows closing external resources.
|
||||
* @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).
|
||||
* @parse: Required for non-packetized input.
|
||||
* Allows chopping incoming data into manageable units (frames)
|
||||
* for subsequent decoding.
|
||||
* @reset: Optional.
|
||||
* Allows subclass (decoder) 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).
|
||||
* @sink_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).
|
||||
* @src_event: Optional.
|
||||
* Event handler on the source 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 likely as well. If non-packetized input is supported or expected,
|
||||
* @parse needs to be overridden as well.
|
||||
*
|
||||
* Since: 0.10.36
|
||||
*/
|
||||
struct _GstVideoDecoderClass
|
||||
{
|
||||
/*< private >*/
|
||||
GstElementClass element_class;
|
||||
|
||||
/*< public >*/
|
||||
gboolean (*open) (GstVideoDecoder *decoder);
|
||||
|
||||
gboolean (*close) (GstVideoDecoder *decoder);
|
||||
|
||||
gboolean (*start) (GstVideoDecoder *decoder);
|
||||
|
||||
gboolean (*stop) (GstVideoDecoder *decoder);
|
||||
|
||||
GstFlowReturn (*parse) (GstVideoDecoder *decoder,
|
||||
GstVideoCodecFrame *frame,
|
||||
GstAdapter *adapter,
|
||||
gboolean at_eos);
|
||||
|
||||
gboolean (*set_format) (GstVideoDecoder *decoder,
|
||||
GstVideoCodecState * state);
|
||||
|
||||
gboolean (*reset) (GstVideoDecoder *decoder,
|
||||
gboolean hard);
|
||||
|
||||
GstFlowReturn (*finish) (GstVideoDecoder *decoder);
|
||||
|
||||
GstFlowReturn (*handle_frame) (GstVideoDecoder *decoder,
|
||||
GstVideoCodecFrame *frame);
|
||||
|
||||
gboolean (*sink_event) (GstVideoDecoder *decoder,
|
||||
GstEvent *event);
|
||||
|
||||
gboolean (*src_event) (GstVideoDecoder *decoder,
|
||||
GstEvent *event);
|
||||
|
||||
|
||||
/*< private >*/
|
||||
/* FIXME before moving to base */
|
||||
void *padding[GST_PADDING_LARGE];
|
||||
};
|
||||
|
||||
GType gst_video_decoder_get_type (void);
|
||||
|
||||
/* Context parameters */
|
||||
void gst_video_decoder_set_packetized (GstVideoDecoder * decoder,
|
||||
gboolean packetized);
|
||||
|
||||
gboolean gst_video_decoder_get_packetized (GstVideoDecoder * decoder);
|
||||
|
||||
void gst_video_decoder_set_estimate_rate (GstVideoDecoder * dec,
|
||||
gboolean enabled);
|
||||
|
||||
gint gst_video_decoder_get_estimate_rate (GstVideoDecoder * dec);
|
||||
|
||||
void gst_video_decoder_set_max_errors (GstVideoDecoder * dec,
|
||||
gint num);
|
||||
|
||||
gint gst_video_decoder_get_max_errors (GstVideoDecoder * dec);
|
||||
|
||||
void gst_video_decoder_set_latency (GstVideoDecoder *decoder,
|
||||
GstClockTime min_latency,
|
||||
GstClockTime max_latency);
|
||||
void gst_video_decoder_get_latency (GstVideoDecoder *decoder,
|
||||
GstClockTime *min_latency,
|
||||
GstClockTime *max_latency);
|
||||
|
||||
|
||||
/* Object methods */
|
||||
|
||||
GstVideoCodecFrame *gst_video_decoder_get_frame (GstVideoDecoder *decoder,
|
||||
int frame_number);
|
||||
|
||||
GstVideoCodecFrame *gst_video_decoder_get_oldest_frame (GstVideoDecoder *decoder);
|
||||
|
||||
/* Parsing related methods */
|
||||
void gst_video_decoder_add_to_frame (GstVideoDecoder *decoder,
|
||||
int n_bytes);
|
||||
GstFlowReturn gst_video_decoder_have_frame (GstVideoDecoder *decoder);
|
||||
|
||||
GstBuffer *gst_video_decoder_alloc_output_buffer (GstVideoDecoder * decoder);
|
||||
|
||||
GstFlowReturn gst_video_decoder_alloc_output_frame (GstVideoDecoder *decoder,
|
||||
GstVideoCodecFrame *frame);
|
||||
|
||||
GstVideoCodecState *gst_video_decoder_set_output_state (GstVideoDecoder *decoder,
|
||||
GstVideoFormat fmt, guint width, guint height,
|
||||
GstVideoCodecState *reference);
|
||||
|
||||
GstVideoCodecState *gst_video_decoder_get_output_state (GstVideoDecoder *decoder);
|
||||
|
||||
GstClockTimeDiff gst_video_decoder_get_max_decode_time (GstVideoDecoder *decoder,
|
||||
GstVideoCodecFrame *frame);
|
||||
|
||||
GstFlowReturn gst_video_decoder_finish_frame (GstVideoDecoder *decoder,
|
||||
GstVideoCodecFrame *frame);
|
||||
|
||||
GstFlowReturn gst_video_decoder_drop_frame (GstVideoDecoder *dec,
|
||||
GstVideoCodecFrame *frame);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif
|
||||
|
1652
gst-libs/gst/video/gstvideoencoder.c
Normal file
1652
gst-libs/gst/video/gstvideoencoder.c
Normal file
File diff suppressed because it is too large
Load diff
306
gst-libs/gst/video/gstvideoencoder.h
Normal file
306
gst-libs/gst/video/gstvideoencoder.h
Normal file
|
@ -0,0 +1,306 @@
|
|||
/* 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>
|
||||
* Copyright (C) 2012 Collabora Ltd.
|
||||
* Author : Edward Hervey <edward@collabora.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_VIDEO_ENCODER_H_
|
||||
#define _GST_VIDEO_ENCODER_H_
|
||||
|
||||
#include <gst/video/gstvideoutils.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GST_TYPE_VIDEO_ENCODER \
|
||||
(gst_video_encoder_get_type())
|
||||
#define GST_VIDEO_ENCODER(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_VIDEO_ENCODER,GstVideoEncoder))
|
||||
#define GST_VIDEO_ENCODER_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_VIDEO_ENCODER,GstVideoEncoderClass))
|
||||
#define GST_VIDEO_ENCODER_GET_CLASS(obj) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_VIDEO_ENCODER,GstVideoEncoderClass))
|
||||
#define GST_IS_VIDEO_ENCODER(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_VIDEO_ENCODER))
|
||||
#define GST_IS_VIDEO_ENCODER_CLASS(obj) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_VIDEO_ENCODER))
|
||||
#define GST_VIDEO_ENCODER_CAST(enc) ((GstVideoEncoder*)enc)
|
||||
|
||||
/**
|
||||
* GST_VIDEO_ENCODER_SINK_NAME:
|
||||
*
|
||||
* The name of the templates for the sink pad.
|
||||
*
|
||||
* Since: 0.10.36
|
||||
*/
|
||||
#define GST_VIDEO_ENCODER_SINK_NAME "sink"
|
||||
/**
|
||||
* GST_VIDEO_ENCODER_SRC_NAME:
|
||||
*
|
||||
* The name of the templates for the source pad.
|
||||
*
|
||||
* Since: 0.10.36
|
||||
*/
|
||||
#define GST_VIDEO_ENCODER_SRC_NAME "src"
|
||||
|
||||
/**
|
||||
* GST_VIDEO_ENCODER_FLOW_DROPPED:
|
||||
*
|
||||
* Returned when the event/buffer should be dropped.
|
||||
*
|
||||
* Since: 0.10.36
|
||||
*/
|
||||
#define GST_VIDEO_ENCODER_FLOW_DROPPED GST_FLOW_CUSTOM_SUCCESS_1
|
||||
|
||||
/**
|
||||
* GST_VIDEO_ENCODER_SRC_PAD:
|
||||
* @obj: a #GstVideoEncoder
|
||||
*
|
||||
* Gives the pointer to the source #GstPad object of the element.
|
||||
*
|
||||
* Since: 0.10.36
|
||||
*/
|
||||
#define GST_VIDEO_ENCODER_SRC_PAD(obj) (((GstVideoEncoder *) (obj))->srcpad)
|
||||
|
||||
/**
|
||||
* GST_VIDEO_ENCODER_SINK_PAD:
|
||||
* @obj: a #GstVideoEncoder
|
||||
*
|
||||
* Gives the pointer to the sink #GstPad object of the element.
|
||||
*
|
||||
* Since: 0.10.36
|
||||
*/
|
||||
#define GST_VIDEO_ENCODER_SINK_PAD(obj) (((GstVideoEncoder *) (obj))->sinkpad)
|
||||
|
||||
/**
|
||||
* GST_VIDEO_ENCODER_FLOW_NEED_DATA:
|
||||
*
|
||||
* Returned while parsing to indicate more data is needed.
|
||||
*
|
||||
* Since: 0.10.36
|
||||
**/
|
||||
#define GST_VIDEO_ENCODER_FLOW_NEED_DATA GST_FLOW_CUSTOM_SUCCESS
|
||||
|
||||
/**
|
||||
* GST_VIDEO_ENCODER_FLOW_DROPPED:
|
||||
*
|
||||
* Returned when the event/buffer should be dropped.
|
||||
*
|
||||
* Since: 0.10.36
|
||||
*/
|
||||
#define GST_VIDEO_ENCODER_FLOW_DROPPED GST_FLOW_CUSTOM_SUCCESS_1
|
||||
|
||||
/**
|
||||
* GST_VIDEO_ENCODER_INPUT_SEGMENT:
|
||||
* @obj: base parse instance
|
||||
*
|
||||
* Gives the segment of the element.
|
||||
*
|
||||
* Since: 0.10.36
|
||||
*/
|
||||
#define GST_VIDEO_ENCODER_INPUT_SEGMENT(obj) (GST_VIDEO_ENCODER_CAST (obj)->input_segment)
|
||||
|
||||
/**
|
||||
* GST_VIDEO_ENCODER_OUTPUT_SEGMENT:
|
||||
* @obj: base parse instance
|
||||
*
|
||||
* Gives the segment of the element.
|
||||
*
|
||||
* Since: 0.10.36
|
||||
*/
|
||||
#define GST_VIDEO_ENCODER_OUTPUT_SEGMENT(obj) (GST_VIDEO_ENCODER_CAST (obj)->output_segment)
|
||||
|
||||
/**
|
||||
* GST_VIDEO_ENCODER_STREAM_LOCK:
|
||||
* @encoder: video encoder instance
|
||||
*
|
||||
* Obtain a lock to protect the encoder function from concurrent access.
|
||||
*
|
||||
* Since: 0.10.36
|
||||
*/
|
||||
#define GST_VIDEO_ENCODER_STREAM_LOCK(encoder) g_static_rec_mutex_lock (&GST_VIDEO_ENCODER (encoder)->stream_lock)
|
||||
|
||||
/**
|
||||
* GST_VIDEO_ENCODER_STREAM_UNLOCK:
|
||||
* @encoder: video encoder instance
|
||||
*
|
||||
* Release the lock that protects the encoder function from concurrent access.
|
||||
*
|
||||
* Since: 0.10.36
|
||||
*/
|
||||
#define GST_VIDEO_ENCODER_STREAM_UNLOCK(encoder) g_static_rec_mutex_unlock (&GST_VIDEO_ENCODER (encoder)->stream_lock)
|
||||
|
||||
typedef struct _GstVideoEncoder GstVideoEncoder;
|
||||
typedef struct _GstVideoEncoderPrivate GstVideoEncoderPrivate;
|
||||
typedef struct _GstVideoEncoderClass GstVideoEncoderClass;
|
||||
|
||||
/**
|
||||
* GstVideoEncoder:
|
||||
*
|
||||
* The opaque #GstVideoEncoder data structure.
|
||||
*
|
||||
* Since: 0.10.36
|
||||
*/
|
||||
struct _GstVideoEncoder
|
||||
{
|
||||
/*< 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 */
|
||||
GStaticRecMutex stream_lock;
|
||||
|
||||
/* MT-protected (with STREAM_LOCK) */
|
||||
GstSegment input_segment;
|
||||
GstSegment output_segment;
|
||||
|
||||
GstVideoEncoderPrivate *priv;
|
||||
/* FIXME before moving to base */
|
||||
void *padding[GST_PADDING_LARGE];
|
||||
};
|
||||
|
||||
/**
|
||||
* GstVideoEncoderClass:
|
||||
* @open: Optional.
|
||||
* Called when the element changes to GST_STATE_READY.
|
||||
* Allows opening external resources. Since: 0.10.37.
|
||||
* @close: Optional.
|
||||
* Called when the element changes to GST_STATE_NULL.
|
||||
* Allows closing external resources. Since: 0.10.37.
|
||||
* @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.
|
||||
* GstVideoCodecState fields have already been
|
||||
* set according to provided caps.
|
||||
* @handle_frame: Provides input frame to subclass.
|
||||
* @reset: Optional.
|
||||
* Allows subclass (encoder) to perform post-seek semantics reset.
|
||||
* @finish: Optional.
|
||||
* Called to request subclass to dispatch any pending remaining
|
||||
* data (e.g. at EOS).
|
||||
* @pre_push: 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.
|
||||
* @getcaps: Optional.
|
||||
* Allows for a custom sink getcaps implementation (e.g.
|
||||
* for multichannel input specification). If not implemented,
|
||||
* default returns gst_video_encoder_proxy_getcaps
|
||||
* applied to sink template caps.
|
||||
* @sink_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).
|
||||
* @src_event: Optional.
|
||||
* Event handler on the source 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.
|
||||
*
|
||||
* Since: 0.10.36
|
||||
*/
|
||||
struct _GstVideoEncoderClass
|
||||
{
|
||||
/*< private >*/
|
||||
GstElementClass element_class;
|
||||
|
||||
/*< public >*/
|
||||
/* virtual methods for subclasses */
|
||||
gboolean (*open) (GstVideoEncoder *encoder);
|
||||
|
||||
gboolean (*close) (GstVideoEncoder *encoder);
|
||||
|
||||
gboolean (*start) (GstVideoEncoder *encoder);
|
||||
|
||||
gboolean (*stop) (GstVideoEncoder *encoder);
|
||||
|
||||
gboolean (*set_format) (GstVideoEncoder *encoder,
|
||||
GstVideoCodecState *state);
|
||||
|
||||
GstFlowReturn (*handle_frame) (GstVideoEncoder *encoder,
|
||||
GstVideoCodecFrame *frame);
|
||||
|
||||
gboolean (*reset) (GstVideoEncoder *encoder,
|
||||
gboolean hard);
|
||||
|
||||
GstFlowReturn (*finish) (GstVideoEncoder *encoder);
|
||||
|
||||
GstFlowReturn (*pre_push) (GstVideoEncoder *encoder,
|
||||
GstVideoCodecFrame *frame);
|
||||
|
||||
GstCaps * (*getcaps) (GstVideoEncoder *enc);
|
||||
|
||||
gboolean (*sink_event) (GstVideoEncoder *encoder,
|
||||
GstEvent *event);
|
||||
|
||||
gboolean (*src_event) (GstVideoEncoder *encoder,
|
||||
GstEvent *event);
|
||||
|
||||
/*< private >*/
|
||||
/* FIXME before moving to base */
|
||||
gpointer _gst_reserved[GST_PADDING_LARGE];
|
||||
};
|
||||
|
||||
GType gst_video_encoder_get_type (void);
|
||||
|
||||
GstVideoCodecState* gst_video_encoder_get_output_state (GstVideoEncoder *encoder);
|
||||
|
||||
GstVideoCodecState* gst_video_encoder_set_output_state (GstVideoEncoder * encoder,
|
||||
GstCaps * caps,
|
||||
GstVideoCodecState * reference);
|
||||
|
||||
GstVideoCodecFrame* gst_video_encoder_get_frame (GstVideoEncoder *encoder,
|
||||
int frame_number);
|
||||
GstVideoCodecFrame* gst_video_encoder_get_oldest_frame (GstVideoEncoder *encoder);
|
||||
|
||||
GstFlowReturn gst_video_encoder_finish_frame (GstVideoEncoder *encoder,
|
||||
GstVideoCodecFrame *frame);
|
||||
|
||||
GstCaps * gst_video_encoder_proxy_getcaps (GstVideoEncoder * enc,
|
||||
GstCaps * caps);
|
||||
void gst_video_encoder_set_discont (GstVideoEncoder *encoder);
|
||||
gboolean gst_video_encoder_get_discont (GstVideoEncoder *encoder);
|
||||
|
||||
void gst_video_encoder_set_latency (GstVideoEncoder *encoder,
|
||||
GstClockTime min_latency,
|
||||
GstClockTime max_latency);
|
||||
void gst_video_encoder_get_latency (GstVideoEncoder *encoder,
|
||||
GstClockTime *min_latency,
|
||||
GstClockTime *max_latency);
|
||||
|
||||
void gst_video_encoder_set_headers (GstVideoEncoder *encoder,
|
||||
GList *headers);
|
||||
G_END_DECLS
|
||||
|
||||
#endif
|
||||
|
189
gst-libs/gst/video/gstvideoutils.c
Normal file
189
gst-libs/gst/video/gstvideoutils.c
Normal file
|
@ -0,0 +1,189 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 2008 David Schleef <ds@schleef.org>
|
||||
* Copyright (C) 2012 Collabora Ltd.
|
||||
* Author : Edward Hervey <edward@collabora.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.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "gstvideoutils.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
GType
|
||||
gst_video_codec_frame_get_type (void)
|
||||
{
|
||||
static volatile gsize type = 0;
|
||||
|
||||
if (g_once_init_enter (&type)) {
|
||||
GType _type;
|
||||
|
||||
_type = g_boxed_type_register_static ("GstVideoCodecFrame",
|
||||
(GBoxedCopyFunc) gst_video_codec_frame_ref,
|
||||
(GBoxedFreeFunc) gst_video_codec_frame_unref);
|
||||
g_once_init_leave (&type, _type);
|
||||
}
|
||||
return (GType) type;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
_gst_video_codec_frame_free (GstVideoCodecFrame * frame)
|
||||
{
|
||||
g_return_if_fail (frame != NULL);
|
||||
|
||||
if (frame->input_buffer) {
|
||||
gst_buffer_unref (frame->input_buffer);
|
||||
}
|
||||
|
||||
if (frame->output_buffer) {
|
||||
gst_buffer_unref (frame->output_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 (GstVideoCodecFrame, frame);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_video_codec_frame_set_hook:
|
||||
* @frame: a #GstVideoCodecFrame
|
||||
* @hook: private data
|
||||
* @notify: (closure hook): a #GDestroyNotify
|
||||
*
|
||||
* Sets the #GDestroyNotify that will be called (along with the @hook) when
|
||||
* the frame is freed.
|
||||
*
|
||||
* If a @hook was previously set, then the previous set @notify will be called
|
||||
* before the @hook is replaced.
|
||||
*/
|
||||
void
|
||||
gst_video_codec_frame_set_hook (GstVideoCodecFrame * frame, void *hook,
|
||||
GDestroyNotify notify)
|
||||
{
|
||||
if (frame->coder_hook_destroy_notify && frame->coder_hook)
|
||||
frame->coder_hook_destroy_notify (frame->coder_hook);
|
||||
|
||||
frame->coder_hook = hook;
|
||||
frame->coder_hook_destroy_notify = notify;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_video_codec_frame_ref:
|
||||
* @frame: a #GstVideoCodecFrame
|
||||
*
|
||||
* Increases the refcount of the given frame by one.
|
||||
*
|
||||
* Returns: @buf
|
||||
*/
|
||||
GstVideoCodecFrame *
|
||||
gst_video_codec_frame_ref (GstVideoCodecFrame * frame)
|
||||
{
|
||||
g_return_val_if_fail (frame != NULL, NULL);
|
||||
|
||||
g_atomic_int_inc (&frame->ref_count);
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_video_codec_frame_unref:
|
||||
* @frame: a #GstVideoCodecFrame
|
||||
*
|
||||
* Decreases the refcount of the frame. If the refcount reaches 0, the frame
|
||||
* will be freed.
|
||||
*/
|
||||
void
|
||||
gst_video_codec_frame_unref (GstVideoCodecFrame * 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_codec_frame_free (frame);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* gst_video_codec_state_ref:
|
||||
* @state: a #GstVideoCodecState
|
||||
*
|
||||
* Increases the refcount of the given state by one.
|
||||
*
|
||||
* Returns: @buf
|
||||
*/
|
||||
GstVideoCodecState *
|
||||
gst_video_codec_state_ref (GstVideoCodecState * state)
|
||||
{
|
||||
g_return_val_if_fail (state != NULL, NULL);
|
||||
|
||||
g_atomic_int_inc (&state->ref_count);
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
static void
|
||||
_gst_video_codec_state_free (GstVideoCodecState * state)
|
||||
{
|
||||
if (state->caps)
|
||||
gst_caps_unref (state->caps);
|
||||
if (state->codec_data)
|
||||
gst_buffer_unref (state->codec_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_video_codec_state_unref:
|
||||
* @state: a #GstVideoCodecState
|
||||
*
|
||||
* Decreases the refcount of the state. If the refcount reaches 0, the state
|
||||
* will be freed.
|
||||
*/
|
||||
void
|
||||
gst_video_codec_state_unref (GstVideoCodecState * state)
|
||||
{
|
||||
g_return_if_fail (state != NULL);
|
||||
g_return_if_fail (state->ref_count > 0);
|
||||
|
||||
if (g_atomic_int_dec_and_test (&state->ref_count)) {
|
||||
_gst_video_codec_state_free (state);
|
||||
}
|
||||
}
|
||||
|
||||
GType
|
||||
gst_video_codec_state_get_type (void)
|
||||
{
|
||||
static volatile gsize type = 0;
|
||||
|
||||
if (g_once_init_enter (&type)) {
|
||||
GType _type;
|
||||
|
||||
_type = g_boxed_type_register_static ("GstVideoCodecState",
|
||||
(GBoxedCopyFunc) gst_video_codec_state_ref,
|
||||
(GBoxedFreeFunc) gst_video_codec_state_unref);
|
||||
g_once_init_leave (&type, _type);
|
||||
}
|
||||
return (GType) type;
|
||||
}
|
277
gst-libs/gst/video/gstvideoutils.h
Normal file
277
gst-libs/gst/video/gstvideoutils.h
Normal file
|
@ -0,0 +1,277 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 2008 David Schleef <ds@schleef.org>
|
||||
* Copyright (C) 2012 Collabora Ltd.
|
||||
* Author : Edward Hervey <edward@collabora.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_VIDEO_UTILS_H_
|
||||
#define _GST_VIDEO_UTILS_H_
|
||||
|
||||
#include <gst/gst.h>
|
||||
#include <gst/video/video.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
#define GST_TYPE_VIDEO_CODEC_STATE \
|
||||
(gst_video_codec_state_get_type())
|
||||
|
||||
#define GST_TYPE_VIDEO_CODEC_FRAME \
|
||||
(gst_video_codec_frame_get_type())
|
||||
|
||||
typedef struct _GstVideoCodecState GstVideoCodecState;
|
||||
typedef struct _GstVideoCodecFrame GstVideoCodecFrame;
|
||||
|
||||
/**
|
||||
* GstVideoCodecState:
|
||||
* @info: The #GstVideoInfo describing the stream
|
||||
* @caps: The #GstCaps
|
||||
* @codec_data: (optional) a #GstBuffer corresponding to the
|
||||
* 'codec_data' field of a stream.
|
||||
*
|
||||
* Structure representing the state of an incoming or outgoing video
|
||||
* stream for encoders and decoders.
|
||||
*
|
||||
* Decoders and encoders will receive such a state through their
|
||||
* respective @set_format vmethods.
|
||||
*
|
||||
* Decoders and encoders can set the downstream state, by using the
|
||||
* @gst_video_decoder_set_output_state() or
|
||||
* @gst_video_encoder_set_output_state() methods.
|
||||
*/
|
||||
struct _GstVideoCodecState
|
||||
{
|
||||
/*< private >*/
|
||||
gint ref_count;
|
||||
|
||||
/*< public >*/
|
||||
GstVideoInfo info;
|
||||
|
||||
GstCaps *caps;
|
||||
|
||||
GstBuffer *codec_data;
|
||||
|
||||
/*< private >*/
|
||||
void *padding[GST_PADDING_LARGE];
|
||||
};
|
||||
|
||||
/**
|
||||
* GstVideoCodecFrameFlags:
|
||||
* @GST_VIDEO_CODEC_FRAME_FLAG_DECODE_ONLY: is the frame only meant to be decoded
|
||||
* @GST_VIDEO_CODEC_FRAME_FLAG_SYNC_POINT: is the frame a synchronization point (keyframe)
|
||||
* @GST_VIDEO_CODEC_FRAME_FLAG_FORCE_KEYFRAME: should the output frame be made a keyframe
|
||||
* @GST_VIDEO_CODEC_FRAME_FLAG_FORCE_KEYFRAME_HEADERS: should the encoder output stream headers
|
||||
* @GST_VIDEO_CODEC_FRAME_FLAG_TFF: top-field first
|
||||
* @GST_VIDEO_CODEC_FRAME_FLAG_RFF: the field is repeated
|
||||
* @GST_VIDEO_CODEC_FRAME_FLAG_ONEFIELD: only one field is present
|
||||
*
|
||||
* Flags for #GstVideoCodecFrame
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
GST_VIDEO_CODEC_FRAME_FLAG_DECODE_ONLY = (1<<0),
|
||||
GST_VIDEO_CODEC_FRAME_FLAG_SYNC_POINT = (1<<1),
|
||||
GST_VIDEO_CODEC_FRAME_FLAG_FORCE_KEYFRAME = (1<<2),
|
||||
GST_VIDEO_CODEC_FRAME_FLAG_FORCE_KEYFRAME_HEADERS = (1<<3),
|
||||
GST_VIDEO_CODEC_FRAME_FLAG_TFF = (1<<4),
|
||||
GST_VIDEO_CODEC_FRAME_FLAG_RFF = (1<<5),
|
||||
GST_VIDEO_CODEC_FRAME_FLAG_ONEFIELD = (1<<6)
|
||||
} GstVideoCodecFrameFlags;
|
||||
|
||||
/**
|
||||
* GST_VIDEO_CODEC_FRAME_FLAGS:
|
||||
* @frame: a #GstVideoCodecFrame
|
||||
*
|
||||
* The entire set of flags for the @frame
|
||||
*/
|
||||
#define GST_VIDEO_CODEC_FRAME_FLAGS(frame) ((frame)->flags)
|
||||
|
||||
/**
|
||||
* GST_VIDEO_CODEC_FRAME_FLAG_IS_SET:
|
||||
* @frame: a #GstVideoCodecFrame
|
||||
* @flag: a flag to check for
|
||||
*
|
||||
* Checks whether the given @flag is set
|
||||
*/
|
||||
#define GST_VIDEO_CODEC_FRAME_FLAG_IS_SET(frame,flag) !!(GST_VIDEO_CODEC_FRAME_FLAGS(frame) & (flag))
|
||||
|
||||
/**
|
||||
* GST_VIDEO_CODEC_FRAME_FLAG_SET:
|
||||
* @frame: a #GstVideoCodecFrame
|
||||
* @flag: Flag to set, can be any number of bits in guint32.
|
||||
*
|
||||
* This macro sets the given bits
|
||||
*/
|
||||
#define GST_VIDEO_CODEC_FRAME_FLAG_SET(frame,flag) (GST_VIDEO_CODEC_FRAME_FLAGS(frame) |= (flag))
|
||||
|
||||
/**
|
||||
* GST_VIDEO_CODEC_FRAME_FLAG_UNSET:
|
||||
* @frame: a #GstVideoCodecFrame
|
||||
* @flag: Flag to unset
|
||||
*
|
||||
* This macro usets the given bits.
|
||||
*/
|
||||
#define GST_VIDEO_CODEC_FRAME_FLAG_UNSET(frame,flag) (GST_VIDEO_CODEC_FRAME_FLAGS(frame) &= ~(flag))
|
||||
|
||||
/**
|
||||
* GST_VIDEO_CODEC_FRAME_IS_DECODE_ONLY:
|
||||
* @frame: a #GstVideoCodecFrame
|
||||
*
|
||||
* Tests if the buffer should only be decoded but not sent downstream.
|
||||
*/
|
||||
#define GST_VIDEO_CODEC_FRAME_IS_DECODE_ONLY(frame) (GST_VIDEO_CODEC_FRAME_FLAG_IS_SET(frame, GST_VIDEO_CODEC_FRAME_FLAG_DECODE_ONLY))
|
||||
|
||||
/**
|
||||
* GST_VIDEO_CODEC_FRAME_SET_DECODE_ONLY:
|
||||
* @frame: a #GstVideoCodecFrame
|
||||
*
|
||||
* Sets the buffer to not be sent downstream.
|
||||
*
|
||||
* Decoder implementation can use this if they have frames that
|
||||
* are not meant to be displayed.
|
||||
*
|
||||
* Encoder implementation can safely ignore this field.
|
||||
*/
|
||||
#define GST_VIDEO_CODEC_FRAME_SET_DECODE_ONLY(frame) (GST_VIDEO_CODEC_FRAME_FLAG_SET(frame, GST_VIDEO_CODEC_FRAME_FLAG_DECODE_ONLY))
|
||||
|
||||
/**
|
||||
* GST_VIDEO_CODEC_FRAME_IS_SYNC_POINT:
|
||||
* @frame: a #GstVideoCodecFrame
|
||||
*
|
||||
* Tests if the frame is a synchronization point (like a keyframe).
|
||||
*
|
||||
* Decoder implementations can use this to detect keyframes.
|
||||
*/
|
||||
#define GST_VIDEO_CODEC_FRAME_IS_SYNC_POINT(frame) (GST_VIDEO_CODEC_FRAME_FLAG_IS_SET(frame, GST_VIDEO_CODEC_FRAME_FLAG_SYNC_POINT))
|
||||
|
||||
/**
|
||||
* GST_VIDEO_CODEC_FRAME_SET_SYNC_POINT:
|
||||
* @frame: a #GstVideoCodecFrame
|
||||
*
|
||||
* Sets the frame to be a synchronization point (like a keyframe).
|
||||
*
|
||||
* Encoder implementations should set this accordingly.
|
||||
*
|
||||
* Decoder implementing parsing features should set this when they
|
||||
* detect such a synchronization point.
|
||||
*/
|
||||
#define GST_VIDEO_CODEC_FRAME_SET_SYNC_POINT(frame) (GST_VIDEO_CODEC_FRAME_FLAG_SET(frame, GST_VIDEO_CODEC_FRAME_FLAG_SYNC_POINT))
|
||||
#define GST_VIDEO_CODEC_FRAME_UNSET_SYNC_POINT(frame) (GST_VIDEO_CODEC_FRAME_FLAG_UNSET(frame, GST_VIDEO_CODEC_FRAME_FLAG_SYNC_POINT))
|
||||
|
||||
|
||||
/**
|
||||
* GST_VIDEO_CODEC_FRAME_IS_FORCE_KEYFRAME:
|
||||
* @frame: a #GstVideoCodecFrame
|
||||
*
|
||||
* Tests if the frame must be encoded as a keyframe. Applies only to
|
||||
* frames provided to encoders. Decoders can safely ignore this field.
|
||||
*/
|
||||
#define GST_VIDEO_CODEC_FRAME_IS_FORCE_KEYFRAME(frame) (GST_VIDEO_CODEC_FRAME_FLAG_IS_SET(frame, GST_VIDEO_CODEC_FRAME_FLAG_FORCE_KEYFRAME))
|
||||
#define GST_VIDEO_CODEC_FRAME_SET_FORCE_KEYFRAME(frame) (GST_VIDEO_CODEC_FRAME_FLAG_SET(frame, GST_VIDEO_CODEC_FRAME_FLAG_FORCE_KEYFRAME))
|
||||
#define GST_VIDEO_CODEC_FRAME_UNSET_FORCE_KEYFRAME(frame) (GST_VIDEO_CODEC_FRAME_FLAG_UNSET(frame, GST_VIDEO_CODEC_FRAME_FLAG_FORCE_KEYFRAME))
|
||||
|
||||
/**
|
||||
* GST_VIDEO_CODEC_FRAME_IS_FORCE_KEYFRAME_HEADERS:
|
||||
* @frame: a #GstVideoCodecFrame
|
||||
*
|
||||
* Tests if encoder should output stream headers before outputting the
|
||||
* resulting encoded buffer for the given frame.
|
||||
*
|
||||
* Applies only to frames provided to encoders. Decoders can safely
|
||||
* ignore this field.
|
||||
*/
|
||||
#define GST_VIDEO_CODEC_FRAME_IS_FORCE_KEYFRAME_HEADERS(frame) (GST_VIDEO_CODEC_FRAME_FLAG_IS_SET(frame, GST_VIDEO_CODEC_FRAME_FLAG_FORCE_KEYFRAME_HEADERS))
|
||||
#define GST_VIDEO_CODEC_FRAME_SET_FORCE_KEYFRAME_HEADERS(frame) (GST_VIDEO_CODEC_FRAME_FLAG_SET(frame, GST_VIDEO_CODEC_FRAME_FLAG_FORCE_KEYFRAME_HEADERS))
|
||||
#define GST_VIDEO_CODEC_FRAME_UNSET_FORCE_KEYFRAME_HEADERS(frame) (GST_VIDEO_CODEC_FRAME_FLAG_UNSET(frame, GST_VIDEO_CODEC_FRAME_FLAG_FORCE_KEYFRAME_HEADERS))
|
||||
|
||||
/**
|
||||
* GstVideoCodecFrame:
|
||||
* @pts: Presentation timestamp
|
||||
* @dts: Decoding timestamp
|
||||
* @duration: Duration of the frame
|
||||
* @system_frame_number: Unique identifier for the frame. Use this if you need
|
||||
* to get hold of the frame later (like when data is being decoded).
|
||||
* Typical usage in decoders is to set this on the opaque value provided
|
||||
* to the library and get back the frame using gst_video_decoder_get_frame()
|
||||
* @distance_from_sync: Distance in frames from the last synchronization point.
|
||||
* @input_buffer: the input #GstBuffer that created this frame.
|
||||
* @output_buffer: the output #GstBuffer. Implementations should set this either
|
||||
* directly, or by using the @gst_video_decoder_alloc_output_frame() or
|
||||
* @gst_video_decoder_alloc_output_buffer() methods.
|
||||
* @field_index:
|
||||
* @n_fields: number of fields in the frame (default 2). Decoders can change
|
||||
* this if the frame contains a different number of fields.
|
||||
* @deadline: Running time when the frame will be used.
|
||||
* @events: Events that will be pushed downstream before this frame is pushed.
|
||||
*
|
||||
* A #GstVideoCodecFrame represents a video frame both in raw and
|
||||
* encoded form.
|
||||
*/
|
||||
struct _GstVideoCodecFrame
|
||||
{
|
||||
/*< private >*/
|
||||
gint ref_count;
|
||||
|
||||
guint32 flags;
|
||||
|
||||
/*< public >*/
|
||||
gint system_frame_number; /* ED */
|
||||
gint decode_frame_number; /* ED */
|
||||
gint presentation_frame_number; /* ED */
|
||||
|
||||
GstClockTime dts; /* ED */
|
||||
GstClockTime pts; /* ED */
|
||||
GstClockTime duration; /* ED */
|
||||
|
||||
int distance_from_sync; /* ED */
|
||||
|
||||
GstBuffer *input_buffer; /* ED */
|
||||
GstBuffer *output_buffer; /* ED */
|
||||
|
||||
GstClockTime deadline; /* D */
|
||||
|
||||
/* Events that should be pushed downstream *before*
|
||||
* the next output_buffer */
|
||||
GList *events; /* ED */
|
||||
|
||||
/*< private >*/
|
||||
|
||||
void *coder_hook;
|
||||
GDestroyNotify coder_hook_destroy_notify;
|
||||
|
||||
void *padding[GST_PADDING_LARGE];
|
||||
};
|
||||
|
||||
/* GstVideoCodecState */
|
||||
GType gst_video_codec_state_get_type (void);
|
||||
|
||||
GstVideoCodecState *gst_video_codec_state_ref (GstVideoCodecState * state);
|
||||
|
||||
void gst_video_codec_state_unref (GstVideoCodecState * state);
|
||||
|
||||
|
||||
/* GstVideoCodecFrame */
|
||||
GType gst_video_codec_frame_get_type (void);
|
||||
|
||||
GstVideoCodecFrame *gst_video_codec_frame_ref (GstVideoCodecFrame * frame);
|
||||
void gst_video_codec_frame_unref (GstVideoCodecFrame * frame);
|
||||
void gst_video_codec_frame_set_hook (GstVideoCodecFrame *frame,
|
||||
void *hook,
|
||||
GDestroyNotify notify);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif
|
|
@ -1,9 +1,48 @@
|
|||
EXPORTS
|
||||
_gst_video_decoder_error
|
||||
gst_video_buffer_get_overlay_composition
|
||||
gst_video_buffer_set_overlay_composition
|
||||
gst_video_calculate_display_ratio
|
||||
gst_video_codec_frame_get_type
|
||||
gst_video_codec_frame_ref
|
||||
gst_video_codec_frame_set_hook
|
||||
gst_video_codec_frame_unref
|
||||
gst_video_codec_state_get_type
|
||||
gst_video_codec_state_ref
|
||||
gst_video_codec_state_unref
|
||||
gst_video_convert_frame
|
||||
gst_video_convert_frame_async
|
||||
gst_video_decoder_add_to_frame
|
||||
gst_video_decoder_alloc_output_buffer
|
||||
gst_video_decoder_alloc_output_frame
|
||||
gst_video_decoder_drop_frame
|
||||
gst_video_decoder_finish_frame
|
||||
gst_video_decoder_get_estimate_rate
|
||||
gst_video_decoder_get_frame
|
||||
gst_video_decoder_get_latency
|
||||
gst_video_decoder_get_max_decode_time
|
||||
gst_video_decoder_get_max_errors
|
||||
gst_video_decoder_get_oldest_frame
|
||||
gst_video_decoder_get_output_state
|
||||
gst_video_decoder_get_packetized
|
||||
gst_video_decoder_get_type
|
||||
gst_video_decoder_have_frame
|
||||
gst_video_decoder_set_estimate_rate
|
||||
gst_video_decoder_set_latency
|
||||
gst_video_decoder_set_max_errors
|
||||
gst_video_decoder_set_output_state
|
||||
gst_video_decoder_set_packetized
|
||||
gst_video_decoder_set_src_caps
|
||||
gst_video_encoder_finish_frame
|
||||
gst_video_encoder_get_frame
|
||||
gst_video_encoder_get_latency
|
||||
gst_video_encoder_get_oldest_frame
|
||||
gst_video_encoder_get_output_state
|
||||
gst_video_encoder_get_type
|
||||
gst_video_encoder_proxy_getcaps
|
||||
gst_video_encoder_set_headers
|
||||
gst_video_encoder_set_latency
|
||||
gst_video_encoder_set_output_state
|
||||
gst_video_event_is_force_key_unit
|
||||
gst_video_event_new_downstream_force_key_unit
|
||||
gst_video_event_new_still_frame
|
||||
|
|
Loading…
Reference in a new issue