Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Opus
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Xiph.Org
Opus
Commits
a10e8796
Commit
a10e8796
authored
14 years ago
by
Jean-Marc Valin
Browse files
Options
Downloads
Patches
Plain Diff
Better handling of test_opus bandwidth options
parent
30a5e7eb
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/opus_encoder.c
+0
-1
0 additions, 1 deletion
src/opus_encoder.c
src/test_opus.c
+44
-19
44 additions, 19 deletions
src/test_opus.c
with
44 additions
and
20 deletions
src/opus_encoder.c
+
0
−
1
View file @
a10e8796
...
...
@@ -96,7 +96,6 @@ int opus_encode(OpusEncoder *st, const short *pcm, int frame_size,
SKP_int32
nBytes
;
ec_enc
enc
;
ec_byte_buffer
buf
;
SKP_SILK_SDK_EncControlStruct
encControl
;
int
framerate
,
period
;
int
silk_internal_bandwidth
;
int
bytes_target
;
...
...
This diff is collapsed.
Click to expand it.
src/test_opus.c
+
44
−
19
View file @
a10e8796
...
...
@@ -51,7 +51,7 @@ void print_usage( char* argv[] )
fprintf
(
stderr
,
"mode: 0 for SILK, 1 for hybrid, 2 for CELT:
\n
"
);
fprintf
(
stderr
,
"options:
\n
"
);
fprintf
(
stderr
,
"-vbr : enable variable bitrate (recommended for SILK)
\n
"
);
fprintf
(
stderr
,
"-
internal_rate <Hz> : internal sampling rate in Hz, default: input smplng rate
\n
"
);
fprintf
(
stderr
,
"-
bandwidth <NB|MB|WB|SWB|FB> : audio bandwidth (from narrowband to fullband)
\n
"
);
fprintf
(
stderr
,
"-max_payload <bytes> : maximum payload size in bytes, default: 1024
\n
"
);
fprintf
(
stderr
,
"-complexity <comp> : SILK complexity, 0: low, 1: medium, 2: high; default: 2
\n
"
);
fprintf
(
stderr
,
"-inbandfec : enable SILK inband FEC
\n
"
);
...
...
@@ -108,6 +108,7 @@ int main(int argc, char *argv[])
/* defaults: */
use_vbr
=
0
;
int
bandwidth
=-
1
;
internal_sampling_rate_Hz
=
sampling_rate
;
max_payload_bytes
=
MAX_PACKET
;
complexity
=
2
;
...
...
@@ -121,8 +122,21 @@ int main(int argc, char *argv[])
if
(
STR_CASEINSENSITIVE_COMPARE
(
argv
[
args
],
"-vbr"
)
==
0
)
{
use_vbr
=
1
;
args
++
;
}
else
if
(
STR_CASEINSENSITIVE_COMPARE
(
argv
[
args
],
"-internal_rate"
)
==
0
)
{
internal_sampling_rate_Hz
=
atoi
(
argv
[
args
+
1
]
);
}
else
if
(
STR_CASEINSENSITIVE_COMPARE
(
argv
[
args
],
"-bandwidth"
)
==
0
)
{
if
(
strcmp
(
argv
[
args
+
1
],
"NB"
)
==
0
)
bandwidth
=
BANDWIDTH_NARROWBAND
;
else
if
(
strcmp
(
argv
[
args
+
1
],
"MB"
)
==
0
)
bandwidth
=
BANDWIDTH_MEDIUMBAND
;
else
if
(
strcmp
(
argv
[
args
+
1
],
"WB"
)
==
0
)
bandwidth
=
BANDWIDTH_WIDEBAND
;
else
if
(
strcmp
(
argv
[
args
+
1
],
"SWB"
)
==
0
)
bandwidth
=
BANDWIDTH_SUPERWIDEBAND
;
else
if
(
strcmp
(
argv
[
args
+
1
],
"FB"
)
==
0
)
bandwidth
=
BANDWIDTH_FULLBAND
;
else
{
fprintf
(
stderr
,
"Unknown bandwidth %s. Supported are NB, MB, WB, SWB, FB.
\n
"
,
argv
[
args
+
1
]);
return
1
;
}
args
+=
2
;
}
else
if
(
STR_CASEINSENSITIVE_COMPARE
(
argv
[
args
],
"-max_payload"
)
==
0
)
{
max_payload_bytes
=
atoi
(
argv
[
args
+
1
]
);
...
...
@@ -179,28 +193,39 @@ int main(int argc, char *argv[])
return
1
;
}
if
(
mode
==
MODE_SILK_ONLY
)
{
if
(
bandwidth
==
BANDWIDTH_SUPERWIDEBAND
||
bandwidth
==
BANDWIDTH_SUPERWIDEBAND
)
{
fprintf
(
stderr
,
"Predictive mode only supports up to wideband
\n
"
);
return
1
;
}
}
if
(
mode
==
MODE_HYBRID
)
{
if
(
bandwidth
!=
BANDWIDTH_SUPERWIDEBAND
&&
bandwidth
!=
BANDWIDTH_SUPERWIDEBAND
)
{
fprintf
(
stderr
,
"Hybrid mode only supports superwideband and fullband
\n
"
);
return
1
;
}
}
if
(
mode
==
MODE_CELT_ONLY
)
{
if
(
bandwidth
==
BANDWIDTH_MEDIUMBAND
)
{
fprintf
(
stderr
,
"Transform mode does not support mediumband
\n
"
);
return
1
;
}
}
enc
=
opus_encoder_create
(
sampling_rate
,
channels
);
dec
=
opus_decoder_create
(
sampling_rate
,
channels
);
opus_encoder_ctl
(
enc
,
OPUS_SET_MODE
(
mode
));
opus_encoder_ctl
(
enc
,
OPUS_SET_BITRATE
(
bitrate_bps
));
if
(
internal_sampling_rate_Hz
==
48000
)
{
opus_encoder_ctl
(
enc
,
OPUS_SET_BANDWIDTH
(
BANDWIDTH_FULLBAND
));
}
else
if
(
internal_sampling_rate_Hz
==
32000
)
{
opus_encoder_ctl
(
enc
,
OPUS_SET_BANDWIDTH
(
BANDWIDTH_SUPERWIDEBAND
));
//} else if( internal_sampling_rate_Hz == 24000 ) {
// opus_encoder_ctl(enc, OPUS_SET_BANDWIDTH(BANDWIDTH_EXTRAWIDEBAND));
}
else
if
(
internal_sampling_rate_Hz
==
16000
)
{
opus_encoder_ctl
(
enc
,
OPUS_SET_BANDWIDTH
(
BANDWIDTH_WIDEBAND
));
}
else
if
(
internal_sampling_rate_Hz
==
12000
)
{
opus_encoder_ctl
(
enc
,
OPUS_SET_BANDWIDTH
(
BANDWIDTH_MEDIUMBAND
));
}
else
if
(
internal_sampling_rate_Hz
==
8000
)
{
opus_encoder_ctl
(
enc
,
OPUS_SET_BANDWIDTH
(
BANDWIDTH_NARROWBAND
));
}
else
{
fprintf
(
stderr
,
"Unsupported internal sampling rate %d
\n
"
,
internal_sampling_rate_Hz
);
return
1
;
}
if
(
bandwidth
!=
-
1
)
opus_encoder_ctl
(
enc
,
OPUS_SET_BANDWIDTH
(
bandwidth
));
opus_encoder_ctl
(
enc
,
OPUS_SET_VBR_FLAG
(
use_vbr
));
opus_encoder_ctl
(
enc
,
OPUS_SET_COMPLEXITY
(
complexity
));
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment