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

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

?? ibitstr.cpp

?? < VC++視頻音頻開發>> 這本書的源碼
?? CPP
字號:
/* ibitstr.cpp

	Input bitstream class implementation

   Changes by Jeff Tsay:

	01/26/96 : Modified for Windows file handles.

   11/29/96 : Added syncword detection for compatibility with streams produced
   by DALET. Changed at the request of Wilfried Solbach, thanks for the
   donation in advance! However Layer I MPP files playback jerkily.

   03/09/97 : Added a routine to read layer III side info. Also not mentioned
   previously are several routines that allow seeking in a stream.

   04/14/97 : Moved the side info routine to the layer III decoder object.
   Revamped the seeking mechanism and also included better syncword detection.
   Moved the original file reading mechanisms back for better
   portability, and used John Fehr's implementations of the seeking routines
	for non-Win32 file reading. */

/*
 *  @(#) ibitstream.cc 1.8, last edit: 6/15/94 16:51:45
 *  @(#) Copyright (C) 1993, 1994 Tobias Bading (bading@cs.tu-berlin.de)
 *  @(#) Berlin University of Technology
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

/*
 *  Changes from version 1.1 to 1.2:
 *    - third argument in open syscall added
 *    - minor bug in get_header() fixed
 */
#define __WIN32__


#ifdef  __WIN32__
#include <windows.h>
#else
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
#endif   // __WIN32__

#ifndef  GUI
#include <iostream.h>
#endif   // GUI

#include "all.h"
#include "ibitstr.h"
#include "header.h"

#ifdef  DAMN_INTEL_BYTE_ORDER
#define swap_int32(int_32) (((int_32) << 24) | (((int_32) << 8) & 0x00ff0000) | \
				               (((int_32) >> 8) & 0x0000ff00) | ((int_32) >> 24))
#endif  // DAMN_INTEL_BYTE_ORDER


Ibitstream::Ibitstream(const char *filename)
{

#ifdef __WIN32__

  SECURITY_ATTRIBUTES security;
  security.nLength              = sizeof(SECURITY_ATTRIBUTES);
  security.lpSecurityDescriptor = NULL;
  security.bInheritHandle       = FALSE;

  fd = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ,
                  &security, OPEN_EXISTING, NULL, NULL);

  if (fd == INVALID_HANDLE_VALUE) {
     char bad_file_msg[256];
     lstrcpy(bad_file_msg, "Error opening file: ");

#ifdef WIN32GUI
	  MessageBox(NULL, lstrcat(bad_file_msg, filename) , "Invalid handle", MB_OK);
#else
	cerr  << "Error opening file: " << filename << endl;
#endif // WIN32GUI

     return;
  }

#else
  // copy any arguments you need, open the file, and check for error

  if ((fd = open(filename, O_RDONLY)) == -1)
  {
#ifndef GUI
  		cerr << "Error opening file: " << filename << endl;
#endif
      return;
  }

#endif // __WIN32__

  wordpointer       = buffer;
  bitindex          = 0;

  // Seeking variables
  current_frame_number = -1;

#ifdef SEEK_STOP
  last_frame_number    = -1;
#endif

  copy = false;
}

Ibitstream::Ibitstream(const Ibitstream &s0)
{

  int32 i;

  fd = s0.fd;

  for (i=0; i<bufferintsize; i++)
  	   buffer[i] = s0.buffer[i];

  framesize = s0.framesize;

  wordpointer = buffer + (s0.wordpointer - s0.buffer);

  bitindex = s0.bitindex;
  syncword = s0.syncword;
  single_ch_mode = s0.single_ch_mode;

  current_frame_number = s0.current_frame_number;

#ifdef SEEK_STOP
  last_frame_number = s0.last_frame_number;
#endif

  copy = true;
}

// Dummy constructor
Ibitstream::Ibitstream()
{

  fd = 0;

  wordpointer       = buffer;
  bitindex          = 0;

  current_frame_number = -1;

#ifdef SEEK_STOP
  last_frame_number    = -1;
#endif

  copy = false;
}

