libavcodec/ac3dec.c File Reference

#include <stdio.h>
#include <stddef.h>
#include <math.h>
#include <string.h>
#include "avcodec.h"
#include "ac3_parser.h"
#include "bitstream.h"
#include "crc.h"
#include "dsputil.h"
#include "random.h"

Go to the source code of this file.

Data Structures

struct  AC3DecodeContext
struct  mant_groups
 Grouped mantissas for 3-level 5-level and 11-level quantization. More...

Defines

#define LEVEL_MINUS_3DB   0.7071067811865476
 Adjustments in dB gain.
#define LEVEL_MINUS_4POINT5DB   0.5946035575013605
#define LEVEL_MINUS_6DB   0.5000000000000000
#define LEVEL_MINUS_9DB   0.3535533905932738
#define LEVEL_ZERO   0.0000000000000000
#define LEVEL_ONE   1.0000000000000000
#define AC3_MAX_CHANNELS   7
#define CPL_CH   0
#define AC3_OUTPUT_LFEON   8

Functions

static float symmetric_dequant (int code, int levels)
 Symmetrical Dequantization reference: Section 7.3.3 Expansion of Mantissas for Symmetrical Quantization Tables 7.19 to 7.23.
static void ac3_tables_init (void)
static int ac3_decode_init (AVCodecContext *avctx)
 AVCodec initialization.
static int ac3_parse_header (AC3DecodeContext *s)
 Parse the 'sync info' and 'bit stream info' from the AC-3 bitstream.
static void set_downmix_coeffs (AC3DecodeContext *s)
 Set stereo downmixing coefficients based on frame header info.
static void decode_exponents (GetBitContext *gbc, int exp_strategy, int ngrps, uint8_t absexp, int8_t *dexps)
 Decode the grouped exponents according to exponent strategy.
static void uncouple_channels (AC3DecodeContext *s)
 Generate transform coefficients for each coupled channel in the coupling range using the coupling coefficients and coupling coordinates.
static int get_transform_coeffs_ch (AC3DecodeContext *s, int ch_index, mant_groups *m)
 Get the transform coefficients for a particular channel reference: Section 7.3 Quantization and Decoding of Mantissas.
static void remove_dithering (AC3DecodeContext *s)
 Remove random dithering from coefficients with zero-bit mantissas reference: Section 7.3.4 Dither for Zero Bit Mantissas (bap=0).
static int get_transform_coeffs (AC3DecodeContext *s)
 Get the transform coefficients.
static void do_rematrixing (AC3DecodeContext *s)
 Stereo rematrixing.
static void do_imdct_256 (AC3DecodeContext *s, int chindex)
 Perform the 256-point IMDCT.
static void do_imdct (AC3DecodeContext *s)
 Inverse MDCT Transform.
static void ac3_downmix (AC3DecodeContext *s)
 Downmix the output to mono or stereo.
static int ac3_parse_audio_block (AC3DecodeContext *s, int blk)
 Parse an audio block from AC-3 bitstream.
static int ac3_decode_frame (AVCodecContext *avctx, void *data, int *data_size, uint8_t *buf, int buf_size)
 Decode a single AC-3 frame.
static int ac3_decode_end (AVCodecContext *avctx)
 Uninitialize the AC-3 decoder.

Variables

static const uint8_t rematrix_band_tab [5] = { 13, 25, 37, 61, 253 }
 Table of bin locations for rematrixing bands reference: Section 7.5.2 Rematrixing : Frequency Band Definitions.
static float scale_factors [25]
 table for exponent to scale_factor mapping scale_factors[i] = 2 ^ -i
static uint8_t exp_ungroup_tab [128][3]
 table for grouping exponents
static float b1_mantissas [32][3]
 tables for ungrouping mantissas
static float b2_mantissas [128][3]
static float b3_mantissas [8]
static float b4_mantissas [128][2]
static float b5_mantissas [16]
static const uint8_t quantization_tab [16]
 Quantization table: levels for symmetric.
static float dynamic_range_tab [256]
 dynamic range table.
static const float gain_levels [6]
static const uint8_t center_levels [4] = { 2, 3, 4, 3 }
 Table for center mix levels reference: Section 5.4.2.4 cmixlev.
static const uint8_t surround_levels [4] = { 2, 4, 0, 4 }
 Table for surround mix levels reference: Section 5.4.2.5 surmixlev.
static const uint8_t ac3_default_coeffs [8][5][2]
 Table for default stereo downmixing coefficients reference: Section 7.8.2 Downmixing Into Two Channels.
AVCodec ac3_decoder


Define Documentation

#define AC3_MAX_CHANNELS   7

Definition at line 123 of file ac3dec.c.

#define AC3_OUTPUT_LFEON   8

Definition at line 126 of file ac3dec.c.

