亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? adpcm.c

?? adpcm編碼源代碼
?? C
字號:
#include "common.h"
#include <stdio.h>



/* Intel ADPCM step variation table */
short indexTable[16] = {
    -1, -1, -1, -1, 2, 4, 6, 8,
    -1, -1, -1, -1, 2, 4, 6, 8,
};

// const short
short stepsizeTable[89] = {
    7, 8, 9, 10, 11, 12, 13, 14, 16, 17,
    19, 21, 23, 25, 28, 31, 34, 37, 41, 45,
    50, 55, 60, 66, 73, 80, 88, 97, 107, 118,
    130, 143, 157, 173, 190, 209, 230, 253, 279, 307,
    337, 371, 408, 449, 494, 544, 598, 658, 724, 796,
    876, 963, 1060, 1166, 1282, 1411, 1552, 1707, 1878, 2066,
    2272, 2499, 2749, 3024, 3327, 3660, 4026, 4428, 4871, 5358,
    5894, 6484, 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899,
    15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767
};
/*======================================= Encode Part Begin ====================================*/
// these parameters are for encode
/* left channel parameters */
short LeftEncodePreVal;       // save the previous value for left channel
short LeftEncodeIndex;        // save the index for left channel

//short LeftEncodeDataIn[10];    // here is the 2 word bytes input audio data for left channel
//char LeftEncodeDataOut[60];   // store the compressed data
short LeftEncodeDataIn[10];
char LeftEncodeDataOut[512];   // store the compressed data 128

short RightEncodeDataIn[10];   // here is the 2 word bytes input audio data for right channel
char RightEncodeDataOut[512];  // store the compressed data 128



/* right channel parameters */
short RightEncodePreVal;      // save the previous value for right channel
short RightEncodeIndex;       // save the index for right channel
//short RightEncodeDataIn[10];   // here is the 2 word bytes input audio data for right channel
//char RightEncodeDataOut[60];  // store the compressed data

/* output pointer for left and right channel */
unsigned char EncodeOutPointer;
unsigned char tmp=0;



/*===============================================================================================
= Explain:                                                                                      =
= You can sample the audio data and stored it in xEncodeDataIn[](total 2 word every time), then =
= you can call ADPCM_Encode(), the audio data will be compressed and stored in xEncodeDataOut[],=
= 2 word will be compressed as 1 byte                                                           =
= Example:                                                                                      =
= Now LeftEncodeDataIn[0]=0xfd26,LeftEncodeDataIn[1]=0xfc6a,EncodeOutPointer=0,                 =
= after you call ADPCM_Encode(LeftChannel), then LeftEncodeDataOut[0] will be 0xff              =
===============================================================================================*/
void ADPCM_Encode (unsigned char LeftRight)
{
  unsigned char i;
  short step;
  short valpre;
  short index;
  short val;
  short delta;
  unsigned char sign;
  short vpdiff;
  unsigned char outbuffer;

  if (LeftRight==LeftChannel)
  {
    valpre = LeftEncodePreVal;
    index = LeftEncodeIndex;
  }
  else
  {
    valpre = RightEncodePreVal;
    index = RightEncodeIndex;
  }

  step = stepsizeTable[index];

  for (i=0;i<2;i++)
  {
    if (LeftRight==LeftChannel)
      val = LeftEncodeDataIn[i];
    else
      val = RightEncodeDataIn[i];
    // Step 1 --- compute difference with previous value
    //delta = val - valpre;
    //sign = (delta<0)?8:0;
    //if (sign==8) delta=(-delta);
    if (val<valpre)
    {
      sign = 8;
      delta=valpre-val;
    }
    else
    {
      sign = 0;
      delta=val-valpre;
    }
    // Step 2 --- Divide and clamp
    /*
    if (1)
    {
      delta = (delta<<2)/step;
      if (delta>7) delta = 7;
      vpdiff = (delta*step)>>2;
    }
    else
    {*/
      vpdiff = 0;
      if (delta > step)
      {
        tmp = 4;
        delta -= step;
        vpdiff = step;
      }
      step >>= 1;
      if (delta > step)
      {
        tmp |= 2;
        delta -= step;
        vpdiff += step;
      }
      step >>= 1;
      if (delta > step)
      {
        tmp |= 1;
        vpdiff += step;
      }
      delta = tmp;
    //}
    // Step 3 --- Update previous value
    if (sign==8)
      valpre -= vpdiff;
    else
      valpre += vpdiff;
    // Step 4 --- Clamp previous value to 16 bits

    if (valpre>32767)
      valpre = 32767;
    else if (valpre<-32768)
      valpre = -32768;
    // Step 5 --- Assemble value, update index and step values
    delta |= sign;
    index += indexTable[delta];
    if (index<0)  index = 0;
    if (index>88) index = 88;
    step = stepsizeTable[index];
    // Step 6 --- Output value
    if (i==0)
    {
      outbuffer = (delta<<4)&0xf0;
    }
    else  // here 2 frame end, need save the valpre and index
    {
      if (LeftRight==LeftChannel)
      {
        LeftEncodeIndex = index;
        LeftEncodePreVal = valpre;
        LeftEncodeDataOut[EncodeOutPointer]=(delta&0x0f)|outbuffer;
      }
      else
      {
        RightEncodeIndex = index;
        RightEncodePreVal = valpre;
        RightEncodeDataOut[EncodeOutPointer]=(char)((delta&0x0f)|outbuffer);
      }
    }
  }
}

