FFmpeg
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
 

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 qdmc_hufftab [][2]
 
static const uint8_t huff_sizes []
 
static const uint8_t huff_bits []
 
const AVCodec ff_qdmc_decoder
 

Macro Definition Documentation

◆ BITSTREAM_READER_LE

#define BITSTREAM_READER_LE

Definition at line 26 of file qdmc.c.

Function Documentation

◆ qdmc_init_static_data()

static av_cold void qdmc_init_static_data ( void  )
static

Definition at line 163 of file qdmc.c.

Referenced by qdmc_decode_init().

◆ make_noises()

static void make_noises ( QDMCContext s)
static

Definition at line 183 of file qdmc.c.

Referenced by qdmc_decode_init().

◆ qdmc_decode_init()

static av_cold int qdmc_decode_init ( AVCodecContext avctx)
static

Definition at line 205 of file qdmc.c.

◆ qdmc_decode_close()

static av_cold int qdmc_decode_close ( AVCodecContext avctx)
static

Definition at line 310 of file qdmc.c.

◆ qdmc_get_vlc()

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

Definition at line 319 of file qdmc.c.

Referenced by read_noise_data(), and read_wave_data().

◆ skip_label()

static int skip_label ( QDMCContext s,
GetBitContext gb 
)
static

Definition at line 339 of file qdmc.c.

Referenced by decode_frame().

◆ read_noise_data()

static int read_noise_data ( QDMCContext s,
GetBitContext gb 
)
static

Definition at line 355 of file qdmc.c.

Referenced by decode_frame().

◆ add_tone()

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

Definition at line 403 of file qdmc.c.

Referenced by read_wave_data().

◆ read_wave_data()

static int read_wave_data ( QDMCContext s,
GetBitContext gb 
)
static

Definition at line 420 of file qdmc.c.

Referenced by decode_frame().

◆ lin_calc()

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

Definition at line 482 of file qdmc.c.

Referenced by add_noise().

◆ add_noise()

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

Definition at line 508 of file qdmc.c.

Referenced by decode_frame().

◆ add_wave()

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

Definition at line 542 of file qdmc.c.

Referenced by add_waves().

◆ add_wave0()

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

Definition at line 574 of file qdmc.c.

Referenced by add_waves().

◆ add_waves()

static void add_waves ( QDMCContext s,
int  current_subframe 
)
static

Definition at line 592 of file qdmc.c.

Referenced by decode_frame().

◆ decode_frame()

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

Definition at line 616 of file qdmc.c.

Referenced by qdmc_decode_frame().

◆ qdmc_flush()

static av_cold void qdmc_flush ( AVCodecContext avctx)
static

Definition at line 685 of file qdmc.c.

Referenced by qdmc_decode_frame().

◆ qdmc_decode_frame()

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

Definition at line 695 of file qdmc.c.

Variable Documentation

◆ sin_table

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().

◆ vtable

VLC vtable[6]
static

Definition at line 74 of file qdmc.c.

Referenced by qdmc_init_static_data(), read_noise_data(), and read_wave_data().

◆ code_prefix

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().

◆ amplitude_tab

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().

◆ qdmc_nodes

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().

◆ noise_bands_size

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().

◆ noise_bands_selector

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().

◆ qdmc_hufftab

const uint8_t qdmc_hufftab[][2]
static

Definition at line 122 of file qdmc.c.

Referenced by qdmc_init_static_data().

◆ huff_sizes

const uint8_t huff_sizes[]
static
Initial value:
= {
27, 12, 28, 47, 9, 9
}

Definition at line 155 of file qdmc.c.

Referenced by qdmc_init_static_data().

◆ huff_bits

const uint8_t huff_bits[]
static
Initial value:
= {
12, 10, 12, 12, 8, 6
}

Definition at line 159 of file qdmc.c.

Referenced by qdmc_init_static_data().

◆ ff_qdmc_decoder

const AVCodec ff_qdmc_decoder
Initial value:
= {
.name = "qdmc",
.long_name = NULL_IF_CONFIG_SMALL("QDesign Music Codec 1"),
.priv_data_size = sizeof(QDMCContext),
.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
}

Definition at line 728 of file qdmc.c.

FF_CODEC_CAP_INIT_THREADSAFE
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
Definition: internal.h:41
init
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:31
qdmc_decode_frame
static int qdmc_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
Definition: qdmc.c:695
qdmc_decode_close
static av_cold int qdmc_decode_close(AVCodecContext *avctx)
Definition: qdmc.c:310
decode
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
Definition: decode_audio.c:71
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
qdmc_decode_init
static av_cold int qdmc_decode_init(AVCodecContext *avctx)
Definition: qdmc.c:205
QDMCContext
Definition: qdmc.c:45
flush
static void flush(AVCodecContext *avctx)
Definition: aacdec_template.c:592
AV_CODEC_CAP_CHANNEL_CONF
#define AV_CODEC_CAP_CHANNEL_CONF
Codec should fill in channel configuration and samplerate instead of container.
Definition: codec.h:104
AV_CODEC_CAP_DR1
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition: codec.h:52
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:117
AV_CODEC_ID_QDMC
@ AV_CODEC_ID_QDMC
Definition: codec_id.h:471
qdmc_flush
static av_cold void qdmc_flush(AVCodecContext *avctx)
Definition: qdmc.c:685