sdk-world v2026.11.05
PS2 SDK - world tier (copyleft-allowed, non-essential packages)
Loading...
Searching...
No Matches
frame.h
Go to the documentation of this file.
1/*
2 * libmad - MPEG audio decoder library
3 * Copyright (C) 2000-2004 Underbit Technologies, Inc.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 * $Id: frame.h,v 1.20 2004/01/23 09:41:32 rob Exp $
20 */
21
26# ifndef LIBMAD_FRAME_H
27# define LIBMAD_FRAME_H
28
29# include "fixed.h"
30# include "timer.h"
31# include "stream.h"
32
33enum mad_layer {
34 MAD_LAYER_I = 1, /* Layer I */
35 MAD_LAYER_II = 2, /* Layer II */
36 MAD_LAYER_III = 3 /* Layer III */
37};
38
39enum mad_mode {
40 MAD_MODE_SINGLE_CHANNEL = 0, /* single channel */
41 MAD_MODE_DUAL_CHANNEL = 1, /* dual channel */
42 MAD_MODE_JOINT_STEREO = 2, /* joint (MS/intensity) stereo */
43 MAD_MODE_STEREO = 3 /* normal LR stereo */
44};
45
46enum mad_emphasis {
47 MAD_EMPHASIS_NONE = 0, /* no emphasis */
48 MAD_EMPHASIS_50_15_US = 1, /* 50/15 microseconds emphasis */
49 MAD_EMPHASIS_CCITT_J_17 = 3, /* CCITT J.17 emphasis */
50 MAD_EMPHASIS_RESERVED = 2 /* unknown emphasis */
51};
52
53struct mad_header {
54 enum mad_layer layer; /* audio layer (1, 2, or 3) */
55 enum mad_mode mode; /* channel mode (see above) */
56 int mode_extension; /* additional mode info */
57 enum mad_emphasis emphasis; /* de-emphasis to use (see above) */
58
59 unsigned long bitrate; /* stream bitrate (bps) */
60 unsigned int samplerate; /* sampling frequency (Hz) */
61
62 unsigned short crc_check; /* frame CRC accumulator */
63 unsigned short crc_target; /* final target CRC checksum */
64
65 int flags; /* flags (see below) */
66 int private_bits; /* private bits (see below) */
67
68 mad_timer_t duration; /* audio playing time of frame */
69};
70
71struct mad_frame {
72 struct mad_header header; /* MPEG audio header */
73
74 int options; /* decoding options (from stream) */
75
76 mad_fixed_t sbsample[2][36][32]; /* synthesis subband filter samples */
77 mad_fixed_t (*overlap)[2][32][18]; /* Layer III block overlap data */
78};
79
80# define MAD_NCHANNELS(header) ((header)->mode ? 2 : 1)
81# define MAD_NSBSAMPLES(header) \
82 ((header)->layer == MAD_LAYER_I ? 12 : \
83 (((header)->layer == MAD_LAYER_III && \
84 ((header)->flags & MAD_FLAG_LSF_EXT)) ? 18 : 36))
85
86enum {
87 MAD_FLAG_NPRIVATE_III = 0x0007, /* number of Layer III private bits */
88 MAD_FLAG_INCOMPLETE = 0x0008, /* header but not data is decoded */
89
90 MAD_FLAG_PROTECTION = 0x0010, /* frame has CRC protection */
91 MAD_FLAG_COPYRIGHT = 0x0020, /* frame is copyright */
92 MAD_FLAG_ORIGINAL = 0x0040, /* frame is original (else copy) */
93 MAD_FLAG_PADDING = 0x0080, /* frame has additional slot */
94
95 MAD_FLAG_I_STEREO = 0x0100, /* uses intensity joint stereo */
96 MAD_FLAG_MS_STEREO = 0x0200, /* uses middle/side joint stereo */
97 MAD_FLAG_FREEFORMAT = 0x0400, /* uses free format bitrate */
98
99 MAD_FLAG_LSF_EXT = 0x1000, /* lower sampling freq. extension */
100 MAD_FLAG_MC_EXT = 0x2000, /* multichannel audio extension */
101 MAD_FLAG_MPEG_2_5_EXT = 0x4000 /* MPEG 2.5 (unofficial) extension */
102};
103
104enum {
105 MAD_PRIVATE_HEADER = 0x0100, /* header private bit */
106 MAD_PRIVATE_III = 0x001f /* Layer III private bits (up to 5) */
107};
108
109void mad_header_init(struct mad_header *);
110
111# define mad_header_finish(header) /* nothing */
112
113int mad_header_decode(struct mad_header *, struct mad_stream *);
114
115void mad_frame_init(struct mad_frame *);
116void mad_frame_finish(struct mad_frame *);
117
118int mad_frame_decode(struct mad_frame *, struct mad_stream *);
119
120void mad_frame_mute(struct mad_frame *);
121
122# endif