libavcodec/alsdec.c File Reference

MPEG-4 ALS decoder. More...

#include "avcodec.h"
#include "get_bits.h"
#include "unary.h"
#include "mpeg4audio.h"
#include "bytestream.h"
#include "bgmc.h"
#include <stdint.h>

Go to the source code of this file.

Data Structures

struct  ALSSpecificConfig
struct  ALSChannelData
struct  ALSDecContext
struct  ALSBlockData

Defines

#define MISSING_ERR(cond, str, errval)
#define INTERLEAVE_OUTPUT(bps)

Enumerations

enum  RA_Flag { RA_FLAG_NONE, RA_FLAG_FRAMES, RA_FLAG_HEADER }

Functions

static av_cold void dprint_specific_config (ALSDecContext *ctx)
static av_cold int read_specific_config (ALSDecContext *ctx)
 Reads an ALSSpecificConfig from a buffer into the output struct.
static int check_specific_config (ALSDecContext *ctx)
 Checks the ALSSpecificConfig for unsupported features.
static void parse_bs_info (const uint32_t bs_info, unsigned int n, unsigned int div, unsigned int **div_blocks, unsigned int *num_blocks)
 Parses the bs_info field to extract the block partitioning used in block switching mode, refer to ISO/IEC 14496-3, section 11.6.2.
static int32_t decode_rice (GetBitContext *gb, unsigned int k)
 Reads and decodes a Rice codeword.
static void parcor_to_lpc (unsigned int k, const int32_t *par, int32_t *cof)
 Converts PARCOR coefficient k to direct filter coefficient.
static void get_block_sizes (ALSDecContext *ctx, unsigned int *div_blocks, uint32_t *bs_info)
 Reads block switching field if necessary and sets actual block sizes.
static void read_const_block_data (ALSDecContext *ctx, ALSBlockData *bd)
 Reads the block data for a constant block.
static void decode_const_block_data (ALSDecContext *ctx, ALSBlockData *bd)
 Decodes the block data for a constant block.
static int read_var_block_data (ALSDecContext *ctx, ALSBlockData *bd)
 Reads the block data for a non-constant block.
static int decode_var_block_data (ALSDecContext *ctx, ALSBlockData *bd)
 Decodes the block data for a non-constant block.
static int read_block (ALSDecContext *ctx, ALSBlockData *bd)
 Reads the block data.
static int decode_block (ALSDecContext *ctx, ALSBlockData *bd)
 Decodes the block data.
static int read_decode_block (ALSDecContext *ctx, ALSBlockData *bd)
 Reads and decodes block data successively.
static void zero_remaining (unsigned int b, unsigned int b_max, const unsigned int *div_blocks, int32_t *buf)
 Computes the number of samples left to decode for the current frame and sets these samples to zero.
static int decode_blocks_ind (ALSDecContext *ctx, unsigned int ra_frame, unsigned int c, const unsigned int *div_blocks, unsigned int *js_blocks)
 Decodes blocks independently.
static int decode_blocks (ALSDecContext *ctx, unsigned int ra_frame, unsigned int c, const unsigned int *div_blocks, unsigned int *js_blocks)
 Decodes blocks dependently.
static int read_channel_data (ALSDecContext *ctx, ALSChannelData *cd, int c)
 Reads the channel data.
static int revert_channel_correlation (ALSDecContext *ctx, ALSBlockData *bd, ALSChannelData **cd, int *reverted, unsigned int offset, int c)
 Recursively reverts the inter-channel correlation for a block.
static int read_frame_data (ALSDecContext *ctx, unsigned int ra_frame)
 Reads the frame data.
static int decode_frame (AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt)
 Decodes an ALS frame.
static av_cold int decode_end (AVCodecContext *avctx)
 Uninitializes the ALS decoder.
static av_cold int decode_init (AVCodecContext *avctx)
 Initializes the ALS decoder.
static av_cold void flush (AVCodecContext *avctx)
 Flushes (resets) the frame ID after seeking.

Variables

