mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-28 11:10:37 +00:00
Merge remote-tracking branch 'origin/0.10'
Video base classes and theora plugin still needs to be ported again Conflicts: docs/libs/gst-plugins-base-libs-docs.sgml docs/libs/gst-plugins-base-libs-sections.txt docs/libs/gst-plugins-base-libs.types ext/theora/gsttheoradec.c ext/theora/gsttheoradec.h ext/theora/gsttheoraenc.c ext/theora/gsttheoraenc.h gst-libs/gst/video/Makefile.am gst-libs/gst/video/video.c gst-libs/gst/video/video.h gst/playback/gsturidecodebin.c tests/check/libs/video.c tests/check/pipelines/theoraenc.c win32/common/libgstvideo.def
This commit is contained in:
commit
a0e3a9e32d
16 changed files with 6586 additions and 2360 deletions
|
@ -181,6 +181,9 @@
|
|||
<xi:include href="xml/gstcolorbalancechannel.xml" />
|
||||
<xi:include href="xml/gstvideoorientation.xml" />
|
||||
<xi:include href="xml/gstvideooverlay.xml" />
|
||||
<xi:include href="xml/gstvideodecoder.xml" />
|
||||
<xi:include href="xml/gstvideoencoder.xml" />
|
||||
<xi:include href="xml/gstvideoutils.xml" />
|
||||
</chapter>
|
||||
</part>
|
||||
|
||||
|
|
|
@ -1927,7 +1927,90 @@ GstEncodingTargetClass
|
|||
<INCLUDE>gst/video/video.h</INCLUDE>
|
||||
GST_VIDEO_FPS_RANGE
|
||||
GST_VIDEO_SIZE_RANGE
|
||||
GST_VIDEO_BUFFER_TFF
|
||||
GST_VIDEO_BUFFER_RFF
|
||||
GST_VIDEO_BUFFER_ONEFIELD
|
||||
GST_VIDEO_BUFFER_PROGRESSIVE
|
||||
GstVideoChromaSite
|
||||
GstVideoColorMatrix
|
||||
GstVideoColorPrimaries
|
||||
GstVideoColorRange
|
||||
GstVideoColorimetry
|
||||
GstVideoFlags
|
||||
GstVideoFormatFlags
|
||||
GstVideoFormatPack
|
||||
GstVideoFormatUnpack
|
||||
GstVideoInterlaceMode
|
||||
GstVideoTransferFunction
|
||||
GstVideoFormat
|
||||
GstVideoFormatInfo
|
||||
GST_VIDEO_FORMAT_INFO_BITS
|
||||
GST_VIDEO_FORMAT_INFO_DATA
|
||||
GST_VIDEO_FORMAT_INFO_DEPTH
|
||||
GST_VIDEO_FORMAT_INFO_FLAGS
|
||||
GST_VIDEO_FORMAT_INFO_FORMAT
|
||||
GST_VIDEO_FORMAT_INFO_HAS_ALPHA
|
||||
GST_VIDEO_FORMAT_INFO_HAS_PALETTE
|
||||
GST_VIDEO_FORMAT_INFO_H_SUB
|
||||
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
|
||||
GST_VIDEO_FORMAT_INFO_OFFSET
|
||||
GST_VIDEO_FORMAT_INFO_PLANE
|
||||
GST_VIDEO_FORMAT_INFO_POFFSET
|
||||
GST_VIDEO_FORMAT_INFO_PSTRIDE
|
||||
GST_VIDEO_FORMAT_INFO_SCALE_HEIGHT
|
||||
GST_VIDEO_FORMAT_INFO_SCALE_WIDTH
|
||||
GST_VIDEO_FORMAT_INFO_SHIFT
|
||||
GST_VIDEO_FORMAT_INFO_STRIDE
|
||||
GST_VIDEO_FORMAT_INFO_W_SUB
|
||||
GstVideoInfo
|
||||
GST_VIDEO_INFO_COMP_BITS
|
||||
GST_VIDEO_INFO_COMP_DATA
|
||||
GST_VIDEO_INFO_COMP_DEPTH
|
||||
GST_VIDEO_INFO_COMP_HEIGHT
|
||||
GST_VIDEO_INFO_COMP_OFFSET
|
||||
GST_VIDEO_INFO_COMP_PLANE
|
||||
GST_VIDEO_INFO_COMP_POFFSET
|
||||
GST_VIDEO_INFO_COMP_PSTRIDE
|
||||
GST_VIDEO_INFO_COMP_STRIDE
|
||||
GST_VIDEO_INFO_COMP_WIDTH
|
||||
GST_VIDEO_INFO_FLAGS
|
||||
GST_VIDEO_INFO_FLAG_IS_SET
|
||||
GST_VIDEO_INFO_FLAG_SET
|
||||
GST_VIDEO_INFO_FLAG_UNSET
|
||||
GST_VIDEO_INFO_FORMAT
|
||||
GST_VIDEO_INFO_FPS_D
|
||||
GST_VIDEO_INFO_FPS_N
|
||||
GST_VIDEO_INFO_HAS_ALPHA
|
||||
GST_VIDEO_INFO_HEIGHT
|
||||
GST_VIDEO_INFO_INTERLACE_MODE
|
||||
GST_VIDEO_INFO_IS_GRAY
|
||||
GST_VIDEO_INFO_IS_INTERLACED
|
||||
GST_VIDEO_INFO_IS_RGB
|
||||
GST_VIDEO_INFO_IS_YUV
|
||||
GST_VIDEO_INFO_NAME
|
||||
GST_VIDEO_INFO_N_COMPONENTS
|
||||
GST_VIDEO_INFO_N_PLANES
|
||||
GST_VIDEO_INFO_PAR_D
|
||||
GST_VIDEO_INFO_PAR_N
|
||||
GST_VIDEO_INFO_PLANE_OFFSET
|
||||
GST_VIDEO_INFO_PLANE_STRIDE
|
||||
GST_VIDEO_INFO_SIZE
|
||||
GST_VIDEO_INFO_WIDTH
|
||||
GST_VIDEO_MAX_COMPONENTS
|
||||
GST_VIDEO_MAX_PLANES
|
||||
GST_VIDEO_SUB_SCALE
|
||||
gst_video_info_convert
|
||||
gst_video_info_from_caps
|
||||
gst_video_info_init
|
||||
gst_video_info_set_format
|
||||
gst_video_info_to_caps
|
||||
gst_video_calculate_display_ratio
|
||||
gst_video_format_to_fourcc
|
||||
gst_video_format_from_fourcc
|
||||
|
@ -1945,6 +2028,22 @@ gst_video_event_parse_downstream_force_key_unit
|
|||
<SUBSECTION Standard>
|
||||
gst_video_format_get_type
|
||||
GST_TYPE_VIDEO_FORMAT
|
||||
GST_TYPE_VIDEO_CHROMA_SITE
|
||||
GST_TYPE_VIDEO_COLOR_MATRIX
|
||||
GST_TYPE_VIDEO_COLOR_PRIMARIES
|
||||
GST_TYPE_VIDEO_COLOR_RANGE
|
||||
GST_TYPE_VIDEO_FLAGS
|
||||
GST_TYPE_VIDEO_FORMAT_FLAGS
|
||||
GST_TYPE_VIDEO_INTERLACE_MODE
|
||||
GST_TYPE_VIDEO_TRANSFER_FUNCTION
|
||||
gst_video_chroma_site_get_type
|
||||
gst_video_color_matrix_get_type
|
||||
gst_video_color_primaries_get_type
|
||||
gst_video_color_range_get_type
|
||||
gst_video_flags_get_type
|
||||
gst_video_format_flags_get_type
|
||||
gst_video_interlace_mode_get_type
|
||||
gst_video_transfer_function_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
|
@ -2035,6 +2134,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>
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,5 +1,8 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 2004 Benjamin Otte <in7y118@public.uni-hamburg.de>
|
||||
* Copyright (c) 2012 Collabora Ltd.
|
||||
* Author : Edward Hervey <edward@collabora.com>
|
||||
* Author : Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
|
@ -25,9 +28,9 @@
|
|||
#endif
|
||||
|
||||
#include <gst/gst.h>
|
||||
#include <gst/video/gstvideodecoder.h>
|
||||
#include <theora/theoradec.h>
|
||||
#include <string.h>
|
||||
#include <gst/video/video.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
@ -52,69 +55,41 @@ typedef struct _GstTheoraDecClass GstTheoraDecClass;
|
|||
*/
|
||||
struct _GstTheoraDec
|
||||
{
|
||||
GstElement element;
|
||||
|
||||
/* Pads */
|
||||
GstPad *sinkpad;
|
||||
GstPad *srcpad;
|
||||
GstVideoDecoder element;
|
||||
|
||||
/* theora decoder state */
|
||||
th_dec_ctx *decoder;
|
||||
//theora_state state;
|
||||
th_setup_info *setup;
|
||||
th_info info;
|
||||
th_comment comment;
|
||||
|
||||
gboolean have_header;
|
||||
|
||||
GstClockTime last_timestamp;
|
||||
guint64 frame_nr;
|
||||
gboolean need_keyframe;
|
||||
GstVideoInfo vinfo;
|
||||
GstVideoCodecState *input_state;
|
||||
GstVideoCodecState *output_state;
|
||||
gint offset_x, offset_y;
|
||||
|
||||
gint output_bpp;
|
||||
GstBufferPool *pool;
|
||||
gboolean has_cropping;
|
||||
gboolean need_cropping;
|
||||
|
||||
/* telemetry debugging options */
|
||||
/* telemetry debuging options */
|
||||
gint telemetry_mv;
|
||||
gint telemetry_mbmode;
|
||||
gint telemetry_qi;
|
||||
gint telemetry_bits;
|
||||
|
||||
/* list of buffers that need timestamps */
|
||||
GList *queued;
|
||||
/* list of raw output buffers */
|
||||
GList *output;
|
||||
/* gather/decode queues for reverse playback */
|
||||
GList *gather;
|
||||
GList *decode;
|
||||
GList *pendingevents;
|
||||
gboolean crop;
|
||||
|
||||
GstTagList *tags;
|
||||
|
||||
/* segment info */ /* with STREAM_LOCK */
|
||||
GstSegment segment;
|
||||
gboolean discont;
|
||||
guint32 seqnum;
|
||||
|
||||
/* QoS stuff */ /* with LOCK*/
|
||||
gdouble proportion;
|
||||
GstClockTime earliest_time;
|
||||
guint64 processed;
|
||||
guint64 dropped;
|
||||
|
||||
gboolean have_par;
|
||||
gint par_num;
|
||||
gint par_den;
|
||||
};
|
||||
|
||||
struct _GstTheoraDecClass
|
||||
{
|
||||
GstElementClass parent_class;
|
||||
GstVideoDecoderClass parent_class;
|
||||
};
|
||||
|
||||
GType gst_theora_dec_get_type (void);
|
||||
gboolean gst_theora_dec_register (GstPlugin * plugin);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,5 +1,8 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 2004 Wim Taymans <wim@fluendo.com>
|
||||
* Copyright (c) 2012 Collabora Ltd.
|
||||
* Author : Edward Hervey <edward@collabora.com>
|
||||
* Author : Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
|
@ -22,10 +25,9 @@
|
|||
|
||||
#include <gst/gst.h>
|
||||
#include <gst/base/gstadapter.h>
|
||||
#include <gst/video/gstvideoencoder.h>
|
||||
#include <theora/theoraenc.h>
|
||||
|
||||
#include <gst/video/video.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GST_TYPE_THEORA_ENC \
|
||||
|
@ -42,6 +44,22 @@ G_BEGIN_DECLS
|
|||
typedef struct _GstTheoraEnc GstTheoraEnc;
|
||||
typedef struct _GstTheoraEncClass GstTheoraEncClass;
|
||||
|
||||
/**
|
||||
* GstTheoraEncBorderMode:
|
||||
* @BORDER_NONE: no border
|
||||
* @BORDER_BLACK: black border
|
||||
* @BORDER_MIRROR: Mirror image in border
|
||||
*
|
||||
* Border color to add when sizes not multiple of 16.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
BORDER_NONE,
|
||||
BORDER_BLACK,
|
||||
BORDER_MIRROR
|
||||
}
|
||||
GstTheoraEncBorderMode;
|
||||
|
||||
/**
|
||||
* GstTheoraEncMultipassMode:
|
||||
* @MULTIPASS_MODE_SINGLE_PASS: Single pass encoding
|
||||
|
@ -63,12 +81,7 @@ typedef enum
|
|||
*/
|
||||
struct _GstTheoraEnc
|
||||
{
|
||||
GstElement element;
|
||||
|
||||
GstPad *sinkpad;
|
||||
GstPad *srcpad;
|
||||
|
||||
GstSegment segment;
|
||||
GstVideoEncoder element;
|
||||
|
||||
ogg_stream_state to;
|
||||
|
||||
|
@ -85,19 +98,16 @@ struct _GstTheoraEnc
|
|||
gint keyframe_freq;
|
||||
gint keyframe_force;
|
||||
|
||||
GstVideoInfo vinfo;
|
||||
gint info_width, info_height;
|
||||
GstClockTime next_ts;
|
||||
GstVideoCodecState *input_state;
|
||||
|
||||
GstClockTime expected_ts;
|
||||
gboolean next_discont;
|
||||
|
||||
gboolean force_keyframe;
|
||||
gint width, height;
|
||||
gint fps_n, fps_d;
|
||||
|
||||
guint packetno;
|
||||
guint64 bytes_out;
|
||||
guint64 granulepos_offset;
|
||||
guint64 timestamp_offset;
|
||||
guint64 pfn_offset;
|
||||
|
||||
gint speed_level;
|
||||
gboolean vp3_compatible;
|
||||
|
@ -106,13 +116,6 @@ struct _GstTheoraEnc
|
|||
gboolean cap_underflow;
|
||||
int rate_buffer;
|
||||
|
||||
/* variables for dup-on-gap */
|
||||
gboolean dup_on_gap;
|
||||
gboolean current_discont;
|
||||
GstBuffer *prevbuf;
|
||||
GQueue *t_queue;
|
||||
/* end dup-on-gap */
|
||||
|
||||
GstTheoraEncMultipassMode multipass_mode;
|
||||
GIOChannel *multipass_cache_fd;
|
||||
GstAdapter *multipass_cache_adapter;
|
||||
|
@ -121,10 +124,11 @@ struct _GstTheoraEnc
|
|||
|
||||
struct _GstTheoraEncClass
|
||||
{
|
||||
GstElementClass parent_class;
|
||||
GstVideoEncoderClass parent_class;
|
||||
};
|
||||
|
||||
GType gst_theora_enc_get_type (void);
|
||||
gboolean gst_theora_enc_register (GstPlugin * plugin);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
@ -25,7 +25,10 @@ libgstvideo_@GST_API_VERSION@_la_SOURCES = \
|
|||
gstvideometa.c \
|
||||
gstvideopool.c \
|
||||
videoorientation.c \
|
||||
videooverlay.c
|
||||
videooverlay.c \
|
||||
gstvideodecoder.c \
|
||||
gstvideoencoder.c \
|
||||
gstvideoutils.c
|
||||
|
||||
nodist_libgstvideo_@GST_API_VERSION@_la_SOURCES = $(BUILT_SOURCES)
|
||||
|
||||
|
@ -40,7 +43,10 @@ libgstvideo_@GST_API_VERSION@include_HEADERS = \
|
|||
gstvideometa.h \
|
||||
gstvideopool.h \
|
||||
videoorientation.h \
|
||||
videooverlay.h
|
||||
videooverlay.h \
|
||||
gstvideodecoder.h \
|
||||
gstvideoencoder.h \
|
||||
gstvideoutils.h
|
||||
nodist_libgstvideo_@GST_API_VERSION@include_HEADERS = $(built_headers)
|
||||
|
||||
libgstvideo_@GST_API_VERSION@_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS)
|
||||
|
|
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.
|
2745
gst-libs/gst/video/gstvideodecoder.c
Normal file
2745
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
|
|
@ -231,7 +231,7 @@ fill_planes (GstBlendVideoFormatInfo * info)
|
|||
info->offset[1] = info->offset[2] +
|
||||
info->stride[1] * (GST_ROUND_UP_4 (height) / 4);
|
||||
break;
|
||||
case GST_VIDEO_FORMAT_UNKNOWN:
|
||||
default:
|
||||
GST_ERROR ("invalid format");
|
||||
g_warning ("invalid format");
|
||||
break;
|
||||
|
|
|
@ -308,126 +308,6 @@ GST_START_TEST (test_continuity)
|
|||
|
||||
GST_END_TEST;
|
||||
|
||||
static GstPadProbeReturn
|
||||
drop_second_data_buffer (GstPad * droppad, GstPadProbeInfo * info,
|
||||
gpointer unused)
|
||||
{
|
||||
GstBuffer *buffer = GST_PAD_PROBE_INFO_BUFFER (info);
|
||||
|
||||
if (GST_BUFFER_OFFSET (buffer) == 1)
|
||||
return GST_PAD_PROBE_DROP;
|
||||
else
|
||||
return GST_PAD_PROBE_OK;
|
||||
}
|
||||
|
||||
GST_START_TEST (test_discontinuity)
|
||||
{
|
||||
GstElement *bin;
|
||||
GstPad *pad, *droppad;
|
||||
gchar *pipe_str;
|
||||
GstBuffer *buffer;
|
||||
GError *error = NULL;
|
||||
guint drop_id;
|
||||
|
||||
pipe_str = g_strdup_printf ("videotestsrc num-buffers=10"
|
||||
" ! video/x-raw,format=(string)I420,framerate=10/1"
|
||||
" ! theoraenc ! fakesink name=fs0");
|
||||
|
||||
bin = gst_parse_launch (pipe_str, &error);
|
||||
fail_unless (bin != NULL, "Error parsing pipeline: %s",
|
||||
error ? error->message : "(invalid error)");
|
||||
g_free (pipe_str);
|
||||
|
||||
/* the plan: same as test_continuity, but dropping a buffer and seeing if
|
||||
theoraenc correctly notes the discontinuity */
|
||||
|
||||
/* get the pad to use to drop buffers */
|
||||
{
|
||||
GstElement *sink = gst_bin_get_by_name (GST_BIN (bin), "theoraenc0");
|
||||
|
||||
fail_unless (sink != NULL, "Could not get theoraenc out of bin");
|
||||
droppad = gst_element_get_static_pad (sink, "sink");
|
||||
fail_unless (droppad != NULL, "Could not get pad out of theoraenc");
|
||||
gst_object_unref (sink);
|
||||
}
|
||||
|
||||
/* get the pad */
|
||||
{
|
||||
GstElement *sink = gst_bin_get_by_name (GST_BIN (bin), "fs0");
|
||||
|
||||
fail_unless (sink != NULL, "Could not get fakesink out of bin");
|
||||
pad = gst_element_get_static_pad (sink, "sink");
|
||||
fail_unless (pad != NULL, "Could not get pad out of fakesink");
|
||||
gst_object_unref (sink);
|
||||
}
|
||||
|
||||
drop_id = gst_pad_add_probe (droppad, GST_PAD_PROBE_TYPE_BUFFER,
|
||||
drop_second_data_buffer, NULL, NULL);
|
||||
gst_buffer_straw_start_pipeline (bin, pad);
|
||||
|
||||
/* header packets should have timestamp == NONE, granulepos 0 */
|
||||
buffer = gst_buffer_straw_get_buffer (bin, pad);
|
||||
check_buffer_timestamp (buffer, GST_CLOCK_TIME_NONE);
|
||||
check_buffer_duration (buffer, GST_CLOCK_TIME_NONE);
|
||||
check_buffer_granulepos (buffer, 0);
|
||||
check_buffer_is_header (buffer, TRUE);
|
||||
gst_buffer_unref (buffer);
|
||||
|
||||
buffer = gst_buffer_straw_get_buffer (bin, pad);
|
||||
check_buffer_timestamp (buffer, GST_CLOCK_TIME_NONE);
|
||||
check_buffer_duration (buffer, GST_CLOCK_TIME_NONE);
|
||||
check_buffer_granulepos (buffer, 0);
|
||||
check_buffer_is_header (buffer, TRUE);
|
||||
gst_buffer_unref (buffer);
|
||||
|
||||
buffer = gst_buffer_straw_get_buffer (bin, pad);
|
||||
check_buffer_timestamp (buffer, GST_CLOCK_TIME_NONE);
|
||||
check_buffer_duration (buffer, GST_CLOCK_TIME_NONE);
|
||||
check_buffer_granulepos (buffer, 0);
|
||||
check_buffer_is_header (buffer, TRUE);
|
||||
gst_buffer_unref (buffer);
|
||||
|
||||
{
|
||||
buffer = gst_buffer_straw_get_buffer (bin, pad);
|
||||
check_buffer_timestamp (buffer, 0);
|
||||
/* plain division because I know the answer is exact */
|
||||
check_buffer_duration (buffer, GST_SECOND / 10);
|
||||
check_buffer_granulepos (buffer, 1 << GRANULEPOS_SHIFT);
|
||||
check_buffer_is_header (buffer, FALSE);
|
||||
fail_if (GST_BUFFER_IS_DISCONT (buffer), "expected continuous buffer yo");
|
||||
gst_buffer_unref (buffer);
|
||||
|
||||
/* check discontinuity with the next buffer */
|
||||
buffer = gst_buffer_straw_get_buffer (bin, pad);
|
||||
check_buffer_duration (buffer, GST_SECOND / 10);
|
||||
/* After a discont, we'll always get a keyframe, so this one should be
|
||||
* 3<<GRANULEPOS_SHIFT */
|
||||
check_buffer_granulepos (buffer, 3 << GRANULEPOS_SHIFT);
|
||||
check_buffer_is_header (buffer, FALSE);
|
||||
fail_unless (GST_BUFFER_IS_DISCONT (buffer),
|
||||
"expected discontinuous buffer yo");
|
||||
gst_buffer_unref (buffer);
|
||||
|
||||
/* Then the buffer after that should be continuous */
|
||||
buffer = gst_buffer_straw_get_buffer (bin, pad);
|
||||
fail_if (GST_BUFFER_IS_DISCONT (buffer), "expected continuous buffer yo");
|
||||
/* plain division because I know the answer is exact */
|
||||
check_buffer_duration (buffer, GST_SECOND / 10);
|
||||
check_buffer_granulepos (buffer, (3 << GRANULEPOS_SHIFT) | 1);
|
||||
check_buffer_is_header (buffer, FALSE);
|
||||
gst_buffer_unref (buffer);
|
||||
}
|
||||
|
||||
gst_buffer_straw_stop_pipeline (bin, pad);
|
||||
gst_pad_remove_probe (droppad, drop_id);
|
||||
|
||||
gst_object_unref (droppad);
|
||||
gst_object_unref (pad);
|
||||
gst_object_unref (bin);
|
||||
}
|
||||
|
||||
GST_END_TEST;
|
||||
|
||||
#endif /* #ifndef GST_DISABLE_PARSE */
|
||||
|
||||
static Suite *
|
||||
|
@ -443,7 +323,6 @@ theoraenc_suite (void)
|
|||
#ifndef GST_DISABLE_PARSE
|
||||
tcase_add_test (tc_chain, test_granulepos_offset);
|
||||
tcase_add_test (tc_chain, test_continuity);
|
||||
tcase_add_test (tc_chain, test_discontinuity);
|
||||
#endif
|
||||
|
||||
return s;
|
||||
|
|
Loading…
Reference in a new issue