Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Mark Harris
Opus
Commits
bf17da60
Commit
bf17da60
authored
Feb 14, 2008
by
Jean-Marc Valin
Browse files
Reduced useless calls to ncwrs64() by half.
parent
5fa59954
Changes
3
Hide whitespace changes
Inline
Side-by-side
libcelt/cwrs.c
View file @
bf17da60
...
...
@@ -246,19 +246,25 @@ void cwrsi64(int _n,int _m,celt_uint64_t _i,int *_x,int *_s){
of size _n with associated sign bits.
_x: The combination with elements sorted in ascending order.
_s: The associated sign bits.*/
celt_uint64_t
icwrs64
(
int
_n
,
int
_m
,
const
int
*
_x
,
const
int
*
_s
){
celt_uint64_t
icwrs64
(
int
_n
,
int
_m
,
const
int
*
_x
,
const
int
*
_s
,
celt_uint64_t
*
bound
){
celt_uint64_t
i
;
int
j
;
int
k
;
celt_uint64_t
nc
[
_n
+
1
];
for
(
j
=
0
;
j
<
_n
+
1
;
j
++
)
nc
[
j
]
=
1
;
for
(
k
=
0
;
k
<
_m
-
1
;
k
++
)
for
(
k
=
0
;
k
<
_m
;
k
++
)
next_ncwrs64
(
nc
,
_n
+
1
,
0
);
if
(
bound
)
*
bound
=
nc
[
_n
];
i
=
0
;
for
(
k
=
j
=
0
;
k
<
_m
;
k
++
){
celt_uint64_t
pn
;
celt_uint64_t
p
;
if
(
k
<
_m
-
1
)
prev_ncwrs64
(
nc
,
_n
+
1
,
0
);
else
prev_ncwrs64
(
nc
,
_n
+
1
,
1
);
/*p=ncwrs64(_n-j,_m-k-1);
pn=ncwrs64(_n-j-1,_m-k-1);*/
p
=
nc
[
_n
-
j
];
...
...
@@ -274,10 +280,6 @@ celt_uint64_t icwrs64(int _n,int _m,const int *_x,const int *_s){
p
+=
pn
;
}
if
((
k
==
0
||
_x
[
k
]
!=
_x
[
k
-
1
])
&&
_s
[
k
])
i
+=
p
>>
1
;
if
(
k
<
_m
-
2
)
prev_ncwrs64
(
nc
,
_n
+
1
,
0
);
else
prev_ncwrs64
(
nc
,
_n
+
1
,
1
);
}
return
i
;
}
...
...
@@ -326,7 +328,9 @@ void encode_pulses(int *_y, int N, int K, ec_enc *enc)
int
comb
[
K
];
int
signs
[
K
];
pulse2comb
(
N
,
K
,
comb
,
signs
,
_y
);
ec_enc_uint64
(
enc
,
icwrs64
(
N
,
K
,
comb
,
signs
),
ncwrs64
(
N
,
K
));
celt_uint64_t
bound
,
id
;
id
=
icwrs64
(
N
,
K
,
comb
,
signs
,
&
bound
);
ec_enc_uint64
(
enc
,
id
,
bound
);
}
void
decode_pulses
(
int
*
_y
,
int
N
,
int
K
,
ec_dec
*
dec
)
...
...
libcelt/cwrs.h
View file @
bf17da60
...
...
@@ -51,7 +51,7 @@ celt_uint64_t ncwrs64(int _n,int _m);
void
cwrsi64
(
int
_n
,
int
_m
,
celt_uint64_t
_i
,
int
*
_x
,
int
*
_s
);
celt_uint64_t
icwrs64
(
int
_n
,
int
_m
,
const
int
*
_x
,
const
int
*
_s
);
celt_uint64_t
icwrs64
(
int
_n
,
int
_m
,
const
int
*
_x
,
const
int
*
_s
,
celt_uint64_t
*
bound
);
void
encode_pulses
(
int
*
_y
,
int
N
,
int
K
,
ec_enc
*
enc
);
...
...
tests/cwrs64-test.c
View file @
bf17da60
...
...
@@ -31,7 +31,7 @@ int main(int _argc,char **_argv){
printf(" %c%i",k>0&&x[k]==x[k-1]?' ':s[k]?'-':'+',x[k]);
}
printf(" ->");*/
if
(
icwrs64
(
n
,
m
,
x
,
s
)
!=
i
){
if
(
icwrs64
(
n
,
m
,
x
,
s
,
NULL
)
!=
i
){
fprintf
(
stderr
,
"Combination-index mismatch.
\n
"
);
return
1
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment