Commit 6463ff19 authored by Luis de Bethencourt's avatar Luis de Bethencourt

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
parent dd741e64
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment