Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
f7542d7e
Commit
f7542d7e
authored
Apr 27, 2017
by
Rostislav Pehlivanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
opus_pvq: use function pointers for recursion
Signed-off-by:
Rostislav Pehlivanov
<
atomnuker@gmail.com
>
parent
453f8ea2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
37 deletions
+25
-37
opus_pvq.c
libavcodec/opus_pvq.c
+25
-37
No files found.
libavcodec/opus_pvq.c
View file @
f7542d7e
...
@@ -477,6 +477,14 @@ static void celt_stereo_ms_decouple(float *X, float *Y, int N)
...
@@ -477,6 +477,14 @@ static void celt_stereo_ms_decouple(float *X, float *Y, int N)
}
}
}
}
#define QUANT_FN(name) uint32_t (*name)(CeltFrame *f, OpusRangeCoder *rc, \
const int band, float *X, float *Y, \
int N, int b, uint32_t blocks, \
float *lowband, int duration, \
float *lowband_out, int level, \
float gain, float *lowband_scratch, \
int fill)
static
av_always_inline
uint32_t
quant_band_template
(
CeltFrame
*
f
,
OpusRangeCoder
*
rc
,
const
int
band
,
static
av_always_inline
uint32_t
quant_band_template
(
CeltFrame
*
f
,
OpusRangeCoder
*
rc
,
const
int
band
,
float
*
X
,
float
*
Y
,
int
N
,
int
b
,
uint32_t
blocks
,
float
*
X
,
float
*
Y
,
int
N
,
int
b
,
uint32_t
blocks
,
float
*
lowband
,
int
duration
,
float
*
lowband_out
,
float
*
lowband
,
int
duration
,
float
*
lowband_out
,
...
@@ -497,6 +505,7 @@ static av_always_inline uint32_t quant_band_template(CeltFrame *f, OpusRangeCode
...
@@ -497,6 +505,7 @@ static av_always_inline uint32_t quant_band_template(CeltFrame *f, OpusRangeCode
float
mid
=
0
,
side
=
0
;
float
mid
=
0
,
side
=
0
;
int
longblocks
=
(
B0
==
1
);
int
longblocks
=
(
B0
==
1
);
uint32_t
cm
=
0
;
uint32_t
cm
=
0
;
QUANT_FN
(
rec
)
=
quant
?
ff_celt_encode_band
:
ff_celt_decode_band
;
if
(
N
==
1
)
{
if
(
N
==
1
)
{
float
*
x
=
X
;
float
*
x
=
X
;
...
@@ -693,9 +702,8 @@ static av_always_inline uint32_t quant_band_template(CeltFrame *f, OpusRangeCode
...
@@ -693,9 +702,8 @@ static av_always_inline uint32_t quant_band_template(CeltFrame *f, OpusRangeCode
sign
=
1
-
2
*
sign
;
sign
=
1
-
2
*
sign
;
/* We use orig_fill here because we want to fold the side, but if
/* We use orig_fill here because we want to fold the side, but if
itheta==16384, we'll have cleared the low bits of fill. */
itheta==16384, we'll have cleared the low bits of fill. */
cm
=
ff_celt_decode_band
(
f
,
rc
,
band
,
x2
,
NULL
,
N
,
mbits
,
blocks
,
cm
=
rec
(
f
,
rc
,
band
,
x2
,
NULL
,
N
,
mbits
,
blocks
,
lowband
,
duration
,
lowband
,
duration
,
lowband_out
,
level
,
gain
,
lowband_out
,
level
,
gain
,
lowband_scratch
,
orig_fill
);
lowband_scratch
,
orig_fill
);
/* We don't split N=2 bands, so cm is either 1 or 0 (for a fold-collapse),
/* We don't split N=2 bands, so cm is either 1 or 0 (for a fold-collapse),
and there's no need to worry about mixing with the other channel. */
and there's no need to worry about mixing with the other channel. */
y2
[
0
]
=
-
sign
*
x2
[
1
];
y2
[
0
]
=
-
sign
*
x2
[
1
];
...
@@ -716,6 +724,7 @@ static av_always_inline uint32_t quant_band_template(CeltFrame *f, OpusRangeCode
...
@@ -716,6 +724,7 @@ static av_always_inline uint32_t quant_band_template(CeltFrame *f, OpusRangeCode
float
*
next_lowband_out1
=
NULL
;
float
*
next_lowband_out1
=
NULL
;
int
next_level
=
0
;
int
next_level
=
0
;
int
rebalance
;
int
rebalance
;
uint32_t
cmt
;
/* Give more bits to low-energy MDCTs than they would
/* Give more bits to low-energy MDCTs than they would
* otherwise deserve */
* otherwise deserve */
...
@@ -746,55 +755,34 @@ static av_always_inline uint32_t quant_band_template(CeltFrame *f, OpusRangeCode
...
@@ -746,55 +755,34 @@ static av_always_inline uint32_t quant_band_template(CeltFrame *f, OpusRangeCode
if
(
mbits
>=
sbits
)
{
if
(
mbits
>=
sbits
)
{
/* In stereo mode, we do not apply a scaling to the mid
/* In stereo mode, we do not apply a scaling to the mid
* because we need the normalized mid for folding later */
* because we need the normalized mid for folding later */
cm
=
quant
?
ff_celt_encode_band
(
f
,
rc
,
band
,
X
,
NULL
,
N
,
mbits
,
blocks
,
cm
=
rec
(
f
,
rc
,
band
,
X
,
NULL
,
N
,
mbits
,
blocks
,
lowband
,
lowband
,
duration
,
next_lowband_out1
,
duration
,
next_lowband_out1
,
next_level
,
next_level
,
stereo
?
1
.
0
f
:
(
gain
*
mid
),
stereo
?
1
.
0
f
:
(
gain
*
mid
),
lowband_scratch
,
fill
);
lowband_scratch
,
fill
)
:
ff_celt_decode_band
(
f
,
rc
,
band
,
X
,
NULL
,
N
,
mbits
,
blocks
,
lowband
,
duration
,
next_lowband_out1
,
next_level
,
stereo
?
1
.
0
f
:
(
gain
*
mid
),
lowband_scratch
,
fill
);
rebalance
=
mbits
-
(
rebalance
-
f
->
remaining2
);
rebalance
=
mbits
-
(
rebalance
-
f
->
remaining2
);
if
(
rebalance
>
3
<<
3
&&
itheta
!=
0
)
if
(
rebalance
>
3
<<
3
&&
itheta
!=
0
)
sbits
+=
rebalance
-
(
3
<<
3
);
sbits
+=
rebalance
-
(
3
<<
3
);
/* For a stereo split, the high bits of fill are always zero,
/* For a stereo split, the high bits of fill are always zero,
* so no folding will be done to the side. */
* so no folding will be done to the side. */
cm
|=
quant
?
ff_celt_encode_band
(
f
,
rc
,
band
,
Y
,
NULL
,
N
,
sbits
,
blocks
,
cmt
=
rec
(
f
,
rc
,
band
,
Y
,
NULL
,
N
,
sbits
,
blocks
,
next_lowband2
,
next_lowband2
,
duration
,
NULL
,
duration
,
NULL
,
next_level
,
gain
*
side
,
NULL
,
next_level
,
gain
*
side
,
NULL
,
fill
>>
blocks
);
fill
>>
blocks
)
<<
((
B0
>>
1
)
&
(
stereo
-
1
))
:
cm
|=
cmt
<<
((
B0
>>
1
)
&
(
stereo
-
1
));
ff_celt_decode_band
(
f
,
rc
,
band
,
Y
,
NULL
,
N
,
sbits
,
blocks
,
next_lowband2
,
duration
,
NULL
,
next_level
,
gain
*
side
,
NULL
,
fill
>>
blocks
)
<<
((
B0
>>
1
)
&
(
stereo
-
1
));
}
else
{
}
else
{
/* For a stereo split, the high bits of fill are always zero,
/* For a stereo split, the high bits of fill are always zero,
* so no folding will be done to the side. */
* so no folding will be done to the side. */
cm
=
quant
?
ff_celt_encode_band
(
f
,
rc
,
band
,
Y
,
NULL
,
N
,
sbits
,
blocks
,
cm
=
rec
(
f
,
rc
,
band
,
Y
,
NULL
,
N
,
sbits
,
blocks
,
next_lowband2
,
next_lowband2
,
duration
,
NULL
,
duration
,
NULL
,
next_level
,
gain
*
side
,
NULL
,
fill
>>
blocks
);
next_level
,
gain
*
side
,
NULL
,
cm
<<=
((
B0
>>
1
)
&
(
stereo
-
1
));
fill
>>
blocks
)
<<
((
B0
>>
1
)
&
(
stereo
-
1
))
:
ff_celt_decode_band
(
f
,
rc
,
band
,
Y
,
NULL
,
N
,
sbits
,
blocks
,
next_lowband2
,
duration
,
NULL
,
next_level
,
gain
*
side
,
NULL
,
fill
>>
blocks
)
<<
((
B0
>>
1
)
&
(
stereo
-
1
));
rebalance
=
sbits
-
(
rebalance
-
f
->
remaining2
);
rebalance
=
sbits
-
(
rebalance
-
f
->
remaining2
);
if
(
rebalance
>
3
<<
3
&&
itheta
!=
16384
)
if
(
rebalance
>
3
<<
3
&&
itheta
!=
16384
)
mbits
+=
rebalance
-
(
3
<<
3
);
mbits
+=
rebalance
-
(
3
<<
3
);
/* In stereo mode, we do not apply a scaling to the mid because
/* In stereo mode, we do not apply a scaling to the mid because
* we need the normalized mid for folding later */
* we need the normalized mid for folding later */
cm
|=
quant
?
ff_celt_encode_band
(
f
,
rc
,
band
,
X
,
NULL
,
N
,
mbits
,
blocks
,
cm
|=
rec
(
f
,
rc
,
band
,
X
,
NULL
,
N
,
mbits
,
blocks
,
lowband
,
duration
,
lowband
,
duration
,
next_lowband_out1
,
next_lowband_out1
,
next_level
,
stereo
?
1
.
0
f
:
(
gain
*
mid
),
next_level
,
stereo
?
1
.
0
f
:
(
gain
*
mid
),
lowband_scratch
,
fill
);
lowband_scratch
,
fill
)
:
ff_celt_decode_band
(
f
,
rc
,
band
,
X
,
NULL
,
N
,
mbits
,
blocks
,
lowband
,
duration
,
next_lowband_out1
,
next_level
,
stereo
?
1
.
0
f
:
(
gain
*
mid
),
lowband_scratch
,
fill
);
}
}
}
}
}
else
{
}
else
{
...
...
Write
Preview
Markdown
is supported
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