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
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
Alexander Traud
Opus
Commits
c81b5102
Commit
c81b5102
authored
13 years ago
by
Gregory Maxwell
Browse files
Options
Downloads
Patches
Plain Diff
Fix a number of multistream decoder bugs; add some very basic multistream decoder tests.
parent
b975a426
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
include/opus_multistream.h
+15
-0
15 additions, 0 deletions
include/opus_multistream.h
src/opus_multistream.c
+17
-13
17 additions, 13 deletions
src/opus_multistream.c
tests/test_opus_api.c
+241
-72
241 additions, 72 deletions
tests/test_opus_api.c
with
273 additions
and
85 deletions
include/opus_multistream.h
+
15
−
0
View file @
c81b5102
...
...
@@ -89,6 +89,14 @@ OPUS_EXPORT int opus_multistream_encode_float(
int
max_data_bytes
/**< Allocated memory for payload; don't use for controlling bitrate */
);
/** Gets the size of an OpusMSEncoder structure.
* @returns size
*/
OPUS_EXPORT
opus_int32
opus_multistream_encoder_get_size
(
int
streams
,
/**< Total number of coded streams */
int
coupled_streams
/**< Number of coupled (stereo) streams */
);
/** Deallocate a multstream encoder state */
OPUS_EXPORT
void
opus_multistream_encoder_destroy
(
OpusMSEncoder
*
st
);
...
...
@@ -139,6 +147,13 @@ OPUS_EXPORT int opus_multistream_decode_float(
/**< decoded. If no such data is available the frame is decoded as if it were lost. */
);
/** Gets the size of an OpusMSDecoder structure.
* @returns size
*/
OPUS_EXPORT
opus_int32
opus_multistream_decoder_get_size
(
int
streams
,
/**< Total number of coded streams */
int
coupled_streams
/**< Number of coupled (stereo) streams */
);
/** Get or set options on a multistream decoder state */
OPUS_EXPORT
int
opus_multistream_decoder_ctl
(
OpusMSDecoder
*
st
,
int
request
,
...);
...
...
This diff is collapsed.
Click to expand it.
src/opus_multistream.c
+
17
−
13
View file @
c81b5102
...
...
@@ -133,11 +133,12 @@ static int validate_encoder_layout(const ChannelLayout *layout)
return
1
;
}
int
opus_multistream_encoder_get_size
(
int
nb_streams
,
int
nb_coupled_streams
)
opus_
int
32
opus_multistream_encoder_get_size
(
int
nb_streams
,
int
nb_coupled_streams
)
{
int
coupled_size
;
int
mono_size
;
if
(
nb_streams
<
1
||
nb_coupled_streams
>
nb_streams
||
nb_coupled_streams
<
0
)
return
0
;
coupled_size
=
opus_encoder_get_size
(
2
);
mono_size
=
opus_encoder_get_size
(
1
);
return
align
(
sizeof
(
OpusMSEncoder
))
...
...
@@ -435,7 +436,7 @@ int opus_multistream_encoder_ctl(OpusMSEncoder *st, int request, ...)
else
ptr
+=
align
(
mono_size
);
ret
=
opus_encoder_ctl
(
enc
,
request
,
value
);
if
(
ret
<
0
)
if
(
ret
!=
OPUS_OK
)
break
;
}
}
...
...
@@ -476,11 +477,12 @@ void opus_multistream_encoder_destroy(OpusMSEncoder *st)
/* DECODER */
int
opus_multistream_decoder_get_size
(
int
nb_streams
,
int
nb_coupled_streams
)
opus_
int
32
opus_multistream_decoder_get_size
(
int
nb_streams
,
int
nb_coupled_streams
)
{
int
coupled_size
;
int
mono_size
;
if
(
nb_streams
<
1
||
nb_coupled_streams
>
nb_streams
||
nb_coupled_streams
<
0
)
return
0
;
coupled_size
=
opus_decoder_get_size
(
2
);
mono_size
=
opus_decoder_get_size
(
1
);
return
align
(
sizeof
(
OpusMSDecoder
))
...
...
@@ -499,7 +501,7 @@ int opus_multistream_decoder_init(
{
int
coupled_size
;
int
mono_size
;
int
i
;
int
i
,
ret
;
char
*
ptr
;
st
->
layout
.
nb_channels
=
channels
;
...
...
@@ -511,18 +513,20 @@ int opus_multistream_decoder_init(
if
(
!
validate_layout
(
&
st
->
layout
))
return
OPUS_BAD_ARG
;
ptr
=
(
char
*
)
st
+
align
(
sizeof
(
OpusMS
En
coder
));
ptr
=
(
char
*
)
st
+
align
(
sizeof
(
OpusMS
De
coder
));
coupled_size
=
opus_decoder_get_size
(
2
);
mono_size
=
opus_decoder_get_size
(
1
);
for
(
i
=
0
;
i
<
st
->
layout
.
nb_coupled_streams
;
i
++
)
{
opus_decoder_init
((
OpusDecoder
*
)
ptr
,
Fs
,
2
);
ret
=
opus_decoder_init
((
OpusDecoder
*
)
ptr
,
Fs
,
2
);
if
(
ret
!=
OPUS_OK
)
return
ret
;
ptr
+=
align
(
coupled_size
);
}
for
(;
i
<
st
->
layout
.
nb_streams
;
i
++
)
{
opus_decoder_init
((
OpusDecoder
*
)
ptr
,
Fs
,
1
);
ret
=
opus_decoder_init
((
OpusDecoder
*
)
ptr
,
Fs
,
1
);
if
(
ret
!=
OPUS_OK
)
return
ret
;
ptr
+=
align
(
mono_size
);
}
return
OPUS_OK
;
...
...
@@ -576,12 +580,12 @@ static int opus_multistream_decode_native(
ALLOC_STACK
;
ALLOC
(
buf
,
2
*
frame_size
,
opus_val16
);
ptr
=
(
char
*
)
st
+
align
(
sizeof
(
OpusMS
En
coder
));
ptr
=
(
char
*
)
st
+
align
(
sizeof
(
OpusMS
De
coder
));
coupled_size
=
opus_decoder_get_size
(
2
);
mono_size
=
opus_decoder_get_size
(
1
);
if
(
len
<
2
*
st
->
layout
.
nb_streams
-
1
)
return
OPUS_B
UFFER_TOO_SMALL
;
if
(
len
<
0
)
return
OPUS_B
AD_ARG
;
for
(
s
=
0
;
s
<
st
->
layout
.
nb_streams
;
s
++
)
{
OpusDecoder
*
dec
;
...
...
@@ -590,7 +594,7 @@ static int opus_multistream_decode_native(
dec
=
(
OpusDecoder
*
)
ptr
;
ptr
+=
(
s
<
st
->
layout
.
nb_coupled_streams
)
?
align
(
coupled_size
)
:
align
(
mono_size
);
if
(
len
<
=
0
)
if
(
len
<
0
)
{
RESTORE_STACK
;
return
OPUS_INVALID_PACKET
;
...
...
@@ -755,7 +759,7 @@ int opus_multistream_decoder_ctl(OpusMSDecoder *st, int request, ...)
else
ptr
+=
align
(
mono_size
);
ret
=
opus_decoder_ctl
(
dec
,
request
,
value
);
if
(
ret
<
0
)
if
(
ret
!=
OPUS_OK
)
break
;
}
}
...
...
@@ -773,7 +777,7 @@ int opus_multistream_decoder_ctl(OpusMSDecoder *st, int request, ...)
else
ptr
+=
align
(
mono_size
);
ret
=
opus_decoder_ctl
(
dec
,
OPUS_RESET_STATE
);
if
(
ret
<
0
)
if
(
ret
!=
OPUS_OK
)
break
;
}
}
...
...
This diff is collapsed.
Click to expand it.
tests/test_opus_api.c
+
241
−
72
View file @
c81b5102
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