FreeRDP
dsp.c File Reference
#include <freerdp/config.h>
#include <winpr/assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <winpr/crt.h>
#include <freerdp/types.h>
#include <freerdp/log.h>
#include <freerdp/codec/dsp.h>
#include "dsp.h"

Macros

#define TAG   FREERDP_TAG("dsp")
 

Functions

static INT16 read_int16 (const BYTE *WINPR_RESTRICT src)
 
static BOOL freerdp_dsp_channel_mix (FREERDP_DSP_CONTEXT *WINPR_RESTRICT context, const BYTE *WINPR_RESTRICT src, size_t size, const AUDIO_FORMAT *WINPR_RESTRICT srcFormat, const BYTE **WINPR_RESTRICT data, size_t *WINPR_RESTRICT length)
 
static BOOL freerdp_dsp_resample (FREERDP_DSP_CONTEXT *WINPR_RESTRICT context, const BYTE *WINPR_RESTRICT src, size_t size, const AUDIO_FORMAT *WINPR_RESTRICT srcFormat, const BYTE **WINPR_RESTRICT data, size_t *WINPR_RESTRICT length)
 
static UINT16 dsp_decode_ima_adpcm_sample (ADPCM *WINPR_RESTRICT adpcm, unsigned int channel, BYTE sample)
 
static BOOL freerdp_dsp_decode_ima_adpcm (FREERDP_DSP_CONTEXT *WINPR_RESTRICT context, const BYTE *WINPR_RESTRICT src, size_t size, wStream *WINPR_RESTRICT out)
 
static BYTE dsp_encode_ima_adpcm_sample (ADPCM *WINPR_RESTRICT adpcm, int channel, INT16 sample)
 
static BOOL freerdp_dsp_encode_ima_adpcm (FREERDP_DSP_CONTEXT *WINPR_RESTRICT context, const BYTE *WINPR_RESTRICT src, size_t size, wStream *WINPR_RESTRICT out)
 
static INLINE INT16 freerdp_dsp_decode_ms_adpcm_sample (ADPCM *WINPR_RESTRICT adpcm, BYTE sample, int channel)
 
static BOOL freerdp_dsp_decode_ms_adpcm (FREERDP_DSP_CONTEXT *WINPR_RESTRICT context, const BYTE *WINPR_RESTRICT src, size_t size, wStream *WINPR_RESTRICT out)
 
static BYTE freerdp_dsp_encode_ms_adpcm_sample (ADPCM *WINPR_RESTRICT adpcm, INT32 sample, int channel)
 
static BOOL freerdp_dsp_encode_ms_adpcm (FREERDP_DSP_CONTEXT *WINPR_RESTRICT context, const BYTE *WINPR_RESTRICT src, size_t size, wStream *WINPR_RESTRICT out)
 
FREERDP_DSP_CONTEXT * freerdp_dsp_context_new (BOOL encoder)
 
void freerdp_dsp_context_free (FREERDP_DSP_CONTEXT *context)
 
BOOL freerdp_dsp_encode (FREERDP_DSP_CONTEXT *WINPR_RESTRICT context, const AUDIO_FORMAT *WINPR_RESTRICT srcFormat, const BYTE *WINPR_RESTRICT data, size_t length, wStream *WINPR_RESTRICT out)
 
BOOL freerdp_dsp_decode (FREERDP_DSP_CONTEXT *WINPR_RESTRICT context, const AUDIO_FORMAT *WINPR_RESTRICT srcFormat, const BYTE *WINPR_RESTRICT data, size_t length, wStream *WINPR_RESTRICT out)
 
BOOL freerdp_dsp_supports_format (const AUDIO_FORMAT *WINPR_RESTRICT format, BOOL encode)
 
BOOL freerdp_dsp_context_reset (FREERDP_DSP_CONTEXT *WINPR_RESTRICT context, const AUDIO_FORMAT *WINPR_RESTRICT targetFormat, UINT32 FramesPerPacket)
 
BOOL freerdp_dsp_common_context_init (FREERDP_DSP_COMMON_CONTEXT *context, BOOL encode)
 
void freerdp_dsp_common_context_uninit (FREERDP_DSP_COMMON_CONTEXT *context)
 

Variables

static const INT16 ima_step_index_table []
 
static const INT16 ima_step_size_table []
 
