2
The mediastreamer library aims at providing modular media processing and I/O
3
for linphone, but also for any telephony application.
4
Copyright (C) 2001 Simon MORLAT simon.morlat@linphone.org
6
This library is free software; you can redistribute it and/or
7
modify it under the terms of the GNU Lesser General Public
8
License as published by the Free Software Foundation; either
9
version 2.1 of the License, or (at your option) any later version.
11
This library is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
Lesser General Public License for more details.
16
You should have received a copy of the GNU Lesser General Public
17
License along with this library; if not, write to the Free Software
18
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22
#include "msLPC10decoder.h"
23
#include "msLPC10encoder.h"
27
extern MSFilter * ms_LPC10encoder_new(void);
29
MSCodecInfo LPC10info={
33
MS_FILTER_AUDIO_CODEC,
35
"A low quality but very low bit rate codec from the U.S. Department of Defense."
49
static MSLPC10DecoderClass *ms_LPC10decoder_class=NULL;
51
MSFilter * ms_LPC10decoder_new(void)
55
r=g_new(MSLPC10Decoder,1);
56
ms_LPC10decoder_init(r);
57
if (ms_LPC10decoder_class==NULL)
59
ms_LPC10decoder_class=g_new(MSLPC10DecoderClass,1);
60
ms_LPC10decoder_class_init(ms_LPC10decoder_class);
62
MS_FILTER(r)->klass=MS_FILTER_CLASS(ms_LPC10decoder_class);
68
void ms_LPC10decoder_init(MSLPC10Decoder *r)
70
ms_filter_init(MS_FILTER(r));
71
MS_FILTER(r)->infifos=r->f_inputs;
72
MS_FILTER(r)->outfifos=r->f_outputs;
73
MS_FILTER(r)->r_mingran=7;
74
memset(r->f_inputs,0,sizeof(MSFifo*)*MSLPC10DECODER_MAX_INPUTS);
75
memset(r->f_outputs,0,sizeof(MSFifo*)*MSLPC10DECODER_MAX_INPUTS);
76
r->lpc10_dec=create_lpc10_decoder_state();
79
void ms_LPC10decoder_class_init(MSLPC10DecoderClass *klass)
81
ms_filter_class_init(MS_FILTER_CLASS(klass));
82
ms_filter_class_set_name(MS_FILTER_CLASS(klass),"LPC10Dec");
83
MS_FILTER_CLASS(klass)->max_finputs=MSLPC10DECODER_MAX_INPUTS;
84
MS_FILTER_CLASS(klass)->max_foutputs=MSLPC10DECODER_MAX_INPUTS;
85
MS_FILTER_CLASS(klass)->r_maxgran=7;
86
MS_FILTER_CLASS(klass)->w_maxgran=LPC10_SAMPLES_PER_FRAME*2;
87
MS_FILTER_CLASS(klass)->destroy=(MSFilterDestroyFunc)ms_LPC10decoder_destroy;
88
MS_FILTER_CLASS(klass)->process=(MSFilterProcessFunc)ms_LPC10decoder_process;
89
MS_FILTER_CLASS(klass)->info=(MSFilterInfo*)&LPC10info;
92
void ms_LPC10decoder_process(MSLPC10Decoder *r)
97
float speech[LPC10_SAMPLES_PER_FRAME];
98
INT32 bits[LPC10_BITS_IN_COMPRESSED_FRAME];
100
/* process output fifos, but there is only one for this class of filter*/
106
err1=ms_fifo_get_read_ptr(fi,7,&s);
109
err1=ms_fifo_get_write_ptr(fo,LPC10_SAMPLES_PER_FRAME*2,&d);
112
read_bits(s, bits, LPC10_BITS_IN_COMPRESSED_FRAME);
113
lpc10_decode(bits,speech, r->lpc10_dec);
114
write_16bit_samples((INT16*)d, speech, LPC10_SAMPLES_PER_FRAME);
120
void ms_LPC10decoder_uninit(MSLPC10Decoder *obj)
122
free(obj->lpc10_dec);
125
void ms_LPC10decoder_destroy( MSLPC10Decoder *obj)
127
ms_LPC10decoder_uninit(obj);