/*======================================= Decode Part Begin ====================================*/
// these parameters are for Decode
/* left channel parameters */
short LeftDecodePreVal;       // save the previous value for left channel
short LeftDecodeIndex;        // save the index for left channel


char LeftDecodeDataIn[220 * 1024];    // input audio data compressed for left channel

short LeftDecodeDataOut[10];   // store the uncompressed data

/* right channel parameters */
short RightDecodePreVal;      // save the previous value for right channel
short RightDecodeIndex;       // save the index for right channel
char RightDecodeDataIn[220 * 1024];   // input audio data compressed for right channel
short RightDecodeDataOut[10];  // store the uncompressed data

/* output pointer for left and right channel */
unsigned char DecodeOutPointer;


/*===============================================================================================
= Explain:                                                                                      =
= You can get the audio data compressed and stored it in xDecodeDataIn[] (total 1 byte every    =
= time), then you can call ADPCM_Decode(), the audio data will be uncompressed and stored in    =
= xDecodeDataOut[],1 byte will be uncompressed as 2 words                                       =                                                        
= Example:                                                                                      =
= Now LeftDecodeDataIn[0]=0xff,DecodeOutPointer=0,                                              =
= after you call ADPCM_Encode(LeftChannel),                                                     =
= then LeftDecodeDataOut[0]=0xfff4, LeftDecodeDataOut[1]=0xffd8                                 =
===============================================================================================*/

void ADPCM_Decode (unsigned char LeftRight)
{
  unsigned char i;
  short step;
  short index;
  short valpre;
  short delta;
  unsigned char sign;
  short vpdiff;
  unsigned char inbuffer;

  if (LeftRight==LeftChannel)
  {
    valpre=LeftDecodePreVal;
    index=LeftDecodeIndex;
    inbuffer=LeftDecodeDataIn[DecodeOutPointer];
  }
  else
  {
    valpre=RightDecodePreVal;
    index=RightDecodeIndex;
    inbuffer=RightDecodeDataIn[DecodeOutPointer];
  }
  step = stepsizeTable[index];
  for (i=0;i<2;i++)
  {
    // Step 1 --- get the delta value and compute next index
    if (i==0)
    {
      delta=(inbuffer>>4)&0x0f;
    }
    else
    {
      delta=inbuffer&0x0f;
    }
    // Step2 --- Find new index value (for later)

    index += indexTable[delta];
    if (index<0)
    {
      index = 0;
    }
    else if (index>88)
    {
      index = 88;
    }
    // Step 3 --- Separate sign and magnitude
    sign = delta & 8;
    delta = delta & 7;
    // Step 4 --- update output value
    /*
    if (0)
    {
      vpdiff = (delta*step)>>2;
    }
    else
    {*/
      vpdiff = 0;
      if (delta&4)
      {
        vpdiff = (step<<2);
      }
     if (delta&2)
     {
       vpdiff += (step<<1);
     }
      if (delta&1)
      {
        vpdiff += step;
      }
      vpdiff >>=2;
    //}

    if (sign) valpre -= vpdiff;
    else  valpre += vpdiff;
    // Step 5 --- clamp output value
    if (valpre>32767) valpre = 32767;
    else if (valpre<-32768) valpre = -32768;
    // Step 6 --- Update step value
    step = stepsizeTable[index];
    // Step 7 --- Output value
    if (LeftRight==LeftChannel)
    {
      LeftDecodeDataOut[i]=valpre;
      LeftDecodePreVal=valpre;
      LeftDecodeIndex=index;
    }
    else
    {
      RightDecodeDataOut[i]=valpre;
      RightDecodePreVal=valpre;
      RightDecodeIndex=index;
    }
  }
}