void Ibitstream::reset()
{
  
  SetFilePointer(fd, 0, NULL, FILE_BEGIN);

  wordpointer       = buffer;
  bitindex          = 0;

  current_frame_number = -1;

#ifdef SEEK_STOP
  last_frame_number    = -1;
#endif

  copy = false;
}



Ibitstream::~Ibitstream()
{
  // close the file
#ifdef __WIN32__
  if (fd && !copy) CloseHandle(fd);
#else
  if (fd && !copy) close(fd);
#endif
}

Ibitstream &Ibitstream::operator = (const Ibitstream &s0)
{
  int32 i;

  fd = s0.fd;

  for (i=0; i<bufferintsize; i++)
  	   buffer[i] = s0.buffer[i];

  framesize = s0.framesize;

  wordpointer = buffer + (s0.wordpointer - s0.buffer);

  bitindex = s0.bitindex;
  syncword = s0.syncword;
  single_ch_mode = s0.single_ch_mode;

  current_frame_number = s0.current_frame_number;

#ifdef SEEK_STOP
  last_frame_number = s0.last_frame_number;
#endif

	copy = true;

	return *this;
}

bool Ibitstream::get_header (uint32 *headerstring, enum e_syncmode syncmode)
{
  bool result, sync;

  int32 numread;

  do {

	// Read 4 bytes from the file, placing the number of bytes actually
   // read in numread
#ifdef __WIN32__
   result = (bool) ReadFile(fd, (char *) headerstring, 4,
   							    (DWORD *) &numread, NULL);
#else
	if (fd == -1) return false; // check for error opening file
	result = (bool) ((numread=read(fd, (char*) headerstring, 4)) == 4);
#endif

   if (!(result && (numread == 4)))
      return false;

#ifdef DAMN_INTEL_BYTE_ORDER
	if (syncmode == INITIAL_SYNC) {
	   sync =  ((*headerstring & 0x0000F0FF) == 0x0000F0FF);
   } else {
   	sync =  ((*headerstring & 0x000CF8FF) == syncword) &&
             (((*headerstring & 0xC0000000) == 0xC0000000) == single_ch_mode);
   }
#else
	if (syncmode == INITIAL_SYNC) {
		sync =  ((*headerstring & 0xFFF00000) == 0xFFF00000);

	} else {
   	sync =  ((*headerstring & 0xFFF80C00) == syncword) &&
             (((*headerstring & 0x000000C0) == 0x000000C0) == single_ch_mode);
   }
#endif // DAMN_INTEL_BYTE_ORDER

   if (!sync)
 	// rewind 3 bytes in the file so we can try to sync again, if
   // successful set result to true
#ifdef __WIN32__
      result = (bool) SetFilePointer(fd, -3, NULL, FILE_CURRENT);
#else
		result = (bool) (lseek(fd, -3, SEEK_CUR) != -1);
#endif // __WIN32__

  } while (!sync && result);

  if (!result)
     return false;

#ifdef DAMN_INTEL_BYTE_ORDER
  uint32 header = *headerstring;
  *headerstring = swap_int32(header);
#endif // DAMN_INTEL_BYTE_ORDER

  current_frame_number++;

#ifdef SEEK_STOP
  if (last_frame_number < current_frame_number)
	  last_frame_number = current_frame_number;
#endif

  return true;
}

bool Ibitstream::read_frame(uint32 bytesize)
{

  int32 numread;

  // read bytesize bytes from the file, placing the number of bytes
  // actually read in numread and setting result to true if
  // successful
#ifdef __WIN32__
  bool result = ReadFile(fd, buffer, bytesize, (DWORD *) &numread, NULL);
#else
  bool result = (bool) ((numread=read(fd,buffer,bytesize)) != -1);
#endif // __WIN32__


/*  if (bytesize > (bufferintsize << 2))
  {
	 cerr << "Internal error: framelength > bufferlength?!\n";
	 exit (1);
  } */

  wordpointer = buffer;
  bitindex    = 0;
  framesize   = bytesize;

#ifdef DAMN_INTEL_BYTE_ORDER
  uint32 *wordp;
  for (wordp = buffer + ((bytesize - 1) >> 2); wordp >= buffer; --wordp)
  {

#ifdef INTEL386

  // inline 386 assembly doesn't work on Borland compiler

  __asm {
      mov eax, wordp
		mov ebx, [eax]
      bswap ebx
      mov [eax], ebx
  }

#else

	 uint32 word   = *wordp;
    *wordp = swap_int32(word);

#endif // INTEL386

  } // for (wordp ...

#endif // DAMN_INTEL_BYTE_ORDER

  return((bool) (result && (numread == framesize)));
}

