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
This commit is contained in:
Mario Sanchez Prada 2016-04-22 15:02:16 +01:00 committed by Tim-Philipp Müller
parent 4ba6214d3a
commit 8740313504

View file

@ -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);
encoder->last_pts += frame->duration;
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;
}