Commit 87403135 authored by Mario Sanchez Prada's avatar Mario Sanchez Prada Committed by Tim-Philipp Müller

vpxenc: Properly handle frames with too low duration

When a frame's duration is too low, calling gst_util_uint64_scale()
to scale its value can result into it being truncated to zero, which
will cause the vpx encoder to return an VPX_CODEC_INVALID_PARAM error
when trying to encode.

To prevent this from happening, we simply ignore the duration when
encoding if it becomes zero after scaling, logging a warning message.

https://bugzilla.gnome.org/show_bug.cgi?id=765391
parent 4ba6214d
......@@ -1888,7 +1888,17 @@ gst_vpx_enc_handle_frame (GstVideoEncoder * video_encoder,
duration =
gst_util_uint64_scale (frame->duration, encoder->cfg.g_timebase.den,
encoder->cfg.g_timebase.num * (GstClockTime) GST_SECOND);
if (duration > 0) {
encoder->last_pts += frame->duration;
} else {
/* We force the path ignoring the duration if we end up with a zero
* value for duration after scaling (e.g. duration value too small) */
GST_WARNING_OBJECT (encoder,
"Ignoring too small frame duration %" GST_TIME_FORMAT,
GST_TIME_ARGS (frame->duration));
duration = 1;
}
} else {
duration = 1;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment