source: roaraudio/libroardsp/interleave.c @ 3036:0789cd065a6a

Last change on this file since 3036:0789cd065a6a was 3036:0789cd065a6a, checked in by phi, 14 years ago

added dummy for roar_interl_encode_ext()

File size: 2.4 KB
Line 
1//interleave.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
27int roar_interl_init  (struct roar_interleave * state, size_t channels, size_t bits) {
28 if ( state == NULL )
29  return -1;
30
31 // we can currently only hanle full bytes:
32 if ( bits % 8 )
33  return -1;
34
35 // currently we have a channel limit
36 if ( channels > ROAR_INTERLEAVE_MAX_CHANNELS )
37  return -1;
38
39 memset(state, 0, sizeof(struct roar_interleave));
40
41 state->channels = channels;
42 state->bits     = bits;
43
44 return 0;
45}
46
47int roar_interl_uninit(struct roar_interleave * state) {
48 if ( state == NULL )
49  return -1;
50
51 memset(state, 0, sizeof(struct roar_interleave));
52
53 return 0;
54}
55
56int roar_interl_ctl   (struct roar_interleave * state, int cmd, void * data) {
57 if ( state == NULL )
58  return -1;
59
60 return -1;
61}
62
63int roar_interl_encode_ext(struct roar_interleave * state, void ** in, void  * out, size_t len) {
64 if ( state == NULL )
65  return -1;
66
67 return -1;
68}
69
70int roar_interl_decode_ext(struct roar_interleave * state, void * in, void ** out, size_t len) {
71 size_t chan = 0;
72 size_t ic;       // input counter
73 size_t bc   = 0; // bit counter
74 char   * op[ROAR_INTERLEAVE_MAX_CHANNELS]; // output pointer
75
76 if ( state == NULL )
77  return -1;
78
79 if ( in == NULL || out == NULL )
80  return -1;
81
82 if ( len == 0 )
83  return 0;
84
85 memcpy(op, out, sizeof(void*)*state->channels);
86
87 for (ic = 0; ic < len; ic++) {
88  // get char and copy it
89  *(op[chan]) = ((char*)in)[ic];
90  op[chan]++;
91
92  bc += 8;
93
94  if ( bc == state->bits ) {
95   bc = 0;
96   chan++;
97   if ( chan == state->channels )
98    chan = 0;
99  }
100 }
101
102 return -1;
103}
104
105//ll
Note: See TracBrowser for help on using the repository browser.