[asterisk-commits] qwell: trunk r150729 - in /trunk: codecs/ include/asterisk/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Oct 17 16:35:24 CDT 2008
Author: qwell
Date: Fri Oct 17 16:35:23 2008
New Revision: 150729
URL: http://svn.digium.com/view/asterisk?view=rev&rev=150729
Log:
Merge codec_consistency branch. This should make sample usage much happier.
Added:
trunk/codecs/ex_adpcm.h
- copied unchanged from r150728, team/qwell/codec_consistency_fix/codecs/ex_adpcm.h
trunk/codecs/ex_alaw.h
- copied unchanged from r150728, team/qwell/codec_consistency_fix/codecs/ex_alaw.h
trunk/codecs/ex_g722.h
- copied unchanged from r150728, team/qwell/codec_consistency_fix/codecs/ex_g722.h
trunk/codecs/ex_g726.h
- copied unchanged from r150728, team/qwell/codec_consistency_fix/codecs/ex_g726.h
trunk/codecs/ex_gsm.h
- copied unchanged from r150728, team/qwell/codec_consistency_fix/codecs/ex_gsm.h
trunk/codecs/ex_ilbc.h
- copied unchanged from r150728, team/qwell/codec_consistency_fix/codecs/ex_ilbc.h
trunk/codecs/ex_lpc10.h
- copied unchanged from r150728, team/qwell/codec_consistency_fix/codecs/ex_lpc10.h
trunk/codecs/ex_speex.h
- copied unchanged from r150728, team/qwell/codec_consistency_fix/codecs/ex_speex.h
trunk/codecs/ex_ulaw.h
- copied unchanged from r150728, team/qwell/codec_consistency_fix/codecs/ex_ulaw.h
trunk/include/asterisk/slin.h
- copied unchanged from r150728, team/qwell/codec_consistency_fix/include/asterisk/slin.h
Removed:
trunk/codecs/adpcm_slin_ex.h
trunk/codecs/g722_slin_ex.h
trunk/codecs/g726_slin_ex.h
trunk/codecs/gsm_slin_ex.h
trunk/codecs/ilbc_slin_ex.h
trunk/codecs/lpc10_slin_ex.h
trunk/codecs/slin_adpcm_ex.h
trunk/codecs/slin_g722_ex.h
trunk/codecs/slin_g726_ex.h
trunk/codecs/slin_gsm_ex.h
trunk/codecs/slin_ilbc_ex.h
trunk/codecs/slin_lpc10_ex.h
trunk/codecs/slin_resample_ex.h
trunk/codecs/slin_speex_ex.h
trunk/codecs/slin_ulaw_ex.h
trunk/codecs/speex_slin_ex.h
trunk/codecs/ulaw_slin_ex.h
Modified:
trunk/codecs/codec_a_mu.c
trunk/codecs/codec_adpcm.c
trunk/codecs/codec_alaw.c
trunk/codecs/codec_g722.c
trunk/codecs/codec_g726.c
trunk/codecs/codec_gsm.c
trunk/codecs/codec_ilbc.c
trunk/codecs/codec_lpc10.c
trunk/codecs/codec_resample.c
trunk/codecs/codec_speex.c
trunk/codecs/codec_ulaw.c
Modified: trunk/codecs/codec_a_mu.c
URL: http://svn.digium.com/view/asterisk/trunk/codecs/codec_a_mu.c?view=diff&rev=150729&r1=150728&r2=150729
==============================================================================
--- trunk/codecs/codec_a_mu.c (original)
+++ trunk/codecs/codec_a_mu.c Fri Oct 17 16:35:23 2008
@@ -38,9 +38,9 @@
static unsigned char mu2a[256];
static unsigned char a2mu[256];
-/* Sample frame data (Mu data is okay) */
-
-#include "ulaw_slin_ex.h"
+/* Sample frame data */
+#include "ex_ulaw.h"
+#include "ex_alaw.h"
/*! \brief convert frame data and store into the buffer */
static int alawtoulaw_framein(struct ast_trans_pvt *pvt, struct ast_frame *f)
@@ -74,43 +74,12 @@
return 0;
}
-/*
- * alawToLin_Sample. Just random data, somehow...
- */
-static struct ast_frame *alawtoulaw_sample(void)
-{
- static struct ast_frame f;
- f.frametype = AST_FRAME_VOICE;
- f.subclass = AST_FORMAT_ALAW;
- f.datalen = sizeof(ulaw_slin_ex);
- f.samples = sizeof(ulaw_slin_ex);
- f.mallocd = 0;
- f.offset = 0;
- f.src = __PRETTY_FUNCTION__;
- f.data.ptr = ulaw_slin_ex; /* XXX what ? */
- return &f;
-}
-
-static struct ast_frame *ulawtoalaw_sample(void)
-{
- static struct ast_frame f;
- f.frametype = AST_FRAME_VOICE;
- f.subclass = AST_FORMAT_ULAW;
- f.datalen = sizeof(ulaw_slin_ex);
- f.samples = sizeof(ulaw_slin_ex);
- f.mallocd = 0;
- f.offset = 0;
- f.src = __PRETTY_FUNCTION__;
- f.data.ptr = ulaw_slin_ex;
- return &f;
-}
-
static struct ast_translator alawtoulaw = {
.name = "alawtoulaw",
.srcfmt = AST_FORMAT_ALAW,
.dstfmt = AST_FORMAT_ULAW,
.framein = alawtoulaw_framein,
- .sample = alawtoulaw_sample,
+ .sample = alaw_sample,
.buffer_samples = BUFFER_SAMPLES,
.buf_size = BUFFER_SAMPLES,
};
@@ -120,7 +89,7 @@
.srcfmt = AST_FORMAT_ULAW,
.dstfmt = AST_FORMAT_ALAW,
.framein = ulawtoalaw_framein,
- .sample = ulawtoalaw_sample,
+ .sample = ulaw_sample,
.buffer_samples = BUFFER_SAMPLES,
.buf_size = BUFFER_SAMPLES,
};
Modified: trunk/codecs/codec_adpcm.c
URL: http://svn.digium.com/view/asterisk/trunk/codecs/codec_adpcm.c?view=diff&rev=150729&r1=150728&r2=150729
==============================================================================
--- trunk/codecs/codec_adpcm.c (original)
+++ trunk/codecs/codec_adpcm.c Fri Oct 17 16:35:23 2008
@@ -44,9 +44,8 @@
#define BUFFER_SAMPLES 8096 /* size for the translation buffers */
/* Sample frame data */
-
-#include "slin_adpcm_ex.h"
-#include "adpcm_slin_ex.h"
+#include "asterisk/slin.h"
+#include "ex_adpcm.h"
/*
* Step size index shift table
@@ -285,43 +284,12 @@
}
-/*! \brief AdpcmToLin_Sample */
-static struct ast_frame *adpcmtolin_sample(void)
-{
- static struct ast_frame f;
- f.frametype = AST_FRAME_VOICE;
- f.subclass = AST_FORMAT_ADPCM;
- f.datalen = sizeof(adpcm_slin_ex);
- f.samples = sizeof(adpcm_slin_ex) * 2;
- f.mallocd = 0;
- f.offset = 0;
- f.src = __PRETTY_FUNCTION__;
- f.data.ptr = adpcm_slin_ex;
- return &f;
-}
-
-/*! \brief LinToAdpcm_Sample */
-static struct ast_frame *lintoadpcm_sample(void)
-{
- static struct ast_frame f;
- f.frametype = AST_FRAME_VOICE;
- f.subclass = AST_FORMAT_SLINEAR;
- f.datalen = sizeof(slin_adpcm_ex);
- /* Assume 8000 Hz */
- f.samples = sizeof(slin_adpcm_ex) / 2;
- f.mallocd = 0;
- f.offset = 0;
- f.src = __PRETTY_FUNCTION__;
- f.data.ptr = slin_adpcm_ex;
- return &f;
-}
-
static struct ast_translator adpcmtolin = {
.name = "adpcmtolin",
.srcfmt = AST_FORMAT_ADPCM,
.dstfmt = AST_FORMAT_SLINEAR,
.framein = adpcmtolin_framein,
- .sample = adpcmtolin_sample,
+ .sample = adpcm_sample,
.desc_size = sizeof(struct adpcm_decoder_pvt),
.buffer_samples = BUFFER_SAMPLES,
.buf_size = BUFFER_SAMPLES * 2,
@@ -334,7 +302,7 @@
.dstfmt = AST_FORMAT_ADPCM,
.framein = lintoadpcm_framein,
.frameout = lintoadpcm_frameout,
- .sample = lintoadpcm_sample,
+ .sample = slin8_sample,
.desc_size = sizeof (struct adpcm_encoder_pvt),
.buffer_samples = BUFFER_SAMPLES,
.buf_size = BUFFER_SAMPLES/ 2, /* 2 samples per byte */
Modified: trunk/codecs/codec_alaw.c
URL: http://svn.digium.com/view/asterisk/trunk/codecs/codec_alaw.c?view=diff&rev=150729&r1=150728&r2=150729
==============================================================================
--- trunk/codecs/codec_alaw.c (original)
+++ trunk/codecs/codec_alaw.c Fri Oct 17 16:35:23 2008
@@ -35,10 +35,9 @@
#define BUFFER_SAMPLES 8096 /* size for the translation buffers */
-/* Sample frame data (Mu data is okay) */
-
-#include "slin_ulaw_ex.h"
-#include "ulaw_slin_ex.h"
+/* Sample frame data */
+#include "asterisk/slin.h"
+#include "ex_alaw.h"
/*! \brief decode frame into lin and fill output buffer. */
static int alawtolin_framein(struct ast_trans_pvt *pvt, struct ast_frame *f)
@@ -72,42 +71,12 @@
return 0;
}
-/*! \brief alawToLin_Sample */
-static struct ast_frame *alawtolin_sample(void)
-{
- static struct ast_frame f;
- f.frametype = AST_FRAME_VOICE;
- f.subclass = AST_FORMAT_ALAW;
- f.datalen = sizeof(ulaw_slin_ex);
- f.samples = sizeof(ulaw_slin_ex);
- f.mallocd = 0;
- f.offset = 0;
- f.src = __PRETTY_FUNCTION__;
- f.data.ptr = ulaw_slin_ex;
- return &f;
-}
-
-/*! \brief LinToalaw_Sample */
-static struct ast_frame *lintoalaw_sample(void)
-{
- static struct ast_frame f;
- f.frametype = AST_FRAME_VOICE;
- f.subclass = AST_FORMAT_SLINEAR;
- f.datalen = sizeof(slin_ulaw_ex);
- f.samples = sizeof(slin_ulaw_ex) / 2;
- f.mallocd = 0;
- f.offset = 0;
- f.src = __PRETTY_FUNCTION__;
- f.data.ptr = slin_ulaw_ex;
- return &f;
-}
-
static struct ast_translator alawtolin = {
.name = "alawtolin",
.srcfmt = AST_FORMAT_ALAW,
.dstfmt = AST_FORMAT_SLINEAR,
.framein = alawtolin_framein,
- .sample = alawtolin_sample,
+ .sample = alaw_sample,
.buffer_samples = BUFFER_SAMPLES,
.buf_size = BUFFER_SAMPLES * 2,
.plc_samples = 160,
@@ -118,7 +87,7 @@
.srcfmt = AST_FORMAT_SLINEAR,
.dstfmt = AST_FORMAT_ALAW,
.framein = lintoalaw_framein,
- .sample = lintoalaw_sample,
+ .sample = slin8_sample,
.buffer_samples = BUFFER_SAMPLES,
.buf_size = BUFFER_SAMPLES,
};
Modified: trunk/codecs/codec_g722.c
URL: http://svn.digium.com/view/asterisk/trunk/codecs/codec_g722.c?view=diff&rev=150729&r1=150728&r2=150729
==============================================================================
--- trunk/codecs/codec_g722.c (original)
+++ trunk/codecs/codec_g722.c Fri Oct 17 16:35:23 2008
@@ -46,11 +46,11 @@
#define BUFFER_SAMPLES 8096 /* size for the translation buffers */
#define BUF_SHIFT 5
+#include "g722/g722.h"
+
/* Sample frame data */
-
-#include "g722/g722.h"
-#include "slin_g722_ex.h"
-#include "g722_slin_ex.h"
+#include "asterisk/slin.h"
+#include "ex_g722.h"
struct g722_encoder_pvt {
g722_encode_state_t g722;
@@ -130,62 +130,6 @@
pvt->datalen += outlen;
return 0;
-}
-
-static struct ast_frame *g722tolin_sample(void)
-{
- static struct ast_frame f = {
- .frametype = AST_FRAME_VOICE,
- .subclass = AST_FORMAT_G722,
- .datalen = sizeof(g722_slin_ex),
- .samples = sizeof(g722_slin_ex) * 2,
- .src = __PRETTY_FUNCTION__,
- .data.ptr = g722_slin_ex,
- };
-
- return &f;
-}
-
-static struct ast_frame *g722tolin16_sample(void)
-{
- static struct ast_frame f = {
- .frametype = AST_FRAME_VOICE,
- .subclass = AST_FORMAT_G722,
- .datalen = sizeof(g722_slin_ex),
- .samples = sizeof(g722_slin_ex) * 2,
- .src = __PRETTY_FUNCTION__,
- .data.ptr = g722_slin_ex,
- };
-
- return &f;
-}
-
-static struct ast_frame *lintog722_sample (void)
-{
- static struct ast_frame f = {
- .frametype = AST_FRAME_VOICE,
- .subclass = AST_FORMAT_SLINEAR,
- .datalen = sizeof(slin_g722_ex),
- .samples = ARRAY_LEN(slin_g722_ex),
- .src = __PRETTY_FUNCTION__,
- .data.ptr = slin_g722_ex,
- };
-
- return &f;
-}
-
-static struct ast_frame *lin16tog722_sample (void)
-{
- static struct ast_frame f = {
- .frametype = AST_FRAME_VOICE,
- .subclass = AST_FORMAT_SLINEAR16,
- .datalen = sizeof(slin_g722_ex),
- .samples = ARRAY_LEN(slin_g722_ex),
- .src = __PRETTY_FUNCTION__,
- .data.ptr = slin_g722_ex,
- };
-
- return &f;
}
static struct ast_translator g722tolin = {
@@ -194,7 +138,7 @@
.dstfmt = AST_FORMAT_SLINEAR,
.newpvt = g722tolin_new, /* same for both directions */
.framein = g722tolin_framein,
- .sample = g722tolin_sample,
+ .sample = g722_sample,
.desc_size = sizeof(struct g722_decoder_pvt),
.buffer_samples = BUFFER_SAMPLES / sizeof(int16_t),
.buf_size = BUFFER_SAMPLES,
@@ -207,7 +151,7 @@
.dstfmt = AST_FORMAT_G722,
.newpvt = lintog722_new, /* same for both directions */
.framein = lintog722_framein,
- .sample = lintog722_sample,
+ .sample = slin8_sample,
.desc_size = sizeof(struct g722_encoder_pvt),
.buffer_samples = BUFFER_SAMPLES * 2,
.buf_size = BUFFER_SAMPLES,
@@ -219,7 +163,7 @@
.dstfmt = AST_FORMAT_SLINEAR16,
.newpvt = g722tolin16_new, /* same for both directions */
.framein = g722tolin_framein,
- .sample = g722tolin16_sample,
+ .sample = g722_sample,
.desc_size = sizeof(struct g722_decoder_pvt),
.buffer_samples = BUFFER_SAMPLES / sizeof(int16_t),
.buf_size = BUFFER_SAMPLES,
@@ -232,7 +176,7 @@
.dstfmt = AST_FORMAT_G722,
.newpvt = lin16tog722_new, /* same for both directions */
.framein = lintog722_framein,
- .sample = lin16tog722_sample,
+ .sample = slin16_sample,
.desc_size = sizeof(struct g722_encoder_pvt),
.buffer_samples = BUFFER_SAMPLES * 2,
.buf_size = BUFFER_SAMPLES,
Modified: trunk/codecs/codec_g726.c
URL: http://svn.digium.com/view/asterisk/trunk/codecs/codec_g726.c?view=diff&rev=150729&r1=150728&r2=150729
==============================================================================
--- trunk/codecs/codec_g726.c (original)
+++ trunk/codecs/codec_g726.c Fri Oct 17 16:35:23 2008
@@ -58,9 +58,8 @@
#define BUF_SHIFT 5
/* Sample frame data */
-
-#include "slin_g726_ex.h"
-#include "g726_slin_ex.h"
+#include "asterisk/slin.h"
+#include "ex_g726.h"
/*
* The following is the definition of the state structure
@@ -786,41 +785,13 @@
return 0;
}
-static struct ast_frame *g726tolin_sample(void)
-{
- static struct ast_frame f = {
- .frametype = AST_FRAME_VOICE,
- .subclass = AST_FORMAT_G726,
- .datalen = sizeof(g726_slin_ex),
- .samples = sizeof(g726_slin_ex) * 2, /* 2 samples per byte */
- .src = __PRETTY_FUNCTION__,
- .data.ptr = g726_slin_ex,
- };
-
- return &f;
-}
-
-static struct ast_frame *lintog726_sample (void)
-{
- static struct ast_frame f = {
- .frametype = AST_FRAME_VOICE,
- .subclass = AST_FORMAT_SLINEAR,
- .datalen = sizeof(slin_g726_ex),
- .samples = sizeof(slin_g726_ex) / 2, /* 1 sample per 2 bytes */
- .src = __PRETTY_FUNCTION__,
- .data.ptr = slin_g726_ex,
- };
-
- return &f;
-}
-
static struct ast_translator g726tolin = {
.name = "g726tolin",
.srcfmt = AST_FORMAT_G726,
.dstfmt = AST_FORMAT_SLINEAR,
.newpvt = lintog726_new, /* same for both directions */
.framein = g726tolin_framein,
- .sample = g726tolin_sample,
+ .sample = g726_sample,
.desc_size = sizeof(struct g726_coder_pvt),
.buffer_samples = BUFFER_SAMPLES,
.buf_size = BUFFER_SAMPLES * 2,
@@ -833,7 +804,7 @@
.dstfmt = AST_FORMAT_G726,
.newpvt = lintog726_new, /* same for both directions */
.framein = lintog726_framein,
- .sample = lintog726_sample,
+ .sample = slin8_sample,
.desc_size = sizeof(struct g726_coder_pvt),
.buffer_samples = BUFFER_SAMPLES,
.buf_size = BUFFER_SAMPLES/2,
@@ -845,7 +816,7 @@
.dstfmt = AST_FORMAT_SLINEAR,
.newpvt = lintog726_new, /* same for both directions */
.framein = g726aal2tolin_framein,
- .sample = g726tolin_sample,
+ .sample = g726_sample,
.desc_size = sizeof(struct g726_coder_pvt),
.buffer_samples = BUFFER_SAMPLES,
.buf_size = BUFFER_SAMPLES * 2,
@@ -858,7 +829,7 @@
.dstfmt = AST_FORMAT_G726_AAL2,
.newpvt = lintog726_new, /* same for both directions */
.framein = lintog726aal2_framein,
- .sample = lintog726_sample,
+ .sample = slin8_sample,
.desc_size = sizeof(struct g726_coder_pvt),
.buffer_samples = BUFFER_SAMPLES,
.buf_size = BUFFER_SAMPLES / 2,
@@ -869,7 +840,7 @@
.srcfmt = AST_FORMAT_G726,
.dstfmt = AST_FORMAT_G726_AAL2,
.framein = g726tog726aal2_framein, /* same for both directions */
- .sample = lintog726_sample,
+ .sample = g726_sample,
.buffer_samples = BUFFER_SAMPLES,
.buf_size = BUFFER_SAMPLES,
};
@@ -879,7 +850,7 @@
.srcfmt = AST_FORMAT_G726_AAL2,
.dstfmt = AST_FORMAT_G726,
.framein = g726tog726aal2_framein, /* same for both directions */
- .sample = lintog726_sample,
+ .sample = g726_sample,
.buffer_samples = BUFFER_SAMPLES,
.buf_size = BUFFER_SAMPLES,
};
Modified: trunk/codecs/codec_gsm.c
URL: http://svn.digium.com/view/asterisk/trunk/codecs/codec_gsm.c?view=diff&rev=150729&r1=150728&r2=150729
==============================================================================
--- trunk/codecs/codec_gsm.c (original)
+++ trunk/codecs/codec_gsm.c Fri Oct 17 16:35:23 2008
@@ -47,15 +47,15 @@
#include "../formats/msgsm.h"
-/* Sample frame data */
-#include "slin_gsm_ex.h"
-#include "gsm_slin_ex.h"
-
#define BUFFER_SAMPLES 8000
#define GSM_SAMPLES 160
#define GSM_FRAME_LEN 33
#define MSGSM_FRAME_LEN 65
+/* Sample frame data */
+#include "asterisk/slin.h"
+#include "ex_gsm.h"
+
struct gsm_translator_pvt { /* both gsm2lin and lin2gsm */
gsm gsm;
int16_t buf[BUFFER_SAMPLES]; /* lin2gsm, temporary storage */
@@ -66,36 +66,6 @@
struct gsm_translator_pvt *tmp = pvt->pvt;
return (tmp->gsm = gsm_create()) ? 0 : -1;
-}
-
-static struct ast_frame *lintogsm_sample(void)
-{
- static struct ast_frame f;
- f.frametype = AST_FRAME_VOICE;
- f.subclass = AST_FORMAT_SLINEAR;
- f.datalen = sizeof(slin_gsm_ex);
- /* Assume 8000 Hz */
- f.samples = sizeof(slin_gsm_ex)/2;
- f.mallocd = 0;
- f.offset = 0;
- f.src = __PRETTY_FUNCTION__;
- f.data.ptr = slin_gsm_ex;
- return &f;
-}
-
-static struct ast_frame *gsmtolin_sample(void)
-{
- static struct ast_frame f;
- f.frametype = AST_FRAME_VOICE;
- f.subclass = AST_FORMAT_GSM;
- f.datalen = sizeof(gsm_slin_ex);
- /* All frames are 20 ms long */
- f.samples = GSM_SAMPLES;
- f.mallocd = 0;
- f.offset = 0;
- f.src = __PRETTY_FUNCTION__;
- f.data.ptr = gsm_slin_ex;
- return &f;
}
/*! \brief decode and store in outbuf. */
@@ -203,7 +173,7 @@
.newpvt = gsm_new,
.framein = gsmtolin_framein,
.destroy = gsm_destroy_stuff,
- .sample = gsmtolin_sample,
+ .sample = gsm_sample,
.buffer_samples = BUFFER_SAMPLES,
.buf_size = BUFFER_SAMPLES * 2,
.desc_size = sizeof (struct gsm_translator_pvt ),
@@ -218,7 +188,7 @@
.framein = lintogsm_framein,
.frameout = lintogsm_frameout,
.destroy = gsm_destroy_stuff,
- .sample = lintogsm_sample,
+ .sample = slin8_sample,
.desc_size = sizeof (struct gsm_translator_pvt ),
.buf_size = (BUFFER_SAMPLES * GSM_FRAME_LEN + GSM_SAMPLES - 1)/GSM_SAMPLES,
};
Modified: trunk/codecs/codec_ilbc.c
URL: http://svn.digium.com/view/asterisk/trunk/codecs/codec_ilbc.c?view=diff&rev=150729&r1=150728&r2=150729
==============================================================================
--- trunk/codecs/codec_ilbc.c (original)
+++ trunk/codecs/codec_ilbc.c Fri Oct 17 16:35:23 2008
@@ -40,10 +40,6 @@
#include "ilbc/iLBC_encode.h"
#include "ilbc/iLBC_decode.h"
-/* Sample frame data */
-#include "slin_ilbc_ex.h"
-#include "ilbc_slin_ex.h"
-
#define USE_ILBC_ENHANCER 0
#define ILBC_MS 30
/* #define ILBC_MS 20 */
@@ -51,6 +47,10 @@
#define ILBC_FRAME_LEN 50 /* apparently... */
#define ILBC_SAMPLES 240 /* 30ms at 8000 hz */
#define BUFFER_SAMPLES 8000
+
+/* Sample frame data */
+#include "asterisk/slin.h"
+#include "ex_ilbc.h"
struct ilbc_coder_pvt {
iLBC_Enc_Inst_t enc;
@@ -75,35 +75,6 @@
initDecode(&tmp->dec, ILBC_MS, USE_ILBC_ENHANCER);
return 0;
-}
-
-static struct ast_frame *lintoilbc_sample(void)
-{
- static struct ast_frame f;
- f.frametype = AST_FRAME_VOICE;
- f.subclass = AST_FORMAT_SLINEAR;
- f.datalen = sizeof(slin_ilbc_ex);
- f.samples = sizeof(slin_ilbc_ex)/2;
- f.mallocd = 0;
- f.offset = 0;
- f.src = __PRETTY_FUNCTION__;
- f.data.ptr = slin_ilbc_ex;
- return &f;
-}
-
-static struct ast_frame *ilbctolin_sample(void)
-{
- static struct ast_frame f;
- f.frametype = AST_FRAME_VOICE;
- f.subclass = AST_FORMAT_ILBC;
- f.datalen = sizeof(ilbc_slin_ex);
- /* All frames are 30 ms long */
- f.samples = ILBC_SAMPLES;
- f.mallocd = 0;
- f.offset = 0;
- f.src = __PRETTY_FUNCTION__;
- f.data.ptr = ilbc_slin_ex;
- return &f;
}
/*! \brief decode a frame and store in outbuf */
@@ -194,7 +165,7 @@
.dstfmt = AST_FORMAT_SLINEAR,
.newpvt = ilbctolin_new,
.framein = ilbctolin_framein,
- .sample = ilbctolin_sample,
+ .sample = ilbc_sample,
.desc_size = sizeof(struct ilbc_coder_pvt),
.buf_size = BUFFER_SAMPLES * 2,
.native_plc = 1,
@@ -207,7 +178,7 @@
.newpvt = lintoilbc_new,
.framein = lintoilbc_framein,
.frameout = lintoilbc_frameout,
- .sample = lintoilbc_sample,
+ .sample = slin8_sample,
.desc_size = sizeof(struct ilbc_coder_pvt),
.buf_size = (BUFFER_SAMPLES * ILBC_FRAME_LEN + ILBC_SAMPLES - 1) / ILBC_SAMPLES,
};
Modified: trunk/codecs/codec_lpc10.c
URL: http://svn.digium.com/view/asterisk/trunk/codecs/codec_lpc10.c?view=diff&rev=150729&r1=150728&r2=150729
==============================================================================
--- trunk/codecs/codec_lpc10.c (original)
+++ trunk/codecs/codec_lpc10.c Fri Oct 17 16:35:23 2008
@@ -39,8 +39,8 @@
#include "lpc10/lpc10.h"
/* Sample frame data */
-#include "slin_lpc10_ex.h"
-#include "lpc10_slin_ex.h"
+#include "asterisk/slin.h"
+#include "ex_lpc10.h"
/* We use a very strange format here... I have no idea why... The frames are 180
samples long, which isn't even an even number of milliseconds... Not only that
@@ -73,37 +73,6 @@
struct lpc10_coder_pvt *tmp = pvt->pvt;
return (tmp->lpc10.dec = create_lpc10_decoder_state()) ? 0 : -1;
-}
-
-static struct ast_frame *lintolpc10_sample(void)
-{
- static struct ast_frame f;
- f.frametype = AST_FRAME_VOICE;
- f.subclass = AST_FORMAT_SLINEAR;
- f.datalen = sizeof(slin_lpc10_ex);
- /* Assume 8000 Hz */
- f.samples = LPC10_SAMPLES_PER_FRAME;
- f.mallocd = 0;
- f.offset = 0;
- f.src = __PRETTY_FUNCTION__;
- f.data.ptr = slin_lpc10_ex;
- return &f;
-}
-
-static struct ast_frame *lpc10tolin_sample(void)
-{
- static struct ast_frame f;
- f.frametype = AST_FRAME_VOICE;
- f.subclass = AST_FORMAT_LPC10;
- f.datalen = sizeof(lpc10_slin_ex);
- /* All frames are 22 ms long (maybe a little more -- why did he choose
- LPC10_SAMPLES_PER_FRAME sample frames anyway?? */
- f.samples = LPC10_SAMPLES_PER_FRAME;
- f.mallocd = 0;
- f.offset = 0;
- f.src = __PRETTY_FUNCTION__;
- f.data.ptr = lpc10_slin_ex;
- return &f;
}
static void extract_bits(INT32 *bits, unsigned char *c)
@@ -229,7 +198,7 @@
.newpvt = lpc10_dec_new,
.framein = lpc10tolin_framein,
.destroy = lpc10_destroy,
- .sample = lpc10tolin_sample,
+ .sample = lpc10_sample,
.desc_size = sizeof(struct lpc10_coder_pvt),
.buffer_samples = BUFFER_SAMPLES,
.plc_samples = LPC10_SAMPLES_PER_FRAME,
@@ -244,7 +213,7 @@
.framein = lintolpc10_framein,
.frameout = lintolpc10_frameout,
.destroy = lpc10_destroy,
- .sample = lintolpc10_sample,
+ .sample = slin8_sample,
.desc_size = sizeof(struct lpc10_coder_pvt),
.buffer_samples = BUFFER_SAMPLES,
.buf_size = LPC10_BYTES_IN_COMPRESSED_FRAME * (1 + BUFFER_SAMPLES / LPC10_SAMPLES_PER_FRAME),
Modified: trunk/codecs/codec_resample.c
URL: http://svn.digium.com/view/asterisk/trunk/codecs/codec_resample.c?view=diff&rev=150729&r1=150728&r2=150729
==============================================================================
--- trunk/codecs/codec_resample.c (original)
+++ trunk/codecs/codec_resample.c Fri Oct 17 16:35:23 2008
@@ -49,7 +49,7 @@
#include "asterisk/module.h"
#include "asterisk/translate.h"
-#include "slin_resample_ex.h"
+#include "asterisk/slin.h"
#define RESAMPLER_QUALITY 1
@@ -69,9 +69,9 @@
{
struct slin16_to_slin8_pvt *resamp_pvt = pvt->pvt;
- resamp_pvt->resample_factor = 0.5;
-
- if (!(resamp_pvt->resampler = resample_open(RESAMPLER_QUALITY, 0.5, 0.5)))
+ resamp_pvt->resample_factor = 8000.0 / 16000.0;
+
+ if (!(resamp_pvt->resampler = resample_open(RESAMPLER_QUALITY, resamp_pvt->resample_factor, resamp_pvt->resample_factor)))
return -1;
return 0;
@@ -81,9 +81,9 @@
{
struct slin8_to_slin16_pvt *resamp_pvt = pvt->pvt;
- resamp_pvt->resample_factor = 2.0;
-
- if (!(resamp_pvt->resampler = resample_open(RESAMPLER_QUALITY, 2.0, 2.0)))
+ resamp_pvt->resample_factor = 16000.0 / 8000.0;
+
+ if (!(resamp_pvt->resampler = resample_open(RESAMPLER_QUALITY, resamp_pvt->resample_factor, resamp_pvt->resample_factor)))
return -1;
return 0;
@@ -168,34 +168,6 @@
return resample_frame(pvt, resampler, resample_factor, f);
}
-static struct ast_frame *slin16_to_slin8_sample(void)
-{
- static struct ast_frame f = {
- .frametype = AST_FRAME_VOICE,
- .subclass = AST_FORMAT_SLINEAR16,
- .datalen = sizeof(slin16_slin8_ex),
- .samples = ARRAY_LEN(slin16_slin8_ex),
- .src = __PRETTY_FUNCTION__,
- .data.ptr = slin16_slin8_ex,
- };
-
- return &f;
-}
-
-static struct ast_frame *slin8_to_slin16_sample(void)
-{
- static struct ast_frame f = {
- .frametype = AST_FRAME_VOICE,
- .subclass = AST_FORMAT_SLINEAR,
- .datalen = sizeof(slin8_slin16_ex),
- .samples = ARRAY_LEN(slin8_slin16_ex),
- .src = __PRETTY_FUNCTION__,
- .data.ptr = slin8_slin16_ex,
- };
-
- return &f;
-}
-
static struct ast_translator slin16_to_slin8 = {
.name = "slin16_to_slin8",
.srcfmt = AST_FORMAT_SLINEAR16,
@@ -203,7 +175,7 @@
.newpvt = slin16_to_slin8_new,
.destroy = slin16_to_slin8_destroy,
.framein = slin16_to_slin8_framein,
- .sample = slin16_to_slin8_sample,
+ .sample = slin16_sample,
.desc_size = sizeof(struct slin16_to_slin8_pvt),
.buffer_samples = (OUTBUF_SIZE / sizeof(int16_t)),
.buf_size = OUTBUF_SIZE,
@@ -216,7 +188,7 @@
.newpvt = slin8_to_slin16_new,
.destroy = slin8_to_slin16_destroy,
.framein = slin8_to_slin16_framein,
- .sample = slin8_to_slin16_sample,
+ .sample = slin8_sample,
.desc_size = sizeof(struct slin8_to_slin16_pvt),
.buffer_samples = (OUTBUF_SIZE / sizeof(int16_t)),
.buf_size = OUTBUF_SIZE,
Modified: trunk/codecs/codec_speex.c
URL: http://svn.digium.com/view/asterisk/trunk/codecs/codec_speex.c?view=diff&rev=150729&r1=150728&r2=150729
==============================================================================
--- trunk/codecs/codec_speex.c (original)
+++ trunk/codecs/codec_speex.c Fri Oct 17 16:35:23 2008
@@ -52,10 +52,6 @@
#include "asterisk/module.h"
#include "asterisk/config.h"
#include "asterisk/utils.h"
-
-/* Sample frame data */
-#include "slin_speex_ex.h"
-#include "speex_slin_ex.h"
/* codec variables */
static int quality = 3;
@@ -84,6 +80,10 @@
#define BUFFER_SAMPLES 8000
#define SPEEX_SAMPLES 160
+/* Sample frame data */
+#include "asterisk/slin.h"
+#include "ex_speex.h"
+
struct speex_coder_pvt {
void *speex;
SpeexBits bits;
@@ -152,36 +152,6 @@
speex_decoder_ctl(tmp->speex, SPEEX_SET_ENH, &enhancement);
return 0;
-}
-
-static struct ast_frame *lintospeex_sample(void)
-{
- static struct ast_frame f;
- f.frametype = AST_FRAME_VOICE;
- f.subclass = AST_FORMAT_SLINEAR;
- f.datalen = sizeof(slin_speex_ex);
- /* Assume 8000 Hz */
- f.samples = sizeof(slin_speex_ex)/2;
- f.mallocd = 0;
- f.offset = 0;
- f.src = __PRETTY_FUNCTION__;
- f.data.ptr = slin_speex_ex;
- return &f;
-}
-
-static struct ast_frame *speextolin_sample(void)
-{
- static struct ast_frame f;
- f.frametype = AST_FRAME_VOICE;
- f.subclass = AST_FORMAT_SPEEX;
- f.datalen = sizeof(speex_slin_ex);
- /* All frames are 20 ms long */
- f.samples = SPEEX_SAMPLES;
- f.mallocd = 0;
- f.offset = 0;
- f.src = __PRETTY_FUNCTION__;
- f.data.ptr = speex_slin_ex;
- return &f;
}
/*! \brief convert and store into outbuf */
@@ -346,7 +316,7 @@
.newpvt = speextolin_new,
.framein = speextolin_framein,
.destroy = speextolin_destroy,
- .sample = speextolin_sample,
+ .sample = speex_sample,
.desc_size = sizeof(struct speex_coder_pvt),
.buffer_samples = BUFFER_SAMPLES,
.buf_size = BUFFER_SAMPLES * 2,
@@ -361,7 +331,7 @@
.framein = lintospeex_framein,
.frameout = lintospeex_frameout,
.destroy = lintospeex_destroy,
- .sample = lintospeex_sample,
+ .sample = slin8_sample,
.desc_size = sizeof(struct speex_coder_pvt),
.buffer_samples = BUFFER_SAMPLES,
.buf_size = BUFFER_SAMPLES * 2, /* XXX maybe a lot less ? */
Modified: trunk/codecs/codec_ulaw.c
URL: http://svn.digium.com/view/asterisk/trunk/codecs/codec_ulaw.c?view=diff&rev=150729&r1=150728&r2=150729
==============================================================================
--- trunk/codecs/codec_ulaw.c (original)
+++ trunk/codecs/codec_ulaw.c Fri Oct 17 16:35:23 2008
@@ -36,9 +36,8 @@
#define BUFFER_SAMPLES 8096 /* size for the translation buffers */
/* Sample frame data */
-
-#include "slin_ulaw_ex.h"
-#include "ulaw_slin_ex.h"
+#include "asterisk/slin.h"
+#include "ex_ulaw.h"
/*! \brief convert and store samples in outbuf */
static int ulawtolin_framein(struct ast_trans_pvt *pvt, struct ast_frame *f)
@@ -73,40 +72,6 @@
return 0;
}
-/*! * \brief ulawToLin_Sample */
-static struct ast_frame *ulawtolin_sample(void)
-{
- static struct ast_frame f;
- f.frametype = AST_FRAME_VOICE;
- f.subclass = AST_FORMAT_ULAW;
- f.datalen = sizeof(ulaw_slin_ex);
- f.samples = sizeof(ulaw_slin_ex);
- f.mallocd = 0;
- f.offset = 0;
- f.src = __PRETTY_FUNCTION__;
- f.data.ptr = ulaw_slin_ex;
- return &f;
-}
-
-/*!
- * \brief LinToulaw_Sample
- */
-
-static struct ast_frame *lintoulaw_sample(void)
-{
- static struct ast_frame f;
- f.frametype = AST_FRAME_VOICE;
- f.subclass = AST_FORMAT_SLINEAR;
- f.datalen = sizeof(slin_ulaw_ex);
- /* Assume 8000 Hz */
- f.samples = sizeof(slin_ulaw_ex) / 2;
- f.mallocd = 0;
- f.offset = 0;
- f.src = __PRETTY_FUNCTION__;
- f.data.ptr = slin_ulaw_ex;
- return &f;
-}
-
/*!
* \brief The complete translator for ulawToLin.
*/
@@ -116,7 +81,7 @@
.srcfmt = AST_FORMAT_ULAW,
.dstfmt = AST_FORMAT_SLINEAR,
.framein = ulawtolin_framein,
- .sample = ulawtolin_sample,
+ .sample = ulaw_sample,
.buffer_samples = BUFFER_SAMPLES,
.buf_size = BUFFER_SAMPLES * 2,
.plc_samples = 160,
@@ -131,7 +96,7 @@
.srcfmt = AST_FORMAT_SLINEAR,
.dstfmt = AST_FORMAT_ULAW,
.framein = lintoulaw_framein,
- .sample = lintoulaw_sample,
+ .sample = slin8_sample,
.buf_size = BUFFER_SAMPLES,
.buffer_samples = BUFFER_SAMPLES,
};
More information about the asterisk-commits
mailing list