FFmpeg
Functions | Variables
twinvqdec.c File Reference
#include <math.h>
#include <stdint.h>
#include "libavutil/channel_layout.h"
#include "avcodec.h"
#include "get_bits.h"
#include "internal.h"
#include "twinvq.h"
#include "metasound_data.h"
#include "twinvq_data.h"

Go to the source code of this file.

Functions

static int very_broken_op (int a, int b)
 Evaluate a * b / 400 rounded to the nearest integer. More...
 
static void add_peak (int period, int width, const float *shape, float ppc_gain, float *speech, int len)
 Sum to data a periodic peak of a given period, width and shape. More...
 
static void decode_ppc (TwinVQContext *tctx, int period_coef, int g_coef, const float *shape, float *speech)
 
static void dec_bark_env (TwinVQContext *tctx, const uint8_t *in, int use_hist, int ch, float *out, float gain, enum TwinVQFrameType ftype)
 
static void read_cb_data (TwinVQContext *tctx, GetBitContext *gb, uint8_t *dst, enum TwinVQFrameType ftype)
 
static int twinvq_read_bitstream (AVCodecContext *avctx, TwinVQContext *tctx, const uint8_t *buf, int buf_size)
 
static av_cold int twinvq_decode_init (AVCodecContext *avctx)
 

Variables

static const TwinVQModeTab mode_08_08
 
static const TwinVQModeTab mode_11_08
 
static const TwinVQModeTab mode_11_10
 
static const TwinVQModeTab mode_16_16
 
static const TwinVQModeTab mode_22_20
 
static const TwinVQModeTab mode_22_24
 
static const TwinVQModeTab mode_22_32
 
static const TwinVQModeTab mode_44_40
 
static const TwinVQModeTab mode_44_48
 
const AVCodec ff_twinvq_decoder
 

Function Documentation

◆ very_broken_op()

static int very_broken_op ( int  a,
int  b 
)
static

Evaluate a * b / 400 rounded to the nearest integer.

When, for example, a * b == 200 and the nearest integer is ill-defined, use a table to emulate the following broken float-based implementation used by the binary decoder:

static int very_broken_op(int a, int b)
{
static float test; // Ugh, force gcc to do the division first...
test = a / 400.0;
return b * test + 0.5;
}
Note
if this function is replaced by just ROUNDED_DIV(a * b, 400.0), the stddev between the original file (before encoding with Yamaha encoder) and the decoded output increases, which leads one to believe that the encoder expects exactly this broken calculation.

Definition at line 134 of file twinvqdec.c.

Referenced by add_peak().

◆ add_peak()

static void add_peak ( int  period,
int  width,
const float *  shape,
float  ppc_gain,
float *  speech,
int  len 
)
static

Sum to data a periodic peak of a given period, width and shape.

Parameters
periodthe period of the peak divided by 400.0

Definition at line 155 of file twinvqdec.c.

Referenced by decode_ppc().

◆ decode_ppc()

static void decode_ppc ( TwinVQContext tctx,
int  period_coef,
int  g_coef,
const float *  shape,
float *  speech 
)
static

Definition at line 179 of file twinvqdec.c.

Referenced by twinvq_decode_init().

◆ dec_bark_env()

static void dec_bark_env ( TwinVQContext tctx,
const uint8_t *  in,
int  use_hist,
int  ch,
float *  out,
float  gain,
enum TwinVQFrameType  ftype 
)
static

Definition at line 211 of file twinvqdec.c.

Referenced by twinvq_decode_init().

◆ read_cb_data()

static void read_cb_data ( TwinVQContext tctx,
GetBitContext gb,
uint8_t *  dst,
enum TwinVQFrameType  ftype 
)
static

Definition at line 239 of file twinvqdec.c.

Referenced by twinvq_read_bitstream().

◆ twinvq_read_bitstream()

static int twinvq_read_bitstream ( AVCodecContext avctx,
TwinVQContext tctx,
const uint8_t *  buf,
int  buf_size 
)
static

Definition at line 252 of file twinvqdec.c.

Referenced by twinvq_decode_init().

◆ twinvq_decode_init()

static av_cold int twinvq_decode_init ( AVCodecContext avctx)
static

Definition at line 320 of file twinvqdec.c.

Variable Documentation

◆ mode_08_08

