source: roaraudio/libroardsp/transcode_celt.c @ 2191:2fa43472c538

Last change on this file since 2191:2fa43472c538 was 2191:2fa43472c538, checked in by phi, 15 years ago

added init and uninit, need to write encoder and decoder code.

File size: 2.7 KB
Line 
1//transcode_celt.c:
2
3/*
4 *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009
5 *
6 *  This file is part of libroardsp a part of RoarAudio,
7 *  a cross-platform sound system for both, home and professional use.
8 *  See README for details.
9 *
10 *  This file is free software; you can redistribute it and/or modify
11 *  it under the terms of the GNU General Public License version 3
12 *  as published by the Free Software Foundation.
13 *
14 *  libroardsp is distributed in the hope that it will be useful,
15 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 *  GNU General Public License for more details.
18 *
19 *  You should have received a copy of the GNU General Public License
20 *  along with this software; see the file COPYING.  If not, write to
21 *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
22 *
23 */
24
25#include "libroardsp.h"
26
27#ifdef ROAR_HAVE_LIBCELT
28
29int roar_xcoder_celt_init       (struct roar_xcoder * state) {
30 struct roar_xcoder_celt * self = malloc(sizeof(struct roar_xcoder_celt));
31 struct roar_audio_info  * info = &(state->info.pcm);
32
33 if ( self == NULL )
34  return -1;
35
36 // curruntly only 16 bit mode is supported
37 if ( info->bits != 16 ) {
38  free(self);
39  return -1;
40 }
41
42 memset(self, 0, sizeof(struct roar_xcoder_celt));
43
44 state->inst = self;
45
46 self->frame_size           = 256;
47
48 self->mode                 = celt_mode_create(info->rate, info->channels, self->frame_size, NULL);
49
50 if ( self->mode == NULL ) {
51  free(self);
52  return -1;
53 }
54
55 if (state->encode) {
56  self->encoder = celt_encoder_create(self->mode);
57  if ( self->encoder == NULL ) {
58   roar_xcoder_celt_uninit(state);
59   return -1;
60  }
61 } else {
62  self->decoder = celt_decoder_create(self->mode);
63  if ( self->decoder == NULL ) {
64   roar_xcoder_celt_uninit(state);
65   return -1;
66  }
67 }
68
69 return 0;
70}
71
72int roar_xcoder_celt_uninit     (struct roar_xcoder * state) {
73 struct roar_xcoder_celt * self = state->inst;
74
75 if ( self->encoder )
76 celt_encoder_destroy(self->encoder);
77
78 if ( self->decoder )
79 celt_decoder_destroy(self->decoder);
80
81 if ( self->mode )
82  celt_mode_destroy(self->mode);
83
84 free(self);
85
86 return -1;
87}
88
89int roar_xcoder_celt_packet_size(struct roar_xcoder * state, int samples) {
90 struct roar_xcoder_celt * self = state->inst;
91
92 return self->frame_size;
93}
94
95int roar_xcoder_celt_encode     (struct roar_xcoder * state, void * buf, size_t len) {
96 struct roar_xcoder_celt * self = state->inst;
97
98 if (!state->encode)
99  return -1;
100
101 return -1;
102}
103
104int roar_xcoder_celt_decode     (struct roar_xcoder * state, void * buf, size_t len) {
105 struct roar_xcoder_celt * self = state->inst;
106
107 if (state->encode)
108  return -1;
109
110 return -1;
111}
112
113#endif
114
115//ll
Note: See TracBrowser for help on using the repository browser.