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

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

?? bitstream.c

?? mp3文件格式與wav文件格式的音頻文件轉換工具
?? C
字號:
#include <string.h>#include <ctype.h>#include <stdlib.h>#include <malloc.h>#include "types.h"#include "error.h"#include "bitstream.h"/*******************************************************************************  bit_stream.c package*  Author:  Jean-Georges Fritsch, C-Cube Microsystems******************************************************************************//********************************************************************  This package provides functions to write (exclusive or read)  information from (exclusive or to) the bit stream.  If the bit stream is opened in read mode only the get functions are  available. If the bit stream is opened in write mode only the put  functions are available.********************************************************************//*open_bit_stream_w(); open the device to write the bit stream into it    *//*open_bit_stream_r(); open the device to read the bit stream from it     *//*close_bit_stream();  close the device containing the bit stream         *//*alloc_buffer();      open and initialize the buffer;                    *//*desalloc_buffer();   empty and close the buffer                         *//*back_track_buffer();     goes back N bits in the buffer                 *//*unsigned int get1bit();  read 1 bit from the bit stream                 *//*unsigned long getbits(); read N bits from the bit stream                *//*unsigned long byte_ali_getbits();   read the next byte aligned N bits from*//*                                    the bit stream                        *//*unsigned long look_ahead(); grep the next N bits in the bit stream without*//*                            changing the buffer pointer                   *//*put1bit(); write 1 bit from the bit stream  *//*put1bit(); write 1 bit from the bit stream  *//*putbits(); write N bits from the bit stream *//*byte_ali_putbits(); write byte aligned the next N bits into the bit stream*//*unsigned long sstell(); return the current bit stream length (in bits)    *//*int end_bs(); return 1 if the end of bit stream reached otherwise 0       *//*int seek_sync(); return 1 if a sync word was found in the bit stream      *//*                 otherwise returns 0                                      *//* refill the buffer from the input device when the buffer becomes empty    */int refill_buffer(bs)bitstream_t *bs;   /* bit stream structure */{   register int i=bs->buf_size-2-bs->buf_byte_idx;   register unsigned long n=1;   register int index=0;   char val[2];   while ((i>=0) && (!bs->eob)) {      if (bs->format == BINARY)         n = fread(&bs->buf[i--], sizeof(unsigned char), 1, bs->pt);      else {         while((index < 2) && n) {            n = fread(&val[index], sizeof(char), 1, bs->pt);            switch (val[index]) {                  case 0x30:                  case 0x31:                  case 0x32:                  case 0x33:                  case 0x34:                  case 0x35:                  case 0x36:                  case 0x37:                  case 0x38:                  case 0x39:                  case 0x41:                  case 0x42:                  case 0x43:                  case 0x44:                  case 0x45:                  case 0x46:                  index++;                  break;                  default: break;            }         }         if (val[0] <= 0x39)   bs->buf[i] = (val[0] - 0x30) << 4;                 else  bs->buf[i] = (val[0] - 0x37) << 4;         if (val[1] <= 0x39)   bs->buf[i--] |= (val[1] - 0x30);                 else  bs->buf[i--] |= (val[1] - 0x37);         index = 0;      }      if (!n) {         bs->eob= i+1;      }    }   return 0;}/* empty the buffer to the output device when the buffer becomes full */void empty_buffer(bs, minimum)bitstream_t *bs;   /* bit stream structure */int minimum;            /* end of the buffer to empty */{   register int i;//#if BS_FORMAT == BINARY   for (i=bs->buf_size-1;i>=minimum;i--)      fwrite(&bs->buf[i], sizeof(unsigned char), 1, bs->pt);//#else//   for (i=bs->buf_size-1;i>=minimum;i--) {//       char val[2];//       val[0] = he[((bs->buf[i] >> 4) & 0x0F)];//       val[1] = he[(bs->buf[i] & 0x0F)];//       fwrite(val, sizeof(char), 2, bs->pt);//   }//#endiffflush(bs->pt); /* NEW SS to assist in debugging*/   for (i=minimum-1; i>=0; i--)       bs->buf[bs->buf_size - minimum + i] = bs->buf[i];   bs->buf_byte_idx = bs->buf_size -1 - minimum;   bs->buf_bit_idx = 8;}/* open the device to write the bit stream into it */void open_bit_stream_w(bs, bs_filenam, size)bitstream_t *bs;   /* bit stream structure */char *bs_filenam;       /* name of the bit stream file */int size;               /* size of the buffer */{   if ((bs->pt = fopen(bs_filenam, "wb")) == NULL) {      printf("Could not create \"%s\".\n", bs_filenam);      exit(1);   }   alloc_buffer(bs, size);   bs->buf_byte_idx = size-1;   bs->buf_bit_idx=8;   bs->totbit=0;   bs->mode = WRITE_MODE;   bs->eob = FALSE;   bs->eobs = FALSE;}/* open the device to read the bit stream from it */void open_bit_stream_r(bs, bs_filenam, size)bitstream_t *bs;   /* bit stream structure */char *bs_filenam;       /* name of the bit stream file */int size;               /* size of the buffer */{   register unsigned long n;   register unsigned char flag = 1;   unsigned char val;   if ((bs->pt = fopen(bs_filenam, "rb")) == NULL) {      printf("Could not find \"%s\".\n", bs_filenam);      exit(1);   }   do {     n = fread(&val, sizeof(unsigned char), 1, bs->pt);     switch (val) {      case 0x30:      case 0x31:      case 0x32:      case 0x33:      case 0x34:      case 0x35:      case 0x36:      case 0x37:      case 0x38:      case 0x39:      case 0x41:      case 0x42:      case 0x43:      case 0x44:      case 0x45:      case 0x46:      case 0xa:  /* \n */      case 0xd:  /* cr */      case 0x1a:  /* sub */          break;      default: /* detection of an binary character */          flag--;          break;     }   } while (flag & n);   if (flag) {      printf ("the bit stream file %s is an ASCII file\n", bs_filenam);      bs->format = ASCII;   }   else {      bs->format = BINARY;      printf ("the bit stream file %s is a BINARY file\n", bs_filenam);   }   fclose(bs->pt);   if ((bs->pt = fopen(bs_filenam, "rb")) == NULL) {      printf("Could not find \"%s\".\n", bs_filenam);      exit(1);   }   alloc_buffer(bs, size);   bs->buf_byte_idx=0;   bs->buf_bit_idx=0;   bs->totbit=0;   bs->mode = READ_MODE;   bs->eob = FALSE;   bs->eobs = FALSE;}/*close the device containing the bit stream after a read process*/void close_bit_stream_r(bs)bitstream_t *bs;   /* bit stream structure */{   fclose(bs->pt);   desalloc_buffer(bs);}/*close the device containing the bit stream after a write process*/void close_bit_stream_w(bs)bitstream_t *bs;   /* bit stream structure */{   empty_buffer(bs, bs->buf_byte_idx);   fclose(bs->pt);   desalloc_buffer(bs);}/*open and initialize the buffer; */void alloc_buffer(bs, size)bitstream_t *bs;   /* bit stream structure */int size;{   bs->buf = (unsigned char *)malloc(size*sizeof(unsigned char));   bs->buf_size = size;}/*empty and close the buffer */void desalloc_buffer(bs)bitstream_t *bs;   /* bit stream structure */{   free(bs->buf);}int putmask[9]={0x0, 0x1, 0x3, 0x7, 0xf, 0x1f, 0x3f, 0x7f, 0xff};int clearmask[9]={0xff, 0xfe, 0xfc, 0xf8, 0xf0, 0xe0, 0xc0, 0x80, 0x0};void back_track_buffer(bs, N) /* goes back N bits in the buffer */bitstream_t *bs;   /* bit stream structure */int N;{   int tmp = N - (N/8)*8;   register int i;   bs->totbit -= N;   for (i=bs->buf_byte_idx;i< bs->buf_byte_idx+N/8-1;i++) bs->buf[i] = 0;   bs->buf_byte_idx += N/8;   if ( (tmp + bs->buf_bit_idx) <= 8) {      bs->buf_bit_idx += tmp;   }   else {      bs->buf_byte_idx ++;      bs->buf_bit_idx += (tmp - 8);   }   bs->buf[bs->buf_byte_idx] &= clearmask[bs->buf_bit_idx];}int mask[8]={0x1, 0x2, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80};/*read 1 bit from the bit stream */unsigned int get1bit(bs)bitstream_t *bs;   /* bit stream structure */{   unsigned int bit;   register int i;   bs->totbit++;   if (!bs->buf_bit_idx) {        bs->buf_bit_idx = 8;        bs->buf_byte_idx--;        if ((bs->buf_byte_idx < MINIMUM) || (bs->buf_byte_idx < bs->eob)) {             if (bs->eob)                bs->eobs = TRUE;             else {                for (i=bs->buf_byte_idx; i>=0;i--)                  bs->buf[bs->buf_size-1-bs->buf_byte_idx+i] = bs->buf[i];                refill_buffer(bs);                bs->buf_byte_idx = bs->buf_size-1;             }        }   }   bit = bs->buf[bs->buf_byte_idx]&mask[bs->buf_bit_idx-1];   bit = bit >> (bs->buf_bit_idx-1);   bs->buf_bit_idx--;   return(bit);}/*write 1 bit from the bit stream */void put1bit(bs, bit)bitstream_t *bs;   /* bit stream structure */int bit;                /* bit to write into the buffer */{   bs->totbit++;   bs->buf[bs->buf_byte_idx] |= (bit&0x1) << (bs->buf_bit_idx-1);   bs->buf_bit_idx--;   if (!bs->buf_bit_idx) {       bs->buf_bit_idx = 8;       bs->buf_byte_idx--;       if (bs->buf_byte_idx < 0)          empty_buffer(bs, MINIMUM);       bs->buf[bs->buf_byte_idx] = 0;   }}/*look ahead for the next N bits from the bit stream */unsigned long look_ahead(bs, N)bitstream_t *bs;   /* bit stream structure */int N;                  /* number of bits to read from the bit stream */{ unsigned long val=0; register int j = N; register int k, tmp; register int bit_idx = bs->buf_bit_idx; register int byte_idx = bs->buf_byte_idx; if (N > MAX_LENGTH)    printf("Cannot read or write more than %d bits at a time.\n", MAX_LENGTH); while (j > 0) {    if (!bit_idx) {        bit_idx = 8;        byte_idx--;    }    k = MIN (j, bit_idx);    tmp = bs->buf[byte_idx]&putmask[bit_idx];    tmp = tmp >> (bit_idx-k);    val |= tmp << (j-k);    bit_idx -= k;    j -= k; } return(val);}/*read N bit from the bit stream */unsigned long getbits(bs, N)bitstream_t *bs;   /* bit stream structure */int N;                  /* number of bits to read from the bit stream */{ unsigned long val=0; register int i; register int j = N; register int k, tmp; if (N > MAX_LENGTH)    printf("Cannot read or write more than %d bits at a time.\n", MAX_LENGTH); bs->totbit += N; while (j > 0) {   if (!bs->buf_bit_idx) {        bs->buf_bit_idx = 8;        bs->buf_byte_idx--;        if ((bs->buf_byte_idx < MINIMUM) || (bs->buf_byte_idx < bs->eob)) {             if (bs->eob)                bs->eobs = TRUE;             else {                for (i=bs->buf_byte_idx; i>=0;i--)                   bs->buf[bs->buf_size-1-bs->buf_byte_idx+i] = bs->buf[i];                refill_buffer(bs);                bs->buf_byte_idx = bs->buf_size-1;             }        }   }   k = MIN (j, bs->buf_bit_idx);   tmp = bs->buf[bs->buf_byte_idx]&putmask[bs->buf_bit_idx];   tmp = tmp >> (bs->buf_bit_idx-k);   val |= tmp << (j-k);   bs->buf_bit_idx -= k;   j -= k; } return(val);}/*write N bits into the bit stream */void putbits(bs, val, N)bitstream_t *bs;   /* bit stream structure */unsigned int val;       /* val to write into the buffer */int N;                  /* number of bits of val */{ register int j = N; register int k, tmp; if (N > MAX_LENGTH)    printf("Cannot read or write more than %d bits at a time.\n", MAX_LENGTH); bs->totbit += N; while (j > 0) {   k = MIN(j, bs->buf_bit_idx);   tmp = val >> (j-k);   bs->buf[bs->buf_byte_idx] |= (tmp&putmask[k]) << (bs->buf_bit_idx-k);   bs->buf_bit_idx -= k;   if (!bs->buf_bit_idx) {       bs->buf_bit_idx = 8;       bs->buf_byte_idx--;       if (bs->buf_byte_idx < 0)          empty_buffer(bs, MINIMUM);       bs->buf[bs->buf_byte_idx] = 0;   }   j -= k; }}/*write N bits byte aligned into the bit stream */void byte_ali_putbits(bs, val, N)bitstream_t *bs;   /* bit stream structure */unsigned int val;       /* val to write into the buffer */int N;                  /* number of bits of val */{ unsigned long aligning, sstell(); if (N > MAX_LENGTH)    printf("Cannot read or write more than %d bits at a time.\n", MAX_LENGTH); aligning = sstell(bs)%8; if (aligning)     putbits(bs, (unsigned int)0, (int)(8-aligning));  putbits(bs, val, N);}/*read the next bute aligned N bits from the bit stream */unsigned long byte_ali_getbits(bs, N)bitstream_t *bs;   /* bit stream structure */int N;                  /* number of bits of val */{ unsigned long aligning, sstell(); if (N > MAX_LENGTH)    printf("Cannot read or write more than %d bits at a time.\n", MAX_LENGTH); aligning = sstell(bs)%8; if (aligning)    getbits(bs, (int)(8-aligning)); return(getbits(bs, N));}/*return the current bit stream length (in bits)*/unsigned long sstell(bs)bitstream_t *bs;   /* bit stream structure */{  return(bs->totbit);}/*return the status of the bit stream*//* returns 1 if end of bit stream was reached *//* returns 0 if end of bit stream was not reached */int end_bs(bs)bitstream_t *bs;   /* bit stream structure */{  return(bs->eobs);}/*this function seeks for a byte aligned sync word in the bit stream and  places the bit stream pointer right after the sync.  This function returns 1 if the sync was found otherwise it returns 0  */int seek_sync(bs, sync, N)bitstream_t *bs;   /* bit stream structure */long sync;      /* sync word maximum 32 bits */int N;          /* sync word length */{#if defined(MACINTOSH) && !defined(__powerc) double pow();#endif unsigned long aligning, stell(); unsigned long val; long maxi = (int)pow(2.0, (float)N) - 1; aligning = sstell(bs)%ALIGNING; if (aligning)    getbits(bs, (int)(ALIGNING-aligning));  val = getbits(bs, N);  while (((val&maxi) != sync) && (!end_bs(bs))) {        val <<= ALIGNING;        val |= getbits(bs, ALIGNING);  } if (end_bs(bs)) return(0); else return(1);}#define BUFSIZE 4096static unsigned long offset,totbit=0, buf_byte_idx=0;static unsigned int buf[BUFSIZE];static unsigned int buf_bit_idx=8;unsigned long hgetbits(int N){ unsigned long val=0; register int j = N; register int k, tmp; totbit += N; while (j > 0) {   if (!buf_bit_idx) {        buf_bit_idx = 8;        buf_byte_idx++;        if (buf_byte_idx > offset) ERROR("Buffer overflow !!\n");   }   k = MIN (j, buf_bit_idx);   tmp = buf[buf_byte_idx%BUFSIZE]&putmask[buf_bit_idx];   tmp = tmp >> (buf_bit_idx-k);   val |= tmp << (j-k);   buf_bit_idx -= k;   j -= k; } return(val);}/*******************************************************************************  End of bit_stream.c package******************************************************************************/

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美国产精品劲爆| 国产网站一区二区| 99精品国产99久久久久久白柏 | 国产福利一区在线| 卡一卡二国产精品| 久久精品99国产精品| 蜜桃久久久久久久| 精品一区二区在线看| 麻豆91在线看| 国产在线观看一区二区| 国内精品伊人久久久久av影院| 老汉av免费一区二区三区| 麻豆一区二区99久久久久| 狠狠久久亚洲欧美| 成人免费毛片嘿嘿连载视频| 成人h动漫精品一区二区| 成人avav影音| 色综合天天狠狠| 欧美在线免费播放| 宅男在线国产精品| 精品国产三级电影在线观看| 国产精品美女久久久久久久| 亚洲三级久久久| 日韩激情中文字幕| 国产成人福利片| 91传媒视频在线播放| 69堂国产成人免费视频| 国产欧美日韩在线| 亚洲永久精品大片| 激情综合五月婷婷| av电影在线不卡| 日韩欧美国产系列| 自拍偷拍国产精品| 日本网站在线观看一区二区三区| 国产精品99久久久| 在线视频一区二区三| 国产精品国产三级国产有无不卡| 亚洲香肠在线观看| 懂色av一区二区三区免费看| 欧美亚洲日本一区| 国产视频一区在线播放| 午夜激情久久久| 成人18精品视频| 欧美一区二区在线视频| 亚洲欧美怡红院| 美女视频黄免费的久久 | 欧美日韩午夜影院| 久久天天做天天爱综合色| 亚洲精品视频在线看| 国产乱一区二区| 91精品国产免费| 亚洲免费观看高清完整| 国产乱人伦偷精品视频不卡| 欧美精品乱码久久久久久按摩| 国产精品污www在线观看| 秋霞电影一区二区| 欧美色精品在线视频| 国产精品美女久久久久久久| 经典三级一区二区| 在线91免费看| 亚洲一区二区高清| 91视视频在线观看入口直接观看www| 欧美xxxxxxxxx| 日韩制服丝袜先锋影音| 一本久久精品一区二区| 国产丝袜美腿一区二区三区| 国内精品在线播放| 精品少妇一区二区三区免费观看| 午夜精品一区二区三区免费视频| 91在线视频观看| 国产精品国产自产拍高清av | 精品视频一区二区不卡| 亚洲情趣在线观看| 色综合色狠狠天天综合色| 国产精品久久久久影院| 国产91露脸合集magnet| 国产精品无圣光一区二区| 国产精品1区二区.| 久久精品男人天堂av| 国产成人av一区二区三区在线观看| 欧美r级电影在线观看| 美女视频一区在线观看| 精品久久99ma| 黑人精品欧美一区二区蜜桃 | 北条麻妃国产九九精品视频| 欧美激情中文字幕| proumb性欧美在线观看| 亚洲裸体xxx| 欧美日韩一区二区在线观看| 调教+趴+乳夹+国产+精品| 欧美一区二区三区小说| 麻豆成人av在线| 国产午夜精品福利| av一本久道久久综合久久鬼色| 亚洲欧洲综合另类| 欧美疯狂做受xxxx富婆| 黑人巨大精品欧美一区| 国产精品福利av| 欧美在线一区二区三区| 日韩vs国产vs欧美| 国产亚洲综合色| 91久久精品一区二区二区| 日韩精品亚洲专区| 国产亚洲精品久| 色欧美88888久久久久久影院| 亚洲高清不卡在线| 欧美一级视频精品观看| www.亚洲人| 日韩福利视频网| 国产精品美女久久久久久久| 欧美视频一区二区| 国产99久久久国产精品潘金网站| 国产精品乱码人人做人人爱| 欧美日韩中文精品| 国产成人亚洲综合色影视| 一卡二卡三卡日韩欧美| 69久久99精品久久久久婷婷 | 亚洲激情图片qvod| 欧美一区二区播放| 99在线热播精品免费| 蜜臀久久99精品久久久画质超高清 | 91亚洲精品乱码久久久久久蜜桃| 日韩黄色在线观看| 亚洲欧美视频在线观看视频| 欧美变态tickle挠乳网站| 91久久久免费一区二区| 国产成人精品在线看| 美女视频网站黄色亚洲| 一区二区三区在线播| 中文字幕欧美国产| 久久综合五月天婷婷伊人| 欧美日韩国产精选| av在线不卡网| 丁香激情综合国产| 国产九色精品成人porny| 日本成人中文字幕| 亚洲一区二区三区爽爽爽爽爽| 欧美国产精品v| 国产午夜亚洲精品不卡 | 日本午夜精品一区二区三区电影| 中文字幕亚洲区| 国产午夜精品理论片a级大结局| 制服.丝袜.亚洲.中文.综合| 在线看国产日韩| 色女孩综合影院| 91免费版在线看| 北条麻妃一区二区三区| 成人国产精品视频| 懂色一区二区三区免费观看| 国产成人福利片| 国产成人啪午夜精品网站男同| 国内精品伊人久久久久影院对白| 奇米精品一区二区三区四区| 奇米四色…亚洲| 美女一区二区视频| 精彩视频一区二区| 精品一区二区三区免费| 国产精品一卡二卡在线观看| 国产精品一区一区| 99国产精品久| 91久久久免费一区二区| 欧美日韩国产美女| 日韩免费电影一区| 国产午夜亚洲精品午夜鲁丝片 | 欧美视频在线一区二区三区 | 欧美一区二区精品久久911| 欧美一级片在线看| 精品播放一区二区| 国产日韩欧美综合一区| 亚洲色图欧洲色图| 亚洲一二三区不卡| 蜜乳av一区二区三区| 国产精品伊人色| www.av亚洲| 色婷婷狠狠综合| 成人av电影在线| 99久久久久久99| 欧美色图一区二区三区| 欧美日韩成人综合| 在线看日本不卡| 日韩欧美国产三级电影视频| 久久夜色精品一区| 欧美一卡二卡在线| 久久久久国色av免费看影院| 水蜜桃久久夜色精品一区的特点| 99精品视频中文字幕| 国产色婷婷亚洲99精品小说| 久久99国产精品免费网站| 欧美日韩www| 亚洲一区二区黄色| 在线日韩av片| 亚洲一区二区美女| 欧美三区在线观看| 亚洲最大成人综合| 日本韩国一区二区| 一二三区精品视频| 欧美亚洲国产一卡| 亚洲成av人片在线观看| 欧美日韩视频在线一区二区| 亚洲福利视频一区二区|