mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 20:21:24 +00:00
vaapiencode: h264,h265: validate fps numerator
Validate that fps numerator is non-zero so it can be used to calculate the duration of the B frame. Also it gst_util_uint64_scale() is used instead of normal arithmetic in order to aviod overflows, underflows and loss of precision. https://bugzilla.gnome.org/show_bug.cgi?id=768458
This commit is contained in:
parent
f182b8be2b
commit
4259d1aec7
2 changed files with 8 additions and 8 deletions
|
@ -2467,11 +2467,11 @@ reset_properties (GstVaapiEncoderH264 * encoder)
|
|||
encoder->num_bframes = 0;
|
||||
}
|
||||
|
||||
if (encoder->num_bframes)
|
||||
encoder->cts_offset = GST_SECOND * GST_VAAPI_ENCODER_FPS_D (encoder) /
|
||||
GST_VAAPI_ENCODER_FPS_N (encoder);
|
||||
if (encoder->num_bframes > 0 && GST_VAAPI_ENCODER_FPS_N (encoder) > 0)
|
||||
encoder->cts_offset = gst_util_uint64_scale (GST_SECOND,
|
||||
GST_VAAPI_ENCODER_FPS_D (encoder), GST_VAAPI_ENCODER_FPS_N (encoder));
|
||||
else
|
||||
encoder->cts_offset = 0;
|
||||
encoder->cts_offset = GST_CLOCK_TIME_NONE;
|
||||
|
||||
/* init max_frame_num, max_poc */
|
||||
encoder->log2_max_frame_num =
|
||||
|
|
|
@ -2030,11 +2030,11 @@ reset_properties (GstVaapiEncoderH265 * encoder)
|
|||
if (encoder->num_bframes > (base_encoder->keyframe_period + 1) / 2)
|
||||
encoder->num_bframes = (base_encoder->keyframe_period + 1) / 2;
|
||||
|
||||
if (encoder->num_bframes)
|
||||
encoder->cts_offset = GST_SECOND * GST_VAAPI_ENCODER_FPS_D (encoder) /
|
||||
GST_VAAPI_ENCODER_FPS_N (encoder);
|
||||
if (encoder->num_bframes > 0 && GST_VAAPI_ENCODER_FPS_N (encoder) > 0)
|
||||
encoder->cts_offset = gst_util_uint64_scale (GST_SECOND,
|
||||
GST_VAAPI_ENCODER_FPS_D (encoder), GST_VAAPI_ENCODER_FPS_N (encoder));
|
||||
else
|
||||
encoder->cts_offset = 0;
|
||||
encoder->cts_offset = GST_CLOCK_TIME_NONE;
|
||||
|
||||
/* init max_poc */
|
||||
encoder->log2_max_pic_order_cnt =
|
||||
|
|
Loading…
Reference in a new issue