summaryrefslogtreecommitdiff
path: root/gst-libs
diff options
context:
space:
mode:
authorVíctor Manuel Jáquez Leal <vjaquez@igalia.com>2021-09-07 09:45:54 +0200
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>2021-09-17 12:48:33 +0000
commitf51371d7b9b628b95e635d45d44345c7de2dd20f (patch)
tree91449ffbc6c5ba766517eba08aec1c77b8dd1c39 /gst-libs
parent7d1f6459a09f23d6f0735956f0cd14fdefdaf16d (diff)
downloadgstreamer-plugins-bad-f51371d7b9b628b95e635d45d44345c7de2dd20f.tar.gz
codecs: mpeg2decoder: Use tsg framerate for latency.
Latency setting relies on src pad caps, but they aren't set when the function is called, and latency is never updated. In order to fix it, this patch uses TSG framerate first, and if it's not set yet, sinkpad caps are used to get the framerate. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2514>
Diffstat (limited to 'gst-libs')
-rw-r--r--gst-libs/gst/codecs/gstmpeg2decoder.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/gst-libs/gst/codecs/gstmpeg2decoder.c b/gst-libs/gst/codecs/gstmpeg2decoder.c
index d9c275349..ae0e331e6 100644
--- a/gst-libs/gst/codecs/gstmpeg2decoder.c
+++ b/gst-libs/gst/codecs/gstmpeg2decoder.c
@@ -404,21 +404,27 @@ gst_mpeg2_decoder_set_latency (GstMpeg2Decoder * decoder)
{
GstCaps *caps;
GstClockTime min, max;
+ GstMpeg2DecoderPrivate *priv = decoder->priv;
GstStructure *structure;
gint fps_d = 1, fps_n = 0;
- caps = gst_pad_get_current_caps (GST_VIDEO_DECODER_SRC_PAD (decoder));
- if (!caps)
- return;
-
- structure = gst_caps_get_structure (caps, 0);
- if (gst_structure_get_fraction (structure, "framerate", &fps_n, &fps_d)) {
- if (fps_n == 0) {
- /* variable framerate: see if we have a max-framerate */
- gst_structure_get_fraction (structure, "max-framerate", &fps_n, &fps_d);
+ if (priv->tsg.fps_d > 0 && priv->tsg.fps_n > 0) {
+ fps_n = priv->tsg.fps_n;
+ fps_d = priv->tsg.fps_d;
+ } else {
+ caps = gst_pad_get_current_caps (GST_VIDEO_DECODER_SINK_PAD (decoder));
+ if (caps) {
+ structure = gst_caps_get_structure (caps, 0);
+ if (gst_structure_get_fraction (structure, "framerate", &fps_n, &fps_d)) {
+ if (fps_n == 0) {
+ /* variable framerate: see if we have a max-framerate */
+ gst_structure_get_fraction (structure, "max-framerate", &fps_n,
+ &fps_d);
+ }
+ }
+ gst_caps_unref (caps);
}
}
- gst_caps_unref (caps);
/* if no fps or variable, then 25/1 */
if (fps_n == 0) {