Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(165)

Side by Side Diff: opus/celt/tests/test_unit_laplace.c

Issue 11196031: Add copy of opus library in deps/third_party. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « opus/celt/tests/test_unit_entropy.c ('k') | opus/celt/tests/test_unit_mathops.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 #ifdef HAVE_CONFIG_H
2 #include "config.h"
3 #endif
4
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include "laplace.h"
8 #define CELT_C
9 #include "stack_alloc.h"
10
11 #include "entenc.c"
12 #include "entdec.c"
13 #include "entcode.c"
14 #include "laplace.c"
15
16 #define DATA_SIZE 40000
17
18 int ec_laplace_get_start_freq(int decay)
19 {
20 opus_uint32 ft = 32768 - LAPLACE_MINP*(2*LAPLACE_NMIN+1);
21 int fs = (ft*(16384-decay))/(16384+decay);
22 return fs+LAPLACE_MINP;
23 }
24
25 int main(void)
26 {
27 int i;
28 int ret = 0;
29 ec_enc enc;
30 ec_dec dec;
31 unsigned char *ptr;
32 int val[10000], decay[10000];
33 ALLOC_STACK;
34 ptr = (unsigned char *)malloc(DATA_SIZE);
35 ec_enc_init(&enc,ptr,DATA_SIZE);
36
37 val[0] = 3; decay[0] = 6000;
38 val[1] = 0; decay[1] = 5800;
39 val[2] = -1; decay[2] = 5600;
40 for (i=3;i<10000;i++)
41 {
42 val[i] = rand()%15-7;
43 decay[i] = rand()%11000+5000;
44 }
45 for (i=0;i<10000;i++)
46 ec_laplace_encode(&enc, &val[i],
47 ec_laplace_get_start_freq(decay[i]), decay[i]);
48
49 ec_enc_done(&enc);
50
51 ec_dec_init(&dec,ec_get_buffer(&enc),ec_range_bytes(&enc));
52
53 for (i=0;i<10000;i++)
54 {
55 int d = ec_laplace_decode(&dec,
56 ec_laplace_get_start_freq(decay[i]), decay[i]);
57 if (d != val[i])
58 {
59 fprintf (stderr, "Got %d instead of %d\n", d, val[i]);
60 ret = 1;
61 }
62 }
63
64 return ret;
65 }
OLDNEW
« no previous file with comments | « opus/celt/tests/test_unit_entropy.c ('k') | opus/celt/tests/test_unit_mathops.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698