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

  1. /*
  2.  *  @(#) header.h 1.7, last edit: 6/15/94 16:55:33
  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 HEADER_H
  22. #define HEADER_H
  23.  
  24. #include "all.h"
  25. #include "ibitstr.h"
  26. #include "crc.h"
  27.  
  28.  
  29. enum e_mode { stereo, joint_stereo, dual_channel, single_channel  };
  30. enum e_sample_frequency { fourtyfour_point_one, fourtyeight, thirtytwo };
  31.  
  32.  
  33. // Class for extraction information from a frame header:
  34. class Header
  35. {
  36.   static const uint32    frequencies[3];
  37.   uint32        h_layer, h_protection_bit, h_bitrate_index,
  38.                 h_padding_bit, h_mode_extension;
  39.   e_mode        h_mode;
  40.   e_sample_frequency    h_sample_frequency;
  41.   uint32        h_number_of_subbands, h_intensity_stereo_bound;
  42.   BOOL        h_copyright, h_original;
  43.   Crc16        *crc;
  44.   uint16        checksum;
  45.  
  46.   uint32    nSlots;
  47.  
  48. public:
  49.             Header (void) { crc = (Crc16 *)0; }
  50.                  ~Header (void) { if (crc) delete crc; }
  51.   BOOL            read_header (Ibitstream *, Crc16 **);
  52.             // read a 32-bit header from the bitstream
  53.  
  54.   // functions to query header contents:
  55.   uint32        layer (void) { return h_layer; };
  56.   uint32        bitrate_index (void) { return h_bitrate_index; };
  57.   e_sample_frequency    sample_frequency (void) { return h_sample_frequency; };
  58.   uint32        frequency (void) { return frequencies[h_sample_frequency]; }
  59.   static uint32    frequency (e_sample_frequency rate) { return frequencies[rate]; }
  60.   e_mode        mode (void) { return h_mode; };
  61.   BOOL            checksums (void) { return (BOOL) !h_protection_bit; }
  62.   BOOL            copyright (void) { return  h_copyright; }
  63.   BOOL            original (void) { return   h_original; }
  64.  
  65.   BOOL            checksum_ok (void) { return (BOOL) (checksum == crc->checksum ()); }
  66.             // compares computed checksum with stream checksum
  67.  
  68.   // Layer 3 stuff
  69.   BOOL         padding(void) { return ( (BOOL) h_padding_bit); }
  70.   uint32       slots(void) { return (nSlots); }
  71.   int32            mode_extension(void) { return (h_mode_extension); }
  72.  
  73.   // functions which return header informations as strings:
  74.   const char *        layer_string (void);
  75.   const char *        bitrate_string (void);
  76.   const char *        sample_frequency_string (void);
  77.   const char *        mode_string (void);
  78.  
  79.   uint32        number_of_subbands (void) { return h_number_of_subbands; };
  80.             // returns the number of subbands in the current frame
  81.   uint32        intensity_stereo_bound (void) {return h_intensity_stereo_bound; };
  82.             // (Layer II joint stereo only)
  83.             // returns the number of subbands which are in stereo mode,
  84.             // subbands above that limit are in intensity stereo mode
  85.  
  86.   // Scrolling stuff
  87.  
  88.   uint32        calculate_framesize (); // made public
  89.   uint32    max_number_of_frames (Ibitstream *stream);
  90.   uint32    min_number_of_frames (Ibitstream *stream);
  91.  
  92.   real      ms_per_frame(void); // milliseconds per frame, for time display
  93.  
  94. };
  95.  
  96. #endif
  97.