FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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 "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
 
AVCodec ff_twinvq_decoder
 

Function Documentation

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 133 of file twinvqdec.c.

Referenced by 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 154 of file twinvqdec.c.

Referenced by decode_ppc().

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

Definition at line 178 of file twinvqdec.c.

Referenced by twinvq_decode_init().

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 210 of file twinvqdec.c.

Referenced by twinvq_decode_init().

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

Definition at line 238 of file twinvqdec.c.

Referenced by twinvq_read_bitstream().

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

Definition at line 251 of file twinvqdec.c.

Referenced by twinvq_decode_init().

static av_cold int twinvq_decode_init ( AVCodecContext avctx)
static

Definition at line 319 of file twinvqdec.c.

Variable Documentation

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, tab.lsp08, 1, 5, 3, 3, tab.shape08, 8, 28, 20, 6, 40
}
static const uint16_t bark_tab_m08_256[]
Definition: twinvq_data.h:80
int16_t cb0808l0[1088]
Definition: twinvq_data.h:144
static const uint16_t bark_tab_s08_64[]
Definition: twinvq_data.h:110
int16_t fcb08m[320]
Definition: twinvq_data.h:140
int16_t cb0808m1[1024]
Definition: twinvq_data.h:149
int16_t fcb08l[640]
Definition: twinvq_data.h:139
int16_t cb0808l1[1088]
Definition: twinvq_data.h:145
int16_t shape08[1280]
Definition: twinvq_data.h:142
int16_t cb0808s1[1152]
Definition: twinvq_data.h:147
int16_t cb0808m0[1024]
Definition: twinvq_data.h:148
static const struct twinvq_data tab
static const uint16_t bark_tab_l08_512[]
Definition: twinvq_data.h:41
int16_t cb0808s0[1152]
Definition: twinvq_data.h:146
int16_t fcb08s[320]
Definition: twinvq_data.h:141
float lsp08[504]
Definition: twinvq_data.h:138

Definition at line 32 of file twinvqdec.c.

Referenced by twinvq_decode_init().

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, tab.lsp11, 1, 6, 4, 3, tab.shape11, 9, 36, 30, 7, 90
}
int16_t cb1108l1[1728]
Definition: twinvq_data.h:152
int16_t cb1108m1[1536]
Definition: twinvq_data.h:154
int16_t fcb11l[640]
Definition: twinvq_data.h:158
int16_t cb1108l0[1728]
Definition: twinvq_data.h:151
int16_t shape11[1280]
Definition: twinvq_data.h:161
static const uint16_t bark_tab_l11_512[]
static const uint16_t bark_tab_m11_256[]
float lsp11[1312]
Definition: twinvq_data.h:162
int16_t cb1108s1[1856]
Definition: twinvq_data.h:156
int16_t fcb11m[320]
Definition: twinvq_data.h:159
int16_t cb1108m0[1536]
Definition: twinvq_data.h:153
static const uint16_t bark_tab_s11_64[]
static const struct twinvq_data tab
int16_t fcb11s[320]
Definition: twinvq_data.h:160
int16_t cb1108s0[1856]
Definition: twinvq_data.h:155

Definition at line 41 of file twinvqdec.c.

Referenced by twinvq_decode_init().

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, tab.lsp11, 1, 6, 4, 3, tab.shape11, 9, 36, 30, 7, 90
}
int16_t cb1110s1[1344]
Definition: twinvq_data.h:169
int16_t cb1110l1[1280]
Definition: twinvq_data.h:165
int16_t cb1110s0[1344]
Definition: twinvq_data.h:168
int16_t fcb11l[640]
Definition: twinvq_data.h:158
int16_t shape11[1280]
Definition: twinvq_data.h:161
static const uint16_t bark_tab_l11_512[]
int16_t cb1110l0[1280]
Definition: twinvq_data.h:164
int16_t cb1110m0[1152]
Definition: twinvq_data.h:166
static const uint16_t bark_tab_m11_256[]
float lsp11[1312]
Definition: twinvq_data.h:162
int16_t fcb11m[320]
Definition: twinvq_data.h:159
int16_t cb1110m1[1152]
Definition: twinvq_data.h:167
static const uint16_t bark_tab_s11_64[]
static const struct twinvq_data tab
int16_t fcb11s[320]
Definition: twinvq_data.h:160