static const int8_t parcor_rice_table [3][20][2]
 Rice parameters and corresponding index offsets for decoding the indices of scaled PARCOR values.
static const int16_t parcor_scaled_values []
 Scaled PARCOR values used for the first two PARCOR coefficients.
static const uint8_t ltp_gain_values [4][4]
 Gain values of p(0) for long-term prediction.
static const int16_t mcc_weightings []
 Inter-channel weighting factors for multi-channel correlation.
static const uint8_t tail_code [16][6]
 Tail codes used in arithmetic coding using block Gilbert-Moore codes.
AVCodec als_decoder


Detailed Description

MPEG-4 ALS decoder.

Author:
Thilo Borgmann <thilo.borgmann _at_ googlemail.com>

Definition in file alsdec.c.


Define Documentation

#define INTERLEAVE_OUTPUT ( bps   ) 

Value:

{                                                              \
        int##bps##_t *dest = (int##bps##_t*) data;                 \
        shift = bps - ctx->avctx->bits_per_raw_sample;             \
        for (sample = 0; sample < ctx->cur_frame_length; sample++) \
            for (c = 0; c < avctx->channels; c++)                  \
                *dest++ = ctx->raw_samples[c][sample] << shift;    \
    }

Referenced by decode_frame().

#define MISSING_ERR ( cond,
str,
errval   ) 

Value:

{                                                   \
        if (cond) {                                     \
            av_log_missing_feature(ctx->avctx, str, 0); \
            error = errval;                             \
        }                                               \
    }

Referenced by check_specific_config().


Enumeration Type Documentation

enum RA_Flag

Enumerator:
RA_FLAG_NONE 
RA_FLAG_FRAMES 
RA_FLAG_HEADER 

Definition at line 146 of file alsdec.c.


Function Documentation

static int check_specific_config ( ALSDecContext ctx  )  [static]

Checks the ALSSpecificConfig for unsupported features.

Definition at line 397 of file alsdec.c.

Referenced by decode_init().

static int decode_block ( ALSDecContext ctx,
ALSBlockData bd 
) [static]

Decodes the block data.

Definition at line 949 of file alsdec.c.

Referenced by decode_frame(), mjpeg_decode_scan(), read_decode_block(), and read_frame_data().

static int decode_blocks ( ALSDecContext ctx,
unsigned int  ra_frame,
unsigned int  c,
const unsigned int *  div_blocks,
unsigned int *  js_blocks 
) [static]

Decodes blocks dependently.

Definition at line 1042 of file alsdec.c.

Referenced by decode_frame(), and read_frame_data().

static int decode_blocks_ind ( ALSDecContext ctx,
unsigned int  ra_frame,
unsigned int  c,
const unsigned int *  div_blocks,
unsigned int *  js_blocks 
) [static]

Decodes blocks independently.

Definition at line 1004 of file alsdec.c.

Referenced by read_frame_data().

static void decode_const_block_data ( ALSDecContext ctx,
ALSBlockData bd 
) [static]

Decodes the block data for a constant block.

Definition at line 561 of file alsdec.c.

Referenced by decode_block().

static av_cold int decode_end ( AVCodecContext avctx  )  [static]

Uninitializes the ALS decoder.

Definition at line 1449 of file alsdec.c.

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

Decodes an ALS frame.

Definition at line 1380 of file alsdec.c.

static av_cold int decode_init ( AVCodecContext avctx  )  [static]

Initializes the ALS decoder.

Definition at line 1479 of file alsdec.c.

static int32_t decode_rice ( GetBitContext gb,
unsigned int  k 
) [static]

Reads and decodes a Rice codeword.

Definition at line 445 of file alsdec.c.

Referenced by read_channel_data(), and read_var_block_data().

static int decode_var_block_data ( ALSDecContext ctx,
ALSBlockData bd 
) [static]

Decodes the block data for a non-constant block.

Definition at line 822 of file alsdec.c.

Referenced by decode_block().

static av_cold void dprint_specific_config ( ALSDecContext ctx  )  [static]