struct {
   BYTE   byte_num
 
   BYTE   byte_shift
 
ima_stereo_encode_map []
 
static const INT32 ms_adpcm_adaptation_table []
 
static const INT32 ms_adpcm_coeffs1 [7] = { 256, 512, 0, 192, 240, 460, 392 }
 
static const INT32 ms_adpcm_coeffs2 [7] = { 0, -256, 0, 64, 0, -208, -232 }
 

Macro Definition Documentation

◆ TAG

#define TAG   FREERDP_TAG("dsp")

FreeRDP: A Remote Desktop Protocol Implementation Digital Sound Processing

Copyright 2010-2011 Vic Lee

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Function Documentation

◆ dsp_decode_ima_adpcm_sample()

static UINT16 dsp_decode_ima_adpcm_sample ( ADPCM *WINPR_RESTRICT  adpcm,
unsigned int  channel,
BYTE  sample 
)
static
Here is the caller graph for this function:

◆ dsp_encode_ima_adpcm_sample()

static BYTE dsp_encode_ima_adpcm_sample ( ADPCM *WINPR_RESTRICT  adpcm,
int  channel,
INT16  sample 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ freerdp_dsp_channel_mix()

static BOOL freerdp_dsp_channel_mix ( FREERDP_DSP_CONTEXT *WINPR_RESTRICT  context,
const BYTE *WINPR_RESTRICT  src,
size_t  size,
const AUDIO_FORMAT *WINPR_RESTRICT  srcFormat,
const BYTE **WINPR_RESTRICT  data,
size_t *WINPR_RESTRICT  length 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ freerdp_dsp_common_context_init()

BOOL freerdp_dsp_common_context_init ( FREERDP_DSP_COMMON_CONTEXT context,
BOOL  encode 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ freerdp_dsp_common_context_uninit()

void freerdp_dsp_common_context_uninit ( FREERDP_DSP_COMMON_CONTEXT context)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ freerdp_dsp_context_free()

void freerdp_dsp_context_free ( FREERDP_DSP_CONTEXT *  context)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ freerdp_dsp_context_new()

FREERDP_DSP_CONTEXT* freerdp_dsp_context_new ( BOOL  encoder)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ freerdp_dsp_context_reset()

BOOL freerdp_dsp_context_reset ( FREERDP_DSP_CONTEXT *WINPR_RESTRICT  context,
const AUDIO_FORMAT *WINPR_RESTRICT  targetFormat,
UINT32  FramesPerPacket 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ freerdp_dsp_decode()

BOOL freerdp_dsp_decode ( FREERDP_DSP_CONTEXT *WINPR_RESTRICT  context,
const AUDIO_FORMAT *WINPR_RESTRICT  srcFormat,
const BYTE *WINPR_RESTRICT  data,
size_t  length,
wStream *WINPR_RESTRICT  out 
)
Here is the call graph for this function:

◆ freerdp_dsp_decode_ima_adpcm()

static BOOL freerdp_dsp_decode_ima_adpcm ( FREERDP_DSP_CONTEXT *WINPR_RESTRICT  context,
const BYTE *WINPR_RESTRICT  src,
size_t  size,
wStream *WINPR_RESTRICT  out 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ freerdp_dsp_decode_ms_adpcm()

static BOOL freerdp_dsp_decode_ms_adpcm ( FREERDP_DSP_CONTEXT *WINPR_RESTRICT  context,
const BYTE *WINPR_RESTRICT  src,
size_t  size,
wStream *WINPR_RESTRICT  out 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ freerdp_dsp_decode_ms_adpcm_sample()

static INLINE INT16 freerdp_dsp_decode_ms_adpcm_sample ( ADPCM *WINPR_RESTRICT  adpcm,
BYTE  sample,
int  channel 
)
static
Here is the caller graph for this function:

◆ freerdp_dsp_encode()

BOOL freerdp_dsp_encode ( FREERDP_DSP_CONTEXT *WINPR_RESTRICT  context,
const AUDIO_FORMAT *WINPR_RESTRICT  srcFormat,
const BYTE *WINPR_RESTRICT  data,
size_t  length,
wStream *WINPR_RESTRICT  out 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ freerdp_dsp_encode_ima_adpcm()

static BOOL freerdp_dsp_encode_ima_adpcm ( FREERDP_DSP_CONTEXT *WINPR_RESTRICT  context,
const BYTE *WINPR_RESTRICT  src,
size_t  size,
wStream *WINPR_RESTRICT  out 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ freerdp_dsp_encode_ms_adpcm()

static BOOL freerdp_dsp_encode_ms_adpcm ( FREERDP_DSP_CONTEXT *WINPR_RESTRICT  context,
const BYTE *WINPR_RESTRICT  src,
size_t  size,
wStream *WINPR_RESTRICT  out 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ freerdp_dsp_encode_ms_adpcm_sample()

static BYTE freerdp_dsp_encode_ms_adpcm_sample ( ADPCM *WINPR_RESTRICT  adpcm,
INT32  sample,
int  channel 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ freerdp_dsp_resample()

static BOOL freerdp_dsp_resample ( FREERDP_DSP_CONTEXT *WINPR_RESTRICT  context,
const BYTE *WINPR_RESTRICT  src,
size_t  size,
const AUDIO_FORMAT *WINPR_RESTRICT  srcFormat,
const BYTE **WINPR_RESTRICT  data,
size_t *WINPR_RESTRICT  length 
)
static

Microsoft Multimedia Standards Update http://download.microsoft.com/download/9/8/6/9863C72A-A3AA-4DDB-B1BA-CA8D17EFD2D4/RIFFNEW.pdf

Here is the call graph for this function:
Here is the caller graph for this function:

◆ freerdp_dsp_supports_format()

BOOL freerdp_dsp_supports_format ( const AUDIO_FORMAT *WINPR_RESTRICT  format,
BOOL  encode 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ read_int16()

static INT16 read_int16 ( const BYTE *WINPR_RESTRICT  src)
static
Here is the caller graph for this function:

Variable Documentation

◆ byte_num

BYTE byte_num

◆ byte_shift

BYTE byte_shift

◆ ima_step_index_table

const INT16 ima_step_index_table[]
static
Initial value:
= {
-1, -1, -1, -1, 2, 4, 6, 8, -1, -1, -1, -1, 2, 4, 6, 8
}

Microsoft IMA ADPCM specification:

http://wiki.multimedia.cx/index.php?title=Microsoft_IMA_ADPCM http://wiki.multimedia.cx/index.php?title=IMA_ADPCM

◆ ima_step_size_table

const INT16 ima_step_size_table[]
static
Initial value:
= {
7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 19, 21, 23,
25, 28, 31, 34, 37, 41, 45, 50, 55, 60, 66, 73, 80,
88, 97, 107, 118, 130, 143, 157, 173, 190, 209, 230, 253, 279,
307, 337, 371, 408, 449, 494, 544, 598, 658, 724, 796, 876, 963,
1060, 1166, 1282, 1411, 1552, 1707, 1878, 2066, 2272, 2499, 2749, 3024, 3327,
3660, 4026, 4428, 4871, 5358, 5894, 6484, 7132, 7845, 8630, 9493, 10442, 11487,
12635, 13899, 15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767
}

◆ 

const { ... } ima_stereo_encode_map[]
Initial value:
= { { 0, 0 }, { 4, 0 }, { 0, 4 }, { 4, 4 }, { 1, 0 }, { 5, 0 },
{ 1, 4 }, { 5, 4 }, { 2, 0 }, { 6, 0 }, { 2, 4 }, { 6, 4 },
{ 3, 0 }, { 7, 0 }, { 3, 4 }, { 7, 4 } }

0 1 2 3 2 0 6 4 10 8 14 12 <left>

4 5 6 7 3 1 7 5 11 9 15 13 <right>

◆ ms_adpcm_adaptation_table

const INT32 ms_adpcm_adaptation_table[]
static
Initial value:
= { 230, 230, 230, 230, 307, 409, 512, 614,
768, 614, 512, 409, 307, 230, 230, 230 }

Microsoft ADPCM Specification:

http://wiki.multimedia.cx/index.php?title=Microsoft_ADPCM

◆ ms_adpcm_coeffs1

const INT32 ms_adpcm_coeffs1[7] = { 256, 512, 0, 192, 240, 460, 392 }
static

◆ ms_adpcm_coeffs2

const INT32 ms_adpcm_coeffs2[7] = { 0, -256, 0, 64, 0, -208, -232 }
static