00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 # ifndef LIBMAD_FRAME_H
00023 # define LIBMAD_FRAME_H
00024
00025 # include "fixed.h"
00026 # include "timer.h"
00027 # include "stream.h"
00028
00029 enum mad_layer {
00030 MAD_LAYER_I = 1,
00031 MAD_LAYER_II = 2,
00032 MAD_LAYER_III = 3
00033 };
00034
00035 enum mad_mode {
00036 MAD_MODE_SINGLE_CHANNEL = 0,
00037 MAD_MODE_DUAL_CHANNEL = 1,
00038 MAD_MODE_JOINT_STEREO = 2,
00039 MAD_MODE_STEREO = 3
00040 };
00041
00042 enum mad_emphasis {
00043 MAD_EMPHASIS_NONE = 0,
00044 MAD_EMPHASIS_50_15_US = 1,
00045 MAD_EMPHASIS_CCITT_J_17 = 3,
00046 MAD_EMPHASIS_RESERVED = 2
00047 };
00048
00049 struct mad_header {
00050 enum mad_layer layer;
00051 enum mad_mode mode;
00052 int mode_extension;
00053 enum mad_emphasis emphasis;
00054
00055 unsigned long bitrate;
00056 unsigned int samplerate;
00057
00058 unsigned short crc_check;
00059 unsigned short crc_target;
00060
00061 int flags;
00062 int private_bits;
00063
00064 mad_timer_t duration;
00065 };
00066
00067 struct mad_frame {
00068 struct mad_header header;
00069
00070 int options;
00071
00072 mad_fixed_t sbsample[2][36][32];
00073 mad_fixed_t (*overlap)[2][32][18];
00074 };
00075
00076 # define MAD_NCHANNELS(header) ((header)->mode ? 2 : 1)
00077 # define MAD_NSBSAMPLES(header) \
00078 ((header)->layer == MAD_LAYER_I ? 12 : \
00079 (((header)->layer == MAD_LAYER_III && \
00080 ((header)->flags & MAD_FLAG_LSF_EXT)) ? 18 : 36))
00081
00082 enum {
00083 MAD_FLAG_NPRIVATE_III = 0x0007,
00084 MAD_FLAG_INCOMPLETE = 0x0008,
00085
00086 MAD_FLAG_PROTECTION = 0x0010,
00087 MAD_FLAG_COPYRIGHT = 0x0020,
00088 MAD_FLAG_ORIGINAL = 0x0040,
00089 MAD_FLAG_PADDING = 0x0080,
00090
00091 MAD_FLAG_I_STEREO = 0x0100,
00092 MAD_FLAG_MS_STEREO = 0x0200,
00093 MAD_FLAG_FREEFORMAT = 0x0400,
00094
00095 MAD_FLAG_LSF_EXT = 0x1000,
00096 MAD_FLAG_MC_EXT = 0x2000,
00097 MAD_FLAG_MPEG_2_5_EXT = 0x4000
00098 };
00099
00100 enum {
00101 MAD_PRIVATE_HEADER = 0x0100,
00102 MAD_PRIVATE_III = 0x001f
00103 };
00104
00105 void mad_header_init(struct mad_header *);
00106
00107 # define mad_header_finish(header)
00108
00109 int mad_header_decode(struct mad_header *, struct mad_stream *);
00110
00111 void mad_frame_init(struct mad_frame *);
00112 void mad_frame_finish(struct mad_frame *);
00113
00114 int mad_frame_decode(struct mad_frame *, struct mad_stream *);
00115
00116 void mad_frame_mute(struct mad_frame *);
00117
00118 # endif