Definition at line 237 of file alsdec.c.

Referenced by read_specific_config().

static av_cold void flush ( AVCodecContext avctx  )  [static]

Flushes (resets) the frame ID after seeking.

Definition at line 1615 of file alsdec.c.

static void get_block_sizes ( ALSDecContext ctx,
unsigned int *  div_blocks,
uint32_t *  bs_info 
) [static]

Reads block switching field if necessary and sets actual block sizes.

Also assures that the block sizes of the last frame correspond to the actual number of samples.

Definition at line 483 of file alsdec.c.

Referenced by read_frame_data().

static void parcor_to_lpc ( unsigned int  k,
const int32_t *  par,
int32_t *  cof 
) [static]

Converts PARCOR coefficient k to direct filter coefficient.

Definition at line 463 of file alsdec.c.

Referenced by decode_var_block_data().

static void parse_bs_info ( const uint32_t  bs_info,
unsigned int  n,
unsigned int  div,
unsigned int **  div_blocks,
unsigned int *  num_blocks 
) [static]

Parses the bs_info field to extract the block partitioning used in block switching mode, refer to ISO/IEC 14496-3, section 11.6.2.

Definition at line 422 of file alsdec.c.

Referenced by get_block_sizes().

static int read_block ( ALSDecContext ctx,
ALSBlockData bd 
) [static]

Reads the block data.

Definition at line 931 of file alsdec.c.

Referenced by read_decode_block(), and read_frame_data().

static int read_channel_data ( ALSDecContext ctx,
ALSChannelData cd,
int  c 
) [static]

Reads the channel data.

Definition at line 1123 of file alsdec.c.

Referenced by read_frame_data().

static void read_const_block_data ( ALSDecContext ctx,
ALSBlockData bd 
) [static]

Reads the block data for a constant block.

Definition at line 536 of file alsdec.c.

Referenced by read_block().

static int read_decode_block ( ALSDecContext ctx,
ALSBlockData bd 
) [static]

Reads and decodes block data successively.

Definition at line 971 of file alsdec.c.

Referenced by decode_blocks(), and decode_blocks_ind().

static int read_frame_data ( ALSDecContext ctx,
unsigned int  ra_frame 
) [static]

Reads the frame data.

< block sizes.

Definition at line 1251 of file alsdec.c.

Referenced by decode_frame().

static av_cold int read_specific_config ( ALSDecContext ctx  )  [static]

Reads an ALSSpecificConfig from a buffer into the output struct.

Definition at line 267 of file alsdec.c.

Referenced by decode_init().

static int read_var_block_data ( ALSDecContext ctx,
ALSBlockData bd 
) [static]

Reads the block data for a non-constant block.

Definition at line 575 of file alsdec.c.

Referenced by read_block().

static int revert_channel_correlation ( ALSDecContext ctx,
ALSBlockData bd,
ALSChannelData **  cd,
int *  reverted,
unsigned int  offset,
int  c 
) [static]

Recursively reverts the inter-channel correlation for a block.

Definition at line 1170 of file alsdec.c.

Referenced by read_frame_data().

static void zero_remaining ( unsigned int  b,
unsigned int  b_max,
const unsigned int *  div_blocks,
int32_t *  buf 
) [static]

Computes the number of samples left to decode for the current frame and sets these samples to zero.

Definition at line 989 of file alsdec.c.

Referenced by decode_blocks(), and decode_blocks_ind().


Variable Documentation

Initial value:

 {
    "als",
    AVMEDIA_TYPE_AUDIO,
    CODEC_ID_MP4ALS,
    sizeof(ALSDecContext),
    decode_init,
    NULL,
    decode_end,
    decode_frame,
    .flush = flush,
    .capabilities = CODEC_CAP_SUBFRAMES,
    .long_name = NULL_IF_CONFIG_SMALL("MPEG-4 Audio Lossless Coding (ALS)"),
}

Definition at line 1623 of file alsdec.c.

const uint8_t ltp_gain_values[4][4] [static]

