libavcodec/mlpdec.c File Reference

MLP decoder. More...

#include <stdint.h>
#include "avcodec.h"
#include "dsputil.h"
#include "libavutil/intreadwrite.h"
#include "get_bits.h"
#include "libavutil/crc.h"
#include "parser.h"
#include "mlp_parser.h"
#include "mlp.h"

Go to the source code of this file.

Data Structures

struct  SubStream
struct  MLPDecodeContext

Defines

#define VLC_BITS   9
 number of bits used for VLC lookup - longest Huffman code is 9
#define MSB_MASK(bits)   (-1u << bits)
#define PARAM_BLOCKSIZE   (1 << 7)
#define PARAM_MATRIX   (1 << 6)
#define PARAM_OUTSHIFT   (1 << 5)
#define PARAM_QUANTSTEP   (1 << 4)
#define PARAM_FIR   (1 << 3)
#define PARAM_IIR   (1 << 2)
#define PARAM_HUFFOFFSET   (1 << 1)
#define PARAM_PRESENCE   (1 << 0)

Functions

static av_cold void init_static (void)
 Initialize static data, constant between all invocations of the codec.
static int32_t calculate_sign_huff (MLPDecodeContext *m, unsigned int substr, unsigned int ch)
static int read_huff_channels (MLPDecodeContext *m, GetBitContext *gbp, unsigned int substr, unsigned int pos)
 Read a sample, consisting of either, both or neither of entropy-coded MSBs and plain LSBs.
static av_cold int mlp_decode_init (AVCodecContext *avctx)
static int read_major_sync (MLPDecodeContext *m, GetBitContext *gb)
 Read a major sync info header - contains high level information about the stream - sample rate, channel arrangement etc.
static int read_restart_header (MLPDecodeContext *m, GetBitContext *gbp, const uint8_t *buf, unsigned int substr)
 Read a restart header from a block in a substream.
static int read_filter_params (MLPDecodeContext *m, GetBitContext *gbp, unsigned int substr, unsigned int channel, unsigned int filter)
 Read parameters for one of the prediction filters.
static int read_matrix_params (MLPDecodeContext *m, unsigned int substr, GetBitContext *gbp)
 Read parameters for primitive matrices.
static int read_channel_params (MLPDecodeContext *m, unsigned int substr, GetBitContext *gbp, unsigned int ch)
 Read channel parameters.
static int read_decoding_params (MLPDecodeContext *m, GetBitContext *gbp, unsigned int substr)
 Read decoding parameters that change more often than those in the restart header.
static void filter_channel (MLPDecodeContext *m, unsigned int substr, unsigned int channel)
 Generate PCM samples using the prediction filters and residual values read from the data stream, and update the filter state.
static int read_block_data (MLPDecodeContext *m, GetBitContext *gbp, unsigned int substr)
 Read a block of PCM residual data (or actual if no filtering active).
static void generate_2_noise_channels (MLPDecodeContext *m, unsigned int substr)
 Noise generation functions.
static void fill_noise_buffer (MLPDecodeContext *m, unsigned int substr)
 Generate a block of noise, used when restart sync word == 0x31eb.
static void rematrix_channels (MLPDecodeContext *m, unsigned int substr)
 Apply the channel matrices in turn to reconstruct the original audio samples.
static int output_data_internal (MLPDecodeContext *m, unsigned int substr, uint8_t *data, unsigned int *data_size, int is32)
 Write the audio data into the output buffer.
static int output_data (MLPDecodeContext *m, unsigned int substr, uint8_t *data, unsigned int *data_size)
static int read_access_unit (AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt)
 Read an access unit from the stream.

Variables

static const char * sample_message
static VLC huff_vlc [3]
static const int8_t noise_table [256]
 Data table used for TrueHD noise generation function.
AVCodec ff_mlp_decoder


Detailed Description

MLP decoder.

Definition in file mlpdec.c.


Define Documentation

#define MSB_MASK ( bits   )     (-1u << bits)

Definition at line 759 of file mlpdec.c.

Referenced by filter_channel(), and rematrix_channels().

#define PARAM_BLOCKSIZE   (1 << 7)

Definition at line 78 of file mlpdec.c.

Referenced by read_decoding_params().

#define PARAM_FIR   (1 << 3)

Definition at line 82 of file mlpdec.c.

Referenced by read_channel_params().

#define PARAM_HUFFOFFSET   (1 << 1)

Definition at line 84 of file mlpdec.c.

Referenced by read_channel_params().

