diff options
Diffstat (limited to 'apps/metadata/au.c')
-rw-r--r-- | apps/metadata/au.c | 105 |
1 files changed, 0 insertions, 105 deletions
diff --git a/apps/metadata/au.c b/apps/metadata/au.c deleted file mode 100644 index 94e7453644..0000000000 --- a/apps/metadata/au.c +++ /dev/null | |||
@@ -1,105 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2010 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 | #include <stdio.h> | ||
22 | #include <string.h> | ||
23 | #include <inttypes.h> | ||
24 | |||
25 | #include "system.h" | ||
26 | #include "metadata.h" | ||
27 | #include "metadata_common.h" | ||
28 | #include "metadata_parsers.h" | ||
29 | #include "logf.h" | ||
30 | |||
31 | static const unsigned char bitspersamples[9] = { | ||
32 | 0, /* encoding */ | ||
33 | 8, /* 1: G.711 MULAW */ | ||
34 | 8, /* 2: Linear PCM 8bit */ | ||
35 | 16, /* 3: Linear PCM 16bit */ | ||
36 | 24, /* 4: Linear PCM 24bit */ | ||
37 | 32, /* 5: Linear PCM 32bit */ | ||
38 | 32, /* 6: IEEE float 32bit */ | ||
39 | 64, /* 7: IEEE float 64bit */ | ||
40 | /* encoding 8 - 26 unsupported. */ | ||
41 | 8, /* 27: G.711 ALAW */ | ||
42 | }; | ||
43 | |||
44 | static inline unsigned char get_au_bitspersample(unsigned int encoding) | ||
45 | { | ||
46 | if (encoding < 8) | ||
47 | return bitspersamples[encoding]; | ||
48 | else if (encoding == 27) | ||
49 | return bitspersamples[8]; | ||
50 | |||
51 | return 0; | ||
52 | } | ||
53 | |||
54 | bool get_au_metadata(int fd, struct mp3entry* id3) | ||
55 | { | ||
56 | /* temporary buffer */ | ||
57 | unsigned char* buf = (unsigned char *)id3->path; | ||
58 | unsigned long numbytes = 0; | ||
59 | int offset; | ||
60 | |||
61 | id3->vbr = false; /* All Sun audio files are CBR */ | ||
62 | id3->filesize = filesize(fd); | ||
63 | id3->length = 0; | ||
64 | |||
65 | lseek(fd, 0, SEEK_SET); | ||
66 | if ((read(fd, buf, 24) < 24) || (memcmp(buf, ".snd", 4) != 0)) | ||
67 | { | ||
68 | /* | ||
69 | * no header | ||
70 | * | ||
71 | * frequency: 8000 Hz | ||
72 | * bits per sample: 8 bit | ||
73 | * channel: mono | ||
74 | */ | ||
75 | numbytes = id3->filesize; | ||
76 | id3->frequency = 8000; | ||
77 | id3->bitrate = 8; | ||
78 | } | ||
79 | else | ||
80 | { | ||
81 | /* parse header */ | ||
82 | |||
83 | /* data offset */ | ||
84 | offset = get_long_be(buf + 4); | ||
85 | if (offset < 24) | ||
86 | { | ||
87 | DEBUGF("CODEC_ERROR: sun audio offset size is small: %d\n", offset); | ||
88 | return false; | ||
89 | } | ||
90 | /* data size */ | ||
91 | numbytes = get_long_be(buf + 8); | ||
92 | if (numbytes == (uint32_t)0xffffffff) | ||
93 | numbytes = id3->filesize - offset; | ||
94 | |||
95 | id3->frequency = get_long_be(buf + 16); | ||
96 | id3->bitrate = get_au_bitspersample(get_long_be(buf + 12)) * get_long_be(buf + 20) | ||
97 | * id3->frequency / 1000; | ||
98 | } | ||
99 | |||
100 | /* Calculate track length [ms] */ | ||
101 | if (id3->bitrate) | ||
102 | id3->length = (numbytes << 3) / id3->bitrate; | ||
103 | |||
104 | return true; | ||
105 | } | ||