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

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

?? mp3dec.c

?? 用DSP實現MP3解壓縮的源碼文件
?? C
?? 第 1 頁 / 共 4 頁
字號:
/* MPEG AUDIO LAYER 3 DECODER */
/* Bjorn Wesen 1997           */

/*#define USE_DATA */

#undef ROCKFORD

#ifndef DSP
#define DECVERBOSE
#endif

#include "mp3dec.h"

#ifdef DSPSIMUL
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#else
#ifdef DSP
#include "c3x_start.h"
#include "c3x_control.h"
#endif
#endif

#ifdef INT_MATH

mpfloat
operator+(mpfloat a, mpfloat b) {
    return mpfloat(a._val + b._val);
}

mpfloat
operator-(mpfloat a, mpfloat b) {
    return mpfloat(a._val - b._val);
}

mpfloat
operator-(mpfloat a) {
    return mpfloat(-a._val);
}

mpfloat
operator*(mpfloat a, mpfloat b) {
    return mpfloat(a._val * b._val);
}

mpfloat operator/(mpfloat a, mpfloat b) {
    return mpfloat(a._val / b._val);
}

#endif


static float Frame_sampfreqs[4] = { 44.1, 48, 32, 0 };
static int Frame_bitrates[15] = { 0, 32, 40, 48, 56, 64, 80, 96, 
				  112, 128, 160, 192, 224, 256, 320 };

/* scalefac_compress indexes into this table to find the sizes of the 
   scalefactor bitfields */

static int Frame_slen[2][16] = { { 0, 0, 0, 0, 3, 1, 1, 1,
				   2, 2, 2, 3, 3, 3, 4, 4 },
				 { 0, 1, 2, 3, 0, 1, 2, 3,
				   1, 2, 3, 1, 2, 3, 2, 3 } };

/* for each samplerate there is a special division of the 576 frequency
   lines into bands */

struct Frame_band Frame_bands[3] = {
    
    { { 0,4,8,12,16,20,24,30,36,44,52,
	62,74,90,110,134,162,196,238,288,342,418,576 },
      { 0,4,8,12,16,22,30,40,52,66,84,106,136,192 }},

    { { 0,4,8,12,16,20,24,30,36,42,50,
	60,72,88,106,128,156,190,230,276,330,384,576 },
      { 0,4,8,12,16,22,28,38,50,64,80,100,126,192 }},

    { { 0,4,8,12,16,20,24,30,36,44,54,
	66,82,102,126,156,194,240,296,364,448,550,576 },
      { 0,4,8,12,16,22,30,42,58,78,104,138,180,192 }}
};


static Bitstream Frame_bitbuf;   /* used for keeping the main data */


#ifdef DECVERBOSE

void dump_floats(mpfloat *f, int num)
{
    int i;
    printf("\n");
    for(i = 0; i < num; i++) {
	if(i && !(i % 5))
	    printf("\n");
	printf("%10f ", f[i]);
    }
    printf("\n");
}


void dump_ints(int *f, int num)
{
    int i;
    printf("\n");
    for(i = 0; i < num; i++) {
	if(i && !(i % 5))
	    printf("\n");
	printf("%8d ", f[i]);
    }
    printf("\n");
}
#endif

int frameNum = 0;
#ifdef UNIX
int
main(int argc, char **argv)
{
    FILE *fp; 
    int i = 0;
    char nameb[256];
    PCMSample samples[576*4];
    int numframes = 1024;
    Bitstream my_bs;
    Frame my_frame;

    my_bs.buffer32 = (unsigned long *)malloc(0x2000 * 4);
    
    if(argc < 2)
	exit(0);
    
    if(argc == 3)
	numframes = atoi(argv[2]);

    Frame_init();
    HuffmanTable_init();
    Granule_init();
    sprintf(nameb, "%s.mp3", argv[1]);
    Bitstream_open(&my_bs, nameb);
    sprintf(nameb, "%s.raw", argv[1]);
    fp = fopen(nameb, "wb");
    printf("Decoding...\n");
    do {
	fprintf(stderr, "\r[%6d]", i++);
	fflush(stderr);
	frameNum++;
	Frame_load(&my_frame, &my_bs, samples);
	fwrite(samples, 2, 576*4, fp);
/*    Frame_dump(&my_frame); */
    } while(!Bitstream32_fillbuffer(&my_bs) && i < numframes);
    printf("\n");
    Bitstream_close(&my_bs);
    fclose(fp);
    
    exit(0);
}