const TwinVQModeTab mode_08_08
static
Initial value:
= {
{
{ 8, bark_tab_s08_64, 10, tab.fcb08s, 1, 5, tab.cb0808s0, tab.cb0808s1, 18 },
{ 2, bark_tab_m08_256, 20, tab.fcb08m, 2, 5, tab.cb0808m0, tab.cb0808m1, 16 },
},
512, 12, ff_metasound_lsp8, 1, 5, 3, 3, tab.shape08, 8, 28, 20, 6, 40
}

Definition at line 33 of file twinvqdec.c.

Referenced by twinvq_decode_init().

◆ mode_11_08

const TwinVQModeTab mode_11_08
static
Initial value:
= {
{
{ 8, bark_tab_s11_64, 10, tab.fcb11s, 1, 5, tab.cb1108s0, tab.cb1108s1, 29 },
{ 2, bark_tab_m11_256, 20, tab.fcb11m, 2, 5, tab.cb1108m0, tab.cb1108m1, 24 },
},
512, 16, ff_metasound_lsp11, 1, 6, 4, 3, tab.shape11, 9, 36, 30, 7, 90
}

Definition at line 42 of file twinvqdec.c.

Referenced by twinvq_decode_init().

◆ mode_11_10

const TwinVQModeTab mode_11_10
static
Initial value:
= {
{
{ 8, bark_tab_s11_64, 10, tab.fcb11s, 1, 5, tab.cb1110s0, tab.cb1110s1, 21 },
{ 2, bark_tab_m11_256, 20, tab.fcb11m, 2, 5, tab.cb1110m0, tab.cb1110m1, 18 },
},
512, 16, ff_metasound_lsp11, 1, 6, 4, 3, tab.shape11, 9, 36, 30, 7, 90
}

Definition at line 51 of file twinvqdec.c.

Referenced by twinvq_decode_init().

◆ mode_16_16

const TwinVQModeTab mode_16_16
static
Initial value:
= {
{
{ 8, bark_tab_s16_128, 10, tab.fcb16s, 1, 5, tab.cb1616s0, tab.cb1616s1, 16 },
{ 2, bark_tab_m16_512, 20, tab.fcb16m, 2, 5, tab.cb1616m0, tab.cb1616m1, 15 },
},
1024, 16, ff_metasound_lsp16, 1, 6, 4, 3, tab.shape16, 9, 56, 60, 7, 180
}

Definition at line 60 of file twinvqdec.c.

Referenced by twinvq_decode_init().

◆ mode_22_20

const TwinVQModeTab mode_22_20
static
Initial value:
= {
{
},
1024, 16, ff_metasound_lsp22, 1, 6, 4, 3, tab.shape22_1, 9, 56, 36, 7, 144
}

Definition at line 69 of file twinvqdec.c.

Referenced by twinvq_decode_init().

◆ mode_22_24

const TwinVQModeTab mode_22_24
static
Initial value:
= {
{
},
1024, 16, ff_metasound_lsp22, 1, 6, 4, 3, tab.shape22_1, 9, 56, 36, 7, 144
}

Definition at line 78 of file twinvqdec.c.

Referenced by twinvq_decode_init().

◆ mode_22_32

const TwinVQModeTab mode_22_32
static
Initial value:
= {
{
},
512, 16, tab.lsp22_2, 1, 6, 4, 4, tab.shape22_2, 9, 56, 36, 7, 72
}

Definition at line 87 of file twinvqdec.c.

Referenced by twinvq_decode_init().

◆ mode_44_40

const TwinVQModeTab mode_44_40
static
Initial value:
= {
{
{ 16, bark_tab_s44_128, 10, tab.fcb44s, 1, 6, tab.cb4440s0, tab.cb4440s1, 18 },
{ 4, bark_tab_m44_512, 20, tab.fcb44m, 2, 6, tab.cb4440m0, tab.cb4440m1, 17 },
},
2048, 20, ff_metasound_lsp44, 1, 6, 4, 4, tab.shape44, 9, 84, 54, 7, 432
}

Definition at line 96 of file twinvqdec.c.

Referenced by twinvq_decode_init().

◆ mode_44_48

const TwinVQModeTab mode_44_48
static
Initial value:
= {
{
{ 16, bark_tab_s44_128, 10, tab.fcb44s, 1, 6, tab.cb4448s0, tab.cb4448s1, 15 },
{ 4, bark_tab_m44_512, 20, tab.fcb44m, 2, 6, tab.cb4448m0, tab.cb4448m1, 14 },
},
2048, 20, ff_metasound_lsp44, 1, 6, 4, 4, tab.shape44, 9, 84, 54, 7, 432
}

