shithub: libopusenc

Download patch

ref: a04e079b037ef0e506250e4619818557ae73368e
parent: 20a8f3272c98b362610b176c1114fac34b4cc358
author: Jean-Marc Valin <jmvalin@jmvalin.ca>
date: Sat Dec 30 08:57:42 EST 2017

Fixes ope_encoder_drain() bug

assert(enc->streams == NULL) would fail because pad_samples was missing
a fractional number of samples due to the resampler output latency not
being an integer.

--- a/src/opusenc.c
+++ b/src/opusenc.c
@@ -637,7 +637,7 @@
   /* Check if it's already been drained. */
   if (enc->streams == NULL) return OPE_TOO_LATE;
   if (enc->re) resampler_drain = speex_resampler_get_output_latency(enc->re);
-  pad_samples = MAX(LPC_PADDING, enc->global_granule_offset + enc->frame_size + resampler_drain);
+  pad_samples = MAX(LPC_PADDING, enc->global_granule_offset + enc->frame_size + resampler_drain + 1);
   if (!enc->streams->stream_is_init) init_stream(enc);
   shift_buffer(enc);
   assert(enc->buffer_end + pad_samples <= BUFFER_SAMPLES);