home *** CD-ROM | disk | FTP | other *** search
/ The Best of Windows 95.com 1996 September / WIN95_09964.iso / sound / mpw32-5s.zip / IBITSTR.H < prev    next >
C/C++ Source or Header  |  1996-07-25  |  3KB  |  84 lines

  1. /*
  2.  *  @(#) ibitstream.h 1.5, last edit: 6/15/94 16:55:34
  3.  *  @(#) Copyright (C) 1993, 1994 Tobias Bading (bading@cs.tu-berlin.de)
  4.  *  @(#) Berlin University of Technology
  5.  *
  6.  *  This program is free software; you can redistribute it and/or modify
  7.  *  it under the terms of the GNU General Public License as published by
  8.  *  the Free Software Foundation; either version 2 of the License, or
  9.  *  (at your option) any later version.
  10.  *
  11.  *  This program is distributed in the hope that it will be useful,
  12.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  *  GNU General Public License for more details.
  15.  *
  16.  *  You should have received a copy of the GNU General Public License
  17.  *  along with this program; if not, write to the Free Software
  18.  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19.  */
  20.  
  21. #ifndef BITSTREAM_H
  22. #define BITSTREAM_H
  23.  
  24. #define STRICT
  25.  
  26. #include "all.h"
  27. #include "l3type.h"
  28. #include <wtypes.h>
  29.  
  30. const uint32 bufferintsize = 433;
  31.     // max. 1730 bytes per frame: 144 * 384kbit/s / 32000 Hz + 2 Bytes CRC
  32.  
  33.  
  34. // Class to extract bitstrings from files:
  35. class Ibitstream
  36. {
  37. //  int        fd;
  38.   HWND hWnd;
  39.   HANDLE FH;
  40.   SECURITY_ATTRIBUTES security;
  41.   uint32    buffer[bufferintsize];
  42.   uint32    framesize;        // number of valid bytes in buffer
  43.   uint32    *wordpointer;        // position of next unsigned int for get_bits()
  44.   uint32    bitindex;        // number (0-31, from MSB to LSB) of next bit for get_bits()
  45.  
  46.  
  47. public:
  48.  
  49.         Ibitstream (const char *filename, HWND hWnd0);
  50.         ~Ibitstream (void);
  51.  
  52.   BOOL        get_header (uint32 *);
  53.         // get next 32 bits from bitstream in an unsigned int,
  54.         // returned value False => end of stream
  55.   BOOL        read_frame (uint32 bytesize);
  56.         // fill buffer with data from bitstream, returned value False => end of stream
  57.   uint32    get_bits (uint32 number_of_bits);
  58.         // read bits (1 <= number_of_bits <= 16) from buffer into the lower bits
  59.         // of an unsigned int. The LSB contains the latest read bit of the stream.
  60.  
  61.  
  62.   // Layer 3 routines
  63.   BOOL   get_side_info(uint32 channels, III_side_info_t *side_info);
  64.  
  65.  
  66.   // Stream searching routines (Jeff Tsay)
  67.  
  68.   DWORD  file_size();
  69.         // Returns the size, in bytes, of the input file.
  70.  
  71.   DWORD  seek(int32 frames, int32 frame_size);
  72.         // Seeks frames for 32 kHz and 48 kHz (non-padded) files
  73.  
  74.   DWORD  seek_pad(int32 frames, int32 frame_size);
  75.         // Seeks frames for 44.1 kHz (padded) files
  76.  
  77.   int32 *offset;         // offset from predicted frame location
  78.   int32 current_frame;
  79.   int32 last_frame_number;
  80.  
  81. };
  82.  
  83. #endif
  84.