Definition at line 105 of file twinvqdec.c.

Referenced by twinvq_decode_init().

◆ ff_twinvq_decoder

const AVCodec ff_twinvq_decoder
Initial value:
= {
.name = "twinvq",
.long_name = NULL_IF_CONFIG_SMALL("VQF TwinVQ"),
.priv_data_size = sizeof(TwinVQContext),
.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
}

Definition at line 417 of file twinvqdec.c.

twinvq_data::cb0808s1
int16_t cb0808s1[1152]
Definition: twinvq_data.h:146
AV_SAMPLE_FMT_FLTP
@ AV_SAMPLE_FMT_FLTP
float, planar
Definition: samplefmt.h:69
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
twinvq_data::fcb08m
int16_t fcb08m[320]
Definition: twinvq_data.h:139
twinvq_data::fcb22s_2
int16_t fcb22s_2[640]
Definition: twinvq_data.h:202
twinvq_data::cb1616l0
int16_t cb1616l0[1024]
Definition: twinvq_data.h:174
twinvq_data::cb1108s0
int16_t cb1108s0[1856]
Definition: twinvq_data.h:154
twinvq_data::cb2220m1
int16_t cb2220m1[1088]
Definition: twinvq_data.h:184
ff_metasound_lsp22
const float ff_metasound_lsp22[]
Definition: metasound_data.c:12520
bark_tab_m22_256
static const uint16_t bark_tab_m22_256[]
Definition: twinvq_data.h:95
twinvq_data::cb4440s1
int16_t cb4440s1[1152]
Definition: twinvq_data.h:218
sample_fmts
static enum AVSampleFormat sample_fmts[]
Definition: adpcmenc.c:953
bark_tab_s44_128
static const uint16_t bark_tab_s44_128[]
Definition: twinvq_data.h:126
twinvq_decode_init
static av_cold int twinvq_decode_init(AVCodecContext *avctx)
Definition: twinvqdec.c:320
twinvq_data::cb0808l0
int16_t cb0808l0[1088]
Definition: twinvq_data.h:143
twinvq_data::cb2232l1
int16_t cb2232l1[768]
Definition: twinvq_data.h:207
twinvq_data::cb4448s1
int16_t cb4448s1[960]
Definition: twinvq_data.h:230
twinvq_data::fcb11l
int16_t fcb11l[640]
Definition: twinvq_data.h:157
b
#define b
Definition: input.c:41
twinvq_data::cb4440m0
int16_t cb4440m0[1088]
Definition: twinvq_data.h:215
twinvq_data::cb2232s0
int16_t cb2232s0[704]
Definition: twinvq_data.h:210
twinvq_data::lsp22_2
float lsp22_2[1312]
Definition: twinvq_data.h:204
bark_tab_s16_128
static const uint16_t bark_tab_s16_128[]
Definition: twinvq_data.h:118
twinvq_data::cb1616s1
int16_t cb1616s1[1024]
Definition: twinvq_data.h:179
twinvq_data::cb1110s1
int16_t cb1110s1[1344]
Definition: twinvq_data.h:167
twinvq_data::cb2224s1
int16_t cb2224s1[960]
Definition: twinvq_data.h:198
twinvq_data::fcb22s_1
int16_t fcb22s_1[640]
Definition: twinvq_data.h:190
twinvq_data::fcb44s
int16_t fcb44s[640]
Definition: twinvq_data.h:222
twinvq_data::cb0808m0
int16_t cb0808m0[1024]
Definition: twinvq_data.h:147
twinvq_data::cb1108l1
int16_t cb1108l1[1728]
Definition: twinvq_data.h:151
twinvq_data::cb2224s0
int16_t cb2224s0[960]
Definition: twinvq_data.h:197
tab
static const struct twinvq_data tab
Definition: twinvq_data.h:10345
twinvq_data::cb0808s0
int16_t cb0808s0[1152]
Definition: twinvq_data.h:145
twinvq_data::cb2232l0
int16_t cb2232l0[768]
Definition: twinvq_data.h:206
bark_tab_l08_512
static const uint16_t bark_tab_l08_512[]
Definition: twinvq_data.h:41
very_broken_op
static int very_broken_op(int a, int b)
Evaluate a * b / 400 rounded to the nearest integer.
Definition: twinvqdec.c:134
ff_twinvq_decode_frame
int ff_twinvq_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
Definition: twinvq.c:476
twinvq_data::fcb08l
int16_t fcb08l[640]
Definition: twinvq_data.h:138
bark_tab_m16_512
static const uint16_t bark_tab_m16_512[]
Definition: twinvq_data.h:90
twinvq_data::fcb08s
int16_t fcb08s[320]
Definition: twinvq_data.h:140
twinvq_data::cb1108m1
int16_t cb1108m1[1536]
Definition: twinvq_data.h:153
ff_metasound_lsp44
const float ff_metasound_lsp44[]
Definition: metasound_data.c:12687
twinvq_data::fcb11s
int16_t fcb11s[320]
Definition: twinvq_data.h:159
twinvq_data::fcb16m
int16_t fcb16m[320]
Definition: twinvq_data.h:170
decode
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
Definition: decode_audio.c:71
bark_tab_l16_1024
static const uint16_t bark_tab_l16_1024[]
Definition: twinvq_data.h:53
ff_metasound_lsp16
const float ff_metasound_lsp16[]
Definition: metasound_data.c:12341
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
twinvq_data::cb1616m1
int16_t cb1616m1[960]
Definition: twinvq_data.h:177
twinvq_data::cb4448l1
int16_t cb4448l1[896]
Definition: twinvq_data.h:226
twinvq_data::cb4448m1
int16_t cb4448m1[896]
Definition: twinvq_data.h:228
twinvq_data::cb4440m1
int16_t cb4440m1[1088]
Definition: twinvq_data.h:216
twinvq_data::cb1108l0
int16_t cb1108l0[1728]
Definition: twinvq_data.h:150
twinvq_data::cb2220l0
int16_t cb2220l0[1152]
Definition: twinvq_data.h:181
ff_metasound_lsp11
const float ff_metasound_lsp11[]
Definition: metasound_data.c:12174
ff_twinvq_decode_close
av_cold int ff_twinvq_decode_close(AVCodecContext *avctx)
Definition: twinvq.c:741
twinvq_data::cb1110m1
int16_t cb1110m1[1152]
Definition: twinvq_data.h:165
twinvq_data::cb4440l1
int16_t cb4440l1[1088]
Definition: twinvq_data.h:214
twinvq_data::cb2224l0
int16_t cb2224l0[960]
Definition: twinvq_data.h:193
twinvq_data::fcb11m
int16_t fcb11m[320]
Definition: twinvq_data.h:158
twinvq_data::shape22_1
int16_t shape22_1[1152]
Definition: twinvq_data.h:191
twinvq_data::shape22_2
int16_t shape22_2[1152]
Definition: twinvq_data.h:203
twinvq_data::fcb44l
int16_t fcb44l[640]
Definition: twinvq_data.h:220
twinvq_data::cb4440s0
int16_t cb4440s0[1152]
Definition: twinvq_data.h:217
twinvq_data::fcb44m
int16_t fcb44m[640]
Definition: twinvq_data.h:221
twinvq_data::cb1616s0
int16_t cb1616s0[1024]
Definition: twinvq_data.h:178
twinvq_data::cb1110l1
int16_t cb1110l1[1280]
Definition: twinvq_data.h:163
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
twinvq_data::fcb22m_1
int16_t fcb22m_1[640]
Definition: twinvq_data.h:189
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_SAMPLE_FMT_NONE
@ AV_SAMPLE_FMT_NONE
Definition: samplefmt.h:59
bark_tab_s11_64
static const uint16_t bark_tab_s11_64[]
Definition: twinvq_data.h:114
twinvq_data::shape11
int16_t shape11[1280]
Definition: twinvq_data.h:160
twinvq_data::cb1616m0
int16_t cb1616m0[960]
Definition: twinvq_data.h:176
twinvq_data::cb2224m1
int16_t cb2224m1[896]
Definition: twinvq_data.h:196
a
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
Definition: undefined.txt:41
twinvq_data::cb1616l1
int16_t cb1616l1[1024]
Definition: twinvq_data.h:175
twinvq_data::cb4440l0
int16_t cb4440l0[1088]
Definition: twinvq_data.h:213
bark_tab_m44_512
static const uint16_t bark_tab_m44_512[]
Definition: twinvq_data.h:105
twinvq_data::cb1108s1
int16_t cb1108s1[1856]
Definition: twinvq_data.h:155
bark_tab_l44_2048
static const uint16_t bark_tab_l44_2048[]
Definition: twinvq_data.h:73
twinvq_data::shape16
int16_t shape16[1920]
Definition: twinvq_data.h:172
bark_tab_m08_256
static const uint16_t bark_tab_m08_256[]
Definition: twinvq_data.h:80
twinvq_data::cb2224m0
int16_t cb2224m0[896]
Definition: twinvq_data.h:195
twinvq_data::cb4448s0
int16_t cb4448s0[960]
Definition: twinvq_data.h:229
twinvq_data::fcb16l
int16_t fcb16l[640]
Definition: twinvq_data.h:169
twinvq_data::cb1110l0
int16_t cb1110l0[1280]
Definition: twinvq_data.h:162
AVSampleFormat
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:58
twinvq_data::cb4448l0
int16_t cb4448l0[896]
Definition: twinvq_data.h:225
twinvq_data::cb2220m0
int16_t cb2220m0[1088]
Definition: twinvq_data.h:183
ff_metasound_lsp8
const float ff_metasound_lsp8[]
Definition: metasound_data.c:12108
twinvq_data::cb2232s1
int16_t cb2232s1[704]
Definition: twinvq_data.h:211
twinvq_data::fcb22l_2
int16_t fcb22l_2[512]
Definition: twinvq_data.h:200
bark_tab_l22_512
static const uint16_t bark_tab_l22_512[]
Definition: twinvq_data.h:66
twinvq_data::shape08
int16_t shape08[1280]
Definition: twinvq_data.h:141
twinvq_data::cb1108m0
int16_t cb1108m0[1536]
Definition: twinvq_data.h:152
twinvq_data::cb2220l1
int16_t cb2220l1[1152]
Definition: twinvq_data.h:182
bark_tab_s22_128
static const uint16_t bark_tab_s22_128[]
Definition: twinvq_data.h:122
twinvq_data::cb0808m1
int16_t cb0808m1[1024]
Definition: twinvq_data.h:148
twinvq_data::cb2224l1
int16_t cb2224l1[960]
Definition: twinvq_data.h:194
test
static void test(const char *pattern, const char *host)
Definition: noproxy.c:23
twinvq_data::cb4448m0
int16_t cb4448m0[896]
Definition: twinvq_data.h:227
bark_tab_m11_256
static const uint16_t bark_tab_m11_256[]
Definition: twinvq_data.h:85
bark_tab_m22_512
static const uint16_t bark_tab_m22_512[]
Definition: twinvq_data.h:100
twinvq_data::fcb22m_2
int16_t fcb22m_2[640]
Definition: twinvq_data.h:201
twinvq_data::fcb16s
int16_t fcb16s[320]
Definition: twinvq_data.h:171
twinvq_data::cb2232m0
int16_t cb2232m0[704]
Definition: twinvq_data.h:208
twinvq_data::cb0808l1
int16_t cb0808l1[1088]
Definition: twinvq_data.h:144
twinvq_data::fcb22l_1
int16_t fcb22l_1[512]
Definition: twinvq_data.h:188
twinvq_data::cb2232m1
int16_t cb2232m1[704]
Definition: twinvq_data.h:209
bark_tab_l11_512
static const uint16_t bark_tab_l11_512[]
Definition: twinvq_data.h:47
twinvq_data::cb2220s0
int16_t cb2220s0[1152]
Definition: twinvq_data.h:185
TwinVQContext
Definition: twinvq.h:137
twinvq_data::cb1110m0
int16_t cb1110m0[1152]
Definition: twinvq_data.h:164
bark_tab_l22_1024
static const uint16_t bark_tab_l22_1024[]
Definition: twinvq_data.h:59
twinvq_data::shape44
int16_t shape44[1152]
Definition: twinvq_data.h:223
AV_CODEC_ID_TWINVQ
@ AV_CODEC_ID_TWINVQ
Definition: codec_id.h:465
bark_tab_s08_64
static const uint16_t bark_tab_s08_64[]
Definition: twinvq_data.h:110
twinvq_data::cb2220s1
int16_t cb2220s1[1152]
Definition: twinvq_data.h:186
twinvq_data::cb1110s0
int16_t cb1110s0[1344]
Definition: twinvq_data.h:166