diff --git a/doc/draft-valin-codec-prototype.xml b/doc/draft-valin-codec-prototype.xml
index 99b64a2a..8ebda971 100644
--- a/doc/draft-valin-codec-prototype.xml
+++ b/doc/draft-valin-codec-prototype.xml
@@ -115,11 +115,11 @@ which references two other
repositories (for SILK and CELT). Some snapshots are provided for
convenience at along
with sample files.
-Although the build system is very primitive
-(and inconsistent), some instructions are provided in the toplevel README file.
+Although the build system is very primitive, some instructions are provided
+in the toplevel README file.
This is very early development so both the quality and feature set should
-greatly improve over time. In the current version, only 48 kHz audio with 20 ms
-frames are supported, but support for all configurations listed in
+greatly improve over time. In the current version, only 48 kHz audio is
+supported, but support for all configurations listed in
is planned.
@@ -176,11 +176,13 @@ There is thus a total of 30 configurations, so 5 bits are necessary (with 2 code
indicate the mode, frame size and sampling rate (MFS). This leaves 3 bits for the number of frames per packets (codes 0 to 7):
0-2: 1-3 frames in the packet, each with equal compressed size
-3: arbitrary number of frames in the packet, each with equal compressed size (size needs to be signalled)
+3: arbitrary number of frames in the packet, each with equal compressed size (one size needs to be encoded)
4-5: 2-3 frames in the packet, with different compressed sizes, which need to be encoded (except the last one)
6: arbitrary number of frames in the packet, with different compressed sizes, each of which needs to be encoded
-7: The first frame has this MFS, but others have different MFS. Compressed sizes need to be encoded.
+7: The first frame has this MFS, but others have different MFS. Each compressed size needs to be encoded.
+When code 7 is used and the last frames of a packet have the same MFS, it is
+allowed to switch to another code for them.
@@ -248,7 +250,7 @@ Two frames of different compressed size:
-Three frames of different *durations*:
+Three frames of different durations:
@@ -273,9 +275,14 @@ Three frames of different *durations*:
-The codec needs to take appropriate
-security considerations into account, for example as outlined in
- and .
+The codec needs to take appropriate security considerations
+into account, as outlined in and .
+It is extremely important for the decoder to be robust against malicious
+payloads. Malicious payloads must not cause the decoder to overrun its
+allocated memory or to take much more resources to decode. Although problems
+in encoders are typically rarer, the same applies to the encoder. Malicious
+audio stream must not cause the encoder to misbehave because this would
+allow an attacker to attack transcoding gateways.
diff --git a/src/hybrid_decoder.c b/src/hybrid_decoder.c
index 9fdaf3ea..2d258a44 100644
--- a/src/hybrid_decoder.c
+++ b/src/hybrid_decoder.c
@@ -94,7 +94,7 @@ int hybrid_decode(HybridDecoder *st, const unsigned char *data,
/* Handle error */
}
} else {
- for (i=0;i<960;i++)
+ for (i=0;icelt_dec, data, len, pcm_celt, frame_size, &dec);
- for (i=0;i<960;i++)
+ for (i=0;imode != MODE_CELT_ONLY)
{
st->encControl.bitRate = (bytes_per_packet*50*8+6000)/2;
+ st->encControl.packetSize = frame_size;
/* Call SILK encoder for the low band */
nBytes = bytes_per_packet;
- ret = SKP_Silk_SDK_Encode( st->silk_enc, &st->encControl, pcm, 960, &enc, &nBytes );
+ ret = SKP_Silk_SDK_Encode( st->silk_enc, &st->encControl, pcm, frame_size, &enc, &nBytes );
if( ret ) {
fprintf (stderr, "SILK encode error\n");
/* Handle error */
@@ -121,7 +122,7 @@ int hybrid_encode(HybridEncoder *st, const short *pcm, int frame_size,
for (i=0;idelay_buffer[i];
- for (;i<960;i++)
+ for (;icelt_enc, CELT_SET_PREDICTION(1));
@@ -129,7 +130,7 @@ int hybrid_encode(HybridEncoder *st, const short *pcm, int frame_size,
/* FIXME: Do some delay compensation here */
ret = celt_encode_with_ec(st->celt_enc, buf, NULL, frame_size, data, bytes_per_packet, &enc);
for (i=0;idelay_buffer[i] = pcm[960-ENCODER_DELAY_COMPENSATION+i];
+ st->delay_buffer[i] = pcm[frame_size-ENCODER_DELAY_COMPENSATION+i];
} else {
ec_enc_done(&enc);
}