forked from len0rd/rockbox
Sync to SVN.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15792 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
d6e22443c4
commit
929443cca5
14 changed files with 249 additions and 227 deletions
|
|
@ -42,7 +42,7 @@
|
||||||
#define SPEEX_MINOR_VERSION 1 /**< Minor Speex version. */
|
#define SPEEX_MINOR_VERSION 1 /**< Minor Speex version. */
|
||||||
#define SPEEX_MICRO_VERSION 15 /**< Micro Speex version. */
|
#define SPEEX_MICRO_VERSION 15 /**< Micro Speex version. */
|
||||||
#define SPEEX_EXTRA_VERSION "" /**< Extra Speex version. */
|
#define SPEEX_EXTRA_VERSION "" /**< Extra Speex version. */
|
||||||
#define SPEEX_VERSION "speex-1.2beta3" /**< Speex version string. */
|
#define SPEEX_VERSION "speex-1.2beta4" /**< Speex version string. */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* A couple test to catch stupid option combinations */
|
/* A couple test to catch stupid option combinations */
|
||||||
|
|
@ -127,8 +127,6 @@ typedef spx_word32_t spx_sig_t;
|
||||||
#include "fixed_arm5e.h"
|
#include "fixed_arm5e.h"
|
||||||
#elif defined (ARM4_ASM)
|
#elif defined (ARM4_ASM)
|
||||||
#include "fixed_arm4.h"
|
#include "fixed_arm4.h"
|
||||||
#elif defined (ARM5E_ASM)
|
|
||||||
#include "fixed_arm5e.h"
|
|
||||||
#elif defined (BFIN_ASM)
|
#elif defined (BFIN_ASM)
|
||||||
#include "fixed_bfin.h"
|
#include "fixed_bfin.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -151,13 +151,9 @@ void speex_bits_read_from(SpeexBits *bits, char *chars, int len)
|
||||||
|
|
||||||
static void speex_bits_flush(SpeexBits *bits)
|
static void speex_bits_flush(SpeexBits *bits)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
int nchars = ((bits->nbBits+BITS_PER_CHAR-1)>>LOG2_BITS_PER_CHAR);
|
int nchars = ((bits->nbBits+BITS_PER_CHAR-1)>>LOG2_BITS_PER_CHAR);
|
||||||
if (bits->charPtr>0)
|
if (bits->charPtr>0)
|
||||||
{
|
SPEEX_MOVE(bits->chars, &bits->chars[bits->charPtr], nchars-bits->charPtr);
|
||||||
for (i=bits->charPtr;i<nchars; i++)
|
|
||||||
bits->chars[i-bits->charPtr]=bits->chars[i];
|
|
||||||
}
|
|
||||||
bits->nbBits -= bits->charPtr<<LOG2_BITS_PER_CHAR;
|
bits->nbBits -= bits->charPtr<<LOG2_BITS_PER_CHAR;
|
||||||
bits->charPtr=0;
|
bits->charPtr=0;
|
||||||
}
|
}
|
||||||
|
|
@ -232,8 +228,6 @@ int speex_bits_write_whole_bytes(SpeexBits *bits, char *chars, int max_nbytes)
|
||||||
bits->chars[0]=bits->chars[max_nchars];
|
bits->chars[0]=bits->chars[max_nchars];
|
||||||
else
|
else
|
||||||
bits->chars[0]=0;
|
bits->chars[0]=0;
|
||||||
for (i=1;i<((bits->nbBits)>>LOG2_BITS_PER_CHAR)+1;i++)
|
|
||||||
bits->chars[i]=0;
|
|
||||||
bits->charPtr=0;
|
bits->charPtr=0;
|
||||||
bits->nbBits &= (BITS_PER_CHAR-1);
|
bits->nbBits &= (BITS_PER_CHAR-1);
|
||||||
return max_nchars*BYTES_PER_CHAR;
|
return max_nchars*BYTES_PER_CHAR;
|
||||||
|
|
|
||||||
|
|
@ -149,8 +149,7 @@ int update_target
|
||||||
ALLOC(e, nsf, spx_sig_t);
|
ALLOC(e, nsf, spx_sig_t);
|
||||||
|
|
||||||
/* FIXME: Do we still need to copy the target? */
|
/* FIXME: Do we still need to copy the target? */
|
||||||
for (i=0;i<nsf;i++)
|
SPEEX_COPY(t, target, nsf);
|
||||||
t[i]=target[i];
|
|
||||||
|
|
||||||
compute_weighted_codebook(shape_cb, r, resp, resp2, E, shape_cb_size, subvect_size, stack);
|
compute_weighted_codebook(shape_cb, r, resp, resp2, E, shape_cb_size, subvect_size, stack);
|
||||||
|
|
||||||
|
|
@ -344,11 +343,10 @@ int update_target
|
||||||
oind[i]=itmp+(2*i+1)*nb_subvect;
|
oind[i]=itmp+(2*i+1)*nb_subvect;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=0;i<nsf;i++)
|
SPEEX_COPY(t, target, nsf);
|
||||||
t[i]=target[i];
|
|
||||||
|
|
||||||
for (j=0;j<N;j++)
|
for (j=0;j<N;j++)
|
||||||
speex_move(&ot[j][0], t, nsf*sizeof(spx_word16_t));
|
SPEEX_COPY(&ot[j][0], t, nsf);
|
||||||
|
|
||||||
/* Pre-compute codewords response and energy */
|
/* Pre-compute codewords response and energy */
|
||||||
compute_weighted_codebook(shape_cb, r, resp, resp2, E, shape_cb_size, subvect_size, stack);
|
compute_weighted_codebook(shape_cb, r, resp, resp2, E, shape_cb_size, subvect_size, stack);
|
||||||
|
|
@ -597,8 +595,7 @@ int update_target
|
||||||
|
|
||||||
for (i=0;i<nsf;i++)
|
for (i=0;i<nsf;i++)
|
||||||
exc[i]+=SHL32(EXTEND32(tmp[i]),8);
|
exc[i]+=SHL32(EXTEND32(tmp[i]),8);
|
||||||
for (i=0;i<nsf;i++)
|
SPEEX_MEMSET(target, 0, nsf);
|
||||||
target[i]=0;
|
|
||||||
}
|
}
|
||||||
#endif /* SPEEX_DISABLE_ENCODER */
|
#endif /* SPEEX_DISABLE_ENCODER */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -120,8 +120,8 @@ static void tb_add(struct TimingBuffer *tb, spx_int16_t timing)
|
||||||
int move_size = tb->filled-pos;
|
int move_size = tb->filled-pos;
|
||||||
if (tb->filled == MAX_TIMINGS)
|
if (tb->filled == MAX_TIMINGS)
|
||||||
move_size -= 1;
|
move_size -= 1;
|
||||||
speex_move(&tb->timing[pos+1], &tb->timing[pos], move_size*sizeof(tb->timing[0]));
|
SPEEX_COPY(&tb->timing[pos+1], &tb->timing[pos], move_size);
|
||||||
speex_move(&tb->counts[pos+1], &tb->counts[pos], move_size*sizeof(tb->counts[0]));
|
SPEEX_COPY(&tb->counts[pos+1], &tb->counts[pos], move_size);
|
||||||
}
|
}
|
||||||
/* Insert */
|
/* Insert */
|
||||||
tb->timing[pos] = timing;
|
tb->timing[pos] = timing;
|
||||||
|
|
@ -153,6 +153,7 @@ struct JitterBuffer_ {
|
||||||
int buffer_margin; /**< How many frames we want to keep in the buffer (lower bound) */
|
int buffer_margin; /**< How many frames we want to keep in the buffer (lower bound) */
|
||||||
int late_cutoff; /**< How late must a packet be for it not to be considered at all */
|
int late_cutoff; /**< How late must a packet be for it not to be considered at all */
|
||||||
int interp_requested; /**< An interpolation is requested by speex_jitter_update_delay() */
|
int interp_requested; /**< An interpolation is requested by speex_jitter_update_delay() */
|
||||||
|
int auto_adjust; /**< Whether to automatically adjust the delay at any time */
|
||||||
|
|
||||||
struct TimingBuffer _tb[MAX_BUFFERS]; /**< Don't use those directly */
|
struct TimingBuffer _tb[MAX_BUFFERS]; /**< Don't use those directly */
|
||||||
struct TimingBuffer *timeBuffers[MAX_BUFFERS]; /**< Storing arrival time of latest frames so we can compute some stats */
|
struct TimingBuffer *timeBuffers[MAX_BUFFERS]; /**< Storing arrival time of latest frames so we can compute some stats */
|
||||||
|
|
@ -268,7 +269,7 @@ static spx_int16_t compute_opt_delay(JitterBuffer *jitter)
|
||||||
|
|
||||||
|
|
||||||
/** Initialise jitter buffer */
|
/** Initialise jitter buffer */
|
||||||
JitterBuffer *jitter_buffer_init(void)
|
JitterBuffer *jitter_buffer_init(int step_size)
|
||||||
{
|
{
|
||||||
JitterBuffer *jitter = (JitterBuffer*)speex_alloc(sizeof(JitterBuffer));
|
JitterBuffer *jitter = (JitterBuffer*)speex_alloc(sizeof(JitterBuffer));
|
||||||
if (jitter)
|
if (jitter)
|
||||||
|
|
@ -277,13 +278,14 @@ JitterBuffer *jitter_buffer_init(void)
|
||||||
spx_int32_t tmp;
|
spx_int32_t tmp;
|
||||||
for (i=0;i<SPEEX_JITTER_MAX_BUFFER_SIZE;i++)
|
for (i=0;i<SPEEX_JITTER_MAX_BUFFER_SIZE;i++)
|
||||||
jitter->packets[i].data=NULL;
|
jitter->packets[i].data=NULL;
|
||||||
jitter->delay_step = 1;
|
jitter->delay_step = step_size;
|
||||||
jitter->concealment_size = 1;
|
jitter->concealment_size = step_size;
|
||||||
/*FIXME: Should this be 0 or 1?*/
|
/*FIXME: Should this be 0 or 1?*/
|
||||||
jitter->buffer_margin = 0;
|
jitter->buffer_margin = 0;
|
||||||
jitter->late_cutoff = 50;
|
jitter->late_cutoff = 50;
|
||||||
jitter->destroy = NULL;
|
jitter->destroy = NULL;
|
||||||
jitter->latency_tradeoff = 0;
|
jitter->latency_tradeoff = 0;
|
||||||
|
jitter->auto_adjust = 1;
|
||||||
tmp = 4;
|
tmp = 4;
|
||||||
jitter_buffer_ctl(jitter, JITTER_BUFFER_SET_MAX_LATE_RATE, &tmp);
|
jitter_buffer_ctl(jitter, JITTER_BUFFER_SET_MAX_LATE_RATE, &tmp);
|
||||||
jitter_buffer_reset(jitter);
|
jitter_buffer_reset(jitter);
|
||||||
|
|
@ -369,33 +371,27 @@ void jitter_buffer_put(JitterBuffer *jitter, const JitterBufferPacket *packet)
|
||||||
int late;
|
int late;
|
||||||
/*fprintf (stderr, "put packet %d %d\n", timestamp, span);*/
|
/*fprintf (stderr, "put packet %d %d\n", timestamp, span);*/
|
||||||
|
|
||||||
/* Syncing on the first packet to arrive */
|
|
||||||
if (jitter->reset_state)
|
|
||||||
{
|
|
||||||
jitter->reset_state=0;
|
|
||||||
jitter->pointer_timestamp = packet->timestamp;
|
|
||||||
jitter->next_stop = packet->timestamp;
|
|
||||||
/*fprintf(stderr, "reset to %d\n", timestamp);*/
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Cleanup buffer (remove old packets that weren't played) */
|
/* Cleanup buffer (remove old packets that weren't played) */
|
||||||
for (i=0;i<SPEEX_JITTER_MAX_BUFFER_SIZE;i++)
|
if (!jitter->reset_state)
|
||||||
{
|
{
|
||||||
/* Make sure we don't discard a "just-late" packet in case we want to play it next (if we interpolate). */
|
for (i=0;i<SPEEX_JITTER_MAX_BUFFER_SIZE;i++)
|
||||||
if (jitter->packets[i].data && LE32(jitter->packets[i].timestamp + jitter->packets[i].span, jitter->pointer_timestamp))
|
|
||||||
{
|
{
|
||||||
/*fprintf (stderr, "cleaned (not played)\n");*/
|
/* Make sure we don't discard a "just-late" packet in case we want to play it next (if we interpolate). */
|
||||||
if (jitter->destroy)
|
if (jitter->packets[i].data && LE32(jitter->packets[i].timestamp + jitter->packets[i].span, jitter->pointer_timestamp))
|
||||||
jitter->destroy(jitter->packets[i].data);
|
{
|
||||||
else
|
/*fprintf (stderr, "cleaned (not played)\n");*/
|
||||||
speex_free(jitter->packets[i].data);
|
if (jitter->destroy)
|
||||||
jitter->packets[i].data = NULL;
|
jitter->destroy(jitter->packets[i].data);
|
||||||
|
else
|
||||||
|
speex_free(jitter->packets[i].data);
|
||||||
|
jitter->packets[i].data = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*fprintf(stderr, "arrival: %d %d %d\n", packet->timestamp, jitter->next_stop, jitter->pointer_timestamp);*/
|
/*fprintf(stderr, "arrival: %d %d %d\n", packet->timestamp, jitter->next_stop, jitter->pointer_timestamp);*/
|
||||||
/* Check if packet is late (could still be useful though) */
|
/* Check if packet is late (could still be useful though) */
|
||||||
if (LT32(packet->timestamp, jitter->next_stop))
|
if (!jitter->reset_state && LT32(packet->timestamp, jitter->next_stop))
|
||||||
{
|
{
|
||||||
update_timings(jitter, ((spx_int32_t)packet->timestamp) - ((spx_int32_t)jitter->next_stop) - jitter->buffer_margin);
|
update_timings(jitter, ((spx_int32_t)packet->timestamp) - ((spx_int32_t)jitter->next_stop) - jitter->buffer_margin);
|
||||||
late = 1;
|
late = 1;
|
||||||
|
|
@ -404,7 +400,7 @@ void jitter_buffer_put(JitterBuffer *jitter, const JitterBufferPacket *packet)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Only insert the packet if it's not hopelessly late (i.e. totally useless) */
|
/* Only insert the packet if it's not hopelessly late (i.e. totally useless) */
|
||||||
if (GE32(packet->timestamp+packet->span+jitter->delay_step, jitter->pointer_timestamp))
|
if (jitter->reset_state || GE32(packet->timestamp+packet->span+jitter->delay_step, jitter->pointer_timestamp))
|
||||||
{
|
{
|
||||||
|
|
||||||
/*Find an empty slot in the buffer*/
|
/*Find an empty slot in the buffer*/
|
||||||
|
|
@ -451,8 +447,9 @@ void jitter_buffer_put(JitterBuffer *jitter, const JitterBufferPacket *packet)
|
||||||
jitter->packets[i].timestamp=packet->timestamp;
|
jitter->packets[i].timestamp=packet->timestamp;
|
||||||
jitter->packets[i].span=packet->span;
|
jitter->packets[i].span=packet->span;
|
||||||
jitter->packets[i].len=packet->len;
|
jitter->packets[i].len=packet->len;
|
||||||
|
jitter->packets[i].sequence=packet->sequence;
|
||||||
jitter->packets[i].user_data=packet->user_data;
|
jitter->packets[i].user_data=packet->user_data;
|
||||||
if (late)
|
if (jitter->reset_state || late)
|
||||||
jitter->arrival[i] = 0;
|
jitter->arrival[i] = 0;
|
||||||
else
|
else
|
||||||
jitter->arrival[i] = jitter->next_stop;
|
jitter->arrival[i] = jitter->next_stop;
|
||||||
|
|
@ -469,12 +466,40 @@ int jitter_buffer_get(JitterBuffer *jitter, JitterBufferPacket *packet, spx_int3
|
||||||
int incomplete = 0;
|
int incomplete = 0;
|
||||||
spx_int16_t opt;
|
spx_int16_t opt;
|
||||||
|
|
||||||
|
if (start_offset != NULL)
|
||||||
|
*start_offset = 0;
|
||||||
|
|
||||||
|
/* Syncing on the first call */
|
||||||
|
if (jitter->reset_state)
|
||||||
|
{
|
||||||
|
int found = 0;
|
||||||
|
/* Find the oldest packet */
|
||||||
|
spx_uint32_t oldest=0;
|
||||||
|
for (i=0;i<SPEEX_JITTER_MAX_BUFFER_SIZE;i++)
|
||||||
|
{
|
||||||
|
if (jitter->packets[i].data && (!found || LT32(jitter->packets[i].timestamp,oldest)))
|
||||||
|
{
|
||||||
|
oldest = jitter->packets[i].timestamp;
|
||||||
|
found = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (found)
|
||||||
|
{
|
||||||
|
jitter->reset_state=0;
|
||||||
|
jitter->pointer_timestamp = oldest;
|
||||||
|
jitter->next_stop = oldest;
|
||||||
|
} else {
|
||||||
|
packet->timestamp = 0;
|
||||||
|
packet->span = jitter->interp_requested;
|
||||||
|
return JITTER_BUFFER_MISSING;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
jitter->last_returned_timestamp = jitter->pointer_timestamp;
|
jitter->last_returned_timestamp = jitter->pointer_timestamp;
|
||||||
|
|
||||||
if (jitter->interp_requested != 0)
|
if (jitter->interp_requested != 0)
|
||||||
{
|
{
|
||||||
if (start_offset)
|
|
||||||
*start_offset = 0;
|
|
||||||
packet->timestamp = jitter->pointer_timestamp;
|
packet->timestamp = jitter->pointer_timestamp;
|
||||||
packet->span = jitter->interp_requested;
|
packet->span = jitter->interp_requested;
|
||||||
|
|
||||||
|
|
@ -487,7 +512,7 @@ int jitter_buffer_get(JitterBuffer *jitter, JitterBufferPacket *packet, spx_int3
|
||||||
|
|
||||||
jitter->buffered = packet->span - desired_span;
|
jitter->buffered = packet->span - desired_span;
|
||||||
|
|
||||||
return JITTER_BUFFER_MISSING;
|
return JITTER_BUFFER_INSERTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Searching for the packet that fits best */
|
/* Searching for the packet that fits best */
|
||||||
|
|
@ -551,7 +576,7 @@ int jitter_buffer_get(JitterBuffer *jitter, JitterBufferPacket *packet, spx_int3
|
||||||
/* If we find something */
|
/* If we find something */
|
||||||
if (i!=SPEEX_JITTER_MAX_BUFFER_SIZE)
|
if (i!=SPEEX_JITTER_MAX_BUFFER_SIZE)
|
||||||
{
|
{
|
||||||
|
spx_int32_t offset;
|
||||||
|
|
||||||
/* We (obviously) haven't lost this packet */
|
/* We (obviously) haven't lost this packet */
|
||||||
jitter->lost_count = 0;
|
jitter->lost_count = 0;
|
||||||
|
|
@ -563,8 +588,12 @@ int jitter_buffer_get(JitterBuffer *jitter, JitterBufferPacket *packet, spx_int3
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* FIXME: Check for potential overflow */
|
if (jitter->packets[i].len > packet->len)
|
||||||
packet->len = jitter->packets[i].len;
|
{
|
||||||
|
speex_warning_int("jitter_buffer_get(): packet too large to fit. Size is", jitter->packets[i].len);
|
||||||
|
} else {
|
||||||
|
packet->len = jitter->packets[i].len;
|
||||||
|
}
|
||||||
/* Copy packet */
|
/* Copy packet */
|
||||||
if (jitter->destroy)
|
if (jitter->destroy)
|
||||||
{
|
{
|
||||||
|
|
@ -577,23 +606,27 @@ int jitter_buffer_get(JitterBuffer *jitter, JitterBufferPacket *packet, spx_int3
|
||||||
}
|
}
|
||||||
jitter->packets[i].data = NULL;
|
jitter->packets[i].data = NULL;
|
||||||
/* Set timestamp and span (if requested) */
|
/* Set timestamp and span (if requested) */
|
||||||
if (start_offset)
|
offset = (spx_int32_t)jitter->packets[i].timestamp-(spx_int32_t)jitter->pointer_timestamp;
|
||||||
*start_offset = (spx_int32_t)jitter->packets[i].timestamp-(spx_int32_t)jitter->pointer_timestamp;
|
if (start_offset != NULL)
|
||||||
|
*start_offset = offset;
|
||||||
|
else if (offset != 0)
|
||||||
|
speex_warning_int("jitter_buffer_get() discarding non-zero start_offset", offset);
|
||||||
|
|
||||||
packet->timestamp = jitter->packets[i].timestamp;
|
packet->timestamp = jitter->packets[i].timestamp;
|
||||||
jitter->last_returned_timestamp = packet->timestamp;
|
jitter->last_returned_timestamp = packet->timestamp;
|
||||||
|
|
||||||
packet->span = jitter->packets[i].span;
|
packet->span = jitter->packets[i].span;
|
||||||
|
packet->sequence = jitter->packets[i].sequence;
|
||||||
packet->user_data = jitter->packets[i].user_data;
|
packet->user_data = jitter->packets[i].user_data;
|
||||||
/* Point to the end of the current packet */
|
/* Point to the end of the current packet */
|
||||||
jitter->pointer_timestamp = jitter->packets[i].timestamp+jitter->packets[i].span;
|
jitter->pointer_timestamp = jitter->packets[i].timestamp+jitter->packets[i].span;
|
||||||
|
|
||||||
jitter->buffered = *start_offset + packet->span - desired_span;
|
jitter->buffered = packet->span - desired_span;
|
||||||
|
|
||||||
if (incomplete)
|
if (start_offset != NULL)
|
||||||
return JITTER_BUFFER_INCOMPLETE;
|
jitter->buffered += *start_offset;
|
||||||
else
|
|
||||||
return JITTER_BUFFER_OK;
|
return JITTER_BUFFER_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -603,8 +636,6 @@ int jitter_buffer_get(JitterBuffer *jitter, JitterBufferPacket *packet, spx_int3
|
||||||
jitter->lost_count++;
|
jitter->lost_count++;
|
||||||
/*fprintf (stderr, "m");*/
|
/*fprintf (stderr, "m");*/
|
||||||
/*fprintf (stderr, "lost_count = %d\n", jitter->lost_count);*/
|
/*fprintf (stderr, "lost_count = %d\n", jitter->lost_count);*/
|
||||||
if (start_offset)
|
|
||||||
*start_offset = 0;
|
|
||||||
|
|
||||||
opt = compute_opt_delay(jitter);
|
opt = compute_opt_delay(jitter);
|
||||||
|
|
||||||
|
|
@ -621,6 +652,8 @@ int jitter_buffer_get(JitterBuffer *jitter, JitterBufferPacket *packet, spx_int3
|
||||||
/* Don't move the pointer_timestamp forward */
|
/* Don't move the pointer_timestamp forward */
|
||||||
packet->len = 0;
|
packet->len = 0;
|
||||||
|
|
||||||
|
jitter->buffered = packet->span - desired_span;
|
||||||
|
return JITTER_BUFFER_INSERTION;
|
||||||
/*jitter->pointer_timestamp -= jitter->delay_step;*/
|
/*jitter->pointer_timestamp -= jitter->delay_step;*/
|
||||||
/*fprintf (stderr, "Forced to interpolate\n");*/
|
/*fprintf (stderr, "Forced to interpolate\n");*/
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -631,11 +664,12 @@ int jitter_buffer_get(JitterBuffer *jitter, JitterBufferPacket *packet, spx_int3
|
||||||
packet->span = desired_span;
|
packet->span = desired_span;
|
||||||
jitter->pointer_timestamp += desired_span;
|
jitter->pointer_timestamp += desired_span;
|
||||||
packet->len = 0;
|
packet->len = 0;
|
||||||
|
|
||||||
|
jitter->buffered = packet->span - desired_span;
|
||||||
|
return JITTER_BUFFER_MISSING;
|
||||||
/*fprintf (stderr, "Normal loss\n");*/
|
/*fprintf (stderr, "Normal loss\n");*/
|
||||||
}
|
}
|
||||||
|
|
||||||
jitter->buffered = packet->span - desired_span;
|
|
||||||
return JITTER_BUFFER_MISSING;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -663,6 +697,7 @@ int jitter_buffer_get_another(JitterBuffer *jitter, JitterBufferPacket *packet)
|
||||||
jitter->packets[i].data = NULL;
|
jitter->packets[i].data = NULL;
|
||||||
packet->timestamp = jitter->packets[i].timestamp;
|
packet->timestamp = jitter->packets[i].timestamp;
|
||||||
packet->span = jitter->packets[i].span;
|
packet->span = jitter->packets[i].span;
|
||||||
|
packet->sequence = jitter->packets[i].sequence;
|
||||||
packet->user_data = jitter->packets[i].user_data;
|
packet->user_data = jitter->packets[i].user_data;
|
||||||
return JITTER_BUFFER_OK;
|
return JITTER_BUFFER_OK;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -673,33 +708,8 @@ int jitter_buffer_get_another(JitterBuffer *jitter, JitterBufferPacket *packet)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get pointer timestamp of jitter buffer */
|
|
||||||
int jitter_buffer_get_pointer_timestamp(JitterBuffer *jitter)
|
|
||||||
{
|
|
||||||
return jitter->pointer_timestamp;
|
|
||||||
}
|
|
||||||
|
|
||||||
void jitter_buffer_tick(JitterBuffer *jitter)
|
|
||||||
{
|
|
||||||
if (jitter->buffered >= 0)
|
|
||||||
{
|
|
||||||
jitter->next_stop = jitter->pointer_timestamp - jitter->buffered;
|
|
||||||
} else {
|
|
||||||
jitter->next_stop = jitter->pointer_timestamp;
|
|
||||||
speex_warning_int("jitter buffer sees negative buffering, you code might be broken. Value is ", jitter->buffered);
|
|
||||||
}
|
|
||||||
jitter->buffered = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void jitter_buffer_remaining_span(JitterBuffer *jitter, spx_uint32_t rem)
|
|
||||||
{
|
|
||||||
if (jitter->buffered < 0)
|
|
||||||
speex_warning_int("jitter buffer sees negative buffering, you code might be broken. Value is ", jitter->buffered);
|
|
||||||
jitter->next_stop = jitter->pointer_timestamp - rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Let the jitter buffer know it's the right time to adjust the buffering delay to the network conditions */
|
/* Let the jitter buffer know it's the right time to adjust the buffering delay to the network conditions */
|
||||||
int jitter_buffer_update_delay(JitterBuffer *jitter, JitterBufferPacket *packet, spx_int32_t *start_offset)
|
static int _jitter_buffer_update_delay(JitterBuffer *jitter, JitterBufferPacket *packet, spx_int32_t *start_offset)
|
||||||
{
|
{
|
||||||
spx_int16_t opt = compute_opt_delay(jitter);
|
spx_int16_t opt = compute_opt_delay(jitter);
|
||||||
/*fprintf(stderr, "opt adjustment is %d ", opt);*/
|
/*fprintf(stderr, "opt adjustment is %d ", opt);*/
|
||||||
|
|
@ -721,6 +731,50 @@ int jitter_buffer_update_delay(JitterBuffer *jitter, JitterBufferPacket *packet,
|
||||||
return opt;
|
return opt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Let the jitter buffer know it's the right time to adjust the buffering delay to the network conditions */
|
||||||
|
int jitter_buffer_update_delay(JitterBuffer *jitter, JitterBufferPacket *packet, spx_int32_t *start_offset)
|
||||||
|
{
|
||||||
|
/* If the programmer calls jitter_buffer_update_delay() directly,
|
||||||
|
automatically disable auto-adjustment */
|
||||||
|
jitter->auto_adjust = 0;
|
||||||
|
|
||||||
|
return _jitter_buffer_update_delay(jitter, packet, start_offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get pointer timestamp of jitter buffer */
|
||||||
|
int jitter_buffer_get_pointer_timestamp(JitterBuffer *jitter)
|
||||||
|
{
|
||||||
|
return jitter->pointer_timestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
void jitter_buffer_tick(JitterBuffer *jitter)
|
||||||
|
{
|
||||||
|
/* Automatically-adjust the buffering delay if requested */
|
||||||
|
if (jitter->auto_adjust)
|
||||||
|
_jitter_buffer_update_delay(jitter, NULL, NULL);
|
||||||
|
|
||||||
|
if (jitter->buffered >= 0)
|
||||||
|
{
|
||||||
|
jitter->next_stop = jitter->pointer_timestamp - jitter->buffered;
|
||||||
|
} else {
|
||||||
|
jitter->next_stop = jitter->pointer_timestamp;
|
||||||
|
speex_warning_int("jitter buffer sees negative buffering, your code might be broken. Value is ", jitter->buffered);
|
||||||
|
}
|
||||||
|
jitter->buffered = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void jitter_buffer_remaining_span(JitterBuffer *jitter, spx_uint32_t rem)
|
||||||
|
{
|
||||||
|
/* Automatically-adjust the buffering delay if requested */
|
||||||
|
if (jitter->auto_adjust)
|
||||||
|
_jitter_buffer_update_delay(jitter, NULL, NULL);
|
||||||
|
|
||||||
|
if (jitter->buffered < 0)
|
||||||
|
speex_warning_int("jitter buffer sees negative buffering, your code might be broken. Value is ", jitter->buffered);
|
||||||
|
jitter->next_stop = jitter->pointer_timestamp - rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Used like the ioctl function to control the jitter buffer parameters */
|
/* Used like the ioctl function to control the jitter buffer parameters */
|
||||||
int jitter_buffer_ctl(JitterBuffer *jitter, int request, void *ptr)
|
int jitter_buffer_ctl(JitterBuffer *jitter, int request, void *ptr)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -509,7 +509,7 @@ void kiss_fft_stride(kiss_fft_cfg st,const kiss_fft_cpx *fin,kiss_fft_cpx *fout,
|
||||||
speex_fatal("In-place FFT not supported");
|
speex_fatal("In-place FFT not supported");
|
||||||
/*CHECKBUF(tmpbuf,ntmpbuf,st->nfft);
|
/*CHECKBUF(tmpbuf,ntmpbuf,st->nfft);
|
||||||
kf_work(tmpbuf,fin,1,in_stride, st->factors,st);
|
kf_work(tmpbuf,fin,1,in_stride, st->factors,st);
|
||||||
speex_move(fout,tmpbuf,sizeof(kiss_fft_cpx)*st->nfft);*/
|
SPEEX_MOVE(fout,tmpbuf,st->nfft);*/
|
||||||
} else {
|
} else {
|
||||||
kf_shuffle( fout, fin, 1,in_stride, st->factors,st);
|
kf_shuffle( fout, fin, 1,in_stride, st->factors,st);
|
||||||
kf_work( fout, fin, 1,in_stride, st->factors,st, 1, in_stride, 1);
|
kf_work( fout, fin, 1,in_stride, st->factors,st, 1, in_stride, 1);
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@
|
||||||
#include "filters.h"
|
#include "filters.h"
|
||||||
#include <speex/speex_bits.h>
|
#include <speex/speex_bits.h>
|
||||||
#include "math_approx.h"
|
#include "math_approx.h"
|
||||||
|
#include "os_support.h"
|
||||||
|
|
||||||
#ifndef NULL
|
#ifndef NULL
|
||||||
#define NULL 0
|
#define NULL 0
|
||||||
|
|
@ -498,8 +499,7 @@ int scaledown
|
||||||
*cdbk_index=best_cdbk;
|
*cdbk_index=best_cdbk;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=0;i<nsf;i++)
|
SPEEX_MEMSET(exc, 0, nsf);
|
||||||
exc[i]=0;
|
|
||||||
for (i=0;i<3;i++)
|
for (i=0;i<3;i++)
|
||||||
{
|
{
|
||||||
int j;
|
int j;
|
||||||
|
|
@ -551,7 +551,7 @@ int plc_tuning,
|
||||||
spx_word32_t *cumul_gain
|
spx_word32_t *cumul_gain
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
int i,j;
|
int i;
|
||||||
int cdbk_index, pitch=0, best_gain_index=0;
|
int cdbk_index, pitch=0, best_gain_index=0;
|
||||||
VARDECL(spx_sig_t *best_exc);
|
VARDECL(spx_sig_t *best_exc);
|
||||||
VARDECL(spx_word16_t *new_target);
|
VARDECL(spx_word16_t *new_target);
|
||||||
|
|
@ -583,8 +583,7 @@ spx_word32_t *cumul_gain
|
||||||
{
|
{
|
||||||
speex_bits_pack(bits, 0, params->pitch_bits);
|
speex_bits_pack(bits, 0, params->pitch_bits);
|
||||||
speex_bits_pack(bits, 0, params->gain_bits);
|
speex_bits_pack(bits, 0, params->gain_bits);
|
||||||
for (i=0;i<nsf;i++)
|
SPEEX_MEMSET(exc, 0, nsf);
|
||||||
exc[i]=0;
|
|
||||||
return start;
|
return start;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -621,16 +620,13 @@ spx_word32_t *cumul_gain
|
||||||
for (i=0;i<N;i++)
|
for (i=0;i<N;i++)
|
||||||
{
|
{
|
||||||
pitch=nbest[i];
|
pitch=nbest[i];
|
||||||
for (j=0;j<nsf;j++)
|
SPEEX_MEMSET(exc, 0, nsf);
|
||||||
exc[j]=0;
|
|
||||||
err=pitch_gain_search_3tap(target, ak, awk1, awk2, exc, gain_cdbk, gain_cdbk_size, pitch, p, nsf,
|
err=pitch_gain_search_3tap(target, ak, awk1, awk2, exc, gain_cdbk, gain_cdbk_size, pitch, p, nsf,
|
||||||
bits, stack, exc2, r, new_target, &cdbk_index, plc_tuning, *cumul_gain, scaledown);
|
bits, stack, exc2, r, new_target, &cdbk_index, plc_tuning, *cumul_gain, scaledown);
|
||||||
if (err<best_err || best_err<0)
|
if (err<best_err || best_err<0)
|
||||||
{
|
{
|
||||||
for (j=0;j<nsf;j++)
|
SPEEX_COPY(best_exc, exc, nsf);
|
||||||
best_exc[j]=exc[j];
|
SPEEX_COPY(best_target, new_target, nsf);
|
||||||
for (j=0;j<nsf;j++)
|
|
||||||
best_target[j]=new_target[j];
|
|
||||||
best_err=err;
|
best_err=err;
|
||||||
best_pitch=pitch;
|
best_pitch=pitch;
|
||||||
best_gain_index=cdbk_index;
|
best_gain_index=cdbk_index;
|
||||||
|
|
@ -646,10 +642,8 @@ spx_word32_t *cumul_gain
|
||||||
#endif
|
#endif
|
||||||
/*printf ("%f\n", cumul_gain);*/
|
/*printf ("%f\n", cumul_gain);*/
|
||||||
/*printf ("encode pitch: %d %d\n", best_pitch, best_gain_index);*/
|
/*printf ("encode pitch: %d %d\n", best_pitch, best_gain_index);*/
|
||||||
for (i=0;i<nsf;i++)
|
SPEEX_COPY(exc, best_exc, nsf);
|
||||||
exc[i]=best_exc[i];
|
SPEEX_COPY(target, best_target, nsf);
|
||||||
for (i=0;i<nsf;i++)
|
|
||||||
target[i]=best_target[i];
|
|
||||||
#ifdef FIXED_POINT
|
#ifdef FIXED_POINT
|
||||||
/* Scale target back up if needed */
|
/* Scale target back up if needed */
|
||||||
if (scaledown)
|
if (scaledown)
|
||||||
|
|
@ -739,8 +733,7 @@ int cdbk_offset
|
||||||
gain[0] = SHL16(gain[0],7);
|
gain[0] = SHL16(gain[0],7);
|
||||||
gain[1] = SHL16(gain[1],7);
|
gain[1] = SHL16(gain[1],7);
|
||||||
gain[2] = SHL16(gain[2],7);
|
gain[2] = SHL16(gain[2],7);
|
||||||
for (i=0;i<nsf;i++)
|
SPEEX_MEMSET(exc_out, 0, nsf);
|
||||||
exc_out[i]=0;
|
|
||||||
for (i=0;i<3;i++)
|
for (i=0;i<3;i++)
|
||||||
{
|
{
|
||||||
int j;
|
int j;
|
||||||
|
|
|
||||||
|
|
@ -1042,7 +1042,7 @@ void speex_echo_cancellation(SpeexEchoState *st, const spx_int16_t *in, const sp
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* We consider that the filter has had minimal adaptation if the following is true*/
|
/* We consider that the filter has had minimal adaptation if the following is true*/
|
||||||
if (!st->adapted && st->sum_adapt > QCONST32(M,15) && MULT16_32_Q15(st->leak_estimate,Syy) > MULT16_32_Q15(QCONST16(.03f,15),Syy))
|
if (!st->adapted && st->sum_adapt > SHL32(EXTEND32(M),15) && MULT16_32_Q15(st->leak_estimate,Syy) > MULT16_32_Q15(QCONST16(.03f,15),Syy))
|
||||||
{
|
{
|
||||||
st->adapted = 1;
|
st->adapted = 1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -293,8 +293,8 @@ int nb_encode(void *state, void *vin, SpeexBits *bits)
|
||||||
ALLOC(interp_qlpc, st->lpcSize, spx_coef_t);
|
ALLOC(interp_qlpc, st->lpcSize, spx_coef_t);
|
||||||
|
|
||||||
/* Move signals 1 frame towards the past */
|
/* Move signals 1 frame towards the past */
|
||||||
speex_move(st->excBuf, st->excBuf+st->frameSize, (st->max_pitch+2)*sizeof(spx_word16_t));
|
SPEEX_MOVE(st->excBuf, st->excBuf+st->frameSize, st->max_pitch+2);
|
||||||
speex_move(st->swBuf, st->swBuf+st->frameSize, (st->max_pitch+2)*sizeof(spx_word16_t));
|
SPEEX_MOVE(st->swBuf, st->swBuf+st->frameSize, st->max_pitch+2);
|
||||||
|
|
||||||
if (st->highpass_enabled)
|
if (st->highpass_enabled)
|
||||||
highpass(in, in, st->frameSize, (st->isWideband?HIGHPASS_WIDEBAND:HIGHPASS_NARROWBAND)|HIGHPASS_INPUT, st->mem_hp);
|
highpass(in, in, st->frameSize, (st->isWideband?HIGHPASS_WIDEBAND:HIGHPASS_NARROWBAND)|HIGHPASS_INPUT, st->mem_hp);
|
||||||
|
|
@ -337,6 +337,7 @@ int nb_encode(void *state, void *vin, SpeexBits *bits)
|
||||||
|
|
||||||
/* Whole frame analysis (open-loop estimation of pitch and excitation gain) */
|
/* Whole frame analysis (open-loop estimation of pitch and excitation gain) */
|
||||||
{
|
{
|
||||||
|
int diff = st->windowSize-st->frameSize;
|
||||||
if (st->first)
|
if (st->first)
|
||||||
for (i=0;i<st->lpcSize;i++)
|
for (i=0;i<st->lpcSize;i++)
|
||||||
interp_lsp[i] = lsp[i];
|
interp_lsp[i] = lsp[i];
|
||||||
|
|
@ -362,10 +363,8 @@ int nb_encode(void *state, void *vin, SpeexBits *bits)
|
||||||
bw_lpc(st->gamma1, interp_lpc, bw_lpc1, st->lpcSize);
|
bw_lpc(st->gamma1, interp_lpc, bw_lpc1, st->lpcSize);
|
||||||
bw_lpc(st->gamma2, interp_lpc, bw_lpc2, st->lpcSize);
|
bw_lpc(st->gamma2, interp_lpc, bw_lpc2, st->lpcSize);
|
||||||
|
|
||||||
for (i=0;i<st->windowSize-st->frameSize;i++)
|
SPEEX_COPY(st->sw, st->winBuf, diff);
|
||||||
st->sw[i] = st->winBuf[i];
|
SPEEX_COPY(st->sw+diff, in, st->frameSize-diff);
|
||||||
for (;i<st->frameSize;i++)
|
|
||||||
st->sw[i] = in[i-st->windowSize+st->frameSize];
|
|
||||||
filter_mem16(st->sw, bw_lpc1, bw_lpc2, st->sw, st->frameSize, st->lpcSize, st->mem_sw_whole, stack);
|
filter_mem16(st->sw, bw_lpc1, bw_lpc2, st->sw, st->frameSize, st->lpcSize, st->mem_sw_whole, stack);
|
||||||
|
|
||||||
open_loop_nbest_pitch(st->sw, st->min_pitch, st->max_pitch, st->frameSize,
|
open_loop_nbest_pitch(st->sw, st->min_pitch, st->max_pitch, st->frameSize,
|
||||||
|
|
@ -397,10 +396,8 @@ int nb_encode(void *state, void *vin, SpeexBits *bits)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*Compute "real" excitation*/
|
/*Compute "real" excitation*/
|
||||||
for (i=0;i<st->windowSize-st->frameSize;i++)
|
SPEEX_COPY(st->exc, st->winBuf, diff);
|
||||||
st->exc[i] = st->winBuf[i];
|
SPEEX_COPY(st->exc+diff, in, st->frameSize-diff);
|
||||||
for (;i<st->frameSize;i++)
|
|
||||||
st->exc[i] = in[i-st->windowSize+st->frameSize];
|
|
||||||
fir_mem16(st->exc, interp_lpc, st->exc, st->frameSize, st->lpcSize, st->mem_exc, stack);
|
fir_mem16(st->exc, interp_lpc, st->exc, st->frameSize, st->lpcSize, st->mem_exc, stack);
|
||||||
|
|
||||||
/* Compute open-loop excitation gain */
|
/* Compute open-loop excitation gain */
|
||||||
|
|
@ -415,15 +412,12 @@ int nb_encode(void *state, void *vin, SpeexBits *bits)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef VORBIS_PSYCHO
|
#ifdef VORBIS_PSYCHO
|
||||||
for(i=0;i<256-st->frameSize;i++)
|
SPEEX_MOVE(st->psy_window, st->psy_window+st->frameSize, 256-st->frameSize);
|
||||||
st->psy_window[i] = st->psy_window[i+st->frameSize];
|
SPEEX_COPY(&st->psy_window[256-st->frameSize], in, st->frameSize);
|
||||||
for(i=0;i<st->frameSize;i++)
|
|
||||||
st->psy_window[256-st->frameSize+i] = in[i];
|
|
||||||
compute_curve(st->psy, st->psy_window, st->curve);
|
compute_curve(st->psy, st->psy_window, st->curve);
|
||||||
/*print_vec(st->curve, 128, "curve");*/
|
/*print_vec(st->curve, 128, "curve");*/
|
||||||
if (st->first)
|
if (st->first)
|
||||||
for (i=0;i<128;i++)
|
SPEEX_COPY(st->old_curve, st->curve, 128);
|
||||||
st->old_curve[i] = st->curve[i];
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*VBR stuff*/
|
/*VBR stuff*/
|
||||||
|
|
@ -562,7 +556,7 @@ int nb_encode(void *state, void *vin, SpeexBits *bits)
|
||||||
st->first=1;
|
st->first=1;
|
||||||
st->bounded_pitch = 1;
|
st->bounded_pitch = 1;
|
||||||
|
|
||||||
speex_move(st->winBuf, in+2*st->frameSize-st->windowSize, (st->windowSize-st->frameSize)*sizeof(spx_word16_t));
|
SPEEX_COPY(st->winBuf, in+2*st->frameSize-st->windowSize, st->windowSize-st->frameSize);
|
||||||
|
|
||||||
/* Clear memory (no need to really compute it) */
|
/* Clear memory (no need to really compute it) */
|
||||||
for (i=0;i<st->lpcSize;i++)
|
for (i=0;i<st->lpcSize;i++)
|
||||||
|
|
@ -739,8 +733,7 @@ int nb_encode(void *state, void *vin, SpeexBits *bits)
|
||||||
for (i=0;i<st->lpcSize;i++)
|
for (i=0;i<st->lpcSize;i++)
|
||||||
mem[i]=SHL32(st->mem_sw[i],1);
|
mem[i]=SHL32(st->mem_sw[i],1);
|
||||||
filter_mem16(ringing, st->bw_lpc1, st->bw_lpc2, ringing, response_bound, st->lpcSize, mem, stack);
|
filter_mem16(ringing, st->bw_lpc1, st->bw_lpc2, ringing, response_bound, st->lpcSize, mem, stack);
|
||||||
for (i=response_bound;i<st->subframeSize;i++)
|
SPEEX_MEMSET(&ringing[response_bound], 0, st->subframeSize-response_bound);
|
||||||
ringing[i]=0;
|
|
||||||
#else
|
#else
|
||||||
iir_mem16(ringing, interp_qlpc, ringing, st->subframeSize, st->lpcSize, mem, stack);
|
iir_mem16(ringing, interp_qlpc, ringing, st->subframeSize, st->lpcSize, mem, stack);
|
||||||
for (i=0;i<st->lpcSize;i++)
|
for (i=0;i<st->lpcSize;i++)
|
||||||
|
|
@ -762,8 +755,7 @@ int nb_encode(void *state, void *vin, SpeexBits *bits)
|
||||||
target[i]=EXTRACT16(SATURATE(SUB32(sw[i],PSHR32(ringing[i],1)),32767));
|
target[i]=EXTRACT16(SATURATE(SUB32(sw[i],PSHR32(ringing[i],1)),32767));
|
||||||
|
|
||||||
/* Reset excitation */
|
/* Reset excitation */
|
||||||
for (i=0;i<st->subframeSize;i++)
|
SPEEX_MEMSET(exc, 0, st->subframeSize);
|
||||||
exc[i]=0;
|
|
||||||
|
|
||||||
/* If we have a long-term predictor (otherwise, something's wrong) */
|
/* If we have a long-term predictor (otherwise, something's wrong) */
|
||||||
speex_assert (SUBMODE(ltp_quant));
|
speex_assert (SUBMODE(ltp_quant));
|
||||||
|
|
@ -804,8 +796,7 @@ int nb_encode(void *state, void *vin, SpeexBits *bits)
|
||||||
st->pitch[sub]=pitch;
|
st->pitch[sub]=pitch;
|
||||||
}
|
}
|
||||||
/* Quantization of innovation */
|
/* Quantization of innovation */
|
||||||
for (i=0;i<st->subframeSize;i++)
|
SPEEX_MEMSET(innov, 0, st->subframeSize);
|
||||||
innov[i]=0;
|
|
||||||
|
|
||||||
/* FIXME: Make sure this is save from overflows (so far so good) */
|
/* FIXME: Make sure this is save from overflows (so far so good) */
|
||||||
for (i=0;i<st->subframeSize;i++)
|
for (i=0;i<st->subframeSize;i++)
|
||||||
|
|
@ -867,8 +858,7 @@ int nb_encode(void *state, void *vin, SpeexBits *bits)
|
||||||
char *tmp_stack=stack;
|
char *tmp_stack=stack;
|
||||||
VARDECL(spx_sig_t *innov2);
|
VARDECL(spx_sig_t *innov2);
|
||||||
ALLOC(innov2, st->subframeSize, spx_sig_t);
|
ALLOC(innov2, st->subframeSize, spx_sig_t);
|
||||||
for (i=0;i<st->subframeSize;i++)
|
SPEEX_MEMSET(innov2, 0, st->subframeSize);
|
||||||
innov2[i]=0;
|
|
||||||
for (i=0;i<st->subframeSize;i++)
|
for (i=0;i<st->subframeSize;i++)
|
||||||
target[i]=MULT16_16_P13(QCONST16(2.2f,13), target[i]);
|
target[i]=MULT16_16_P13(QCONST16(2.2f,13), target[i]);
|
||||||
SUBMODE(innovation_quant)(target, interp_qlpc, bw_lpc1, bw_lpc2,
|
SUBMODE(innovation_quant)(target, interp_qlpc, bw_lpc1, bw_lpc2,
|
||||||
|
|
@ -887,10 +877,8 @@ int nb_encode(void *state, void *vin, SpeexBits *bits)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=0;i<st->subframeSize;i++)
|
|
||||||
sw[i] = exc[i];
|
|
||||||
/* Final signal synthesis from excitation */
|
/* Final signal synthesis from excitation */
|
||||||
iir_mem16(sw, interp_qlpc, sw, st->subframeSize, st->lpcSize, st->mem_sp, stack);
|
iir_mem16(exc, interp_qlpc, sw, st->subframeSize, st->lpcSize, st->mem_sp, stack);
|
||||||
|
|
||||||
/* Compute weighted signal again, from synthesized speech (not sure it's the right thing) */
|
/* Compute weighted signal again, from synthesized speech (not sure it's the right thing) */
|
||||||
if (st->complexity!=0)
|
if (st->complexity!=0)
|
||||||
|
|
@ -909,10 +897,7 @@ int nb_encode(void *state, void *vin, SpeexBits *bits)
|
||||||
|
|
||||||
#ifdef VORBIS_PSYCHO
|
#ifdef VORBIS_PSYCHO
|
||||||
if (st->submodeID>=1)
|
if (st->submodeID>=1)
|
||||||
{
|
SPEEX_COPY(st->old_curve, st->curve, 128);
|
||||||
for (i=0;i<128;i++)
|
|
||||||
st->old_curve[i] = st->curve[i];
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (st->submodeID==1)
|
if (st->submodeID==1)
|
||||||
|
|
@ -927,7 +912,7 @@ int nb_encode(void *state, void *vin, SpeexBits *bits)
|
||||||
|
|
||||||
/* The next frame will not be the first (Duh!) */
|
/* The next frame will not be the first (Duh!) */
|
||||||
st->first = 0;
|
st->first = 0;
|
||||||
speex_move(st->winBuf, in+2*st->frameSize-st->windowSize, (st->windowSize-st->frameSize)*sizeof(spx_word16_t));
|
SPEEX_COPY(st->winBuf, in+2*st->frameSize-st->windowSize, st->windowSize-st->frameSize);
|
||||||
|
|
||||||
if (SUBMODE(innovation_quant) == noise_codebook_quant || st->submodeID==0)
|
if (SUBMODE(innovation_quant) == noise_codebook_quant || st->submodeID==0)
|
||||||
st->bounded_pitch = 1;
|
st->bounded_pitch = 1;
|
||||||
|
|
@ -980,8 +965,7 @@ void *nb_decoder_init(const SpeexMode *m)
|
||||||
|
|
||||||
/* st->excBuf = (spx_word16_t*)speex_alloc((st->frameSize + 2*st->max_pitch + st->subframeSize + 12)*sizeof(spx_word16_t)); */
|
/* st->excBuf = (spx_word16_t*)speex_alloc((st->frameSize + 2*st->max_pitch + st->subframeSize + 12)*sizeof(spx_word16_t)); */
|
||||||
st->exc = st->excBuf + 2*st->max_pitch + st->subframeSize + 6;
|
st->exc = st->excBuf + 2*st->max_pitch + st->subframeSize + 6;
|
||||||
for (i=0;i<st->frameSize + st->max_pitch + 1;i++)
|
SPEEX_MEMSET(st->excBuf, 0, st->frameSize + st->max_pitch);
|
||||||
st->excBuf[i]=0;
|
|
||||||
|
|
||||||
/* st->interp_qlpc = (spx_coef_t*)speex_alloc(st->lpcSize*sizeof(spx_coef_t)); */
|
/* st->interp_qlpc = (spx_coef_t*)speex_alloc(st->lpcSize*sizeof(spx_coef_t)); */
|
||||||
/* st->old_qlsp = (spx_lsp_t*)speex_alloc(st->lpcSize*sizeof(spx_lsp_t)); */
|
/* st->old_qlsp = (spx_lsp_t*)speex_alloc(st->lpcSize*sizeof(spx_lsp_t)); */
|
||||||
|
|
@ -1079,7 +1063,7 @@ static void nb_decode_lost(DecState *st, spx_word16_t *out, char *stack)
|
||||||
innov_gain = compute_rms16(st->exc, st->frameSize);
|
innov_gain = compute_rms16(st->exc, st->frameSize);
|
||||||
noise_gain = MULT16_16_Q15(innov_gain, MULT16_16_Q15(fact, SUB16(Q15ONE,MULT16_16_Q15(pitch_gain,pitch_gain))));
|
noise_gain = MULT16_16_Q15(innov_gain, MULT16_16_Q15(fact, SUB16(Q15ONE,MULT16_16_Q15(pitch_gain,pitch_gain))));
|
||||||
/* Shift all buffers by one frame */
|
/* Shift all buffers by one frame */
|
||||||
speex_move(st->excBuf, st->excBuf+st->frameSize, (2*st->max_pitch + st->subframeSize + 12)*sizeof(spx_word16_t));
|
SPEEX_MOVE(st->excBuf, st->excBuf+st->frameSize, 2*st->max_pitch + st->subframeSize + 12);
|
||||||
|
|
||||||
|
|
||||||
pitch_val = st->last_pitch + SHR32((spx_int32_t)speex_rand(1+st->count_lost, &st->seed),SIG_SHIFT);
|
pitch_val = st->last_pitch + SHR32((spx_int32_t)speex_rand(1+st->count_lost, &st->seed),SIG_SHIFT);
|
||||||
|
|
@ -1094,8 +1078,8 @@ static void nb_decode_lost(DecState *st, spx_word16_t *out, char *stack)
|
||||||
}
|
}
|
||||||
|
|
||||||
bw_lpc(QCONST16(.98,15), st->interp_qlpc, st->interp_qlpc, st->lpcSize);
|
bw_lpc(QCONST16(.98,15), st->interp_qlpc, st->interp_qlpc, st->lpcSize);
|
||||||
iir_mem16(&st->exc[-st->subframeSize], st->interp_qlpc, out,
|
iir_mem16(&st->exc[-st->subframeSize], st->interp_qlpc, out, st->frameSize,
|
||||||
st->frameSize, st->lpcSize, st->mem_sp, stack);
|
st->lpcSize, st->mem_sp, stack);
|
||||||
highpass(out, out, st->frameSize, HIGHPASS_NARROWBAND|HIGHPASS_OUTPUT, st->mem_hp);
|
highpass(out, out, st->frameSize, HIGHPASS_NARROWBAND|HIGHPASS_OUTPUT, st->mem_hp);
|
||||||
|
|
||||||
st->first = 0;
|
st->first = 0;
|
||||||
|
|
@ -1229,7 +1213,7 @@ int nb_decode(void *state, SpeexBits *bits, void *vout)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Shift all buffers by one frame */
|
/* Shift all buffers by one frame */
|
||||||
speex_move(st->excBuf, st->excBuf+st->frameSize, (2*st->max_pitch + st->subframeSize + 12)*sizeof(spx_word16_t));
|
SPEEX_MOVE(st->excBuf, st->excBuf+st->frameSize, 2*st->max_pitch + st->subframeSize + 12);
|
||||||
|
|
||||||
/* If null mode (no transmission), just set a couple things to zero*/
|
/* If null mode (no transmission), just set a couple things to zero*/
|
||||||
if (st->submodes[st->submodeID] == NULL)
|
if (st->submodes[st->submodeID] == NULL)
|
||||||
|
|
@ -1346,8 +1330,7 @@ int nb_decode(void *state, SpeexBits *bits, void *vout)
|
||||||
|
|
||||||
|
|
||||||
/* Reset excitation */
|
/* Reset excitation */
|
||||||
for (i=0;i<st->subframeSize;i++)
|
SPEEX_MEMSET(exc, 0, st->subframeSize);
|
||||||
exc[i]=0;
|
|
||||||
|
|
||||||
/*Adaptive codebook contribution*/
|
/*Adaptive codebook contribution*/
|
||||||
speex_assert (SUBMODE(ltp_unquant));
|
speex_assert (SUBMODE(ltp_unquant));
|
||||||
|
|
@ -1411,8 +1394,7 @@ int nb_decode(void *state, SpeexBits *bits, void *vout)
|
||||||
int q_energy;
|
int q_energy;
|
||||||
spx_word32_t ener;
|
spx_word32_t ener;
|
||||||
|
|
||||||
for (i=0;i<st->subframeSize;i++)
|
SPEEX_MEMSET(innov, 0, st->subframeSize);
|
||||||
innov[i]=0;
|
|
||||||
|
|
||||||
/* Decode sub-frame gain correction */
|
/* Decode sub-frame gain correction */
|
||||||
if (SUBMODE(have_subframe_gain)==3)
|
if (SUBMODE(have_subframe_gain)==3)
|
||||||
|
|
@ -1441,8 +1423,7 @@ int nb_decode(void *state, SpeexBits *bits, void *vout)
|
||||||
char *tmp_stack=stack;
|
char *tmp_stack=stack;
|
||||||
VARDECL(spx_sig_t *innov2);
|
VARDECL(spx_sig_t *innov2);
|
||||||
ALLOC(innov2, st->subframeSize, spx_sig_t);
|
ALLOC(innov2, st->subframeSize, spx_sig_t);
|
||||||
for (i=0;i<st->subframeSize;i++)
|
SPEEX_MEMSET(innov2, 0, st->subframeSize);
|
||||||
innov2[i]=0;
|
|
||||||
SUBMODE(innovation_unquant)(innov2, SUBMODE(innovation_params), st->subframeSize, bits, stack, &st->seed);
|
SUBMODE(innovation_unquant)(innov2, SUBMODE(innovation_params), st->subframeSize, bits, stack, &st->seed);
|
||||||
signal_mul(innov2, innov2, MULT16_32_Q15(QCONST16(0.454545f,15),ener), st->subframeSize);
|
signal_mul(innov2, innov2, MULT16_32_Q15(QCONST16(0.454545f,15),ener), st->subframeSize);
|
||||||
for (i=0;i<st->subframeSize;i++)
|
for (i=0;i<st->subframeSize;i++)
|
||||||
|
|
@ -1469,8 +1450,7 @@ int nb_decode(void *state, SpeexBits *bits, void *vout)
|
||||||
if (g>GAIN_SCALING)
|
if (g>GAIN_SCALING)
|
||||||
g=GAIN_SCALING;
|
g=GAIN_SCALING;
|
||||||
|
|
||||||
for (i=0;i<st->subframeSize;i++)
|
SPEEX_MEMSET(exc, 0, st->subframeSize);
|
||||||
exc[i]=0;
|
|
||||||
while (st->voc_offset<st->subframeSize)
|
while (st->voc_offset<st->subframeSize)
|
||||||
{
|
{
|
||||||
/* exc[st->voc_offset]= g*sqrt(2*ol_pitch)*ol_gain;
|
/* exc[st->voc_offset]= g*sqrt(2*ol_pitch)*ol_gain;
|
||||||
|
|
@ -1505,8 +1485,7 @@ int nb_decode(void *state, SpeexBits *bits, void *vout)
|
||||||
multicomb(st->exc-st->subframeSize, out, st->interp_qlpc, st->lpcSize, 2*st->subframeSize, best_pitch, 40, SUBMODE(comb_gain), stack);
|
multicomb(st->exc-st->subframeSize, out, st->interp_qlpc, st->lpcSize, 2*st->subframeSize, best_pitch, 40, SUBMODE(comb_gain), stack);
|
||||||
multicomb(st->exc+st->subframeSize, out+2*st->subframeSize, st->interp_qlpc, st->lpcSize, 2*st->subframeSize, best_pitch, 40, SUBMODE(comb_gain), stack);
|
multicomb(st->exc+st->subframeSize, out+2*st->subframeSize, st->interp_qlpc, st->lpcSize, 2*st->subframeSize, best_pitch, 40, SUBMODE(comb_gain), stack);
|
||||||
} else {
|
} else {
|
||||||
for (i=0;i<st->frameSize;i++)
|
SPEEX_COPY(out, &st->exc[-st->subframeSize], st->frameSize);
|
||||||
out[i]=st->exc[i-st->subframeSize];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If the last packet was lost, re-scale the excitation to obtain the same energy as encoded in ol_gain */
|
/* If the last packet was lost, re-scale the excitation to obtain the same energy as encoded in ol_gain */
|
||||||
|
|
|
||||||
|
|
@ -86,20 +86,20 @@ static inline void speex_free_scratch (void *ptr)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** Print warning message with integer argument to stderr */
|
/** Copy n bytes of memory from src to dst. The 0* term provides compile-time type checking */
|
||||||
#ifndef OVERRIDE_SPEEX_MOVE
|
#ifndef OVERRIDE_SPEEX_COPY
|
||||||
static inline void *speex_move (void *dest, void *src, int n)
|
#define SPEEX_COPY(dst, src, n) (memcpy((dst), (src), (n)*sizeof(*(dst)) + 0*((dst)-(src)) ))
|
||||||
{
|
|
||||||
return memmove(dest,src,n);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** Print warning message with integer argument to stderr */
|
/** Copy n bytes of memory from src to dst, allowing overlapping regions. The 0* term
|
||||||
|
provides compile-time type checking */
|
||||||
#ifndef OVERRIDE_SPEEX_MOVE
|
#ifndef OVERRIDE_SPEEX_MOVE
|
||||||
static inline void *speex_memset (void *s, int c, int n)
|
#define SPEEX_MOVE(dst, src, n) (memmove((dst), (src), (n)*sizeof(*(dst)) + 0*((dst)-(src)) ))
|
||||||
{
|
#endif
|
||||||
return memset(s,c,n);
|
|
||||||
}
|
/** Set n bytes of memory to value of c, starting at address s */
|
||||||
|
#ifndef OVERRIDE_SPEEX_MEMSET
|
||||||
|
#define SPEEX_MEMSET(dst, c, n) (memset((dst), (c), (n)*sizeof(*(dst))))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -337,11 +337,14 @@ static int resampler_basic_direct_single(SpeexResamplerState *st, spx_uint32_t c
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Do the new part */
|
/* Do the new part */
|
||||||
ptr = in+st->in_stride*(last_sample-N+1+j);
|
if (in != NULL)
|
||||||
for (;j<N;j++)
|
|
||||||
{
|
{
|
||||||
sum += MULT16_16(*ptr,st->sinc_table[samp_frac_num*st->filt_len+j]);
|
ptr = in+st->in_stride*(last_sample-N+1+j);
|
||||||
ptr += st->in_stride;
|
for (;j<N;j++)
|
||||||
|
{
|
||||||
|
sum += MULT16_16(*ptr,st->sinc_table[samp_frac_num*st->filt_len+j]);
|
||||||
|
ptr += st->in_stride;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*out = PSHR32(sum,15);
|
*out = PSHR32(sum,15);
|
||||||
|
|
@ -385,11 +388,14 @@ static int resampler_basic_direct_double(SpeexResamplerState *st, spx_uint32_t c
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Do the new part */
|
/* Do the new part */
|
||||||
ptr = in+st->in_stride*(last_sample-N+1+j);
|
if (in != NULL)
|
||||||
for (;j<N;j++)
|
|
||||||
{
|
{
|
||||||
sum += MULT16_16(*ptr,(double)st->sinc_table[samp_frac_num*st->filt_len+j]);
|
ptr = in+st->in_stride*(last_sample-N+1+j);
|
||||||
ptr += st->in_stride;
|
for (;j<N;j++)
|
||||||
|
{
|
||||||
|
sum += MULT16_16(*ptr,(double)st->sinc_table[samp_frac_num*st->filt_len+j]);
|
||||||
|
ptr += st->in_stride;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*out = sum;
|
*out = sum;
|
||||||
|
|
@ -445,16 +451,20 @@ static int resampler_basic_interpolate_single(SpeexResamplerState *st, spx_uint3
|
||||||
accum[2] += MULT16_16(curr_mem,st->sinc_table[4+(j+1)*st->oversample-offset]);
|
accum[2] += MULT16_16(curr_mem,st->sinc_table[4+(j+1)*st->oversample-offset]);
|
||||||
accum[3] += MULT16_16(curr_mem,st->sinc_table[4+(j+1)*st->oversample-offset+1]);
|
accum[3] += MULT16_16(curr_mem,st->sinc_table[4+(j+1)*st->oversample-offset+1]);
|
||||||
}
|
}
|
||||||
ptr = in+st->in_stride*(last_sample-N+1+j);
|
|
||||||
/* Do the new part */
|
if (in != NULL)
|
||||||
for (;j<N;j++)
|
|
||||||
{
|
{
|
||||||
spx_word16_t curr_in = *ptr;
|
ptr = in+st->in_stride*(last_sample-N+1+j);
|
||||||
ptr += st->in_stride;
|
/* Do the new part */
|
||||||
accum[0] += MULT16_16(curr_in,st->sinc_table[4+(j+1)*st->oversample-offset-2]);
|
for (;j<N;j++)
|
||||||
accum[1] += MULT16_16(curr_in,st->sinc_table[4+(j+1)*st->oversample-offset-1]);
|
{
|
||||||
accum[2] += MULT16_16(curr_in,st->sinc_table[4+(j+1)*st->oversample-offset]);
|
spx_word16_t curr_in = *ptr;
|
||||||
accum[3] += MULT16_16(curr_in,st->sinc_table[4+(j+1)*st->oversample-offset+1]);
|
ptr += st->in_stride;
|
||||||
|
accum[0] += MULT16_16(curr_in,st->sinc_table[4+(j+1)*st->oversample-offset-2]);
|
||||||
|
accum[1] += MULT16_16(curr_in,st->sinc_table[4+(j+1)*st->oversample-offset-1]);
|
||||||
|
accum[2] += MULT16_16(curr_in,st->sinc_table[4+(j+1)*st->oversample-offset]);
|
||||||
|
accum[3] += MULT16_16(curr_in,st->sinc_table[4+(j+1)*st->oversample-offset+1]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
cubic_coef(frac, interp);
|
cubic_coef(frac, interp);
|
||||||
sum = MULT16_32_Q15(interp[0],accum[0]) + MULT16_32_Q15(interp[1],accum[1]) + MULT16_32_Q15(interp[2],accum[2]) + MULT16_32_Q15(interp[3],accum[3]);
|
sum = MULT16_32_Q15(interp[0],accum[0]) + MULT16_32_Q15(interp[1],accum[1]) + MULT16_32_Q15(interp[2],accum[2]) + MULT16_32_Q15(interp[3],accum[3]);
|
||||||
|
|
@ -509,16 +519,19 @@ static int resampler_basic_interpolate_double(SpeexResamplerState *st, spx_uint3
|
||||||
accum[2] += MULT16_16(curr_mem,st->sinc_table[4+(j+1)*st->oversample-offset]);
|
accum[2] += MULT16_16(curr_mem,st->sinc_table[4+(j+1)*st->oversample-offset]);
|
||||||
accum[3] += MULT16_16(curr_mem,st->sinc_table[4+(j+1)*st->oversample-offset+1]);
|
accum[3] += MULT16_16(curr_mem,st->sinc_table[4+(j+1)*st->oversample-offset+1]);
|
||||||
}
|
}
|
||||||
ptr = in+st->in_stride*(last_sample-N+1+j);
|
if (in != NULL)
|
||||||
/* Do the new part */
|
|
||||||
for (;j<N;j++)
|
|
||||||
{
|
{
|
||||||
double curr_in = *ptr;
|
ptr = in+st->in_stride*(last_sample-N+1+j);
|
||||||
ptr += st->in_stride;
|
/* Do the new part */
|
||||||
accum[0] += MULT16_16(curr_in,st->sinc_table[4+(j+1)*st->oversample-offset-2]);
|
for (;j<N;j++)
|
||||||
accum[1] += MULT16_16(curr_in,st->sinc_table[4+(j+1)*st->oversample-offset-1]);
|
{
|
||||||
accum[2] += MULT16_16(curr_in,st->sinc_table[4+(j+1)*st->oversample-offset]);
|
double curr_in = *ptr;
|
||||||
accum[3] += MULT16_16(curr_in,st->sinc_table[4+(j+1)*st->oversample-offset+1]);
|
ptr += st->in_stride;
|
||||||
|
accum[0] += MULT16_16(curr_in,st->sinc_table[4+(j+1)*st->oversample-offset-2]);
|
||||||
|
accum[1] += MULT16_16(curr_in,st->sinc_table[4+(j+1)*st->oversample-offset-1]);
|
||||||
|
accum[2] += MULT16_16(curr_in,st->sinc_table[4+(j+1)*st->oversample-offset]);
|
||||||
|
accum[3] += MULT16_16(curr_in,st->sinc_table[4+(j+1)*st->oversample-offset+1]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
cubic_coef(frac, interp);
|
cubic_coef(frac, interp);
|
||||||
sum = interp[0]*accum[0] + interp[1]*accum[1] + interp[2]*accum[2] + interp[3]*accum[3];
|
sum = interp[0]*accum[0] + interp[1]*accum[1] + interp[2]*accum[2] + interp[3]*accum[3];
|
||||||
|
|
@ -966,7 +979,10 @@ int speex_resampler_process_interleaved_float(SpeexResamplerState *st, const flo
|
||||||
for (i=0;i<st->nb_channels;i++)
|
for (i=0;i<st->nb_channels;i++)
|
||||||
{
|
{
|
||||||
*out_len = bak_len;
|
*out_len = bak_len;
|
||||||
speex_resampler_process_float(st, i, in+i, in_len, out+i, out_len);
|
if (in != NULL)
|
||||||
|
speex_resampler_process_float(st, i, in+i, in_len, out+i, out_len);
|
||||||
|
else
|
||||||
|
speex_resampler_process_float(st, i, NULL, in_len, out+i, out_len);
|
||||||
}
|
}
|
||||||
st->in_stride = istride_save;
|
st->in_stride = istride_save;
|
||||||
st->out_stride = ostride_save;
|
st->out_stride = ostride_save;
|
||||||
|
|
@ -985,7 +1001,10 @@ int speex_resampler_process_interleaved_int(SpeexResamplerState *st, const spx_i
|
||||||
for (i=0;i<st->nb_channels;i++)
|
for (i=0;i<st->nb_channels;i++)
|
||||||
{
|
{
|
||||||
*out_len = bak_len;
|
*out_len = bak_len;
|
||||||
speex_resampler_process_int(st, i, in+i, in_len, out+i, out_len);
|
if (in != NULL)
|
||||||
|
speex_resampler_process_int(st, i, in+i, in_len, out+i, out_len);
|
||||||
|
else
|
||||||
|
speex_resampler_process_int(st, i, NULL, in_len, out+i, out_len);
|
||||||
}
|
}
|
||||||
st->in_stride = istride_save;
|
st->in_stride = istride_save;
|
||||||
st->out_stride = ostride_save;
|
st->out_stride = ostride_save;
|
||||||
|
|
|
||||||
|
|
@ -70,12 +70,6 @@ static inline void speex_free_scratch (void *ptr)
|
||||||
codec_free(ptr);
|
codec_free(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define OVERRIDE_SPEEX_MOVE 1
|
|
||||||
static inline void *speex_move (void *dest, void *src, int n)
|
|
||||||
{
|
|
||||||
return memmove(dest,src,n);
|
|
||||||
}
|
|
||||||
|
|
||||||
#define OVERRIDE_SPEEX_FATAL 1
|
#define OVERRIDE_SPEEX_FATAL 1
|
||||||
static inline void _speex_fatal(const char *str, const char *file, int line)
|
static inline void _speex_fatal(const char *str, const char *file, int line)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -354,10 +354,8 @@ int sb_encode(void *state, void *vin, SpeexBits *bits)
|
||||||
speex_encode_native(st->st_low, low, bits);
|
speex_encode_native(st->st_low, low, bits);
|
||||||
|
|
||||||
high = high - (st->windowSize-st->frame_size);
|
high = high - (st->windowSize-st->frame_size);
|
||||||
for (i=0;i<st->windowSize-st->frame_size;i++)
|
SPEEX_COPY(high, st->high, st->windowSize-st->frame_size);
|
||||||
high[i] = st->high[i];
|
SPEEX_COPY(st->high, &high[st->frame_size], st->windowSize-st->frame_size);
|
||||||
for (i=0;i<st->windowSize-st->frame_size;i++)
|
|
||||||
st->high[i] = high[i+st->frame_size];
|
|
||||||
|
|
||||||
|
|
||||||
ALLOC(low_pi_gain, st->nbSubframes, spx_word32_t);
|
ALLOC(low_pi_gain, st->nbSubframes, spx_word32_t);
|
||||||
|
|
@ -690,8 +688,7 @@ int sb_encode(void *state, void *vin, SpeexBits *bits)
|
||||||
signal_div(target, target, scale, st->subframeSize);
|
signal_div(target, target, scale, st->subframeSize);
|
||||||
|
|
||||||
/* Reset excitation */
|
/* Reset excitation */
|
||||||
for (i=0;i<st->subframeSize;i++)
|
SPEEX_MEMSET(innov, 0, st->subframeSize);
|
||||||
innov[i]=0;
|
|
||||||
|
|
||||||
/*print_vec(target, st->subframeSize, "\ntarget");*/
|
/*print_vec(target, st->subframeSize, "\ntarget");*/
|
||||||
SUBMODE(innovation_quant)(target, st->interp_qlpc, bw_lpc1, bw_lpc2,
|
SUBMODE(innovation_quant)(target, st->interp_qlpc, bw_lpc1, bw_lpc2,
|
||||||
|
|
@ -705,8 +702,7 @@ int sb_encode(void *state, void *vin, SpeexBits *bits)
|
||||||
char *tmp_stack=stack;
|
char *tmp_stack=stack;
|
||||||
VARDECL(spx_sig_t *innov2);
|
VARDECL(spx_sig_t *innov2);
|
||||||
ALLOC(innov2, st->subframeSize, spx_sig_t);
|
ALLOC(innov2, st->subframeSize, spx_sig_t);
|
||||||
for (i=0;i<st->subframeSize;i++)
|
SPEEX_MEMSET(innov2, 0, st->subframeSize);
|
||||||
innov2[i]=0;
|
|
||||||
for (i=0;i<st->subframeSize;i++)
|
for (i=0;i<st->subframeSize;i++)
|
||||||
target[i]=MULT16_16_P13(QCONST16(2.5f,13), target[i]);
|
target[i]=MULT16_16_P13(QCONST16(2.5f,13), target[i]);
|
||||||
|
|
||||||
|
|
@ -1018,8 +1014,7 @@ int sb_decode(void *state, SpeexBits *bits, void *vout)
|
||||||
if (st->innov_save)
|
if (st->innov_save)
|
||||||
{
|
{
|
||||||
innov_save = st->innov_save+2*offset;
|
innov_save = st->innov_save+2*offset;
|
||||||
for (i=0;i<2*st->subframeSize;i++)
|
SPEEX_MEMSET(innov_save, 0, 2*st->subframeSize);
|
||||||
innov_save[i]=0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* LSP interpolation */
|
/* LSP interpolation */
|
||||||
|
|
@ -1048,8 +1043,7 @@ int sb_decode(void *state, SpeexBits *bits, void *vout)
|
||||||
filter_ratio=(rl+.01)/(rh+.01);
|
filter_ratio=(rl+.01)/(rh+.01);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (i=0;i<st->subframeSize;i++)
|
SPEEX_MEMSET(exc, 0, st->subframeSize);
|
||||||
exc[i]=0;
|
|
||||||
if (!SUBMODE(innovation_unquant))
|
if (!SUBMODE(innovation_unquant))
|
||||||
{
|
{
|
||||||
spx_word32_t g;
|
spx_word32_t g;
|
||||||
|
|
@ -1087,8 +1081,7 @@ int sb_decode(void *state, SpeexBits *bits, void *vout)
|
||||||
char *tmp_stack=stack;
|
char *tmp_stack=stack;
|
||||||
VARDECL(spx_sig_t *innov2);
|
VARDECL(spx_sig_t *innov2);
|
||||||
ALLOC(innov2, st->subframeSize, spx_sig_t);
|
ALLOC(innov2, st->subframeSize, spx_sig_t);
|
||||||
for (i=0;i<st->subframeSize;i++)
|
SPEEX_MEMSET(innov2, 0, st->subframeSize);
|
||||||
innov2[i]=0;
|
|
||||||
SUBMODE(innovation_unquant)(innov2, SUBMODE(innovation_params), st->subframeSize,
|
SUBMODE(innovation_unquant)(innov2, SUBMODE(innovation_params), st->subframeSize,
|
||||||
bits, stack, &st->seed);
|
bits, stack, &st->seed);
|
||||||
signal_mul(innov2, innov2, MULT16_32_P15(QCONST16(0.4f,15),scale), st->subframeSize);
|
signal_mul(innov2, innov2, MULT16_32_P15(QCONST16(0.4f,15),scale), st->subframeSize);
|
||||||
|
|
|
||||||
|
|
@ -63,16 +63,15 @@ struct _JitterBufferPacket {
|
||||||
spx_uint32_t timestamp; /**< Timestamp for the packet */
|
spx_uint32_t timestamp; /**< Timestamp for the packet */
|
||||||
spx_uint32_t span; /**< Time covered by the packet (same units as timestamp) */
|
spx_uint32_t span; /**< Time covered by the packet (same units as timestamp) */
|
||||||
spx_uint16_t sequence; /**< RTP Sequence number if available (0 otherwise) */
|
spx_uint16_t sequence; /**< RTP Sequence number if available (0 otherwise) */
|
||||||
spx_uint16_t flags; /**< Info about the returned packet */
|
|
||||||
spx_uint32_t user_data; /**< Put whatever data you like here (it's ignored by the jitter buffer) */
|
spx_uint32_t user_data; /**< Put whatever data you like here (it's ignored by the jitter buffer) */
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Packet has been retrieved */
|
/** Packet has been retrieved */
|
||||||
#define JITTER_BUFFER_OK 0
|
#define JITTER_BUFFER_OK 0
|
||||||
/** Packet is missing */
|
/** Packet is lost or is late */
|
||||||
#define JITTER_BUFFER_MISSING 1
|
#define JITTER_BUFFER_MISSING 1
|
||||||
/** Packet is incomplete (does not cover the entire tick */
|
/** A "fake" packet is meant to be inserted here to increase buffering */
|
||||||
#define JITTER_BUFFER_INCOMPLETE 2
|
#define JITTER_BUFFER_INSERTION 2
|
||||||
/** There was an error in the jitter buffer */
|
/** There was an error in the jitter buffer */
|
||||||
#define JITTER_BUFFER_INTERNAL_ERROR -1
|
#define JITTER_BUFFER_INTERNAL_ERROR -1
|
||||||
/** Invalid argument */
|
/** Invalid argument */
|
||||||
|
|
@ -117,10 +116,12 @@ struct _JitterBufferPacket {
|
||||||
|
|
||||||
/** Initialises jitter buffer
|
/** Initialises jitter buffer
|
||||||
*
|
*
|
||||||
* @param tick Number of samples per "tick", i.e. the time period of the elements that will be retrieved
|
* @param step_size Starting value for the size of concleanment packets and delay
|
||||||
|
adjustment steps. Can be changed at any time using JITTER_BUFFER_SET_DELAY_STEP
|
||||||
|
and JITTER_BUFFER_GET_CONCEALMENT_SIZE.
|
||||||
* @return Newly created jitter buffer state
|
* @return Newly created jitter buffer state
|
||||||
*/
|
*/
|
||||||
JitterBuffer *jitter_buffer_init(void);
|
JitterBuffer *jitter_buffer_init(int step_size);
|
||||||
|
|
||||||
/** Restores jitter buffer to its original state
|
/** Restores jitter buffer to its original state
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -126,7 +126,7 @@ char *speex_header_to_packet(SpeexHeader *header, int *size)
|
||||||
SpeexHeader *le_header;
|
SpeexHeader *le_header;
|
||||||
le_header = (SpeexHeader*)speex_alloc(sizeof(SpeexHeader));
|
le_header = (SpeexHeader*)speex_alloc(sizeof(SpeexHeader));
|
||||||
|
|
||||||
speex_move(le_header, header, sizeof(SpeexHeader));
|
SPEEX_COPY(le_header, header, 1);
|
||||||
|
|
||||||
/*Make sure everything is now little-endian*/
|
/*Make sure everything is now little-endian*/
|
||||||
ENDIAN_SWITCH(le_header->speex_version_id);
|
ENDIAN_SWITCH(le_header->speex_version_id);
|
||||||
|
|
@ -168,7 +168,7 @@ SpeexHeader *speex_packet_to_header(char *packet, int size)
|
||||||
|
|
||||||
/* le_header = (SpeexHeader*)speex_alloc(sizeof(SpeexHeader)); */
|
/* le_header = (SpeexHeader*)speex_alloc(sizeof(SpeexHeader)); */
|
||||||
|
|
||||||
speex_move(le_header, packet, sizeof(SpeexHeader));
|
SPEEX_COPY(le_header, (SpeexHeader*)packet, 1);
|
||||||
|
|
||||||
/*Make sure everything is converted correctly from little-endian*/
|
/*Make sure everything is converted correctly from little-endian*/
|
||||||
ENDIAN_SWITCH(le_header->speex_version_id);
|
ENDIAN_SWITCH(le_header->speex_version_id);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue