Revision bb4c2140

View differences:

configure
22 22
echo "  --enable-faad            enable faad support via libfaad [default=no]"
23 23
echo "  --enable-faadbin         build faad support with runtime linking [default=no]"
24 24
echo "  --enable-faac            enable faac support via libfaac [default=no]"
25
echo "  --enable-libgsm          enable gsm support via libgsm [default=no]"
25 26
echo "  --enable-xvid            enable xvid support via xvidcore [default=no]"
26 27
echo "  --enable-x264            enable H.264 encoding via x264 [default=no]"
27 28
echo "  --enable-mingw32         enable mingw32 native/cross windows compile"
......
158 159
dc1394="no"
159 160
network="yes"
160 161
zlib="yes"
162
libgsm="no"
161 163
mp3lame="no"
162 164
libogg="no"
163 165
vorbis="no"
......
447 449
  ;;
448 450
  --enable-shared-pp) shared_pp="yes"
449 451
  ;;
452
  --enable-libgsm) libgsm="yes"
453
  ;;
450 454
  --enable-mp3lame) mp3lame="yes"
451 455
  ;;
452 456
  --enable-libogg) libogg="yes"
......
1123 1127
fi
1124 1128
echo "gprof enabled    $gprof"
1125 1129
echo "zlib enabled     $zlib"
1130
echo "libgsm enabled   $libgsm"
1126 1131
echo "mp3lame enabled  $mp3lame"
1127 1132
echo "libogg enabled   $libogg"
1128 1133
echo "vorbis enabled   $vorbis"
......
1420 1425
  echo "CONFIG_ZLIB=yes" >> config.mak
1421 1426
fi
1422 1427

  
1428
if test "$libgsm" = "yes" ; then
1429
  echo "#define CONFIG_LIBGSM 1" >> $TMPH
1430
  echo "CONFIG_LIBGSM=yes" >> config.mak
1431
fi
1432

  
1423 1433
if test "$mp3lame" = "yes" ; then
1424 1434
  echo "#define CONFIG_MP3LAME 1" >> $TMPH
1425 1435
  echo "CONFIG_MP3LAME=yes" >> config.mak
libavcodec/Makefile
291 291
EXTRALIBS += -logg
292 292
endif
293 293

  
294
ifeq ($(CONFIG_LIBGSM),yes)
295
OBJS += libgsm.o
296
EXTRALIBS += -lgsm
297
endif
298

  
294 299
ifeq ($(TARGET_GPROF),yes)
295 300
CFLAGS+=-p
296 301
LDFLAGS+=-p
libavcodec/allcodecs.c
186 186
    register_avcodec(&x264_encoder);
187 187
#endif //CONFIG_X264_ENCODER
188 188
#endif
189
#ifdef CONFIG_LIBGSM
190
    register_avcodec(&libgsm_encoder);
191
#endif //CONFIG_LIBGSM
189 192
#endif /* CONFIG_ENCODERS */
190 193
#ifdef CONFIG_RAWVIDEO_ENCODER
191 194
    register_avcodec(&rawvideo_encoder);
......
482 485
#ifdef CONFIG_VORBIS_DECODER
483 486
    register_avcodec(&vorbis_decoder);
484 487
#endif
488
#ifdef CONFIG_LIBGSM
489
    register_avcodec(&libgsm_decoder);
490
#endif //CONFIG_LIBGSM
485 491
#endif /* CONFIG_DECODERS */
486 492

  
487 493
#ifdef AMR_NB
libavcodec/avcodec.h
172 172
    CODEC_ID_SHORTEN,
173 173
    CODEC_ID_ALAC,
174 174
    CODEC_ID_WESTWOOD_SND1,
175
    CODEC_ID_GSM,    
175 176
    
176 177
    CODEC_ID_OGGTHEORA= 0x16000, 
177 178
    
......
2021 2022
extern AVCodec indeo2_decoder;
2022 2023
extern AVCodec vorbis_decoder;
2023 2024
extern AVCodec fraps_decoder;
2025
extern AVCodec libgsm_encoder;
2026
extern AVCodec libgsm_decoder;
2024 2027

  
2025 2028
/* pcm codecs */
2026 2029
#define PCM_CODEC(id, name) \
libavcodec/libgsm.c
1
/*
2
 * Interface to libgsm for gsm encoding/decoding
3
 * Copyright (c) 2005 Alban Bedel <albeu@free.fr>
4
 *
5
 * This library is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU Lesser General Public
7
 * License as published by the Free Software Foundation; either
8
 * version 2 of the License, or (at your option) any later version.
9
 *
10
 * This library is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
 * Lesser General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU Lesser General Public
16
 * License along with this library; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
 */
19
 
20
/**
21
 * @file libgsm.c
22
 * Interface to libgsm for gsm encoding/decoding
23
 */
24

  
25
#include "avcodec.h"
26
#include <gsm.h>
27

  
28
// gsm.h miss some essential constants
29
#define GSM_BLOCK_SIZE 33
30
#define GSM_FRAME_SIZE 160
31

  
32
static int libgsm_init(AVCodecContext *avctx) {
33
    if (avctx->channels > 1 || avctx->sample_rate != 8000)
34
        return -1;
35

  
36
    avctx->frame_size = GSM_FRAME_SIZE;
37
    avctx->block_align = GSM_BLOCK_SIZE;
38

  
39
    avctx->priv_data = gsm_create();
40
    
41
    avctx->coded_frame= avcodec_alloc_frame();
42
    avctx->coded_frame->key_frame= 1;
43
    
44
    return 0;
45
}
46

  
47
static int libgsm_close(AVCodecContext *avctx) {
48
    gsm_destroy(avctx->priv_data);
49
    avctx->priv_data = NULL;
50
    return 0;
51
}
52

  
53
static int libgsm_encode_frame(AVCodecContext *avctx,
54
                               unsigned char *frame, int buf_size, void *data) {
55
    // we need a full block
56
    if(buf_size < GSM_BLOCK_SIZE) return 0;
57

  
58
    gsm_encode(avctx->priv_data,data,frame);
59

  
60
    return GSM_BLOCK_SIZE;
61
}
62

  
63

  
64
AVCodec libgsm_encoder = {
65
    "gsm",
66
    CODEC_TYPE_AUDIO,
67
    CODEC_ID_GSM,
68
    0,
69
    libgsm_init,
70
    libgsm_encode_frame,
71
    libgsm_close,
72
};
73

  
74
static int libgsm_decode_frame(AVCodecContext *avctx,
75
                               void *data, int *data_size,
76
                               uint8_t *buf, int buf_size) {
77

  
78
    if(buf_size < GSM_BLOCK_SIZE) return 0;
79

  
80
    if(gsm_decode(avctx->priv_data,buf,data)) return -1;
81

  
82
    *data_size = GSM_FRAME_SIZE*2;
83
    return GSM_BLOCK_SIZE;
84
}
85

  
86
AVCodec libgsm_decoder = {
87
    "gsm",
88
    CODEC_TYPE_AUDIO,
89
    CODEC_ID_GSM,
90
    0,
91
    libgsm_init,
92
    NULL,
93
    libgsm_close,
94
    libgsm_decode_frame,
95
};

Also available in: Unified diff