Initial value:

 {
    { 0,  8, 16,  24},
    {32, 40, 48,  56},
    {64, 70, 76,  82},
    {88, 92, 96, 100}
}
Gain values of p(0) for long-term prediction.

To be indexed by the Rice coded indices.

Definition at line 105 of file alsdec.c.

Referenced by read_var_block_data().

const int16_t mcc_weightings[] [static]

Initial value:

 {
    204,  192,  179,  166,  153,  140,  128,  115,
    102,   89,   76,   64,   51,   38,   25,   12,
      0,  -12,  -25,  -38,  -51,  -64,  -76,  -89,
   -102, -115, -128, -140, -153, -166, -179, -192
}
Inter-channel weighting factors for multi-channel correlation.

To be indexed by the Rice coded indices.

Definition at line 116 of file alsdec.c.

Referenced by read_channel_data().

const int8_t parcor_rice_table[3][20][2] [static]

Initial value:

 {
    { {-52, 4}, {-29, 5}, {-31, 4}, { 19, 4}, {-16, 4},
      { 12, 3}, { -7, 3}, {  9, 3}, { -5, 3}, {  6, 3},
      { -4, 3}, {  3, 3}, { -3, 2}, {  3, 2}, { -2, 2},
      {  3, 2}, { -1, 2}, {  2, 2}, { -1, 2}, {  2, 2} },
    { {-58, 3}, {-42, 4}, {-46, 4}, { 37, 5}, {-36, 4},
      { 29, 4}, {-29, 4}, { 25, 4}, {-23, 4}, { 20, 4},
      {-17, 4}, { 16, 4}, {-12, 4}, { 12, 3}, {-10, 4},
      {  7, 3}, { -4, 4}, {  3, 3}, { -1, 3}, {  1, 3} },
    { {-59, 3}, {-45, 5}, {-50, 4}, { 38, 4}, {-39, 4},
      { 32, 4}, {-30, 4}, { 25, 3}, {-23, 3}, { 20, 3},
      {-20, 3}, { 16, 3}, {-13, 3}, { 10, 3}, { -7, 3},
      {  3, 3}, {  0, 3}, { -1, 3}, {  2, 3}, { -1, 2} }
}
Rice parameters and corresponding index offsets for decoding the indices of scaled PARCOR values.

The table choosen is set globally by the encoder and stored in ALSSpecificConfig.

Definition at line 45 of file alsdec.c.

Referenced by read_var_block_data().

const int16_t parcor_scaled_values[] [static]

Scaled PARCOR values used for the first two PARCOR coefficients.

To be indexed by the Rice coded indices. Generated by: parcor_scaled_values[i] = 32 + ((i * (i+1)) << 7) - (1 << 20) Actual values are divided by 32 in order to be stored in 16 bits.

Definition at line 66 of file alsdec.c.

Referenced by read_var_block_data().

const uint8_t tail_code[16][6] [static]

Initial value:

 {
    { 74, 44, 25, 13,  7, 3},
    { 68, 42, 24, 13,  7, 3},
    { 58, 39, 23, 13,  7, 3},
    {126, 70, 37, 19, 10, 5},
    {132, 70, 37, 20, 10, 5},
    {124, 70, 38, 20, 10, 5},
    {120, 69, 37, 20, 11, 5},
    {116, 67, 37, 20, 11, 5},
    {108, 66, 36, 20, 10, 5},
    {102, 62, 36, 20, 10, 5},
    { 88, 58, 34, 19, 10, 5},
    {162, 89, 49, 25, 13, 7},
    {156, 87, 49, 26, 14, 7},
    {150, 86, 47, 26, 14, 7},
    {142, 84, 47, 26, 14, 7},
    {131, 79, 46, 26, 14, 7}
}
Tail codes used in arithmetic coding using block Gilbert-Moore codes.

Definition at line 126 of file alsdec.c.

Referenced by read_var_block_data().


Generated on Fri Oct 26 02:36:50 2012 for FFmpeg by  doxygen 1.5.8