1 /*
2  * dca.h
3  * Copyright (C) 2004 Gildas Bazin <gbazin@videolan.org>
4  *
5  * This file is part of libdca, a free DTS Coherent Acoustics stream decoder.
6  * See http://www.videolan.org/developers/libdca.html for updates.
7  *
8  * libdca is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * libdca is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the
20  * Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22  */
23 
24 #ifndef LIBDCA_DCA_H
25 #define LIBDCA_DCA_H
26 
27 /* x86 accelerations */
28 #define MM_ACCEL_X86_MMX	0x80000000
29 #define MM_ACCEL_X86_3DNOW	0x40000000
30 #define MM_ACCEL_X86_MMXEXT	0x20000000
31 
32 uint32_t mm_accel (void);
33 
34 #if defined(LIBDCA_FIXED)
35 typedef int32_t sample_t;
36 typedef int32_t level_t;
37 #elif defined(LIBDCA_DOUBLE)
38 typedef double sample_t;
39 typedef double level_t;
40 #else
41 typedef float sample_t;
42 typedef float level_t;
43 #endif
44 
45 typedef struct dca_state_s dca_state_t;
46 
47 #define DCA_MONO 0
48 #define DCA_CHANNEL 1
49 #define DCA_STEREO 2
50 #define DCA_STEREO_SUMDIFF 3
51 #define DCA_STEREO_TOTAL 4
52 #define DCA_3F 5
53 #define DCA_2F1R 6
54 #define DCA_3F1R 7
55 #define DCA_2F2R 8
56 #define DCA_3F2R 9
57 #define DCA_4F2R 10
58 
59 #define DCA_DOLBY 101 /* FIXME */
60 
61 #define DCA_CHANNEL_MAX  DCA_3F2R /* We don't handle anything above that */
62 #define DCA_CHANNEL_BITS 6
63 #define DCA_CHANNEL_MASK 0x3F
64 
65 #define DCA_LFE 0x80
66 #define DCA_ADJUST_LEVEL 0x100
67 
68 dca_state_t * dca_init (uint32_t mm_accel);
69 
70 int dca_syncinfo (dca_state_t *state, uint8_t * buf, int * flags,
71                   int * sample_rate, int * bit_rate, int *frame_length);
72 
73 int dca_frame (dca_state_t * state, uint8_t * buf, int * flags,
74                level_t * level, sample_t bias);
75 
76 void dca_dynrng (dca_state_t * state,
77                  level_t (* call) (level_t, void *), void * data);
78 
79 int dca_blocks_num (dca_state_t * state);
80 int dca_block (dca_state_t * state);
81 
82 sample_t * dca_samples (dca_state_t * state);
83 
84 void dca_free (dca_state_t * state);
85 
86 #endif /* LIBDCA_DCA_H */
87