diff options
author | Michael Giacomelli <giac2000@hotmail.com> | 2010-01-27 17:25:10 +0000 |
---|---|---|
committer | Michael Giacomelli <giac2000@hotmail.com> | 2010-01-27 17:25:10 +0000 |
commit | c9183bf15e56bbc795f9fb08027ee6285b2ebed4 (patch) | |
tree | e355d4ebbdb9b06e7da5260ec58679aa96da15f1 /apps/codecs/libpcm/pcm_common.h | |
parent | 7a50f6f2740b84d10cbb021fd59a870c09688b88 (diff) | |
download | rockbox-c9183bf15e56bbc795f9fb08027ee6285b2ebed4.tar.gz rockbox-c9183bf15e56bbc795f9fb08027ee6285b2ebed4.zip |
Commit FS#10422 by Yoshihisa Uchida. Seperates WAV and AIFF parsing from PCM decoding by introducing libpcm, a library for decoding linear and non-uniform PCM independently of the container format.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24346 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs/libpcm/pcm_common.h')
-rw-r--r-- | apps/codecs/libpcm/pcm_common.h | 120 |
1 files changed, 120 insertions, 0 deletions
diff --git a/apps/codecs/libpcm/pcm_common.h b/apps/codecs/libpcm/pcm_common.h new file mode 100644 index 0000000000..757d0ad5d9 --- /dev/null +++ b/apps/codecs/libpcm/pcm_common.h | |||
@@ -0,0 +1,120 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2009 Yoshihisa Uchida | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | #ifndef CODEC_LIBPCMS_PCM_COMMON_H | ||
22 | #define CODEC_LIBPCMS_PCM_COMMON_H | ||
23 | |||
24 | #include <sys/types.h> | ||
25 | #include <stdbool.h> | ||
26 | #include <inttypes.h> | ||
27 | |||
28 | /* | ||
29 | * PCM_CHUNK_SIZE has the size only of storing the sample at 1/50 seconds. | ||
30 | * But it might not be 1/50 seconds according to the format. | ||
31 | * Please confirm the source file of each format. | ||
32 | */ | ||
33 | #define PCM_CHUNK_SIZE (4096*2) | ||
34 | |||
35 | /* Macro that sign extends an unsigned byte */ | ||
36 | #define SE(x) ((int32_t)((int8_t)(x))) | ||
37 | |||
38 | /* Macro that shift to -0x80. (0 .. 127 to -128 .. -1, 128 .. 255 to 0 .. 127) */ | ||
39 | #define SFT(x) ((int32_t)x-0x80) | ||
40 | |||
41 | struct pcm_format { | ||
42 | /* | ||
43 | * RIFF: wFormatTag (in 'fmt ' chunk) | ||
44 | * AIFF: compressionType (in 'COMM' chunk) | ||
45 | */ | ||
46 | uint32_t formattag; | ||
47 | |||
48 | /* | ||
49 | * RIFF: wChannels (in 'fmt ' chunk) | ||
50 | * AIFF: numChannels (in 'COMM' chunk) | ||
51 | */ | ||
52 | uint16_t channels; | ||
53 | |||
54 | /* | ||
55 | * RIFF: dwSamplesPerSec (in 'fmt ' chunk) | ||
56 | * AIFF: sampleRate (in 'COMM' chunk) | ||
57 | */ | ||
58 | uint32_t samplespersec; | ||
59 | |||
60 | /* RIFF: dwAvgBytesPerSec (in 'fmt ' chunk) */ | ||
61 | uint32_t avgbytespersec; | ||
62 | |||
63 | /* | ||
64 | * RIFF: wBlockAlign (in 'fmt ' chunk) | ||
65 | * AIFF: blockSize (in 'SSND' chunk) | ||
66 | */ | ||
67 | uint16_t blockalign; | ||
68 | |||
69 | /* | ||
70 | * RIFF: wBitsPerSample (in 'fmt ' chunk) | ||
71 | * AIFF: sampleSize (in 'COMM' chunk) | ||
72 | */ | ||
73 | uint16_t bitspersample; | ||
74 | |||
75 | /* RIFF: wSize (in 'fmt ' chunk) */ | ||
76 | uint16_t size; | ||
77 | |||
78 | /* RIFF: dSamplesPerBlock (in 'fmt ' chunk) */ | ||
79 | uint16_t samplesperblock; | ||
80 | |||
81 | /* RIFF: wTotalSamples (in 'fact' chunk) */ | ||
82 | uint16_t totalsamples; | ||
83 | |||
84 | /* the following values are not RIFF/AIFF chunk values */ | ||
85 | |||
86 | /* bytes per sample */ | ||
87 | int bytespersample; | ||
88 | |||
89 | /* chunk size */ | ||
90 | long chunksize; | ||
91 | |||
92 | /* data size */ | ||
93 | uint32_t numbytes; | ||
94 | |||
95 | /* | ||
96 | * data endian | ||
97 | * true: little endian, false: big endian | ||
98 | */ | ||
99 | bool is_little_endian; | ||
100 | |||
101 | /* | ||
102 | * data signess | ||
103 | * true: signed, false: unsigned | ||
104 | */ | ||
105 | bool is_signed; | ||
106 | }; | ||
107 | |||
108 | struct pcm_codec { | ||
109 | bool (*set_format)(struct pcm_format *format, const unsigned char *fmtpos); | ||
110 | uint32_t (*get_seek_pos)(long seek_time); | ||
111 | int (*decode)(const uint8_t *inbuf, size_t inbufsize, | ||
112 | int32_t *outbuf, int *outbufsize); | ||
113 | }; | ||
114 | |||
115 | struct pcm_entry { | ||
116 | uint32_t format_tag; | ||
117 | const struct pcm_codec *(*get_codec)(void); | ||
118 | }; | ||
119 | |||
120 | #endif | ||