Nanang

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I know you implemented ITU version of codecs. I included my  test file where
I tried to keep everything same as ITU, except that I convert the 10 bit
frames to 80  16bit samples. After that I decode that to PCM. But the sound
I get after decoding is just some metallic scrambled. Am I missing anything
here? Look at the routine covertBit2Serial(); That was what written by me.

 

 

 

 

 

 

void covertBit2Serial(Word16 *input, Word16 *output);

void printbits(Word16 value);

 

int main(int argc, char *argv[] )

{

  Word16  synth_buf[L_FRAME+M], *synth; /* Synthesis                   */

  Word16  parm[PRM_SIZE+1];             /* Synthesis parameters        */

  Word16  serial[SERIAL_SIZE];          /* Serial stream               */

  Word16  Az_dec[MP1*2];                /* Decoded Az for post-filter  */

  Word16  T2[2];                        /* Pitch lag for 2 subframes   */

 

 

  Word16  i, frame;

  FILE   *f_syn, *f_serial;

 

  printf("\n");

  printf("************   G.729a 8.0 KBIT/S SPEECH DECODER  ************\n");

  printf("\n");

  printf("------------------- Fixed point C simulation ----------------\n");

  printf("\n");

  printf("------------ Version 1.1 (Release 2, November 2006) --------\n");

  printf("\n");

 

   /* Passed arguments */

 

   if ( argc != 3)

     {

        printf("Usage :%s bitstream_file  outputspeech_file\n",argv[0]);

        printf("\n");

        printf("Format for bitstream_file:\n");

        printf("  One (2-byte) synchronization word \n");

        printf("  One (2-byte) size word,\n");

        printf("  80 words (2-byte) containing 80 bits.\n");

        printf("\n");

        printf("Format for outputspeech_file:\n");

        printf("  Synthesis is written to a binary file of 16 bits
data.\n");

        exit( 1 );

     }

 

   /* Open file for synthesis and packed serial stream */

 

   if( (f_serial = fopen(argv[1],"rb") ) == NULL )

     {

        printf("%s - Error opening file  %s !!\n", argv[0], argv[1]);

        exit(0);

     }

 

   if( (f_syn = fopen(argv[2], "wb") ) == NULL )

     {

        printf("%s - Error opening file  %s !!\n", argv[0], argv[2]);

        exit(0);

     }

 

   printf("Input bitstream file  :   %s\n",argv[1]);

   printf("Synthesis speech file :   %s\n",argv[2]);

 

/*-----------------------------------------------------------------*

 *           Initialization of decoder                             *

 *-----------------------------------------------------------------*/

 

  for (i=0; i<M; i++) synth_buf[i] = 0;

  synth = synth_buf + M;

 

  bad_lsf = 0;          /* Initialize bad LSF indicator */

  Init_Decod_ld8a();

  Init_Post_Filter();

  Init_Post_Process();

 

 

/*-----------------------------------------------------------------*

 *            Loop for each "L_FRAME" speech data                  *

 *-----------------------------------------------------------------*/

Word16 iBuffer[5];

 

  frame = 0;

  while( fread(iBuffer, sizeof(Word16), 5, f_serial) == 5)

  {

    covertBit2Serial(iBuffer,serial);

 

    printf("Frame =%d\r", frame++);

 

    bits2prm_ld8k( &serial[2], &parm[1]);

 

    /* the hardware detects frame erasures by checking if all bits

       are set to zero

     */

    parm[0] = 0;           /* No frame erasure */

    for (i=2; i < SERIAL_SIZE; i++)

      if (serial[i] == 0 ) parm[0] = 1; /* frame erased     */

 

    /* check pitch parity and put 1 in parm[4] if parity error */

 

    parm[4] = Check_Parity_Pitch(parm[3], parm[4]);

 

    Decod_ld8a(parm, synth, Az_dec, T2);

 

    Post_Filter(synth, Az_dec, T2);        /* Post-filter */

 

    Post_Process(synth, L_FRAME);

 

    fwrite(synth, sizeof(short), L_FRAME, f_syn);

 

  }

  return(0);

}

 

 

 

 

void covertBit2Serial(Word16 *input, Word16 *output){

output[0]=SYNC_WORD;

output[1]=SIZE_WORD;

int outIndex =2;

int i,j;

Word16 Mask;

for (i=0;i<5;i++){

      for(j=0;j<16;j++){

      Mask = 0x0001 << (15-j);

      

      if ((Mask | input[i]) == input[i])

            output[outIndex++] = BIT_1;

      

      else

            output[outIndex++] = BIT_0;

            

      }

 

   }

}

 

 

 

void printbits(Word16 value){

  const int SHIFT = 8 * sizeof( Word16 ) - 1;

   const Word16 MASK = 1 << SHIFT;

//getchar();

 

//printf("buffer is \n");

 

int k = 0;

   for (k = 1; k <= SHIFT + 1; k++ ) 

   {

      printf("%c",value & MASK ? '1' : '0' );

 

      value <<= 1;

 

     // if ( k == 8)

      //   printf( ' ');

   }

//printf("\n");

}

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/attachments/20081110/0ffb7073/attachment-0001.html>


[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux