FFmpeg
Data Structures | Macros | Functions | Variables
dss_sp.c File Reference
#include "libavutil/channel_layout.h"
#include "libavutil/common.h"
#include "libavutil/mem_internal.h"
#include "avcodec.h"
#include "codec_internal.h"
#include "decode.h"
#include "get_bits.h"

Go to the source code of this file.

Data Structures

struct  DssSpSubframe
 
struct  DssSpFrame
 
struct  DssSpContext
 

Macros

#define SUBFRAMES   4
 
#define PULSE_MAX   8
 
#define DSS_SP_FRAME_SIZE   42
 
#define DSS_SP_SAMPLE_COUNT   (66 * SUBFRAMES)
 
#define DSS_SP_FORMULA(a, b, c)   ((int)((((a) * (1 << 15)) + (b) * (unsigned)(c)) + 0x4000) >> 15)
 

Functions

static av_cold int dss_sp_decode_init (AVCodecContext *avctx)
 
static void dss_sp_unpack_coeffs (DssSpContext *p, const uint8_t *src)
 
static void dss_sp_unpack_filter (DssSpContext *p)
 
static void dss_sp_convert_coeffs (int32_t *lpc_filter, int32_t *coeffs)
 
static void dss_sp_add_pulses (int32_t *vector_buf, const struct DssSpSubframe *sf)
 
static void dss_sp_gen_exc (int32_t *vector, int32_t *prev_exc, int pitch_lag, int gain)
 
static void dss_sp_scale_vector (int32_t *vec, int bits, int size)
 
static void dss_sp_update_buf (int32_t *hist, int32_t *vector)
 
static void dss_sp_shift_sq_sub (const int32_t *filter_buf, int32_t *error_buf, int32_t *dst)
 
static void dss_sp_shift_sq_add (const int32_t *filter_buf, int32_t *audio_buf, int32_t *dst)
 
static void dss_sp_vec_mult (const int32_t *src, int32_t *dst, const int16_t *mult)
 
static int dss_sp_get_normalize_bits (int32_t *vector_buf, int16_t size)
 
static int dss_sp_vector_sum (DssSpContext *p, int size)
 
static void dss_sp_sf_synthesis (DssSpContext *p, int32_t lpc_filter, int32_t *dst, int size)
 
static void dss_sp_update_state (DssSpContext *p, int32_t *dst)
 
static void dss_sp_32to16bit (int16_t *dst, int32_t *src, int size)
 
static int dss_sp_decode_one_frame (DssSpContext *p, int16_t *abuf_dst, const uint8_t *abuf_src)
 
static int dss_sp_decode_frame (AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt)
 

Variables

static const uint32_t dss_sp_combinatorial_table [PULSE_MAX][72]
 
static const int16_t dss_sp_filter_cb [14][32]
 
static const uint16_t dss_sp_fixed_cb_gain [64]
 
static const int16_t dss_sp_pulse_val [8]
 
static const uint16_t binary_decreasing_array []
 
static const uint16_t dss_sp_unc_decreasing_array []
 
static const uint16_t dss_sp_adaptive_gain []
 
static const int32_t dss_sp_sinc [67]
 
const FFCodec ff_dss_sp_decoder
 

Macro Definition Documentation

◆ SUBFRAMES

#define SUBFRAMES   4

Definition at line 31 of file dss_sp.c.

◆ PULSE_MAX

#define PULSE_MAX   8

Definition at line 32 of file dss_sp.c.

◆ DSS_SP_FRAME_SIZE

#define DSS_SP_FRAME_SIZE   42

Definition at line 34 of file dss_sp.c.

◆ DSS_SP_SAMPLE_COUNT

#define DSS_SP_SAMPLE_COUNT   (66 * SUBFRAMES)

Definition at line 35 of file dss_sp.c.

◆ DSS_SP_FORMULA

#define DSS_SP_FORMULA (   a,
  b,
  c 
)    ((int)((((a) * (1 << 15)) + (b) * (unsigned)(c)) + 0x4000) >> 15)

Definition at line 36 of file dss_sp.c.

Function Documentation

◆ dss_sp_decode_init()

static av_cold int dss_sp_decode_init ( AVCodecContext avctx)
static

Definition at line 290 of file dss_sp.c.

◆ dss_sp_unpack_coeffs()

static void dss_sp_unpack_coeffs ( DssSpContext p,
const uint8_t *  src 
)
static

Definition at line 304 of file dss_sp.c.

Referenced by dss_sp_decode_one_frame().

◆ dss_sp_unpack_filter()

static void dss_sp_unpack_filter ( DssSpContext p)
static

Definition at line 428 of file dss_sp.c.

Referenced by dss_sp_decode_one_frame().

◆ dss_sp_convert_coeffs()

static void dss_sp_convert_coeffs ( int32_t lpc_filter,
int32_t coeffs 
)
static

Definition at line 436 of file dss_sp.c.

Referenced by dss_sp_decode_one_frame().

◆ dss_sp_add_pulses()

static void dss_sp_add_pulses ( int32_t vector_buf,
const struct DssSpSubframe sf 
)
static

Definition at line 461 of file dss_sp.c.

Referenced by dss_sp_decode_one_frame().

◆ dss_sp_gen_exc()

static void dss_sp_gen_exc ( int32_t vector,
int32_t prev_exc,
int  pitch_lag,
int  gain 
)
static

Definition at line 472 of file dss_sp.c.

Referenced by dss_sp_decode_one_frame().

◆ dss_sp_scale_vector()

static void dss_sp_scale_vector ( int32_t vec,
int  bits,
int  size 
)
static

Definition at line 492 of file dss_sp.c.

Referenced by dss_sp_sf_synthesis().

◆ dss_sp_update_buf()

static void dss_sp_update_buf ( int32_t hist,
int32_t vector 
)
static

Definition at line 504 of file dss_sp.c.

Referenced by dss_sp_decode_one_frame().

◆ dss_sp_shift_sq_sub()

static void dss_sp_shift_sq_sub ( const int32_t filter_buf,
int32_t error_buf,
int32_t dst 
)
static

Definition at line 515 of file dss_sp.c.

Referenced by dss_sp_decode_one_frame(), and dss_sp_sf_synthesis().

◆ dss_sp_shift_sq_add()

static void dss_sp_shift_sq_add ( const int32_t filter_buf,
int32_t audio_buf,
int32_t dst 
)
static

Definition at line 539 of file dss_sp.c.

Referenced by dss_sp_sf_synthesis().

◆ dss_sp_vec_mult()

static void dss_sp_vec_mult ( const int32_t src,
int32_t dst,
const int16_t *  mult 
)
static

Definition at line 561 of file dss_sp.c.

Referenced by dss_sp_sf_synthesis().

◆ dss_sp_get_normalize_bits()

static int dss_sp_get_normalize_bits ( int32_t vector_buf,
int16_t  size 
)
static

Definition at line 572 of file dss_sp.c.

Referenced by dss_sp_sf_synthesis().

◆ dss_sp_vector_sum()

static int dss_sp_vector_sum ( DssSpContext p,
int  size 
)
static

Definition at line 587 of file dss_sp.c.

Referenced by dss_sp_sf_synthesis().

◆ dss_sp_sf_synthesis()

static void dss_sp_sf_synthesis ( DssSpContext p,
int32_t  lpc_filter,
int32_t dst,
int  size 
)
static

Definition at line 595 of file dss_sp.c.

Referenced by dss_sp_decode_one_frame().

◆ dss_sp_update_state()

static void dss_sp_update_state ( DssSpContext p,
int32_t dst 
)
static

Definition at line 668 of file dss_sp.c.

Referenced by dss_sp_decode_one_frame().

◆ dss_sp_32to16bit()

static void dss_sp_32to16bit ( int16_t *  dst,
int32_t src,
int  size 
)
static

Definition at line 697 of file dss_sp.c.

Referenced by dss_sp_decode_one_frame().

◆ dss_sp_decode_one_frame()

static int dss_sp_decode_one_frame ( DssSpContext p,
int16_t *  abuf_dst,
const uint8_t *  abuf_src 
)
static

Definition at line 705 of file dss_sp.c.

Referenced by dss_sp_decode_frame().

◆ dss_sp_decode_frame()

static int dss_sp_decode_frame ( AVCodecContext avctx,
AVFrame frame,
int got_frame_ptr,
AVPacket avpkt 
)
static

Definition at line 742 of file dss_sp.c.

Variable Documentation

◆ dss_sp_combinatorial_table

const uint32_t dss_sp_combinatorial_table[PULSE_MAX][72]
static

Definition at line 75 of file dss_sp.c.

Referenced by dss_sp_unpack_coeffs().

◆ dss_sp_filter_cb

const int16_t dss_sp_filter_cb[14][32]
static

Definition at line 174 of file dss_sp.c.

Referenced by dss_sp_unpack_filter().

◆ dss_sp_fixed_cb_gain

const uint16_t dss_sp_fixed_cb_gain[64]
static
Initial value:
= {
0, 4, 8, 13, 17, 22, 26, 31,
35, 40, 44, 48, 53, 58, 63, 69,
76, 83, 91, 99, 109, 119, 130, 142,
155, 170, 185, 203, 222, 242, 265, 290,
317, 346, 378, 414, 452, 494, 540, 591,
646, 706, 771, 843, 922, 1007, 1101, 1204,
1316, 1438, 1572, 1719, 1879, 2053, 2244, 2453,
2682, 2931, 3204, 3502, 3828, 4184, 4574, 5000,
}

Definition at line 246 of file dss_sp.c.

Referenced by dss_sp_add_pulses().

◆ dss_sp_pulse_val

const int16_t dss_sp_pulse_val[8]
static
Initial value:
= {
-31182, -22273, -13364, -4455, 4455, 13364, 22273, 31182
}

Definition at line 257 of file dss_sp.c.

Referenced by dss_sp_add_pulses().

◆ binary_decreasing_array

const uint16_t binary_decreasing_array[]
static
Initial value:
= {
32767, 16384, 8192, 4096, 2048, 1024, 512, 256,
128, 64, 32, 16, 8, 4, 2,
}

Definition at line 261 of file dss_sp.c.

Referenced by dss_sp_sf_synthesis().

◆ dss_sp_unc_decreasing_array

const uint16_t dss_sp_unc_decreasing_array[]
static
Initial value:
= {
32767, 26214, 20972, 16777, 13422, 10737, 8590, 6872,
5498, 4398, 3518, 2815, 2252, 1801, 1441,
}

Definition at line 266 of file dss_sp.c.

Referenced by dss_sp_sf_synthesis().

◆ dss_sp_adaptive_gain

const uint16_t dss_sp_adaptive_gain[]
static
Initial value:
= {
102, 231, 360, 488, 617, 746, 875, 1004,
1133, 1261, 1390, 1519, 1648, 1777, 1905, 2034,
2163, 2292, 2421, 2550, 2678, 2807, 2936, 3065,
3194, 3323, 3451, 3580, 3709, 3838, 3967, 4096,
}

Definition at line 271 of file dss_sp.c.

Referenced by dss_sp_decode_one_frame().

◆ dss_sp_sinc

const int32_t dss_sp_sinc[67]
static
Initial value:
= {
262, 293, 323, 348, 356, 336, 269, 139,
-67, -358, -733, -1178, -1668, -2162, -2607, -2940,
-3090, -2986, -2562, -1760, -541, 1110, 3187, 5651,
8435, 11446, 14568, 17670, 20611, 23251, 25460, 27125,
28160, 28512, 28160,
27125, 25460, 23251, 20611, 17670, 14568, 11446, 8435,
5651, 3187, 1110, -541, -1760, -2562, -2986, -3090,
-2940, -2607, -2162, -1668, -1178, -733, -358, -67,
139, 269, 336, 356, 348, 323, 293, 262,
}

Definition at line 278 of file dss_sp.c.

Referenced by dss_sp_update_state().

◆ ff_dss_sp_decoder

const FFCodec ff_dss_sp_decoder
Initial value:
= {
.p.name = "dss_sp",
CODEC_LONG_NAME("Digital Speech Standard - Standard Play mode (DSS SP)"),
.p.type = AVMEDIA_TYPE_AUDIO,
.priv_data_size = sizeof(DssSpContext),
}

Definition at line 774 of file dss_sp.c.

dss_sp_decode_frame
static int dss_sp_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt)
Definition: dss_sp.c:742
FF_CODEC_DECODE_CB
#define FF_CODEC_DECODE_CB(func)
Definition: codec_internal.h:287
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
dss_sp_decode_init
static av_cold int dss_sp_decode_init(AVCodecContext *avctx)
Definition: dss_sp.c:290
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:272
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:106
DssSpContext
Definition: dss_sp.c:52
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts.c:365
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
AV_CODEC_ID_DSS_SP
@ AV_CODEC_ID_DSS_SP
Definition: codec_id.h:506