File: header.h

package info (click to toggle)
maplay 1.2b-5
  • links: PTS
  • area: main
  • in suites: slink
  • size: 432 kB
  • ctags: 441
  • sloc: cpp: 5,421; sh: 97; makefile: 86
file content (82 lines) | stat: -rw-r--r-- 3,034 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*
 *  @(#) header.h 1.8, last edit: 25 Oct 1994 16:27:25
 *  @(#) 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.
 */

#ifndef HEADER_H
#define HEADER_H

#include "all.h"
#include "ibitstream.h"
#include "crc.h"


enum e_mode { stereo, joint_stereo, dual_channel, single_channel  };
enum e_sample_frequency { fourtyfour_point_one, fourtyeight, thirtytwo };


// Class for extraction information from a frame header:
class Header
{
  static const uint32	frequencies[3];
  uint32		h_layer, h_protection_bit, h_bitrate_index,
			 h_padding_bit, h_mode_extension;
  e_mode		h_mode;
  e_sample_frequency	h_sample_frequency;
  uint32		h_number_of_subbands, h_intensity_stereo_bound;
  boil			h_copyright, h_original;
  Crc16			*crc;
  uint16		checksum;

  uint32		calculate_framesize ();

public:
			Header (void) { crc = (Crc16 *)0; }
		       ~Header (void) { if (crc) delete crc; }
  boil			read_header (Ibitstream *, Crc16 **);
			// read a 32-bit header from the bitstream

  // functions to query header contents:
  uint32		layer (void) { return h_layer; };
  uint32		bitrate_index (void) { return h_bitrate_index; };
  e_sample_frequency	sample_frequency (void) { return h_sample_frequency; };
  uint32		frequency (void) { return frequencies[h_sample_frequency]; }
  static uint32	frequency (e_sample_frequency rate) { return frequencies[rate]; }
  e_mode		mode (void) { return h_mode; };
  boil			checksums (void) { return !h_protection_bit; }
  boil			copyright (void) { return h_copyright; }
  boil			original (void) { return h_original; }

  boil			checksum_ok (void) { return checksum == crc->checksum (); }
			// compares computed checksum with stream checksum

  // functions which return header informations as strings:
  const char *		layer_string (void);
  const char *		bitrate_string (void);
  const char *		sample_frequency_string (void);
  const char *		mode_string (void);

  uint32		number_of_subbands (void) { return h_number_of_subbands; };
			// returns the number of subbands in the current frame
  uint32		intensity_stereo_bound (void) {return h_intensity_stereo_bound; };
			// (Layer II joint stereo only)
			// returns the number of subbands which are in stereo mode,
			// subbands above that limit are in intensity stereo mode
};

#endif