uint32 Ibitstream::get_bits(uint32 number_of_bits)
{
  static uint32 bitmask[18] =
  {
	 0,	// dummy
	 0x00000001, 0x00000003, 0x00000007, 0x0000000F,
	 0x0000001F, 0x0000003F, 0x0000007F, 0x000000FF,
	 0x000001FF, 0x000003FF, 0x000007FF, 0x00000FFF,
	 0x00001FFF, 0x00003FFF, 0x00007FFF, 0x0000FFFF,
    0x0001FFFF
  };
  uint32 returnvalue;
  uint32 sum = bitindex + number_of_bits;

  if (sum <= 32)
  {
	 // all bits contained in *wordpointer
	 returnvalue = (*wordpointer >> (32 - sum)) & bitmask[number_of_bits];
	 if ((bitindex += number_of_bits) == 32)
	 {
		bitindex = 0;

/*		if ((char *)++wordpointer > (char *)buffer + framesize)
		{
	cerr << "Ibitstream::get_bits(): no more bits in buffer!\n";
	exit (1);
		} */
		wordpointer++; // added by me!
	 }
	 return returnvalue;
  }

#ifdef DAMN_INTEL_BYTE_ORDER
  *((int16 *)&returnvalue + 1) = *(int16 *)wordpointer;
  wordpointer++; // Added by me!
  *(int16 *)&returnvalue = *((int16 *)wordpointer + 1);
#else
  *(int16 *)&returnvalue = *((int16 *)wordpointer + 1);
  wordpointer++; // Added by me!
  *((int16 *)&returnvalue + 1) = *(int16 *)wordpointer;
#endif // DAMN_INTEL_BYTE_ORDER

  returnvalue >>= 48 - sum;	// returnvalue >>= 16 - (number_of_bits - (32 - bitindex))
  returnvalue &= bitmask[number_of_bits];
  bitindex = sum - 32;

  return returnvalue;
}

void Ibitstream::set_syncword(uint32 syncword0)
{

#ifdef DAMN_INTEL_BYTE_ORDER
   syncword = swap_int32(syncword0 & 0xFFFFFF3F);
#else
	syncword = syncword0 & 0xFFFFFF3F;
#endif // DAMN_INTEL_BYTE_ORDER

   single_ch_mode = ((syncword0 & 0x000000C0) == 0x000000C0);
}

uint32 Ibitstream::file_size() const
// return the file size of the file
{

#ifdef __WIN32__
	return GetFileSize(fd, NULL);
#else
	// hmm. I think this should work  -- John Fehr
	off_t o_off;
	off_t len;
	o_off = lseek(fd, 0, SEEK_CUR);
	len   = lseek(fd, 0, SEEK_END);
	lseek(fd, o_off, SEEK_SET);
	return len;
#endif // __WIN32__

}

uint32 Ibitstream::file_pos() const
{
	return SetFilePointer(fd, 0, NULL, FILE_CURRENT);
}



#ifdef SEEK_STOP

bool Ibitstream::seek(int32 frame, int32 frame_size)
// set the file pointer to frame * (frame_size + 4) bytes after the
// beginning of the file and return true if successful
{
	current_frame_number = frame - 1;

#ifdef __WIN32__
	return(SetFilePointer(fd, frame * (frame_size + 4), NULL, FILE_BEGIN)
   	    != 0xFFFFFFFF);
#else

	return lseek(fd, frame * (frame_size + 4), SEEK_SET);
#endif // __WIN32__

}

