2012-03-07 09:18:49 +00:00
|
|
|
/* 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
|
2012-11-03 23:05:09 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2012-03-07 09:18:49 +00:00
|
|
|
*/
|
|
|
|
|
2013-08-16 12:47:31 +00:00
|
|
|
#ifndef __GST_VIDEO_H__
|
|
|
|
#include <gst/video/video.h>
|
|
|
|
#endif
|
|
|
|
|
2012-03-07 09:18:49 +00:00
|
|
|
#ifndef _GST_VIDEO_UTILS_H_
|
|
|
|
#define _GST_VIDEO_UTILS_H_
|
|
|
|
|
|
|
|
#include <gst/gst.h>
|
2018-03-13 11:48:31 +00:00
|
|
|
#include <gst/video/video-prelude.h>
|
2012-03-07 09:18:49 +00:00
|
|
|
|
|
|
|
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
|
2016-03-31 13:31:31 +00:00
|
|
|
* @caps: The #GstCaps used in the caps negotiation of the pad.
|
2014-03-02 04:06:07 +00:00
|
|
|
* @codec_data: a #GstBuffer corresponding to the
|
|
|
|
* 'codec_data' field of a stream, or NULL.
|
2016-03-31 13:31:31 +00:00
|
|
|
* @allocation_caps: The #GstCaps for allocation query and pool
|
|
|
|
* negotiation. Since: 1.10
|
2012-03-07 09:18:49 +00:00
|
|
|
*
|
|
|
|
* 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;
|
|
|
|
|
2016-03-31 13:31:31 +00:00
|
|
|
GstCaps *allocation_caps;
|
|
|
|
|
2012-03-07 09:18:49 +00:00
|
|
|
/*< private >*/
|
2018-02-07 16:40:49 +00:00
|
|
|
gpointer padding[GST_PADDING_LARGE - 1];
|
2012-03-07 09:18:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*
|
|
|
|
* 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),
|
2012-04-25 16:21:03 +00:00
|
|
|
GST_VIDEO_CODEC_FRAME_FLAG_FORCE_KEYFRAME_HEADERS = (1<<3)
|
2012-03-07 09:18:49 +00:00
|
|
|
} 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.
|
2012-07-05 12:29:42 +00:00
|
|
|
* @input_buffer: the input #GstBuffer that created this frame. The buffer is owned
|
|
|
|
* by the frame and references to the frame instead of the buffer should
|
2015-04-16 13:03:05 +00:00
|
|
|
* be kept.
|
2012-03-07 09:18:49 +00:00
|
|
|
* @output_buffer: the output #GstBuffer. Implementations should set this either
|
2013-12-07 00:27:04 +00:00
|
|
|
* directly, or by using the
|
|
|
|
* @gst_video_decoder_allocate_output_frame() or
|
|
|
|
* @gst_video_decoder_allocate_output_buffer() methods. The buffer is
|
|
|
|
* owned by the frame and references to the frame instead of the
|
|
|
|
* buffer should be kept.
|
2012-03-07 09:18:49 +00:00
|
|
|
* @deadline: Running time when the frame will be used.
|
|
|
|
*
|
|
|
|
* A #GstVideoCodecFrame represents a video frame both in raw and
|
|
|
|
* encoded form.
|
|
|
|
*/
|
|
|
|
struct _GstVideoCodecFrame
|
|
|
|
{
|
|
|
|
/*< private >*/
|
|
|
|
gint ref_count;
|
|
|
|
guint32 flags;
|
|
|
|
|
|
|
|
/*< public >*/
|
2012-07-26 16:36:53 +00:00
|
|
|
guint32 system_frame_number; /* ED */
|
2018-04-02 06:34:58 +00:00
|
|
|
|
|
|
|
/*< private >*/
|
2012-07-26 16:36:53 +00:00
|
|
|
guint32 decode_frame_number; /* ED */
|
|
|
|
guint32 presentation_frame_number; /* ED */
|
2012-03-07 09:18:49 +00:00
|
|
|
|
2018-04-02 06:34:58 +00:00
|
|
|
/*< public >*/
|
2012-03-07 09:18:49 +00:00
|
|
|
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 */
|
|
|
|
|
2012-05-16 11:46:57 +00:00
|
|
|
/*< private >*/
|
|
|
|
|
2012-03-07 09:18:49 +00:00
|
|
|
/* Events that should be pushed downstream *before*
|
|
|
|
* the next output_buffer */
|
|
|
|
GList *events; /* ED */
|
|
|
|
|
2012-05-16 11:46:57 +00:00
|
|
|
gpointer user_data;
|
|
|
|
GDestroyNotify user_data_destroy_notify;
|
2012-03-07 09:18:49 +00:00
|
|
|
|
2012-09-28 11:59:24 +00:00
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
GstClockTime ts;
|
2012-10-10 13:04:07 +00:00
|
|
|
GstClockTime ts2;
|
2012-09-28 11:59:24 +00:00
|
|
|
} ABI;
|
2018-02-07 16:40:49 +00:00
|
|
|
gpointer padding[GST_PADDING_LARGE];
|
2012-09-28 11:59:24 +00:00
|
|
|
} abidata;
|
2012-03-07 09:18:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* GstVideoCodecState */
|
2017-05-16 00:09:38 +00:00
|
|
|
|
2018-03-13 11:48:31 +00:00
|
|
|
GST_VIDEO_API
|
2012-03-07 09:18:49 +00:00
|
|
|
GType gst_video_codec_state_get_type (void);
|
|
|
|
|
2018-03-13 11:48:31 +00:00
|
|
|
GST_VIDEO_API
|
2012-03-07 09:18:49 +00:00
|
|
|
GstVideoCodecState *gst_video_codec_state_ref (GstVideoCodecState * state);
|
|
|
|
|
2018-03-13 11:48:31 +00:00
|
|
|
GST_VIDEO_API
|
2012-03-07 09:18:49 +00:00
|
|
|
void gst_video_codec_state_unref (GstVideoCodecState * state);
|
|
|
|
|
|
|
|
|
|
|
|
/* GstVideoCodecFrame */
|
2017-05-16 00:09:38 +00:00
|
|
|
|
2018-03-13 11:48:31 +00:00
|
|
|
GST_VIDEO_API
|
2012-03-07 09:18:49 +00:00
|
|
|
GType gst_video_codec_frame_get_type (void);
|
|
|
|
|
2018-03-13 11:48:31 +00:00
|
|
|
GST_VIDEO_API
|
2012-03-07 09:18:49 +00:00
|
|
|
GstVideoCodecFrame *gst_video_codec_frame_ref (GstVideoCodecFrame * frame);
|
2017-05-16 00:09:38 +00:00
|
|
|
|
2018-03-13 11:48:31 +00:00
|
|
|
GST_VIDEO_API
|
2012-03-07 09:18:49 +00:00
|
|
|
void gst_video_codec_frame_unref (GstVideoCodecFrame * frame);
|
2017-05-16 00:09:38 +00:00
|
|
|
|
2018-03-13 11:48:31 +00:00
|
|
|
GST_VIDEO_API
|
2012-05-16 11:46:57 +00:00
|
|
|
void gst_video_codec_frame_set_user_data (GstVideoCodecFrame *frame,
|
|
|
|
gpointer user_data,
|
|
|
|
GDestroyNotify notify);
|
2017-05-16 00:09:38 +00:00
|
|
|
|
2018-03-13 11:48:31 +00:00
|
|
|
GST_VIDEO_API
|
2012-05-16 11:46:57 +00:00
|
|
|
gpointer gst_video_codec_frame_get_user_data (GstVideoCodecFrame *frame);
|
2012-03-07 09:18:49 +00:00
|
|
|
|
2015-11-10 17:54:23 +00:00
|
|
|
#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
|
|
|
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstVideoCodecFrame, gst_video_codec_frame_unref)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
|
|
|
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstVideoCodecState, gst_video_codec_state_unref)
|
|
|
|
#endif
|
|
|
|
|
2012-03-07 09:18:49 +00:00
|
|
|
G_END_DECLS
|
|
|
|
|
|
|
|
#endif
|