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