Skip to content
Snippets Groups Projects
Commit 769311f9 authored by Jean-Marc Valin's avatar Jean-Marc Valin
Browse files

PLC support

parent 862e1825
No related branches found
No related tags found
No related merge requests found
......@@ -82,8 +82,11 @@ int hybrid_decode(HybridDecoder *st, const unsigned char *data,
SKP_int16 silk_frame_size;
short pcm_celt[960];
ec_byte_readinit(&buf,(unsigned char*)data,len);
ec_dec_init(&dec,&buf);
if (data != NULL)
{
ec_byte_readinit(&buf,(unsigned char*)data,len);
ec_dec_init(&dec,&buf);
}
if (st->mode != MODE_CELT_ONLY)
{
......@@ -92,7 +95,7 @@ int hybrid_decode(HybridDecoder *st, const unsigned char *data,
/* We Should eventually have to set the bandwidth here */
/* Call SILK encoder for the low band */
silk_ret = SKP_Silk_SDK_Decode( st->silk_dec, &DecControl, 0, &dec, len, pcm, &silk_frame_size );
silk_ret = SKP_Silk_SDK_Decode( st->silk_dec, &DecControl, data == NULL, &dec, len, pcm, &silk_frame_size );
if (silk_ret)
{
fprintf (stderr, "SILK decode error\n");
......
......@@ -98,7 +98,7 @@ int hybrid_encode(HybridEncoder *st, const short *pcm, int frame_size,
{
/* Set Encoder parameters */
encControl.API_sampleRate = st->Fs;
encControl.packetLossPercentage = 0;
encControl.packetLossPercentage = 2;
encControl.useInBandFEC = 0;
encControl.useDTX = 0;
encControl.complexity = 2;
......
......@@ -55,6 +55,7 @@ int main(int argc, char *argv[])
int bytes_per_packet;
unsigned char data[MAX_PACKET];
int rate;
int loss = 0;
int count = 0;
int skip;
short *in, *out;
......@@ -62,7 +63,7 @@ int main(int argc, char *argv[])
if (argc != 9 && argc != 8 && argc != 7)
{
fprintf (stderr, "Usage: test_hybrid <rate> <channels> <frame size> "
" <bytes per packet> "
" <bytes per packet> [<packet loss rate>] "
"<input> <output>\n");
return 1;
}
......@@ -72,6 +73,10 @@ int main(int argc, char *argv[])
frame_size = atoi(argv[3]);
bytes_per_packet = atoi(argv[4]);
if (argc >= 8)
loss = atoi(argv[5]);
if (bytes_per_packet < 0 || bytes_per_packet > MAX_PACKET)
{
fprintf (stderr, "bytes per packet must be between 0 and %d\n",
......@@ -117,7 +122,7 @@ int main(int argc, char *argv[])
fprintf (stderr, "hybrid_encode() returned %d\n", len);
return 1;
}
hybrid_decode(dec, data, len, out, frame_size);
hybrid_decode(dec, rand()%100<loss ? NULL : data, len, out, frame_size);
count++;
fwrite(out+skip, sizeof(short), (frame_size-skip)*channels, fout);
skip = 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment