diff options
author | Víctor Manuel Jáquez Leal <victorx.jaquez@intel.com> | 2016-07-21 17:38:40 +0200 |
---|---|---|
committer | Víctor Manuel Jáquez Leal <victorx.jaquez@intel.com> | 2016-08-10 12:20:48 +0200 |
commit | 68b9ab78180c841ad17cb8076c179abdabce8796 (patch) | |
tree | 75ac0fdf323e655a350120d6b823a4cb191918f9 /gst-libs/gst/vaapi/gstvaapiencoder_mpeg2.c | |
parent | 4259d1aec7b046a992ad908804949d2167706280 (diff) |
encoder: h264,h265,mpeg2,vp8: use gst_util_uint64_scale() for bitrate
Use gst_util_uint64_scale() to calculate bitrate instead of normal arithmetic
to avoid overflows, underflows and loss of precision.
https://bugzilla.gnome.org/show_bug.cgi?id=768458
Diffstat (limited to 'gst-libs/gst/vaapi/gstvaapiencoder_mpeg2.c')
-rw-r--r-- | gst-libs/gst/vaapi/gstvaapiencoder_mpeg2.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/gst-libs/gst/vaapi/gstvaapiencoder_mpeg2.c b/gst-libs/gst/vaapi/gstvaapiencoder_mpeg2.c index 0620d9f9..93333078 100644 --- a/gst-libs/gst/vaapi/gstvaapiencoder_mpeg2.c +++ b/gst-libs/gst/vaapi/gstvaapiencoder_mpeg2.c @@ -186,10 +186,11 @@ ensure_bitrate (GstVaapiEncoderMpeg2 * encoder) switch (GST_VAAPI_ENCODER_RATE_CONTROL (encoder)) { case GST_VAAPI_RATECONTROL_CBR: if (!base_encoder->bitrate) - base_encoder->bitrate = GST_VAAPI_ENCODER_WIDTH (encoder) * - GST_VAAPI_ENCODER_HEIGHT (encoder) * - GST_VAAPI_ENCODER_FPS_N (encoder) / - GST_VAAPI_ENCODER_FPS_D (encoder) / 4 / 1000; + base_encoder->bitrate = + gst_util_uint64_scale (GST_VAAPI_ENCODER_WIDTH (encoder) * + GST_VAAPI_ENCODER_HEIGHT (encoder), + GST_VAAPI_ENCODER_FPS_N (encoder), + GST_VAAPI_ENCODER_FPS_D (encoder)) / 4 / 1000; break; default: base_encoder->bitrate = 0; |