Exemple #1
0
void G729aDecoder_Init()
{
	extern Word16 *synth;
	  
    bad_lsf = 0;          /* Initialize bad LSF indicator */
    
    Init_Decod_ld8a();
    Init_Post_Filter();
    Init_Post_Process();
}
Exemple #2
0
static void *create_decoder(const struct PluginCodec_Definition *codec)
{
	DecState *decoder;	

	decoder = Init_Decod_ld8a();
	Init_Post_Filter(decoder);
	Init_Post_Process(decoder);
	
	return (void *)decoder;
}
Exemple #3
0
Flag   g729a_dec_init (void *decState)
{
  g729a_decode_frame_state *state;
  if (decState == NULL)
    return 0;

  state = (g729a_decode_frame_state *)decState;

  Set_zero(state->synth_buf, M);
  state->synth = state->synth_buf + M;

  Init_Decod_ld8a(&state->decoderState);
  Init_Post_Filter(&state->postFilterState);
  Init_Post_Process(&state->postProcessState);

  return 1;
}
Exemple #4
0
static int tdav_codec_g729ab_open(tmedia_codec_t* self)
{
	tdav_codec_g729ab_t* g729a = (tdav_codec_g729ab_t*)self;

	// Initialize the decoder
	bad_lsf = 0;
	g729a->decoder.synth = (g729a->decoder.synth_buf + M);

	Init_Decod_ld8a();
	Init_Post_Filter();
	Init_Post_Process();
	/* for G.729B */
	Init_Dec_cng();
	
	// Initialize the encoder
	Init_Pre_Process();
	Init_Coder_ld8a();
	Set_zero(g729a->encoder.prm, PRM_SIZE + 1);
	/* for G.729B */
	Init_Cod_cng();
	

	return 0;
}
Exemple #5
0
//#if 0
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        ---------------\n");
  printf("\n");

   /* Passed arguments */
   argc = 3;
   strcpy(argv[1],"test.bit");
   strcpy(argv[2],"test.dec");

   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                  *
 *-----------------------------------------------------------------*/

  frame = 0;

  /* c code */

  while( fread(serial, sizeof(Word16), SERIAL_SIZE, f_serial) == SERIAL_SIZE)
  {
    //printf("Frame =%d\n", frame++);
	printf("Frame =%d \n", frame);
	frame = frame + 1;

    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);
}