FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions | Variables
qdmc.c File Reference
#include <math.h>
#include <stddef.h>
#include <stdio.h>
#include "libavutil/channel_layout.h"
#include "libavutil/thread.h"
#include "avcodec.h"
#include "bytestream.h"
#include "get_bits.h"
#include "internal.h"
#include "fft.h"

Go to the source code of this file.

Data Structures

struct  QDMCTone
 
struct  QDMCContext
 

Macros

#define BITSTREAM_READER_LE
 
#define INIT_VLC_STATIC_LE(vlc, nb_bits, nb_codes,bits, bits_wrap, bits_size,codes, codes_wrap, codes_size,symbols, symbols_wrap, symbols_size,static_size)
 

Functions

static av_cold void qdmc_init_static_data (void)
 
static void make_noises (QDMCContext *s)
 
static av_cold int qdmc_decode_init (AVCodecContext *avctx)
 
static av_cold int qdmc_decode_close (AVCodecContext *avctx)
 
static int qdmc_get_vlc (GetBitContext *gb, VLC *table, int flag)
 
static int skip_label (QDMCContext *s, GetBitContext *gb)
 
static int read_noise_data (QDMCContext *s, GetBitContext *gb)
 
static void add_tone (QDMCContext *s, int group, int offset, int freq, int stereo_mode, int amplitude, int phase)
 
static int read_wave_data (QDMCContext *s, GetBitContext *gb)
 
static void lin_calc (QDMCContext *s, float amplitude, int node1, int node2, int index)
 
static void add_noise (QDMCContext *s, int ch, int current_subframe)
 
static void add_wave (QDMCContext *s, int offset, int freqs, int group, int stereo_mode, int amp, int phase)
 
static void add_wave0 (QDMCContext *s, int offset, int freqs, int stereo_mode, int amp, int phase)
 
static void add_waves (QDMCContext *s, int current_subframe)
 
static int decode_frame (QDMCContext *s, GetBitContext *gb, int16_t *out)
 
static av_cold void qdmc_flush (AVCodecContext *avctx)
 