#endif

#ifdef DSP
 
#include "testmp.h"
//static unsigned char inbuffer[20000];

main()
{
    int i, jayjay;
#ifdef DSP_LOFI
    PCMSample samples[288*40];
#else
    PCMSample samples[576*4];
#endif
    int numframes = 40;
    Bitstream my_bs;
    Frame my_frame;
    static unsigned char bit_reservoir[BITSTREAM_BUFSIZE + 4];
    static unsigned char buffel[BITSTREAM_BUFSIZE + 4];

#ifdef DSPSIMUL
    FILE *output;
#else
#ifndef ROCKFORD
    init_da();
#endif
#endif

#ifdef ROCKFORD
    for(jayjay = 0; jayjay < 10;) {
#endif
    i = 0;
    Frame_init();
    Frame_bitbuf.buffer = bit_reservoir;

    HuffmanTable_init();
    Granule_init();

    Bitstream_open(&my_bs, 0);
    my_bs.buffer = buffel;
    Bitstream_fillbuffer(&my_bs);
#ifdef DSPSIMUL
    output = fopen("outfil.raw", "wb");
#endif
    do {
	frameNum++;
	Frame_load(&my_frame, &my_bs, samples + 288*i);
#ifdef DSPSIMUL
	fprintf(stderr, ".");
	fflush(stderr);
	fwrite(samples, 1, 576*4, output);
#else
	/*play_buffer((void *)(samples + 288*i));*/
#endif
	i++;
	Bitstream_fillbuffer(&my_bs);
    } while(i < numframes);
#ifdef ROCKFORD
    }
#else
    play_buffer((void *)samples);
#endif
#ifdef DSPSIMUL
    fprintf(stderr, "\n");
    fclose(output);
    exit(0);
#endif
    while(1);

}
#endif

static int Frame_bitbuf_framestart = 0;

void
Frame_init()
{
    Bitstream_open(&Frame_bitbuf, 0);
}