/*==========================================================================================
            You can test the result with the follow subroutine
===========================================================================================*/
void ADPCM_TEST (void)
{
  EncodeOutPointer=0;
  LeftEncodeDataIn[0]=0xfd26;
  LeftEncodeDataIn[1]=0xfc6a;
  ADPCM_Encode(LeftChannel);
  // ===> here you will get the compressed data in LeftEncodeDataOut[EncodeOutPointer]=0xff

  //EncodeOutPointer++;
  LeftEncodeDataIn[0]=0xfca5;
  LeftEncodeDataIn[1]=0x04dd;
  ADPCM_Encode(LeftChannel);
  // ===> here you will get the compressed data in LeftEncodeDataOut[EncodeOutPointer]=0xf7

  EncodeOutPointer++;
  LeftEncodeDataIn[0]=0xfe77;
  LeftEncodeDataIn[1]=0xfdfa;
  ADPCM_Encode(LeftChannel);
  // ===> here you will get the compressed data in LeftEncodeDataOut[EncodeOutPointer]=0xfb

  DecodeOutPointer=0;
  LeftDecodeDataIn[0]=LeftEncodeDataOut[0];
  ADPCM_Decode(LeftChannel);
  // ===> here you will get the unpressed data in LeftDecodeDataOut[DecodeOutPointer]=0xfff4 0xffd8

  DecodeOutPointer++;
  //LeftDecodeDataIn[1]=LeftEncodeDataOut[1];
  LeftDecodeDataIn[0]=LeftEncodeDataOut[1];

  ADPCM_Decode(LeftChannel);
  // ===> here you will get the unpressed data in LeftDecodeDataOut[DecodeOutPointer]=0xff9d 0x001c

  DecodeOutPointer++;
  LeftDecodeDataIn[2]=LeftEncodeDataOut[2];
  ADPCM_Decode(LeftChannel);
  // ===> here you will get the unpressed data in LeftDecodeDataOut[DecodeOutPointer]=0xff0a 0xfe0e

}

