mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-04 05:22:30 +00:00
libs: encoder: h265: fix possible integer overflow
Coverity scan bug: Unintentional integer overflow. The expression's value may not be what the programmer intended, because the expression is evaluated using a narrow (i.e. few bits) integer type. Cast operator to guint64 before computation to avoid narrowing. merge with 3c5a6add
This commit is contained in:
parent
4e27245f28
commit
bd7716a739
2 changed files with 4 additions and 2 deletions
|
@ -2479,7 +2479,7 @@ ensure_bitrate (GstVaapiEncoderH264 * encoder)
|
||||||
if (!encoder->use_dct8x8)
|
if (!encoder->use_dct8x8)
|
||||||
bits_per_mb += (bits_per_mb * 10) / 100;
|
bits_per_mb += (bits_per_mb * 10) / 100;
|
||||||
|
|
||||||
factor = encoder->mb_width * encoder->mb_height * bits_per_mb;
|
factor = (guint64) encoder->mb_width * encoder->mb_height * bits_per_mb;
|
||||||
base_encoder->bitrate =
|
base_encoder->bitrate =
|
||||||
gst_util_uint64_scale (factor, GST_VAAPI_ENCODER_FPS_N (encoder),
|
gst_util_uint64_scale (factor, GST_VAAPI_ENCODER_FPS_N (encoder),
|
||||||
GST_VAAPI_ENCODER_FPS_D (encoder)) / 1000;
|
GST_VAAPI_ENCODER_FPS_D (encoder)) / 1000;
|
||||||
|
|
|
@ -1902,7 +1902,9 @@ ensure_bitrate (GstVaapiEncoderH265 * encoder)
|
||||||
/* FIXME: Provide better estimation */
|
/* FIXME: Provide better estimation */
|
||||||
/* Using a 1/6 compression ratio */
|
/* Using a 1/6 compression ratio */
|
||||||
/* 12 bits per pixel for YUV420 */
|
/* 12 bits per pixel for YUV420 */
|
||||||
guint64 factor = encoder->luma_width * encoder->luma_height * 12 / 6;
|
guint64 factor;
|
||||||
|
|
||||||
|
factor = (guint64) encoder->luma_width * encoder->luma_height * 12 / 6;
|
||||||
base_encoder->bitrate =
|
base_encoder->bitrate =
|
||||||
gst_util_uint64_scale (factor, GST_VAAPI_ENCODER_FPS_N (encoder),
|
gst_util_uint64_scale (factor, GST_VAAPI_ENCODER_FPS_N (encoder),
|
||||||
GST_VAAPI_ENCODER_FPS_D (encoder)) / 1000;
|
GST_VAAPI_ENCODER_FPS_D (encoder)) / 1000;
|
||||||
|
|
Loading…
Reference in a new issue