FFmpeg
|
#include "libavutil/avassert.h"
#include "avcodec.h"
#include "get_bits.h"
#include "atrac3plus.h"
#include "atrac3plus_data.h"
Go to the source code of this file.
Macros | |
#define | UNPACK_SF_VQ_SHAPE(gb, dst, num_vals) |
#define | DEC_CT_IDX_COMMON(OP) |
#define | CODING_DIRECT get_bits(gb, num_bits) |
#define | CODING_VLC get_vlc2(gb, vlc_tab->table, vlc_tab->bits, 1) |
#define | CODING_VLC_DELTA |
#define | CODING_VLC_DIFF |
Functions | |
static av_cold void | build_canonical_huff (const uint8_t *cb, const uint8_t **xlat, int *tab_offset, VLC *out_vlc) |
Generate canonical VLC table from given descriptor. More... | |
av_cold void | ff_atrac3p_init_vlcs (void) |
Initialize VLC tables for bitstream parsing. More... | |
static int | num_coded_units (GetBitContext *gb, Atrac3pChanParams *chan, Atrac3pChanUnitCtx *ctx, AVCodecContext *avctx) |
Decode number of coded quantization units. More... | |
static int | add_wordlen_weights (Atrac3pChanUnitCtx *ctx, Atrac3pChanParams *chan, int wtab_idx, AVCodecContext *avctx) |
Add weighting coefficients to the decoded word-length information. More... | |
static int | subtract_sf_weights (Atrac3pChanUnitCtx *ctx, Atrac3pChanParams *chan, int wtab_idx, AVCodecContext *avctx) |
Subtract weighting coefficients from decoded scalefactors. More... | |
static void | unpack_vq_shape (int start_val, const int8_t *shape_vec, int *dst, int num_values) |
Unpack vector quantization tables. More... | |
static int | decode_channel_wordlen (GetBitContext *gb, Atrac3pChanUnitCtx *ctx, int ch_num, AVCodecContext *avctx) |
Decode word length for each quantization unit of a channel. More... | |
static int | decode_channel_sf_idx (GetBitContext *gb, Atrac3pChanUnitCtx *ctx, int ch_num, AVCodecContext *avctx) |
Decode scale factor indexes for each quant unit of a channel. More... | |
static int | decode_quant_wordlen (GetBitContext *gb, Atrac3pChanUnitCtx *ctx, int num_channels, AVCodecContext *avctx) |
Decode word length information for each channel. More... | |
static int | decode_scale_factors (GetBitContext *gb, Atrac3pChanUnitCtx *ctx, int num_channels, AVCodecContext *avctx) |
Decode scale factor indexes for each channel. More... | |
static int | get_num_ct_values (GetBitContext *gb, Atrac3pChanUnitCtx *ctx, AVCodecContext *avctx) |
Decode number of code table values. More... | |
static int | decode_channel_code_tab (GetBitContext *gb, Atrac3pChanUnitCtx *ctx, int ch_num, AVCodecContext *avctx) |
Decode code table indexes for each quant unit of a channel. More... | |
static int | decode_code_table_indexes (GetBitContext *gb, Atrac3pChanUnitCtx *ctx, int num_channels, AVCodecContext *avctx) |
Decode code table indexes for each channel. More... | |
static void | decode_qu_spectra (GetBitContext *gb, const Atrac3pSpecCodeTab *tab, VLC *vlc_tab, int16_t *out, const int num_specs) |
Decode huffman-coded spectral lines for a given quant unit. More... | |
static void | decode_spectrum (GetBitContext *gb, Atrac3pChanUnitCtx *ctx, int num_channels, AVCodecContext *avctx) |
Decode huffman-coded IMDCT spectrum for all channels. More... | |
static int | get_subband_flags (GetBitContext *gb, uint8_t *out, int num_flags) |
Retrieve specified amount of flag bits from the input bitstream. More... | |
static void | decode_window_shape (GetBitContext *gb, Atrac3pChanUnitCtx *ctx, int num_channels) |
Decode mdct window shape flags for all channels. More... | |
static int | decode_gainc_npoints (GetBitContext *gb, Atrac3pChanUnitCtx *ctx, int ch_num, int coded_subbands) |
Decode number of gain control points. More... | |
static void | gainc_level_mode3s (AtracGainInfo *dst, AtracGainInfo *ref) |
Implements coding mode 3 (slave) for gain compensation levels. More... | |
static void | gainc_level_mode1m (GetBitContext *gb, Atrac3pChanUnitCtx *ctx, AtracGainInfo *dst) |
Implements coding mode 1 (master) for gain compensation levels. More... | |
static int | decode_gainc_levels (GetBitContext *gb, Atrac3pChanUnitCtx *ctx, int ch_num, int coded_subbands) |
Decode level code for each gain control point. More... | |
static void | gainc_loc_mode0 (GetBitContext *gb, Atrac3pChanUnitCtx *ctx, AtracGainInfo *dst, int pos) |
Implements coding mode 0 for gain compensation locations. More... | |
static void | gainc_loc_mode1 (GetBitContext *gb, Atrac3pChanUnitCtx *ctx, AtracGainInfo *dst) |
Implements coding mode 1 for gain compensation locations. More... | |
static int | decode_gainc_loc_codes (GetBitContext *gb, Atrac3pChanUnitCtx *ctx, int ch_num, int coded_subbands, AVCodecContext *avctx) |
Decode location code for each gain control point. More... | |
static int | decode_gainc_data (GetBitContext *gb, Atrac3pChanUnitCtx *ctx, int num_channels, AVCodecContext *avctx) |
Decode gain control data for all channels. More... | |
static void | decode_tones_envelope (GetBitContext *gb, Atrac3pChanUnitCtx *ctx, int ch_num, int band_has_tones[]) |
Decode envelope for all tones of a channel. More... | |
static int | decode_band_numwavs (GetBitContext *gb, Atrac3pChanUnitCtx *ctx, int ch_num, int band_has_tones[], AVCodecContext *avctx) |
Decode number of tones for each subband of a channel. More... | |
static void | decode_tones_frequency (GetBitContext *gb, Atrac3pChanUnitCtx *ctx, int ch_num, int band_has_tones[]) |
Decode frequency information for each subband of a channel. More... | |
static void | decode_tones_amplitude (GetBitContext *gb, Atrac3pChanUnitCtx *ctx, int ch_num, int band_has_tones[]) |
Decode amplitude information for each subband of a channel. More... | |
static void | decode_tones_phase (GetBitContext *gb, Atrac3pChanUnitCtx *ctx, int ch_num, int band_has_tones[]) |
Decode phase information for each subband of a channel. More... | |
static int | decode_tones_info (GetBitContext *gb, Atrac3pChanUnitCtx *ctx, int num_channels, AVCodecContext *avctx) |
Decode tones info for all channels. More... | |
int | ff_atrac3p_decode_channel_unit (GetBitContext *gb, Atrac3pChanUnitCtx *ctx, int num_channels, AVCodecContext *avctx) |
Decode bitstream data of a channel unit. More... | |
Variables | |
static VLCElem | tables_data [154276] |
static VLC | wl_vlc_tabs [4] |
static VLC | sf_vlc_tabs [8] |
static VLC | ct_vlc_tabs [4] |
static VLC | spec_vlc_tabs [112] |
static VLC | gain_vlc_tabs [11] |
static VLC | tone_vlc_tabs [7] |
Bitstream parser for ATRAC3+ decoder.
Definition in file atrac3plus.c.
#define UNPACK_SF_VQ_SHAPE | ( | gb, | |
dst, | |||
num_vals | |||
) |
Definition at line 226 of file atrac3plus.c.
#define DEC_CT_IDX_COMMON | ( | OP | ) |
Definition at line 599 of file atrac3plus.c.
#define CODING_DIRECT get_bits(gb, num_bits) |
Definition at line 612 of file atrac3plus.c.
Definition at line 614 of file atrac3plus.c.
#define CODING_VLC_DELTA |
Definition at line 616 of file atrac3plus.c.
#define CODING_VLC_DIFF |
Definition at line 622 of file atrac3plus.c.
|
static |
Generate canonical VLC table from given descriptor.
[in] | cb | ptr to codebook descriptor |
[in,out] | xlat | ptr to ptr to translation table |
[in,out] | tab_offset | starting offset to the generated vlc table |
[out] | out_vlc | ptr to vlc table to be generated |
Definition at line 50 of file atrac3plus.c.
Referenced by ff_atrac3p_init_vlcs().
av_cold void ff_atrac3p_init_vlcs | ( | void | ) |
Initialize VLC tables for bitstream parsing.
Definition at line 76 of file atrac3plus.c.
Referenced by atrac3p_init_static().
|
static |
Decode number of coded quantization units.
[in] | gb | the GetBit context |
[in,out] | chan | ptr to the channel parameters |
[in,out] | ctx | ptr to the channel unit context |
[in] | avctx | ptr to the AVCodecContext |
Definition at line 126 of file atrac3plus.c.
Referenced by decode_channel_wordlen().
|
static |
Add weighting coefficients to the decoded word-length information.
[in,out] | ctx | ptr to the channel unit context |
[in,out] | chan | ptr to the channel parameters |
[in] | wtab_idx | index of the table of weights |
[in] | avctx | ptr to the AVCodecContext |
Definition at line 156 of file atrac3plus.c.
Referenced by decode_channel_wordlen().
|
static |
Subtract weighting coefficients from decoded scalefactors.
[in,out] | ctx | ptr to the channel unit context |
[in,out] | chan | ptr to the channel parameters |
[in] | wtab_idx | index of table of weights |
[in] | avctx | ptr to the AVCodecContext |
Definition at line 186 of file atrac3plus.c.
Referenced by decode_channel_sf_idx().
|
inlinestatic |
Unpack vector quantization tables.
[in] | start_val | start value for the unpacked table |
[in] | shape_vec | ptr to table to unpack |
[out] | dst | ptr to output array |
[in] | num_values | number of values to unpack |
Definition at line 214 of file atrac3plus.c.
Referenced by decode_channel_wordlen().
|
static |
Decode word length for each quantization unit of a channel.
[in] | gb | the GetBit context |
[in,out] | ctx | ptr to the channel unit context |
[in] | ch_num | channel to process |
[in] | avctx | ptr to the AVCodecContext |
Definition at line 240 of file atrac3plus.c.
Referenced by decode_quant_wordlen().
|
static |
Decode scale factor indexes for each quant unit of a channel.
[in] | gb | the GetBit context |
[in,out] | ctx | ptr to the channel unit context |
[in] | ch_num | channel to process |
[in] | avctx | ptr to the AVCodecContext |
Definition at line 387 of file atrac3plus.c.
Referenced by decode_scale_factors().
|
static |
Decode word length information for each channel.
[in] | gb | the GetBit context |
[in,out] | ctx | ptr to the channel unit context |
[in] | num_channels | number of channels to process |
[in] | avctx | ptr to the AVCodecContext |
Definition at line 522 of file atrac3plus.c.
Referenced by ff_atrac3p_decode_channel_unit().
|
static |
Decode scale factor indexes for each channel.
[in] | gb | the GetBit context |
[in,out] | ctx | ptr to the channel unit context |
[in] | num_channels | number of channels to process |
[in] | avctx | ptr to the AVCodecContext |
Definition at line 555 of file atrac3plus.c.
Referenced by ff_atrac3p_decode_channel_unit().
|
static |
Decode number of code table values.
[in] | gb | the GetBit context |
[in,out] | ctx | ptr to the channel unit context |
[in] | avctx | ptr to the AVCodecContext |
Definition at line 582 of file atrac3plus.c.
|
static |
Decode code table indexes for each quant unit of a channel.
[in] | gb | the GetBit context |
[in,out] | ctx | ptr to the channel unit context |
[in] | ch_num | channel to process |
[in] | avctx | ptr to the AVCodecContext |
Definition at line 635 of file atrac3plus.c.
Referenced by decode_code_table_indexes().
|
static |
Decode code table indexes for each channel.
[in] | gb | the GetBit context |
[in,out] | ctx | ptr to the channel unit context |
[in] | num_channels | number of channels to process |
[in] | avctx | ptr to the AVCodecContext |
Definition at line 688 of file atrac3plus.c.
Referenced by ff_atrac3p_decode_channel_unit().
|
static |
Decode huffman-coded spectral lines for a given quant unit.
This is a generalized version for all known coding modes. Its speed can be improved by creating separate functions for each mode.
[in] | gb | the GetBit context |
[in] | tab | code table telling how to decode spectral lines |
[in] | vlc_tab | ptr to the huffman table associated with the code table |
[out] | out | pointer to buffer where decoded data should be stored |
[in] | num_specs | number of spectral lines to decode |
Definition at line 721 of file atrac3plus.c.
Referenced by decode_spectrum().
|
static |
Decode huffman-coded IMDCT spectrum for all channels.
[in] | gb | the GetBit context |
[in,out] | ctx | ptr to the channel unit context |
[in] | num_channels | number of channels to process |
[in] | avctx | ptr to the AVCodecContext |
Definition at line 760 of file atrac3plus.c.
Referenced by ff_atrac3p_decode_channel_unit().
|
static |
Retrieve specified amount of flag bits from the input bitstream.
The data can be shortened in the case of the following two common conditions: if all bits are zero then only one signal bit = 0 will be stored, if all bits are ones then two signal bits = 1,0 will be stored. Otherwise, all necessary bits will be directly stored prefixed by two signal bits = 1,1.
[in] | gb | ptr to the GetBitContext |
[out] | out | where to place decoded flags |
[in] | num_flags | number of flags to process |
Definition at line 826 of file atrac3plus.c.
Referenced by decode_tones_info(), decode_window_shape(), and ff_atrac3p_decode_channel_unit().
|
static |
Decode mdct window shape flags for all channels.
[in] | gb | the GetBit context |
[in,out] | ctx | ptr to the channel unit context |
[in] | num_channels | number of channels to process |
Definition at line 851 of file atrac3plus.c.
Referenced by ff_atrac3p_decode_channel_unit().
|
static |
Decode number of gain control points.
[in] | gb | the GetBit context |
[in,out] | ctx | ptr to the channel unit context |
[in] | ch_num | channel to process |
[in] | coded_subbands | number of subbands to process |
Definition at line 870 of file atrac3plus.c.
Referenced by decode_gainc_data().
|
inlinestatic |
Implements coding mode 3 (slave) for gain compensation levels.
[out] | dst | ptr to the output array |
[in] | ref | ptr to the reference channel |
Definition at line 935 of file atrac3plus.c.
Referenced by decode_gainc_levels().
|
inlinestatic |
Implements coding mode 1 (master) for gain compensation levels.
[in] | gb | the GetBit context |
[in] | ctx | ptr to the channel unit context |
[out] | dst | ptr to the output array |
Definition at line 950 of file atrac3plus.c.
Referenced by decode_gainc_levels().
|
static |
Decode level code for each gain control point.
[in] | gb | the GetBit context |
[in,out] | ctx | ptr to the channel unit context |
[in] | ch_num | channel to process |
[in] | coded_subbands | number of subbands to process |
Definition at line 976 of file atrac3plus.c.
Referenced by decode_gainc_data().
|
inlinestatic |
Implements coding mode 0 for gain compensation locations.
[in] | gb | the GetBit context |
[in] | ctx | ptr to the channel unit context |
[out] | dst | ptr to the output array |
[in] | pos | position of the value to be processed |
Definition at line 1058 of file atrac3plus.c.
Referenced by decode_gainc_loc_codes().
|
inlinestatic |
Implements coding mode 1 for gain compensation locations.
[in] | gb | the GetBit context |
[in] | ctx | ptr to the channel unit context |
[out] | dst | ptr to the output array |
Definition at line 1081 of file atrac3plus.c.
Referenced by decode_gainc_loc_codes().
|
static |
Decode location code for each gain control point.
[in] | gb | the GetBit context |
[in,out] | ctx | ptr to the channel unit context |
[in] | ch_num | channel to process |
[in] | coded_subbands | number of subbands to process |
[in] | avctx | ptr to the AVCodecContext |
Definition at line 1113 of file atrac3plus.c.
Referenced by decode_gainc_data().
|
static |
Decode gain control data for all channels.
[in] | gb | the GetBit context |
[in,out] | ctx | ptr to the channel unit context |
[in] | num_channels | number of channels to process |
[in] | avctx | ptr to the AVCodecContext |
Definition at line 1267 of file atrac3plus.c.
Referenced by ff_atrac3p_decode_channel_unit().
|
static |
Decode envelope for all tones of a channel.
[in] | gb | the GetBit context |
[in,out] | ctx | ptr to the channel unit context |
[in] | ch_num | channel to process |
[in] | band_has_tones | ptr to an array of per-band-flags: 1 - tone data present |
Definition at line 1310 of file atrac3plus.c.
Referenced by decode_tones_info().
|
static |
Decode number of tones for each subband of a channel.
[in] | gb | the GetBit context |
[in,out] | ctx | ptr to the channel unit context |
[in] | ch_num | channel to process |
[in] | band_has_tones | ptr to an array of per-band-flags: 1 - tone data present |
[in] | avctx | ptr to the AVCodecContext |
fixed-length coding
variable-length coding
VLC modulo delta to master (slave only)
copy master (slave only)
initialize start tone index for each subband
Definition at line 1351 of file atrac3plus.c.
Referenced by decode_tones_info().
|
static |
Decode frequency information for each subband of a channel.
[in] | gb | the GetBit context |
[in,out] | ctx | ptr to the channel unit context |
[in] | ch_num | channel to process |
[in] | band_has_tones | ptr to an array of per-band-flags: 1 - tone data present |
packed numbers in descending order
packed numbers in ascending order
Definition at line 1415 of file atrac3plus.c.
Referenced by decode_tones_info().
|
static |
Decode amplitude information for each subband of a channel.
[in] | gb | the GetBit context |
[in,out] | ctx | ptr to the channel unit context |
[in] | ch_num | channel to process |
[in] | band_has_tones | ptr to an array of per-band-flags: 1 - tone data present |
fixed-length coding
min + VLC delta
VLC modulo delta to master (slave only)
clone master (slave only)
Definition at line 1475 of file atrac3plus.c.
Referenced by decode_tones_info().
|
static |
Decode phase information for each subband of a channel.
[in] | gb | the GetBit context |
[in,out] | ctx | ptr to the channel unit context |
[in] | ch_num | channel to process |
[in] | band_has_tones | ptr to an array of per-band-flags: 1 - tone data present |
Definition at line 1575 of file atrac3plus.c.
Referenced by decode_tones_info().
|
static |
Decode tones info for all channels.
[in] | gb | the GetBit context |
[in,out] | ctx | ptr to the channel unit context |
[in] | num_channels | number of channels to process |
[in] | avctx | ptr to the AVCodecContext |
Definition at line 1600 of file atrac3plus.c.
Referenced by ff_atrac3p_decode_channel_unit().
int ff_atrac3p_decode_channel_unit | ( | GetBitContext * | gb, |
Atrac3pChanUnitCtx * | ctx, | ||
int | num_channels, | ||
AVCodecContext * | avctx | ||
) |
Decode bitstream data of a channel unit.
[in] | gb | the GetBit context |
[in,out] | ctx | ptr to the channel unit context |
[in] | num_channels | number of channels to process |
[in] | avctx | ptr to the AVCodecContext |
Definition at line 1662 of file atrac3plus.c.
Referenced by atrac3p_decode_frame().
|
static |
Definition at line 34 of file atrac3plus.c.
Referenced by build_canonical_huff().
|
static |
Definition at line 35 of file atrac3plus.c.
Referenced by decode_channel_wordlen(), and ff_atrac3p_init_vlcs().
|
static |
Definition at line 36 of file atrac3plus.c.
Referenced by decode_channel_sf_idx(), and ff_atrac3p_init_vlcs().
|
static |
Definition at line 37 of file atrac3plus.c.
Referenced by decode_channel_code_tab(), and ff_atrac3p_init_vlcs().
|
static |
Definition at line 38 of file atrac3plus.c.
Referenced by decode_spectrum(), and ff_atrac3p_init_vlcs().
|
static |
Definition at line 39 of file atrac3plus.c.
Referenced by decode_gainc_levels(), decode_gainc_loc_codes(), decode_gainc_npoints(), ff_atrac3p_init_vlcs(), gainc_level_mode1m(), and gainc_loc_mode1().
|
static |
Definition at line 40 of file atrac3plus.c.
Referenced by decode_band_numwavs(), decode_tones_amplitude(), decode_tones_frequency(), decode_tones_info(), and ff_atrac3p_init_vlcs().