videoparsers: use parsed or upstream fps to set some baseparse parameters

This commit is contained in:
Mark Nauwelaerts 2012-10-25 17:50:52 +02:00
parent 58441bf262
commit 0d1c7f6ea2
3 changed files with 43 additions and 20 deletions

View file

@ -1194,18 +1194,29 @@ gst_h264_parse_update_src_caps (GstH264Parse * h264parse, GstCaps * caps)
} }
if (G_UNLIKELY (modified)) { if (G_UNLIKELY (modified)) {
gint fps_num = h264parse->fps_num;
gint fps_den = h264parse->fps_den;
GstClockTime latency;
caps = gst_caps_copy (sink_caps); caps = gst_caps_copy (sink_caps);
/* sps should give this */ /* sps should give this */
gst_caps_set_simple (caps, "width", G_TYPE_INT, sps->width, gst_caps_set_simple (caps, "width", G_TYPE_INT, sps->width,
"height", G_TYPE_INT, sps->height, NULL); "height", G_TYPE_INT, sps->height, NULL);
/* upstream overrides */
if (s && gst_structure_has_field (s, "framerate"))
gst_structure_get_fraction (s, "framerate", &fps_num, &fps_den);
/* but not necessarily or reliably this */ /* but not necessarily or reliably this */
if (h264parse->fps_num > 0 && h264parse->fps_den > 0 && if (fps_num > 0 && fps_den > 0) {
(!s || !gst_structure_has_field (s, "framerate"))) {
GST_INFO_OBJECT (h264parse, "setting framerate in caps"); GST_INFO_OBJECT (h264parse, "setting framerate in caps");
gst_caps_set_simple (caps, "framerate", gst_caps_set_simple (caps, "framerate",
GST_TYPE_FRACTION, h264parse->fps_num, h264parse->fps_den, NULL); GST_TYPE_FRACTION, fps_num, fps_den, NULL);
gst_base_parse_set_frame_rate (GST_BASE_PARSE (h264parse), gst_base_parse_set_frame_rate (GST_BASE_PARSE (h264parse),
h264parse->fps_num, h264parse->fps_den, 0, 0); fps_num, fps_den, 0, 0);
latency = gst_util_uint64_scale (GST_SECOND, fps_den, fps_num);
gst_base_parse_set_latency (GST_BASE_PARSE (h264parse), latency,
latency);
} }
} }
} }

View file

@ -589,18 +589,24 @@ gst_mpeg4vparse_update_src_caps (GstMpeg4VParse * mp4vparse)
} }
/* perhaps we have a framerate */ /* perhaps we have a framerate */
if (mp4vparse->vol.fixed_vop_time_increment != 0 && {
(!s || !gst_structure_has_field (s, "framerate"))) {
gint fps_num = mp4vparse->vol.vop_time_increment_resolution; gint fps_num = mp4vparse->vol.vop_time_increment_resolution;
gint fps_den = mp4vparse->vol.fixed_vop_time_increment; gint fps_den = mp4vparse->vol.fixed_vop_time_increment;
GstClockTime latency = gst_util_uint64_scale (GST_SECOND, fps_den, fps_num); GstClockTime latency;
/* upstream overrides */
if (s && gst_structure_has_field (s, "framerate"))
gst_structure_get_fraction (s, "framerate", &fps_num, &fps_den);
if (fps_den > 0 && fps_num > 0) {
gst_caps_set_simple (caps, "framerate", gst_caps_set_simple (caps, "framerate",
GST_TYPE_FRACTION, fps_num, fps_den, NULL); GST_TYPE_FRACTION, fps_num, fps_den, NULL);
gst_base_parse_set_frame_rate (GST_BASE_PARSE (mp4vparse), gst_base_parse_set_frame_rate (GST_BASE_PARSE (mp4vparse),
fps_num, fps_den, 0, 0); fps_num, fps_den, 0, 0);
latency = gst_util_uint64_scale (GST_SECOND, fps_den, fps_num);
gst_base_parse_set_latency (GST_BASE_PARSE (mp4vparse), latency, latency); gst_base_parse_set_latency (GST_BASE_PARSE (mp4vparse), latency, latency);
} }
}
/* or pixel-aspect-ratio */ /* or pixel-aspect-ratio */
if (mp4vparse->vol.par_width > 0 && mp4vparse->vol.par_height > 0 && if (mp4vparse->vol.par_width > 0 && mp4vparse->vol.par_height > 0 &&

View file

@ -659,18 +659,24 @@ gst_mpegv_parse_update_src_caps (GstMpegvParse * mpvparse)
} }
/* perhaps we have a framerate */ /* perhaps we have a framerate */
if (mpvparse->fps_num > 0 && mpvparse->fps_den > 0 && {
(!s || !gst_structure_has_field (s, "framerate"))) {
gint fps_num = mpvparse->fps_num; gint fps_num = mpvparse->fps_num;
gint fps_den = mpvparse->fps_den; gint fps_den = mpvparse->fps_den;
GstClockTime latency = gst_util_uint64_scale (GST_SECOND, fps_den, fps_num); GstClockTime latency;
/* upstream overrides */
if (s && gst_structure_has_field (s, "framerate"))
gst_structure_get_fraction (s, "framerate", &fps_num, &fps_den);
if (fps_den > 0 && fps_num > 0) {
gst_caps_set_simple (caps, "framerate", gst_caps_set_simple (caps, "framerate",
GST_TYPE_FRACTION, fps_num, fps_den, NULL); GST_TYPE_FRACTION, fps_num, fps_den, NULL);
gst_base_parse_set_frame_rate (GST_BASE_PARSE (mpvparse), gst_base_parse_set_frame_rate (GST_BASE_PARSE (mpvparse),
fps_num, fps_den, 0, 0); fps_num, fps_den, 0, 0);
latency = gst_util_uint64_scale (GST_SECOND, fps_den, fps_num);
gst_base_parse_set_latency (GST_BASE_PARSE (mpvparse), latency, latency); gst_base_parse_set_latency (GST_BASE_PARSE (mpvparse), latency, latency);
} }
}
/* or pixel-aspect-ratio */ /* or pixel-aspect-ratio */
if (mpvparse->sequencehdr.par_w && mpvparse->sequencehdr.par_h > 0 && if (mpvparse->sequencehdr.par_w && mpvparse->sequencehdr.par_h > 0 &&