Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.xiph.org/xiph/opus.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGregory Maxwell <greg@xiph.org>2011-11-20 08:58:09 +0400
committerJean-Marc Valin <jmvalin@jmvalin.ca>2012-03-06 02:59:50 +0400
commite7028175af1661abaa3447a6a84750662ab8dfe6 (patch)
tree8a3f924bfb34f1f95393a253aba34805a8ed5223 /src
parent8365b5d00df0d1129a30550f451fb62a24e1bc00 (diff)
40/60ms MDCT/Hybrid were not able to reach maximum bitrate. Now they can.
Also change the packet length in the API from int to opus_int32 because repacketized frames are able to go beyond 32767 bytes in size.
Diffstat (limited to 'src')
-rw-r--r--src/opus_decoder.c22
-rw-r--r--src/opus_encoder.c19
-rw-r--r--src/opus_multistream.c16
3 files changed, 29 insertions, 28 deletions
diff --git a/src/opus_decoder.c b/src/opus_decoder.c
index 889b5a4f..8a3a7237 100644
--- a/src/opus_decoder.c
+++ b/src/opus_decoder.c
@@ -187,7 +187,7 @@ static int opus_packet_get_mode(const unsigned char *data)
}
static int opus_decode_frame(OpusDecoder *st, const unsigned char *data,
- int len, opus_val16 *pcm, int frame_size, int decode_fec)
+ opus_int32 len, opus_val16 *pcm, int frame_size, int decode_fec)
{
void *silk_dec;
CELTDecoder *celt_dec;
@@ -505,7 +505,7 @@ static int opus_decode_frame(OpusDecoder *st, const unsigned char *data,
}
-static int parse_size(const unsigned char *data, int len, short *size)
+static int parse_size(const unsigned char *data, opus_int32 len, short *size)
{
if (len<1)
{
@@ -525,7 +525,7 @@ static int parse_size(const unsigned char *data, int len, short *size)
}
}
-static int opus_packet_parse_impl(const unsigned char *data, int len,
+static int opus_packet_parse_impl(const unsigned char *data, opus_int32 len,
int self_delimited, unsigned char *out_toc,
const unsigned char *frames[48], short size[48], int *payload_offset)
{
@@ -672,7 +672,7 @@ static int opus_packet_parse_impl(const unsigned char *data, int len,
return count;
}
-int opus_packet_parse(const unsigned char *data, int len,
+int opus_packet_parse(const unsigned char *data, opus_int32 len,
unsigned char *out_toc, const unsigned char *frames[48],
short size[48], int *payload_offset)
{
@@ -681,7 +681,7 @@ int opus_packet_parse(const unsigned char *data, int len,
}
int opus_decode_native(OpusDecoder *st, const unsigned char *data,
- int len, opus_val16 *pcm, int frame_size, int decode_fec,
+ opus_int32 len, opus_val16 *pcm, int frame_size, int decode_fec,
int self_delimited, int *packet_offset)
{
int i, nb_samples;
@@ -732,14 +732,14 @@ int opus_decode_native(OpusDecoder *st, const unsigned char *data,
#ifdef FIXED_POINT
int opus_decode(OpusDecoder *st, const unsigned char *data,
- int len, opus_val16 *pcm, int frame_size, int decode_fec)
+ opus_int32 len, opus_val16 *pcm, int frame_size, int decode_fec)
{
return opus_decode_native(st, data, len, pcm, frame_size, decode_fec, 0, NULL);
}
#ifndef DISABLE_FLOAT_API
int opus_decode_float(OpusDecoder *st, const unsigned char *data,
- int len, float *pcm, int frame_size, int decode_fec)
+ opus_int32 len, float *pcm, int frame_size, int decode_fec)
{
VARDECL(opus_int16, out);
int ret, i;
@@ -761,7 +761,7 @@ int opus_decode_float(OpusDecoder *st, const unsigned char *data,
#else
int opus_decode(OpusDecoder *st, const unsigned char *data,
- int len, opus_int16 *pcm, int frame_size, int decode_fec)
+ opus_int32 len, opus_int16 *pcm, int frame_size, int decode_fec)
{
VARDECL(float, out);
int ret, i;
@@ -782,7 +782,7 @@ int opus_decode(OpusDecoder *st, const unsigned char *data,
}
int opus_decode_float(OpusDecoder *st, const unsigned char *data,
- int len, opus_val16 *pcm, int frame_size, int decode_fec)
+ opus_int32 len, opus_val16 *pcm, int frame_size, int decode_fec)
{
return opus_decode_native(st, data, len, pcm, frame_size, decode_fec, 0, NULL);
}
@@ -902,7 +902,7 @@ int opus_packet_get_nb_channels(const unsigned char *data)
return (data[0]&0x4) ? 2 : 1;
}
-int opus_packet_get_nb_frames(const unsigned char packet[], int len)
+int opus_packet_get_nb_frames(const unsigned char packet[], opus_int32 len)
{
int count;
if (len<1)
@@ -919,7 +919,7 @@ int opus_packet_get_nb_frames(const unsigned char packet[], int len)
}
int opus_decoder_get_nb_samples(const OpusDecoder *dec,
- const unsigned char packet[], int len)
+ const unsigned char packet[], opus_int32 len)
{
int samples;
int count = opus_packet_get_nb_frames(packet, len);
diff --git a/src/opus_encoder.c b/src/opus_encoder.c
index 805bffb0..fc7e4f8f 100644
--- a/src/opus_encoder.c
+++ b/src/opus_encoder.c
@@ -220,7 +220,7 @@ int opus_encoder_init(OpusEncoder* st, opus_int32 Fs, int channels, int applicat
return OPUS_OK;
}
-static int pad_frame(unsigned char *data, int len, int new_len)
+static int pad_frame(unsigned char *data, opus_int32 len, opus_int32 new_len)
{
if (len == new_len)
return 0;
@@ -438,11 +438,11 @@ static opus_int32 user_bitrate_to_bitrate(OpusEncoder *st, int frame_size, int m
#ifdef FIXED_POINT
#define opus_encode_native opus_encode
int opus_encode(OpusEncoder *st, const opus_val16 *pcm, int frame_size,
- unsigned char *data, int max_data_bytes)
+ unsigned char *data, opus_int32 out_data_bytes)
#else
#define opus_encode_native opus_encode_float
int opus_encode_float(OpusEncoder *st, const opus_val16 *pcm, int frame_size,
- unsigned char *data, int max_data_bytes)
+ unsigned char *data, opus_int32 out_data_bytes)
#endif
{
void *silk_enc;
@@ -468,11 +468,12 @@ int opus_encode_float(OpusEncoder *st, const opus_val16 *pcm, int frame_size,
int frame_rate;
opus_int32 max_rate;
int curr_bandwidth;
+ opus_int32 max_data_bytes;
VARDECL(opus_val16, tmp_prefill);
ALLOC_STACK;
- max_data_bytes = IMIN(1276, max_data_bytes);
+ max_data_bytes = IMIN(1276, out_data_bytes);
st->rangeFinal = 0;
if (400*frame_size != st->Fs && 200*frame_size != st->Fs && 100*frame_size != st->Fs &&
@@ -746,11 +747,11 @@ int opus_encode_float(OpusEncoder *st, const opus_val16 *pcm, int frame_size,
int nb_frames;
int bak_mode, bak_bandwidth, bak_channels, bak_to_mono;
OpusRepacketizer rp;
- int bytes_per_frame;
+ opus_int32 bytes_per_frame;
nb_frames = frame_size > st->Fs/25 ? 3 : 2;
- bytes_per_frame = max_data_bytes/nb_frames-3;
+ bytes_per_frame = IMIN(1276,(out_data_bytes-3)/nb_frames);
ALLOC(tmp_data, nb_frames*bytes_per_frame, unsigned char);
@@ -783,7 +784,7 @@ int opus_encode_float(OpusEncoder *st, const opus_val16 *pcm, int frame_size,
if (ret<0)
return OPUS_INTERNAL_ERROR;
}
- ret = opus_repacketizer_out(&rp, data, max_data_bytes);
+ ret = opus_repacketizer_out(&rp, data, out_data_bytes);
if (ret<0)
return OPUS_INTERNAL_ERROR;
@@ -1222,7 +1223,7 @@ int opus_encode_float(OpusEncoder *st, const opus_val16 *pcm, int frame_size,
#ifndef DISABLE_FLOAT_API
int opus_encode_float(OpusEncoder *st, const float *pcm, int frame_size,
- unsigned char *data, int max_data_bytes)
+ unsigned char *data, opus_int32 max_data_bytes)
{
int i, ret;
VARDECL(opus_int16, in);
@@ -1242,7 +1243,7 @@ int opus_encode_float(OpusEncoder *st, const float *pcm, int frame_size,
#else
int opus_encode(OpusEncoder *st, const opus_int16 *pcm, int frame_size,
- unsigned char *data, int max_data_bytes)
+ unsigned char *data, opus_int32 max_data_bytes)
{
int i, ret;
VARDECL(float, in);
diff --git a/src/opus_multistream.c b/src/opus_multistream.c
index a2a48b9a..7e8c4d58 100644
--- a/src/opus_multistream.c
+++ b/src/opus_multistream.c
@@ -227,7 +227,7 @@ int opus_multistream_encode_float(
const opus_val16 *pcm,
int frame_size,
unsigned char *data,
- int max_data_bytes
+ opus_int32 max_data_bytes
)
{
int coupled_size;
@@ -309,7 +309,7 @@ int opus_multistream_encode_float(
const float *pcm,
int frame_size,
unsigned char *data,
- int max_data_bytes
+ opus_int32 max_data_bytes
)
{
int i, ret;
@@ -333,7 +333,7 @@ int opus_multistream_encode(
const opus_int16 *pcm,
int frame_size,
unsigned char *data,
- int max_data_bytes
+ opus_int32 max_data_bytes
)
{
int i, ret;
@@ -587,7 +587,7 @@ OpusMSDecoder *opus_multistream_decoder_create(
static int opus_multistream_decode_native(
OpusMSDecoder *st,
const unsigned char *data,
- int len,
+ opus_int32 len,
opus_val16 *pcm,
int frame_size,
int decode_fec
@@ -693,7 +693,7 @@ static int opus_multistream_decode_native(
int opus_multistream_decode(
OpusMSDecoder *st,
const unsigned char *data,
- int len,
+ opus_int32 len,
opus_int16 *pcm,
int frame_size,
int decode_fec
@@ -704,7 +704,7 @@ int opus_multistream_decode(
#ifndef DISABLE_FLOAT_API
int opus_multistream_decode_float(OpusMSDecoder *st, const unsigned char *data,
- int len, float *pcm, int frame_size, int decode_fec)
+ opus_int32 len, float *pcm, int frame_size, int decode_fec)
{
VARDECL(opus_int16, out);
int ret, i;
@@ -726,7 +726,7 @@ int opus_multistream_decode_float(OpusMSDecoder *st, const unsigned char *data,
#else
int opus_multistream_decode(OpusMSDecoder *st, const unsigned char *data,
- int len, opus_int16 *pcm, int frame_size, int decode_fec)
+ opus_int32 len, opus_int16 *pcm, int frame_size, int decode_fec)
{
VARDECL(float, out);
int ret, i;
@@ -747,7 +747,7 @@ int opus_multistream_decode(OpusMSDecoder *st, const unsigned char *data,
int opus_multistream_decode_float(
OpusMSDecoder *st,
const unsigned char *data,
- int len,
+ opus_int32 len,
float *pcm,
int frame_size,
int decode_fec