Go to the documentation of this file.
   42 #define BITSTREAM_READER_LE 
   53 #define QDM2_LIST_ADD(list, size, packet) \ 
   56     list[size - 1].next = &list[size]; \ 
   58       list[size].packet = packet; \ 
   59       list[size].next = NULL; \ 
   64 #define QDM2_SB_USED(sub_sampling) (((sub_sampling) >= 2) ? 30 : 8 << (sub_sampling)) 
   66 #define FIX_NOISE_IDX(noise_idx) \ 
   67   if ((noise_idx) >= 3840) \ 
   68     (noise_idx) -= 3840; \ 
   70 #define SB_DITHERING_NOISE(sb,noise_idx) (noise_table[(noise_idx)++] * sb_noise_attenuation[(sb)]) 
   72 #define SAMPLES_NEEDED \ 
   73      av_log (NULL,AV_LOG_INFO,"This file triggers some untested code. Please contact the developers.\n"); 
   75 #define SAMPLES_NEEDED_2(why) \ 
   76      av_log (NULL,AV_LOG_INFO,"This file triggers some missing code. Please contact the developers.\nPosition: %s\n",why); 
   78 #define QDM2_MAX_FRAME_SIZE 512 
  197     0, 5, 1, 5, 5, 5, 5, 5, 2, 5, 5, 5, 5, 5, 5, 5, 3, 5, 5, 5, 5, 5, 4
 
  221         if ((
value & ~3) > 0)
 
  249     for (
i = 0; 
i < length; 
i++)
 
  252     return (uint16_t)(
value & 0xffff);
 
  266     if (sub_packet->
type == 0) {
 
  267         sub_packet->
size = 0;
 
  272         if (sub_packet->
type & 0x80) {
 
  273             sub_packet->
size <<= 8;
 
  275             sub_packet->
type  &= 0x7f;
 
  278         if (sub_packet->
type == 0x7f)
 
  315     int i, j, n, ch, sum;
 
  320         for (
i = 0; 
i < n; 
i++) {
 
  323             for (j = 0; j < 8; j++)
 
  330             for (j = 0; j < 8; j++)
 
  352         for (j = 0; j < 64; j++) {
 
  377         for (j = 0; j < 64; ) {
 
  378             if (coding_method[ch][sb][j] < 8)
 
  380             if ((coding_method[ch][sb][j] - 8) > 22) {
 
  384                 switch (
switchtable[coding_method[ch][sb][j] - 8]) {
 
  408             for (k = 0; k < 
run; k++) {
 
  410                     int sbjk = sb + (j + k) / 64;
 
  415                     if (coding_method[ch][sbjk][(j + k) % 64] > coding_method[ch][sb][j]) {
 
  419                             memset(&coding_method[ch][sb][j + k], case_val,
 
  421                             memset(&coding_method[ch][sb][j + k], case_val,
 
  442     int i, sb, ch, sb_used;
 
  446         for (sb = 0; sb < 30; sb++)
 
  447             for (
i = 0; 
i < 8; 
i++) {
 
  461         for (sb = 0; sb < sb_used; sb++)
 
  463                 for (
i = 0; 
i < 64; 
i++) {
 
  472         for (sb = 0; sb < sb_used; sb++) {
 
  473             if ((sb >= 4) && (sb <= 23)) {
 
  475                     for (
i = 0; 
i < 64; 
i++) {
 
  489                         for (
i = 0; 
i < 64; 
i++) {
 
  501                         for (
i = 0; 
i < 64; 
i++) {
 
  533                                      int c, 
int superblocktype_2_3,
 
  538     int add1, add2, add3, add4;
 
  541     if (!superblocktype_2_3) {
 
  545         for (ch = 0; ch < nb_channels; ch++) {
 
  546             for (sb = 0; sb < 30; sb++) {
 
  547                 for (j = 1; j < 63; j++) {  
 
  548                     add1 = tone_level_idx[ch][sb][j] - 10;
 
  551                     add2 = add3 = add4 = 0;
 
  567                     tmp = tone_level_idx[ch][sb][j + 1] * 2 - add4 - add3 - add2 - add1;
 
  570                     tone_level_idx_temp[ch][sb][j + 1] = 
tmp & 0xff;
 
  572                 tone_level_idx_temp[ch][sb][0] = tone_level_idx_temp[ch][sb][1];
 
  576         for (ch = 0; ch < nb_channels; ch++)
 
  577             for (sb = 0; sb < 30; sb++)
 
  578                 for (j = 0; j < 64; j++)
 
  579                     acc += tone_level_idx_temp[ch][sb][j];
 
  581         multres = 0x66666667LL * (
acc * 10);
 
  582         esp_40 = (multres >> 32) / 8 + ((multres & 0xffffffff) >> 31);
 
  583         for (ch = 0;  ch < nb_channels; ch++)
 
  584             for (sb = 0; sb < 30; sb++)
 
  585                 for (j = 0; j < 64; j++) {
 
  586                     comp = tone_level_idx_temp[ch][sb][j]* esp_40 * 10;
 
  617                     coding_method[ch][sb][j] = ((
tmp & 0xfffa) + 30 )& 0xff;
 
  619         for (sb = 0; sb < 30; sb++)
 
  621         for (ch = 0; ch < nb_channels; ch++)
 
  622             for (sb = 0; sb < 30; sb++)
 
  623                 for (j = 0; j < 64; j++)
 
  625                         if (coding_method[ch][sb][j] < 10)
 
  626                             coding_method[ch][sb][j] = 10;
 
  629                             if (coding_method[ch][sb][j] < 16)
 
  630                                 coding_method[ch][sb][j] = 16;
 
  632                             if (coding_method[ch][sb][j] < 30)
 
  633                                 coding_method[ch][sb][j] = 30;
 
  637         for (ch = 0; ch < nb_channels; ch++)
 
  638             for (sb = 0; sb < 30; sb++)
 
  639                 for (j = 0; j < 64; j++)
 
  657                                        int length, 
int sb_min, 
int sb_max)
 
  660     int joined_stereo, zero_encoding;
 
  662     float type34_div = 0;
 
  663     float type34_predictor;
 
  665     int sign_bits[16] = {0};
 
  669         for (sb=sb_min; sb < sb_max; sb++)
 
  675     for (sb = sb_min; sb < sb_max; sb++) {
 
  687                 for (j = 0; j < 16; j++)
 
  690             for (j = 0; j < 64; j++)
 
  706             type34_predictor = 0.0;
 
  709             for (j = 0; j < 128; ) {
 
  714                                 for (k = 0; k < 5; k++) {
 
  715                                     if ((j + 2 * k) >= 128)
 
  726                                 for (k = 0; k < 5; k++)
 
  729                             for (k = 0; k < 5; k++)
 
  732                             for (k = 0; k < 10; k++)
 
  744                             f -= 
noise_samples[((sb + 1) * (j +5 * ch + 1)) & 127] * 9.0 / 40.0;
 
  755                                 for (k = 0; k < 5; k++) {
 
  767                                 for (k = 0; k < 5; k++)
 
  771                             for (k = 0; k < 5; k++)
 
  785                             for (k = 0; k < 3; k++)
 
  788                             for (k = 0; k < 3; k++)
 
  837                     for (k = 0; k < 
run && j + k < 128; k++) {
 
  841                             if (sign_bits[(j + k) / 8])
 
  850                     for (k = 0; k < 
run; k++)
 
  881     quantized_coeffs[0] = 
level;
 
  883     for (
i = 0; 
i < 7; ) {
 
  895         for (k = 1; k <= 
run; k++)
 
  928     for (sb = 0; sb < n; sb++)
 
  930             for (j = 0; j < 8; j++) {
 
  934                     for (k=0; k < 8; k++) {
 
  940                     for (k=0; k < 8; k++)
 
  947     for (sb = 0; sb < n; sb++)
 
  955                 for (j = 0; j < 8; j++)
 
  961     for (sb = 0; sb < n; sb++)
 
  963             for (j = 0; j < 8; j++) {
 
  985     for (
i = 1; 
i < n; 
i++)
 
  990             for (j = 0; j < (8 - 1); ) {
 
  997                 for (k = 1; k <= 
run; k++)
 
 1006         for (
i = 0; 
i < 8; 
i++)
 
 1100     if (nodes[0] && nodes[1] && nodes[2])
 
 1106     if (nodes[0] && nodes[1] && nodes[3])
 
 1121     int i, packet_bytes, sub_packet_size, sub_packets_D;
 
 1122     unsigned int next_index = 0;
 
 1163     for (
i = 0; 
i < 6; 
i++)
 
 1167     for (
i = 0; packet_bytes > 0; 
i++) {
 
 1184             if (next_index >= 
header.size)
 
 1192         sub_packet_size = ((
packet->size > 0xff) ? 1 : 0) + 
packet->size + 2;
 
 1197         if (sub_packet_size > packet_bytes) {
 
 1200             packet->size += packet_bytes - sub_packet_size;
 
 1203         packet_bytes -= sub_packet_size;
 
 1215         } 
else if (
packet->type == 13) {
 
 1216             for (j = 0; j < 6; j++)
 
 1218         } 
else if (
packet->type == 14) {
 
 1219             for (j = 0; j < 6; j++)
 
 1221         } 
else if (
packet->type == 15) {
 
 1249         ((sub_packet >= 16) ? (sub_packet - 16) : sub_packet);
 
 1261     int local_int_4, local_int_8, stereo_phase, local_int_10;
 
 1262     int local_int_14, stereo_exp, local_int_20, local_int_28;
 
 1276                     if(local_int_4 < q->group_size)
 
 1282                     local_int_4  += local_int_10;
 
 1283                     local_int_28 += (1 << local_int_8);
 
 1285                     local_int_4  += 8 * local_int_10;
 
 1286                     local_int_28 += (8 << local_int_8);
 
 1291             if (local_int_10 <= 2) {
 
 1296             while (
offset >= (local_int_10 - 1)) {
 
 1297                 offset       += (1 - (local_int_10 - 1));
 
 1298                 local_int_4  += local_int_10;
 
 1299                 local_int_28 += (1 << local_int_8);
 
 1306         local_int_14 = (
offset >> local_int_8);
 
 1329             if (stereo_phase < 0)
 
 1334             int sub_packet = (local_int_20 + local_int_28);
 
 1344                                           stereo_exp, stereo_phase);
 
 1360     for (
i = 0; 
i < 5; 
i++)
 
 1402         } 
else if (
type == 31) {
 
 1403             for (j = 0; j < 4; j++)
 
 1405         } 
else if (
type == 46) {
 
 1406             for (j = 0; j < 6; j++)
 
 1408             for (j = 0; j < 4; j++)
 
 1414     for (
i = 0, j = -1; 
i < 5; 
i++)
 
 1429     const double iscale = 2.0 * 
M_PI / 512.0;
 
 1451         for (
i = 0; 
i < 2; 
i++) {
 
 1457         for (
i = 0; 
i < 4; 
i++) {
 
 1473     const double iscale = 0.25 * 
M_PI;
 
 1475     for (ch = 0; ch < q->
channels; ch++) {
 
 1507     for (
i = 0; 
i < 4; 
i++)
 
 1520                 if (offset < q->frequency_range) {
 
 1568     int i, k, ch, sb_used, sub_sampling, dither_state = 0;
 
 1573     for (ch = 0; ch < q->
channels; ch++)
 
 1574         for (
i = 0; 
i < 8; 
i++)
 
 1575             for (k = sb_used; k < 
SBLIMIT; k++)
 
 1579         float *samples_ptr = q->
samples + ch;
 
 1581         for (
i = 0; 
i < 8; 
i++) {
 
 1594     for (ch = 0; ch < q->
channels; ch++)
 
 1619     float scale = 1.0f / 2.0f;
 
 1664         if (bytestream2_peek_be64(&gb) == (((uint64_t)
MKBETAG(
'f',
'r',
'm',
'a') << 32) |
 
 1665                                             (uint64_t)
MKBETAG(
'Q',
'D',
'M',
'2')))
 
 1677     size = bytestream2_get_be32(&gb);
 
 1686     if (bytestream2_get_be32(&gb) != 
MKBETAG(
'Q',
'D',
'C',
'A')) {
 
 1693     s->nb_channels = 
s->channels = bytestream2_get_be32(&gb);
 
 1702     avctx->
bit_rate = bytestream2_get_be32(&gb);
 
 1703     s->group_size = bytestream2_get_be32(&gb);
 
 1704     s->fft_size = bytestream2_get_be32(&gb);
 
 1705     s->checksum_size = bytestream2_get_be32(&gb);
 
 1706     if (
s->checksum_size >= 1
U << 28 || 
s->checksum_size <= 1) {
 
 1711     s->fft_order = 
av_log2(
s->fft_size) + 1;
 
 1714     if ((
s->fft_order < 7) || (
s->fft_order > 9)) {
 
 1720     s->group_order = 
av_log2(
s->group_size) + 1;
 
 1721     s->frame_size = 
s->group_size / 16; 
 
 1726     s->sub_sampling = 
s->fft_order - 7;
 
 1727     s->frequency_range = 255 / (1 << (2 - 
s->sub_sampling));
 
 1734     switch ((
s->sub_sampling * 2 + 
s->channels - 1)) {
 
 1735         case 0: 
tmp = 40; 
break;
 
 1736         case 1: 
tmp = 48; 
break;
 
 1737         case 2: 
tmp = 56; 
break;
 
 1738         case 3: 
tmp = 72; 
break;
 
 1739         case 4: 
tmp = 80; 
break;
 
 1740         case 5: 
tmp = 100;
break;
 
 1741         default: 
tmp=
s->sub_sampling; 
break;
 
 1748     s->cm_table_select = tmp_val;
 
 1751         s->coeff_per_sb_select = 0;
 
 1753         s->coeff_per_sb_select = 1;
 
 1755         s->coeff_per_sb_select = 2;
 
 1757     if (
s->fft_size != (1 << (
s->fft_order - 1))) {
 
 1816     for (ch = 0; ch < q->
channels; ch++) {
 
 1847                              int *got_frame_ptr, 
AVPacket *avpkt)
 
 1849     const uint8_t *buf = avpkt->
data;
 
 1850     int buf_size = avpkt->
size;
 
 1857     if(buf_size < s->checksum_size)
 
 1866     for (
i = 0; 
i < 16; 
i++) {
 
 1869         out += 
s->channels * 
s->frame_size;
 
 1874     return s->checksum_size;
 
  
#define SAMPLES_NEEDED_2(why)
static VLC fft_stereo_exp_vlc
static const int16_t fft_level_index_table[256]
MPADSPContext mpadsp
Synthesis filter.
static VLC vlc_tab_type30
static VLC vlc_tab_type34
int8_t quantized_coeffs[MPA_MAX_CHANNELS][10][8]
static int get_bits_left(GetBitContext *gb)
static int fix_coding_method_array(int sb, int channels, sb_int8_array coding_method)
Called while processing data from subpackets 11 and 12.
int sample_rate
samples per second
static void comp(unsigned char *dst, ptrdiff_t dst_stride, unsigned char *src, ptrdiff_t src_stride, int add)
int synth_buf_offset[MPA_MAX_CHANNELS]
static uint8_t random_dequant_index[256][5]
static int get_bits_count(const GetBitContext *s)
av_cold void ff_mpadsp_init(MPADSPContext *s)
static av_cold void qdm2_init_static_data(void)
Init static data (does not depend on specific file)
This structure describes decoded (raw) audio or video data.
int sub_packets_B
number of packets on 'B' list
static const int8_t coding_method_table[5][30]
const FFCodec ff_qdm2_decoder
int group_order
Parameters built from header parameters, do not change during playback.
static VLC vlc_tab_tone_level_idx_hi1
#define SOFTCLIP_THRESHOLD
static uint16_t softclip_table[HARDCLIP_THRESHOLD - SOFTCLIP_THRESHOLD+1]
float synth_buf[MPA_MAX_CHANNELS][512 *2]
QDM2SubPNode sub_packet_list_A[16]
list of all packets
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
av_cold int av_tx_init(AVTXContext **ctx, av_tx_fn *tx, enum AVTXType type, int inv, int len, const void *scale, uint64_t flags)
Initialize a transform context with the given configuration (i)MDCTs with an odd length are currently...
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static int qdm2_decode(QDM2Context *q, const uint8_t *in, int16_t *out)
static void process_subpacket_11(QDM2Context *q, QDM2SubPNode *node)
Process subpacket 11.
int has_errors
packet has errors
int checksum_size
size of data block, used also for checksum
int frame_size
size of data frame
static void skip_bits(GetBitContext *s, int n)
static int 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.
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static av_cold void init_noise_samples(void)
AVCodec p
The public AVCodec.
AVChannelLayout ch_layout
Audio channel layout.
float output_buffer[QDM2_MAX_FRAME_SIZE *MPA_MAX_CHANNELS *2]
static void build_sb_samples_from_noise(QDM2Context *q, int sb)
Build subband samples with noise weighted by q->tone_level.
static const struct twinvq_data tab
static void process_synthesis_subpackets(QDM2Context *q, QDM2SubPNode *list)
Process new subpackets for synthesis filter.
QDM2SubPNode sub_packet_list_C[16]
packets with errors?
const uint8_t * data
pointer to subpacket data (points to input data buffer, it's not a private copy)
static const int switchtable[23]
FFTCoefficient fft_coefs[1000]
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 Mos...
static av_cold void rnd_table_init(void)
static void qdm2_fft_init_coefficient(QDM2Context *q, int sub_packet, int offset, int duration, int channel, int exp, int phase)
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
float ff_mpa_synth_window_float[]
static int process_subpacket_9(QDM2Context *q, QDM2SubPNode *node)
Process subpacket 9, init quantized_coeffs with data from it.
unsigned int size
subpacket size
static int ff_thread_once(char *control, void(*routine)(void))
static void qdm2_decode_super_block(QDM2Context *q)
Decode superblock, fill packet lists.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static int qdm2_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt)
static void qdm2_fft_decode_tones(QDM2Context *q, int duration, GetBitContext *gb, int b)
#define FF_ARRAY_ELEMS(a)
static const float fft_tone_level_table[2][64]
const uint8_t * compressed_data
I/O data.
static const float dequant_1bit[2][3]
void(* av_tx_fn)(AVTXContext *s, void *out, void *in, ptrdiff_t stride)
Function pointer to a function to perform the transform.
#define FF_CODEC_DECODE_CB(func)
#define FIX_NOISE_IDX(noise_idx)
struct QDM2SubPNode * next
pointer to next packet in the list, NULL if leaf node
#define HARDCLIP_THRESHOLD
A node in the subpacket list.
#define QDM2_LIST_ADD(list, size, packet)
int do_synth_filter
used to perform or skip synthesis filter
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
static const uint8_t coeff_per_sb_for_dequant[3][30]
static int init_quantized_coeffs_elem0(int8_t *quantized_coeffs, GetBitContext *gb)
Init the first element of a channel in quantized_coeffs with data from packet 10 (quantized_coeffs[ch...
#define CODEC_LONG_NAME(str)
static const float fft_tone_envelope_table[4][31]
static QDM2SubPNode * qdm2_search_subpacket_type_in_list(QDM2SubPNode *list, int type)
Return node pointer to first packet of requested type in list.
float tone_level[MPA_MAX_CHANNELS][30][64]
Mixed temporary data used in decoding.
static int qdm2_get_vlc(GetBitContext *gb, const VLC *vlc, int flag, int depth)
int8_t coding_method[MPA_MAX_CHANNELS][30][64]
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
static av_cold int qdm2_decode_close(AVCodecContext *avctx)
static uint16_t qdm2_packet_checksum(const uint8_t *data, int length, int value)
QDM2 checksum.
static const uint8_t last_coeff[3]
static VLC fft_stereo_phase_vlc
int64_t bit_rate
the average bitrate
static unsigned int get_bits1(GetBitContext *s)
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining list
static void qdm2_fft_tone_synthesizer(QDM2Context *q, int sub_packet)
float sb_samples[MPA_MAX_CHANNELS][128][SBLIMIT]
AVComplexFloat complex[MPA_MAX_CHANNELS][256+1]
static av_always_inline int get_vlc2(GetBitContext *s, const VLCElem *table, int bits, int max_depth)
Parse a vlc code.
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
static av_always_inline int bytestream2_get_bytes_left(GetByteContext *g)
static void process_subpacket_12(QDM2Context *q, QDM2SubPNode *node)
Process subpacket 12.
#define AV_CODEC_CAP_CHANNEL_CONF
Codec should fill in channel configuration and samplerate instead of container.
QDM2SubPNode sub_packet_list_D[16]
DCT packets.
AVComplexFloat temp[MPA_MAX_CHANNELS][256]
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
int(* init)(AVBSFContext *ctx)
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
static void scale(int *out, const int *in, const int w, const int h, const int shift)
#define DECLARE_ALIGNED(n, t, v)
int8_t tone_level_idx_base[MPA_MAX_CHANNELS][30][8]
enum AVSampleFormat sample_fmt
audio sample format
#define MKBETAG(a, b, c, d)
static void qdm2_calculate_fft(QDM2Context *q, int channel, int sub_packet)
static av_cold int qdm2_decode_init(AVCodecContext *avctx)
Init parameters from codec extradata.
static const uint8_t header[24]
static av_always_inline int diff(const struct color_info *a, const struct color_info *b, const int trans_thresh)
int8_t tone_level_idx[MPA_MAX_CHANNELS][30][64]
#define QDM2_SB_USED(sub_sampling)
QDM2SubPacket sub_packets[16]
Packets and packet lists.
int fft_order
order of FFT (actually fftorder+1)
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
static uint8_t random_dequant_type24[128][3]
static const int vlc_stage3_values[60]
static VLC vlc_tab_tone_level_idx_mid
av_cold void av_tx_uninit(AVTXContext **ctx)
Frees a context and sets *ctx to NULL, does nothing when *ctx == NULL.
void av_channel_layout_default(AVChannelLayout *ch_layout, int nb_channels)
Get the default channel layout for a given number of channels.
static const uint8_t fft_subpackets[32]
static VLC vlc_tab_tone_level_idx_hi2
int coeff_per_sb_select
selector for "num. of coeffs. per subband" tables. Can be 0, 1, 2
int nb_samples
number of audio samples (per channel) described by this frame
#define i(width, name, range_min, range_max)
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
int cm_table_select
selector for "coding method" tables. Can be 0, 1 (from init: 0-4)
static void qdm2_decode_fft_packets(QDM2Context *q)
enum AVPacketSideDataType packet
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default value
@ AV_SAMPLE_FMT_S16
signed 16 bits
static void qdm2_decode_sub_packet_header(GetBitContext *gb, QDM2SubPacket *sub_packet)
Fill a QDM2SubPacket structure with packet type, size, and data pointer.
static av_cold void qdm2_init_vlc(void)
const char * name
Name of the codec implementation.
int sub_sampling
subsampling: 0=25%, 1=50%, 2=100% */
int nb_channels
Parameters from codec header, do not change during playback.
static const int8_t tone_level_idx_offset_table[30][4]
static VLC fft_level_exp_alt_vlc
static void average_quantized_coeffs(QDM2Context *q)
Replace 8 elements with their average value.
int8_t tone_level_idx_hi1[MPA_MAX_CHANNELS][3][8][8]
static void fill_tone_level_array(QDM2Context *q, int flag)
Related to synthesis filter Called by process_subpacket_10.
static void init_tone_level_dequantization(QDM2Context *q, GetBitContext *gb)
Related to synthesis filter, process data from packet 10 Init part of quantized_coeffs via function i...
void ff_mpa_synth_init_float(void)
static const float fft_tone_sample_table[4][16][5]
static const float type34_delta[10]
static const uint8_t coeff_per_sb_for_avg[3][30]
@ AV_TX_FLOAT_RDFT
Real to complex and complex to real DFTs.
int fft_size
size of FFT, in complex numbers
main external API structure.
static VLC fft_level_exp_vlc
static void qdm2_synthesis_filter(QDM2Context *q, int index)
int8_t sb_int8_array[2][30][64]
int noise_idx
index for dithering noise table
static float noise_samples[128]
void av_channel_layout_uninit(AVChannelLayout *channel_layout)
Free any allocated data in the channel layout and reset the channel count to 0.
int superblocktype_2_3
select fft tables and some algorithm based on superblock type
int channels
number of channels
Filter the word “frame” indicates either a video frame or a group of audio samples
QDM2SubPNode sub_packet_list_B[16]
FFT packets B are on list.
void ff_mpa_synth_filter_float(MPADSPContext *s, float *synth_buf_ptr, int *synth_buf_offset, float *window, int *dither_state, float *samples, ptrdiff_t incr, float *sb_samples)
int8_t tone_level_idx_hi2[MPA_MAX_CHANNELS][26]
static const float type30_dequant[8]
static int qdm2_get_se_vlc(const VLC *vlc, GetBitContext *gb, int depth)
static const int fft_cutoff_index_table[4][2]
static void process_subpacket_10(QDM2Context *q, QDM2SubPNode *node)
Process subpacket 10 if not null, else.
int fft_coefs_min_index[5]
FFTTone fft_tones[1000]
FFT and tones.
int8_t tone_level_idx_mid[MPA_MAX_CHANNELS][26][8]
#define avpriv_request_sample(...)
static void qdm2_fft_generate_tone(QDM2Context *q, FFTTone *tone)
int fft_coefs_max_index[5]
#define QDM2_MAX_FRAME_SIZE
This structure stores compressed data.
static VLC vlc_tab_fft_tone_offset[5]
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define SB_DITHERING_NOISE(sb, noise_idx)
static const uint8_t dequant_table[64]
int8_t tone_level_idx_temp[MPA_MAX_CHANNELS][30][64]
int group_size
size of frame group (16 frames per group)
static av_cold void softclip_table_init(void)
QDM2SubPacket * packet
packet
float samples[MPA_MAX_CHANNELS *MPA_FRAME_SIZE]