⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 g723atop.c

📁 The combined demo is dedicated for S1C33L05, so DMT33L05 should be used to load and run the demo. F
💻 C
字号:
/*
 *  Copyright (C) SEIKO EPSON CORP.2000
 *  All Rights Reserved
 *
 *  g723atop.c : G723.1Annex-A decoder top level program
 *
 *  Ver 0.10 2000/12/08  Y.Uchiyama  Start
 *  Ver 0.20 2001/01/16  N.Komatsu   Add prefix
 *  Ver 0.30 2001/05/25  N.Komatsu   Add the argument to "g723aSpeak()" function.
 */

#include "Speak.h"
#include "slutil.h"

#include "g723adec.h"

#define SAMPLING_RATE   8000
#define G723A_PACKET_SIZE     FRAME               
#define G723A_SPK_PACKET_SIZE G723A_PACKET_SIZE*2     /* oversampling */
#define G723A_SPLIS_BUF_SIZE  G723A_SPK_PACKET_SIZE*2 /* 2 buffer */

static char	*pbit;
static int	FileLength;
static long     BitDataSize;
extern unsigned char *gSpkParams;

static Slparam	SlParam;
short gSplisBuf[G723A_SPLIS_BUF_SIZE];

void g723aTopDecode(unsigned char *SpkParams, short *Buffer, int Length)
{
    int		i, size;
    char	Line[24], Info;
    short	DataBuff[FRAME];
    
    if(FileLength <= 0) return;

    /* 壒惡怢挿 */
    Line[0] = *pbit++;
    Info = Line[0] & (short)0x0003 ;
    switch(Info) {
	/* Active frame, high rate */
        case 0 : {
            size  = 23;
            break;
	}
        /* Active frame, low rate */
        case 1 : {
            size  = 19;
            break;
	}
        /* Sid Frame */
        case 2 : {
            size  = 3;
            break;
	}
        /* untransmitted */
        default : {
            size  = 0;
            break;
	}
    }

    for(i=0; i<size; ++i)
	Line[i+1] = *pbit++;

    g723aDecode(DataBuff, Line, 0);

    FileLength -= size + 1;

    slPcm2Spk(DataBuff, Buffer, FRAME, &SlParam);
    SpkAppend(SpkParams, Buffer, FRAME<<1);  /* oversampling */
}


static unsigned char *TopSpeakStart(int Clock)
{
    int            BufPos;
    unsigned char *SpkParams;

    SpkInit();
    SpkSoftening(3);
    SpkParams = SpkOpen(SPK_15_MONO,SPK_SAMPLING(Clock,SAMPLING_RATE<<1));
                        /* SAMPLING_RATE<<1 for 2 times over sampling */
    if((int)SpkParams <= 0) return SpkParams;

    for(BufPos=0; (BufPos+G723A_SPK_PACKET_SIZE)<=G723A_SPLIS_BUF_SIZE; 
        BufPos+=G723A_SPK_PACKET_SIZE){
        g723aTopDecode(SpkParams, gSplisBuf+BufPos, G723A_SPK_PACKET_SIZE);
    }
    
    SpkOnDone(SpkParams, g723aTopDecode);
    SpkOnEmpty(SpkParams, SpkClose);
    
    SpkStart(SpkParams);

    return SpkParams;
}


unsigned char *g723aSpeak(char *bitdata, int Clock)
{
    char          *size_data;

    extern unsigned short SPK_PREDATA;

    bitdata++;
    size_data = bitdata;

    BitDataSize = *size_data++ & 0xff;
    BitDataSize += (*size_data++ & 0xff) << 8;
    BitDataSize += (*size_data++ & 0xff) << 16;
    BitDataSize += (*size_data++ & 0xff) << 24;

    FileLength = BitDataSize;
    pbit = bitdata + 4;

    g723aInitDecode(1); /* 1 = PostFilter ON (Default), 0 = PostFilter OFF. */
    g723aInitDecCng();

    SPK_PREDATA = 0x8000;
    SlParam.offset = 0x8000;
    SlParam.limit  = 0xffff;

    return TopSpeakStart(Clock);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -