/usr/include/pjmedia/alaw_ulaw.h is in libpjproject-dev 2.1.0.0.ast20130823-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 | /* $Id: alaw_ulaw.h 3553 2011-05-05 06:14:19Z nanang $ */
/*
* Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
* Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __PJMEDIA_ALAW_ULAW_H__
#define __PJMEDIA_ALAW_ULAW_H__
#include <pjmedia/types.h>
PJ_BEGIN_DECL
#if defined(PJMEDIA_HAS_ALAW_ULAW_TABLE) && PJMEDIA_HAS_ALAW_ULAW_TABLE!=0
extern const pj_uint8_t pjmedia_linear2ulaw_tab[16384];
extern const pj_uint8_t pjmedia_linear2alaw_tab[16384];
extern const pj_int16_t pjmedia_ulaw2linear_tab[256];
extern const pj_int16_t pjmedia_alaw2linear_tab[256];
/**
* Convert 16-bit linear PCM value to 8-bit A-Law.
*
* @param pcm_val 16-bit linear PCM value.
* @return 8-bit A-Law value.
*/
#define pjmedia_linear2alaw(pcm_val) \
pjmedia_linear2alaw_tab[(((pj_int16_t)pcm_val) >> 2) & 0x3fff]
/**
* Convert 8-bit A-Law value to 16-bit linear PCM value.
*
* @param chara_val 8-bit A-Law value.
* @return 16-bit linear PCM value.
*/
#define pjmedia_alaw2linear(chara_val) \
pjmedia_alaw2linear_tab[chara_val]
/**
* Convert 16-bit linear PCM value to 8-bit U-Law.
*
* @param pcm_val 16-bit linear PCM value.
* @return U-bit A-Law value.
*/
#define pjmedia_linear2ulaw(pcm_val) \
pjmedia_linear2ulaw_tab[(((pj_int16_t)pcm_val) >> 2) & 0x3fff]
/**
* Convert 8-bit U-Law value to 16-bit linear PCM value.
*
* @param u_val 8-bit U-Law value.
* @return 16-bit linear PCM value.
*/
#define pjmedia_ulaw2linear(u_val) \
pjmedia_ulaw2linear_tab[u_val]
/**
* Convert 8-bit A-Law value to 8-bit U-Law value.
*
* @param aval 8-bit A-Law value.
* @return 8-bit U-Law value.
*/
#define pjmedia_alaw2ulaw(aval) \
pjmedia_linear2ulaw(pjmedia_alaw2linear(aval))
/**
* Convert 8-bit U-Law value to 8-bit A-Law value.
*
* @param uval 8-bit U-Law value.
* @return 8-bit A-Law value.
*/
#define pjmedia_ulaw2alaw(uval) \
pjmedia_linear2alaw(pjmedia_ulaw2linear(uval))
#else
/**
* Convert 16-bit linear PCM value to 8-bit A-Law.
*
* @param pcm_val 16-bit linear PCM value.
* @return 8-bit A-Law value.
*/
PJ_DECL(pj_uint8_t) pjmedia_linear2alaw(int pcm_val);
/**
* Convert 8-bit A-Law value to 16-bit linear PCM value.
*
* @param chara_val 8-bit A-Law value.
* @return 16-bit linear PCM value.
*/
PJ_DECL(int) pjmedia_alaw2linear(unsigned chara_val);
/**
* Convert 16-bit linear PCM value to 8-bit U-Law.
*
* @param pcm_val 16-bit linear PCM value.
* @return U-bit A-Law value.
*/
PJ_DECL(unsigned char) pjmedia_linear2ulaw(int pcm_val);
/**
* Convert 8-bit U-Law value to 16-bit linear PCM value.
*
* @param u_val 8-bit U-Law value.
* @return 16-bit linear PCM value.
*/
PJ_DECL(int) pjmedia_ulaw2linear(unsigned char u_val);
/**
* Convert 8-bit A-Law value to 8-bit U-Law value.
*
* @param aval 8-bit A-Law value.
* @return 8-bit U-Law value.
*/
PJ_DECL(unsigned char) pjmedia_alaw2ulaw(unsigned char aval);
/**
* Convert 8-bit U-Law value to 8-bit A-Law value.
*
* @param uval 8-bit U-Law value.
* @return 8-bit A-Law value.
*/
PJ_DECL(unsigned char) pjmedia_ulaw2alaw(unsigned char uval);
#endif
/**
* Encode 16-bit linear PCM data to 8-bit U-Law data.
*
* @param dst Destination buffer for 8-bit U-Law data.
* @param src Source, 16-bit linear PCM data.
* @param count Number of samples.
*/
PJ_INLINE(void) pjmedia_ulaw_encode(pj_uint8_t *dst, const pj_int16_t *src,
pj_size_t count)
{
const pj_int16_t *end = src + count;
while (src < end) {
*dst++ = pjmedia_linear2ulaw(*src++);
}
}
/**
* Encode 16-bit linear PCM data to 8-bit A-Law data.
*
* @param dst Destination buffer for 8-bit A-Law data.
* @param src Source, 16-bit linear PCM data.
* @param count Number of samples.
*/
PJ_INLINE(void) pjmedia_alaw_encode(pj_uint8_t *dst, const pj_int16_t *src,
pj_size_t count)
{
const pj_int16_t *end = src + count;
while (src < end) {
*dst++ = pjmedia_linear2alaw(*src++);
}
}
/**
* Decode 8-bit U-Law data to 16-bit linear PCM data.
*
* @param dst Destination buffer for 16-bit PCM data.
* @param src Source, 8-bit U-Law data.
* @param len Encoded frame/source length in bytes.
*/
PJ_INLINE(void) pjmedia_ulaw_decode(pj_int16_t *dst, const pj_uint8_t *src,
pj_size_t len)
{
const pj_uint8_t *end = src + len;
while (src < end) {
*dst++ = pjmedia_ulaw2linear(*src++);
}
}
/**
* Decode 8-bit A-Law data to 16-bit linear PCM data.
*
* @param dst Destination buffer for 16-bit PCM data.
* @param src Source, 8-bit A-Law data.
* @param len Encoded frame/source length in bytes.
*/
PJ_INLINE(void) pjmedia_alaw_decode(pj_int16_t *dst, const pj_uint8_t *src,
pj_size_t len)
{
const pj_uint8_t *end = src + len;
while (src < end) {
*dst++ = pjmedia_alaw2linear(*src++);
}
}
PJ_END_DECL
#endif /* __PJMEDIA_ALAW_ULAW_H__ */
|