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

📄 sphdec1_copy.c

📁 TI Algorithm Soft Kit 5.10 仅包括实例及其原代码
💻 C
字号:
/*  *  Copyright 2006 *  Texas Instruments Incorporated * *  All rights reserved.  Property of Texas Instruments Incorporated *  Restricted rights to use, duplicate or disclose this code are *  granted through contract. *  *//* *  ======== sphdec1_copy.c ======== *  Speech decoder "copy" algorithm, PCM codec family. * *  This file contains an implementation of the IALG interface *  required by xDAIS. */#include <xdc/std.h>#include <string.h>#include <ti/xdais/dm/isphdec1.h>#include <ti/xdais/dm/ispeech1_pcm.h>#include "sphdec1_copy_ti.h"#include "sphdec1_copy_ti_priv.h"/* buffer definitions */#define MININBUFS       1#define MINOUTBUFS      1#define MININBUFSIZE    1#define MINOUTBUFSIZE   1extern IALG_Fxns SPHDEC1COPY_TI_IALG;#define IALGFXNS  \    &SPHDEC1COPY_TI_IALG,       /* module ID */                         \    NULL,                       /* activate */                          \    SPHDEC1COPY_TI_alloc,       /* alloc */                             \    NULL,                       /* control (NULL => no control ops) */  \    NULL,                       /* deactivate */                        \    SPHDEC1COPY_TI_free,        /* free */                              \    SPHDEC1COPY_TI_initObj,     /* init */                              \    NULL,                       /* moved */                             \    NULL                        /* numAlloc (NULL => IALG_MAXMEMRECS) *//* *  ======== SPHDEC1COPY_TI_ISPHDEC ======== *  This structure defines TI's implementation of the ISPHDEC1 interface *  for the SPHDEC1COPY_TI module. */ISPHDEC1_Fxns SPHDEC1COPY_TI_SPHDECCOPY = { /* module_vendor_interface */    {IALGFXNS},    SPHDEC1COPY_TI_process,    SPHDEC1COPY_TI_control,};/* *  ======== SPHDEC1COPY_TI_IALG ======== *  This structure defines TI's implementation of the IALG interface *  for the SPHDEC1COPY_TI module. */#ifdef _TI_asm("_SPHDEC1COPY_TI_IALG .set _SPHDEC1COPY_TI_SPHDECCOPY");#else/* *  We duplicate the structure here to allow this code to be compiled and *  run non-DSP platforms at the expense of unnecessary data space *  consumed by the definition below. */IALG_Fxns SPHDEC1COPY_TI_IALG = {      /* module_vendor_interface */    IALGFXNS};#endifISPHDEC1_Params SPHDEC1COPY_TI_PARAMS = {    sizeof(ISPHDEC1_Params),    ISPEECH1_PCM_COMPAND_DEFAULT,    0,                              /* packingType is a don't care for PCM */    ISPEECH1_CODECSELECT_DEFAULT,    NULL};/* *  ======== SPHDEC1COPY_TI_alloc ======== */Int SPHDEC1COPY_TI_alloc(const IALG_Params *algParams,    IALG_Fxns **pf, IALG_MemRec memTab[]){    /* Request memory for my object */    memTab[0].size = sizeof(SPHDEC1COPY_TI_Obj);    memTab[0].alignment = 0;    memTab[0].space = IALG_EXTERNAL;    memTab[0].attrs = IALG_PERSIST;    return (1);}/* *  ======== SPHDEC1COPY_TI_free ======== */Int SPHDEC1COPY_TI_free(IALG_Handle handle, IALG_MemRec memTab[]){    SPHDEC1COPY_TI_alloc(NULL, NULL, memTab);    return (1);}/* *  ======== SPHDEC1COPY_TI_initObj ======== */Int SPHDEC1COPY_TI_initObj(IALG_Handle handle, const IALG_MemRec memTab[],    IALG_Handle p, const IALG_Params *algParams){    SPHDEC1COPY_TI_Obj *obj = (SPHDEC1COPY_TI_Obj *)handle;    const ISPHDEC1_Params *params = (ISPHDEC1_Params *)algParams;    if (params == NULL) {        params = &SPHDEC1COPY_TI_PARAMS;    }    obj->compandingLaw = params->compandingLaw;    obj->packingType = params->packingType;    obj->codecSelection = params->codecSelection;    obj->postFilter = ISPEECH1_POSTFILTER_DEFAULT;    return (IALG_EOK);}/* *  ======== SPHDEC1COPY_TI_process ======== */XDAS_Int32 SPHDEC1COPY_TI_process(ISPHDEC1_Handle h,    XDM_SingleBufDesc *inCodeWords, XDM_SingleBufDesc *outSamples,    ISPHDEC1_InArgs *inArgs, ISPHDEC1_OutArgs *outArgs){    int  numBytes;    /*     * The number of bytes we can consume is the lesser of the specified     * number of bytes to decode (inCodeWords->bufSize) and the size of the     * buffer that will contain the output (outSamples->bufSize).     */    numBytes = (inCodeWords->bufSize <= outSamples->bufSize) ?        inCodeWords->bufSize : outSamples->bufSize;    /* process the data: read input, produce output */    memcpy(outSamples->buf, inCodeWords->buf, numBytes);    /* Fill out the rest of the outArgs struct */    outArgs->dataSize = numBytes * 8;  /* 8 bits per byte */    outArgs->extendedError = 0;    return (ISPHDEC1_EOK);}/* *  ======== SPHDEC1COPY_TI_control ======== */XDAS_Int32 SPHDEC1COPY_TI_control(ISPHDEC1_Handle handle, ISPHDEC1_Cmd id,    ISPHDEC1_DynamicParams *params, ISPHDEC1_Status *status){    XDAS_Int32 retVal;    SPHDEC1COPY_TI_Obj *obj = (SPHDEC1COPY_TI_Obj *)handle;    /* validate arguments - this codec only supports "base" xDM. */    if ((params->size != sizeof(*params)) ||        (status->size != sizeof(*status))) {        return (ISPHDEC1_EUNSUPPORTED);    }    switch (id) {        case XDM_GETSTATUS:        case XDM_GETBUFINFO:            status->postFilter = obj->postFilter;            status->extendedError = 0;            status->compandingLaw = obj->compandingLaw;            status->packingType = obj->packingType;            status->codecSelection = obj->codecSelection;            status->bufInfo.minNumInBufs = MININBUFS;            status->bufInfo.minNumOutBufs = MINOUTBUFS;            status->bufInfo.minInBufSize[0] = MININBUFSIZE;            status->bufInfo.minOutBufSize[0] = MINOUTBUFSIZE;            retVal = ISPHDEC1_EOK;            break;        case XDM_SETPARAMS:            obj->postFilter = params->postFilter;            retVal = ISPHDEC1_EOK;            break;        case XDM_SETDEFAULT:            /* should validate these rather than blindly assign them! */            obj->compandingLaw = SPHDEC1COPY_TI_PARAMS.compandingLaw;            obj->packingType = SPHDEC1COPY_TI_PARAMS.packingType;            obj->codecSelection = SPHDEC1COPY_TI_PARAMS.codecSelection;            obj->postFilter = ISPEECH1_POSTFILTER_DEFAULT;            retVal = ISPHDEC1_EOK;            break;        case XDM_RESET:        case XDM_FLUSH:            retVal = ISPHDEC1_EOK;            break;        default:            /* unsupported cmd */            retVal = ISPHDEC1_EFAIL;            break;    }    return (retVal);}/* *  @(#) ti.xdais.dm.examples.sphdec1_copy; 1,0,0,19; 10-18-2006 19:12:14; /db/wtree/library/trees/dais-g07x/src/ */

⌨️ 快捷键说明

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