⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 util.h

📁 This code is based on mpeg_play, available from: http://bmrc.berkeley.edu/frame/research/mpeg/
💻 H
📖 第 1 页 / 共 2 页
字号:
/* * Copyright (c) 1995 The Regents of the University of California. * All rights reserved. *  * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose, without fee, and without written agreement is * hereby granted, provided that the above copyright notice and the following * two paragraphs appear in all copies of this software. *  * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *  * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. *//* * Portions of this software Copyright (c) 1995 Brown University. * All rights reserved. *  * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose, without fee, and without written agreement * is hereby granted, provided that the above copyright notice and the * following two paragraphs appear in all copies of this software. *  * IN NO EVENT SHALL BROWN UNIVERSITY BE LIABLE TO ANY PARTY FOR * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF BROWN * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *  * BROWN UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" * BASIS, AND BROWN UNIVERSITY HAS NO OBLIGATION TO PROVIDE MAINTENANCE, * SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. *//*   Changes to make the code reentrant:     deglobalized: curBits, curVidStream     deglobalized: bitOffset, bitLength, bitBuffer in vid_stream, not used       here   Additional changes:   -lsh@cs.brown.edu (Loring Holden) *//* Status codes for bit stream i/o operations. */#include "MPEG.h"#define NO_VID_STREAM (-1)#define STREAM_UNDERFLOW (-2)#define OK 1/* Size increment of extension data buffers. */#define EXT_BUF_SIZE 1024/* External declarations for bitstream i/o operations. */extern unsigned int bitMask[];extern unsigned int nBitMask[];extern unsigned int rBitMask[];extern unsigned int bitTest[];/* Macro for updating bit counter if analysis tool is on. */#ifdef ANALYSIS#define UPDATE_COUNT(numbits) bitCount += numbits#else#define UPDATE_COUNT(numbits)#endif#ifdef NO_SANITY_CHECKS#define get_bits1(result)                                                 \{                                                                         \  UPDATE_COUNT(1);                                                        \  result = ((vid_stream->curBits & 0x80000000) != 0);                     \  vid_stream->curBits <<= 1;                                              \  vid_stream->bit_offset++;                                               \                                                                          \  if (vid_stream->bit_offset & 0x20) {                                    \    vid_stream->bit_offset = 0;                                           \    vid_stream->buffer++;                                                 \    vid_stream->curBits = *vid_stream->buffer;                            \    vid_stream->buf_length--;                                             \  }                                                                       \}#define get_bits2(result)                                                 \{                                                                         \  UPDATE_COUNT(2);                                                        \  vid_stream->bit_offset += 2;                                            \                                                                          \  if (vid_stream->bit_offset & 0x20) {                                    \    vid_stream->bit_offset -= 32;                                         \    vid_stream->buffer++;                                                 \    vid_stream->buf_length--;                                             \    if (vid_stream->bit_offset) {                                         \      vid_stream->curBits |=                                              \	 (*vid_stream->buffer >> (2 - vid_stream->bit_offset));           \    }                                                                     \    result = ((vid_stream->curBits & 0xc0000000) >> 30);                  \    vid_stream->curBits = *vid_stream->buffer << vid_stream->bit_offset;  \  }                                                                       \                                                                          \  result = ((vid_stream->curBits & 0xc0000000) >> 30);                    \  vid_stream->curBits <<= 2;                                              \}#define get_bitsX(num, mask, shift,  result)                              \{                                                                         \  UPDATE_COUNT(num);                                                      \  vid_stream->bit_offset += num;                                          \                                                                          \  if (vid_stream->bit_offset & 0x20) {                                    \    vid_stream->bit_offset -= 32;                                         \    vid_stream->buffer++;                                                 \    vid_stream->buf_length--;                                             \    if (vid_stream->bit_offset) {                                         \      vid_stream->curBits |= (*vid_stream->buffer >>                      \      (num - vid_stream->bit_offset));                                    \    }                                                                     \    result = ((vid_stream->curBits & mask) >> shift);                     \    vid_stream->curBits = *vid_stream->buffer << vid_stream->bit_offset;  \  }                                                                       \  else {                                                                  \    result = ((vid_stream->curBits & mask) >> shift);                     \    vid_stream->curBits <<= num;                                          \  }                                                                       \}#else#define get_bits1(result)                                                 \{                                                                         \  /* Check for underflow. */                                              \                                                                          \  if (vid_stream->buf_length < 2) {                                       \    correct_underflow(vid_stream);                                        \  }                                                                       \  UPDATE_COUNT(1);                                                        \  result = ((vid_stream->curBits & 0x80000000) != 0);                     \  vid_stream->curBits <<= 1;                                              \  vid_stream->bit_offset++;                                               \                                                                          \  if (vid_stream->bit_offset & 0x20) {                                    \    vid_stream->bit_offset = 0;                                           \    vid_stream->buffer++;                                                 \    vid_stream->curBits = *vid_stream->buffer;                            \    vid_stream->buf_length--;                                             \  }                                                                       \}#define get_bits2(result)                                                 \{                                                                         \  /* Check for underflow. */                                              \                                                                          \  if (vid_stream->buf_length < 2) {                                       \    correct_underflow(vid_stream);                                        \  }                                                                       \  UPDATE_COUNT(2);                                                        \  vid_stream->bit_offset += 2;                                            \                                                                          \  if (vid_stream->bit_offset & 0x20) {                                    \    vid_stream->bit_offset -= 32;                                         \    vid_stream->buffer++;                                                 \    vid_stream->buf_length--;                                             \    if (vid_stream->bit_offset) {                                         \      vid_stream->curBits |= (*vid_stream->buffer >>                      \      (2 - vid_stream->bit_offset));                                      \    }                                                                     \    result = ((vid_stream->curBits & 0xc0000000) >> 30);                  \    vid_stream->curBits = *vid_stream->buffer << vid_stream->bit_offset;  \  }                                                                       \                                                                          \  result = ((vid_stream->curBits & 0xc0000000) >> 30);                    \  vid_stream->curBits <<= 2;                                              \}#define get_bitsX(num, mask, shift,  result)                              \{                                                                         \  /* Check for underflow. */                                              \                                                                          \  if (vid_stream->buf_length < 2) {                                       \    correct_underflow(vid_stream);                                        \  }                                                                       \  UPDATE_COUNT(num);                                                      \  vid_stream->bit_offset += num;                                          \                                                                          \  if (vid_stream->bit_offset & 0x20) {                                    \    vid_stream->bit_offset -= 32;                                         \    vid_stream->buffer++;                                                 \    vid_stream->buf_length--;                                             \    if (vid_stream->bit_offset) {                                         \      vid_stream->curBits |= (*vid_stream->buffer >>                      \

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -