FFmpeg
|
#include "libavutil/channel_layout.h"
#include "libavutil/float_dsp.h"
#include "avcodec.h"
#include "get_bits.h"
#include "fft.h"
#include "internal.h"
#include "lsp.h"
#include "sinewin.h"
#include <math.h>
#include <stdint.h>
#include "twinvq_data.h"
Go to the source code of this file.
Data Structures | |
struct | FrameMode |
Parameters and tables that are different for each frame type. More... | |
struct | ModeTab |
Parameters and tables that are different for every combination of bitrate/sample rate. More... | |
struct | TwinContext |
Macros | |
#define | PPC_SHAPE_CB_SIZE 64 |
#define | PPC_SHAPE_LEN_MAX 60 |
#define | SUB_AMP_MAX 4500.0 |
#define | MULAW_MU 100.0 |
#define | GAIN_BITS 8 |
#define | AMP_MAX 13000.0 |
#define | SUB_GAIN_BITS 5 |
#define | WINDOW_TYPE_BITS 4 |
#define | PGAIN_MU 200 |
#define | LSP_COEFS_MAX 20 |
#define | LSP_SPLIT_MAX 4 |
#define | CHANNELS_MAX 2 |
#define | SUBBLOCKS_MAX 16 |
#define | BARK_N_COEF_MAX 4 |
Typedefs | |
typedef struct TwinContext | TwinContext |
Enumerations | |
enum | FrameType { ACTIVE_FRAME, SID_FRAME, UNTRANSMITTED_FRAME, INTRA_FRAME = 0, INTER_FRAME, SKIP_FRAME, FT_SHORT = 0, FT_MEDIUM, FT_LONG, FT_PPC } |
Functions | |
static void | memset_float (float *buf, float val, int size) |
static float | eval_lpc_spectrum (const float *lsp, float cos_val, int order) |
Evaluate a single LPC amplitude spectrum envelope coefficient from the line spectrum pairs. More... | |
static void | eval_lpcenv (TwinContext *tctx, const float *cos_vals, float *lpc) |
Evaluate the LPC amplitude spectrum envelope from the line spectrum pairs. More... | |
static void | interpolate (float *out, float v1, float v2, int size) |
static float | get_cos (int idx, int part, const float *cos_tab, int size) |
static void | eval_lpcenv_or_interp (TwinContext *tctx, enum FrameType ftype, float *out, const float *in, int size, int step, int part) |
Evaluate the LPC amplitude spectrum envelope from the line spectrum pairs. More... | |
static void | eval_lpcenv_2parts (TwinContext *tctx, enum FrameType ftype, const float *buf, float *lpc, int size, int step) |
static void | dequant (TwinContext *tctx, GetBitContext *gb, float *out, enum FrameType ftype, const int16_t *cb0, const int16_t *cb1, int cb_len) |
Inverse quantization. More... | |
static float | mulawinv (float y, float clip, float mu) |
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 (TwinContext *tctx, int period_coef, const float *shape, float ppc_gain, float *speech) |
static void | dec_gain (TwinContext *tctx, GetBitContext *gb, enum FrameType ftype, float *out) |
static void | rearrange_lsp (int order, float *lsp, float min_dist) |
Rearrange the LSP coefficients so that they have a minimum distance of min_dist. More... | |
static void | decode_lsp (TwinContext *tctx, int lpc_idx1, uint8_t *lpc_idx2, int lpc_hist_idx, float *lsp, float *hist) |
static void | dec_lpc_spectrum_inv (TwinContext *tctx, float *lsp, enum FrameType ftype, float *lpc) |
static void | imdct_and_window (TwinContext *tctx, enum FrameType ftype, int wtype, float *in, float *prev, int ch) |
static void | imdct_output (TwinContext *tctx, enum FrameType ftype, int wtype, float **out) |
static void | dec_bark_env (TwinContext *tctx, const uint8_t *in, int use_hist, int ch, float *out, float gain, enum FrameType ftype) |
static void | read_and_decode_spectrum (TwinContext *tctx, GetBitContext *gb, float *out, enum FrameType ftype) |
static int | twin_decode_frame (AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt) |
static av_cold int | init_mdct_win (TwinContext *tctx) |
Init IMDCT and windowing tables. More... | |
static void | permutate_in_line (int16_t *tab, int num_vect, int num_blocks, int block_size, const uint8_t line_len[2], int length_div, enum FrameType ftype) |
Interpret the data as if it were a num_blocks x line_len[0] matrix and for each line do a cyclic permutation, i.e. More... | |
static void | transpose_perm (int16_t *out, int16_t *in, int num_vect, const uint8_t line_len[2], int length_div) |
Interpret the input data as in the following table: More... | |
static void | linear_perm (int16_t *out, int16_t *in, int n_blocks, int size) |
static av_cold void | construct_perm_table (TwinContext *tctx, enum FrameType ftype) |
static av_cold void | init_bitstream_params (TwinContext *tctx) |
static av_cold int | twin_decode_close (AVCodecContext *avctx) |
static av_cold int | twin_decode_init (AVCodecContext *avctx) |
Variables | |
static const ModeTab | mode_08_08 |
static const ModeTab | mode_11_08 |
static const ModeTab | mode_11_10 |
static const ModeTab | mode_16_16 |
static const ModeTab | mode_22_20 |
static const ModeTab | mode_22_24 |
static const ModeTab | mode_22_32 |
static const ModeTab | mode_44_40 |
static const ModeTab | mode_44_48 |
AVCodec | ff_twinvq_decoder |
Macro Definition Documentation
#define AMP_MAX 13000.0 |
Definition at line 213 of file twinvq.c.
Referenced by dec_gain().
#define BARK_N_COEF_MAX 4 |
Definition at line 221 of file twinvq.c.
Referenced by read_and_decode_spectrum().
#define CHANNELS_MAX 2 |
Definition at line 219 of file twinvq.c.
Referenced by read_and_decode_spectrum(), and twin_decode_init().
#define GAIN_BITS 8 |
Definition at line 212 of file twinvq.c.
Referenced by dec_gain(), and init_bitstream_params().
#define LSP_COEFS_MAX 20 |
Definition at line 217 of file twinvq.c.
Referenced by read_and_decode_spectrum().
#define LSP_SPLIT_MAX 4 |
Definition at line 218 of file twinvq.c.
Referenced by read_and_decode_spectrum().
#define MULAW_MU 100.0 |
Definition at line 211 of file twinvq.c.
Referenced by dec_gain().
#define PGAIN_MU 200 |
Definition at line 216 of file twinvq.c.
Referenced by read_and_decode_spectrum().
#define PPC_SHAPE_CB_SIZE 64 |
Definition at line 208 of file twinvq.c.
Referenced by read_and_decode_spectrum().
#define PPC_SHAPE_LEN_MAX 60 |
Definition at line 209 of file twinvq.c.
Referenced by read_and_decode_spectrum().
#define SUB_AMP_MAX 4500.0 |
Definition at line 210 of file twinvq.c.
Referenced by dec_gain().
#define SUB_GAIN_BITS 5 |
Definition at line 214 of file twinvq.c.
Referenced by dec_gain(), and init_bitstream_params().
#define SUBBLOCKS_MAX 16 |
Definition at line 220 of file twinvq.c.
Referenced by read_and_decode_spectrum().
#define WINDOW_TYPE_BITS 4 |
Definition at line 215 of file twinvq.c.
Referenced by init_bitstream_params(), and twin_decode_frame().
Typedef Documentation
typedef struct TwinContext TwinContext |
Enumeration Type Documentation
enum FrameType |
Function Documentation
|
static |
Sum to data a periodic peak of a given period, width and shape.
- Parameters
-
period the period of the peak divised by 400.0
Definition at line 453 of file twinvq.c.
Referenced by decode_ppc().
|
static |
Definition at line 988 of file twinvq.c.
Referenced by init_bitstream_params().
|
static |
Definition at line 697 of file twinvq.c.
Referenced by read_and_decode_spectrum().
|
static |
Definition at line 502 of file twinvq.c.
Referenced by read_and_decode_spectrum().
|
static |
Definition at line 590 of file twinvq.c.
Referenced by read_and_decode_spectrum().
|
static |
Definition at line 551 of file twinvq.c.
Referenced by read_and_decode_spectrum().
|
static |
Definition at line 477 of file twinvq.c.
Referenced by read_and_decode_spectrum().
|
static |
Inverse quantization.
Read CB coefficients for cb1 and cb2 from the bitstream, sum the corresponding vectors and write the result to *out after permutation.
Definition at line 362 of file twinvq.c.
Referenced by read_and_decode_spectrum().
|
static |
Evaluate a single LPC amplitude spectrum envelope coefficient from the line spectrum pairs.
- Parameters
-
lsp a vector of the cosinus of the LSP values cos_val cos(PI*i/N) where i is the index of the LPC amplitude order the order of the LSP (and the size of the *lsp buffer). Must be a multiple of four.
- Returns
- the LPC value
- Todo:
- reuse code from Vorbis decoder: vorbis_floor0_decode
Definition at line 242 of file twinvq.c.
Referenced by eval_lpcenv(), and eval_lpcenv_or_interp().
|
static |
Evaluate the LPC amplitude spectrum envelope from the line spectrum pairs.
Definition at line 267 of file twinvq.c.
Referenced by dec_lpc_spectrum_inv().
|
static |
Definition at line 345 of file twinvq.c.
Referenced by dec_lpc_spectrum_inv().
|
inlinestatic |
Evaluate the LPC amplitude spectrum envelope from the line spectrum pairs.
Probably for speed reasons, the coefficients are evaluated as siiiibiiiisiiiibiiiisiiiibiiiisiiiibiiiis ... where s is an evaluated value, i is a value interpolated from the others and b might be either calculated or interpolated, depending on an unexplained condition.
- Parameters
-
step the size of a block "siiiibiiii" in the cosinus of the LSP data part is 0 for 0...PI (positive cossinus values) and 1 for PI...2PI (negative cossinus values) size the size of the whole output
Definition at line 311 of file twinvq.c.
Referenced by eval_lpcenv_2parts().
|
inlinestatic |
Definition at line 291 of file twinvq.c.
Referenced by eval_lpcenv_or_interp().
|
static |
Definition at line 612 of file twinvq.c.
Referenced by imdct_output().
|
static |
Definition at line 666 of file twinvq.c.
Referenced by twin_decode_frame().
|
static |
Definition at line 1014 of file twinvq.c.
Referenced by twin_decode_init().
|
static |
Init IMDCT and windowing tables.
Definition at line 871 of file twinvq.c.
Referenced by twin_decode_init().
|
static |
Definition at line 280 of file twinvq.c.
Referenced by eval_lpcenv_2parts(), and eval_lpcenv_or_interp().
|
static |
Definition at line 979 of file twinvq.c.
Referenced by construct_perm_table().
|
static |
- Note
- not speed critical, hence not optimized
Definition at line 224 of file twinvq.c.
Referenced by dec_bark_env(), eval_lpcenv_2parts(), and twin_decode_init().
|
inlinestatic |
Definition at line 406 of file twinvq.c.
Referenced by dec_gain(), and read_and_decode_spectrum().
|
static |
Interpret the data as if it were a num_blocks x line_len[0] matrix and for each line do a cyclic permutation, i.e.
abcdefghijklm -> defghijklmabc where the amount to be shifted is evaluated depending on the column.
Definition at line 928 of file twinvq.c.
Referenced by construct_perm_table().
|
static |
Definition at line 724 of file twinvq.c.
Referenced by twin_decode_frame().
|
static |
Rearrange the LSP coefficients so that they have a minimum distance of min_dist.
This function does it exactly as described in section of 3.2.4 of the G.729 specification (but interestingly is different from what the reference decoder actually does).
Definition at line 538 of file twinvq.c.
Referenced by decode_lsp().
|
static |
Interpret the input data as in the following table:
* * abcdefgh * ijklmnop * qrstuvw * x123456 * *
and transpose it, giving the output aiqxbjr1cks2dlt3emu4fvn5gow6hp
Definition at line 969 of file twinvq.c.
Referenced by construct_perm_table().
|
static |
Definition at line 1083 of file twinvq.c.
Referenced by twin_decode_init().
|
static |
|
static |
|
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:
- Note
- if this function is replaced by just ROUNDED_DIV(a*b,400.), 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 432 of file twinvq.c.
Referenced by add_peak().
Variable Documentation
AVCodec ff_twinvq_decoder |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Generated on Mon Nov 18 2024 06:52:09 for FFmpeg by 1.8.11