~ubuntu-branches/ubuntu/breezy/linphone/breezy

« back to all changes in this revision

Viewing changes to mediastreamer2/msAlawenc.c

  • Committer: Bazaar Package Importer
  • Author(s): Stephan Hermann
  • Date: 2005-10-06 13:43:40 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20051006134340-x5ameztbvco519z6
Tags: 1.0.1-6ubuntu7
The "Brain MIA" upload
Added amd64 arch to linphone-common (now)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 /*
 
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
 
5
                                                                                
 
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.
 
10
 
 
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.
 
15
 
 
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
 
19
*/
 
20
 
 
21
 
 
22
#include "msAlawenc.h"
 
23
#include "g711common.h"
 
24
 
 
25
extern MSCodecInfo ALAWinfo;
 
26
 
 
27
 
 
28
/* FOR INTERNAL USE*/
 
29
void ms_ALAWencoder_init(MSALAWEncoder *r);
 
30
void ms_ALAWencoder_process(MSALAWEncoder *r);
 
31
 
 
32
/* tuning parameters :*/
 
33
#define ALAW_ENCODER_WMAXGRAN 160
 
34
#define ALAW_ENCODER_RMAXGRAN 320
 
35
 
 
36
MSFilter * ms_ALAWencoder_new(void)
 
37
{
 
38
        MSALAWEncoder *r;
 
39
        r=g_new(MSALAWEncoder,1);
 
40
        ms_ALAWencoder_init(r);
 
41
        return(MS_FILTER(r));
 
42
}
 
43
 
 
44
declare_simple_static_fifo_setup(alaw_encoder,ALAW_ENCODER_RMAXGRAN,ALAW_ENCODER_WMAXGRAN)
 
45
 
 
46
MSFilterVTable ms_ALAWencoder_vtable={
 
47
        process: ms_ALAWencoder_process,
 
48
        setup_link: simple_static_fifo_setup_ref(alaw_encoder)
 
49
};
 
50
 
 
51
/* FOR INTERNAL USE*/
 
52
void ms_ALAWencoder_init(MSALAWEncoder *r)
 
53
{
 
54
        ms_filter_init(MS_FILTER(r),&ms_ALAWencoder_vtable,"MSALAWEncoder",1,0,1,0);
 
55
        
 
56
}
 
57
        
 
58
void ms_ALAWencoder_process(MSALAWEncoder *r)
 
59
{
 
60
        MSFifo *fi,*fo;
 
61
        gchar *s,*d;
 
62
        int i;
 
63
        
 
64
        fi=r->base.infifos[0];
 
65
        fo=r->base.outfifos[0];
 
66
        
 
67
        s=ms_fifo_get_read_ptr(fi,ALAW_ENCODER_RMAXGRAN);
 
68
        d=ms_fifo_get_write_ptr(fo,ALAW_ENCODER_WMAXGRAN);
 
69
        for(i=0;i<ALAW_ENCODER_WMAXGRAN;i++)
 
70
        {
 
71
                d[i]=s16_to_alaw( *((gint16*)s) );
 
72
                s+=2;
 
73
        }
 
74
}