#define PARAM_IIR   (1 << 2)

Definition at line 83 of file mlpdec.c.

Referenced by read_channel_params().

#define PARAM_MATRIX   (1 << 6)

Definition at line 79 of file mlpdec.c.

Referenced by read_decoding_params().

#define PARAM_OUTSHIFT   (1 << 5)

Definition at line 80 of file mlpdec.c.

Referenced by read_decoding_params().

#define PARAM_PRESENCE   (1 << 0)

Definition at line 85 of file mlpdec.c.

Referenced by read_decoding_params().

#define PARAM_QUANTSTEP   (1 << 4)

Definition at line 81 of file mlpdec.c.

Referenced by read_decoding_params().

#define VLC_BITS   9

number of bits used for VLC lookup - longest Huffman code is 9

Definition at line 39 of file mlpdec.c.


Function Documentation

static int32_t calculate_sign_huff ( MLPDecodeContext m,
unsigned int  substr,
unsigned int  ch 
) [inline, static]

Definition at line 177 of file mlpdec.c.

Referenced by read_channel_params(), and read_decoding_params().

static void fill_noise_buffer ( MLPDecodeContext m,
unsigned int  substr 
) [static]

Generate a block of noise, used when restart sync word == 0x31eb.

Definition at line 881 of file mlpdec.c.

Referenced by rematrix_channels().

static void filter_channel ( MLPDecodeContext m,
unsigned int  substr,
unsigned int  channel 
) [static]

Generate PCM samples using the prediction filters and residual values read from the data stream, and update the filter state.

Definition at line 764 of file mlpdec.c.

Referenced by read_block_data().

static void generate_2_noise_channels ( MLPDecodeContext m,
unsigned int  substr 
) [static]

Noise generation functions.

I'm not sure what these are for - they seem to be some kind of pseudorandom sequence generators, used to generate noise data which is used when the channels are rematrixed. I'm not sure if they provide a practical benefit to compression, or just obfuscate the decoder. Are they for some kind of dithering? Generate two channels of noise, used in the matrix when restart sync word == 0x31ea.

Definition at line 861 of file mlpdec.c.

Referenced by rematrix_channels().

static av_cold void init_static ( void   )  [static]

Initialize static data, constant between all invocations of the codec.

Definition at line 160 of file mlpdec.c.

Referenced by mlp_decode_init().

static av_cold int mlp_decode_init ( AVCodecContext avctx  )  [static]

Definition at line 234 of file mlpdec.c.

static int output_data ( MLPDecodeContext m,
unsigned int  substr,
uint8_t *  data,
unsigned int *  data_size 
) [static]

Definition at line 977 of file mlpdec.c.

Referenced by read_access_unit().

static int output_data_internal ( MLPDecodeContext m,
unsigned int  substr,
uint8_t *  data,
unsigned int *  data_size,
int  is32 
) [static]

Write the audio data into the output buffer.

Definition at line 945 of file mlpdec.c.

Referenced by output_data().

static int read_access_unit ( AVCodecContext avctx,
void *  data,
int *  data_size,
AVPacket avpkt 
) [static]

Read an access unit from the stream.

Returns:
negative on error, 0 if not enough data is present in the input stream, otherwise the number of bytes consumed.

Definition at line 991 of file mlpdec.c.

static int read_block_data ( MLPDecodeContext m,
GetBitContext gbp,
unsigned int  substr 
) [static]

Read a block of PCM residual data (or actual if no filtering active).

Definition at line 791 of file mlpdec.c.

Referenced by read_access_unit().

static int read_channel_params ( MLPDecodeContext m,
unsigned int  substr,
GetBitContext gbp,
unsigned int  ch 
) [static]

Read channel parameters.

Definition at line 654 of file mlpdec.c.

Referenced by read_decoding_params().

static int read_decoding_params ( MLPDecodeContext m,
GetBitContext gbp,
unsigned int  substr 
) [static]

Read decoding parameters that change more often than those in the restart header.

Definition at line 711 of file mlpdec.c.

Referenced by read_access_unit().

static int read_filter_params ( MLPDecodeContext m,
GetBitContext gbp,
unsigned int  substr,
unsigned int  channel,
unsigned int  filter 
) [static]

Read parameters for one of the prediction filters.

Definition at line 516 of file mlpdec.c.

Referenced by read_channel_params().

static int read_huff_channels ( MLPDecodeContext m,
GetBitContext gbp,
unsigned int  substr,
unsigned int  pos 
) [inline, static]

