opusenc: avoid potential overflow expression

The result of the two expressions will be promoted to guint64 anyway,
perform all the arithmetic in 64 bits to avoid potential overflows.

CID 1338690, CID 1338691
This commit is contained in:
Luis de Bethencourt 2015-11-12 12:21:54 +00:00
parent dd741e6412
commit 6463ff198e

View file

@ -1007,7 +1007,7 @@ gst_opus_enc_encode (GstOpusEnc * enc, GstBuffer * buf)
trim_start = enc->pending_lookahead;
enc->pending_lookahead = 0;
} else {
trim_start = input_samples * 48000 / enc->sample_rate;
trim_start = ((guint64) input_samples) * 48000 / enc->sample_rate;
enc->pending_lookahead -= trim_start;
output_samples = 0;
}
@ -1026,7 +1026,8 @@ gst_opus_enc_encode (GstOpusEnc * enc, GstBuffer * buf)
output_samples = enc->consumed_samples - enc->encoded_samples;
input_samples = 0;
GST_DEBUG_OBJECT (enc, "draining %d samples", output_samples);
trim_end = (frame_samples - output_samples) * 48000 / enc->sample_rate;
trim_end =
((guint64) frame_samples - output_samples) * 48000 / enc->sample_rate;
} else if (enc->encoded_samples == enc->consumed_samples) {
GST_DEBUG_OBJECT (enc, "nothing to drain");
goto done;