#include <math.h>
#include <stddef.h>
#include <stdio.h>
#include "avcodec.h"
#include "get_bits.h"
#include "dsputil.h"
#include "rdft.h"
#include "mpegaudiodsp.h"
#include "mpegaudio.h"
#include "qdm2data.h"
#include "qdm2_tablegen.h"
#include <assert.h>
Go to the source code of this file.
Data Structures | |
struct | QDM2SubPacket |
Subpacket. More... | |
struct | QDM2SubPNode |
A node in the subpacket list. More... | |
struct | QDM2Complex |
struct | FFTTone |
struct | FFTCoefficient |
struct | QDM2FFT |
struct | QDM2Context |
QDM2 decoder context. More... | |
Defines | |
#define | ALT_BITSTREAM_READER_LE |
#define | QDM2_LIST_ADD(list, size, packet) |
#define | QDM2_SB_USED(sub_sampling) (((sub_sampling) >= 2) ? 30 : 8 << (sub_sampling)) |
#define | FIX_NOISE_IDX(noise_idx) |
#define | SB_DITHERING_NOISE(sb, noise_idx) (noise_table[(noise_idx)++] * sb_noise_attenuation[(sb)]) |
#define | BITS_LEFT(length, gb) ((length) - get_bits_count ((gb))) |
#define | SAMPLES_NEEDED av_log (NULL,AV_LOG_INFO,"This file triggers some untested code. Please contact the developers.\n"); |
#define | SAMPLES_NEEDED_2(why) av_log (NULL,AV_LOG_INFO,"This file triggers some missing code. Please contact the developers.\nPosition: %s\n",why); |
#define | QDM2_MAX_FRAME_SIZE 512 |
Typedefs | |
typedef int8_t | sb_int8_array [2][30][64] |
Functions | |
static av_cold void | qdm2_init_vlc (void) |
static int | qdm2_get_vlc (GetBitContext *gb, VLC *vlc, int flag, int depth) |
static int | qdm2_get_se_vlc (VLC *vlc, GetBitContext *gb, int depth) |
static uint16_t | qdm2_packet_checksum (const uint8_t *data, int length, int value) |
QDM2 checksum. | |
static void | qdm2_decode_sub_packet_header (GetBitContext *gb, QDM2SubPacket *sub_packet) |
Fill a QDM2SubPacket structure with packet type, size, and data pointer. | |
static QDM2SubPNode * | qdm2_search_subpacket_type_in_list (QDM2SubPNode *list, int type) |
Return node pointer to first packet of requested type in list. | |
static void | average_quantized_coeffs (QDM2Context *q) |
Replace 8 elements with their average value. | |
static void | build_sb_samples_from_noise (QDM2Context *q, int sb) |
Build subband samples with noise weighted by q->tone_level. | |
static void | fix_coding_method_array (int sb, int channels, sb_int8_array coding_method) |
Called while processing data from subpackets 11 and 12. | |
static void | fill_tone_level_array (QDM2Context *q, int flag) |
Related to synthesis filter Called by process_subpacket_10. | |
static void | fill_coding_method_array (sb_int8_array tone_level_idx, sb_int8_array tone_level_idx_temp, sb_int8_array coding_method, int nb_channels, int c, int superblocktype_2_3, int cm_table_select) |
Related to synthesis filter Called by process_subpacket_11 c is built with data from subpacket 11 Most of this function is used only if superblock_type_2_3 == 0, never seen it in samples. | |
static void | synthfilt_build_sb_samples (QDM2Context *q, GetBitContext *gb, int length, int sb_min, int sb_max) |
Called by process_subpacket_11 to process more data from subpacket 11 with sb 0-8 Called by process_subpacket_12 to process data from subpacket 12 with sb 8-sb_used. | |
static void | init_quantized_coeffs_elem0 (int8_t *quantized_coeffs, GetBitContext *gb, int length) |
Init the first element of a channel in quantized_coeffs with data from packet 10 (quantized_coeffs[ch][0]). | |
static void | init_tone_level_dequantization (QDM2Context *q, GetBitContext *gb, int length) |
Related to synthesis filter, process data from packet 10 Init part of quantized_coeffs via function init_quantized_coeffs_elem0 Init tone_level_idx_hi1, tone_level_idx_hi2, tone_level_idx_mid with data from packet 10. | |
static void | process_subpacket_9 (QDM2Context *q, QDM2SubPNode *node) |
Process subpacket 9, init quantized_coeffs with data from it. | |
static void | process_subpacket_10 (QDM2Context *q, QDM2SubPNode *node, int length) |
Process subpacket 10 if not null, else. | |
static void | process_subpacket_11 (QDM2Context *q, QDM2SubPNode *node, int length) |
Process subpacket 11. | |
static void | process_subpacket_12 (QDM2Context *q, QDM2SubPNode *node, int length) |
Process subpacket 12. | |
static void | process_synthesis_subpackets (QDM2Context *q, QDM2SubPNode *list) |
static void | qdm2_decode_super_block (QDM2Context *q) |
static void | qdm2_fft_init_coefficient (QDM2Context *q, int sub_packet, int offset, int duration, int channel, int exp, int phase) |
static void | qdm2_fft_decode_tones (QDM2Context *q, int duration, GetBitContext *gb, int b) |
static void | qdm2_decode_fft_packets (QDM2Context *q) |
static void | qdm2_fft_generate_tone (QDM2Context *q, FFTTone *tone) |
static void | qdm2_fft_tone_synthesizer (QDM2Context *q, int sub_packet) |
static void | qdm2_calculate_fft (QDM2Context *q, int channel, int sub_packet) |
static void | qdm2_synthesis_filter (QDM2Context *q, int index) |
static av_cold void | qdm2_init (QDM2Context *q) |
Init static data (does not depend on specific file). | |
static av_cold int | qdm2_decode_init (AVCodecContext *avctx) |
Init parameters from codec extradata. | |
static av_cold int | qdm2_decode_close (AVCodecContext *avctx) |
static int | qdm2_decode (QDM2Context *q, const uint8_t *in, int16_t *out) |
static int | qdm2_decode_frame (AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) |
Variables | |
static uint8_t | empty_buffer [FF_INPUT_BUFFER_PADDING_SIZE] |
static VLC | vlc_tab_level |
static VLC | vlc_tab_diff |
static VLC | vlc_tab_run |
static VLC | fft_level_exp_alt_vlc |
static VLC | fft_level_exp_vlc |
static VLC | fft_stereo_exp_vlc |
static VLC | fft_stereo_phase_vlc |
static VLC | vlc_tab_tone_level_idx_hi1 |
static VLC | vlc_tab_tone_level_idx_mid |
static VLC | vlc_tab_tone_level_idx_hi2 |
static VLC | vlc_tab_type30 |
static VLC | vlc_tab_type34 |
static VLC | vlc_tab_fft_tone_offset [5] |
static const uint16_t | qdm2_vlc_offs [] |
AVCodec | ff_qdm2_decoder |
Definition in file qdm2.c.
#define BITS_LEFT | ( | length, | |||
gb | ) | ((length) - get_bits_count ((gb))) |
Definition at line 71 of file qdm2.c.
Referenced by init_quantized_coeffs_elem0(), init_tone_level_dequantization(), and synthfilt_build_sb_samples().
#define FIX_NOISE_IDX | ( | noise_idx | ) |
Value:
if ((noise_idx) >= 3840) \
(noise_idx) -= 3840; \
Definition at line 65 of file qdm2.c.
Referenced by build_sb_samples_from_noise(), and synthfilt_build_sb_samples().
#define QDM2_LIST_ADD | ( | list, | |||
size, | |||||
packet | ) |
#define QDM2_MAX_FRAME_SIZE 512 |
#define QDM2_SB_USED | ( | sub_sampling | ) | (((sub_sampling) >= 2) ? 30 : 8 << (sub_sampling)) |
Definition at line 63 of file qdm2.c.
Referenced by average_quantized_coeffs(), fill_tone_level_array(), init_tone_level_dequantization(), process_subpacket_12(), process_subpacket_9(), and qdm2_synthesis_filter().
#define SAMPLES_NEEDED av_log (NULL,AV_LOG_INFO,"This file triggers some untested code. Please contact the developers.\n"); |
Definition at line 73 of file qdm2.c.
Referenced by fill_coding_method_array(), and fix_coding_method_array().
#define SAMPLES_NEEDED_2 | ( | why | ) | av_log (NULL,AV_LOG_INFO,"This file triggers some missing code. Please contact the developers.\nPosition: %s\n",why); |
#define SB_DITHERING_NOISE | ( | sb, | |||
noise_idx | ) | (noise_table[(noise_idx)++] * sb_noise_attenuation[(sb)]) |
Definition at line 69 of file qdm2.c.
Referenced by build_sb_samples_from_noise(), and synthfilt_build_sb_samples().
typedef int8_t sb_int8_array[2][30][64] |
static void average_quantized_coeffs | ( | QDM2Context * | q | ) | [static] |
Replace 8 elements with their average value.
Called by qdm2_decode_superblock before starting subblock decoding.
q | context |
Definition at line 443 of file qdm2.c.
Referenced by qdm2_decode_super_block().
static void build_sb_samples_from_noise | ( | QDM2Context * | q, | |
int | sb | |||
) | [static] |
Build subband samples with noise weighted by q->tone_level.
Called by synthfilt_build_sb_samples.
q | context | |
sb | subband index |
Definition at line 473 of file qdm2.c.
Referenced by synthfilt_build_sb_samples().
static void fill_coding_method_array | ( | sb_int8_array | tone_level_idx, | |
sb_int8_array | tone_level_idx_temp, | |||
sb_int8_array | coding_method, | |||
int | nb_channels, | |||
int | c, | |||
int | superblocktype_2_3, | |||
int | cm_table_select | |||
) | [static] |
Related to synthesis filter Called by process_subpacket_11 c is built with data from subpacket 11 Most of this function is used only if superblock_type_2_3 == 0, never seen it in samples.
tone_level_idx | ||
tone_level_idx_temp | ||
coding_method | q->coding_method[0][0][0] | |
nb_channels | number of channels | |
c | coming from subpacket 11, passed as 8*c | |
superblocktype_2_3 | flag based on superblock packet type | |
cm_table_select | q->cm_table_select |
Definition at line 638 of file qdm2.c.
Referenced by process_subpacket_11().
static void fill_tone_level_array | ( | QDM2Context * | q, | |
int | flag | |||
) | [static] |
Related to synthesis filter Called by process_subpacket_10.
q | context | |
flag | 1 if called after getting data from subpacket 10, 0 if no subpacket 10 |
Definition at line 543 of file qdm2.c.
Referenced by process_subpacket_10().
static void fix_coding_method_array | ( | int | sb, | |
int | channels, | |||
sb_int8_array | coding_method | |||
) | [static] |
Called while processing data from subpackets 11 and 12.
Used after making changes to coding_method array.
sb | subband index | |
channels | number of channels | |
coding_method | q->coding_method[0][0][0] |
Definition at line 498 of file qdm2.c.
Referenced by fill_coding_method_array(), and synthfilt_build_sb_samples().
static void init_quantized_coeffs_elem0 | ( | int8_t * | quantized_coeffs, | |
GetBitContext * | gb, | |||
int | length | |||
) | [static] |
Init the first element of a channel in quantized_coeffs with data from packet 10 (quantized_coeffs[ch][0]).
This is similar to process_subpacket_9, but for a single channel and for element [0] same VLC tables as process_subpacket_9 are used.
quantized_coeffs | pointer to quantized_coeffs[ch][0] | |
gb | bitreader context | |
length | packet length in bits |
Definition at line 956 of file qdm2.c.
Referenced by init_tone_level_dequantization().
static void init_tone_level_dequantization | ( | QDM2Context * | q, | |
GetBitContext * | gb, | |||
int | length | |||
) | [static] |
Related to synthesis filter, process data from packet 10 Init part of quantized_coeffs via function init_quantized_coeffs_elem0 Init tone_level_idx_hi1, tone_level_idx_hi2, tone_level_idx_mid with data from packet 10.
q | context | |
gb | bitreader context | |
length | packet length in bits |
Definition at line 993 of file qdm2.c.
Referenced by process_subpacket_10().
static void process_subpacket_10 | ( | QDM2Context * | q, | |
QDM2SubPNode * | node, | |||
int | length | |||
) | [static] |
Process subpacket 10 if not null, else.
q | context | |
node | pointer to node with packet | |
length | packet length in bits |
Definition at line 1095 of file qdm2.c.
Referenced by process_synthesis_subpackets(), and qdm2_decode_super_block().
static void process_subpacket_11 | ( | QDM2Context * | q, | |
QDM2SubPNode * | node, | |||
int | length | |||
) | [static] |
Process subpacket 11.
q | context | |
node | pointer to node with packet | |
length | packet length in bit |
Definition at line 1117 of file qdm2.c.
Referenced by process_synthesis_subpackets(), and qdm2_decode_super_block().
static void process_subpacket_12 | ( | QDM2Context * | q, | |
QDM2SubPNode * | node, | |||
int | length | |||
) | [static] |
Process subpacket 12.
q | context | |
node | pointer to node with packet | |
length | packet length in bits |
Definition at line 1141 of file qdm2.c.
Referenced by process_synthesis_subpackets(), and qdm2_decode_super_block().
static void process_subpacket_9 | ( | QDM2Context * | q, | |
QDM2SubPNode * | node | |||
) | [static] |
Process subpacket 9, init quantized_coeffs with data from it.
q | context | |
node | pointer to node with packet |
Definition at line 1056 of file qdm2.c.
Referenced by process_synthesis_subpackets().
static void process_synthesis_subpackets | ( | QDM2Context * | q, | |
QDM2SubPNode * | list | |||
) | [static] |
static void qdm2_calculate_fft | ( | QDM2Context * | q, | |
int | channel, | |||
int | sub_packet | |||
) | [static] |
static int qdm2_decode | ( | QDM2Context * | q, | |
const uint8_t * | in, | |||
int16_t * | out | |||
) | [static] |
static av_cold int qdm2_decode_close | ( | AVCodecContext * | avctx | ) | [static] |
static void qdm2_decode_fft_packets | ( | QDM2Context * | q | ) | [static] |
static int qdm2_decode_frame | ( | AVCodecContext * | avctx, | |
void * | data, | |||
int * | data_size, | |||
AVPacket * | avpkt | |||
) | [static] |
static av_cold int qdm2_decode_init | ( | AVCodecContext * | avctx | ) | [static] |
static void qdm2_decode_sub_packet_header | ( | GetBitContext * | gb, | |
QDM2SubPacket * | sub_packet | |||
) | [static] |
Fill a QDM2SubPacket structure with packet type, size, and data pointer.
gb | bitreader context | |
sub_packet | packet under analysis |
Definition at line 392 of file qdm2.c.
Referenced by qdm2_decode_super_block().
static void qdm2_decode_super_block | ( | QDM2Context * | q | ) | [static] |
static void qdm2_fft_decode_tones | ( | QDM2Context * | q, | |
int | duration, | |||
GetBitContext * | gb, | |||
int | b | |||
) | [static] |
static void qdm2_fft_generate_tone | ( | QDM2Context * | q, | |
FFTTone * | tone | |||
) | [static] |
static void qdm2_fft_init_coefficient | ( | QDM2Context * | q, | |
int | sub_packet, | |||
int | offset, | |||
int | duration, | |||
int | channel, | |||
int | exp, | |||
int | phase | |||
) | [static] |
static void qdm2_fft_tone_synthesizer | ( | QDM2Context * | q, | |
int | sub_packet | |||
) | [static] |
static int qdm2_get_se_vlc | ( | VLC * | vlc, | |
GetBitContext * | gb, | |||
int | depth | |||
) | [static] |
Definition at line 359 of file qdm2.c.
Referenced by init_quantized_coeffs_elem0(), and process_subpacket_9().
static int qdm2_get_vlc | ( | GetBitContext * | gb, | |
VLC * | vlc, | |||
int | flag, | |||
int | depth | |||
) | [static] |
Definition at line 336 of file qdm2.c.
Referenced by init_quantized_coeffs_elem0(), init_tone_level_dequantization(), process_subpacket_9(), qdm2_decode_super_block(), qdm2_fft_decode_tones(), qdm2_get_se_vlc(), and synthfilt_build_sb_samples().
static av_cold void qdm2_init | ( | QDM2Context * | q | ) | [static] |
Init static data (does not depend on specific file).
q | context |
Definition at line 1650 of file qdm2.c.
Referenced by qdm2_decode_init().
static av_cold void qdm2_init_vlc | ( | void | ) | [static] |
static uint16_t qdm2_packet_checksum | ( | const uint8_t * | data, | |
int | length, | |||
int | value | |||
) | [static] |
QDM2 checksum.
data | pointer to data to be checksum'ed | |
length | data length | |
value | checksum value |
Definition at line 376 of file qdm2.c.
Referenced by qdm2_decode_super_block().
static QDM2SubPNode* qdm2_search_subpacket_type_in_list | ( | QDM2SubPNode * | list, | |
int | type | |||
) | [static] |
Return node pointer to first packet of requested type in list.
list | list of subpackets to be scanned | |
type | type of searched subpacket |
Definition at line 426 of file qdm2.c.
Referenced by process_synthesis_subpackets().
static void qdm2_synthesis_filter | ( | QDM2Context * | q, | |
int | index | |||
) | [static] |
q | context | |
index | subpacket number |
Definition at line 1611 of file qdm2.c.
Referenced by qdm2_decode().
static void synthfilt_build_sb_samples | ( | QDM2Context * | q, | |
GetBitContext * | gb, | |||
int | length, | |||
int | sb_min, | |||
int | sb_max | |||
) | [static] |
Called by process_subpacket_11 to process more data from subpacket 11 with sb 0-8 Called by process_subpacket_12 to process data from subpacket 12 with sb 8-sb_used.
q | context | |
gb | bitreader context | |
length | packet length in bits | |
sb_min | lower subband processed (sb_min included) | |
sb_max | higher subband processed (sb_max excluded) |
Definition at line 766 of file qdm2.c.
Referenced by process_subpacket_11(), and process_subpacket_12().
uint8_t empty_buffer[FF_INPUT_BUFFER_PADDING_SIZE] [static] |
Definition at line 202 of file qdm2.c.
Referenced by process_subpacket_10(), process_subpacket_11(), and process_subpacket_12().
Initial value:
{ .name = "qdm2", .type = AVMEDIA_TYPE_AUDIO, .id = CODEC_ID_QDM2, .priv_data_size = sizeof(QDM2Context), .init = qdm2_decode_init, .close = qdm2_decode_close, .decode = qdm2_decode_frame, .long_name = NULL_IF_CONFIG_SMALL("QDesign Music Codec 2"), }
VLC fft_level_exp_alt_vlc [static] |
VLC fft_level_exp_vlc [static] |
VLC fft_stereo_exp_vlc [static] |
VLC fft_stereo_phase_vlc [static] |
const uint16_t qdm2_vlc_offs[] [static] |
Initial value:
{ 0,260,566,598,894,1166,1230,1294,1678,1950,2214,2278,2310,2570,2834,3124,3448,3838, }
Definition at line 218 of file qdm2.c.
Referenced by qdm2_init_vlc().
VLC vlc_tab_diff [static] |
VLC vlc_tab_fft_tone_offset[5] [static] |
VLC vlc_tab_level [static] |
VLC vlc_tab_run [static] |
VLC vlc_tab_tone_level_idx_hi1 [static] |
VLC vlc_tab_tone_level_idx_hi2 [static] |
VLC vlc_tab_tone_level_idx_mid [static] |
VLC vlc_tab_type30 [static] |
VLC vlc_tab_type34 [static] |