From 1e829696e83bab49cae120f81c326d7a3a84f84a Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Wed, 11 May 2022 15:18:42 +0200 Subject: [PATCH] vpxenc: fix crash if encoder produces unmatching ts If for some reason the encoder produces frames with a pts higher than the input one, we were dropping all the video encoder frames and ended up crashing when trying to access the pts of a NULL pointer returned by gst_video_encoder_get_oldest_frame(). I hit this scenario by feeding a decreasing timestamp to vp8enc which seem to confuse the encoder. Part-of: --- subprojects/gst-plugins-good/ext/vpx/gstvpxenc.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/subprojects/gst-plugins-good/ext/vpx/gstvpxenc.c b/subprojects/gst-plugins-good/ext/vpx/gstvpxenc.c index 9781cc6..85af4c0 100644 --- a/subprojects/gst-plugins-good/ext/vpx/gstvpxenc.c +++ b/subprojects/gst-plugins-good/ext/vpx/gstvpxenc.c @@ -2033,6 +2033,13 @@ gst_vpx_enc_process (GstVPXEnc * encoder) if (frame) gst_video_encoder_finish_frame (video_encoder, frame); frame = gst_video_encoder_get_oldest_frame (video_encoder); + if (!frame) { + GST_WARNING_OBJECT (encoder, + "vpx pts %" G_GINT64_FORMAT + " does not match input frames, discarding", pkt->data.frame.pts); + goto out; + } + pts = gst_util_uint64_scale (frame->pts, encoder->cfg.g_timebase.den, @@ -2099,6 +2106,8 @@ gst_vpx_enc_process (GstVPXEnc * encoder) pkt = vpx_codec_get_cx_data (&encoder->encoder, &iter); } + +out: g_mutex_unlock (&encoder->encoder_lock); return ret; -- 2.7.4