Commit d970a85c authored by Jean-Marc Valin's avatar Jean-Marc Valin
Browse files

Using opus_repacketizer_init() instead of opus_repacketizer_create() in the encoder

parent e4336a5c
......@@ -569,10 +569,20 @@ int opus_encode_float(OpusEncoder *st, const opus_val16 *pcm, int frame_size,
/* Can't support higher than wideband for >20 ms frames */
if (frame_size > st->Fs/50 && (st->mode == MODE_CELT_ONLY || st->bandwidth > OPUS_BANDWIDTH_WIDEBAND))
{
unsigned char tmp_data[3][1276];
VARDECL(unsigned char, tmp_data);
VARDECL(unsigned char, rp_);
int nb_frames;
int bak_mode, bak_bandwidth, bak_channels;
OpusRepacketizer *rp = opus_repacketizer_create();
OpusRepacketizer *rp;
int bytes_per_frame;
nb_frames = frame_size > st->Fs/25 ? 3 : 2;
bytes_per_frame = max_data_bytes/nb_frames-3;
ALLOC(tmp_data, nb_frames*bytes_per_frame, unsigned char);
ALLOC(rp_, opus_repacketizer_get_size(), unsigned char);
rp = opus_repacketizer_init((OpusRepacketizer*)rp_);
bak_mode = st->user_forced_mode;
bak_bandwidth = st->user_bandwidth;
......@@ -582,17 +592,14 @@ int opus_encode_float(OpusEncoder *st, const opus_val16 *pcm, int frame_size,
st->user_bandwidth = st->bandwidth;
st->force_channels = st->stream_channels;
nb_frames = frame_size > st->Fs/25 ? 3 : 2;
for (i=0;i<nb_frames;i++)
{
int tmp_len;
tmp_len = opus_encode_native(st, pcm+i*(st->channels*st->Fs/50), st->Fs/50, tmp_data[i], max_data_bytes/nb_frames-3);
ret = opus_repacketizer_cat(rp, tmp_data[i], tmp_len);
tmp_len = opus_encode_native(st, pcm+i*(st->channels*st->Fs/50), st->Fs/50, tmp_data+i*bytes_per_frame, bytes_per_frame);
ret = opus_repacketizer_cat(rp, tmp_data+i*bytes_per_frame, tmp_len);
}
ret = opus_repacketizer_out(rp, data, max_data_bytes);
opus_repacketizer_destroy(rp);
st->user_forced_mode = bak_mode;
st->user_bandwidth = bak_bandwidth;
st->force_channels = bak_channels;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment