mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-19 20:46:22 +00:00
mpegvideoparse: Only add meta if downstream needs it
It's not perfect, because in the cases where upstream doesn't initiate an allocation query, we won't know.
This commit is contained in:
parent
14e7e78b7a
commit
2296296a51
2 changed files with 50 additions and 21 deletions
|
@ -76,6 +76,8 @@ static GstCaps *gst_mpegv_parse_get_caps (GstBaseParse * parse,
|
||||||
GstCaps * filter);
|
GstCaps * filter);
|
||||||
static GstFlowReturn gst_mpegv_parse_pre_push_frame (GstBaseParse * parse,
|
static GstFlowReturn gst_mpegv_parse_pre_push_frame (GstBaseParse * parse,
|
||||||
GstBaseParseFrame * frame);
|
GstBaseParseFrame * frame);
|
||||||
|
static gboolean gst_mpegv_parse_sink_query (GstBaseParse * parse,
|
||||||
|
GstQuery * query);
|
||||||
|
|
||||||
static void gst_mpegv_parse_set_property (GObject * object, guint prop_id,
|
static void gst_mpegv_parse_set_property (GObject * object, guint prop_id,
|
||||||
const GValue * value, GParamSpec * pspec);
|
const GValue * value, GParamSpec * pspec);
|
||||||
|
@ -165,6 +167,7 @@ gst_mpegv_parse_class_init (GstMpegvParseClass * klass)
|
||||||
parse_class->get_sink_caps = GST_DEBUG_FUNCPTR (gst_mpegv_parse_get_caps);
|
parse_class->get_sink_caps = GST_DEBUG_FUNCPTR (gst_mpegv_parse_get_caps);
|
||||||
parse_class->pre_push_frame =
|
parse_class->pre_push_frame =
|
||||||
GST_DEBUG_FUNCPTR (gst_mpegv_parse_pre_push_frame);
|
GST_DEBUG_FUNCPTR (gst_mpegv_parse_pre_push_frame);
|
||||||
|
parse_class->sink_query = GST_DEBUG_FUNCPTR (gst_mpegv_parse_sink_query);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -197,6 +200,7 @@ gst_mpegv_parse_reset (GstMpegvParse * mpvparse)
|
||||||
mpvparse->profile = 0;
|
mpvparse->profile = 0;
|
||||||
mpvparse->update_caps = TRUE;
|
mpvparse->update_caps = TRUE;
|
||||||
mpvparse->send_codec_tag = TRUE;
|
mpvparse->send_codec_tag = TRUE;
|
||||||
|
mpvparse->send_mpeg_meta = TRUE;
|
||||||
|
|
||||||
gst_buffer_replace (&mpvparse->config, NULL);
|
gst_buffer_replace (&mpvparse->config, NULL);
|
||||||
memset (&mpvparse->sequencehdr, 0, sizeof (mpvparse->sequencehdr));
|
memset (&mpvparse->sequencehdr, 0, sizeof (mpvparse->sequencehdr));
|
||||||
|
@ -212,6 +216,26 @@ gst_mpegv_parse_reset (GstMpegvParse * mpvparse)
|
||||||
mpvparse->quantmatrext_updated = FALSE;
|
mpvparse->quantmatrext_updated = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gst_mpegv_parse_sink_query (GstBaseParse * parse, GstQuery * query)
|
||||||
|
{
|
||||||
|
gboolean res;
|
||||||
|
GstMpegvParse *mpvparse = GST_MPEGVIDEO_PARSE (parse);
|
||||||
|
|
||||||
|
res = GST_BASE_PARSE_CLASS (parent_class)->sink_query (parse, query);
|
||||||
|
|
||||||
|
if (res && GST_QUERY_TYPE (query) == GST_QUERY_ALLOCATION) {
|
||||||
|
mpvparse->send_mpeg_meta =
|
||||||
|
gst_query_find_allocation_meta (query, GST_MPEG_VIDEO_META_API_TYPE,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
GST_DEBUG_OBJECT (parse, "Downstream can handle GstMpegVideo GstMeta : %d",
|
||||||
|
mpvparse->send_mpeg_meta);
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_mpegv_parse_start (GstBaseParse * parse)
|
gst_mpegv_parse_start (GstBaseParse * parse)
|
||||||
{
|
{
|
||||||
|
@ -340,6 +364,8 @@ gst_mpegv_parse_process_config (GstMpegvParse * mpvparse, GstBuffer * buf,
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* FIXME : Move these functions to libgstcodecparser for usage by
|
||||||
|
* more elements/code */
|
||||||
#ifndef GST_DISABLE_GST_DEBUG
|
#ifndef GST_DISABLE_GST_DEBUG
|
||||||
static const gchar *
|
static const gchar *
|
||||||
picture_start_code_name (guint8 psc)
|
picture_start_code_name (guint8 psc)
|
||||||
|
@ -405,6 +431,7 @@ parse_packet_extension (GstMpegvParse * mpvparse, GstBuffer * buf, guint off)
|
||||||
|
|
||||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||||
|
|
||||||
|
/* FIXME : WE ARE ASSUMING IT IS A *PICTURE* EXTENSION */
|
||||||
if (gst_mpeg_video_parse_picture_extension (&mpvparse->picext, map.data,
|
if (gst_mpeg_video_parse_picture_extension (&mpvparse->picext, map.data,
|
||||||
map.size, off)) {
|
map.size, off)) {
|
||||||
mpvparse->frame_repeat_count = 1;
|
mpvparse->frame_repeat_count = 1;
|
||||||
|
@ -866,6 +893,7 @@ gst_mpegv_parse_pre_push_frame (GstBaseParse * parse, GstBaseParseFrame * frame)
|
||||||
/* usual clipping applies */
|
/* usual clipping applies */
|
||||||
frame->flags |= GST_BASE_PARSE_FRAME_FLAG_CLIP;
|
frame->flags |= GST_BASE_PARSE_FRAME_FLAG_CLIP;
|
||||||
|
|
||||||
|
if (mpvparse->send_mpeg_meta) {
|
||||||
if (mpvparse->seqhdr_updated)
|
if (mpvparse->seqhdr_updated)
|
||||||
seq_hdr = &mpvparse->sequencehdr;
|
seq_hdr = &mpvparse->sequencehdr;
|
||||||
if (mpvparse->seqext_updated)
|
if (mpvparse->seqext_updated)
|
||||||
|
@ -882,12 +910,12 @@ gst_mpegv_parse_pre_push_frame (GstBaseParse * parse, GstBaseParseFrame * frame)
|
||||||
"Adding GstMpegVideoMeta (slice_count:%d, slice_offset:%d)",
|
"Adding GstMpegVideoMeta (slice_count:%d, slice_offset:%d)",
|
||||||
mpvparse->slice_count, mpvparse->slice_offset);
|
mpvparse->slice_count, mpvparse->slice_offset);
|
||||||
meta =
|
meta =
|
||||||
gst_buffer_add_mpeg_video_meta (frame->
|
gst_buffer_add_mpeg_video_meta (frame->out_buffer ? frame->
|
||||||
out_buffer ? frame->out_buffer : frame->buffer, seq_hdr, seq_ext,
|
out_buffer : frame->buffer, seq_hdr, seq_ext, disp_ext, pic_hdr,
|
||||||
disp_ext, pic_hdr, pic_ext, quant_ext);
|
pic_ext, quant_ext);
|
||||||
meta->num_slices = mpvparse->slice_count;
|
meta->num_slices = mpvparse->slice_count;
|
||||||
meta->slice_offset = mpvparse->slice_offset;
|
meta->slice_offset = mpvparse->slice_offset;
|
||||||
|
}
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,6 +69,7 @@ struct _GstMpegvParse {
|
||||||
guint slice_offset;
|
guint slice_offset;
|
||||||
gboolean update_caps;
|
gboolean update_caps;
|
||||||
gboolean send_codec_tag;
|
gboolean send_codec_tag;
|
||||||
|
gboolean send_mpeg_meta;
|
||||||
|
|
||||||
GstBuffer *config;
|
GstBuffer *config;
|
||||||
guint8 profile;
|
guint8 profile;
|
||||||
|
|
Loading…
Reference in a new issue