Fixes a high bit-rate redundant frame bug
We now ensure that the total payload *including* the redundant frame is no more than 1275 bytes. Also, the redundant frame itself must be no more than 257 (the max that can be signalled).
This commit is contained in:
parent
5c3d155188
commit
51ac8e68e6
1 changed files with 7 additions and 3 deletions
|
@ -515,8 +515,6 @@ int opus_encode(OpusEncoder *st, const opus_int16 *pcm, int frame_size,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nb_compr_bytes = IMIN(1275, nb_compr_bytes);
|
|
||||||
ec_enc_shrink(&enc, nb_compr_bytes);
|
|
||||||
} else {
|
} else {
|
||||||
nb_compr_bytes = 0;
|
nb_compr_bytes = 0;
|
||||||
}
|
}
|
||||||
|
@ -556,7 +554,9 @@ int opus_encode(OpusEncoder *st, const opus_int16 *pcm, int frame_size,
|
||||||
ec_enc_bit_logp(&enc, redundancy, 12);
|
ec_enc_bit_logp(&enc, redundancy, 12);
|
||||||
if (redundancy)
|
if (redundancy)
|
||||||
{
|
{
|
||||||
redundancy_bytes = st->stream_channels*st->bitrate_bps/1600;
|
/* Target the same bit-rate for redundancy as for the rest,
|
||||||
|
up to a max of 257 bytes */
|
||||||
|
redundancy_bytes = IMIN(257, st->bitrate_bps/1600);
|
||||||
ec_enc_bit_logp(&enc, celt_to_silk, 1);
|
ec_enc_bit_logp(&enc, celt_to_silk, 1);
|
||||||
if (st->mode == MODE_HYBRID)
|
if (st->mode == MODE_HYBRID)
|
||||||
ec_enc_uint(&enc, redundancy_bytes-2, 256);
|
ec_enc_uint(&enc, redundancy_bytes-2, 256);
|
||||||
|
@ -577,8 +577,12 @@ int opus_encode(OpusEncoder *st, const opus_int16 *pcm, int frame_size,
|
||||||
if(!redundancy)
|
if(!redundancy)
|
||||||
while(ret>2&&data[ret-1]==0)ret--;
|
while(ret>2&&data[ret-1]==0)ret--;
|
||||||
nb_compr_bytes = ret;
|
nb_compr_bytes = ret;
|
||||||
|
} else {
|
||||||
|
nb_compr_bytes = IMIN(1275-redundancy_bytes, nb_compr_bytes);
|
||||||
|
ec_enc_shrink(&enc, nb_compr_bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* 5 ms redundant frame for CELT->SILK */
|
/* 5 ms redundant frame for CELT->SILK */
|
||||||
if (redundancy && celt_to_silk)
|
if (redundancy && celt_to_silk)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue