[opus] Moving from Speex to Opus (question 2)

Hermann Weber hermie.weber at gmx.de
Thu May 9 11:30:33 PDT 2013


Hello!

I was using Speex all the time, and I am now moving to Opus.

I had encapsulated the decoder a bit, I had the following cpp file:

#include "StdAfx.h"
#include "spxcodec.h"

#define MAX_FRAME_SIZE 2000
#define MAX_FRAME_BYTES 2000

CSpxCodec::CSpxCodec() : enh(1), rate(8000)
{
}


CSpxCodec::~CSpxCodec()
{
}

void CSpxCodec::Init()
{
     speex_bits_init(&bits);
     decstate = speex_decoder_init(&speex_nb_mode);

     speex_decoder_ctl(decstate, SPEEX_SET_SAMPLING_RATE, &rate);
     speex_decoder_ctl(decstate, SPEEX_SET_ENH, &enh);

     int iFrameSize=0;
     speex_decoder_ctl(decstate, SPEEX_GET_FRAME_SIZE, &iFrameSize);

}

void CSpxCodec::Free()
{
     speex_bits_destroy(&bits);
     speex_decoder_destroy(decstate);
}

void CSpxCodec::Decode(unsigned char* inbuf, short* outbuf, unsigned int 
len)
{

     char cbits[MAX_FRAME_BYTES];
     float output[MAX_FRAME_SIZE];

     unsigned int i=0;
     unsigned int j=0;

     for (i=0; i<(len/62); i++)
     {

         for (j=0;j<62;j++)
         {
             cbits[j] = inbuf[(i*62)+j];
         }

         speex_bits_read_from(&bits, cbits, 62);
         speex_decode(decstate, &bits, output);

         for (j=0;j<160;j++)
         {
             outbuf[j+(i*160)] = output[j];
         }
     }
}
-------------------
I would like to ask if I can keep this "wrapper".
Please anybody tell me that I can just replace the word "speex" with 
"opus", and it will work, hehehehehe!
Can I keep the 62, 160 part, or will that be different in Opus?
I am not asking because I am lazy, I am just scared because Opus look so 
much different than Speex, and there is no "encoding/decoding for 
dummies" example as there was in Speex.
Could anybody perhaps give me another push in the right direction and 
tell me how a good starting point for Opus newbies?

Thank you so much.

Greetings,
Hermie


More information about the opus mailing list