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.
 
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.
 
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 divised 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 318 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
}

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
}

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
}

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
}

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
}

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
}

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
}

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
}

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
}

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 = CODEC_CAP_DR1,
}

Definition at line 415 of file twinvqdec.c.