mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-22 14:06:23 +00:00
h263parse: update to latest baseparse
This commit is contained in:
parent
46308f8c53
commit
1664b3000f
3 changed files with 518 additions and 259 deletions
File diff suppressed because it is too large
Load diff
|
@ -46,7 +46,7 @@ G_BEGIN_DECLS
|
|||
*
|
||||
* the name of the templates for the source pad
|
||||
*/
|
||||
#define GST_BASE_PARSE_SRC_NAME "src"
|
||||
#define GST_BASE_PARSE_SRC_NAME "src"
|
||||
|
||||
/**
|
||||
* GST_BASE_PARSE_SRC_PAD:
|
||||
|
@ -56,7 +56,7 @@ G_BEGIN_DECLS
|
|||
*
|
||||
* Since: 0.10.x
|
||||
*/
|
||||
#define GST_BASE_PARSE_SRC_PAD(obj) (GST_BASE_PARSE_CAST (obj)->srcpad)
|
||||
#define GST_BASE_PARSE_SRC_PAD(obj) (GST_BASE_PARSE_CAST (obj)->srcpad)
|
||||
|
||||
/**
|
||||
* GST_BASE_PARSE_SINK_PAD:
|
||||
|
@ -87,37 +87,113 @@ G_BEGIN_DECLS
|
|||
*
|
||||
* Since: 0.10.x
|
||||
*/
|
||||
#define GST_BASE_PARSE_FLOW_DROPPED GST_FLOW_CUSTOM_SUCCESS
|
||||
#define GST_BASE_PARSE_FLOW_DROPPED GST_FLOW_CUSTOM_SUCCESS
|
||||
|
||||
/**
|
||||
* GST_BASE_PARSE_FLOW_CLIP:
|
||||
* GstBaseParseFrameFlags:
|
||||
* @GST_BASE_PARSE_FRAME_FLAG_NONE: no flag
|
||||
* @GST_BASE_PARSE_FRAME_FLAG_SYNC: indicates if parsing is 'in sync'
|
||||
* @GST_BASE_PARSE_FRAME_FLAG_DRAIN: indicates if parser is 'draining'.
|
||||
* That is, leftover data (e.g. in FLUSH or EOS situation) is being parsed.
|
||||
* @GST_BASE_PARSE_FRAME_FLAG_NO_FRAME: set to indicate this buffer should not be
|
||||
* counted as frame, e.g. if this frame is dependent on a previous one.
|
||||
* As it is not counted as a frame, bitrate increases but frame to time
|
||||
* conversions are maintained.
|
||||
* @GST_BASE_PARSE_FRAME_FLAG_CLIP: @pre_push_buffer can set this to indicate
|
||||
* that regular segment clipping can still be performed (as opposed to
|
||||
* any custom one having been done).
|
||||
*
|
||||
* A #GstFlowReturn that can be returned from pre_push_buffer to
|
||||
* indicate that regular segment clipping should be performed.
|
||||
* Flags to be used in a #GstBaseParseFrame.
|
||||
*
|
||||
* Since: 0.10.x
|
||||
*/
|
||||
#define GST_BASE_PARSE_FLOW_CLIP GST_FLOW_CUSTOM_SUCCESS_1
|
||||
typedef enum {
|
||||
GST_BASE_PARSE_FRAME_FLAG_NONE = 0,
|
||||
GST_BASE_PARSE_FRAME_FLAG_SYNC = (1 << 0),
|
||||
GST_BASE_PARSE_FRAME_FLAG_DRAIN = (1 << 1),
|
||||
GST_BASE_PARSE_FRAME_FLAG_NO_FRAME = (1 << 2),
|
||||
GST_BASE_PARSE_FRAME_FLAG_CLIP = (1 << 3)
|
||||
} GstBaseParseFrameFlags;
|
||||
|
||||
/**
|
||||
* GST_BASE_PARSE_BUFFER_FLAG_NO_FRAME:
|
||||
* GstBaseParseFrame:
|
||||
* @buffer: data to check for valid frame or parsed frame.
|
||||
* Subclass is allowed to replace this buffer.
|
||||
* @overhead: subclass can set this to indicates the metadata overhead
|
||||
* for the given frame, which is then used to enable more accurate bitrate
|
||||
* computations. If this is -1, it is assumed that this frame should be
|
||||
* skipped in bitrate calculation.
|
||||
* @flags: a combination of input and output #GstBaseParseFrameFlags that
|
||||
* convey additional context to subclass or allow subclass to tune
|
||||
* subsequent #GstBaseParse actions.
|
||||
*
|
||||
* A #GstBufferFlag that can be set to have this buffer not counted as frame,
|
||||
* e.g. if this frame is dependent on a previous one. As it is not counted as
|
||||
* a frame, bitrate increases but frame to time conversions are maintained.
|
||||
* Frame (context) data passed to each frame parsing virtual methods. In
|
||||
* addition to providing the data to be checked for a valid frame or an already
|
||||
* identified frame, it conveys additional metadata or control information
|
||||
* from and to the subclass w.r.t. the particular frame in question (rather
|
||||
* than global parameters). Some of these may apply to each parsing stage, others
|
||||
* only to some a particular one. These parameters are effectively zeroed at start
|
||||
* of each frame's processing, i.e. parsing virtual method invocation sequence.
|
||||
*
|
||||
* Since: 0.10.x
|
||||
*/
|
||||
#define GST_BASE_PARSE_BUFFER_FLAG_NO_FRAME GST_BUFFER_FLAG_LAST
|
||||
typedef struct {
|
||||
GstBuffer *buffer;
|
||||
guint flags;
|
||||
gint overhead;
|
||||
} GstBaseParseFrame;
|
||||
|
||||
/**
|
||||
* GST_BASE_PARSE_FRAME_SYNC:
|
||||
* @frame: base parse frame instance
|
||||
*
|
||||
* Obtains current sync status indicated in frame.
|
||||
*
|
||||
* Since: 0.10.x
|
||||
*/
|
||||
#define GST_BASE_PARSE_FRAME_SYNC(frame) (!!(frame->flags & GST_BASE_PARSE_FRAME_FLAG_SYNC))
|
||||
|
||||
/**
|
||||
* GST_BASE_PARSE_FRAME_DRAIN:
|
||||
* @frame: base parse frame instance
|
||||
*
|
||||
* Obtains current drain status indicated in frame.
|
||||
*
|
||||
* Since: 0.10.x
|
||||
*/
|
||||
#define GST_BASE_PARSE_FRAME_DRAIN(frame) (!!(frame->flags & GST_BASE_PARSE_FRAME_FLAG_DRAIN))
|
||||
|
||||
/**
|
||||
* GstBaseParseFormat:
|
||||
* @GST_BASE_PARSE_FORMAT_NONE: default setting
|
||||
* @GST_BASE_PARSE_FORMAT_PASSTHROUGH: nature of format or configuration
|
||||
* does not allow (much) parsing, so parser should operate in passthrough mode
|
||||
* (which only applies operating in pull mode). That is, incoming buffers
|
||||
* are pushed through unmodified, i.e. no @check_valid_frame or @parse_frame
|
||||
* callbacks will be invoked. On the other hand, @pre_push_buffer is still invoked,
|
||||
* where subclass can perform as much or as little is appropriate for
|
||||
* "passthrough" semantics.
|
||||
* @GST_BASE_PARSE_FORMAT_HAS_TIME: frames carry timing info which subclass
|
||||
* can (generally) parse and provide. In particular, intrinsic time
|
||||
* (rather than estimated) can be obtained following seek.
|
||||
*
|
||||
* Since: 0.10.x
|
||||
*/
|
||||
typedef enum _GstBaseParseFormat {
|
||||
GST_BASE_PARSE_FORMAT_NONE = 0,
|
||||
GST_BASE_PARSE_FORMAT_PASSTHROUGH = (1 << 0),
|
||||
GST_BASE_PARSE_FORMAT_HAS_TIME = (1 << 1),
|
||||
} GstBaseParseFormat;
|
||||
|
||||
/**
|
||||
* GstBaseParseSeekable:
|
||||
* @GST_BASE_PARSE_SEEK_NONE: No seeking possible.
|
||||
* GST_BASE_PARSE_SEEK_DEFAULT: Default seeking possible using estimated bitrate.
|
||||
* GST_BASE_PARSE_SEEK_TABLE: Additional metadata provides more accurate seeking.
|
||||
* @GST_BASE_PARSE_SEEK_DEFAULT: Default seeking possible using estimated bitrate.
|
||||
* @GST_BASE_PARSE_SEEK_TABLE: Additional metadata provides more accurate seeking.
|
||||
*
|
||||
* Indicates what level (of quality) of seeking is possible.
|
||||
*
|
||||
* Since: 0.10.x
|
||||
*/
|
||||
typedef enum _GstBaseParseSeekable {
|
||||
GST_BASE_PARSE_SEEK_NONE,
|
||||
|
@ -200,7 +276,7 @@ struct _GstBaseParse {
|
|||
* Called just prior to pushing a frame (after any pending
|
||||
* events have been sent) to give subclass a chance to perform
|
||||
* additional actions at this time (e.g. tag sending) or to
|
||||
* decide whether this buffer should be dropped or no
|
||||
* decide whether this buffer should be dropped or not
|
||||
* (e.g. custom segment clipping).
|
||||
*
|
||||
* Subclasses can override any of the available virtual methods or not, as
|
||||
|
@ -221,12 +297,15 @@ struct _GstBaseParseClass {
|
|||
GstCaps *caps);
|
||||
|
||||
gboolean (*check_valid_frame) (GstBaseParse *parse,
|
||||
GstBuffer *buffer,
|
||||
GstBaseParseFrame *frame,
|
||||
guint *framesize,
|
||||
gint *skipsize);
|
||||
|
||||
GstFlowReturn (*parse_frame) (GstBaseParse *parse,
|
||||
GstBuffer *buffer);
|
||||
GstBaseParseFrame *frame);
|
||||
|
||||
GstFlowReturn (*pre_push_frame) (GstBaseParse *parse,
|
||||
GstBaseParseFrame *frame);
|
||||
|
||||
gboolean (*convert) (GstBaseParse * parse,
|
||||
GstFormat src_format,
|
||||
|
@ -234,56 +313,45 @@ struct _GstBaseParseClass {
|
|||
GstFormat dest_format,
|
||||
gint64 * dest_value);
|
||||
|
||||
gboolean (*find_frame) (GstBaseParse *parse,
|
||||
GstFormat src_format,
|
||||
gint64 src_value,
|
||||
gint64 * dest_value);
|
||||
|
||||
gboolean (*event) (GstBaseParse *parse,
|
||||
GstEvent *event);
|
||||
|
||||
gboolean (*src_event) (GstBaseParse *parse,
|
||||
GstEvent *event);
|
||||
|
||||
gint (*get_frame_overhead) (GstBaseParse *parse,
|
||||
GstBuffer *buf);
|
||||
|
||||
GstFlowReturn (*pre_push_buffer) (GstBaseParse *parse,
|
||||
GstBuffer *buf);
|
||||
|
||||
/*< private >*/
|
||||
gpointer _gst_reserved[GST_PADDING_LARGE];
|
||||
gpointer _gst_reserved[GST_PADDING_LARGE];
|
||||
};
|
||||
|
||||
GType gst_base_parse_get_type (void);
|
||||
|
||||
void gst_base_parse_frame_init (GstBaseParse * parse,
|
||||
GstBaseParseFrame * frame);
|
||||
GstFlowReturn gst_base_parse_push_frame (GstBaseParse *parse,
|
||||
GstBaseParseFrame *frame);
|
||||
|
||||
GstFlowReturn gst_base_parse_push_buffer (GstBaseParse *parse,
|
||||
GstBuffer *buffer);
|
||||
void gst_base_parse_set_duration (GstBaseParse *parse,
|
||||
GstFormat fmt, gint64 duration,
|
||||
gint interval);
|
||||
void gst_base_parse_set_seek (GstBaseParse * parse,
|
||||
GstBaseParseSeekable seek,
|
||||
guint bitrate);
|
||||
void gst_base_parse_set_min_frame_size (GstBaseParse *parse,
|
||||
guint min_size);
|
||||
void gst_base_parse_set_format (GstBaseParse * parse,
|
||||
GstBaseParseFormat flag,
|
||||
gboolean on);
|
||||
void gst_base_parse_set_frame_props (GstBaseParse * parse,
|
||||
guint fps_num, guint fps_den,
|
||||
guint lead_in, guint lead_out);
|
||||
|
||||
void gst_base_parse_set_duration (GstBaseParse *parse,
|
||||
GstFormat fmt, gint64 duration, gint interval);
|
||||
gboolean gst_base_parse_convert_default (GstBaseParse * parse,
|
||||
GstFormat src_format, gint64 src_value,
|
||||
GstFormat dest_format, gint64 * dest_value);
|
||||
|
||||
void gst_base_parse_set_seek (GstBaseParse * parse,
|
||||
GstBaseParseSeekable seek, guint bitrate);
|
||||
|
||||
void gst_base_parse_set_min_frame_size (GstBaseParse *parse,
|
||||
guint min_size);
|
||||
void gst_base_parse_set_passthrough (GstBaseParse * parse, gboolean passthrough);
|
||||
|
||||
void gst_base_parse_set_frame_props (GstBaseParse * parse, guint fps_num,
|
||||
guint fps_den, guint lead_in, guint lead_out);
|
||||
|
||||
gboolean gst_base_parse_get_sync (GstBaseParse * parse);
|
||||
|
||||
gboolean gst_base_parse_get_drain (GstBaseParse * parse);
|
||||
|
||||
gboolean gst_base_parse_convert_default (GstBaseParse * parse,
|
||||
GstFormat src_format, gint64 src_value,
|
||||
GstFormat dest_format, gint64 * dest_value);
|
||||
|
||||
gboolean gst_base_parse_add_index_entry (GstBaseParse * parse, guint64 offset,
|
||||
GstClockTime ts, gboolean key, gboolean force);
|
||||
gboolean gst_base_parse_add_index_entry (GstBaseParse * parse,
|
||||
guint64 offset, GstClockTime ts,
|
||||
gboolean key, gboolean force);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
@ -56,9 +56,9 @@ static gboolean gst_h263_parse_stop (GstBaseParse * parse);
|
|||
static gboolean gst_h263_parse_sink_event (GstBaseParse * parse,
|
||||
GstEvent * event);
|
||||
static gboolean gst_h263_parse_check_valid_frame (GstBaseParse * parse,
|
||||
GstBuffer * buffer, guint * framesize, gint * skipsize);
|
||||
GstBaseParseFrame * frame, guint * framesize, gint * skipsize);
|
||||
static GstFlowReturn gst_h263_parse_parse_frame (GstBaseParse * parse,
|
||||
GstBuffer * buffer);
|
||||
GstBaseParseFrame * frame);
|
||||
|
||||
static void
|
||||
gst_h263_parse_base_init (gpointer g_class)
|
||||
|
@ -111,7 +111,6 @@ gst_h263_parse_start (GstBaseParse * parse)
|
|||
h263parse->state = PARSING;
|
||||
|
||||
gst_base_parse_set_min_frame_size (parse, 512);
|
||||
gst_base_parse_set_passthrough (parse, FALSE);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -244,13 +243,15 @@ gst_h263_parse_set_src_caps (GstH263Parse * h263parse, H263Params * params)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
gst_h263_parse_check_valid_frame (GstBaseParse * parse, GstBuffer * buffer,
|
||||
guint * framesize, gint * skipsize)
|
||||
gst_h263_parse_check_valid_frame (GstBaseParse * parse,
|
||||
GstBaseParseFrame * frame, guint * framesize, gint * skipsize)
|
||||
{
|
||||
GstH263Parse *h263parse;
|
||||
GstBuffer *buffer;
|
||||
guint psc_pos, next_psc_pos;
|
||||
|
||||
h263parse = GST_H263_PARSE (parse);
|
||||
buffer = frame->buffer;
|
||||
|
||||
if (GST_BUFFER_SIZE (buffer) < 3)
|
||||
return FALSE;
|
||||
|
@ -271,7 +272,7 @@ gst_h263_parse_check_valid_frame (GstBaseParse * parse, GstBuffer * buffer,
|
|||
next_psc_pos = find_psc (buffer, next_psc_pos);
|
||||
|
||||
if (next_psc_pos == -1) {
|
||||
if (gst_base_parse_get_drain (GST_BASE_PARSE (h263parse)))
|
||||
if (GST_BASE_PARSE_FRAME_DRAIN (frame))
|
||||
/* FLUSH/EOS, it's okay if we can't find the next frame */
|
||||
next_psc_pos = GST_BUFFER_SIZE (buffer);
|
||||
else
|
||||
|
@ -288,7 +289,8 @@ gst_h263_parse_check_valid_frame (GstBaseParse * parse, GstBuffer * buffer,
|
|||
res = gst_h263_parse_get_params (¶ms, buffer, FALSE, &h263parse->state);
|
||||
if (res != GST_FLOW_OK || h263parse->state != GOT_HEADER) {
|
||||
GST_WARNING ("Couldn't parse header - setting passthrough mode");
|
||||
gst_base_parse_set_passthrough (parse, TRUE);
|
||||
gst_base_parse_set_format (parse,
|
||||
GST_BASE_PARSE_FORMAT_PASSTHROUGH, TRUE);
|
||||
} else {
|
||||
/* Set srcpad caps since we now have sufficient information to do so */
|
||||
gst_h263_parse_set_src_caps (h263parse, params);
|
||||
|
@ -318,13 +320,15 @@ more:
|
|||
}
|
||||
|
||||
static GstFlowReturn
|
||||
gst_h263_parse_parse_frame (GstBaseParse * parse, GstBuffer * buffer)
|
||||
gst_h263_parse_parse_frame (GstBaseParse * parse, GstBaseParseFrame * frame)
|
||||
{
|
||||
GstH263Parse *h263parse;
|
||||
GstBuffer *buffer;
|
||||
GstFlowReturn res;
|
||||
H263Params *params = NULL;
|
||||
|
||||
h263parse = GST_H263_PARSE (parse);
|
||||
buffer = frame->buffer;
|
||||
|
||||
res = gst_h263_parse_get_params (¶ms, buffer, TRUE, &h263parse->state);
|
||||
if (res != GST_FLOW_OK)
|
||||
|
@ -335,7 +339,7 @@ gst_h263_parse_parse_frame (GstBaseParse * parse, GstBuffer * buffer)
|
|||
* parse the header, which should not be possible. Either way, go into
|
||||
* passthrough mode and let downstream handle it if it can. */
|
||||
GST_WARNING ("Couldn't parse header - setting passthrough mode");
|
||||
gst_base_parse_set_passthrough (parse, TRUE);
|
||||
gst_base_parse_set_format (parse, GST_BASE_PARSE_FORMAT_PASSTHROUGH, TRUE);
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue