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

📄 ad_twin.c

📁 自己移植的linux下的流媒体播放器原代码,支持mms协议,支持ftp和http协议.
💻 C
📖 第 1 页 / 共 2 页
字号:
            nbits, BITS_INT);        exit(1);    }    retval = bread(tmpbit, sizeof(*tmpbit), nbits, sh);    for (ibit=retval; ibit<nbits; ibit++){        tmpbit[ibit] = 0;    }    mask = 0x1<<(nbits-1);    work=0;    for ( ibit=0; ibit<nbits; ibit++ ){        work += mask*tmpbit[ibit];        mask >>= 1;    }    *data = work;    return(retval);}static int GetVqInfo( tvqConfInfoSubBlock *cfg,            int bits0[],            int bits1[],            int variableBits,            INDEX *index,            sh_audio_t *sh){    int idiv;    int bitcount = 0;    if ( index->btype == BLK_LONG ){        TvqUpdateVectorInfo( variableBits, &cfg->ndiv, bits0, bits1 ); // re-calculate VQ bits    }    for ( idiv=0; idiv<cfg->ndiv; idiv++ ){        bitcount += get_bstm(&index->wvq[idiv],bits0[idiv],sh); /* CB 0 */        bitcount += get_bstm(&index->wvq[idiv+cfg->ndiv],bits1[idiv],sh); /* CB 1 */    }    return bitcount;}static int GetBseInfo( tvqConfInfo *cf, tvqConfInfoSubBlock *cfg, INDEX *index, sh_audio_t *sh){    int i_sup, isf, itmp, idiv;    int bitcount = 0;    for ( i_sup=0; i_sup<cf->N_CH; i_sup++ ){        for ( isf=0; isf<cfg->nsf; isf++ ){            for ( idiv=0; idiv<cfg->fw_ndiv; idiv++ ){                itmp = idiv + ( isf + i_sup * cfg->nsf ) * cfg->fw_ndiv;                bitcount += get_bstm(&index->fw[itmp],cfg->fw_nbit,sh);            }        }    }    for ( i_sup=0; i_sup<cf->N_CH; i_sup++ ){        for ( isf=0; isf<cfg->nsf; isf++ ){            bitcount += get_bstm(&index->fw_alf[i_sup * cfg->nsf + isf],cf->FW_ARSW_BITS,sh);        }    }    return bitcount;}static int GetGainInfo(tvqConfInfo *cf, tvqConfInfoSubBlock *cfg, INDEX *index, sh_audio_t *sh ){    int i_sup, iptop, isf;    int bitcount = 0;    for ( i_sup=0; i_sup<cf->N_CH; i_sup++ ){        iptop = ( cfg->nsubg + 1 ) * i_sup;        bitcount += get_bstm(&index->pow[iptop], cf->GAIN_BITS,sh);        for ( isf=0; isf<cfg->nsubg; isf++ ){            bitcount += get_bstm(&index->pow[iptop+isf+1], cf->SUB_GAIN_BITS,sh);        }    }    return bitcount;}static int GetLspInfo( tvqConfInfo *cf, INDEX *index, sh_audio_t *sh ){    int i_sup, itmp;    int bitcount = 0;    for ( i_sup=0; i_sup<cf->N_CH; i_sup++ ){        bitcount += get_bstm(&index->lsp[i_sup][0], cf->LSP_BIT0,sh); /* pred. switch */        bitcount += get_bstm(&index->lsp[i_sup][1], cf->LSP_BIT1,sh); /* first stage */        for ( itmp=0; itmp<cf->LSP_SPLIT; itmp++ ){         /* second stage */            bitcount += get_bstm(&index->lsp[i_sup][itmp+2], cf->LSP_BIT2,sh);        }    }    return bitcount;}static int GetPpcInfo( tvqConfInfo *cf, INDEX *index, sh_audio_t *sh){    int idiv, i_sup;    int bitcount = 0;    vqf_priv_t*priv=sh->context;        for ( idiv=0; idiv<cf->N_DIV_P; idiv++ ){        bitcount += get_bstm(&(index->pls[idiv]), priv->bits_0[BLK_PPC][idiv],sh);       /*CB0*/        bitcount += get_bstm(&(index->pls[idiv+cf->N_DIV_P]), priv->bits_1[BLK_PPC][idiv],sh);/*CB1*/    }    for (i_sup=0; i_sup<cf->N_CH; i_sup++){        bitcount += get_bstm(&(index->pit[i_sup]), cf->BASF_BIT,sh);        bitcount += get_bstm(&(index->pgain[i_sup]), cf->PGAIN_BIT,sh);    }        return bitcount;}static int GetEbcInfo( tvqConfInfo *cf, tvqConfInfoSubBlock *cfg, INDEX *index, sh_audio_t *sh){    int i_sup, isf, itmp;    int bitcount = 0;    for ( i_sup=0; i_sup<cf->N_CH; i_sup++ ){        for ( isf=0; isf<cfg->nsf; isf++){            int indexSfOffset = isf * ( cfg->ncrb - cfg->ebc_crb_base ) - cfg->ebc_crb_base;            for ( itmp=cfg->ebc_crb_base; itmp<cfg->ncrb; itmp++ ){                bitcount += get_bstm(&index->bc[i_sup][itmp+indexSfOffset], cfg->ebc_bits,sh);            }        }    }        return bitcount;}static int vqf_read_frame(sh_audio_t *sh,INDEX *index){    /*--- Variables ---*/    tvqConfInfoSubBlock *cfg;    int variableBits;    int bitcount;    int numFixedBitsPerFrame = TvqGetNumFixedBitsPerFrame();    int btype;    vqf_priv_t *priv=sh->context;        /*--- Initialization ---*/    variableBits = 0;    bitcount = 0;    /*--- read block independent factors ---*/    /* Window type */    bitcount += get_bstm( &index->w_type, priv->cf.BITS_WTYPE, sh );    if ( TvqWtypeToBtype( index->w_type, &index->btype ) ) {        mp_msg(MSGT_DECAUDIO, MSGL_ERR, "Error: unknown window type: %d\n", index->w_type);        return 0;    }    btype = index->btype;    /*--- read block dependent factors ---*/    cfg = &priv->cf.cfg[btype]; // set the block dependent paremeters table    bitcount += variableBits;        /* Interleaved vector quantization */    bitcount += GetVqInfo( cfg, priv->bits_0[btype], priv->bits_1[btype], variableBits, index, sh );        /* Bark-scale envelope */    bitcount += GetBseInfo( &priv->cf, cfg, index, sh );    /* Gain */    bitcount += GetGainInfo( &priv->cf, cfg, index, sh );    /* LSP */    bitcount += GetLspInfo( &priv->cf, index, sh );    /* PPC */    if ( cfg->ppc_enable ){        bitcount += GetPpcInfo( &priv->cf, index, sh );    }    /* Energy Balance Calibration */    if ( cfg->ebc_enable ){        bitcount += GetEbcInfo( &priv->cf, cfg, index, sh );    }        return bitcount == numFixedBitsPerFrame ? bitcount/8 : 0;}static void frtobuf_s16(float out[],       /* Input  --- input data frame */        short bufout[],    /* Output --- output data buffer array */        unsigned frameSize,   /* Input  --- frame size */        unsigned numChannels) /* Input  --- number of channels */{    /*--- Variables ---*/    unsigned ismp, ich;    float *ptr;    float dtmp;        for ( ich=0; ich<numChannels; ich++ ){        ptr = out+ich*frameSize;        for ( ismp=0; ismp<frameSize; ismp++ ){            dtmp = ptr[ismp];            if ( dtmp >= 0. ) {                if ( dtmp > 32700. )                dtmp = 32700.;                bufout[ismp*numChannels+ich] = (short)(dtmp+0.5);            } else {                if ( dtmp < -32700. )                dtmp = -32700.;                bufout[ismp*numChannels+ich] = (short)(dtmp-0.5);            }        }    }}static void frtobuf_float(float out[],       /* Input  --- input data frame */        float bufout[],    /* Output --- output data buffer array */        unsigned frameSize,   /* Input  --- frame size */        unsigned numChannels) /* Input  --- number of channels */{    /*--- Variables ---*/    unsigned ismp, ich;    float *ptr;    float dtmp;        for ( ich=0; ich<numChannels; ich++ ){        ptr = out+ich*frameSize;        for ( ismp=0; ismp<frameSize; ismp++ ){            dtmp = ptr[ismp];            if ( dtmp >= 0. ) {                if ( dtmp > 32700. )                dtmp = 32700.;                bufout[ismp*numChannels+ich] = dtmp/32767.;            } else {                if ( dtmp < -32700. )                dtmp = -32700.;                bufout[ismp*numChannels+ich] = dtmp/32767.;            }        }    }}int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen){    int l, len=0;    vqf_priv_t *priv=sh_audio->context;    while(len<minlen)    {        float out[priv->framesize*sh_audio->channels];        l=vqf_read_frame(sh_audio,&priv->index);        if(!l) break;        TvqDecodeFrame(&priv->index, out);        if (priv->skip_cnt) {            // Ingnore first two frames, replace them with silence            priv->skip_cnt--;            memset(buf, 0, priv->framesize*sh_audio->channels*sh_audio->samplesize);        } else {           if (sh_audio->sample_format == AF_FORMAT_S16_NE)               frtobuf_s16(out, (short *)buf, priv->framesize, sh_audio->channels);           else               frtobuf_float(out, (float *)buf, priv->framesize, sh_audio->channels);        }        len += priv->framesize*sh_audio->channels*sh_audio->samplesize;        buf += priv->framesize*sh_audio->channels*sh_audio->samplesize;    }    return len;}#endif

⌨️ 快捷键说明

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