void
Frame_load(Frame *f, Bitstream *bs, PCMSample *samps)
{
  int ch, scfsi_band, gr, i, previous_end, alignbits,
      trash, part2_start;

  f->samples = samps;

  /* seek the sync word */
  if(!Bitstream_seek_sync(bs)) {
#ifndef DSP
    printf("Couldn't find sync.\n");
#endif
    return;
  }

  /* check that the ID is 1, describing ISO/IEC 11172-3 audio */
  if(!Bitstream32_get1(bs)) {
#ifndef DSP
    printf("Incorrect frame ID = 0!\n");
#endif
    return;
  }

  /* check that its a layer 3 frame */
  if(Bitstream32_get(bs, 2) != LAYER3) {
#ifndef DSP
      printf("Not a layer-3 frame!\n");
#endif
      return;
  }

  /* read the header */

  f->CRC_enable = !Bitstream32_get1(bs);  /* meaning of this bit is inverted */
  f->bitrate_index = Bitstream32_get(bs, 4);
  f->sampling_frequency = Bitstream32_get(bs, 2); 
  f->padding_bit = Bitstream32_get1(bs);
  (void)Bitstream32_get1(bs);  /* skip the private bit, we dont use it */
  f->mode = Bitstream32_get(bs, 2);
  f->channels = (f->mode == MODE_SINGLE_CHANNEL) ? 1 : 2;
  f->mode_extension = Bitstream32_get(bs, 2);
  f->copyright = Bitstream32_get1(bs);
  f->originality = Bitstream32_get1(bs);
  f->emphasis = Bitstream32_get(bs, 2);

  /* if this frame has a CRC, read it */
  
  if(f->CRC_enable)
    f->CRC = Bitstream32_get(bs, 16);

  /* now read the Layer-3 audio_data part of the frame */

  /* the following data constitutes the side information stream -
       - main_data_begin pointer
       - side info for both granules (scfsi)
       - side info granule 1
       - side info granule 2
  */

  /* read the starting offset of the main data */
  
  f->main_data_begin = Bitstream32_get(bs, 9);

  /* read private parts */
  
  if(f->channels == 1)
    (void)Bitstream32_get(bs, 5);   /* 5 private bits for single_channel */
  else
    (void)Bitstream32_get(bs, 3);   /* 3 private bits for other modes */

  /* read scalefactor selection information, 4 bits per channel */
  
  for(ch = 0; ch < f->channels; ch++)
    for(scfsi_band = 0; scfsi_band < 4; scfsi_band++)
      f->scfsi[ch][scfsi_band] = Bitstream32_get1(bs);
  
  /* read the side info for the channels for each granule */
  
  for(gr = 0; gr < 2; gr++)  
    for(ch = 0; ch < f->channels; ch++)
	Granule_decode_info(&f->gr[gr][ch], bs);
    
  /* calculate the size of this header in bytes */

  f->header_size = 4 + 2 * f->CRC_enable + (f->channels == 1 ? 17 : 32);

  /* calculate the size of the main_data block of this frame */

  /* the distance between two consequitive syncwords is determined from
     the formula: N = 144 * bitrate / sampling_frequency + padding */

  /* then we find the size of the main data by taking that number and
     subtracting the size of the header and padding */

  f->main_data_size = (int)(((144 * Frame_bitrates[f->bitrate_index]) /
    Frame_sampfreqs[f->sampling_frequency])) + f->padding_bit - f->header_size;

  /* extract all main data of this frame and insert it into the bitbuffer */
  /* ## TODO check if main data is bytealigned, if so, we can copy it much
     faster */
  
  for(i = f->main_data_size; i > 0; i--)
    Bitstream_putbyte(&Frame_bitbuf, Bitstream32_get(bs, 8));

/*   
  printf("Inserted %d bytes of main data into buffer.\n", f->main_data_size);
  */

  /* get the end (in bytes) of the last used main data */
  
  previous_end = Bitstream_tell(&Frame_bitbuf) / 8;  
/*
  printf("previous_end %d\n", previous_end);
  */
 
  /* align the bit buffer to a byte boundary */
  
  if((alignbits = Bitstream_tell(&Frame_bitbuf) % 8)) {
    Bitstream_get(&Frame_bitbuf, 8 - alignbits);
    previous_end++;
  }

  /* see if there is a gap between the end of the last framedata and
     the start of the new framedata, and if so, discard it. If trash 
     is negative, it means there was an error and there isn't enough
     data to decode this frame */
 
  trash = Frame_bitbuf_framestart - previous_end - f->main_data_begin;

  if(previous_end > BITSTREAM_BUFSIZE) {
    Frame_bitbuf_framestart -= BITSTREAM_BUFSIZE;
    Bitstream_rewindbytes(&Frame_bitbuf, BITSTREAM_BUFSIZE);
  }

  if(trash < 0) {
#ifndef DSP
    printf("Too little data to decode frame.\n");
#endif
    return;
  } else if(trash > 0) {
#ifndef DSP
    printf("%d bytes of trash\n", trash);
#endif
    Bitstream_get(&Frame_bitbuf, 8 * trash);
  }

  /* duplicate the end to reduce the need for modulo calcs in huffman */
  
  Frame_bitbuf.buffer[BITSTREAM_BUFSIZE] = Frame_bitbuf.buffer[0];
  Frame_bitbuf.buffer[BITSTREAM_BUFSIZE + 1] = Frame_bitbuf.buffer[1];
  Frame_bitbuf.buffer[BITSTREAM_BUFSIZE + 2] = Frame_bitbuf.buffer[2];
  Frame_bitbuf.buffer[BITSTREAM_BUFSIZE + 3] = Frame_bitbuf.buffer[3];

  /* remember the start of the next frame */

  Frame_bitbuf_framestart += f->main_data_size;

  /* the Frame_bitbuf stream is now positioned at the start of the
     main_data for this frame, and we know there is enough data to
     decode it, so start reading the granules now. */

  /* the following data constitute the main data stream -
       - scalefactors and Huffman code data granule 1
       - scalefactors and Huffman code data granule 2
       - ancillary data
  */

  /* Bands, scalefactors etc:
       The spectrum of 576 frequency lines, is divided into bands 
       differently depending on sampling frequency and block type.
       Each band has its own scalefactor, which is read below.
       Each band also has its own huffman coded energies, read further
       below.
  */

  /* read the main data stream for both granules */

  for(gr = 0; gr < 2; gr++) {
      
      /* read the main data stream for all channels in the granule */

      Granule_floatfreqs xr[2];     /* 2*576 = 1152 */
      Granule_floatfreqs lr[2];     /* 2*576 = 1152 */

      for(ch = 0; ch < f->channels; ch++) {
	  Granule_intfreqs is;  /* for storing the de-huffmanized energies */

	  part2_start = Bitstream_tell(&Frame_bitbuf);
	  
	  /* decode the scalefactors */

	  Granule_decode_scalefactors(&f->gr[gr][ch], &Frame_bitbuf,
				      ch, gr, f);
	  
	  /* now comes the Huffman coded bits */
	  PROFSTART;

	  Granule_decode_huffman(&f->gr[gr][ch], &Frame_bitbuf, 
				 part2_start, is, f);
	  PROFSTOP;
/*
	  if(frameNum == 85)
	      dump_ints(is, 576);
	      */      
	  Granule_requantize(&f->gr[gr][ch], is, xr[ch], f);

      } /* end of channel loop */

      /* we have the decoded and requantized spectrum for both channels,
	 so we can apply stereo processing */
      /* xr -> lr */

      Granule_process_stereo(&f->gr[gr][0], &f->gr[gr][1], xr, lr, f);
      
      /* now we can, for each channel, synthesize the PCM output */

      for(ch = 0; ch < f->channels; ch++) {
	  
	  /* first we have to reorder short block data */
	  /* lr -> xr */
	  Granule_reorder(&f->gr[gr][ch], lr[ch], xr[ch], f);
/*
	  if(frameNum == 10) {
	      printf("Granule %d\n", gr);
	      dump_floats(lr2[ch], 576);
	  }
	  */
	  /* now we do the alias reduction */
	  /* xr -> xr */
	  Granule_antialias(&f->gr[gr][ch], xr[ch]);
	      
	  /* apply the IMDCT transform */
	  /* xr -> xr */
	  Granule_imdct(&f->gr[gr][ch], ch, xr[ch]);
	  /* frequency inversion to compensate for the polyphase filterbank */
	  /* xr -> xr */
	  
	  Granule_freqinverse(&f->gr[gr][ch], xr[ch]);

	  /* finally generate the PCM samples from the filterbank */
/*
	  if(frameNum == 10) {
	      int z;
	      for(z = 0; z < 576; z++) {
		  if(z && !(z % 5))
		      printf("\n");
		  printf("%6d ", f->samples[gr][z][0]);
	      }
	  }
	  */
      }

#ifdef WIN32
#define FABS(x) (x > 0.0 ? x : -x)
	  /* the windows player has a nice spectrum analyser.. */
	  {
	      int z, y;
	      for(z = 0; z < 32; z++) {
		  f->spectrum[z] = 0.0f;
		  for(y = 0; y < 18; y++)
		      f->spectrum[z] +=
			  FABS(xr[0][z*18+y]) +
			  FABS(xr[1][z*18+y]);
	      }
	  }
#endif

      /* for stereo, use an optimized subband synthesis routine that
	 processes both channels at once */
      /* xr -> samples */

#ifdef DSP_LOFI
      /* do lo-fidelity processing, mono in 11khz *shiver* */
      Granule_subband_synthesis(&f->gr[gr][0], 0, xr[0],
				&f->samples[gr*144]);
#else

      if(f->channels == 2)
	  Granule_subband_synthesis2(&f->gr[gr][ch], xr[0],
				     xr[1],
				     &f->samples[gr*576*2]);
      else
	  Granule_subband_synthesis(&f->gr[gr][0], 0, xr[0],
				    &f->samples[gr*576*2]);
#endif  

  } /* end of granule loop */

}

