source: roaraudio/libroardsp/interleave.c @ 3035:ffd68a1a48cb

Last change on this file since 3035:ffd68a1a48cb was 3035:ffd68a1a48cb, checked in by phi, 14 years ago

corrected function name

File size: 2.2 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_decode_ext(struct roar_interleave * state, void * in, void ** out, size_t len) {
64 size_t chan = 0;
65 size_t ic;       // input counter
66 size_t bc   = 0; // bit counter
67 char   * op[ROAR_INTERLEAVE_MAX_CHANNELS]; // output pointer
68
69 if ( state == NULL )
70  return -1;
71
72 if ( in == NULL || out == NULL )
73  return -1;
74
75 if ( len == 0 )
76  return 0;
77
78 memcpy(op, out, sizeof(void*)*state->channels);
79
80 for (ic = 0; ic < len; ic++) {
81  // get char and copy it
82  *(op[chan]) = ((char*)in)[ic];
83  op[chan]++;
84
85  bc += 8;
86
87  if ( bc == state->bits ) {
88   bc = 0;
89   chan++;
90   if ( chan == state->channels )
91    chan = 0;
92  }
93 }
94
95 return -1;
96}
97
98//ll
Note: See TracBrowser for help on using the repository browser.