[Speex-dev] Real time in ARM - please help

Mo Win mowin.dev at gmail.com
Mon Dec 12 06:57:13 PST 2005


Thanks for the advice. With complexity=1, bit rates 5950,8000 and 15000 (CBR
only), I'm still getting 30-50 seconds encoding time for a 10-second file.
To anyone who has made this work in ARMv4, or knows how to, can I get some
advice on the settings? FIXED_POINT is already defined in all relevant
files. My source code is patterned after sampleenc and I haven't tried using
Ogg..  my source code is attached below in case anyone's interested. I
wonder what I'm doing wrong.. Appreciate any help, thanks a lot.

Mon

int PCMToSpx (BSTR FileOpen, BSTR FileSave, bool VAD, short BitRateChoice)
{
    __int8 Speex [6];
    __int16 SamplingRate = 8000;
    __int8 BitsPerSampleX8 = 2 /* ie 2*8=16-bit */, NumBytes /*aka nBytes or
nbBytes */;

    FILE *fin, *fout;
    void *state;
    int FrameSize, NumFrames = 0;
    int BitRate, temp;
    __int16 in [MaxFrameSize];
    __int8 cbits [MaxFrameBytes];
    SpeexBits bits;

// ********************************** Program Statements
**********************************//

    Speex[0] = 'S';
    Speex[1] = 'p';
    Speex[2] = 'e';
    Speex[3] = 'e';
    Speex[4] = 'x';

    state = speex_encoder_init (&speex_nb_mode);

    fout = _wfopen ((LPCTSTR)FileSave, L"wb");
    if (fout == NULL)
    {
        return 1;
    }

    fin = _wfopen ((LPCTSTR) FileOpen, L"rb");
    if (fin == NULL)
    {
        return 2;
    }

    switch (BitRateChoice)
    {
        case '1':
            BitRate = 6000;
            break;
        case '2':
            BitRate = 8000;
            break;
        case '3':
            BitRate = 15000;
            break;
        default:
            BitRate = 8000;
            break;
    }
    speex_encoder_ctl (state, SPEEX_SET_BITRATE, &BitRate);

    if (VAD)
        temp = 1;
    else
        temp = 0;

    speex_encoder_ctl (state, SPEEX_SET_VAD, &temp);

    speex_encoder_ctl (state, SPEEX_GET_FRAME_SIZE, &FrameSize);

    temp = 1;
    speex_encoder_ctl (state, SPEEX_SET_COMPLEXITY, &temp);
    temp = 0; // Just making sure VBR is off. Probably unnecessary.
    speex_encoder_ctl (state, SPEEX_SET_VBR, &temp);
    temp = 8000;
    speex_encoder_ctl (state, SPEEX_SET_SAMPLING_RATE, &temp);

    fwrite (Speex, 1, 5, fout);
    fwrite (&SamplingRate, 2, 1, fout);
    fwrite (&BitsPerSampleX8, 1, 1, fout);

    fseek(fout,8, SEEK_SET);
    fseek(fin,0, SEEK_SET);

    speex_bits_init (&bits);

    while (1)
    {
        if (feof(fin))
        {
            break;
        }
        fread (in, sizeof (short), FrameSize, fin); //place 160 shorts in
"in" (1 frame)

        speex_bits_reset (&bits);
        speex_encode_int (state, in, &bits);
        NumBytes = speex_bits_write (&bits, cbits, 300);

        if (NumFrames == 0)
        fwrite (&NumBytes, 1, 1, fout);

        fwrite (cbits, 1, NumBytes, fout);

        NumFrames++; /**/
    }

    speex_encoder_destroy (state);
    speex_bits_destroy (&bits);
    fclose (fin);
    fclose (fout);

    return NumFrames;
}

On 12/12/05, Jean-Marc Valin <Jean-Marc.Valin at usherbrooke.ca> wrote:
>
> You should definitely be able to do narrowband in realtime. For
> wideband, it depends on the mode and complexity setting. Try setting the
> complexity to one:
>
> int tmp = 1;
> speex_encoder_ctl(encoder, SPEEX_SET_COMPLEXITY, &tmp);
>
>         Jean-Marc
>
> Le lundi 12 décembre 2005 à 15:33 +0800, Mo Win a écrit :
> > Hi. I tried encoding a raw PCM file to Speex in my Windows Mobile
> > device and it took about 45 seconds to encode a 10-second file. I had
> > FIXED_POINT defined and used speex_encode_int. The device has an ARMV4
> > 400 MHz processor. Question: Is this behavior expected or is it
> > possible to encode speech to speex real-time such that I can record
> > speech directly as speex in my device? What, if any, can be done to
> > speed up encoding time? As expected, decoding was no problem. I was
> > using version 1.1.10.
> >
> > Thank you for all the help,
> > Monica
> > _______________________________________________
> > Speex-dev mailing list
> > Speex-dev at xiph.org
> > http://lists.xiph.org/mailman/listinfo/speex-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.xiph.org/pipermail/speex-dev/attachments/20051212/67160ce5/attachment.htm


More information about the Speex-dev mailing list