Make track_db public
[cmus.git] / sf.h
blob001409b7c69284e937a5208142304fd7f5d101ac
1 /*
2 * Copyright 2004 Timo Hirvonen
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of the
7 * License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
17 * 02111-1307, USA.
20 #ifndef _SF_H
21 #define _SF_H
24 * 0 1 big_endian 0-1
25 * 1 1 is_signed 0-1
26 * 2 1 unused 0
27 * 3-5 3 bits >> 3 0-7 (* 8 = 0-56)
28 * 6-23 18 rate 0-262143
29 * 24-31 8 channels 0-255
31 typedef unsigned int sample_format_t;
33 #define SF_BIGENDIAN_MASK 0x00000001
34 #define SF_SIGNED_MASK 0x00000002
35 #define SF_BITS_MASK 0x00000038
36 #define SF_RATE_MASK 0x00ffffc0
37 #define SF_CHANNELS_MASK 0xff000000
39 #define SF_BIGENDIAN_SHIFT 0
40 #define SF_SIGNED_SHIFT 1
41 #define SF_BITS_SHIFT 0
42 #define SF_RATE_SHIFT 6
43 #define SF_CHANNELS_SHIFT 24
45 #define sf_get_bigendian(sf) (((sf) & SF_BIGENDIAN_MASK) >> SF_BIGENDIAN_SHIFT)
46 #define sf_get_signed(sf) (((sf) & SF_SIGNED_MASK ) >> SF_SIGNED_SHIFT)
47 #define sf_get_bits(sf) (((sf) & SF_BITS_MASK ) >> SF_BITS_SHIFT)
48 #define sf_get_rate(sf) (((sf) & SF_RATE_MASK ) >> SF_RATE_SHIFT)
49 #define sf_get_channels(sf) (((sf) & SF_CHANNELS_MASK ) >> SF_CHANNELS_SHIFT)
51 #define sf_bigendian(val) (((val) << SF_BIGENDIAN_SHIFT) & SF_BIGENDIAN_MASK)
52 #define sf_signed(val) (((val) << SF_SIGNED_SHIFT ) & SF_SIGNED_MASK)
53 #define sf_bits(val) (((val) << SF_BITS_SHIFT ) & SF_BITS_MASK)
54 #define sf_rate(val) (((val) << SF_RATE_SHIFT ) & SF_RATE_MASK)
55 #define sf_channels(val) (((val) << SF_CHANNELS_SHIFT ) & SF_CHANNELS_MASK)
57 #define sf_get_sample_size(sf) (sf_get_bits((sf)) >> 3)
58 #define sf_get_frame_size(sf) (sf_get_sample_size((sf)) * sf_get_channels((sf)))
59 #define sf_get_second_size(sf) (sf_get_rate((sf)) * sf_get_frame_size((sf)))
61 #endif