blob: 5a16287334c20b987dd9905412d03095ed712c51 [file] [log] [blame]
Nanang Izzuddin493a8db2008-08-15 13:17:39 +00001/* $Id$ */
2/*
3 * Copyright (C)2003-2008 Benny Prijono <benny@prijono.org>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19#include <pjmedia-codec/ipp_codecs.h>
20#include <pjmedia/codec.h>
21#include <pjmedia/errno.h>
22#include <pjmedia/endpoint.h>
23#include <pjmedia/plc.h>
24#include <pjmedia/port.h>
25#include <pjmedia/silencedet.h>
26#include <pj/assert.h>
27#include <pj/log.h>
28#include <pj/pool.h>
29#include <pj/string.h>
30#include <pj/os.h>
31
Nanang Izzuddin23a00b72008-08-25 13:58:25 +000032
Nanang Izzuddin493a8db2008-08-15 13:17:39 +000033/*
Benny Prijonoa4e7cdd2008-08-19 15:01:48 +000034 * Only build this file if PJMEDIA_HAS_INTEL_IPP != 0
Nanang Izzuddin493a8db2008-08-15 13:17:39 +000035 */
Benny Prijonoa4e7cdd2008-08-19 15:01:48 +000036#if defined(PJMEDIA_HAS_INTEL_IPP) && PJMEDIA_HAS_INTEL_IPP != 0
Nanang Izzuddin493a8db2008-08-15 13:17:39 +000037
38#include <usc.h>
39
40#define THIS_FILE "ipp_codecs.c"
41
42/* Prototypes for IPP codecs factory */
43static pj_status_t ipp_test_alloc( pjmedia_codec_factory *factory,
44 const pjmedia_codec_info *id );
45static pj_status_t ipp_default_attr( pjmedia_codec_factory *factory,
46 const pjmedia_codec_info *id,
47 pjmedia_codec_param *attr );
48static pj_status_t ipp_enum_codecs( pjmedia_codec_factory *factory,
49 unsigned *count,
50 pjmedia_codec_info codecs[]);
51static pj_status_t ipp_alloc_codec( pjmedia_codec_factory *factory,
52 const pjmedia_codec_info *id,
53 pjmedia_codec **p_codec);
54static pj_status_t ipp_dealloc_codec( pjmedia_codec_factory *factory,
55 pjmedia_codec *codec );
56
57/* Prototypes for IPP codecs implementation. */
58static pj_status_t ipp_codec_init( pjmedia_codec *codec,
59 pj_pool_t *pool );
60static pj_status_t ipp_codec_open( pjmedia_codec *codec,
61 pjmedia_codec_param *attr );
62static pj_status_t ipp_codec_close( pjmedia_codec *codec );
63static pj_status_t ipp_codec_modify(pjmedia_codec *codec,
64 const pjmedia_codec_param *attr );
65static pj_status_t ipp_codec_parse( pjmedia_codec *codec,
66 void *pkt,
67 pj_size_t pkt_size,
68 const pj_timestamp *ts,
69 unsigned *frame_cnt,
70 pjmedia_frame frames[]);
71static pj_status_t ipp_codec_encode( pjmedia_codec *codec,
72 const struct pjmedia_frame *input,
73 unsigned output_buf_len,
74 struct pjmedia_frame *output);
75static pj_status_t ipp_codec_decode( pjmedia_codec *codec,
76 const struct pjmedia_frame *input,
77 unsigned output_buf_len,
78 struct pjmedia_frame *output);
79static pj_status_t ipp_codec_recover(pjmedia_codec *codec,
80 unsigned output_buf_len,
81 struct pjmedia_frame *output);
82
83/* Definition for IPP codecs operations. */
84static pjmedia_codec_op ipp_op =
85{
86 &ipp_codec_init,
87 &ipp_codec_open,
88 &ipp_codec_close,
89 &ipp_codec_modify,
90 &ipp_codec_parse,
91 &ipp_codec_encode,
92 &ipp_codec_decode,
93 &ipp_codec_recover
94};
95
96/* Definition for IPP codecs factory operations. */
97static pjmedia_codec_factory_op ipp_factory_op =
98{
99 &ipp_test_alloc,
100 &ipp_default_attr,
101 &ipp_enum_codecs,
102 &ipp_alloc_codec,
103 &ipp_dealloc_codec
104};
105
106/* IPP codecs factory */
107static struct ipp_factory {
108 pjmedia_codec_factory base;
109 pjmedia_endpt *endpt;
110 pj_pool_t *pool;
111 pj_mutex_t *mutex;
112} ipp_factory;
113
114/* IPP codecs private data. */
115typedef struct ipp_private {
116 int codec_idx; /**< Codec index. */
Nanang Izzuddin35e01de2008-10-29 10:17:02 +0000117 void *codec_setting; /**< Specific codec setting. */
Nanang Izzuddin493a8db2008-08-15 13:17:39 +0000118 pj_pool_t *pool; /**< Pool for each instance. */
119
120 USC_Handle enc; /**< Encoder state. */
121 USC_Handle dec; /**< Decoder state. */
122 USC_CodecInfo *info; /**< Native codec info. */
123 pj_uint16_t frame_size; /**< Bitstream frame size. */
124
Nanang Izzuddin35e01de2008-10-29 10:17:02 +0000125 pj_bool_t plc_enabled; /**< PLC enabled flag. */
126 pjmedia_plc *plc; /**< PJMEDIA PLC engine, NULL if
127 codec has internal PLC. */
Nanang Izzuddin493a8db2008-08-15 13:17:39 +0000128
Nanang Izzuddin35e01de2008-10-29 10:17:02 +0000129 pj_bool_t vad_enabled; /**< VAD enabled flag. */
130 pjmedia_silence_det *vad; /**< PJMEDIA VAD engine, NULL if
131 codec has internal VAD. */
132 pj_timestamp last_tx; /**< Timestamp of last transmit.*/
Nanang Izzuddin493a8db2008-08-15 13:17:39 +0000133} ipp_private_t;
134
135
136/* USC codec implementations. */
137extern USC_Fxns USC_G729AFP_Fxns;
Nanang Izzuddin762a5bd2008-09-16 14:11:09 +0000138extern USC_Fxns USC_G729I_Fxns;
Nanang Izzuddin493a8db2008-08-15 13:17:39 +0000139extern USC_Fxns USC_G723_Fxns;
140extern USC_Fxns USC_G726_Fxns;
141extern USC_Fxns USC_G728_Fxns;
142extern USC_Fxns USC_G722_Fxns;
143extern USC_Fxns USC_GSMAMR_Fxns;
144extern USC_Fxns USC_AMRWB_Fxns;
145extern USC_Fxns USC_AMRWBE_Fxns;
146
Nanang Izzuddin762a5bd2008-09-16 14:11:09 +0000147
Nanang Izzuddin493a8db2008-08-15 13:17:39 +0000148/* CUSTOM CALLBACKS */
149
Nanang Izzuddindf361e02008-08-16 06:46:08 +0000150/* This callback is useful for translating RTP frame into USC frame, e.g:
151 * reassigning frame attributes, reorder bitstream. Default behaviour of
152 * the translation is just setting the USC frame buffer & its size as
153 * specified in RTP frame, setting USC frame frametype to 0, setting bitrate
154 * of USC frame to bitrate info of codec_data. Implement this callback when
155 * the default behaviour is unapplicable.
Nanang Izzuddin493a8db2008-08-15 13:17:39 +0000156 */
Nanang Izzuddindf361e02008-08-16 06:46:08 +0000157typedef void (*predecode_cb)(ipp_private_t *codec_data,
158 const pjmedia_frame *rtp_frame,
159 USC_Bitstream *usc_frame);
Nanang Izzuddin493a8db2008-08-15 13:17:39 +0000160
Nanang Izzuddindf361e02008-08-16 06:46:08 +0000161/* Parse frames from a packet. Default behaviour of frame parsing is
162 * just separating frames based on calculating frame length derived
163 * from bitrate. Implement this callback when the default behaviour is
164 * unapplicable.
Nanang Izzuddin493a8db2008-08-15 13:17:39 +0000165 */
166typedef pj_status_t (*parse_cb)(ipp_private_t *codec_data, void *pkt,
167 pj_size_t pkt_size, const pj_timestamp *ts,
168 unsigned *frame_cnt, pjmedia_frame frames[]);
169
Nanang Izzuddindf361e02008-08-16 06:46:08 +0000170/* Pack frames into a packet. Default behaviour of packing frames is
171 * just stacking the frames with octet aligned without adding any
172 * payload header. Implement this callback when the default behaviour is
173 * unapplicable.
Nanang Izzuddin493a8db2008-08-15 13:17:39 +0000174 */
175typedef pj_status_t (*pack_cb)(ipp_private_t *codec_data, void *pkt,
176 pj_size_t *pkt_size, pj_size_t max_pkt_size);
177
178
179
Nanang Izzuddindf361e02008-08-16 06:46:08 +0000180/* Custom callback implementations. */
181static void predecode_g723( ipp_private_t *codec_data,
182 const pjmedia_frame *rtp_frame,
183 USC_Bitstream *usc_frame);
184static pj_status_t parse_g723( ipp_private_t *codec_data, void *pkt,
185 pj_size_t pkt_size, const pj_timestamp *ts,
186 unsigned *frame_cnt, pjmedia_frame frames[]);
Nanang Izzuddin493a8db2008-08-15 13:17:39 +0000187
Nanang Izzuddindf361e02008-08-16 06:46:08 +0000188static void predecode_g729( ipp_private_t *codec_data,
189 const pjmedia_frame *rtp_frame,
190 USC_Bitstream *usc_frame);
191
192static void predecode_amr( ipp_private_t *codec_data,
193 const pjmedia_frame *rtp_frame,
194 USC_Bitstream *usc_frame);
195static pj_status_t parse_amr( ipp_private_t *codec_data, void *pkt,
Nanang Izzuddin493a8db2008-08-15 13:17:39 +0000196 pj_size_t pkt_size, const pj_timestamp *ts,
197 unsigned *frame_cnt, pjmedia_frame frames[]);
Nanang Izzuddindf361e02008-08-16 06:46:08 +0000198static pj_status_t pack_amr( ipp_private_t *codec_data, void *pkt,
199 pj_size_t *pkt_size, pj_size_t max_pkt_size);
Nanang Izzuddin493a8db2008-08-15 13:17:39 +0000200
201
202/* IPP codec implementation descriptions. */
203static struct ipp_codec {
204 int enabled; /* Is this codec enabled? */
205 const char *name; /* Codec name. */
206 pj_uint8_t pt; /* Payload type. */
207 USC_Fxns *fxns; /* USC callback functions. */
208 unsigned clock_rate; /* Codec's clock rate. */
209 unsigned channel_count; /* Codec's channel count. */
210 unsigned samples_per_frame; /* Codec's samples count. */
211
212 unsigned def_bitrate; /* Default bitrate of this codec. */
213 unsigned max_bitrate; /* Maximum bitrate of this codec. */
214 pj_uint8_t frm_per_pkt; /* Default num of frames per packet.*/
215 int has_native_vad; /* Codec has internal VAD? */
216 int has_native_plc; /* Codec has internal PLC? */
217
Nanang Izzuddindf361e02008-08-16 06:46:08 +0000218 predecode_cb predecode; /* Callback to translate RTP frame
Nanang Izzuddin23a00b72008-08-25 13:58:25 +0000219 into USC frame. */
220 parse_cb parse; /* Callback to parse bitstream. */
221 pack_cb pack; /* Callback to pack bitstream. */
222
223 pjmedia_codec_fmtp dec_fmtp; /* Decoder's fmtp params. */
224}
Nanang Izzuddin493a8db2008-08-15 13:17:39 +0000225
226ipp_codec[] =
227{
Benny Prijonoa4e7cdd2008-08-19 15:01:48 +0000228# if PJMEDIA_HAS_INTEL_IPP_CODEC_AMR
Nanang Izzuddin493a8db2008-08-15 13:17:39 +0000229 {1, "AMR", PJMEDIA_RTP_PT_AMR, &USC_GSMAMR_Fxns, 8000, 1, 160,
230 5900, 12200, 4, 1, 1,
Nanang Izzuddindf361e02008-08-16 06:46:08 +0000231 &predecode_amr, &parse_amr, &pack_amr
Nanang Izzuddin0b8f4ca2008-11-11 11:25:13 +0000232 /*, {1, {{{"octet-align", 11}, {"1", 1}}} } */
Nanang Izzuddindf361e02008-08-16 06:46:08 +0000233 },
234# endif
235
Benny Prijonoa4e7cdd2008-08-19 15:01:48 +0000236# if PJMEDIA_HAS_INTEL_IPP_CODEC_AMRWB
237 {1, "AMR-WB", PJMEDIA_RTP_PT_AMRWB, &USC_AMRWB_Fxns, 16000, 1, 320,
238 15850, 23850, 1, 1, 1,
Nanang Izzuddindf361e02008-08-16 06:46:08 +0000239 &predecode_amr, &parse_amr, &pack_amr
Nanang Izzuddin493a8db2008-08-15 13:17:39 +0000240 },
241# endif
242
Benny Prijonoa4e7cdd2008-08-19 15:01:48 +0000243# if PJMEDIA_HAS_INTEL_IPP_CODEC_G729
Nanang Izzuddin762a5bd2008-09-16 14:11:09 +0000244# if defined(PJ_HAS_FLOATING_POINT) && (PJ_HAS_FLOATING_POINT != 0)
245 {1, "G729", PJMEDIA_RTP_PT_G729, &USC_G729AFP_Fxns, 8000, 1, 80,
Nanang Izzuddin23a00b72008-08-25 13:58:25 +0000246 8000, 11800, 2, 1, 1,
Nanang Izzuddindf361e02008-08-16 06:46:08 +0000247 &predecode_g729, NULL, NULL
Nanang Izzuddin493a8db2008-08-15 13:17:39 +0000248 },
Nanang Izzuddin762a5bd2008-09-16 14:11:09 +0000249# else
250 {1, "G729", PJMEDIA_RTP_PT_G729, &USC_G729I_Fxns, 8000, 1, 80,
251 8000, 11800, 2, 1, 1,
252 &predecode_g729, NULL, NULL
253 },
254# endif
Nanang Izzuddin493a8db2008-08-15 13:17:39 +0000255# endif
256
Benny Prijonoa4e7cdd2008-08-19 15:01:48 +0000257# if PJMEDIA_HAS_INTEL_IPP_CODEC_G723_1
Nanang Izzuddin493a8db2008-08-15 13:17:39 +0000258 /* This is actually G.723.1 */
259 {1, "G723", PJMEDIA_RTP_PT_G723, &USC_G723_Fxns, 8000, 1, 240,
Benny Prijonoa4e7cdd2008-08-19 15:01:48 +0000260 6300, 6300, 1, 1, 1,
Nanang Izzuddindf361e02008-08-16 06:46:08 +0000261 &predecode_g723, &parse_g723, NULL
Nanang Izzuddin493a8db2008-08-15 13:17:39 +0000262 },
263# endif
264
Benny Prijonoa4e7cdd2008-08-19 15:01:48 +0000265# if PJMEDIA_HAS_INTEL_IPP_CODEC_G726
Nanang Izzuddinf216f822008-08-15 18:35:50 +0000266 {0, "G726-16", PJMEDIA_RTP_PT_G726_16, &USC_G726_Fxns, 8000, 1, 80,
Nanang Izzuddin493a8db2008-08-15 13:17:39 +0000267 16000, 16000, 2, 0, 0,
268 NULL, NULL, NULL
269 },
Nanang Izzuddinf216f822008-08-15 18:35:50 +0000270 {0, "G726-24", PJMEDIA_RTP_PT_G726_24, &USC_G726_Fxns, 8000, 1, 80,
Nanang Izzuddin493a8db2008-08-15 13:17:39 +0000271 24000, 24000, 2, 0, 0,
272 NULL, NULL, NULL
273 },
274 {1, "G726-32", PJMEDIA_RTP_PT_G726_32, &USC_G726_Fxns, 8000, 1, 80,
275 32000, 32000, 2, 0, 0,
276 NULL, NULL, NULL
277 },
Nanang Izzuddinf216f822008-08-15 18:35:50 +0000278 {0, "G726-40", PJMEDIA_RTP_PT_G726_40, &USC_G726_Fxns, 8000, 1, 80,
Nanang Izzuddin493a8db2008-08-15 13:17:39 +0000279 40000, 40000, 2, 0, 0,
280 NULL, NULL, NULL
281 },
282# endif
283
Benny Prijonoa4e7cdd2008-08-19 15:01:48 +0000284# if PJMEDIA_HAS_INTEL_IPP_CODEC_G728
Nanang Izzuddin493a8db2008-08-15 13:17:39 +0000285 {1, "G728", PJMEDIA_RTP_PT_G728, &USC_G728_Fxns, 8000, 1, 80,
286 16000, 16000, 2, 0, 1,
287 NULL, NULL, NULL
288 },
289# endif
290
Benny Prijonoa4e7cdd2008-08-19 15:01:48 +0000291# if PJMEDIA_HAS_INTEL_IPP_CODEC_G722_1
Nanang Izzuddin23a00b72008-08-25 13:58:25 +0000292 {0, "G7221", PJMEDIA_RTP_PT_G722_1_16, &USC_G722_Fxns, 16000, 1, 320,
293 16000, 16000, 1, 0, 1,
294 NULL, NULL, NULL,
295 {1, {{{"bitrate", 7}, {"16000", 5}}} }
296 },
297 {1, "G7221", PJMEDIA_RTP_PT_G722_1_24, &USC_G722_Fxns, 16000, 1, 320,
298 24000, 24000, 1, 0, 1,
299 NULL, NULL, NULL,
300 {1, {{{"bitrate", 7}, {"24000", 5}}} }
301 },
302 {1, "G7221", PJMEDIA_RTP_PT_G722_1_32, &USC_G722_Fxns, 16000, 1, 320,
303 32000, 32000, 1, 0, 1,
304 NULL, NULL, NULL,
305 {1, {{{"bitrate", 7}, {"32000", 5}}} }
Nanang Izzuddin493a8db2008-08-15 13:17:39 +0000306 },
307# endif
308};
309
310
Nanang Izzuddind55553a2008-10-28 02:24:46 +0000311#if PJMEDIA_HAS_INTEL_IPP_CODEC_G729
312
313static void predecode_g729( ipp_private_t *codec_data,
314 const pjmedia_frame *rtp_frame,
315 USC_Bitstream *usc_frame)
316{
317 switch (rtp_frame->size) {
318 case 2:
319 /* SID */
320 usc_frame->frametype = 1;
321 usc_frame->bitrate = codec_data->info->params.modes.bitrate;
322 break;
323 case 8:
324 /* G729D */
325 usc_frame->frametype = 2;
326 usc_frame->bitrate = 6400;
327 break;
328 case 10:
329 /* G729 */
330 usc_frame->frametype = 3;
331 usc_frame->bitrate = 8000;
332 break;
333 case 15:
334 /* G729E */
335 usc_frame->frametype = 4;
336 usc_frame->bitrate = 11800;
337 break;
338 default:
339 usc_frame->frametype = 0;
340 usc_frame->bitrate = 0;
341 break;
342 }
343
344 usc_frame->pBuffer = rtp_frame->buf;
345 usc_frame->nbytes = rtp_frame->size;
346}
347
348#endif /* PJMEDIA_HAS_INTEL_IPP_CODEC_G729 */
349
350
351#if PJMEDIA_HAS_INTEL_IPP_CODEC_G723_1
352
353static void predecode_g723( ipp_private_t *codec_data,
354 const pjmedia_frame *rtp_frame,
355 USC_Bitstream *usc_frame)
356{
357 int i, HDR = 0;
358 pj_uint8_t *f = (pj_uint8_t*)rtp_frame->buf;
359
360 PJ_UNUSED_ARG(codec_data);
361
362 for (i = 0; i < 2; ++i){
363 int tmp;
364 tmp = (f[0] >> (i & 0x7)) & 1;
365 HDR += tmp << i ;
366 }
367
368 usc_frame->pBuffer = rtp_frame->buf;
369 usc_frame->nbytes = rtp_frame->size;
370 usc_frame->bitrate = HDR == 0? 6300 : 5300;
371 usc_frame->frametype = 0;
372}
373
374static pj_status_t parse_g723(ipp_private_t *codec_data, void *pkt,
375 pj_size_t pkt_size, const pj_timestamp *ts,
376 unsigned *frame_cnt, pjmedia_frame frames[])
377{
378 unsigned count = 0;
379 pj_uint8_t *f = (pj_uint8_t*)pkt;
380
381 while (pkt_size && count < *frame_cnt) {
382 int framesize, i, j;
383 int HDR = 0;
384
385 for (i = 0; i < 2; ++i){
386 j = (f[0] >> (i & 0x7)) & 1;
387 HDR += j << i ;
388 }
389
390 if (HDR == 0)
391 framesize = 24;
392 else if (HDR == 1)
393 framesize = 20;
394 else if (HDR == 2)
395 framesize = 4;
396 else if (HDR == 3)
397 framesize = 1;
398 else {
399 pj_assert(!"Unknown G723.1 frametype, packet may be corrupted!");
400 return PJMEDIA_CODEC_EINMODE;
401 }
402
403 frames[count].type = PJMEDIA_FRAME_TYPE_AUDIO;
404 frames[count].buf = f;
405 frames[count].size = framesize;
406 frames[count].timestamp.u64 = ts->u64 + count *
407 ipp_codec[codec_data->codec_idx].samples_per_frame;
408
409 f += framesize;
410 pkt_size -= framesize;
411
412 ++count;
413 }
414
415 *frame_cnt = count;
416 return PJ_SUCCESS;
417}
418
419#endif /* PJMEDIA_HAS_INTEL_IPP_CODEC_G723_1 */
420
421
422#if PJMEDIA_HAS_INTEL_IPP_CODEC_AMR
423
424#include <pjmedia-codec/amr_helper.h>
425
Nanang Izzuddin35e01de2008-10-29 10:17:02 +0000426typedef struct amr_settings_t {
Nanang Izzuddin0b8f4ca2008-11-11 11:25:13 +0000427 pjmedia_codec_amr_pack_setting enc_setting;
428 pjmedia_codec_amr_pack_setting dec_setting;
Nanang Izzuddin35e01de2008-10-29 10:17:02 +0000429 pj_int8_t enc_mode;
430} amr_settings_t;
431
432
Nanang Izzuddind55553a2008-10-28 02:24:46 +0000433/* Rearrange AMR bitstream and convert RTP frame into USC frame:
434 * - make the start_bit to be 0
435 * - if it is speech frame, reorder bitstream from sensitivity bits order
436 * to encoder bits order.
437 * - set the appropriate value of usc_frame.
438 */
439static void predecode_amr( ipp_private_t *codec_data,
440 const pjmedia_frame *rtp_frame,
441 USC_Bitstream *usc_frame)
442{
443 pjmedia_frame frame;
444 pjmedia_codec_amr_bit_info *info;
Nanang Izzuddin0b8f4ca2008-11-11 11:25:13 +0000445 pjmedia_codec_amr_pack_setting *setting;
Nanang Izzuddind55553a2008-10-28 02:24:46 +0000446
Nanang Izzuddin35e01de2008-10-29 10:17:02 +0000447 setting = &((amr_settings_t*)codec_data->codec_setting)->dec_setting;
448
Nanang Izzuddind55553a2008-10-28 02:24:46 +0000449 frame = *rtp_frame;
Nanang Izzuddin35e01de2008-10-29 10:17:02 +0000450 pjmedia_codec_amr_predecode(rtp_frame, setting, &frame);
Nanang Izzuddind55553a2008-10-28 02:24:46 +0000451 info = (pjmedia_codec_amr_bit_info*) &frame.bit_info;
452
453 usc_frame->pBuffer = frame.buf;
454 usc_frame->nbytes = frame.size;
455 if (info->mode != -1) {
Nanang Izzuddin35e01de2008-10-29 10:17:02 +0000456 usc_frame->bitrate = setting->amr_nb?
Nanang Izzuddind55553a2008-10-28 02:24:46 +0000457 pjmedia_codec_amrnb_bitrates[info->mode]:
458 pjmedia_codec_amrwb_bitrates[info->mode];
459 } else {
460 usc_frame->bitrate = 0;
461 }
462
463 if (frame.size > 5) {
464 /* Speech */
465 if (info->good_quality)
466 usc_frame->frametype = 0;
467 else
Nanang Izzuddin35e01de2008-10-29 10:17:02 +0000468 usc_frame->frametype = setting->amr_nb ? 5 : 6;
Nanang Izzuddind55553a2008-10-28 02:24:46 +0000469 } else if (frame.size == 5) {
470 /* SID */
471 if (info->good_quality) {
472 pj_bool_t STI;
473 STI = (((pj_uint8_t*)frame.buf)[35 >> 3] & 0x10) != 0;
474 usc_frame->frametype = STI? 2 : 1;
475 } else {
Nanang Izzuddin35e01de2008-10-29 10:17:02 +0000476 usc_frame->frametype = setting->amr_nb ? 6 : 7;
Nanang Izzuddind55553a2008-10-28 02:24:46 +0000477 }
478 } else {
479 /* no data */
480 usc_frame->frametype = 3;
481 }
482}
483
484/* Pack AMR payload */
485static pj_status_t pack_amr(ipp_private_t *codec_data, void *pkt,
486 pj_size_t *pkt_size, pj_size_t max_pkt_size)
487{
488 enum {MAX_FRAMES_PER_PACKET = 16};
489
Nanang Izzuddind55553a2008-10-28 02:24:46 +0000490 pjmedia_frame frames[MAX_FRAMES_PER_PACKET];
491 unsigned nframes = 0;
492 pjmedia_codec_amr_bit_info *info;
493 pj_uint8_t *r; /* Read cursor */
494 pj_uint8_t SID_FT;
Nanang Izzuddin0b8f4ca2008-11-11 11:25:13 +0000495 pjmedia_codec_amr_pack_setting *setting;
Nanang Izzuddind55553a2008-10-28 02:24:46 +0000496
Nanang Izzuddin35e01de2008-10-29 10:17:02 +0000497 setting = &((amr_settings_t*)codec_data->codec_setting)->enc_setting;
Nanang Izzuddind55553a2008-10-28 02:24:46 +0000498
Nanang Izzuddin35e01de2008-10-29 10:17:02 +0000499 SID_FT = (pj_uint8_t)(setting->amr_nb? 8 : 9);
Nanang Izzuddind55553a2008-10-28 02:24:46 +0000500
501 /* Align pkt buf right */
502 r = (pj_uint8_t*)pkt + max_pkt_size - *pkt_size;
503 pj_memmove(r, pkt, *pkt_size);
504
505 /* Get frames */
506 for (;;) {
507 pj_bool_t eof;
508 pj_uint16_t info_;
509
510 info_ = *((pj_uint16_t*)r);
511 eof = ((info_ & 0x40) != 0);
512
513 info = (pjmedia_codec_amr_bit_info*) &frames[nframes].bit_info;
514 pj_bzero(info, sizeof(*info));
515 info->frame_type = (pj_uint8_t)(info_ & 0x0F);
516 info->good_quality = (pj_uint8_t)((info_ & 0x80) == 0);
517 info->mode = (pj_int8_t) ((info_ >> 8) & 0x0F);
518
519 frames[nframes].buf = r + 2;
520 frames[nframes].size = info->frame_type <= SID_FT ?
521 pjmedia_codec_amrnb_framelen[info->frame_type] :
522 0;
523
524 r += frames[nframes].size + 2;
525
526 /* Last frame */
527 if (++nframes >= MAX_FRAMES_PER_PACKET || eof)
528 break;
529 }
530
531 /* Pack */
532 *pkt_size = max_pkt_size;
Nanang Izzuddin35e01de2008-10-29 10:17:02 +0000533 return pjmedia_codec_amr_pack(frames, nframes, setting, pkt, pkt_size);
Nanang Izzuddind55553a2008-10-28 02:24:46 +0000534}
535
536
537/* Parse AMR payload into frames. */
538static pj_status_t parse_amr(ipp_private_t *codec_data, void *pkt,
539 pj_size_t pkt_size, const pj_timestamp *ts,
540 unsigned *frame_cnt, pjmedia_frame frames[])
541{
Nanang Izzuddin35e01de2008-10-29 10:17:02 +0000542 amr_settings_t* s = (amr_settings_t*)codec_data->codec_setting;
Nanang Izzuddin0b8f4ca2008-11-11 11:25:13 +0000543 pjmedia_codec_amr_pack_setting *setting;
Nanang Izzuddin35e01de2008-10-29 10:17:02 +0000544 pj_status_t status;
Nanang Izzuddin0b8f4ca2008-11-11 11:25:13 +0000545 pj_uint8_t cmr;
Nanang Izzuddind55553a2008-10-28 02:24:46 +0000546
Nanang Izzuddin35e01de2008-10-29 10:17:02 +0000547 setting = &s->dec_setting;
Nanang Izzuddind55553a2008-10-28 02:24:46 +0000548
Nanang Izzuddin35e01de2008-10-29 10:17:02 +0000549 status = pjmedia_codec_amr_parse(pkt, pkt_size, ts, setting, frames,
Nanang Izzuddin0b8f4ca2008-11-11 11:25:13 +0000550 frame_cnt, &cmr);
Nanang Izzuddin35e01de2008-10-29 10:17:02 +0000551 if (status != PJ_SUCCESS)
552 return status;
553
554 /* Check Change Mode Request. */
Nanang Izzuddin0b8f4ca2008-11-11 11:25:13 +0000555 if ((setting->amr_nb && cmr <= 7) || (!setting->amr_nb && cmr <= 8)) {
556 s->enc_mode = cmr;
Nanang Izzuddin35e01de2008-10-29 10:17:02 +0000557 }
558
559 return PJ_SUCCESS;
Nanang Izzuddind55553a2008-10-28 02:24:46 +0000560}
561
562#endif /* PJMEDIA_HAS_INTEL_IPP_CODEC_AMR */
563
Nanang Izzuddin493a8db2008-08-15 13:17:39 +0000564
565/*
566 * Initialize and register IPP codec factory to pjmedia endpoint.
567 */
568PJ_DEF(pj_status_t) pjmedia_codec_ipp_init( pjmedia_endpt *endpt )
569{
570 pjmedia_codec_mgr *codec_mgr;
571 pj_status_t status;
572
573 if (ipp_factory.pool != NULL) {
574 /* Already initialized. */
575 return PJ_SUCCESS;
576 }
577
578 /* Create IPP codec factory. */
579 ipp_factory.base.op = &ipp_factory_op;
580 ipp_factory.base.factory_data = NULL;
581 ipp_factory.endpt = endpt;
582
583 ipp_factory.pool = pjmedia_endpt_create_pool(endpt, "IPP codecs", 4000, 4000);
584 if (!ipp_factory.pool)
585 return PJ_ENOMEM;
586
587 /* Create mutex. */
588 status = pj_mutex_create_simple(ipp_factory.pool, "IPP codecs",
589 &ipp_factory.mutex);
590 if (status != PJ_SUCCESS)
591 goto on_error;
592
593 /* Get the codec manager. */
594 codec_mgr = pjmedia_endpt_get_codec_mgr(endpt);
595 if (!codec_mgr) {
596 status = PJ_EINVALIDOP;
597 goto on_error;
598 }
599
600 /* Register codec factory to endpoint. */
601 status = pjmedia_codec_mgr_register_factory(codec_mgr,
602 &ipp_factory.base);
603 if (status != PJ_SUCCESS)
604 goto on_error;
605
606 /* Done. */
607 return PJ_SUCCESS;
608
609on_error:
610 pj_pool_release(ipp_factory.pool);
611 ipp_factory.pool = NULL;
612 return status;
613}
614
615/*
616 * Unregister IPP codecs factory from pjmedia endpoint.
617 */
618PJ_DEF(pj_status_t) pjmedia_codec_ipp_deinit(void)
619{
620 pjmedia_codec_mgr *codec_mgr;
621 pj_status_t status;
622
623 if (ipp_factory.pool == NULL) {
624 /* Already deinitialized */
625 return PJ_SUCCESS;
626 }
627
628 pj_mutex_lock(ipp_factory.mutex);
629
630 /* Get the codec manager. */
631 codec_mgr = pjmedia_endpt_get_codec_mgr(ipp_factory.endpt);
632 if (!codec_mgr) {
633 pj_pool_release(ipp_factory.pool);
634 ipp_factory.pool = NULL;
635 return PJ_EINVALIDOP;
636 }
637
638 /* Unregister IPP codecs factory. */
639 status = pjmedia_codec_mgr_unregister_factory(codec_mgr,
640 &ipp_factory.base);
641
642 /* Destroy mutex. */
643 pj_mutex_destroy(ipp_factory.mutex);
644
645 /* Destroy pool. */
646 pj_pool_release(ipp_factory.pool);
647 ipp_factory.pool = NULL;
648
649 return status;
650}
651
652/*
653 * Check if factory can allocate the specified codec.
654 */
655static pj_status_t ipp_test_alloc( pjmedia_codec_factory *factory,
656 const pjmedia_codec_info *info )
657{
658 unsigned i;
659
660 PJ_UNUSED_ARG(factory);
661
662 /* Type MUST be audio. */
663 if (info->type != PJMEDIA_TYPE_AUDIO)
664 return PJMEDIA_CODEC_EUNSUP;
665
666 for (i = 0; i < PJ_ARRAY_SIZE(ipp_codec); ++i) {
667 pj_str_t name = pj_str((char*)ipp_codec[i].name);
668 if ((pj_stricmp(&info->encoding_name, &name) == 0) &&
669 (info->clock_rate == (unsigned)ipp_codec[i].clock_rate) &&
670 (info->channel_cnt == (unsigned)ipp_codec[i].channel_count) &&
671 (ipp_codec[i].enabled))
672 {
673 return PJ_SUCCESS;
674 }
675 }
676
677 /* Unsupported, or mode is disabled. */
678 return PJMEDIA_CODEC_EUNSUP;
679}
680
681/*
682 * Generate default attribute.
683 */
684static pj_status_t ipp_default_attr (pjmedia_codec_factory *factory,
685 const pjmedia_codec_info *id,
686 pjmedia_codec_param *attr )
687{
688 unsigned i;
689
690 PJ_ASSERT_RETURN(factory==&ipp_factory.base, PJ_EINVAL);
691
692 pj_bzero(attr, sizeof(pjmedia_codec_param));
693
694 for (i = 0; i < PJ_ARRAY_SIZE(ipp_codec); ++i) {
695 pj_str_t name = pj_str((char*)ipp_codec[i].name);
696 if ((pj_stricmp(&id->encoding_name, &name) == 0) &&
697 (id->clock_rate == (unsigned)ipp_codec[i].clock_rate) &&
Nanang Izzuddin23a00b72008-08-25 13:58:25 +0000698 (id->channel_cnt == (unsigned)ipp_codec[i].channel_count) &&
699 (id->pt == (unsigned)ipp_codec[i].pt))
Nanang Izzuddin493a8db2008-08-15 13:17:39 +0000700 {
701 attr->info.pt = (pj_uint8_t)id->pt;
702 attr->info.channel_cnt = ipp_codec[i].channel_count;
703 attr->info.clock_rate = ipp_codec[i].clock_rate;
704 attr->info.avg_bps = ipp_codec[i].def_bitrate;
705 attr->info.max_bps = ipp_codec[i].max_bitrate;
706 attr->info.pcm_bits_per_sample = 16;
707 attr->info.frm_ptime = (pj_uint16_t)
708 (ipp_codec[i].samples_per_frame * 1000 /
709 ipp_codec[i].channel_count /
710 ipp_codec[i].clock_rate);
711 attr->setting.frm_per_pkt = ipp_codec[i].frm_per_pkt;
712
713 /* Default flags. */
Nanang Izzuddin493a8db2008-08-15 13:17:39 +0000714 attr->setting.plc = 1;
715 attr->setting.penh= 0;
Nanang Izzuddin23a00b72008-08-25 13:58:25 +0000716 attr->setting.vad = 1;
717 attr->setting.cng = attr->setting.vad;
718 attr->setting.dec_fmtp = ipp_codec[i].dec_fmtp;
719
720 if (attr->setting.vad == 0) {
721#if PJMEDIA_HAS_INTEL_IPP_CODEC_G729
722 if (id->pt == PJMEDIA_RTP_PT_G729) {
723 /* Signal G729 Annex B is being disabled */
724 attr->setting.dec_fmtp.cnt = 1;
725 pj_strset2(&attr->setting.dec_fmtp.param[0].name, "annexb");
726 pj_strset2(&attr->setting.dec_fmtp.param[0].val, "no");
727 }
728#endif
729 }
Nanang Izzuddin493a8db2008-08-15 13:17:39 +0000730
731 return PJ_SUCCESS;
732 }
733 }
734
735 return PJMEDIA_CODEC_EUNSUP;
736}
737
738/*
739 * Enum codecs supported by this factory.
740 */
741static pj_status_t ipp_enum_codecs(pjmedia_codec_factory *factory,
742 unsigned *count,
743 pjmedia_codec_info codecs[])
744{
745 unsigned max;
746 unsigned i;
747
748 PJ_UNUSED_ARG(factory);
749 PJ_ASSERT_RETURN(codecs && *count > 0, PJ_EINVAL);
750
751 max = *count;
752
753 for (i = 0, *count = 0; i < PJ_ARRAY_SIZE(ipp_codec) && *count < max; ++i)
754 {
755 if (!ipp_codec[i].enabled)
756 continue;
757
758 pj_bzero(&codecs[*count], sizeof(pjmedia_codec_info));
759 codecs[*count].encoding_name = pj_str((char*)ipp_codec[i].name);
760 codecs[*count].pt = ipp_codec[i].pt;
761 codecs[*count].type = PJMEDIA_TYPE_AUDIO;
762 codecs[*count].clock_rate = ipp_codec[i].clock_rate;
763 codecs[*count].channel_cnt = ipp_codec[i].channel_count;
764
765 ++*count;
766 }
767
768 return PJ_SUCCESS;
769}
770
771/*
772 * Allocate a new codec instance.
773 */
774static pj_status_t ipp_alloc_codec( pjmedia_codec_factory *factory,
775 const pjmedia_codec_info *id,
776 pjmedia_codec **p_codec)
777{
778 ipp_private_t *codec_data;
779 pjmedia_codec *codec;
780 int idx;
781 pj_pool_t *pool;
782 unsigned i;
783
784 PJ_ASSERT_RETURN(factory && id && p_codec, PJ_EINVAL);
785 PJ_ASSERT_RETURN(factory == &ipp_factory.base, PJ_EINVAL);
786
787 pj_mutex_lock(ipp_factory.mutex);
788
789 /* Find codec's index */
790 idx = -1;
791 for (i = 0; i < PJ_ARRAY_SIZE(ipp_codec); ++i) {
792 pj_str_t name = pj_str((char*)ipp_codec[i].name);
793 if ((pj_stricmp(&id->encoding_name, &name) == 0) &&
794 (id->clock_rate == (unsigned)ipp_codec[i].clock_rate) &&
795 (id->channel_cnt == (unsigned)ipp_codec[i].channel_count) &&
796 (ipp_codec[i].enabled))
797 {
798 idx = i;
799 break;
800 }
801 }
802 if (idx == -1) {
803 *p_codec = NULL;
804 return PJMEDIA_CODEC_EFAILED;
805 }
806
807 /* Create pool for codec instance */
Benny Prijonoa4e7cdd2008-08-19 15:01:48 +0000808 pool = pjmedia_endpt_create_pool(ipp_factory.endpt, "IPPcodec", 512, 512);
Nanang Izzuddin493a8db2008-08-15 13:17:39 +0000809 codec = PJ_POOL_ZALLOC_T(pool, pjmedia_codec);
810 PJ_ASSERT_RETURN(codec != NULL, PJ_ENOMEM);
811 codec->op = &ipp_op;
812 codec->factory = factory;
813 codec->codec_data = PJ_POOL_ZALLOC_T(pool, ipp_private_t);
814 codec_data = (ipp_private_t*) codec->codec_data;
815
816 /* Create PLC if codec has no internal PLC */
817 if (!ipp_codec[idx].has_native_plc) {
818 pj_status_t status;
819 status = pjmedia_plc_create(pool, ipp_codec[idx].clock_rate,
820 ipp_codec[idx].samples_per_frame, 0,
821 &codec_data->plc);
822 if (status != PJ_SUCCESS) {
823 pj_pool_release(pool);
824 pj_mutex_unlock(ipp_factory.mutex);
825 return status;
826 }
827 }
828
829 /* Create silence detector if codec has no internal VAD */
830 if (!ipp_codec[idx].has_native_vad) {
831 pj_status_t status;
832 status = pjmedia_silence_det_create(pool,
833 ipp_codec[idx].clock_rate,
834 ipp_codec[idx].samples_per_frame,
835 &codec_data->vad);
836 if (status != PJ_SUCCESS) {
837 pj_pool_release(pool);
838 pj_mutex_unlock(ipp_factory.mutex);
839 return status;
840 }
841 }
842
843 codec_data->pool = pool;
844 codec_data->codec_idx = idx;
845
846 pj_mutex_unlock(ipp_factory.mutex);
847
848 *p_codec = codec;
849 return PJ_SUCCESS;
850}
851
852/*
853 * Free codec.
854 */
855static pj_status_t ipp_dealloc_codec( pjmedia_codec_factory *factory,
856 pjmedia_codec *codec )
857{
858 ipp_private_t *codec_data;
859
860 PJ_ASSERT_RETURN(factory && codec, PJ_EINVAL);
861 PJ_ASSERT_RETURN(factory == &ipp_factory.base, PJ_EINVAL);
862
863 /* Close codec, if it's not closed. */
864 codec_data = (ipp_private_t*) codec->codec_data;
865 if (codec_data->enc != NULL || codec_data->dec != NULL) {
866 ipp_codec_close(codec);
867 }
868
869 pj_pool_release(codec_data->pool);
870
871 return PJ_SUCCESS;
872}
873
874/*
875 * Init codec.
876 */
877static pj_status_t ipp_codec_init( pjmedia_codec *codec,
878 pj_pool_t *pool )
879{
880 PJ_UNUSED_ARG(codec);
881 PJ_UNUSED_ARG(pool);
882 return PJ_SUCCESS;
883}
884
885/*
886 * Open codec.
887 */
888static pj_status_t ipp_codec_open( pjmedia_codec *codec,
889 pjmedia_codec_param *attr )
890{
891 ipp_private_t *codec_data = (ipp_private_t*) codec->codec_data;
Benny Prijonoa4e7cdd2008-08-19 15:01:48 +0000892 struct ipp_codec *ippc = &ipp_codec[codec_data->codec_idx];
Nanang Izzuddin493a8db2008-08-15 13:17:39 +0000893 int info_size;
894 pj_pool_t *pool;
Benny Prijonoa4e7cdd2008-08-19 15:01:48 +0000895 int i, j;
Nanang Izzuddin493a8db2008-08-15 13:17:39 +0000896 USC_MemBank *membanks;
897 int nb_membanks;
898
899 pool = codec_data->pool;
Nanang Izzuddin493a8db2008-08-15 13:17:39 +0000900
901 /* Get the codec info size */
Benny Prijonoa4e7cdd2008-08-19 15:01:48 +0000902 if (USC_NoError != ippc->fxns->std.GetInfoSize(&info_size)) {
903 PJ_LOG(1,(THIS_FILE, "Error getting codec info size"));
Nanang Izzuddin493a8db2008-08-15 13:17:39 +0000904 goto on_error;
905 }
906 /* Get the codec info */
907 codec_data->info = pj_pool_zalloc(pool, info_size);
Benny Prijonoa4e7cdd2008-08-19 15:01:48 +0000908 if (USC_NoError != ippc->fxns->std.GetInfo((USC_Handle)NULL,
909 codec_data->info))
Nanang Izzuddin493a8db2008-08-15 13:17:39 +0000910 {
Benny Prijonoa4e7cdd2008-08-19 15:01:48 +0000911 PJ_LOG(1,(THIS_FILE, "Error getting codec info"));
Nanang Izzuddin493a8db2008-08-15 13:17:39 +0000912 goto on_error;
913 }
914
915 /* PREPARING THE ENCODER */
916
917 /* Setting the encoder params */
918 codec_data->info->params.direction = USC_ENCODE;
Nanang Izzuddinf216f822008-08-15 18:35:50 +0000919 codec_data->info->params.modes.vad = attr->setting.vad &&
Nanang Izzuddin23a00b72008-08-25 13:58:25 +0000920 ippc->has_native_vad;
Nanang Izzuddin493a8db2008-08-15 13:17:39 +0000921 codec_data->info->params.modes.bitrate = attr->info.avg_bps;
922 codec_data->info->params.law = 0; /* Linear PCM input */
923
Nanang Izzuddin23a00b72008-08-25 13:58:25 +0000924#if PJMEDIA_HAS_INTEL_IPP_CODEC_G729
925 if (ippc->pt == PJMEDIA_RTP_PT_G729) {
926 /* Check if G729 Annex B is signaled to be disabled */
927 for (i = 0; i < attr->setting.enc_fmtp.cnt; ++i) {
928 if (pj_stricmp2(&attr->setting.enc_fmtp.param[i].name, "annexb")==0)
929 {
930 if (pj_stricmp2(&attr->setting.enc_fmtp.param[i].val, "no")==0)
931 codec_data->info->params.modes.vad = 0;
932 break;
933 }
934 }
935 }
936#endif
937
Nanang Izzuddin493a8db2008-08-15 13:17:39 +0000938 /* Get number of memory blocks needed by the encoder */
Benny Prijonoa4e7cdd2008-08-19 15:01:48 +0000939 if (USC_NoError != ippc->fxns->std.NumAlloc(&codec_data->info->params,
940 &nb_membanks))
Nanang Izzuddin493a8db2008-08-15 13:17:39 +0000941 {
Benny Prijonoa4e7cdd2008-08-19 15:01:48 +0000942 PJ_LOG(1,(THIS_FILE, "Error getting no of memory blocks of encoder"));
Nanang Izzuddin493a8db2008-08-15 13:17:39 +0000943 goto on_error;
944 }
945
946 /* Allocate memory blocks table */
947 membanks = (USC_MemBank*) pj_pool_zalloc(pool,
948 sizeof(USC_MemBank) * nb_membanks);
949 /* Get size of each memory block */
Benny Prijonoa4e7cdd2008-08-19 15:01:48 +0000950 if (USC_NoError != ippc->fxns->std.MemAlloc(&codec_data->info->params,
951 membanks))
Nanang Izzuddin493a8db2008-08-15 13:17:39 +0000952 {
Benny Prijonoa4e7cdd2008-08-19 15:01:48 +0000953 PJ_LOG(1,(THIS_FILE, "Error getting memory blocks size of encoder"));
Nanang Izzuddin493a8db2008-08-15 13:17:39 +0000954 goto on_error;
955 }
956
957 /* Allocate memory for each block */
958 for (i = 0; i < nb_membanks; i++) {
959 membanks[i].pMem = (char*) pj_pool_zalloc(pool, membanks[i].nbytes);
960 }
961
962 /* Create encoder instance */
Benny Prijonoa4e7cdd2008-08-19 15:01:48 +0000963 if (USC_NoError != ippc->fxns->std.Init(&codec_data->info->params,
964 membanks,
965 &codec_data->enc))
Nanang Izzuddin493a8db2008-08-15 13:17:39 +0000966 {
Benny Prijonoa4e7cdd2008-08-19 15:01:48 +0000967 PJ_LOG(1,(THIS_FILE, "Error initializing encoder"));
Nanang Izzuddin493a8db2008-08-15 13:17:39 +0000968 goto on_error;
969 }
970
971 /* PREPARING THE DECODER */
972
973 /* Setting the decoder params */
974 codec_data->info->params.direction = USC_DECODE;
975
Nanang Izzuddin23a00b72008-08-25 13:58:25 +0000976 /* Not sure if VAD affects decoder, just try to be safe */
977 codec_data->info->params.modes.vad = ippc->has_native_vad;
978
Nanang Izzuddin493a8db2008-08-15 13:17:39 +0000979 /* Get number of memory blocks needed by the decoder */
Benny Prijonoa4e7cdd2008-08-19 15:01:48 +0000980 if (USC_NoError != ippc->fxns->std.NumAlloc(&codec_data->info->params,
981 &nb_membanks))
Nanang Izzuddin493a8db2008-08-15 13:17:39 +0000982 {
Benny Prijonoa4e7cdd2008-08-19 15:01:48 +0000983 PJ_LOG(1,(THIS_FILE, "Error getting no of memory blocks of decoder"));
Nanang Izzuddin493a8db2008-08-15 13:17:39 +0000984 goto on_error;
985 }
986
987 /* Allocate memory blocks table */
988 membanks = (USC_MemBank*) pj_pool_zalloc(pool,
989 sizeof(USC_MemBank) * nb_membanks);
990 /* Get size of each memory block */
Benny Prijonoa4e7cdd2008-08-19 15:01:48 +0000991 if (USC_NoError != ippc->fxns->std.MemAlloc(&codec_data->info->params,
992 membanks))
Nanang Izzuddin493a8db2008-08-15 13:17:39 +0000993 {
Benny Prijonoa4e7cdd2008-08-19 15:01:48 +0000994 PJ_LOG(1,(THIS_FILE, "Error getting memory blocks size of decoder"));
Nanang Izzuddin493a8db2008-08-15 13:17:39 +0000995 goto on_error;
996 }
997
998 /* Allocate memory for each block */
999 for (i = 0; i < nb_membanks; i++) {
1000 membanks[i].pMem = (char*) pj_pool_zalloc(pool, membanks[i].nbytes);
1001 }
1002
1003 /* Create decoder instance */
Benny Prijonoa4e7cdd2008-08-19 15:01:48 +00001004 if (USC_NoError != ippc->fxns->std.Init(&codec_data->info->params,
1005 membanks, &codec_data->dec))
Nanang Izzuddin493a8db2008-08-15 13:17:39 +00001006 {
Benny Prijonoa4e7cdd2008-08-19 15:01:48 +00001007 PJ_LOG(1,(THIS_FILE, "Error initializing decoder"));
Nanang Izzuddin493a8db2008-08-15 13:17:39 +00001008 goto on_error;
1009 }
1010
1011 /* Update codec info */
Benny Prijonoa4e7cdd2008-08-19 15:01:48 +00001012 ippc->fxns->std.GetInfo((USC_Handle)codec_data->enc, codec_data->info);
Nanang Izzuddin493a8db2008-08-15 13:17:39 +00001013
1014 /* Get bitstream size */
Benny Prijonoa4e7cdd2008-08-19 15:01:48 +00001015 i = codec_data->info->params.modes.bitrate * ippc->samples_per_frame;
1016 j = ippc->clock_rate << 3;
Nanang Izzuddin493a8db2008-08-15 13:17:39 +00001017 codec_data->frame_size = (pj_uint16_t)(i / j);
1018 if (i % j) ++codec_data->frame_size;
1019
1020 codec_data->vad_enabled = (attr->setting.vad != 0);
1021 codec_data->plc_enabled = (attr->setting.plc != 0);
1022
Nanang Izzuddin35e01de2008-10-29 10:17:02 +00001023#if PJMEDIA_HAS_INTEL_IPP_CODEC_AMR
1024 /* Init AMR settings */
1025 if (ippc->pt == PJMEDIA_RTP_PT_AMR || ippc->pt == PJMEDIA_RTP_PT_AMRWB) {
1026 amr_settings_t *s;
Nanang Izzuddin0b8f4ca2008-11-11 11:25:13 +00001027 pj_uint8_t octet_align = 0;
1028 const pj_str_t STR_FMTP_OCTET_ALIGN = {"octet-align", 11};
1029
1030 /* Check octet-align */
1031 for (i = 0; i < attr->setting.dec_fmtp.cnt; ++i) {
1032 if (pj_stricmp(&attr->setting.dec_fmtp.param[i].name,
1033 &STR_FMTP_OCTET_ALIGN) == 0)
1034 {
1035 octet_align=(pj_uint8_t)
1036 (pj_strtoul(&attr->setting.dec_fmtp.param[i].val));
1037 break;
1038 }
1039 }
Nanang Izzuddin35e01de2008-10-29 10:17:02 +00001040
1041 s = PJ_POOL_ZALLOC_T(pool, amr_settings_t);
1042 codec_data->codec_setting = s;
1043
1044 s->enc_mode = pjmedia_codec_amr_get_mode(ippc->def_bitrate);
1045 if (s->enc_mode < 0)
1046 goto on_error;
1047
1048 s->enc_setting.amr_nb = ippc->pt == PJMEDIA_RTP_PT_AMR;
Nanang Izzuddin0b8f4ca2008-11-11 11:25:13 +00001049 s->enc_setting.octet_aligned = octet_align;
Nanang Izzuddin35e01de2008-10-29 10:17:02 +00001050 s->enc_setting.reorder = PJ_TRUE;
Nanang Izzuddin0b8f4ca2008-11-11 11:25:13 +00001051 s->enc_setting.cmr = 15;
Nanang Izzuddin35e01de2008-10-29 10:17:02 +00001052
1053 s->dec_setting.amr_nb = ippc->pt == PJMEDIA_RTP_PT_AMR;
Nanang Izzuddin0b8f4ca2008-11-11 11:25:13 +00001054 s->dec_setting.octet_aligned = octet_align;
Nanang Izzuddin35e01de2008-10-29 10:17:02 +00001055 s->dec_setting.reorder = PJ_TRUE;
1056 }
1057#endif
1058
Nanang Izzuddin493a8db2008-08-15 13:17:39 +00001059 return PJ_SUCCESS;
1060
1061on_error:
1062 return PJMEDIA_CODEC_EFAILED;
1063}
1064
1065/*
1066 * Close codec.
1067 */
1068static pj_status_t ipp_codec_close( pjmedia_codec *codec )
1069{
1070 PJ_UNUSED_ARG(codec);
1071
1072 return PJ_SUCCESS;
1073}
1074
1075
1076/*
1077 * Modify codec settings.
1078 */
1079static pj_status_t ipp_codec_modify(pjmedia_codec *codec,
1080 const pjmedia_codec_param *attr )
1081{
1082 ipp_private_t *codec_data = (ipp_private_t*) codec->codec_data;
Benny Prijonoa4e7cdd2008-08-19 15:01:48 +00001083 struct ipp_codec *ippc = &ipp_codec[codec_data->codec_idx];
Nanang Izzuddin493a8db2008-08-15 13:17:39 +00001084
1085 codec_data->vad_enabled = (attr->setting.vad != 0);
1086 codec_data->plc_enabled = (attr->setting.plc != 0);
1087
Benny Prijonoa4e7cdd2008-08-19 15:01:48 +00001088 if (ippc->has_native_vad) {
Nanang Izzuddin493a8db2008-08-15 13:17:39 +00001089 USC_Modes modes;
1090
1091 modes = codec_data->info->params.modes;
1092 modes.vad = codec_data->vad_enabled;
Benny Prijonoa4e7cdd2008-08-19 15:01:48 +00001093 ippc->fxns->std.Control(&modes, codec_data->enc);
Nanang Izzuddin493a8db2008-08-15 13:17:39 +00001094 }
1095
1096 return PJ_SUCCESS;
1097}
1098
1099/*
1100 * Get frames in the packet.
1101 */
1102static pj_status_t ipp_codec_parse( pjmedia_codec *codec,
1103 void *pkt,
1104 pj_size_t pkt_size,
1105 const pj_timestamp *ts,
1106 unsigned *frame_cnt,
1107 pjmedia_frame frames[])
1108{
1109 ipp_private_t *codec_data = (ipp_private_t*) codec->codec_data;
Benny Prijonoa4e7cdd2008-08-19 15:01:48 +00001110 struct ipp_codec *ippc = &ipp_codec[codec_data->codec_idx];
Nanang Izzuddin493a8db2008-08-15 13:17:39 +00001111 unsigned count = 0;
1112
1113 PJ_ASSERT_RETURN(frame_cnt, PJ_EINVAL);
1114
Benny Prijonoa4e7cdd2008-08-19 15:01:48 +00001115 if (ippc->parse != NULL) {
1116 return ippc->parse(codec_data, pkt, pkt_size, ts, frame_cnt, frames);
Nanang Izzuddin493a8db2008-08-15 13:17:39 +00001117 }
1118
1119 while (pkt_size >= codec_data->frame_size && count < *frame_cnt) {
1120 frames[count].type = PJMEDIA_FRAME_TYPE_AUDIO;
1121 frames[count].buf = pkt;
1122 frames[count].size = codec_data->frame_size;
Benny Prijonoa4e7cdd2008-08-19 15:01:48 +00001123 frames[count].timestamp.u64 = ts->u64 + count*ippc->samples_per_frame;
Nanang Izzuddin493a8db2008-08-15 13:17:39 +00001124
1125 pkt = ((char*)pkt) + codec_data->frame_size;
1126 pkt_size -= codec_data->frame_size;
1127
1128 ++count;
1129 }
1130
1131 if (pkt_size && count < *frame_cnt) {
1132 frames[count].type = PJMEDIA_FRAME_TYPE_AUDIO;
1133 frames[count].buf = pkt;
1134 frames[count].size = pkt_size;
Benny Prijonoa4e7cdd2008-08-19 15:01:48 +00001135 frames[count].timestamp.u64 = ts->u64 + count*ippc->samples_per_frame;
Nanang Izzuddin493a8db2008-08-15 13:17:39 +00001136 ++count;
1137 }
1138
1139 *frame_cnt = count;
1140 return PJ_SUCCESS;
1141}
1142
1143/*
1144 * Encode frames.
1145 */
1146static pj_status_t ipp_codec_encode( pjmedia_codec *codec,
1147 const struct pjmedia_frame *input,
1148 unsigned output_buf_len,
1149 struct pjmedia_frame *output)
1150{
1151 ipp_private_t *codec_data = (ipp_private_t*) codec->codec_data;
Benny Prijonoa4e7cdd2008-08-19 15:01:48 +00001152 struct ipp_codec *ippc = &ipp_codec[codec_data->codec_idx];
Nanang Izzuddin493a8db2008-08-15 13:17:39 +00001153 unsigned samples_per_frame;
1154 unsigned nsamples;
1155 pj_size_t tx = 0;
1156 pj_int16_t *pcm_in = (pj_int16_t*)input->buf;
Benny Prijonob1339242008-08-21 20:58:55 +00001157 pj_uint8_t *bits_out = (pj_uint8_t*) output->buf;
Nanang Izzuddindf361e02008-08-16 06:46:08 +00001158 pj_uint8_t pt;
Nanang Izzuddin493a8db2008-08-15 13:17:39 +00001159
1160 /* Invoke external VAD if codec has no internal VAD */
1161 if (codec_data->vad && codec_data->vad_enabled) {
1162 pj_bool_t is_silence;
1163 pj_int32_t silence_duration;
1164
1165 silence_duration = pj_timestamp_diff32(&codec_data->last_tx,
1166 &input->timestamp);
1167
1168 is_silence = pjmedia_silence_det_detect(codec_data->vad,
1169 (const pj_int16_t*) input->buf,
1170 (input->size >> 1),
1171 NULL);
1172 if (is_silence &&
1173 PJMEDIA_CODEC_MAX_SILENCE_PERIOD != -1 &&
Benny Prijonoa4e7cdd2008-08-19 15:01:48 +00001174 silence_duration < (PJMEDIA_CODEC_MAX_SILENCE_PERIOD *
1175 (int)ippc->clock_rate / 1000))
Nanang Izzuddin493a8db2008-08-15 13:17:39 +00001176 {
1177 output->type = PJMEDIA_FRAME_TYPE_NONE;
1178 output->buf = NULL;
1179 output->size = 0;
1180 output->timestamp = input->timestamp;
1181 return PJ_SUCCESS;
1182 } else {
1183 codec_data->last_tx = input->timestamp;
1184 }
1185 }
1186
1187 nsamples = input->size >> 1;
Benny Prijonoa4e7cdd2008-08-19 15:01:48 +00001188 samples_per_frame = ippc->samples_per_frame;
1189 pt = ippc->pt;
Nanang Izzuddin493a8db2008-08-15 13:17:39 +00001190
1191 PJ_ASSERT_RETURN(nsamples % samples_per_frame == 0,
1192 PJMEDIA_CODEC_EPCMFRMINLEN);
1193
1194 /* Encode the frames */
1195 while (nsamples >= samples_per_frame) {
1196 USC_PCMStream in;
1197 USC_Bitstream out;
1198
1199 in.bitrate = codec_data->info->params.modes.bitrate;
1200 in.nbytes = samples_per_frame << 1;
1201 in.pBuffer = (char*)pcm_in;
1202 in.pcmType.bitPerSample = codec_data->info->params.pcmType.bitPerSample;
1203 in.pcmType.nChannels = codec_data->info->params.pcmType.nChannels;
1204 in.pcmType.sample_frequency = codec_data->info->params.pcmType.sample_frequency;
1205
Benny Prijonob1339242008-08-21 20:58:55 +00001206 out.pBuffer = (char*)bits_out;
Nanang Izzuddin493a8db2008-08-15 13:17:39 +00001207
Benny Prijonoa4e7cdd2008-08-19 15:01:48 +00001208#if PJMEDIA_HAS_INTEL_IPP_CODEC_AMR
Nanang Izzuddind55553a2008-10-28 02:24:46 +00001209 /* For AMR: reserve two octets for AMR frame info */
Nanang Izzuddindf361e02008-08-16 06:46:08 +00001210 if (pt == PJMEDIA_RTP_PT_AMR || pt == PJMEDIA_RTP_PT_AMRWB) {
Nanang Izzuddind55553a2008-10-28 02:24:46 +00001211 out.pBuffer += 2;
Nanang Izzuddin493a8db2008-08-15 13:17:39 +00001212 }
1213#endif
1214
Benny Prijonoa4e7cdd2008-08-19 15:01:48 +00001215 if (USC_NoError != ippc->fxns->Encode(codec_data->enc, &in, &out)) {
Nanang Izzuddin493a8db2008-08-15 13:17:39 +00001216 break;
1217 }
1218
Benny Prijonoa4e7cdd2008-08-19 15:01:48 +00001219#if PJMEDIA_HAS_INTEL_IPP_CODEC_AMR
Nanang Izzuddin35e01de2008-10-29 10:17:02 +00001220 /* For AMR: put info (frametype, degraded, last frame, mode) in the
1221 * first two octets for payload packing.
Benny Prijonoa4e7cdd2008-08-19 15:01:48 +00001222 */
Nanang Izzuddindf361e02008-08-16 06:46:08 +00001223 if (pt == PJMEDIA_RTP_PT_AMR || pt == PJMEDIA_RTP_PT_AMRWB) {
Nanang Izzuddind55553a2008-10-28 02:24:46 +00001224 pj_uint16_t *info = (pj_uint16_t*)bits_out;
Nanang Izzuddin493a8db2008-08-15 13:17:39 +00001225
Nanang Izzuddind55553a2008-10-28 02:24:46 +00001226 /* Two octets for AMR frame info, 0=LSB:
Nanang Izzuddin493a8db2008-08-15 13:17:39 +00001227 * bit 0-3 : frame type
1228 * bit 6 : last frame flag
1229 * bit 7 : quality flag
Nanang Izzuddind55553a2008-10-28 02:24:46 +00001230 * bit 8-11 : mode
Nanang Izzuddin493a8db2008-08-15 13:17:39 +00001231 */
Nanang Izzuddind55553a2008-10-28 02:24:46 +00001232 out.nbytes += 2;
Nanang Izzuddindf361e02008-08-16 06:46:08 +00001233 if (out.frametype == 0 || out.frametype == 4 ||
1234 (pt == PJMEDIA_RTP_PT_AMR && out.frametype == 5) ||
1235 (pt == PJMEDIA_RTP_PT_AMRWB && out.frametype == 6))
1236 {
Nanang Izzuddind55553a2008-10-28 02:24:46 +00001237 /* Speech frame type */
1238 *info = (char)pjmedia_codec_amr_get_mode(out.bitrate);
1239 /* Quality */
Nanang Izzuddindf361e02008-08-16 06:46:08 +00001240 if (out.frametype == 5 || out.frametype == 6)
Nanang Izzuddin493a8db2008-08-15 13:17:39 +00001241 *info |= 0x80;
Nanang Izzuddindf361e02008-08-16 06:46:08 +00001242 } else if (out.frametype == 1 || out.frametype == 2 ||
1243 (pt == PJMEDIA_RTP_PT_AMR && out.frametype == 6) ||
1244 (pt == PJMEDIA_RTP_PT_AMRWB && out.frametype == 7))
1245 {
Nanang Izzuddind55553a2008-10-28 02:24:46 +00001246 /* SID frame type */
Benny Prijonoa4e7cdd2008-08-19 15:01:48 +00001247 *info = (pj_uint8_t)(pt == PJMEDIA_RTP_PT_AMRWB? 9 : 8);
Nanang Izzuddind55553a2008-10-28 02:24:46 +00001248 /* Quality */
Nanang Izzuddindf361e02008-08-16 06:46:08 +00001249 if (out.frametype == 6 || out.frametype == 7)
1250 *info |= 0x80;
1251 } else {
Nanang Izzuddin493a8db2008-08-15 13:17:39 +00001252 /* Untransmited */
1253 *info = 15;
Nanang Izzuddind55553a2008-10-28 02:24:46 +00001254 out.nbytes = 2;
Nanang Izzuddin493a8db2008-08-15 13:17:39 +00001255 }
1256
Nanang Izzuddind55553a2008-10-28 02:24:46 +00001257 /* Mode */
1258 *info |= (char)pjmedia_codec_amr_get_mode(out.bitrate) << 8;
1259
Nanang Izzuddin493a8db2008-08-15 13:17:39 +00001260 /* Last frame flag */
1261 if (nsamples == samples_per_frame)
1262 *info |= 0x40;
1263 }
Nanang Izzuddin7dd32682008-08-19 11:23:33 +00001264#endif
Nanang Izzuddin493a8db2008-08-15 13:17:39 +00001265
1266 pcm_in += samples_per_frame;
1267 nsamples -= samples_per_frame;
1268 tx += out.nbytes;
1269 bits_out += out.nbytes;
Nanang Izzuddin23a00b72008-08-25 13:58:25 +00001270
1271#if PJMEDIA_HAS_INTEL_IPP_CODEC_G729
Nanang Izzuddine3a6fca2008-08-27 13:15:25 +00001272 if (pt == PJMEDIA_RTP_PT_G729) {
1273 if (out.frametype == 1) {
1274 /* SID */
1275 break;
1276 } else if (out.frametype == 0) {
1277 /* Untransmitted */
1278 tx -= out.nbytes;
1279 break;
1280 }
Nanang Izzuddin23a00b72008-08-25 13:58:25 +00001281 }
1282#endif
1283
Nanang Izzuddin493a8db2008-08-15 13:17:39 +00001284 }
Nanang Izzuddin493a8db2008-08-15 13:17:39 +00001285
Benny Prijonoa4e7cdd2008-08-19 15:01:48 +00001286 if (ippc->pack != NULL) {
1287 ippc->pack(codec_data, output->buf, &tx, output_buf_len);
Nanang Izzuddin493a8db2008-08-15 13:17:39 +00001288 }
1289
1290 /* Check if we don't need to transmit the frame (DTX) */
1291 if (tx == 0) {
1292 output->buf = NULL;
1293 output->size = 0;
1294 output->timestamp.u64 = input->timestamp.u64;
1295 output->type = PJMEDIA_FRAME_TYPE_NONE;
1296 return PJ_SUCCESS;
1297 }
1298
1299 output->size = tx;
1300 output->type = PJMEDIA_FRAME_TYPE_AUDIO;
1301 output->timestamp = input->timestamp;
1302
1303 return PJ_SUCCESS;
1304}
1305
1306/*
1307 * Decode frame.
1308 */
1309static pj_status_t ipp_codec_decode( pjmedia_codec *codec,
1310 const struct pjmedia_frame *input,
1311 unsigned output_buf_len,
1312 struct pjmedia_frame *output)
1313{
1314 ipp_private_t *codec_data = (ipp_private_t*) codec->codec_data;
Benny Prijonoa4e7cdd2008-08-19 15:01:48 +00001315 struct ipp_codec *ippc = &ipp_codec[codec_data->codec_idx];
Nanang Izzuddin493a8db2008-08-15 13:17:39 +00001316 unsigned samples_per_frame;
1317 USC_PCMStream out;
1318 USC_Bitstream in;
1319 pj_uint8_t pt;
1320
Benny Prijonoa4e7cdd2008-08-19 15:01:48 +00001321 pt = ippc->pt;
1322 samples_per_frame = ippc->samples_per_frame;
Nanang Izzuddin493a8db2008-08-15 13:17:39 +00001323
1324 PJ_ASSERT_RETURN(output_buf_len >= samples_per_frame << 1,
1325 PJMEDIA_CODEC_EPCMTOOSHORT);
1326
1327 if (input->type == PJMEDIA_FRAME_TYPE_AUDIO) {
Benny Prijonoa4e7cdd2008-08-19 15:01:48 +00001328 if (ippc->predecode) {
1329 ippc->predecode(codec_data, input, &in);
Nanang Izzuddin493a8db2008-08-15 13:17:39 +00001330 } else {
1331 /* Most IPP codecs have frametype==0 for speech frame */
Nanang Izzuddindf361e02008-08-16 06:46:08 +00001332 in.pBuffer = (char*)input->buf;
1333 in.nbytes = input->size;
Nanang Izzuddin493a8db2008-08-15 13:17:39 +00001334 in.frametype = 0;
1335 in.bitrate = codec_data->info->params.modes.bitrate;
1336 }
1337
1338 out.pBuffer = output->buf;
Nanang Izzuddin493a8db2008-08-15 13:17:39 +00001339 }
Nanang Izzuddin493a8db2008-08-15 13:17:39 +00001340
1341 if (input->type != PJMEDIA_FRAME_TYPE_AUDIO ||
Benny Prijonoa4e7cdd2008-08-19 15:01:48 +00001342 USC_NoError != ippc->fxns->Decode(codec_data->dec, &in, &out))
Nanang Izzuddin493a8db2008-08-15 13:17:39 +00001343 {
1344 pjmedia_zero_samples((pj_int16_t*)output->buf, samples_per_frame);
1345 output->size = samples_per_frame << 1;
1346 output->timestamp.u64 = input->timestamp.u64;
1347 output->type = PJMEDIA_FRAME_TYPE_AUDIO;
1348 return PJ_SUCCESS;
1349 }
1350
Benny Prijonoa4e7cdd2008-08-19 15:01:48 +00001351#if PJMEDIA_HAS_INTEL_IPP_CODEC_G726
Nanang Izzuddin493a8db2008-08-15 13:17:39 +00001352 /* For G.726: amplify decoding result (USC G.726 encoder deamplified it) */
Nanang Izzuddin493a8db2008-08-15 13:17:39 +00001353 if (pt == PJMEDIA_RTP_PT_G726_16 || pt == PJMEDIA_RTP_PT_G726_24 ||
1354 pt == PJMEDIA_RTP_PT_G726_32 || pt == PJMEDIA_RTP_PT_G726_40)
1355 {
1356 unsigned i;
1357 pj_int16_t *s = (pj_int16_t*)output->buf;
1358
1359 for (i = 0; i < samples_per_frame; ++i)
1360 s[i] <<= 2;
1361 }
1362#endif
1363
1364 output->type = PJMEDIA_FRAME_TYPE_AUDIO;
1365 output->size = samples_per_frame << 1;
1366 output->timestamp.u64 = input->timestamp.u64;
1367
1368 /* Invoke external PLC if codec has no internal PLC */
1369 if (codec_data->plc && codec_data->plc_enabled)
1370 pjmedia_plc_save(codec_data->plc, (pj_int16_t*)output->buf);
1371
1372 return PJ_SUCCESS;
1373}
1374
1375/*
1376 * Recover lost frame.
1377 */
1378static pj_status_t ipp_codec_recover(pjmedia_codec *codec,
1379 unsigned output_buf_len,
1380 struct pjmedia_frame *output)
1381{
1382 ipp_private_t *codec_data = (ipp_private_t*) codec->codec_data;
Benny Prijonoa4e7cdd2008-08-19 15:01:48 +00001383 struct ipp_codec *ippc = &ipp_codec[codec_data->codec_idx];
Nanang Izzuddin493a8db2008-08-15 13:17:39 +00001384 unsigned samples_per_frame;
1385
1386 PJ_UNUSED_ARG(output_buf_len);
1387
Benny Prijonoa4e7cdd2008-08-19 15:01:48 +00001388 samples_per_frame = ippc->samples_per_frame;
Nanang Izzuddin493a8db2008-08-15 13:17:39 +00001389
1390 output->type = PJMEDIA_FRAME_TYPE_AUDIO;
1391 output->size = samples_per_frame << 1;
1392
1393 if (codec_data->plc_enabled) {
1394 if (codec_data->plc) {
1395 pjmedia_plc_generate(codec_data->plc, (pj_int16_t*)output->buf);
1396 } else {
1397 USC_PCMStream out;
1398 out.pBuffer = output->buf;
Benny Prijonoa4e7cdd2008-08-19 15:01:48 +00001399 ippc->fxns->Decode(codec_data->dec, NULL, &out);
Nanang Izzuddin493a8db2008-08-15 13:17:39 +00001400 }
1401 } else {
1402 pjmedia_zero_samples((pj_int16_t*)output->buf, samples_per_frame);
1403 }
1404
1405 return PJ_SUCCESS;
1406}
1407
Nanang Izzuddin493a8db2008-08-15 13:17:39 +00001408
Benny Prijonoa4e7cdd2008-08-19 15:01:48 +00001409#if defined(_MSC_VER) && PJMEDIA_AUTO_LINK_IPP_LIBS
1410# pragma comment( lib, "ippcore.lib")
1411# pragma comment( lib, "ipps.lib")
1412# pragma comment( lib, "ippsc.lib")
1413# pragma comment( lib, "ippsr.lib")
1414# pragma comment( lib, "usc.lib")
Nanang Izzuddin493a8db2008-08-15 13:17:39 +00001415#endif
1416
1417
Benny Prijonoa4e7cdd2008-08-19 15:01:48 +00001418#endif /* PJMEDIA_HAS_INTEL_IPP */
Nanang Izzuddin493a8db2008-08-15 13:17:39 +00001419