bool Ibitstream::seek_pad(int32 frame, int32 base_frame_size,
                          Header *header, uint32 *offset)
{
	// base_frame_size is the frame size _without_ padding.

	Crc16 *crc = NULL;

	int32 total_frame_size = base_frame_size + 4;
	int32 diff;

	if (last_frame_number < frame) {
		diff = (last_frame_number >= 0) ?  offset[last_frame_number] : 0;

   	// set the file pointer to ((last_frame_number+1) * total_frame_size)
      // bytes after the beginning of the file
#ifdef __WIN32__
		SetFilePointer(fd, (last_frame_number + 1) * total_frame_size +
							diff, NULL, FILE_BEGIN);
#else
		lseek(fd, (last_frame_number + 1) * total_frame_size + diff, SEEK_SET);
#endif // __WIN32__

		current_frame_number = last_frame_number;

		do {
			if (!header->read_header(this, &crc)) // will increment last_frame_number
				return false;
		} while (last_frame_number < frame);

      return true;

	} else {
		diff = (frame > 0) ? offset[frame - 1] : 0;

   	// set the file pointer to (frame * total_frame_size  + diff) bytes
      // after the beginning of the file
#ifdef __WIN32__
		SetFilePointer(fd, frame * total_frame_size + diff, NULL, FILE_BEGIN);
#else
		lseek(fd, frame * total_frame_size + diff, SEEK_SET);
#endif // __WIN32__

		current_frame_number = frame - 1;

      return header->read_header(this, &crc);
	}
}

#endif // SEEK_STOP


?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品一区二区三区在线观看国产| 亚洲国产精品久久艾草纯爱 | 成人激情视频网站| 欧美中文字幕一区| 欧美经典一区二区| 久久99精品久久久久久| 欧美性色黄大片| 中文字幕在线免费不卡| 久久精品国产亚洲aⅴ| 91高清视频在线| 91老师片黄在线观看| 日韩小视频在线观看专区| 亚洲一区在线观看网站| 91在线观看美女| 欧美国产精品劲爆| 国产精品一区久久久久| 日韩一区二区电影在线| 亚洲国产综合视频在线观看| a级精品国产片在线观看| 久久女同互慰一区二区三区| 老司机免费视频一区二区| 欧美日韩一级视频| 亚洲国产综合色| 欧美日本视频在线| 午夜视频在线观看一区二区| 欧美私人免费视频| 亚洲成av人片一区二区三区| 色综合色狠狠综合色| 亚洲天天做日日做天天谢日日欢 | 在线观看三级视频欧美| 综合久久综合久久| 色婷婷久久99综合精品jk白丝 | 久久久久久久国产精品影院| 激情综合五月天| 久久在线观看免费| 成人性生交大片免费看中文网站| 久久青草欧美一区二区三区| 国产成人啪午夜精品网站男同| 欧美r级电影在线观看| 国产一区二区三区免费| 欧美韩国日本综合| 一本大道久久a久久精品综合| 亚洲精品视频观看| 欧美日韩国产首页| 久热成人在线视频| 欧美激情综合五月色丁香 | 国产激情一区二区三区| 国产精品青草久久| 在线免费不卡电影| 青青青伊人色综合久久| 精品久久久久久最新网址| 国产成人午夜高潮毛片| 亚洲欧美一区二区三区国产精品| 在线看日本不卡| 精品一二三四在线| 中文字幕日韩精品一区| 欧美日韩不卡视频| 国产电影一区在线| 亚洲精品亚洲人成人网| 日韩一区二区三区视频在线观看 | 91久久精品一区二区二区| 丝袜国产日韩另类美女| 亚洲国产精品成人综合| 欧美日韩精品一区二区三区蜜桃| 精品一区二区三区免费观看| 亚洲欧美aⅴ...| 欧美mv和日韩mv国产网站| 色综合网站在线| 国产在线国偷精品产拍免费yy| 国产精品美女久久福利网站| 欧美精品v国产精品v日韩精品| 国产精品资源网站| 午夜精品成人在线视频| 中文字幕欧美区| 欧美一区二区视频在线观看2020| 懂色av一区二区三区免费观看 | 亚洲国产成人精品视频| 久久综合色播五月| 欧美日本在线视频| 不卡av在线网| 九九热在线视频观看这里只有精品| 亚洲人成网站色在线观看| 精品国产一区二区三区忘忧草| 在线观看91精品国产入口| 国产精品一品视频| 久久99久国产精品黄毛片色诱| 亚洲欧美在线另类| 国产婷婷色一区二区三区| 日韩一区二区免费在线观看| 色综合激情久久| 成人av先锋影音| 国精品**一区二区三区在线蜜桃| 五月天婷婷综合| 亚洲激情图片qvod| 亚洲丝袜美腿综合| 国产精品人成在线观看免费| 久久久久国产精品人| 日韩精品一区二区在线观看| 欧美日韩小视频| 欧美三级日本三级少妇99| 91在线免费播放| 99国产精品久久久久久久久久 | 自拍偷在线精品自拍偷无码专区| 久久婷婷久久一区二区三区| 欧美成人免费网站| 欧美成va人片在线观看| 日韩精品中文字幕一区| 日韩一本二本av| 欧美一级一区二区| 日韩精品一区二区三区在线观看 | 免播放器亚洲一区| 裸体健美xxxx欧美裸体表演| 日本中文在线一区| 免费成人性网站| 久久电影网站中文字幕| 极品少妇一区二区| 国产成人av一区二区三区在线 | 亚洲午夜在线视频| 亚洲成在人线免费| 日韩成人免费看| 精品一区二区在线观看| 国产剧情一区在线| 成人网男人的天堂| 91影院在线免费观看| 欧美私人免费视频| 日韩三级在线免费观看| 亚洲精品在线电影| 中文字幕av一区二区三区免费看| 欧美国产综合一区二区| 亚洲精品国产无天堂网2021| 亚洲图片欧美一区| 久久爱另类一区二区小说| 国产精品一区专区| 色综合视频一区二区三区高清| 欧美三级日本三级少妇99| 91精品在线观看入口| 国产亚洲欧洲997久久综合| 国产精品久久久久7777按摩| 亚洲国产精品一区二区久久| 麻豆国产精品官网| 成人久久久精品乱码一区二区三区 | 日本美女一区二区三区视频| 国产美女视频一区| 欧美亚洲动漫另类| 精品sm在线观看| 一区二区三区四区中文字幕| 日韩激情av在线| 成人一区二区视频| 欧美色中文字幕| 国产欧美视频在线观看| 一区二区国产视频| 国产做a爰片久久毛片| 91极品美女在线| 日韩欧美中文字幕精品| 自拍视频在线观看一区二区| 日韩国产精品大片| 9l国产精品久久久久麻豆| 制服丝袜亚洲精品中文字幕| 国产日产欧美一区二区视频| 亚洲电影中文字幕在线观看| 国产成人av在线影院| 6080午夜不卡| 自拍偷拍亚洲综合| 国产成a人亚洲精品| 日韩一区二区三区在线| 一区二区三区日韩精品| 国产伦精品一区二区三区视频青涩 | 国产亚洲精品中文字幕| 日本中文一区二区三区| 色综合天天性综合| 国产欧美一区二区精品忘忧草| 日韩电影在线免费| 欧美综合一区二区三区| 国产精品视频免费| 国产最新精品精品你懂的| 91精品国产综合久久婷婷香蕉| 亚洲视频一区二区在线观看| 国产精品乡下勾搭老头1| 欧美一区二区三区爱爱| 亚洲国产日韩一级| 色综合久久综合中文综合网| 国产亚洲精品超碰| 国产一区二区三区免费看| 日韩精品中文字幕在线一区| 亚洲电影视频在线| 色嗨嗨av一区二区三区| 中文字幕一区二区在线播放| 国产不卡视频在线播放| 国产性色一区二区| 国产一区二区三区av电影| 欧美v日韩v国产v| 麻豆精品精品国产自在97香蕉| 91精品国产乱| 麻豆国产精品视频| 精品精品国产高清a毛片牛牛 | 欧美日韩不卡视频| 视频一区二区三区在线| 69精品人人人人| 日本欧美大码aⅴ在线播放| 在线成人小视频|