diff options
author | Jean-Marc Valin <jmvalin@jmvalin.ca> | 2016-09-09 16:51:01 -0400 |
---|---|---|
committer | Jean-Marc Valin <jmvalin@jmvalin.ca> | 2016-09-14 11:41:02 -0400 |
commit | 70e3c348228a28ea7f62def5ecbce71b975a517b (patch) | |
tree | 99e8fe83cf191a60b89902aa5c90dbc573f0d2af /src/opus_encoder.c | |
parent | fa2578bf4791be31b67748ce6a815829d9a6f175 (diff) | |
download | opus-70e3c348228a28ea7f62def5ecbce71b975a517b.tar.gz |
Fixing failure due to CBR allocating zero byte to a stream
Diffstat (limited to 'src/opus_encoder.c')
-rw-r--r-- | src/opus_encoder.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/opus_encoder.c b/src/opus_encoder.c index aa5e73d4..40440100 100644 --- a/src/opus_encoder.c +++ b/src/opus_encoder.c @@ -1336,7 +1336,8 @@ opus_int32 opus_encode_native(OpusEncoder *st, const opus_val16 *pcm, int frame_ /* We need to make sure that "int" values always fit in 16 bits. */ cbrBytes = IMIN( (3*st->bitrate_bps/8 + frame_rate3/2)/frame_rate3, max_data_bytes); st->bitrate_bps = cbrBytes*(opus_int32)frame_rate3*8/3; - max_data_bytes = cbrBytes; + /* Make sure we provide at least one byte to avoid failing. */ + max_data_bytes = IMAX(1, cbrBytes); } if (max_data_bytes<3 || st->bitrate_bps < 3*frame_rate*8 || (frame_rate<50 && (max_data_bytes*frame_rate<300 || st->bitrate_bps < 2400))) @@ -1363,6 +1364,8 @@ opus_int32 opus_encode_native(OpusEncoder *st, const opus_val16 *pcm, int frame_ ret = opus_packet_pad(data, ret, max_data_bytes); if (ret == OPUS_OK) ret = max_data_bytes; + else + ret = OPUS_INTERNAL_ERROR; } RESTORE_STACK; return ret; |