void main()
{

FILE *fd1;
FILE *fd2;
short buf[1024];
short dabuf[1024];
int cnt = 0;
int leftpt = 0;
int leftdapt = 0;
int i = 0;
int uu = 0;
char enoutL = 0;
char enoutR = 0;

short deout1L = 0,deout2L = 0;
short deout1R = 0,deout2R = 0;

int decodeL_in = 0;
int decodeR_in = 0;



fd1 = fopen("e:\\PUNCH.wav","rb+");
fd2 = fopen("e:\\test33.wav","wb+");

fread( buf, 1, 58, fd1);
fwrite(buf,1,58,fd2);



//fclose(fd2);
ADPCM_TEST();
//EncodeOutPointer = 0;

while((cnt = fread( buf, 1, 1024, fd1)) != 0)
{  
  EncodeOutPointer = 0;
  
  while(i < cnt/4)
  {

  //左聲道壓
  EncodeOutPointer = 0;

  LeftEncodeDataIn[0]= buf[leftpt];
  LeftEncodeDataIn[1]= buf[leftpt + 2];

  ADPCM_Encode(LeftChannel);

  // ===> here you will get the compressed data in LeftEncodeDataOut[EncodeOutPointer]=0xff
  
  //解壓
  DecodeOutPointer = 0;
  LeftDecodeDataIn[decodeL_in++] = LeftEncodeDataOut[0]; 
  ADPCM_Decode(LeftChannel);
 


  //寫入另一個文件
  dabuf[leftdapt] = LeftDecodeDataOut[0];
  dabuf[leftdapt + 2] = LeftDecodeDataOut[1];

  //
  //右聲道亞    
  EncodeOutPointer = 0;
  
  RightEncodeDataIn[0]= buf[leftpt + 1];
  RightEncodeDataIn[1]= buf[leftpt + 3];
  ADPCM_Encode(RightChannel);
  // ===> here you will get the compressed data in LeftEncodeDataOut[EncodeOutPointer]=0xff

  //解壓
  DecodeOutPointer = 0;

  RightDecodeDataIn[decodeR_in++] = RightEncodeDataOut[0];
 
  ADPCM_Decode(RightChannel);


  //寫入另一個文件
  dabuf[leftdapt + 1] = RightDecodeDataOut[0];
  dabuf[leftdapt + 3] = RightDecodeDataOut[1];

  leftpt += 4;
  leftdapt += 4;

   i++;
   
  }

  fwrite(dabuf,2,512,fd2);
  


}



fclose(fd1);
fclose(fd2);



}