static int qdmc_decode_frame (AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
 

Variables

static float sin_table [512]
 
static VLC vtable [6]
 
static const unsigned code_prefix []
 
static const float amplitude_tab [64]
 
static const uint16_t qdmc_nodes [112]
 
static const uint8_t noise_bands_size []
 
static const uint8_t noise_bands_selector []
 
static const uint8_t noise_value_bits []
 
static const uint8_t noise_value_symbols []
 
static const uint16_t noise_value_codes []
 
static const uint8_t noise_segment_length_bits []
 
static const uint8_t noise_segment_length_symbols []
 
static const uint16_t noise_segment_length_codes []
 
static const uint8_t freq_diff_bits []
 
static const uint32_t freq_diff_codes []
 
static const uint8_t amplitude_bits []
 
static const uint16_t amplitude_codes []
 
static const uint8_t amplitude_diff_bits []
 
static const uint8_t amplitude_diff_codes []
 
static const uint8_t phase_diff_bits []
 
static const uint8_t phase_diff_codes []
 
AVCodec ff_qdmc_decoder
 

Macro Definition Documentation

#define BITSTREAM_READER_LE

Definition at line 26 of file qdmc.c.

#define INIT_VLC_STATIC_LE (   vlc,
  nb_bits,
  nb_codes,
  bits,
  bits_wrap,
  bits_size,
  codes,
  codes_wrap,
  codes_size,
  symbols,
  symbols_wrap,
  symbols_size,
  static_size 
)
Value:
do { \
static VLC_TYPE table[static_size][2]; \
(vlc)->table = table; \
(vlc)->table_allocated = static_size; \
ff_init_vlc_sparse(vlc, nb_bits, nb_codes, \
bits, bits_wrap, bits_size, \
codes, codes_wrap, codes_size, \
symbols, symbols_wrap, symbols_size, \
} while (0)
int ff_init_vlc_sparse(VLC *vlc_arg, int nb_bits, int nb_codes, const void *bits, int bits_wrap, int bits_size, const void *codes, int codes_wrap, int codes_size, const void *symbols, int symbols_wrap, int symbols_size, int flags)
Definition: bitstream.c:268
static const uint16_t table[]
Definition: prosumer.c:203
#define INIT_VLC_LE
Definition: vlc.h:54
#define INIT_VLC_USE_NEW_STATIC
Definition: vlc.h:55
#define VLC_TYPE
Definition: vlc.h:24

Definition at line 192 of file qdmc.c.

Referenced by qdmc_init_static_data().

Function Documentation

static av_cold void qdmc_init_static_data ( void  )
static

Definition at line 208 of file qdmc.c.

Referenced by qdmc_decode_init().

static void make_noises ( QDMCContext s)
static

Definition at line 230 of file qdmc.c.

Referenced by qdmc_decode_init().

static av_cold int qdmc_decode_init ( AVCodecContext avctx)
static

Definition at line 252 of file qdmc.c.

static av_cold int qdmc_decode_close ( AVCodecContext avctx)
static

Definition at line 357 of file qdmc.c.

static int qdmc_get_vlc ( GetBitContext gb,
VLC table,
int  flag 
)
static

Definition at line 366 of file qdmc.c.

Referenced by read_noise_data(), and read_wave_data().

static int skip_label ( QDMCContext s,
GetBitContext gb 
)
static

Definition at line 388 of file qdmc.c.

Referenced by decode_frame().

static int read_noise_data ( QDMCContext s,
GetBitContext gb 
)
static

Definition at line 404 of file qdmc.c.

Referenced by decode_frame().

static void add_tone ( QDMCContext s,
int  group,
int  offset,
int  freq,
int  stereo_mode,
int  amplitude,
int  phase 
)
static

Definition at line 452 of file qdmc.c.

Referenced by read_wave_data().

static int read_wave_data ( QDMCContext s,
GetBitContext gb 
)
static

Definition at line 469 of file qdmc.c.

Referenced by decode_frame().

static void lin_calc ( QDMCContext s,
float  amplitude,
int  node1,
int  node2,
int  index 
)
static

Definition at line 531 of file qdmc.c.

Referenced by add_noise().

static void add_noise ( QDMCContext s,
int  ch,
int  current_subframe 
)
static

Definition at line 557 of file qdmc.c.

Referenced by decode_frame().

static void add_wave ( QDMCContext s,
int  offset,
int  freqs,
int  group,
int  stereo_mode,
int  amp,
int  phase 
)
static

Definition at line 591 of file qdmc.c.

Referenced by add_waves().

static void add_wave0 ( QDMCContext s,
int  offset,
int  freqs,
int  stereo_mode,
int  amp,
int  phase 
)
static

Definition at line 623 of file qdmc.c.

Referenced by add_waves().

static void add_waves ( QDMCContext s,
int  current_subframe 
)
static

Definition at line 641 of file qdmc.c.

Referenced by decode_frame().

static int decode_frame ( QDMCContext s,
GetBitContext gb,
int16_t *  out 
)
static

Definition at line 665 of file qdmc.c.

Referenced by qdmc_decode_frame().

static av_cold void qdmc_flush ( AVCodecContext avctx)
static

Definition at line 734 of file qdmc.c.

Referenced by qdmc_decode_frame().

static int qdmc_decode_frame ( AVCodecContext avctx,
void data,
int got_frame_ptr,
AVPacket avpkt 
)
static

Definition at line 744 of file qdmc.c.

Variable Documentation

float sin_table[512]
static

Definition at line 73 of file qdmc.c.

Referenced by add_wave(), add_wave0(), qdmc_decode_init(), and qdmc_init_static_data().

VLC vtable[6]
static

Definition at line 74 of file qdmc.c.

const unsigned code_prefix[]
static
Initial value:
= {
0x0, 0x1, 0x2, 0x3, 0x4, 0x6, 0x8, 0xA,
0xC, 0x10, 0x14, 0x18, 0x1C, 0x24, 0x2C, 0x34,
0x3C, 0x4C, 0x5C, 0x6C, 0x7C, 0x9C, 0xBC, 0xDC,
0xFC, 0x13C, 0x17C, 0x1BC, 0x1FC, 0x27C, 0x2FC, 0x37C,
0x3FC, 0x4FC, 0x5FC, 0x6FC, 0x7FC, 0x9FC, 0xBFC, 0xDFC,
0xFFC, 0x13FC, 0x17FC, 0x1BFC, 0x1FFC, 0x27FC, 0x2FFC, 0x37FC,
0x3FFC, 0x4FFC, 0x5FFC, 0x6FFC, 0x7FFC, 0x9FFC, 0xBFFC, 0xDFFC,
0xFFFC, 0x13FFC, 0x17FFC, 0x1BFFC, 0x1FFFC, 0x27FFC, 0x2FFFC, 0x37FFC,
0x3FFFC
}

Definition at line 76 of file qdmc.c.

Referenced by build_table(), and qdmc_get_vlc().

const float amplitude_tab[64]
static
Initial value:
= {
1.18750000f, 1.68359380f, 2.37500000f, 3.36718750f, 4.75000000f,
6.73437500f, 9.50000000f, 13.4687500f, 19.0000000f, 26.9375000f,
38.0000000f, 53.8750000f, 76.0000000f, 107.750000f, 152.000000f,
215.500000f, 304.000000f, 431.000000f, 608.000000f, 862.000000f,
1216.00000f, 1724.00000f, 2432.00000f, 3448.00000f, 4864.00000f,
6896.00000f, 9728.00000f, 13792.0000f, 19456.0000f, 27584.0000f,
38912.0000f, 55168.0000f, 77824.0000f, 110336.000f, 155648.000f,
220672.000f, 311296.000f, 441344.000f, 622592.000f, 882688.000f,
1245184.00f, 1765376.00f, 2490368.00f, 3530752.00f, 4980736.00f,
7061504.00f, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
}

Definition at line 88 of file qdmc.c.

Referenced by add_noise(), add_wave(), and add_wave0().

const uint16_t qdmc_nodes[112]
static
Initial value:
= {
0, 1, 2, 4, 6, 8, 12, 16, 24, 32, 48, 56, 64,
80, 96, 120, 144, 176, 208, 240, 256,
0, 2, 4, 8, 16, 24, 32, 48, 56, 64, 80, 104,
128, 160, 208, 256, 0, 0, 0, 0, 0,
0, 2, 4, 8, 16, 32, 48, 64, 80, 112, 160, 208,
256, 0, 0, 0, 0, 0, 0, 0, 0,
0, 4, 8, 16, 32, 48, 64, 96, 144, 208, 256,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 4, 16, 32, 64, 256, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
}

Definition at line 101 of file qdmc.c.

Referenced by add_noise(), and make_noises().

const uint8_t noise_bands_size[]
static
Initial value:
= {
19, 14, 11, 9, 4, 2, 0
}

Definition at line 114 of file qdmc.c.

Referenced by add_noise(), make_noises(), and read_noise_data().

const uint8_t noise_bands_selector[]
static
Initial value:
= {
4, 3, 2, 1, 0, 0, 0,
}

Definition at line 118 of file qdmc.c.

Referenced by qdmc_decode_init().

const uint8_t noise_value_bits[]
static
Initial value:
= {
12, 7, 9, 7, 10, 9, 11, 9, 9, 2, 9, 9, 9, 9,
9, 3, 9, 10, 10, 12, 2, 3, 3, 5, 5, 6, 7,
}

Definition at line 122 of file qdmc.c.

Referenced by qdmc_init_static_data().

const uint8_t noise_value_symbols[]
static
Initial value:
= {
0, 10, 11, 12, 13, 14, 15, 16, 18, 1, 20, 22, 24,
26, 28, 2, 30, 32, 34, 36, 3, 4, 5, 6, 7, 8, 9,
}

Definition at line 127 of file qdmc.c.

Referenced by qdmc_init_static_data().

const uint16_t noise_value_codes[]
static
Initial value:
= {
0xC7A, 0x002, 0x0FA, 0x03A, 0x35A, 0x1C2, 0x07A, 0x1FA,
0x17A, 0x000, 0x0DA, 0x142, 0x0C2, 0x042, 0x1DA, 0x001,
0x05A, 0x15A, 0x27A, 0x47A, 0x003, 0x005, 0x006, 0x012,
0x00A, 0x022, 0x01A,
}

Definition at line 132 of file qdmc.c.

Referenced by qdmc_init_static_data().

const uint8_t noise_segment_length_bits[]
static
Initial value:
= {
10, 8, 5, 1, 2, 4, 4, 4, 6, 7, 9, 10,
}

Definition at line 139 of file qdmc.c.

Referenced by qdmc_init_static_data().

const uint8_t noise_segment_length_symbols[]
static
Initial value:
= {
0, 13, 17, 1, 2, 3, 4, 5, 6, 7, 8, 9,
}

Definition at line 143 of file qdmc.c.

Referenced by qdmc_init_static_data().

const uint16_t noise_segment_length_codes[]
static
Initial value:
= {
0x30B, 0x8B, 0x1B, 0x0, 0x1, 0x3, 0x7, 0xF, 0x2b, 0x4B, 0xB, 0x10B,
}

Definition at line 147 of file qdmc.c.

Referenced by qdmc_init_static_data().

const uint8_t freq_diff_bits[]
static
Initial value:
= {
18, 2, 4, 4, 5, 4, 4, 5, 5, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 6,
7, 6, 6, 6, 7, 7, 7, 7, 7, 8, 9, 9, 8, 9, 11, 11, 12, 12, 13, 12,
14, 15, 18, 16, 17,
}

Definition at line 151 of file qdmc.c.

Referenced by qdmc_init_static_data().

const uint32_t freq_diff_codes[]
static
Initial value:
= {
0x2AD46, 0x1, 0x0, 0x3, 0xC, 0xA, 0x7, 0x18, 0x12, 0xE, 0x4, 0x16,
0xF, 0x1C, 0x8, 0x22, 0x26, 0x2, 0x3B, 0x34, 0x74, 0x1F, 0x14, 0x2B,
0x1B, 0x3F, 0x28, 0x54, 0x6, 0x4B, 0xB, 0x68, 0xE8, 0x46, 0xC6, 0x1E8,
0x146, 0x346, 0x546, 0x746, 0x1D46, 0xF46, 0xD46, 0x6D46, 0xAD46, 0x2D46,
0x1AD46,
}

Definition at line 157 of file qdmc.c.

Referenced by qdmc_init_static_data().

const uint8_t amplitude_bits[]
static
Initial value:
= {
13, 7, 8, 9, 10, 10, 10, 10, 10, 9, 8, 7, 6,
5, 4, 3, 3, 2, 3, 3, 4, 5, 7, 8, 9, 11, 12, 13,
}

Definition at line 165 of file qdmc.c.

Referenced by qdmc_init_static_data().

const uint16_t amplitude_codes[]
static
Initial value:
= {
0x1EC6, 0x6, 0xC2, 0x142, 0x242, 0x246, 0xC6, 0x46, 0x42, 0x146, 0xA2,
0x62, 0x26, 0x16, 0xE, 0x5, 0x4, 0x3, 0x0, 0x1, 0xA, 0x12, 0x2, 0x22,
0x1C6, 0x2C6, 0x6C6, 0xEC6,
}

Definition at line 170 of file qdmc.c.

Referenced by qdmc_init_static_data().

const uint8_t amplitude_diff_bits[]
static
Initial value:
= {
8, 2, 1, 3, 4, 5, 6, 7, 8,
}

Definition at line 176 of file qdmc.c.

Referenced by qdmc_init_static_data().

const uint8_t amplitude_diff_codes[]
static
Initial value:
= {
0xFE, 0x0, 0x1, 0x2, 0x6, 0xE, 0x1E, 0x3E, 0x7E,
}

Definition at line 180 of file qdmc.c.

Referenced by qdmc_init_static_data().

const uint8_t phase_diff_bits[]
static
Initial value:
= {
6, 2, 2, 4, 4, 6, 5, 4, 2,
}

Definition at line 184 of file qdmc.c.

Referenced by qdmc_init_static_data().

const uint8_t phase_diff_codes[]
static
Initial value:
= {
0x35, 0x2, 0x0, 0x1, 0xD, 0x15, 0x5, 0x9, 0x3,
}

Definition at line 188 of file qdmc.c.

Referenced by qdmc_init_static_data().

AVCodec ff_qdmc_decoder
Initial value:
= {
.name = "qdmc",
.long_name = NULL_IF_CONFIG_SMALL("QDesign Music Codec 1"),
.priv_data_size = sizeof(QDMCContext),
.capabilities = AV_CODEC_CAP_DR1,
}
static void flush(AVCodecContext *avctx)
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
Definition: decode_audio.c:42
static av_cold int qdmc_decode_close(AVCodecContext *avctx)
Definition: qdmc.c:357
static av_cold void qdmc_flush(AVCodecContext *avctx)
Definition: qdmc.c:734
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:186
static av_cold int qdmc_decode_init(AVCodecContext *avctx)
Definition: qdmc.c:252
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
Definition: avcodec.h:968
static int qdmc_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
Definition: qdmc.c:744

Definition at line 777 of file qdmc.c.