Referenced by ac3_decode_frame(), ac3_parse_audio_block(), ac3_parse_header(), and do_imdct().

#define CPL_CH   0

#define LEVEL_MINUS_3DB   0.7071067811865476

Adjustments in dB gain.

Definition at line 78 of file ac3dec.c.

Referenced by ac3_downmix(), and set_downmix_coeffs().

#define LEVEL_MINUS_4POINT5DB   0.5946035575013605

Definition at line 79 of file ac3dec.c.

#define LEVEL_MINUS_6DB   0.5000000000000000

Definition at line 80 of file ac3dec.c.

#define LEVEL_MINUS_9DB   0.3535533905932738

Definition at line 81 of file ac3dec.c.

#define LEVEL_ONE   1.0000000000000000

Definition at line 83 of file ac3dec.c.

#define LEVEL_ZERO   0.0000000000000000

Definition at line 82 of file ac3dec.c.


Function Documentation

static int ac3_decode_end ( AVCodecContext avctx  )  [static]

Uninitialize the AC-3 decoder.

Definition at line 1156 of file ac3dec.c.

static int ac3_decode_frame ( AVCodecContext avctx,
void *  data,
int *  data_size,
uint8_t buf,
int  buf_size 
) [static]

Decode a single AC-3 frame.

Definition at line 1073 of file ac3dec.c.

static int ac3_decode_init ( AVCodecContext avctx  )  [static]

AVCodec initialization.

Definition at line 271 of file ac3dec.c.

static void ac3_downmix ( AC3DecodeContext s  )  [static]

Downmix the output to mono or stereo.

Definition at line 740 of file ac3dec.c.

Referenced by ac3_parse_audio_block().

static int ac3_parse_audio_block ( AC3DecodeContext s,
int  blk 
) [static]

Parse an audio block from AC-3 bitstream.

Definition at line 767 of file ac3dec.c.

Referenced by ac3_decode_frame().

static int ac3_parse_header ( AC3DecodeContext s  )  [static]

Parse the 'sync info' and 'bit stream info' from the AC-3 bitstream.

GetBitContext within AC3DecodeContext must point to start of the synchronized ac3 bitstream.

Definition at line 308 of file ac3dec.c.

Referenced by ac3_decode_frame().

static void ac3_tables_init ( void   )  [static]

Definition at line 213 of file ac3dec.c.

Referenced by ac3_decode_init().

static void decode_exponents ( GetBitContext gbc,
int  exp_strategy,
int  ngrps,
uint8_t  absexp,
int8_t *  dexps 
) [static]

Decode the grouped exponents according to exponent strategy.

reference: Section 7.1.3 Exponent Decoding

Definition at line 421 of file ac3dec.c.

Referenced by ac3_parse_audio_block().

static void do_imdct ( AC3DecodeContext s  )  [inline, static]

Inverse MDCT Transform.

Convert frequency domain coefficients to time-domain audio samples. reference: Section 7.9.4 Transformation Equations

Definition at line 709 of file ac3dec.c.

Referenced by ac3_parse_audio_block().

static void do_imdct_256 ( AC3DecodeContext s,
int  chindex 
) [static]

Perform the 256-point IMDCT.

Definition at line 666 of file ac3dec.c.

Referenced by do_imdct().

static void do_rematrixing ( AC3DecodeContext s  )  [static]

Stereo rematrixing.

reference: Section 7.5.4 Rematrixing : Decoding Technique

Definition at line 642 of file ac3dec.c.

Referenced by ac3_parse_audio_block().

static int get_transform_coeffs ( AC3DecodeContext s  )  [static]

Get the transform coefficients.

Definition at line 599 of file ac3dec.c.

Referenced by ac3_parse_audio_block().

static int get_transform_coeffs_ch ( AC3DecodeContext s,
int  ch_index,
mant_groups m 
) [static]

Get the transform coefficients for a particular channel reference: Section 7.3 Quantization and Decoding of Mantissas.

Definition at line 491 of file ac3dec.c.

Referenced by get_transform_coeffs().

static void remove_dithering ( AC3DecodeContext s  )  [static]

Remove random dithering from coefficients with zero-bit mantissas reference: Section 7.3.4 Dither for Zero Bit Mantissas (bap=0).

Definition at line 567 of file ac3dec.c.

Referenced by get_transform_coeffs().

static void set_downmix_coeffs ( AC3DecodeContext s  )  [static]

Set stereo downmixing coefficients based on frame header info.

reference: Section 7.8.2 Downmixing Into Two Channels

Definition at line 394 of file ac3dec.c.

Referenced by ac3_decode_frame().

static float symmetric_dequant ( int  code,
int  levels 
) [inline, static]

Symmetrical Dequantization reference: Section 7.3.3 Expansion of Mantissas for Symmetrical Quantization Tables 7.19 to 7.23.

