FFmpeg
|
Bitstream parser for ATRAC3+ decoder. More...
#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 VLC_TYPE | tables_data [154276][2] |
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 321 of file atrac3plus.c.
Referenced by decode_channel_sf_idx().
#define DEC_CT_IDX_COMMON | ( | OP | ) |
Definition at line 690 of file atrac3plus.c.
Referenced by decode_channel_code_tab().
#define CODING_DIRECT get_bits(gb, num_bits) |
Definition at line 703 of file atrac3plus.c.
Referenced by decode_channel_code_tab().
Definition at line 705 of file atrac3plus.c.
Referenced by decode_channel_code_tab().
#define CODING_VLC_DELTA |
Definition at line 707 of file atrac3plus.c.
Referenced by decode_channel_code_tab().
#define CODING_VLC_DIFF |
Definition at line 713 of file atrac3plus.c.
Referenced by decode_channel_code_tab().
|
static |
Generate canonical VLC table from given descriptor.
[in] | cb | ptr to codebook descriptor |
[in] | xlat | ptr to translation table or NULL |
[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().
Initialize VLC tables for bitstream parsing.
Definition at line 80 of file atrac3plus.c.
Referenced by atrac3p_decode_init().
|
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 221 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 251 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 281 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 309 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 335 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 478 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 613 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 646 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 673 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 726 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 779 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 812 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 851 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 921 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 946 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 965 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 1030 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 1045 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 1071 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 1153 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 1176 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 1208 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 1362 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 1405 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 1446 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 1510 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 1570 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 1670 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 1695 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 1757 of file atrac3plus.c.
Referenced by atrac3p_decode_frame().
|
static |
Definition at line 34 of file atrac3plus.c.
Referenced by build_canonical_huff(), and ff_atrac3p_init_vlcs().
|
static |
Definition at line 35 of file atrac3plus.c.
|
static |
Definition at line 36 of file atrac3plus.c.
|
static |
Definition at line 37 of file atrac3plus.c.
Referenced by decode_channel_code_tab().
|
static |
Definition at line 38 of file atrac3plus.c.
|
static |
Definition at line 39 of file atrac3plus.c.
|
static |
Definition at line 40 of file atrac3plus.c.