コード例 #1
0
int Hi3511AudioDecSendStream(int nChannel, void *stream, int *size)
{
	HI_S32 s32ret;
	AUDIO_FRAME_S stStream;
	AUDIO_DEC_HEADER *audioHeader; // delete by liujw 12-3-5

	char ucOutBuff[1024];
	unsigned long currentPosition = 0;
	unsigned long audioSize = 0;
	int iRet = 0;
	 
    if (stream==NULL || size==NULL)
    {
    	return -1;
    }
    
	audioHeader = (AUDIO_DEC_HEADER *)stream;
	
	if (audioHeader->u32Len >= 512)
	{
		return -1;	
	}

#ifdef G726	
	//printf("audioHeader->u32Len = %d\n", audioHeader->u32Len);
	fwrite(stream+16, 1, audioHeader->u32Len, g_pDecFile);
	 while(currentPosition < audioHeader->u32Len){
		iRet = g726_decode(g_State726_32, (short*)(ucOutBuff+audioSize),(stream+16+currentPosition), 80);
		currentPosition += 80;
		audioSize += iRet;
	}
	memcpy(stream, ucOutBuff, audioSize*2);
	memcpy(stStream.aData, stream, audioSize*2);
	*size = audioSize;
	stStream.enBitwidth = 1;
	stStream.enSoundmode = 0;
	stStream.u64TimeStamp = 0;
	stStream.u32Seq = g_audio_seq++;
	stStream.u32Len = audioSize*2;
	memset(stream, 0, 1024*40);
	memcpy(stream, &stStream, sizeof(AUDIO_FRAME_S));
	//fwrite(ucOutBuff, 1, audioSize, g_pDecFile);
#else  //G711--zhangjing--g711½âÂë
	G711Decoder((short *)stStream.aData,stream+sizeof(AUDIO_DEC_HEADER),(audioHeader->u32Len*2),0);

	*size = audioHeader->u32Len;
	stStream.enBitwidth = 1;
	stStream.enSoundmode = 0;
	stStream.u64TimeStamp = 0;
	stStream.u32Seq = g_audio_seq++;
	stStream.u32Len = audioHeader->u32Len*2;
	//printf("stStream-u32len:%d\n",stStream.u32Len);
	memset(stream, 0,sizeof(AUDIO_FRAME_S));
	memcpy(stream, &stStream, sizeof(AUDIO_FRAME_S));
#endif
	return 0;
}
コード例 #2
0
ファイル: g726.c プロジェクト: AmesianX/baresip
static int decode(struct audec_state *st, int16_t *sampv,
		  size_t *sampc, const uint8_t *buf, size_t len)
{
	if (!sampv || !sampc || !buf)
		return EINVAL;

	*sampc = g726_decode(&st->st, sampv, buf, (int)len);

	return 0;
}
コード例 #3
0
ファイル: g726.c プロジェクト: Studio-Link/baresip
static int decode(struct audec_state *st, int fmt, void *sampv,
		  size_t *sampc, const uint8_t *buf, size_t len)
{
	if (!sampv || !sampc || !buf)
		return EINVAL;

	if (fmt != AUFMT_S16LE)
		return ENOTSUP;

	*sampc = g726_decode(&st->st, sampv, buf, (int)len);

	return 0;
}
コード例 #4
0
int G726ToPcm::Decode(unsigned char* outbuf, unsigned int* outlen , unsigned char* inbuf, unsigned int inlen)
{
	//iRet = g726_decode(g_state726_16, (short*)ucOutBuff, ucInBuff,30);//   120 лл
	//iRet = g726_decode(g_state726_24, (short*)ucOutBuff, ucInBuff, 30);//   80 лл
	//iRet = g726_decode(g_state726_32, (short*)ucOutBuff, ucInBuff, 30);// 60
	//iRet = g726_decode(g_state726_40, (short*)ucOutBuff, ucInBuff, 30);// 48

	int iRet = g726_decode(m_state726, (short*)outbuf, inbuf, inlen);

	*outlen = iRet*2;

	return iRet*2;
}
コード例 #5
0
static switch_status_t switch_g726_decode(switch_codec_t *codec,
										  switch_codec_t *other_codec,
										  void *encoded_data,
										  uint32_t encoded_data_len,
										  uint32_t encoded_rate, void *decoded_data, uint32_t *decoded_data_len, uint32_t *decoded_rate,
										  unsigned int *flag)
{
	g726_state_t *context = codec->private_info;

	if (!context) {
		return SWITCH_STATUS_FALSE;
	}

	*decoded_data_len = (2 * g726_decode(context, (int16_t *) decoded_data, (uint8_t *) encoded_data, encoded_data_len));

	return SWITCH_STATUS_SUCCESS;
}
コード例 #6
0
ファイル: test_utils.c プロジェクト: odmanV2/freecenter
SPAN_DECLARE(void) codec_munge(codec_munge_state_t *s, int16_t amp[], int len)
{
    uint8_t law;
    uint8_t adpcmdata[160];
    int i;
    int adpcm;
    int x;

    switch (s->munging_codec)
    {
    case MUNGE_CODEC_NONE:
        /* Do nothing */
        break;
    case MUNGE_CODEC_ALAW:
        for (i = 0;  i < len;  i++)
        {
            law = linear_to_alaw(amp[i]);
            amp[i] = alaw_to_linear(law);
        }
        break;
    case MUNGE_CODEC_ULAW:
        for (i = 0;  i < len;  i++)
        {
            law = linear_to_ulaw(amp[i]);
            if (s->rbs_pattern & (1 << s->sequence))
            {
                /* Strip the bottom bit at the RBS rate */
                law &= 0xFE;
            }
            amp[i] = ulaw_to_linear(law);
        }
        break;
    case MUNGE_CODEC_G726_32K:
        /* This could actually be any of the G.726 rates */
        for (i = 0;  i < len;  i += x)
        {
            x = (len - i >= 160)  ?  160  :  (len - i);
            adpcm = g726_encode(&s->g726_enc_state, adpcmdata, amp + i, x);
            g726_decode(&s->g726_dec_state, amp + i, adpcmdata, adpcm);
        }
        break;
    }
}
コード例 #7
0
int internal_decode_g726(void* handle, const void* pCodedData, 
                         unsigned cbCodedPacketSize, void* pAudioBuffer, 
                         unsigned cbBufferSize, unsigned *pcbCodedSize, 
                         const struct RtpHeader* pRtpHeader)
{
   int samples;
   int maxBytesToDecode;

   // TODO: fix this hack
   maxBytesToDecode = cbCodedPacketSize;
   // g726_state_t is now opaque.  Can no longer access bits_per_sample bits_per_sample 
   //maxBytesToDecode = PLG_MIN(cbCodedPacketSize, cbBufferSize*8/((g726_state_t*)handle)->bits_per_sample);
   //assert(maxBytesToDecode == cbCodedPacketSize);
   
   samples = g726_decode((g726_state_t*)handle, (int16_t*)pAudioBuffer, pCodedData, maxBytesToDecode);
//   printf("G726 decoded %d frames.\n", samples);
   *pcbCodedSize = samples;

   return RPLG_SUCCESS;
}
コード例 #8
0
ファイル: test_utils.c プロジェクト: avesus/guruchat
void codec_munge(codec_munge_state_t *s, int16_t amp[], int len)
{
    uint8_t law;
    uint8_t adpcmdata[160];
    int i;
    int adpcm;
    int x;

    switch (s->munging_codec)
    {
    case MUNGE_CODEC_NONE:
        /* Do nothing */
        break;
    case MUNGE_CODEC_ALAW:
        for (i = 0;  i < len;  i++)
        {
            law = linear_to_alaw(amp[i]);
            amp[i] = alaw_to_linear(law);
        }
        break;
    case MUNGE_CODEC_ULAW:
        for (i = 0;  i < len;  i++)
        {
            law = linear_to_ulaw(amp[i]);
            amp[i] = ulaw_to_linear(law);
        }
        break;
    case MUNGE_CODEC_G726_32K:
        /* This could actually be any of the G.726 rates */
        for (i = 0;  i < len;  i += x)
        {
            x = (len - i >= 160)  ?  160  :  (len - i);
            adpcm = g726_encode(&s->g726_enc_state, adpcmdata, amp + i, x);
            g726_decode(&s->g726_dec_state, amp + i, adpcmdata, adpcm);
        }
        break;
    }
}
コード例 #9
0
ファイル: g726_tests.c プロジェクト: vir/spandsp
int main(int argc, char *argv[])
{
    g726_state_t *enc_state;
    g726_state_t *dec_state;
    int opt;
    int itutests;
    int bit_rate;
    SNDFILE *inhandle;
    SNDFILE *outhandle;
    int16_t amp[1024];
    int frames;
    int adpcm;
    int packing;

    bit_rate = 32000;
    itutests = true;
    packing = G726_PACKING_NONE;
    while ((opt = getopt(argc, argv, "b:LR")) != -1)
    {
        switch (opt)
        {
        case 'b':
            bit_rate = atoi(optarg);
            if (bit_rate != 16000  &&  bit_rate != 24000  &&  bit_rate != 32000  &&  bit_rate != 40000)
            {
                fprintf(stderr, "Invalid bit rate selected. Only 16000, 24000, 32000 and 40000 are valid.\n");
                exit(2);
            }
            itutests = false;
            break;
        case 'L':
            packing = G726_PACKING_LEFT;
            break;
        case 'R':
            packing = G726_PACKING_RIGHT;
            break;
        default:
            //usage();
            exit(2);
        }
    }

    if (itutests)
    {
        itu_compliance_tests();
    }
    else
    {
        if ((inhandle = sf_open_telephony_read(IN_FILE_NAME, 1)) == NULL)
        {
            fprintf(stderr, "    Cannot open audio file '%s'\n", IN_FILE_NAME);
            exit(2);
        }
        if ((outhandle = sf_open_telephony_write(OUT_FILE_NAME, 1)) == NULL)
        {
            fprintf(stderr, "    Cannot create audio file '%s'\n", OUT_FILE_NAME);
            exit(2);
        }

        printf("ADPCM packing is %d\n", packing);
        enc_state = g726_init(NULL, bit_rate, G726_ENCODING_LINEAR, packing);
        dec_state = g726_init(NULL, bit_rate, G726_ENCODING_LINEAR, packing);

        while ((frames = sf_readf_short(inhandle, amp, 159)))
        {
            adpcm = g726_encode(enc_state, adpcmdata, amp, frames);
            frames = g726_decode(dec_state, amp, adpcmdata, adpcm);
            sf_writef_short(outhandle, amp, frames);
        }
        if (sf_close_telephony(inhandle))
        {
            printf("    Cannot close audio file '%s'\n", IN_FILE_NAME);
            exit(2);
        }
        if (sf_close_telephony(outhandle))
        {
            printf("    Cannot close audio file '%s'\n", OUT_FILE_NAME);
            exit(2);
        }
        printf("'%s' transcoded to '%s' at %dbps.\n", IN_FILE_NAME, OUT_FILE_NAME, bit_rate);
        g726_free(enc_state);
        g726_free(dec_state);
    }
    return 0;
}
コード例 #10
0
ファイル: g726_tests.c プロジェクト: vir/spandsp
static void itu_compliance_tests(void)
{
    g726_state_t enc_state;
    g726_state_t dec_state;
    int len2;
    int len3;
    int i;
    int test;
    int bad_samples;
    int conditioning_samples;
    int samples;
    int conditioning_adpcm;
    int adpcm;

    len2 = 0;
    conditioning_samples = 0;
    for (test = 0;  itu_test_sets[test].rate;  test++)
    {
        printf("Test %2d: '%s' + '%s'\n"
               "      -> '%s' + '%s'\n"
               "      -> '%s' [%d, %d, %d]\n",
               test,
               itu_test_sets[test].conditioning_pcm_file,
               itu_test_sets[test].pcm_file,
               itu_test_sets[test].conditioning_adpcm_file,
               itu_test_sets[test].adpcm_file,
               itu_test_sets[test].output_file,
               itu_test_sets[test].rate,
               itu_test_sets[test].compression_law,
               itu_test_sets[test].decompression_law);
        if (itu_test_sets[test].compression_law != G726_ENCODING_NONE)
        {
            /* Test the encode side */
            g726_init(&enc_state, itu_test_sets[test].rate, itu_test_sets[test].compression_law, G726_PACKING_NONE);
            if (itu_test_sets[test].conditioning_pcm_file[0])
            {
                conditioning_samples = get_test_vector(itu_test_sets[test].conditioning_pcm_file, xlaw, MAX_TEST_VECTOR_LEN);
                printf("Test %d: Homing %d samples at %dbps\n", test, conditioning_samples, itu_test_sets[test].rate);
            }
            else
            {
                conditioning_samples = 0;
            }
            samples = get_test_vector(itu_test_sets[test].pcm_file, xlaw + conditioning_samples, MAX_TEST_VECTOR_LEN);
            memcpy(itudata, xlaw, samples + conditioning_samples);
            printf("Test %d: Compressing %d samples at %dbps\n", test, samples, itu_test_sets[test].rate);
            len2 = g726_encode(&enc_state, adpcmdata, itudata, conditioning_samples + samples);
        }
        /* Test the decode side */
        g726_init(&dec_state, itu_test_sets[test].rate, itu_test_sets[test].decompression_law, G726_PACKING_NONE);
        if (itu_test_sets[test].conditioning_adpcm_file[0])
        {
            conditioning_adpcm = get_test_vector(itu_test_sets[test].conditioning_adpcm_file, unpacked, MAX_TEST_VECTOR_LEN);
            printf("Test %d: Homing %d octets at %dbps\n", test, conditioning_adpcm, itu_test_sets[test].rate);
        }
        else
        {
            conditioning_adpcm = 0;
        }
        adpcm = get_test_vector(itu_test_sets[test].adpcm_file, unpacked + conditioning_adpcm, MAX_TEST_VECTOR_LEN);
        if (itu_test_sets[test].compression_law != G726_ENCODING_NONE)
        {
            /* Test our compressed version against the reference compressed version */
            printf("Test %d: Compressed data check - %d/%d octets\n", test, conditioning_adpcm + adpcm, len2);
            if (conditioning_adpcm + adpcm == len2)
            {
                for (bad_samples = 0, i = conditioning_samples;  i < len2;  i++)
                {
                    if (adpcmdata[i] != unpacked[i])
                    {
                        bad_samples++;
                        printf("Test %d: Compressed mismatch %d %x %x\n", test, i, adpcmdata[i], unpacked[i]);
                    }
                }
                if (bad_samples > 0)
                {
                    printf("Test failed\n");
                    exit(2);
                }
                printf("Test passed\n");
            }
            else
            {
                printf("Test %d: Length mismatch - ref = %d, processed = %d\n", test, conditioning_adpcm + adpcm, len2);
                exit(2);
            }
        }

        len3 = g726_decode(&dec_state, outdata, unpacked, conditioning_adpcm + adpcm);

        /* Get the output reference data */
        samples = get_test_vector(itu_test_sets[test].output_file, xlaw, MAX_TEST_VECTOR_LEN);
        memcpy(itu_ref, xlaw, samples);
        /* Test our decompressed version against the reference decompressed version */
        printf("Test %d: Decompressed data check - %d/%d samples\n", test, samples, len3 - conditioning_adpcm);
        if (samples == len3 - conditioning_adpcm)
        {
            for (bad_samples = 0, i = 0;  i < len3;  i++)
            {
                if (itu_ref[i] != ((uint8_t *) outdata)[i + conditioning_adpcm])
                {
                    bad_samples++;
                    printf("Test %d: Decompressed mismatch %d %x %x\n", test, i, itu_ref[i], ((uint8_t *) outdata)[i + conditioning_adpcm]);
                }
            }
            if (bad_samples > 0)
            {
                printf("Test failed\n");
                exit(2);
            }
            printf("Test passed\n");
        }
        else
        {
            printf("Test %d: Length mismatch - ref = %d, processed = %d\n", test, samples, len3 - conditioning_adpcm);
            exit(2);
        }
    }

    printf("Tests passed.\n");
}
コード例 #11
0
int main(int argc, char *argv[])
{
    g726_state_t enc_state;
    g726_state_t dec_state;
    int len2;
    int len3;
    int i;
    int test;
    int bits_per_code;
    int itutests;
    int bit_rate;
    int bad_samples;
    AFfilehandle inhandle;
    AFfilehandle outhandle;
    AFfilesetup filesetup;
    int16_t amp[1024];
    int frames;
    int outframes;
    int conditioning_samples;
    int samples;
    int conditioning_adpcm;
    int adpcm;
    int packing;
    float x;

    i = 1;
    bit_rate = 32000;
    itutests = TRUE;
    packing = G726_PACKING_NONE;
    while (argc > i)
    {
        if (strcmp(argv[i], "-16") == 0)
        {
            bit_rate = 16000;
            itutests = FALSE;
            i++;
        }
        else if (strcmp(argv[i], "-24") == 0)
        {
            bit_rate = 24000;
            itutests = FALSE;
            i++;
        }
        else if (strcmp(argv[i], "-32") == 0)
        {
            bit_rate = 32000;
            itutests = FALSE;
            i++;
        }
        else if (strcmp(argv[i], "-40") == 0)
        {
            bit_rate = 40000;
            itutests = FALSE;
            i++;
        }
        else if (strcmp(argv[i], "-l") == 0)
        {
            packing = G726_PACKING_LEFT;
            i++;
        }
        else if (strcmp(argv[i], "-r") == 0)
        {
            packing = G726_PACKING_RIGHT;
            i++;
        }
        else
        {
            fprintf(stderr, "Unknown parameter %s specified.\n", argv[i]);
            exit(2);
        }
    }

    len2 = 0;
    conditioning_samples = 0;
    if (itutests)
    {
        for (test = 0;  itu_test_sets[test].rate;  test++)
        {
            printf("Test %2d: '%s' + '%s'\n"
                   "      -> '%s' + '%s'\n"
                   "      -> '%s' [%d, %d, %d]\n",
                   test,
                   itu_test_sets[test].conditioning_pcm_file,
                   itu_test_sets[test].pcm_file,
                   itu_test_sets[test].conditioning_adpcm_file,
                   itu_test_sets[test].adpcm_file,
                   itu_test_sets[test].output_file,
                   itu_test_sets[test].rate,
                   itu_test_sets[test].compression_law,
                   itu_test_sets[test].decompression_law);
            switch (itu_test_sets[test].rate)
            {
            case 16000:
                bits_per_code = 2;
                break;
            case 24000:
                bits_per_code = 3;
                break;
            case 32000:
            default:
                bits_per_code = 4;
                break;
            case 40000:
                bits_per_code = 5;
                break;
            }
            if (itu_test_sets[test].compression_law != G726_ENCODING_NONE)
            {
                /* Test the encode side */
                g726_init(&enc_state, itu_test_sets[test].rate, itu_test_sets[test].compression_law, G726_PACKING_NONE);
                if (itu_test_sets[test].conditioning_pcm_file[0])
                {
                    conditioning_samples = get_test_vector(itu_test_sets[test].conditioning_pcm_file, xlaw, MAX_TEST_VECTOR_LEN);
                    printf("Test %d: Homing %d samples at %dbps\n", test, conditioning_samples, itu_test_sets[test].rate);
                }
                else
                {
                    conditioning_samples = 0;
                }
                samples = get_test_vector(itu_test_sets[test].pcm_file, xlaw + conditioning_samples, MAX_TEST_VECTOR_LEN);
                memcpy(itudata, xlaw, samples + conditioning_samples);
                printf("Test %d: Compressing %d samples at %dbps\n", test, samples, itu_test_sets[test].rate);
                len2 = g726_encode(&enc_state, adpcmdata, itudata, conditioning_samples + samples);
            }
            /* Test the decode side */
            g726_init(&dec_state, itu_test_sets[test].rate, itu_test_sets[test].decompression_law, G726_PACKING_NONE);
            if (itu_test_sets[test].conditioning_adpcm_file[0])
            {
                conditioning_adpcm = get_test_vector(itu_test_sets[test].conditioning_adpcm_file, unpacked, MAX_TEST_VECTOR_LEN);
                printf("Test %d: Homing %d octets at %dbps\n", test, conditioning_adpcm, itu_test_sets[test].rate);
            }
            else
            {
                conditioning_adpcm = 0;
            }
            adpcm = get_test_vector(itu_test_sets[test].adpcm_file, unpacked + conditioning_adpcm, MAX_TEST_VECTOR_LEN);
            if (itu_test_sets[test].compression_law != G726_ENCODING_NONE)
            {
                /* Test our compressed version against the reference compressed version */
                printf("Test %d: Compressed data check - %d/%d octets\n", test, conditioning_adpcm + adpcm, len2);
                if (conditioning_adpcm + adpcm == len2)
                {
                    for (bad_samples = 0, i = conditioning_samples;  i < len2;  i++)
                    {
                        if (adpcmdata[i] != unpacked[i])
                        {
                            bad_samples++;
                            printf("Test %d: Compressed mismatch %d %x %x\n", test, i, adpcmdata[i], unpacked[i]);
                        }
                    }
                    if (bad_samples > 0)
                    {
                        printf("Test failed\n");
                        exit(2);
                    }
                    printf("Test passed\n");
                }
                else
                {
                    printf("Test %d: Length mismatch - ref = %d, processed = %d\n", test, conditioning_adpcm + adpcm, len2);
                    exit(2);
                }
            }

            len3 = g726_decode(&dec_state, outdata, unpacked, conditioning_adpcm + adpcm);

            /* Get the output reference data */
            samples = get_test_vector(itu_test_sets[test].output_file, xlaw, MAX_TEST_VECTOR_LEN);
            memcpy(itu_ref, xlaw, samples);
            /* Test our decompressed version against the reference decompressed version */
            printf("Test %d: Decompressed data check - %d/%d samples\n", test, samples, len3 - conditioning_adpcm);
            if (samples == len3 - conditioning_adpcm)
            {
                for (bad_samples = 0, i = 0;  i < len3;  i++)
                {
                    if (itu_ref[i] != ((uint8_t *) outdata)[i + conditioning_adpcm])
                    {
                        bad_samples++;
                        printf("Test %d: Decompressed mismatch %d %x %x\n", test, i, itu_ref[i], ((uint8_t *) outdata)[i + conditioning_adpcm]);
                    }
                }
                if (bad_samples > 0)
                {
                    printf("Test failed\n");
                    exit(2);
                }
                printf("Test passed\n");
            }
            else
            {
                printf("Test %d: Length mismatch - ref = %d, processed = %d\n", test, samples, len3 - conditioning_adpcm);
                exit(2);
            }
        }

        printf("Tests passed.\n");
    }
    else
    {
        if ((inhandle = afOpenFile(IN_FILE_NAME, "r", 0)) == AF_NULL_FILEHANDLE)
        {
            printf("    Cannot open wave file '%s'\n", IN_FILE_NAME);
            exit(2);
        }
        if ((x = afGetFrameSize(inhandle, AF_DEFAULT_TRACK, 1)) != 2.0)
        {
            printf("    Unexpected frame size in wave file '%s'\n", IN_FILE_NAME);
            exit(2);
        }
        if ((x = afGetRate(inhandle, AF_DEFAULT_TRACK)) != (float) SAMPLE_RATE)
        {
            printf("    Unexpected sample rate in wave file '%s'\n", IN_FILE_NAME);
            exit(2);
        }
        if ((x = afGetChannels(inhandle, AF_DEFAULT_TRACK)) != 1.0)
        {
            printf("    Unexpected number of channels in wave file '%s'\n", IN_FILE_NAME);
            exit(2);
        }
        if ((filesetup = afNewFileSetup()) == AF_NULL_FILESETUP)
        {
            fprintf(stderr, "    Failed to create file setup\n");
            exit(2);
        }
        afInitSampleFormat(filesetup, AF_DEFAULT_TRACK, AF_SAMPFMT_TWOSCOMP, 16);
        afInitRate(filesetup, AF_DEFAULT_TRACK, (float) SAMPLE_RATE);
        afInitFileFormat(filesetup, AF_FILE_WAVE);
        afInitChannels(filesetup, AF_DEFAULT_TRACK, 1);

        outhandle = afOpenFile(OUT_FILE_NAME, "w", filesetup);
        if (outhandle == AF_NULL_FILEHANDLE)
        {
            fprintf(stderr, "    Cannot create wave file '%s'\n", OUT_FILE_NAME);
            exit(2);
        }

        printf("ADPCM packing is %d\n", packing);
        g726_init(&enc_state, bit_rate, G726_ENCODING_LINEAR, packing);
        g726_init(&dec_state, bit_rate, G726_ENCODING_LINEAR, packing);

        while ((frames = afReadFrames(inhandle, AF_DEFAULT_TRACK, amp, 159)))
        {
            adpcm = g726_encode(&enc_state, adpcmdata, amp, frames);
            frames = g726_decode(&dec_state, amp, adpcmdata, adpcm);
            outframes = afWriteFrames(outhandle, AF_DEFAULT_TRACK, amp, frames);
        }
        if (afCloseFile(inhandle) != 0)
        {
            printf("    Cannot close wave file '%s'\n", IN_FILE_NAME);
            exit(2);
        }
        if (afCloseFile(outhandle) != 0)
        {
            printf("    Cannot close wave file '%s'\n", OUT_FILE_NAME);
            exit(2);
        }
        afFreeFileSetup(filesetup);
        printf("'%s' transcoded to '%s' at %dbps.\n", IN_FILE_NAME, OUT_FILE_NAME, bit_rate);
    }
    return 0;
}