Read a sample, consisting of either, both or neither of entropy-coded MSBs and plain LSBs.

Definition at line 198 of file mlpdec.c.

Referenced by read_block_data().

static int read_major_sync ( MLPDecodeContext m,
GetBitContext gb 
) [static]

Read a major sync info header - contains high level information about the stream - sample rate, channel arrangement etc.

Most of this information is not actually necessary for decoding, only for playback.

Definition at line 253 of file mlpdec.c.

Referenced by read_access_unit().

static int read_matrix_params ( MLPDecodeContext m,
unsigned int  substr,
GetBitContext gbp 
) [static]

Read parameters for primitive matrices.

Definition at line 591 of file mlpdec.c.

Referenced by read_decoding_params().

static int read_restart_header ( MLPDecodeContext m,
GetBitContext gbp,
const uint8_t *  buf,
unsigned int  substr 
) [static]

Read a restart header from a block in a substream.

This contains parameters required to decode the audio that do not change very often. Generally (always) present only in blocks following a major sync.

Definition at line 359 of file mlpdec.c.

Referenced by read_access_unit().

static void rematrix_channels ( MLPDecodeContext m,
unsigned int  substr 
) [static]

Apply the channel matrices in turn to reconstruct the original audio samples.

Definition at line 900 of file mlpdec.c.

Referenced by read_access_unit().


Variable Documentation

Initial value:

 {
    "mlp",
    AVMEDIA_TYPE_AUDIO,
    CODEC_ID_MLP,
    sizeof(MLPDecodeContext),
    mlp_decode_init,
    NULL,
    NULL,
    read_access_unit,
    .long_name = NULL_IF_CONFIG_SMALL("MLP (Meridian Lossless Packing)"),
}

Definition at line 1186 of file mlpdec.c.

VLC huff_vlc[3] [static]

Definition at line 156 of file mlpdec.c.

const int8_t noise_table[256] [static]

Initial value:

 {
     30,  51,  22,  54,   3,   7,  -4,  38,  14,  55,  46,  81,  22,  58,  -3,   2,
     52,  31,  -7,  51,  15,  44,  74,  30,  85, -17,  10,  33,  18,  80,  28,  62,
     10,  32,  23,  69,  72,  26,  35,  17,  73,  60,   8,  56,   2,   6,  -2,  -5,
     51,   4,  11,  50,  66,  76,  21,  44,  33,  47,   1,  26,  64,  48,  57,  40,
     38,  16, -10, -28,  92,  22, -18,  29, -10,   5, -13,  49,  19,  24,  70,  34,
     61,  48,  30,  14,  -6,  25,  58,  33,  42,  60,  67,  17,  54,  17,  22,  30,
     67,  44,  -9,  50, -11,  43,  40,  32,  59,  82,  13,  49, -14,  55,  60,  36,
     48,  49,  31,  47,  15,  12,   4,  65,   1,  23,  29,  39,  45,  -2,  84,  69,
      0,  72,  37,  57,  27,  41, -15, -16,  35,  31,  14,  61,  24,   0,  27,  24,
     16,  41,  55,  34,  53,   9,  56,  12,  25,  29,  53,   5,  20, -20,  -8,  20,
     13,  28,  -3,  78,  38,  16,  11,  62,  46,  29,  21,  24,  46,  65,  43, -23,
     89,  18,  74,  21,  38, -12,  19,  12, -19,   8,  15,  33,   4,  57,   9,  -8,
     36,  35,  26,  28,   7,  83,  63,  79,  75,  11,   3,  87,  37,  47,  34,  40,
     39,  19,  20,  42,  27,  34,  39,  77,  13,  42,  59,  64,  45,  -1,  32,  37,
     45,  -5,  53,  -6,   7,  36,  50,  23,   6,  32,   9, -21,  18,  71,  27,  52,
    -25,  31,  35,  42,  -1,  68,  63,  52,  26,  43,  66,  37,  41,  25,  40,  70,
}
Data table used for TrueHD noise generation function.

Definition at line 832 of file mlpdec.c.

Referenced by fill_noise_buffer(), main(), and rnd_table_init().

const char* sample_message [static]

Initial value:

    "Please file a bug report following the instructions at "
    "http://ffmpeg.org/bugreports.html and include "
    "a sample of this file."

Definition at line 42 of file mlpdec.c.

Referenced by read_block_data(), read_major_sync(), and read_restart_header().


Generated on Fri Oct 26 02:38:17 2012 for FFmpeg by  doxygen 1.5.8