Definition at line 205 of file ac3dec.c.

Referenced by ac3_tables_init().

static void uncouple_channels ( AC3DecodeContext s  )  [static]

Generate transform coefficients for each coupled channel in the coupling range using the coupling coefficients and coupling coordinates.

reference: Section 7.4.3 Coupling Coordinate Format

Definition at line 452 of file ac3dec.c.

Referenced by get_transform_coeffs().


Variable Documentation

Initial value:

 {
    .name = "ac3",
    .type = CODEC_TYPE_AUDIO,
    .id = CODEC_ID_AC3,
    .priv_data_size = sizeof (AC3DecodeContext),
    .init = ac3_decode_init,
    .close = ac3_decode_end,
    .decode = ac3_decode_frame,
}

Definition at line 1165 of file ac3dec.c.

const uint8_t ac3_default_coeffs[8][5][2] [static]

Initial value:

 {
    { { 1, 0 }, { 0, 1 },                               },
    { { 2, 2 },                                         },
    { { 1, 0 }, { 0, 1 },                               },
    { { 1, 0 }, { 3, 3 }, { 0, 1 },                     },
    { { 1, 0 }, { 0, 1 }, { 4, 4 },                     },
    { { 1, 0 }, { 3, 3 }, { 0, 1 }, { 5, 5 },           },
    { { 1, 0 }, { 0, 1 }, { 4, 0 }, { 0, 4 },           },
    { { 1, 0 }, { 3, 3 }, { 0, 1 }, { 4, 0 }, { 0, 4 }, },
}
Table for default stereo downmixing coefficients reference: Section 7.8.2 Downmixing Into Two Channels.

Definition at line 110 of file ac3dec.c.

Referenced by set_downmix_coeffs().

float b1_mantissas[32][3] [static]

tables for ungrouping mantissas

Definition at line 59 of file ac3dec.c.

Referenced by ac3_tables_init(), and get_transform_coeffs_ch().

float b2_mantissas[128][3] [static]

Definition at line 60 of file ac3dec.c.

Referenced by ac3_tables_init(), and get_transform_coeffs_ch().

float b3_mantissas[8] [static]

Definition at line 61 of file ac3dec.c.

Referenced by ac3_tables_init(), and get_transform_coeffs_ch().

float b4_mantissas[128][2] [static]

Definition at line 62 of file ac3dec.c.

Referenced by ac3_tables_init(), and get_transform_coeffs_ch().

float b5_mantissas[16] [static]

Definition at line 63 of file ac3dec.c.

Referenced by ac3_tables_init(), and get_transform_coeffs_ch().

const uint8_t center_levels[4] = { 2, 3, 4, 3 } [static]

Table for center mix levels reference: Section 5.4.2.4 cmixlev.

Definition at line 98 of file ac3dec.c.

Referenced by ac3_parse_header().

float dynamic_range_tab[256] [static]

dynamic range table.

converts codes to scale factors.

Definition at line 75 of file ac3dec.c.

Referenced by ac3_parse_audio_block(), and ac3_tables_init().

uint8_t exp_ungroup_tab[128][3] [static]

table for grouping exponents

Definition at line 55 of file ac3dec.c.

Referenced by ac3_tables_init(), and decode_exponents().

const float gain_levels[6] [static]

Initial value:

Definition at line 85 of file ac3dec.c.

Referenced by set_downmix_coeffs().

const uint8_t quantization_tab[16] [static]

Initial value:

 {
    0, 3, 5, 7, 11, 15,
    5, 6, 7, 8, 9, 10, 11, 12, 14, 16
}
Quantization table: levels for symmetric.

bits for asymmetric. reference: Table 7.18 Mapping of bap to Quantizer

Definition at line 69 of file ac3dec.c.

Referenced by get_transform_coeffs_ch().

const uint8_t rematrix_band_tab[5] = { 13, 25, 37, 61, 253 } [static]

Table of bin locations for rematrixing bands reference: Section 7.5.2 Rematrixing : Frequency Band Definitions.

Definition at line 46 of file ac3dec.c.

Referenced by do_rematrixing().

float scale_factors[25] [static]

table for exponent to scale_factor mapping scale_factors[i] = 2 ^ -i

Definition at line 52 of file ac3dec.c.

Referenced by ac3_parse_audio_block(), ac3_tables_init(), compute_scale_factors(), get_transform_coeffs_ch(), mp_decode_layer1(), and mp_decode_layer2().

const uint8_t surround_levels[4] = { 2, 4, 0, 4 } [static]

Table for surround mix levels reference: Section 5.4.2.5 surmixlev.

Definition at line 104 of file ac3dec.c.

Referenced by ac3_parse_header().


Generated on Thu Apr 2 07:15:40 2009 for ffmpeg by  doxygen 1.5.6