?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产欧美日韩综合| 奇米在线7777在线精品| 欧美综合天天夜夜久久| 亚洲永久精品国产| 欧美二区乱c少妇| 日本欧美在线观看| 久久综合色婷婷| 成人福利视频在线| 亚洲一二三四在线| 欧美久久一二区| 激情综合网天天干| 国产精品乱子久久久久| 色久综合一二码| 日韩影院在线观看| 久久久久久久久蜜桃| 99久久综合狠狠综合久久| 伊人色综合久久天天| 欧美一级淫片007| 成人深夜视频在线观看| 亚洲免费三区一区二区| 欧美一区二区人人喊爽| 成人三级在线视频| 亚洲一二三区在线观看| 精品国产在天天线2019| 不卡的av网站| 日本sm残虐另类| 欧美国产精品一区| 欧美午夜免费电影| 国产一区二区三区日韩| 亚洲人成网站精品片在线观看 | av不卡免费电影| 亚洲午夜免费电影| 精品久久久久久久一区二区蜜臀| 成人av午夜电影| 午夜a成v人精品| 亚洲国产精品黑人久久久| 欧美日韩一区中文字幕| 国产伦精品一区二区三区在线观看| 亚洲视频综合在线| 欧美大片在线观看一区| 色国产精品一区在线观看| 裸体健美xxxx欧美裸体表演| 国产精品国产三级国产aⅴ无密码| 欧美精品久久天天躁| 岛国精品在线观看| 免费一级片91| 亚洲精品免费播放| 久久在线观看免费| 欧美三级在线看| 不卡视频在线看| 美女任你摸久久 | 亚洲在线一区二区三区| 337p日本欧洲亚洲大胆精品| 在线观看91视频| 国产精品996| 日本不卡在线视频| 麻豆精品精品国产自在97香蕉| 国产成人h网站| 日韩国产在线观看一区| 日韩伦理电影网| 精品日本一线二线三线不卡| 欧美三级资源在线| av动漫一区二区| 国产综合久久久久久鬼色| 亚洲h精品动漫在线观看| 国产精品久久久久aaaa樱花| 久久综合一区二区| 宅男噜噜噜66一区二区66| 色狠狠色噜噜噜综合网| 成人综合在线视频| 激情欧美一区二区三区在线观看| 一个色综合网站| 国产精品网站一区| 日韩美女天天操| 欧美一区二区福利视频| 欧美三级三级三级| 一本色道综合亚洲| 成人av资源在线观看| 国产精品一品二品| 开心九九激情九九欧美日韩精美视频电影 | 亚洲欧美日韩在线| 国产午夜久久久久| 欧美精品一区二区三区在线| 日韩一二三四区| 69av一区二区三区| 欧美视频中文字幕| 在线视频亚洲一区| 一本大道av伊人久久综合| 成人黄色网址在线观看| 国产精品一区二区男女羞羞无遮挡 | 欧美福利一区二区| 欧美午夜在线一二页| 在线视频欧美精品| 日本电影亚洲天堂一区| 91论坛在线播放| 91一区一区三区| 91浏览器入口在线观看| 91在线观看视频| 99久久精品国产一区| 97精品电影院| 91麻豆精品秘密| 91色视频在线| 91久久精品一区二区二区| 日本伦理一区二区| www.成人在线| 91欧美一区二区| 日本久久精品电影| 欧美三级日韩三级| 欧美剧情片在线观看| 欧美一区二区三区四区五区| 91精品国产福利| 欧美一级夜夜爽| 精品粉嫩超白一线天av| 久久中文字幕电影| 国产色婷婷亚洲99精品小说| 亚洲国产成人自拍| 亚洲欧洲三级电影| 亚洲情趣在线观看| 亚洲国产欧美在线人成| 图片区小说区区亚洲影院| 婷婷国产在线综合| 亚洲一区二区四区蜜桃| 中文字幕av一区二区三区免费看 | 亚洲国产成人午夜在线一区| 国产精品女同互慰在线看| 国产精品短视频| 亚洲伦在线观看| 午夜精品一区二区三区电影天堂| 日韩电影免费在线看| 久久91精品久久久久久秒播| 国产成人av电影免费在线观看| 成人福利视频在线看| 欧美影院精品一区| 日韩欧美国产wwwww| 国产午夜精品久久久久久免费视| 综合av第一页| 天天综合色天天| 激情综合色播五月| 成人黄色av网站在线| 精品视频一区二区三区免费| 日韩女优制服丝袜电影| 国产精品久久久久久久久免费丝袜| 亚洲美女在线国产| 免费观看在线色综合| 成人免费黄色在线| 欧美在线free| 精品国产乱码久久久久久老虎| 国产精品免费aⅴ片在线观看| 亚洲一区二区在线免费看| 久久精品99国产国产精| 不卡av在线免费观看| 欧美精品在线视频| 欧美激情一区二区三区在线| 亚洲一二三四在线观看| 国产乱码字幕精品高清av| 在线亚洲高清视频| 精品久久久网站| 亚洲激情图片一区| 国产综合色在线视频区| 日本高清不卡视频| 亚洲精品一线二线三线| 夜夜揉揉日日人人青青一国产精品| 美女视频黄免费的久久 | 久久女同性恋中文字幕| 亚洲靠逼com| 精品一区二区免费视频| 91久久国产最好的精华液| 欧美精品一区二区久久久 | 中文字幕亚洲欧美在线不卡| 视频一区二区不卡| 成人午夜大片免费观看| 欧美日本在线观看| 国产精品免费aⅴ片在线观看| 丝袜a∨在线一区二区三区不卡| 国产jizzjizz一区二区| 在线不卡的av| 亚洲日本成人在线观看| 国产一区二区成人久久免费影院| 欧美视频在线一区二区三区| 国产欧美综合色| 日韩黄色小视频| 一本色道**综合亚洲精品蜜桃冫| 精品免费视频一区二区| 亚洲第一狼人社区| 国产传媒久久文化传媒| 日韩一级成人av| 亚洲国产综合色| 99精品国产视频| 久久精品视频一区二区三区| 无码av免费一区二区三区试看| 91丨九色porny丨蝌蚪| 日韩黄色免费网站| 中文字幕一区二区三区乱码在线| 免费一级片91| 欧美中文字幕久久| 国产精品国产三级国产aⅴ无密码| 精品一区二区三区在线播放| 欧美日韩色综合| 亚洲品质自拍视频网站| 春色校园综合激情亚洲|