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

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

?? mp3dec.c

?? 基于TI的DSP處理器TMS320VC5402的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一区二区三区免费野_久草精品视频
国产精品久久久久永久免费观看| 国产麻豆欧美日韩一区| 亚洲欧美日韩在线| 国产精品久久影院| 国产清纯白嫩初高生在线观看91| 26uuu国产一区二区三区| 欧美精品一区二区三区高清aⅴ| 欧美一区二区三区男人的天堂| 欧美另类z0zxhd电影| 欧美人xxxx| 日韩欧美激情一区| 精品国产不卡一区二区三区| 久久久久国产精品厨房| 久久综合成人精品亚洲另类欧美 | 精品写真视频在线观看| 麻豆成人综合网| 国产乱码精品一区二区三区忘忧草 | 亚洲女同一区二区| 亚洲久草在线视频| 五月天欧美精品| 免费一级片91| 国产福利一区二区| 不卡高清视频专区| 欧美在线观看视频一区二区三区| 制服丝袜一区二区三区| 精品捆绑美女sm三区| 欧美国产精品一区| 怡红院av一区二区三区| 肉肉av福利一精品导航| 国产在线精品一区二区三区不卡| 成人免费va视频| 欧美视频完全免费看| 日韩色在线观看| 中文字幕av一区 二区| 依依成人精品视频| 看片网站欧美日韩| 国产成人av一区| 色欧美88888久久久久久影院| 欧美精品久久久久久久久老牛影院| 精品国产乱码久久久久久夜甘婷婷 | 欧美中文字幕不卡| 欧美成人高清电影在线| 国产精品美女久久福利网站| 午夜伦欧美伦电影理论片| 国产在线精品免费av| 91美女片黄在线观看| 日韩一级免费观看| 中文字幕不卡在线观看| 亚洲一区二区美女| 国产精品99久| 欧美高清精品3d| 国产精品国产三级国产普通话三级 | 国产.欧美.日韩| 欧美日韩免费一区二区三区| 久久亚洲欧美国产精品乐播| 亚洲一区二区三区影院| 国产精品综合在线视频| 欧美日韩综合在线免费观看| 欧美极品另类videosde| 日产精品久久久久久久性色| 成人黄色免费短视频| 欧美一级二级三级蜜桃| 亚洲精品视频免费看| 国产精品一线二线三线| 91精品国产综合久久精品麻豆| 中文字幕精品—区二区四季| 午夜av区久久| 99riav一区二区三区| 久久久久国产精品人| 日韩黄色在线观看| 色乱码一区二区三区88| 中文字幕欧美国产| 老司机精品视频线观看86| 欧美色视频一区| 综合久久久久久| 成人小视频在线观看| 2023国产精品| 麻豆91在线观看| 在线成人av影院| 亚洲另类春色国产| 99久久精品一区二区| 久久久久久久久久久99999| 日韩精品亚洲专区| 欧美性猛交xxxxxxxx| 亚洲人成亚洲人成在线观看图片| 国产精品 欧美精品| 91精品国产欧美一区二区| 一区二区三区四区国产精品| 99精品视频在线观看| 国产人久久人人人人爽| 国产成人在线色| 久久久久久夜精品精品免费| 精品一区二区av| 精品国产乱码久久久久久1区2区| 青青草国产精品97视觉盛宴| 3751色影院一区二区三区| 日韩精品一二三| 日韩欧美亚洲国产另类| 久久国内精品自在自线400部| 欧美岛国在线观看| 九九**精品视频免费播放| 欧美一卡2卡3卡4卡| 麻豆成人在线观看| 亚洲精品在线观看视频| 国产在线精品一区在线观看麻豆| 精品国产乱码久久久久久久| 精品一区二区三区在线观看| 久久久久国产精品麻豆ai换脸 | 麻豆一区二区99久久久久| 欧美日韩亚洲国产综合| 亚洲电影在线播放| 欧美久久久久中文字幕| 日韩电影在线一区| 2021久久国产精品不只是精品| 国产在线精品一区二区不卡了| 日本一区二区高清| 色综合久久综合中文综合网| 一区二区免费看| 欧美欧美欧美欧美首页| 精品一区二区三区欧美| 中文字幕av一区二区三区免费看| 99re6这里只有精品视频在线观看| 一区二区三区中文字幕电影| 欧美精品久久久久久久多人混战| 久久精品av麻豆的观看方式| 欧美极品美女视频| 91福利视频久久久久| 日韩av电影免费观看高清完整版 | 日韩精品电影一区亚洲| 日韩欧美123| 成人性生交大合| 亚洲一区二区在线播放相泽| 日韩欧美久久久| 从欧美一区二区三区| 亚洲免费观看在线观看| 欧美乱熟臀69xxxxxx| 国产在线乱码一区二区三区| 亚洲欧美另类综合偷拍| 在线播放亚洲一区| 国产精品一级片在线观看| 亚洲免费视频成人| 欧美电影免费观看高清完整版| 成人妖精视频yjsp地址| 亚洲va欧美va人人爽| 久久众筹精品私拍模特| 在线亚洲一区观看| 精品一区中文字幕| 亚洲女同一区二区| 精品成人a区在线观看| 91小视频免费看| 久久国产尿小便嘘嘘| 日韩理论电影院| 欧美va亚洲va国产综合| 色综合视频在线观看| 久久精品国产99| 亚洲永久精品大片| 久久美女艺术照精彩视频福利播放| 色哟哟精品一区| 国产一区二三区| 亚瑟在线精品视频| 国产欧美日韩视频在线观看| 69堂亚洲精品首页| 不卡av电影在线播放| 精品一区二区精品| 亚洲午夜久久久久久久久电影网| 久久久久久久精| 欧美精品1区2区3区| 丰满亚洲少妇av| 免费观看30秒视频久久| 亚洲美女一区二区三区| 国产欧美日韩不卡| 欧美肥妇free| 日本乱人伦aⅴ精品| 国产乱码字幕精品高清av| 日韩不卡免费视频| 洋洋成人永久网站入口| 国产精品久久综合| 亚洲精品一区二区三区影院| 在线播放欧美女士性生活| 91色婷婷久久久久合中文| 国产91在线看| 精品一区二区影视| 欧美aaa在线| 天天影视网天天综合色在线播放| 亚洲免费在线观看视频| 日本一区二区成人在线| 久久久精品一品道一区| 日韩精品一区二区三区中文精品| 欧美二区在线观看| 欧美中文字幕亚洲一区二区va在线| 不卡的av在线| 成+人+亚洲+综合天堂| 丁香六月久久综合狠狠色| 久久精品国产999大香线蕉| 男男视频亚洲欧美| 日产精品久久久久久久性色| 婷婷六月综合网| 午夜一区二区三区视频| 一区二区三区视频在线观看| 一区二区在线看|