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
d6a0216c
Commit
d6a0216c
authored
13 years ago
by
Jean-Marc Valin
Browse files
Options
Downloads
Patches
Plain Diff
Making use of the opus_int* types in the toplevel Opus code
parent
ff5f7228
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/opus.h
+4
-2
4 additions, 2 deletions
src/opus.h
src/opus_decoder.c
+6
-6
6 additions, 6 deletions
src/opus_decoder.c
src/opus_decoder.h
+2
-2
2 additions, 2 deletions
src/opus_decoder.h
src/opus_encoder.c
+8
-8
8 additions, 8 deletions
src/opus_encoder.c
with
20 additions
and
18 deletions
src/opus.h
+
4
−
2
View file @
d6a0216c
...
...
@@ -28,6 +28,8 @@
#ifndef OPUS_H
#define OPUS_H
#include
"opus_types.h"
#ifdef __cplusplus
extern
"C"
{
#endif
...
...
@@ -175,7 +177,7 @@ OPUS_EXPORT OpusEncoder *opus_encoder_init(
/* Returns length of the data payload (in bytes) */
OPUS_EXPORT
int
opus_encode
(
OpusEncoder
*
st
,
/* Encoder state */
const
short
*
pcm
,
/* Input signal (interleaved if 2 channels). length is frame_size*channels */
const
opus_int16
*
pcm
,
/* Input signal (interleaved if 2 channels). length is frame_size*channels */
int
frame_size
,
/* Number of samples per frame of input signal */
unsigned
char
*
data
,
/* Output payload (no more than max_data_bytes long) */
int
max_data_bytes
/* Allocated memory for payload; don't use for controlling bitrate */
...
...
@@ -200,7 +202,7 @@ OPUS_EXPORT int opus_decode(
OpusDecoder
*
st
,
/* Decoder state */
const
unsigned
char
*
data
,
/* Input payload. Use a NULL pointer to indicate packet loss */
int
len
,
/* Number of bytes in payload */
short
*
pcm
,
/* Output signal (interleaved if 2 channels). length is frame_size*channels */
opus_int16
*
pcm
,
/* Output signal (interleaved if 2 channels). length is frame_size*channels */
int
frame_size
,
/* Number of samples per frame of input signal */
int
decode_fec
/* Flag (0/1) to request that any in-band forward error correction data be */
/* decoded. If no such data is available the frame is decoded as if it were lost. */
...
...
This diff is collapsed.
Click to expand it.
src/opus_decoder.c
+
6
−
6
View file @
d6a0216c
...
...
@@ -111,7 +111,7 @@ OpusDecoder *opus_decoder_create(int Fs, int channels)
return
opus_decoder_init
((
OpusDecoder
*
)
raw_state
,
Fs
,
channels
);
}
static
void
smooth_fade
(
const
short
*
in1
,
const
short
*
in2
,
short
*
out
,
static
void
smooth_fade
(
const
opus_int16
*
in1
,
const
opus_int16
*
in2
,
opus_int16
*
out
,
int
overlap
,
int
channels
,
const
opus_val16
*
window
,
int
Fs
)
{
int
i
,
c
;
...
...
@@ -144,7 +144,7 @@ static int opus_packet_get_mode(const unsigned char *data)
}
static
int
opus_decode_frame
(
OpusDecoder
*
st
,
const
unsigned
char
*
data
,
int
len
,
short
*
pcm
,
int
frame_size
,
int
decode_fec
)
int
len
,
opus_int16
*
pcm
,
int
frame_size
,
int
decode_fec
)
{
void
*
silk_dec
;
CELTDecoder
*
celt_dec
;
...
...
@@ -152,8 +152,8 @@ static int opus_decode_frame(OpusDecoder *st, const unsigned char *data,
ec_dec
dec
;
silk_DecControlStruct
DecControl
;
opus_int32
silk_frame_size
;
short
pcm_celt
[
960
*
2
];
short
pcm_transition
[
480
*
2
];
opus_int16
pcm_celt
[
960
*
2
];
opus_int16
pcm_transition
[
480
*
2
];
int
audiosize
;
int
mode
;
...
...
@@ -162,7 +162,7 @@ static int opus_decode_frame(OpusDecoder *st, const unsigned char *data,
int
redundancy
=
0
;
int
redundancy_bytes
=
0
;
int
celt_to_silk
=
0
;
short
redundant_audio
[
240
*
2
];
opus_int16
redundant_audio
[
240
*
2
];
int
c
;
int
F2_5
,
F5
,
F10
,
F20
;
const
opus_val16
*
window
;
...
...
@@ -413,7 +413,7 @@ static int parse_size(const unsigned char *data, int len, short *size)
}
int
opus_decode
(
OpusDecoder
*
st
,
const
unsigned
char
*
data
,
int
len
,
short
*
pcm
,
int
frame_size
,
int
decode_fec
)
int
len
,
opus_int16
*
pcm
,
int
frame_size
,
int
decode_fec
)
{
int
i
,
bytes
,
nb_samples
;
int
count
;
...
...
This diff is collapsed.
Click to expand it.
src/opus_decoder.h
+
2
−
2
View file @
d6a0216c
...
...
@@ -48,8 +48,8 @@ struct OpusDecoder {
int
rangeFinal
;
};
static
inline
short
SAT16
(
int
x
)
{
return
x
>
32767
?
32767
:
x
<
-
32768
?
-
32768
:
(
short
)
x
;
static
inline
opus_int16
SAT16
(
opus_
int
32
x
)
{
return
x
>
32767
?
32767
:
x
<
-
32768
?
-
32768
:
(
opus_int16
)
x
;
};
#endif
/* OPUS_DECODER_H */
...
...
This diff is collapsed.
Click to expand it.
src/opus_encoder.c
+
8
−
8
View file @
d6a0216c
...
...
@@ -162,7 +162,7 @@ OpusEncoder *opus_encoder_create(int Fs, int channels, int mode)
return
opus_encoder_init
((
OpusEncoder
*
)
raw_state
,
Fs
,
channels
,
mode
);
}
int
opus_encode
(
OpusEncoder
*
st
,
const
short
*
pcm
,
int
frame_size
,
int
opus_encode
(
OpusEncoder
*
st
,
const
opus_int16
*
pcm
,
int
frame_size
,
unsigned
char
*
data
,
int
max_data_bytes
)
{
void
*
silk_enc
;
...
...
@@ -181,7 +181,7 @@ int opus_encode(OpusEncoder *st, const short *pcm, int frame_size,
int
celt_to_silk
=
0
;
/* TODO: This is 60 only so we can handle 60ms speech/audio switching
it shouldn't be too hard to reduce to 20 ms if needed */
short
pcm_buf
[
60
*
48
*
2
];
opus_int16
pcm_buf
[
60
*
48
*
2
];
int
nb_compr_bytes
;
int
to_celt
=
0
;
opus_int32
mono_rate
;
...
...
@@ -510,16 +510,16 @@ int opus_encode(OpusEncoder *st, const short *pcm, int frame_size,
delta_Q14
=
(
st
->
hybrid_stereo_width_Q14
-
st
->
silk_mode
.
stereoWidth_Q14
)
/
nSamples_8ms
;
for
(
i
=
0
;
i
<
nSamples_8ms
;
i
++
)
{
width_Q14
+=
delta_Q14
;
diff
=
pcm_buf
[
2
*
i
+
1
]
-
(
int
)
pcm_buf
[
2
*
i
];
diff
=
pcm_buf
[
2
*
i
+
1
]
-
(
opus_
int
32
)
pcm_buf
[
2
*
i
];
diff
=
(
diff
*
width_Q14
)
>>
15
;
pcm_buf
[
2
*
i
]
=
(
short
)(
pcm_buf
[
2
*
i
]
+
diff
);
pcm_buf
[
2
*
i
+
1
]
=
(
short
)(
pcm_buf
[
2
*
i
+
1
]
-
diff
);
pcm_buf
[
2
*
i
]
=
(
opus_int16
)(
pcm_buf
[
2
*
i
]
+
diff
);
pcm_buf
[
2
*
i
+
1
]
=
(
opus_int16
)(
pcm_buf
[
2
*
i
+
1
]
-
diff
);
}
for
(
;
i
<
frame_size
;
i
++
)
{
diff
=
pcm_buf
[
2
*
i
+
1
]
-
(
int
)
pcm_buf
[
2
*
i
];
diff
=
pcm_buf
[
2
*
i
+
1
]
-
(
opus_
int
32
)
pcm_buf
[
2
*
i
];
diff
=
(
diff
*
width_Q14
)
>>
15
;
pcm_buf
[
2
*
i
]
=
(
short
)(
pcm_buf
[
2
*
i
]
+
diff
);
pcm_buf
[
2
*
i
+
1
]
=
(
short
)(
pcm_buf
[
2
*
i
+
1
]
-
diff
);
pcm_buf
[
2
*
i
]
=
(
opus_int16
)(
pcm_buf
[
2
*
i
]
+
diff
);
pcm_buf
[
2
*
i
+
1
]
=
(
opus_int16
)(
pcm_buf
[
2
*
i
+
1
]
-
diff
);
}
st
->
hybrid_stereo_width_Q14
=
st
->
silk_mode
.
stereoWidth_Q14
;
}
...
...
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