Definition at line 50 of file twinvqdec.c.

Referenced by twinvq_decode_init().

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, tab.lsp16, 1, 6, 4, 3, tab.shape16, 9, 56, 60, 7, 180
}
static const uint16_t bark_tab_m16_512[]
int16_t cb1616l0[1024]
Definition: twinvq_data.h:177
int16_t cb1616s0[1024]
Definition: twinvq_data.h:181
int16_t fcb16m[320]
Definition: twinvq_data.h:172
int16_t cb1616l1[1024]
Definition: twinvq_data.h:178
int16_t fcb16l[640]
Definition: twinvq_data.h:171
int16_t cb1616m0[960]
Definition: twinvq_data.h:179
int16_t fcb16s[320]
Definition: twinvq_data.h:173
int16_t cb1616s1[1024]
Definition: twinvq_data.h:182
float lsp16[1400]
Definition: twinvq_data.h:175
int16_t cb1616m1[960]
Definition: twinvq_data.h:180
static const uint16_t bark_tab_s16_128[]
static const uint16_t bark_tab_l16_1024[]
int16_t shape16[1920]
Definition: twinvq_data.h:174
static const struct twinvq_data tab

Definition at line 59 of file twinvqdec.c.

Referenced by twinvq_decode_init().

const TwinVQModeTab mode_22_20
static
Initial value:
= {
{
},
1024, 16, tab.lsp22_1, 1, 6, 4, 3, tab.shape22_1, 9, 56, 36, 7, 144
}
static const uint16_t bark_tab_m22_512[]
static const uint16_t bark_tab_l22_1024[]
int16_t cb2220m1[1088]
Definition: twinvq_data.h:187
int16_t fcb22m_1[640]
Definition: twinvq_data.h:192
int16_t cb2220l1[1152]
Definition: twinvq_data.h:185
int16_t cb2220s0[1152]
Definition: twinvq_data.h:188
int16_t cb2220m0[1088]
Definition: twinvq_data.h:186
int16_t fcb22s_1[640]
Definition: twinvq_data.h:193
static const uint16_t bark_tab_s22_128[]
int16_t cb2220l0[1152]
Definition: twinvq_data.h:184
int16_t shape22_1[1152]
Definition: twinvq_data.h:194
float lsp22_1[1312]
Definition: twinvq_data.h:195
int16_t fcb22l_1[512]
Definition: twinvq_data.h:191
int16_t cb2220s1[1152]
Definition: twinvq_data.h:189
static const struct twinvq_data tab

Definition at line 68 of file twinvqdec.c.

Referenced by twinvq_decode_init().

const TwinVQModeTab mode_22_24
static
Initial value:
= {
{
},
1024, 16, tab.lsp22_1, 1, 6, 4, 3, tab.shape22_1, 9, 56, 36, 7, 144
}
static const uint16_t bark_tab_m22_512[]
static const uint16_t bark_tab_l22_1024[]
int16_t cb2224s0[960]
Definition: twinvq_data.h:201
int16_t fcb22m_1[640]
Definition: twinvq_data.h:192
int16_t cb2224l0[960]
Definition: twinvq_data.h:197
int16_t cb2224s1[960]
Definition: twinvq_data.h:202
int16_t fcb22s_1[640]
Definition: twinvq_data.h:193
static const uint16_t bark_tab_s22_128[]
int16_t cb2224m0[896]
Definition: twinvq_data.h:199
int16_t shape22_1[1152]
Definition: twinvq_data.h:194
float lsp22_1[1312]
Definition: twinvq_data.h:195
int16_t cb2224l1[960]
Definition: twinvq_data.h:198
int16_t fcb22l_1[512]
Definition: twinvq_data.h:191
int16_t cb2224m1[896]
Definition: twinvq_data.h:200
static const struct twinvq_data tab

Definition at line 77 of file twinvqdec.c.

Referenced by twinvq_decode_init().

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
}
int16_t cb2232m0[704]
Definition: twinvq_data.h:212
int16_t cb2232l0[768]
Definition: twinvq_data.h:210
int16_t cb2232s1[704]
Definition: twinvq_data.h:215
int16_t fcb22l_2[512]
Definition: twinvq_data.h:204
int16_t cb2232m1[704]
Definition: twinvq_data.h:213
int16_t shape22_2[1152]
Definition: twinvq_data.h:207
int16_t cb2232l1[768]
Definition: twinvq_data.h:211
static const uint16_t bark_tab_m22_256[]
Definition: twinvq_data.h:95
static const uint16_t bark_tab_s22_128[]
static const uint16_t bark_tab_l22_512[]
Definition: twinvq_data.h:66
int16_t fcb22m_2[640]
Definition: twinvq_data.h:205
float lsp22_2[1312]
Definition: twinvq_data.h:208
int16_t fcb22s_2[640]
Definition: twinvq_data.h:206
static const struct twinvq_data tab
int16_t cb2232s0[704]
Definition: twinvq_data.h:214

Definition at line 86 of file twinvqdec.c.

Referenced by twinvq_decode_init().

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, tab.lsp44, 1, 6, 4, 4, tab.shape44, 9, 84, 54, 7, 432
}
static const uint16_t bark_tab_l44_2048[]
int16_t fcb44l[640]
Definition: twinvq_data.h:224
int16_t cb4440s1[1152]
Definition: twinvq_data.h:222
int16_t cb4440m1[1088]
Definition: twinvq_data.h:220
int16_t fcb44m[640]
Definition: twinvq_data.h:225
static const uint16_t bark_tab_m44_512[]
int16_t cb4440l0[1088]
Definition: twinvq_data.h:217
int16_t fcb44s[640]
Definition: twinvq_data.h:226
float lsp44[1640]
Definition: twinvq_data.h:228
int16_t cb4440s0[1152]
Definition: twinvq_data.h:221
int16_t shape44[1152]
Definition: twinvq_data.h:227
int16_t cb4440m0[1088]
Definition: twinvq_data.h:219
int16_t cb4440l1[1088]
Definition: twinvq_data.h:218
static const struct twinvq_data tab
static const uint16_t bark_tab_s44_128[]

Definition at line 95 of file twinvqdec.c.

Referenced by twinvq_decode_init().

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, tab.lsp44, 1, 6, 4, 4, tab.shape44, 9, 84, 54, 7, 432
}
static const uint16_t bark_tab_l44_2048[]
int16_t fcb44l[640]
Definition: twinvq_data.h:224
int16_t cb4448l1[896]
Definition: twinvq_data.h:231
int16_t fcb44m[640]
Definition: twinvq_data.h:225
int16_t cb4448m0[896]
Definition: twinvq_data.h:232
static const uint16_t bark_tab_m44_512[]
int16_t cb4448s0[960]
Definition: twinvq_data.h:234
int16_t fcb44s[640]
Definition: twinvq_data.h:226
float lsp44[1640]
Definition: twinvq_data.h:228
int16_t shape44[1152]
Definition: twinvq_data.h:227
int16_t cb4448m1[896]
Definition: twinvq_data.h:233
int16_t cb4448s1[960]
Definition: twinvq_data.h:235
static const struct twinvq_data tab
int16_t cb4448l0[896]
Definition: twinvq_data.h:230
static const uint16_t bark_tab_s44_128[]

Definition at line 104 of file twinvqdec.c.

Referenced by twinvq_decode_init().

AVCodec ff_twinvq_decoder
Initial value:
= {
.name = "twinvq",
.long_name = NULL_IF_CONFIG_SMALL("VQF TwinVQ"),
.priv_data_size = sizeof(TwinVQContext),
.capabilities = AV_CODEC_CAP_DR1,
}
float, planar
Definition: samplefmt.h:69
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
static av_cold int twinvq_decode_init(AVCodecContext *avctx)
Definition: twinvqdec.c:319
av_cold int ff_twinvq_decode_close(AVCodecContext *avctx)
Definition: twinvq.c:751
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:176
int ff_twinvq_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
Definition: twinvq.c:476
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:58
static int decode(AVCodecContext *avctx, void *data, int *got_sub, AVPacket *avpkt)
Definition: ccaption_dec.c:722
static enum AVSampleFormat sample_fmts[]
Definition: adpcmenc.c:701
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
Definition: avcodec.h:956

Definition at line 416 of file twinvqdec.c.