diff options
Diffstat (limited to 'lib/rbcodec/codecs/libffmpegFLAC/bitstream.h')
-rw-r--r-- | lib/rbcodec/codecs/libffmpegFLAC/bitstream.h | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/lib/rbcodec/codecs/libffmpegFLAC/bitstream.h b/lib/rbcodec/codecs/libffmpegFLAC/bitstream.h new file mode 100644 index 0000000000..5fc3460c8e --- /dev/null +++ b/lib/rbcodec/codecs/libffmpegFLAC/bitstream.h | |||
@@ -0,0 +1,79 @@ | |||
1 | /** | ||
2 | * @file bitstream.h | ||
3 | * bitstream api header. | ||
4 | */ | ||
5 | |||
6 | #ifndef BITSTREAM_H | ||
7 | #define BITSTREAM_H | ||
8 | |||
9 | #include <inttypes.h> | ||
10 | #include "ffmpeg_get_bits.h" | ||
11 | |||
12 | #ifndef BUILD_STANDALONE | ||
13 | #include <config.h> | ||
14 | #include <system.h> | ||
15 | #else | ||
16 | #include <stdio.h> | ||
17 | #define IBSS_ATTR | ||
18 | #define ICONST_ATTR | ||
19 | #define ICODE_ATTR | ||
20 | #endif | ||
21 | |||
22 | #if (CONFIG_CPU == MCF5250) || (CONFIG_CPU == PP5022) || (CONFIG_CPU == PP5024) | ||
23 | #define ICODE_ATTR_FLAC ICODE_ATTR | ||
24 | #define IBSS_ATTR_FLAC IBSS_ATTR | ||
25 | /* Enough IRAM to move additional data to it. */ | ||
26 | #define IBSS_ATTR_FLAC_LARGE_IRAM IBSS_ATTR | ||
27 | #define IBSS_ATTR_FLAC_XLARGE_IRAM | ||
28 | |||
29 | #elif defined(CPU_S5L870X) | ||
30 | #define ICODE_ATTR_FLAC ICODE_ATTR | ||
31 | #define IBSS_ATTR_FLAC IBSS_ATTR | ||
32 | /* Enough IRAM to move even more additional data to it. */ | ||
33 | #define IBSS_ATTR_FLAC_LARGE_IRAM IBSS_ATTR | ||
34 | #define IBSS_ATTR_FLAC_XLARGE_IRAM IBSS_ATTR | ||
35 | |||
36 | #else | ||
37 | #define ICODE_ATTR_FLAC ICODE_ATTR | ||
38 | #define IBSS_ATTR_FLAC IBSS_ATTR | ||
39 | /* Not enough IRAM available. */ | ||
40 | #define IBSS_ATTR_FLAC_LARGE_IRAM | ||
41 | #define IBSS_ATTR_FLAC_XLARGE_IRAM | ||
42 | #endif | ||
43 | |||
44 | /* Endian conversion routines for standalone compilation */ | ||
45 | #ifdef BUILD_STANDALONE | ||
46 | #ifdef BUILD_BIGENDIAN | ||
47 | #define betoh32(x) (x) | ||
48 | #define letoh32(x) swap32(x) | ||
49 | #else | ||
50 | #define letoh32(x) (x) | ||
51 | #define betoh32(x) swap32(x) | ||
52 | #endif | ||
53 | |||
54 | /* Taken from rockbox/firmware/export/system.h */ | ||
55 | |||
56 | static inline unsigned short swap16(unsigned short value) | ||
57 | /* | ||
58 | result[15..8] = value[ 7..0]; | ||
59 | result[ 7..0] = value[15..8]; | ||
60 | */ | ||
61 | { | ||
62 | return (value >> 8) | (value << 8); | ||
63 | } | ||
64 | |||
65 | static inline unsigned long swap32(unsigned long value) | ||
66 | /* | ||
67 | result[31..24] = value[ 7.. 0]; | ||
68 | result[23..16] = value[15.. 8]; | ||
69 | result[15.. 8] = value[23..16]; | ||
70 | result[ 7.. 0] = value[31..24]; | ||
71 | */ | ||
72 | { | ||
73 | unsigned long hi = swap16(value >> 16); | ||
74 | unsigned long lo = swap16(value & 0xffff); | ||
75 | return (lo << 16) | hi; | ||
76 | } | ||
77 | #endif | ||
78 | |||
79 | #endif /* BITSTREAM_H */ | ||