23 #ifndef AVCODEC_PCM_TABLEGEN_H
24 #define AVCODEC_PCM_TABLEGEN_H
31 #define SIGN_BIT (0x80)
32 #define QUANT_MASK (0xf)
35 #define SEG_MASK (0x70)
39 #define VIDC_SIGN_BIT (1)
40 #define VIDC_QUANT_MASK (0x1E)
41 #define VIDC_QUANT_SHIFT (1)
42 #define VIDC_SEG_SHIFT (5)
43 #define VIDC_SEG_MASK (0xE0)
45 #if CONFIG_PCM_ALAW_DECODER || CONFIG_PCM_ALAW_ENCODER
47 static av_cold int alaw2linear(
unsigned char a_val)
56 if(seg) t= (t + t + 1 + 32) << (seg + 2);
57 else t= (t + t + 1 ) << 3;
63 #if CONFIG_PCM_MULAW_DECODER || CONFIG_PCM_MULAW_ENCODER
64 static av_cold int ulaw2linear(
unsigned char u_val)
82 #if CONFIG_PCM_VIDC_DECODER || CONFIG_PCM_VIDC_ENCODER
83 static av_cold int vidc2linear(
unsigned char u_val)
98 #if CONFIG_HARDCODED_TABLES
99 #define pcm_alaw_tableinit()
100 #define pcm_ulaw_tableinit()
101 #define pcm_vidc_tableinit()
102 #include "libavcodec/pcm_tables.h"
105 #if CONFIG_PCM_ALAW_DECODER || CONFIG_PCM_ALAW_ENCODER
106 static uint8_t linear_to_alaw[16384];
108 #if CONFIG_PCM_MULAW_DECODER || CONFIG_PCM_MULAW_ENCODER
109 static uint8_t linear_to_ulaw[16384];
111 #if CONFIG_PCM_VIDC_DECODER || CONFIG_PCM_VIDC_ENCODER
112 static uint8_t linear_to_vidc[16384];
115 #if CONFIG_PCM_ALAW_DECODER || CONFIG_PCM_ALAW_ENCODER || \
116 CONFIG_PCM_MULAW_DECODER || CONFIG_PCM_MULAW_ENCODER || \
117 CONFIG_PCM_VIDC_DECODER || CONFIG_PCM_VIDC_ENCODER
118 static av_cold void build_xlaw_table(uint8_t *linear_to_xlaw,
119 int (*xlaw2linear)(
unsigned char),
125 linear_to_xlaw[8192] =
mask;
127 v1 = xlaw2linear(
i ^
mask);
128 v2 = xlaw2linear((
i + 1) ^
mask);
129 v = (v1 + v2 + 4) >> 3;
131 linear_to_xlaw[8192 - j] = (
i ^ (
mask ^ 0x80));
132 linear_to_xlaw[8192 + j] = (
i ^
mask);
136 linear_to_xlaw[8192 - j] = (127 ^ (
mask ^ 0x80));
137 linear_to_xlaw[8192 + j] = (127 ^
mask);
139 linear_to_xlaw[0] = linear_to_xlaw[1];
143 #if CONFIG_PCM_ALAW_DECODER || CONFIG_PCM_ALAW_ENCODER
144 static void pcm_alaw_tableinit(
void)
146 build_xlaw_table(linear_to_alaw, alaw2linear, 0xd5);
150 #if CONFIG_PCM_MULAW_DECODER || CONFIG_PCM_MULAW_ENCODER
151 static void pcm_ulaw_tableinit(
void)
153 build_xlaw_table(linear_to_ulaw, ulaw2linear, 0xff);
157 #if CONFIG_PCM_VIDC_DECODER || CONFIG_PCM_VIDC_ENCODER
158 static void pcm_vidc_tableinit(
void)
160 build_xlaw_table(linear_to_vidc, vidc2linear, 0xff);