Unverified Commit 01aecb28 authored by Jean-Marc Valin's avatar Jean-Marc Valin
Browse files

Computing the exact (I think) padding size

parent 84ccf379
...@@ -620,11 +620,11 @@ OPE_EXPORT int ope_get_page(OggOpusEnc *enc, unsigned char **page, int *len, int ...@@ -620,11 +620,11 @@ OPE_EXPORT int ope_get_page(OggOpusEnc *enc, unsigned char **page, int *len, int
static void extend_signal(float *x, int before, int after, int channels); static void extend_signal(float *x, int before, int after, int channels);
int ope_drain(OggOpusEnc *enc) { int ope_drain(OggOpusEnc *enc) {
int pad_samples;
if (enc->unrecoverable) return OPE_UNRECOVERABLE; if (enc->unrecoverable) return OPE_UNRECOVERABLE;
/* Check if it's already been drained. */ /* Check if it's already been drained. */
if (enc->streams == NULL) return OPE_TOO_LATE; if (enc->streams == NULL) return OPE_TOO_LATE;
/* FIXME: Use a better value. */ pad_samples = MAX(LPC_PADDING, enc->global_granule_offset + enc->frame_size);
int pad_samples = 3000;
if (!enc->streams->stream_is_init) init_stream(enc); if (!enc->streams->stream_is_init) init_stream(enc);
shift_buffer(enc); shift_buffer(enc);
assert(enc->buffer_end + pad_samples <= BUFFER_SAMPLES); assert(enc->buffer_end + pad_samples <= BUFFER_SAMPLES);
...@@ -634,6 +634,8 @@ int ope_drain(OggOpusEnc *enc) { ...@@ -634,6 +634,8 @@ int ope_drain(OggOpusEnc *enc) {
enc->buffer_end += pad_samples; enc->buffer_end += pad_samples;
assert(enc->buffer_end <= BUFFER_SAMPLES); assert(enc->buffer_end <= BUFFER_SAMPLES);
encode_buffer(enc); encode_buffer(enc);
if (enc->unrecoverable) return OPE_UNRECOVERABLE;
/* Draining should have called all the streams to complete. */
assert(enc->streams == NULL); assert(enc->streams == NULL);
return OPE_OK; return OPE_OK;
} }
......
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