#include "global.h"
#include <stdlib.h>
#include "bit.h"
#include "stream.h"
#include "frame.h"
#include "timer.h"
#include "layer12.h"
#include "layer3.h"
Go to the source code of this file.
Functions | |
void | mad_header_init (struct mad_header *header) |
Initializes a newly created mad_header structure. | |
void | mad_frame_init (struct mad_frame *frame) |
Initializes a frame struct. | |
void | mad_frame_finish (struct mad_frame *frame) |
Deallocates any dynamic memory associated with frame. | |
static int | decode_header (struct mad_header *header, struct mad_stream *stream) |
Reads header data and following CRC word. | |
static int | free_bitrate (struct mad_stream *stream, struct mad_header const *header) |
Attempts to discover the bitstream's free bitrate. | |
int | mad_header_decode (struct mad_header *header, struct mad_stream *stream) |
Reads the next frame header from the stream. | |
int | mad_frame_decode (struct mad_frame *frame, struct mad_stream *stream) |
Decodes a single frame from a bitstream. | |
void | mad_frame_mute (struct mad_frame *frame) |
Zeroes all subband values so the frame becomes silent. | |
Variables | |
static unsigned long const | bitrate_table [5][15] |
static unsigned int const | samplerate_table [3] = { 44100, 48000, 32000 } |
static int(*const | decoder_table [3])(struct mad_stream *, struct mad_frame *) |
Definition in file frame.c.
static int decode_header | ( | struct mad_header * | header, | |
struct mad_stream * | stream | |||
) | [static] |
Reads header data and following CRC word.
Definition at line 119 of file frame.c.
References mad_header::bitrate, bitrate_table, mad_header::crc_check, mad_header::crc_target, mad_header::emphasis, mad_stream::error, mad_header::flags, mad_header::layer, mad_bit_crc(), mad_bit_read(), mad_bit_skip(), MAD_EMPHASIS_RESERVED, MAD_ERROR_BADBITRATE, MAD_ERROR_BADEMPHASIS, MAD_ERROR_BADLAYER, MAD_ERROR_BADSAMPLERATE, MAD_ERROR_LOSTSYNC, MAD_FLAG_COPYRIGHT, MAD_FLAG_LSF_EXT, MAD_FLAG_MPEG_2_5_EXT, MAD_FLAG_ORIGINAL, MAD_FLAG_PADDING, MAD_FLAG_PROTECTION, MAD_PRIVATE_HEADER, mad_header::mode, mad_header::mode_extension, mad_header::private_bits, mad_stream::ptr, mad_header::samplerate, and samplerate_table.
Referenced by free_bitrate(), and mad_header_decode().
static int free_bitrate | ( | struct mad_stream * | stream, | |
struct mad_header const * | header | |||
) | [static] |
Attempts to discover the bitstream's free bitrate.
Definition at line 237 of file frame.c.
References decode_header(), mad_stream::error, mad_header::flags, mad_stream::freerate, mad_header::layer, mad_bit_nextbyte(), mad_bit_skip(), MAD_ERROR_LOSTSYNC, MAD_FLAG_LSF_EXT, MAD_FLAG_PADDING, MAD_LAYER_I, MAD_LAYER_III, mad_stream_sync(), mad_stream::ptr, mad_header::samplerate, and mad_stream::this_frame.
Referenced by mad_header_decode().
int mad_frame_decode | ( | struct mad_frame * | frame, | |
struct mad_stream * | stream | |||
) |
Decodes a single frame from a bitstream.
Definition at line 434 of file frame.c.
References mad_stream::anc_bitlen, mad_stream::anc_ptr, decoder_table, mad_stream::error, mad_header::flags, mad_frame::header, mad_header::layer, mad_bit_finish, mad_bit_init(), mad_bit_length(), MAD_FLAG_INCOMPLETE, mad_header_decode(), MAD_LAYER_III, MAD_RECOVERABLE, mad_stream::next_frame, mad_stream::options, mad_frame::options, mad_stream::ptr, and mad_stream::this_frame.
Referenced by run_sync().
void mad_frame_finish | ( | struct mad_frame * | frame | ) |
Deallocates any dynamic memory associated with frame.
Definition at line 105 of file frame.c.
References mad_frame::header, mad_header_finish, and mad_frame::overlap.
Referenced by run_sync().
void mad_frame_init | ( | struct mad_frame * | frame | ) |
Initializes a frame struct.
Definition at line 92 of file frame.c.
References mad_frame::header, mad_frame_mute(), mad_header_init(), mad_frame::options, and mad_frame::overlap.
Referenced by run_sync().
void mad_frame_mute | ( | struct mad_frame * | frame | ) |
Zeroes all subband values so the frame becomes silent.
Definition at line 479 of file frame.c.
References mad_frame::overlap, s, and mad_frame::sbsample.
Referenced by error_default(), and mad_frame_init().
int mad_header_decode | ( | struct mad_header * | header, | |
struct mad_stream * | stream | |||
) |
Reads the next frame header from the stream.
Definition at line 297 of file frame.c.
References mad_header::bitrate, mad_stream::bufend, decode_header(), mad_header::duration, mad_stream::error, mad_header::flags, free_bitrate(), mad_stream::freerate, mad_header::layer, mad_bit_init(), mad_bit_nextbyte(), MAD_BUFFER_GUARD, MAD_ERROR_BUFLEN, MAD_ERROR_BUFPTR, MAD_ERROR_LOSTSYNC, MAD_FLAG_FREEFORMAT, MAD_FLAG_INCOMPLETE, MAD_FLAG_LSF_EXT, MAD_FLAG_PADDING, MAD_LAYER_I, MAD_LAYER_III, MAD_NSBSAMPLES, mad_stream_sync(), mad_timer_set(), mad_stream::next_frame, mad_stream::ptr, mad_header::samplerate, mad_stream::skiplen, mad_stream::sync, and mad_stream::this_frame.
Referenced by mad_frame_decode(), and run_sync().
void mad_header_init | ( | struct mad_header * | header | ) |
Initializes a newly created mad_header structure.
Definition at line 70 of file frame.c.
References mad_header::bitrate, mad_header::crc_check, mad_header::crc_target, mad_header::duration, mad_header::emphasis, mad_header::flags, mad_header::layer, mad_timer_zero, mad_header::mode, mad_header::mode_extension, mad_header::private_bits, and mad_header::samplerate.
Referenced by mad_frame_init().
unsigned long const bitrate_table[5][15] [static] |
Initial value:
{ { 0, 32000, 64000, 96000, 128000, 160000, 192000, 224000, 256000, 288000, 320000, 352000, 384000, 416000, 448000 }, { 0, 32000, 48000, 56000, 64000, 80000, 96000, 112000, 128000, 160000, 192000, 224000, 256000, 320000, 384000 }, { 0, 32000, 40000, 48000, 56000, 64000, 80000, 96000, 112000, 128000, 160000, 192000, 224000, 256000, 320000 }, { 0, 32000, 48000, 56000, 64000, 80000, 96000, 112000, 128000, 144000, 160000, 176000, 192000, 224000, 256000 }, { 0, 8000, 16000, 24000, 32000, 40000, 48000, 56000, 64000, 80000, 96000, 112000, 128000, 144000, 160000 } }
Definition at line 41 of file frame.c.
Referenced by decode_header().
int(*const decoder_table[3])(struct mad_stream *, struct mad_frame *) [static] |
unsigned int const samplerate_table[3] = { 44100, 48000, 32000 } [static] |