Mercurial > libavcodec.hg
annotate libgsm.c @ 4378:d15d3cd71df2 libavcodec
Remove debug line.
author | banan |
---|---|
date | Sun, 21 Jan 2007 21:25:16 +0000 |
parents | c8c591fe26f8 |
children | c0bf618fbe7e |
rev | line source |
---|---|
2729 | 1 /* |
2 * Interface to libgsm for gsm encoding/decoding | |
3 * Copyright (c) 2005 Alban Bedel <albeu@free.fr> | |
4 * | |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3036
diff
changeset
|
5 * This file is part of FFmpeg. |
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3036
diff
changeset
|
6 * |
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3036
diff
changeset
|
7 * FFmpeg is free software; you can redistribute it and/or |
2729 | 8 * modify it under the terms of the GNU Lesser General Public |
9 * License as published by the Free Software Foundation; either | |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3036
diff
changeset
|
10 * version 2.1 of the License, or (at your option) any later version. |
2729 | 11 * |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3036
diff
changeset
|
12 * FFmpeg is distributed in the hope that it will be useful, |
2729 | 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 * Lesser General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU Lesser General Public | |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3036
diff
changeset
|
18 * License along with FFmpeg; if not, write to the Free Software |
3036
0b546eab515d
Update licensing information: The FSF changed postal address.
diego
parents:
2967
diff
changeset
|
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
2729 | 20 */ |
2967 | 21 |
2729 | 22 /** |
23 * @file libgsm.c | |
24 * Interface to libgsm for gsm encoding/decoding | |
25 */ | |
26 | |
27 #include "avcodec.h" | |
28 #include <gsm.h> | |
29 | |
30 // gsm.h miss some essential constants | |
31 #define GSM_BLOCK_SIZE 33 | |
32 #define GSM_FRAME_SIZE 160 | |
33 | |
34 static int libgsm_init(AVCodecContext *avctx) { | |
35 if (avctx->channels > 1 || avctx->sample_rate != 8000) | |
36 return -1; | |
37 | |
38 avctx->frame_size = GSM_FRAME_SIZE; | |
39 avctx->block_align = GSM_BLOCK_SIZE; | |
40 | |
41 avctx->priv_data = gsm_create(); | |
2967 | 42 |
2729 | 43 avctx->coded_frame= avcodec_alloc_frame(); |
44 avctx->coded_frame->key_frame= 1; | |
2967 | 45 |
2729 | 46 return 0; |
47 } | |
48 | |
49 static int libgsm_close(AVCodecContext *avctx) { | |
50 gsm_destroy(avctx->priv_data); | |
51 avctx->priv_data = NULL; | |
52 return 0; | |
53 } | |
54 | |
55 static int libgsm_encode_frame(AVCodecContext *avctx, | |
56 unsigned char *frame, int buf_size, void *data) { | |
57 // we need a full block | |
58 if(buf_size < GSM_BLOCK_SIZE) return 0; | |
59 | |
60 gsm_encode(avctx->priv_data,data,frame); | |
61 | |
62 return GSM_BLOCK_SIZE; | |
63 } | |
64 | |
65 | |
66 AVCodec libgsm_encoder = { | |
67 "gsm", | |
68 CODEC_TYPE_AUDIO, | |
69 CODEC_ID_GSM, | |
70 0, | |
71 libgsm_init, | |
72 libgsm_encode_frame, | |
73 libgsm_close, | |
74 }; | |
75 | |
76 static int libgsm_decode_frame(AVCodecContext *avctx, | |
77 void *data, int *data_size, | |
78 uint8_t *buf, int buf_size) { | |
79 | |
80 if(buf_size < GSM_BLOCK_SIZE) return 0; | |
81 | |
82 if(gsm_decode(avctx->priv_data,buf,data)) return -1; | |
83 | |
84 *data_size = GSM_FRAME_SIZE*2; | |
85 return GSM_BLOCK_SIZE; | |
86 } | |
87 | |
88 AVCodec libgsm_decoder = { | |
89 "gsm", | |
90 CODEC_TYPE_AUDIO, | |
91 CODEC_ID_GSM, | |
92 0, | |
93 libgsm_init, | |
94 NULL, | |
95 libgsm_close, | |
96 libgsm_decode_frame, | |
97 }; |