#ifdef MAKE_DATA

void
make_data_file(const char *fname, const char *datname, mpfloat *nbrs, int len)
{
    int i;
    FILE *f = fopen(fname, "w");
    fprintf(f, "static mpfloat %s[%d] = {\n", datname, len);
    for(i = 0; i < len; i++) {
	if(i && !(i % 4))
	    fprintf(f, "\n");
	fprintf(f, "%.12g, ", nbrs[i]);
    }
    fprintf(f, "\n};\n\n");

    fclose(f);
}

void
make_data_file_2d(const char *fname,
		  const char *datname, mpfloat *nbrs, int len1, int len2)
{
    int i, j;
    FILE *f = fopen(fname, "w");
    fprintf(f, "static mpfloat %s[%d][%d] = {\n", datname, len1, len2);
    for(j = 0; j < len1; j++) {
	fprintf(f, "{\n");
	for(i = 0; i < len2; i++) {

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
一区二区在线观看不卡| 97se亚洲国产综合在线| 日本伊人色综合网| 亚洲一二三四久久| 亚洲综合激情网| 一区二区三区日韩欧美精品| 亚洲理论在线观看| 亚洲老司机在线| 一区二区三区免费| 亚洲国产精品一区二区www| 亚洲免费视频成人| 亚洲午夜久久久久久久久电影院 | 欧美一级片在线看| 69久久99精品久久久久婷婷 | 樱花影视一区二区| 亚洲一区二区视频在线观看| 亚洲午夜久久久久久久久久久| 亚洲福利视频一区二区| 日韩精品国产精品| 久久精品久久综合| 国产精品资源网| 成人福利电影精品一区二区在线观看| 成人av在线播放网址| www.亚洲免费av| 日本国产一区二区| 555夜色666亚洲国产免| 欧美一级在线免费| 久久精品一级爱片| 亚洲人成在线播放网站岛国| 亚洲一区二区三区四区中文字幕 | 国产成人在线观看免费网站| 国产盗摄女厕一区二区三区| 91丝袜美腿高跟国产极品老师| 欧美日韩精品一区二区在线播放| 日韩精品一区二区三区在线| 国产午夜精品久久久久久免费视 | 91玉足脚交白嫩脚丫在线播放| 欧美日韩一区在线| 精品国产免费一区二区三区香蕉| 亚洲国产精品v| 午夜精品一区二区三区电影天堂| 麻豆精品一区二区综合av| 成人午夜视频网站| 欧美日韩国产一级二级| 久久久久久久久97黄色工厂| 亚洲欧洲日韩在线| 婷婷成人综合网| 国产91精品久久久久久久网曝门| 一本大道av伊人久久综合| 日韩一区二区三区av| 中文字幕永久在线不卡| 日韩电影在线观看网站| va亚洲va日韩不卡在线观看| 欧美老肥妇做.爰bbww视频| 国产亚洲欧美激情| 午夜精品福利久久久| 成人国产精品免费观看动漫| 欧美一区二区在线免费观看| 亚洲视频一二区| 国产美女主播视频一区| 欧美高清hd18日本| 一区在线观看免费| 国产精品99久久久久久久vr | 国产精品人成在线观看免费| 午夜欧美2019年伦理| 成人午夜电影小说| 日韩精品中文字幕在线不卡尤物| 中文字幕欧美一区| 国产传媒欧美日韩成人| 91.com视频| 亚洲综合区在线| av在线这里只有精品| 精品国产一区二区三区久久影院| 亚洲视频电影在线| 久久91精品久久久久久秒播| 91香蕉视频黄| 精品国产一区二区三区av性色| 欧美国产综合色视频| 舔着乳尖日韩一区| 91美女蜜桃在线| 欧美一区二区精品久久911| 国产欧美日韩在线观看| 日韩av一区二区三区四区| 色8久久精品久久久久久蜜| 久久青草欧美一区二区三区| 性欧美大战久久久久久久久| 99久久久国产精品免费蜜臀| 精品国产一区二区国模嫣然| 亚洲va中文字幕| 国产宾馆实践打屁股91| 精品国产91乱码一区二区三区| 亚洲自拍与偷拍| heyzo一本久久综合| 精品毛片乱码1区2区3区| 亚洲宅男天堂在线观看无病毒| 国产精品综合网| 日韩一区二区在线观看视频| 午夜精品久久久久久久久| 91在线视频免费观看| 国产亚洲1区2区3区| 久久99精品久久久久久久久久久久 | 日韩欧美在线一区二区三区| 亚洲主播在线观看| 国精产品一区一区三区mba视频| 欧美videos大乳护士334| 天使萌一区二区三区免费观看| 97国产一区二区| 国产精品国产三级国产| 国产成人精品免费网站| 亚洲精品一线二线三线| 三级亚洲高清视频| 日韩丝袜情趣美女图片| 亚洲1区2区3区4区| 欧美在线观看视频一区二区 | 黑人精品欧美一区二区蜜桃 | 日韩欧美一二三区| 日本aⅴ精品一区二区三区 | 在线中文字幕一区二区| 亚洲美女视频在线| 色婷婷综合久久久久中文一区二区| 中文字幕在线观看一区二区| 一个色综合av| 日本国产一区二区| 亚洲国产精品久久人人爱| 色一情一伦一子一伦一区| 亚洲一区二区成人在线观看| 在线精品亚洲一区二区不卡| 一区二区三区中文字幕在线观看| 91免费视频观看| 亚洲激情图片一区| 91精品福利在线| 五月婷婷久久综合| 精品国产sm最大网站| 欧美日韩综合在线免费观看| 亚洲午夜影视影院在线观看| 欧美日韩亚州综合| 日本中文在线一区| 精品国产三级a在线观看| 国产一区二区在线观看视频| 中文字幕免费观看一区| 91女神在线视频| 亚洲国产精品一区二区www在线| 欧美一区二区在线视频| 国内成+人亚洲+欧美+综合在线| 国产情人综合久久777777| 99精品在线免费| 亚洲制服丝袜在线| 日韩女优av电影| 亚洲成av人**亚洲成av**| 国产亚洲一区二区三区四区| 国产69精品一区二区亚洲孕妇| 国产精品久久久久aaaa| 欧美在线观看18| 麻豆视频观看网址久久| 久久综合色一综合色88| 91精品91久久久中77777| 免费成人深夜小野草| 国产日韩欧美不卡| 欧美影片第一页| 精品一区二区三区免费播放| 国产女人18水真多18精品一级做| 欧美主播一区二区三区| 精品一区二区免费视频| 中文字幕制服丝袜成人av| 欧美剧情片在线观看| 国产黄色精品网站| 亚洲色图视频网| 久久精品亚洲乱码伦伦中文 | 国产不卡视频一区二区三区| 久久综合给合久久狠狠狠97色69| 色婷婷综合久久久中文一区二区| 蜜桃久久久久久| 亚洲欧美日韩国产中文在线| 日韩欧美国产综合一区| aaa欧美大片| 日韩电影在线观看电影| 在线观看日韩av先锋影音电影院| 老司机免费视频一区二区 | 奇米四色…亚洲| 最新中文字幕一区二区三区 | 欧美精品丝袜中出| 成人av电影在线观看| 九九久久精品视频| 日韩有码一区二区三区| 一区免费观看视频| 国产性色一区二区| 日韩视频中午一区| 欧美亚洲图片小说| 色哟哟一区二区三区| 国产成人av自拍| 久久精品国产澳门| 亚洲国产日韩精品| 国产精品国产成人国产三级 | 欧美人与禽zozo性伦| 99精品国产91久久久久久| 国产伦精品一区二区三区视频青涩 | 亚洲视频在线一区观看| 久久精品一区二区三区不卡牛牛| 精品国产欧美一区二区| 日韩三级.com|