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
9a3f8739
Verified
Commit
9a3f8739
authored
2 years ago
by
Jean-Marc Valin
Browse files
Options
Downloads
Patches
Plain Diff
Adds -lossfile option to opus_demo
parent
54ea2624
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/opus_demo.c
+18
-2
18 additions, 2 deletions
src/opus_demo.c
with
18 additions
and
2 deletions
src/opus_demo.c
+
18
−
2
View file @
9a3f8739
...
...
@@ -62,7 +62,8 @@ void print_usage( char* argv[] )
fprintf
(
stderr
,
"-inbandfec : enable SILK inband FEC
\n
"
);
fprintf
(
stderr
,
"-forcemono : force mono encoding, even for stereo input
\n
"
);
fprintf
(
stderr
,
"-dtx : enable SILK DTX
\n
"
);
fprintf
(
stderr
,
"-loss <perc> : simulate packet loss, in percent (0-100); default: 0
\n
"
);
fprintf
(
stderr
,
"-loss <perc> : optimize for loss percentage and simulate packet loss, in percent (0-100); default: 0
\n
"
);
fprintf
(
stderr
,
"-lossfile <file> : simulate packet loss, reading loss from file
\n
"
);
}
static
void
int_to_char
(
opus_uint32
i
,
unsigned
char
ch
[
4
])
...
...
@@ -264,6 +265,7 @@ int main(int argc, char *argv[])
int
delayed_decision
=
0
;
int
ret
=
EXIT_FAILURE
;
int
lost_count
=
0
;
FILE
*
packet_loss_file
=
NULL
;
if
(
argc
<
5
)
{
...
...
@@ -422,6 +424,13 @@ int main(int argc, char *argv[])
}
else
if
(
strcmp
(
argv
[
args
],
"-loss"
)
==
0
)
{
packet_loss_perc
=
atoi
(
argv
[
args
+
1
]
);
args
+=
2
;
}
else
if
(
strcmp
(
argv
[
args
],
"-lossfile"
)
==
0
)
{
packet_loss_file
=
fopen
(
argv
[
args
+
1
],
"r"
);
if
(
packet_loss_file
==
NULL
)
{
fprintf
(
stderr
,
"failed to open loss file %s
\n
"
,
argv
[
args
+
1
]
);
exit
(
1
);
}
args
+=
2
;
}
else
if
(
strcmp
(
argv
[
args
],
"-sweep"
)
==
0
)
{
check_encoder_option
(
decode_only
,
"-sweep"
);
sweep_bps
=
atoi
(
argv
[
args
+
1
]
);
...
...
@@ -760,7 +769,14 @@ int main(int argc, char *argv[])
}
else
{
int
fr
;
int
run_decoder
;
lost
=
len
==
0
||
(
packet_loss_perc
>
0
&&
rand
()
%
100
<
packet_loss_perc
);
if
(
packet_loss_file
!=
NULL
)
{
if
(
fscanf
(
packet_loss_file
,
"%d"
,
&
lost
)
!=
1
)
{
lost
=
0
;
}
}
else
{
lost
=
(
packet_loss_perc
>
0
)
&&
(
rand
()
%
100
<
packet_loss_perc
);
}
if
(
len
==
0
)
lost
=
1
;
if
(
lost
)
{
lost_count
++
;
...
...
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