~ubuntu-branches/ubuntu/wily/sflphone/wily

« back to all changes in this revision

Viewing changes to daemon/libs/pjproject-2.2.1/pjmedia/src/test/codec_vectors.c

  • Committer: Package Import Robot
  • Author(s): Francois Marier, Francois Marier, Mark Purcell
  • Date: 2014-10-18 15:08:50 UTC
  • mfrom: (1.1.12)
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20141018150850-2exfk34ckb15pcwi
Tags: 1.4.1-0.1
[ Francois Marier ]
* Non-maintainer upload
* New upstream release (closes: #759576, #741130)
  - debian/rules +PJPROJECT_VERSION := 2.2.1
  - add upstream patch to fix broken TLS support
  - add patch to fix pjproject regression

[ Mark Purcell ]
* Build-Depends:
  - sflphone-daemon + libavformat-dev, libavcodec-dev, libswscale-dev,
  libavdevice-dev, libavutil-dev
  - sflphone-gnome + libclutter-gtk-1.0-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $Id: codec_vectors.c 4712 2014-01-23 08:09:29Z nanang $ */
 
2
/* 
 
3
 * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
 
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 "test.h"
 
20
#include <pjmedia-codec.h>
 
21
 
 
22
#define THIS_FILE   "codec_vectors.c"
 
23
#define TMP_OUT     "output.tmp"
 
24
 
 
25
/*
 
26
 * Encode test. Read input from WAV file, encode to temporary output file, 
 
27
 * and compare the temporary output file to the reference file.
 
28
 */
 
29
static int codec_test_encode(pjmedia_codec_mgr *mgr, 
 
30
                             char *codec_name, 
 
31
                             unsigned bitrate,
 
32
                             const char *wav_file,
 
33
                             const char *ref_encoded_file)
 
34
{
 
35
    pj_str_t codec_id = pj_str(codec_name);
 
36
    pj_pool_t *pool = NULL;
 
37
    unsigned count, samples_per_frame;
 
38
    pj_size_t encoded_frame_len = 0, pos;
 
39
    pjmedia_codec *codec = NULL;
 
40
    const pjmedia_codec_info *ci[1];
 
41
    pjmedia_codec_param codec_param;
 
42
    pjmedia_port *wav_port = NULL;
 
43
    pjmedia_frame in_frame, out_frame;
 
44
    FILE *output = NULL, *fref = NULL;
 
45
    int rc = 0;
 
46
    pj_status_t status;
 
47
 
 
48
    pool = pj_pool_create(mem, "codec-vectors", 512, 512, NULL);
 
49
    if (!pool)  {
 
50
        rc = -20;
 
51
        goto on_return;
 
52
    }
 
53
 
 
54
    /* Find and open the codec */
 
55
    count = 1;
 
56
    status = pjmedia_codec_mgr_find_codecs_by_id(mgr, &codec_id, &count, ci, NULL);
 
57
    if (status != PJ_SUCCESS) {
 
58
        rc = -30;
 
59
        goto on_return;
 
60
    }
 
61
 
 
62
    status = pjmedia_codec_mgr_alloc_codec(mgr, ci[0], &codec);
 
63
    if (status != PJ_SUCCESS) {
 
64
        rc = -40;
 
65
        goto on_return;
 
66
    }
 
67
 
 
68
    status = pjmedia_codec_mgr_get_default_param(mgr, ci[0], &codec_param);
 
69
    if (status != PJ_SUCCESS) {
 
70
        rc = -50;
 
71
        goto on_return;
 
72
    }
 
73
 
 
74
    codec_param.info.avg_bps = bitrate;
 
75
    codec_param.setting.vad = 0;
 
76
 
 
77
    status = pjmedia_codec_init(codec, pool);
 
78
    if (status != PJ_SUCCESS) {
 
79
        rc = -60;
 
80
        goto on_return;
 
81
    }
 
82
 
 
83
    status = pjmedia_codec_open(codec, &codec_param);
 
84
    if (status != PJ_SUCCESS) {
 
85
        rc = -70;
 
86
        goto on_return;
 
87
    }
 
88
 
 
89
    /* Open WAV file */
 
90
    status = pjmedia_wav_player_port_create(pool, wav_file, 
 
91
                                            codec_param.info.frm_ptime, 
 
92
                                            PJMEDIA_FILE_NO_LOOP, 0, 
 
93
                                            &wav_port);
 
94
    if (status != PJ_SUCCESS) {
 
95
        rc = -80;
 
96
        goto on_return;
 
97
    }
 
98
 
 
99
    /* Open output file */
 
100
    output = fopen(TMP_OUT, "wb");
 
101
    if (!output) {
 
102
        rc = -90;
 
103
        goto on_return;
 
104
    }
 
105
 
 
106
    /* Allocate buffer for PCM and encoded frames */
 
107
    samples_per_frame = codec_param.info.clock_rate * codec_param.info.frm_ptime / 1000;
 
108
    in_frame.buf = pj_pool_alloc(pool, samples_per_frame * 2);
 
109
    out_frame.buf = (pj_uint8_t*) pj_pool_alloc(pool, samples_per_frame);
 
110
 
 
111
    /* Loop read WAV file and encode and write to output file */
 
112
    for (;;) {
 
113
        in_frame.size = samples_per_frame * 2;
 
114
        in_frame.type = PJMEDIA_FRAME_TYPE_AUDIO;
 
115
 
 
116
        status = pjmedia_port_get_frame(wav_port, &in_frame);
 
117
        if (status != PJ_SUCCESS || in_frame.type != PJMEDIA_FRAME_TYPE_AUDIO)
 
118
            break;
 
119
 
 
120
        out_frame.size = samples_per_frame;
 
121
        status = pjmedia_codec_encode(codec, &in_frame, samples_per_frame,
 
122
                                   &out_frame);
 
123
        if (status != PJ_SUCCESS) {
 
124
            rc = -95;
 
125
            goto on_return;
 
126
        }
 
127
 
 
128
        if (out_frame.size) {
 
129
            fwrite(out_frame.buf, out_frame.size, 1, output);
 
130
 
 
131
            if (encoded_frame_len == 0)
 
132
                encoded_frame_len = out_frame.size;
 
133
        }    
 
134
    }
 
135
 
 
136
    fclose(output);
 
137
    output = NULL;
 
138
    
 
139
    /* Compare encoded files */
 
140
    fref = fopen(ref_encoded_file, "rb");
 
141
    if (!fref) {
 
142
        rc = -100;
 
143
        goto on_return;
 
144
    }
 
145
 
 
146
    output = fopen(TMP_OUT, "rb");
 
147
    if (!output) {
 
148
        rc = -110;
 
149
        goto on_return;
 
150
    }
 
151
 
 
152
    pos = 0;
 
153
    for (;;) {
 
154
        pj_size_t count;
 
155
        
 
156
        count = fread(in_frame.buf, encoded_frame_len, 1, fref);
 
157
        if (count != 1)
 
158
            break;
 
159
 
 
160
        count = fread(out_frame.buf, encoded_frame_len, 1, output);
 
161
        if (count != 1)
 
162
            break;
 
163
 
 
164
        if (memcmp(in_frame.buf, out_frame.buf, encoded_frame_len)) {
 
165
            unsigned i;
 
166
            pj_uint8_t *in = (pj_uint8_t*)in_frame.buf;
 
167
            pj_uint8_t *out = (pj_uint8_t*)out_frame.buf;
 
168
 
 
169
            for (i=0; i<encoded_frame_len; ++i) {
 
170
                if (in[i] != out[i])
 
171
                    break;
 
172
            }
 
173
 
 
174
            PJ_LOG(1,(THIS_FILE,"     failed: mismatch at pos %d", pos+i));
 
175
            rc = -200;
 
176
            break;
 
177
        }
 
178
 
 
179
        pos += encoded_frame_len;
 
180
    }
 
181
 
 
182
on_return:
 
183
    if (output)
 
184
        fclose(output);
 
185
 
 
186
    if (fref)
 
187
        fclose(fref);
 
188
 
 
189
    if (codec) {
 
190
        pjmedia_codec_close(codec);
 
191
        pjmedia_codec_mgr_dealloc_codec(mgr, codec);
 
192
    }
 
193
 
 
194
    if (wav_port)
 
195
        pjmedia_port_destroy(wav_port);
 
196
 
 
197
    if (pool)
 
198
        pj_pool_release(pool);
 
199
 
 
200
    return rc;
 
201
}
 
202
 
 
203
 
 
204
/*
 
205
 * Read file in ITU format (".itu" extension).
 
206
 *
 
207
 * Set swap_endian to TRUE if the ITU file is stored in little 
 
208
 * endian format (normally true).
 
209
 */
 
210
static int read_ITU_format(FILE  *fp_bitstream,
 
211
                           short *out_words,
 
212
                           short *p_frame_error_flag,
 
213
                           int number_of_16bit_words_per_frame,
 
214
                           pj_bool_t swap_endian)
 
215
{
 
216
    enum { MAX_BITS_PER_FRAME = 160*8 };
 
217
    short i,j;
 
218
    short nsamp;
 
219
    short packed_word;
 
220
    short bit_count;
 
221
    short bit;
 
222
    short in_array[MAX_BITS_PER_FRAME+2];
 
223
    short one = 0x0081;
 
224
    short zero = 0x007f;
 
225
    short frame_start = 0x6b21;
 
226
 
 
227
    nsamp = (short)fread(in_array, 2, 2 + 16*number_of_16bit_words_per_frame,
 
228
                         fp_bitstream);
 
229
 
 
230
    j = 0;
 
231
    bit = in_array[j++];
 
232
    if (bit != frame_start) {
 
233
        *p_frame_error_flag = 1;
 
234
    } else {
 
235
        *p_frame_error_flag = 0;
 
236
        
 
237
        /* increment j to skip over the number of bits in frame */
 
238
        j++;
 
239
 
 
240
        for (i=0; i<number_of_16bit_words_per_frame; i++) {
 
241
            packed_word = 0;
 
242
            bit_count = 15;
 
243
            while (bit_count >= 0) {
 
244
                bit = in_array[j++];
 
245
                if (bit == zero) 
 
246
                    bit = 0;
 
247
                else if (bit == one) 
 
248
                    bit = 1;
 
249
                else 
 
250
                    *p_frame_error_flag = 1;
 
251
 
 
252
                packed_word <<= 1;
 
253
                packed_word = (short )(packed_word + bit);
 
254
                bit_count--;
 
255
            }
 
256
 
 
257
            if (swap_endian)
 
258
                out_words[i] = pj_ntohs(packed_word);
 
259
            else
 
260
                out_words[i] = packed_word;
 
261
        }
 
262
    }
 
263
    return (nsamp-1)/16;
 
264
}
 
265
 
 
266
 
 
267
/*
 
268
 * Decode test
 
269
 *
 
270
 * Decode the specified encoded file in "in_encoded_file" into temporary
 
271
 * PCM output file, and compare the temporary PCM output file with
 
272
 * the PCM reference file.
 
273
 *
 
274
 * Some reference file requires manipulation to the PCM output
 
275
 * before comparison, such manipulation can be done by supplying
 
276
 * this function with the "manip" function.
 
277
 */
 
278
static int codec_test_decode(pjmedia_codec_mgr *mgr, 
 
279
                             char *codec_name, 
 
280
                             unsigned bitrate,
 
281
                             unsigned encoded_len,
 
282
                             const char *in_encoded_file,
 
283
                             const char *ref_pcm_file,
 
284
                             void (*manip)(short *pcm, unsigned count))
 
285
{
 
286
    pj_str_t codec_id = pj_str(codec_name);
 
287
    pj_pool_t *pool = NULL;
 
288
    unsigned count, samples_per_frame, pos;
 
289
    pjmedia_codec *codec = NULL;
 
290
    const pjmedia_codec_info *ci[1];
 
291
    pjmedia_codec_param codec_param;
 
292
    pjmedia_frame out_frame;
 
293
    void *pkt;
 
294
    FILE *input = NULL, *output = NULL, *fref = NULL;
 
295
    pj_bool_t is_itu_format = PJ_FALSE;
 
296
    int rc = 0;
 
297
    pj_status_t status;
 
298
 
 
299
    pool = pj_pool_create(mem, "codec-vectors", 512, 512, NULL);
 
300
    if (!pool)  {
 
301
        rc = -20;
 
302
        goto on_return;
 
303
    }
 
304
 
 
305
    /* Find and open the codec */
 
306
    count = 1;
 
307
    status = pjmedia_codec_mgr_find_codecs_by_id(mgr, &codec_id, &count, ci, NULL);
 
308
    if (status != PJ_SUCCESS) {
 
309
        rc = -30;
 
310
        goto on_return;
 
311
    }
 
312
 
 
313
    status = pjmedia_codec_mgr_alloc_codec(mgr, ci[0], &codec);
 
314
    if (status != PJ_SUCCESS) {
 
315
        rc = -40;
 
316
        goto on_return;
 
317
    }
 
318
 
 
319
    status = pjmedia_codec_mgr_get_default_param(mgr, ci[0], &codec_param);
 
320
    if (status != PJ_SUCCESS) {
 
321
        rc = -50;
 
322
        goto on_return;
 
323
    }
 
324
 
 
325
    codec_param.info.avg_bps = bitrate;
 
326
    codec_param.setting.vad = 0;
 
327
 
 
328
    status = pjmedia_codec_init(codec, pool);
 
329
    if (status != PJ_SUCCESS) {
 
330
        rc = -60;
 
331
        goto on_return;
 
332
    }
 
333
 
 
334
    status = pjmedia_codec_open(codec, &codec_param);
 
335
    if (status != PJ_SUCCESS) {
 
336
        rc = -70;
 
337
        goto on_return;
 
338
    }
 
339
 
 
340
    /* Open input file */
 
341
    input = fopen(in_encoded_file, "rb");
 
342
    if (!input) {
 
343
        rc = -80;
 
344
        goto on_return;
 
345
    }
 
346
 
 
347
    /* Is the file in ITU format? */
 
348
    is_itu_format = pj_ansi_stricmp(in_encoded_file+strlen(in_encoded_file)-4,
 
349
                                    ".itu")==0;
 
350
 
 
351
    /* Open output file */
 
352
    output = fopen(TMP_OUT, "wb");
 
353
    if (!output) {
 
354
        rc = -90;
 
355
        goto on_return;
 
356
    }
 
357
 
 
358
    /* Allocate buffer for PCM and encoded frames */
 
359
    samples_per_frame = codec_param.info.clock_rate * codec_param.info.frm_ptime / 1000;
 
360
    pkt = pj_pool_alloc(pool, samples_per_frame * 2);
 
361
    out_frame.buf = (pj_uint8_t*) pj_pool_alloc(pool, samples_per_frame * 2);
 
362
 
 
363
    /* Loop read WAV file and encode and write to output file */
 
364
    for (;;) {
 
365
        pjmedia_frame in_frame[2];
 
366
        pj_timestamp ts;
 
367
        unsigned count;
 
368
        pj_bool_t has_frame;
 
369
 
 
370
        if (is_itu_format) {
 
371
            int nsamp;
 
372
            short frame_err = 0;
 
373
 
 
374
            nsamp = read_ITU_format(input, (short*)pkt, &frame_err,
 
375
                                    encoded_len / 2, PJ_TRUE);
 
376
            if (nsamp != (int)encoded_len / 2)
 
377
                break;
 
378
 
 
379
            has_frame = !frame_err;
 
380
        } else {
 
381
            if (fread(pkt, encoded_len, 1, input) != 1)
 
382
                break;
 
383
 
 
384
            has_frame = PJ_TRUE;
 
385
        }
 
386
 
 
387
        if (has_frame) {
 
388
            count = 2;
 
389
            if (pjmedia_codec_parse(codec, pkt, encoded_len, &ts, 
 
390
                                    &count, in_frame) != PJ_SUCCESS) 
 
391
            {
 
392
                rc = -100;
 
393
                goto on_return;
 
394
            }
 
395
 
 
396
            if (count != 1) {
 
397
                rc = -110;
 
398
                goto on_return;
 
399
            }
 
400
 
 
401
            if (pjmedia_codec_decode(codec, &in_frame[0], samples_per_frame*2,
 
402
                                     &out_frame) != PJ_SUCCESS) 
 
403
            {
 
404
                rc = -120;
 
405
                goto on_return;
 
406
            }
 
407
        } else {
 
408
            if (pjmedia_codec_recover(codec, samples_per_frame*2, 
 
409
                                      &out_frame) != PJ_SUCCESS)
 
410
            {
 
411
                rc = -125;
 
412
                goto on_return;
 
413
            }
 
414
        }
 
415
 
 
416
        if (manip)
 
417
            manip((short*)out_frame.buf, samples_per_frame);
 
418
 
 
419
        if (fwrite(out_frame.buf, out_frame.size, 1, output) != 1) {
 
420
            rc = -130;
 
421
            goto on_return;
 
422
        }
 
423
    }
 
424
 
 
425
    fclose(input);
 
426
    input = NULL;
 
427
 
 
428
    fclose(output);
 
429
    output = NULL;
 
430
    
 
431
    /* Compare encoded files */
 
432
    fref = fopen(ref_pcm_file, "rb");
 
433
    if (!fref) {
 
434
        rc = -140;
 
435
        goto on_return;
 
436
    }
 
437
 
 
438
    output = fopen(TMP_OUT, "rb");
 
439
    if (!output) {
 
440
        rc = -110;
 
441
        goto on_return;
 
442
    }
 
443
 
 
444
    pos = 0;
 
445
    for (;;) {
 
446
        pj_size_t count;
 
447
        
 
448
        count = fread(pkt, samples_per_frame*2, 1, fref);
 
449
        if (count != 1)
 
450
            break;
 
451
 
 
452
        count = fread(out_frame.buf, samples_per_frame*2, 1, output);
 
453
        if (count != 1)
 
454
            break;
 
455
 
 
456
        if (memcmp(pkt, out_frame.buf, samples_per_frame*2)) {
 
457
            unsigned i;
 
458
            pj_int16_t *in = (pj_int16_t*)pkt;
 
459
            pj_int16_t *out = (pj_int16_t*)out_frame.buf;
 
460
 
 
461
            for (i=0; i<samples_per_frame; ++i) {
 
462
                if (in[i] != out[i])
 
463
                    break;
 
464
            }
 
465
 
 
466
            PJ_LOG(1,(THIS_FILE,"     failed: mismatch at samples %d", pos+i));
 
467
            rc = -200;
 
468
            break;
 
469
        }
 
470
 
 
471
        pos += samples_per_frame;
 
472
    }
 
473
 
 
474
on_return:
 
475
    if (output)
 
476
        fclose(output);
 
477
 
 
478
    if (fref)
 
479
        fclose(fref);
 
480
 
 
481
    if (input)
 
482
        fclose(input);
 
483
 
 
484
    if (codec) {
 
485
        pjmedia_codec_close(codec);
 
486
        pjmedia_codec_mgr_dealloc_codec(mgr, codec);
 
487
    }
 
488
 
 
489
    if (pool)
 
490
        pj_pool_release(pool);
 
491
 
 
492
    return rc;
 
493
}
 
494
 
 
495
#if PJMEDIA_HAS_G7221_CODEC
 
496
/* For ITU testing, off the 2 lsbs. */
 
497
static void g7221_pcm_manip(short *pcm, unsigned count)
 
498
{
 
499
    unsigned i;
 
500
    for (i=0; i<count; i++)
 
501
        pcm[i] &= 0xfffc;
 
502
 
 
503
}
 
504
#endif  /* PJMEDIA_HAS_G7221_CODEC */
 
505
 
 
506
int codec_test_vectors(void)
 
507
{
 
508
    pjmedia_endpt *endpt;
 
509
    pjmedia_codec_mgr *mgr;
 
510
    int rc, rc_final = 0;
 
511
    struct enc_vectors {
 
512
        char        *codec_name;
 
513
        unsigned     bit_rate;
 
514
        const char  *wav_file;
 
515
        const char  *ref_encoded_file;
 
516
    } enc_vectors[] = 
 
517
    {
 
518
#if PJMEDIA_HAS_G7221_CODEC
 
519
        { "G7221/16000/1", 24000, 
 
520
          "../src/test/vectors/g722_1_enc_in.wav", 
 
521
          "../src/test/vectors/g722_1_enc_out_24000_be.pak"
 
522
        },
 
523
        { "G7221/16000/1", 32000, 
 
524
          "../src/test/vectors/g722_1_enc_in.wav", 
 
525
          "../src/test/vectors/g722_1_enc_out_32000_be.pak"
 
526
        },
 
527
#endif
 
528
        { NULL }
 
529
    };
 
530
    struct dec_vectors {
 
531
        char        *codec_name;
 
532
        unsigned     bit_rate;
 
533
        unsigned     encoded_frame_len;
 
534
        void        (*manip)(short *pcm, unsigned count);
 
535
        const char  *enc_file;
 
536
        const char  *ref_pcm_file;
 
537
    } dec_vectors[] = 
 
538
    {
 
539
#if PJMEDIA_HAS_G7221_CODEC
 
540
        { "G7221/16000/1", 24000, 60,
 
541
          &g7221_pcm_manip,
 
542
          "../src/test/vectors/g722_1_enc_out_24000_be.pak", 
 
543
          "../src/test/vectors/g722_1_dec_out_24000.pcm"
 
544
        },
 
545
        { "G7221/16000/1", 32000, 80,
 
546
          &g7221_pcm_manip,
 
547
          "../src/test/vectors/g722_1_enc_out_32000_be.pak", 
 
548
          "../src/test/vectors/g722_1_dec_out_32000.pcm"
 
549
        },
 
550
        { "G7221/16000/1", 24000, 60,
 
551
          &g7221_pcm_manip,
 
552
          "../src/test/vectors/g722_1_dec_in_24000_fe.itu",
 
553
          "../src/test/vectors/g722_1_dec_out_24000_fe.pcm"
 
554
        },
 
555
        { "G7221/16000/1", 32000, 80,
 
556
          &g7221_pcm_manip,
 
557
          "../src/test/vectors/g722_1_dec_in_32000_fe.itu",
 
558
          "../src/test/vectors/g722_1_dec_out_32000_fe.pcm"
 
559
        },
 
560
#endif
 
561
        { NULL }
 
562
    };
 
563
    unsigned i;
 
564
    pj_status_t status;
 
565
 
 
566
    status = pjmedia_endpt_create(mem, NULL, 0, &endpt);
 
567
    if (status != PJ_SUCCESS)
 
568
        return -5;
 
569
 
 
570
    mgr = pjmedia_endpt_get_codec_mgr(endpt);
 
571
 
 
572
#if PJMEDIA_HAS_G7221_CODEC
 
573
    status = pjmedia_codec_g7221_init(endpt);
 
574
    if (status != PJ_SUCCESS) {
 
575
        pjmedia_endpt_destroy(endpt);
 
576
        return -7;
 
577
    }
 
578
 
 
579
    /* Set shift value to zero for the test vectors */
 
580
    pjmedia_codec_g7221_set_pcm_shift(0);
 
581
#endif
 
582
 
 
583
    PJ_LOG(3,(THIS_FILE,"  encode tests:"));
 
584
    for (i=0; i<PJ_ARRAY_SIZE(enc_vectors); ++i) {
 
585
        if (!enc_vectors[i].codec_name)
 
586
            continue;
 
587
        PJ_LOG(3,(THIS_FILE,"    %s @%d bps %s ==> %s", 
 
588
                  enc_vectors[i].codec_name, 
 
589
                  enc_vectors[i].bit_rate,
 
590
                  enc_vectors[i].wav_file,
 
591
                  enc_vectors[i].ref_encoded_file));
 
592
        rc = codec_test_encode(mgr, enc_vectors[i].codec_name,
 
593
                               enc_vectors[i].bit_rate,
 
594
                               enc_vectors[i].wav_file,
 
595
                               enc_vectors[i].ref_encoded_file);
 
596
        if (rc != 0)
 
597
            rc_final = rc;
 
598
    }
 
599
 
 
600
    PJ_LOG(3,(THIS_FILE,"  decode tests:"));
 
601
    for (i=0; i<PJ_ARRAY_SIZE(dec_vectors); ++i) {
 
602
        if (!dec_vectors[i].codec_name)
 
603
            continue;
 
604
        PJ_LOG(3,(THIS_FILE,"    %s @%d bps %s ==> %s", 
 
605
                  dec_vectors[i].codec_name, 
 
606
                  dec_vectors[i].bit_rate,
 
607
                  dec_vectors[i].enc_file,
 
608
                  dec_vectors[i].ref_pcm_file));
 
609
        rc = codec_test_decode(mgr, dec_vectors[i].codec_name,
 
610
                               dec_vectors[i].bit_rate,
 
611
                               dec_vectors[i].encoded_frame_len,
 
612
                               dec_vectors[i].enc_file,
 
613
                               dec_vectors[i].ref_pcm_file,
 
614
                               dec_vectors[i].manip);
 
615
        if (rc != 0)
 
616
            rc_final = rc;
 
617
    }
 
618
 
 
619
    if (pj_file_exists(TMP_OUT))
 
620
        pj_file_delete(TMP_OUT);
 
621
 
 
622
    pjmedia_endpt_destroy(endpt);
 
623
    return rc_final;
 
624
}
 
625