summaryrefslogtreecommitdiff
path: root/apps/metadata/monkeys.c
diff options
context:
space:
mode:
authorSean Bartell <wingedtachikoma@gmail.com>2011-06-24 01:25:21 -0400
committerNils Wallménius <nils@rockbox.org>2012-03-18 12:00:39 +0100
commitb5716df4cb2837bbbc42195cf1aefcf03e21d6a6 (patch)
tree130cd712e2e00893b6df9959a375a8d9523a1aca /apps/metadata/monkeys.c
parent24bd9d5393dbe39a5c6194877bc00ede669b1d5d (diff)
downloadrockbox-b5716df4cb2837bbbc42195cf1aefcf03e21d6a6.tar.gz
rockbox-b5716df4cb2837bbbc42195cf1aefcf03e21d6a6.zip
Build librbcodec with DSP and metadata.
All associated files are moved to /lib/rbcodec. Change-Id: I572ddd2b8a996aae1e98c081d06b1ed356dce222
Diffstat (limited to 'apps/metadata/monkeys.c')
-rw-r--r--apps/metadata/monkeys.c97
1 files changed, 0 insertions, 97 deletions
diff --git a/apps/metadata/monkeys.c b/apps/metadata/monkeys.c
deleted file mode 100644
index 4aff1412aa..0000000000
--- a/apps/metadata/monkeys.c
+++ /dev/null
@@ -1,97 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 Dave Chapman
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 <stdlib.h>
24#include <ctype.h>
25#include <inttypes.h>
26
27#include "system.h"
28#include "metadata.h"
29#include "metadata_common.h"
30#include "metadata_parsers.h"
31
32bool get_monkeys_metadata(int fd, struct mp3entry* id3)
33{
34 /* Use the trackname part of the id3 structure as a temporary buffer */
35 unsigned char* buf = (unsigned char *)id3->path;
36 unsigned char* header;
37 bool rc = false;
38 uint32_t descriptorlength;
39 uint32_t totalsamples;
40 uint32_t blocksperframe, finalframeblocks, totalframes;
41 int fileversion;
42
43 lseek(fd, 0, SEEK_SET);
44
45 if (read(fd, buf, 4) < 4)
46 {
47 return rc;
48 }
49
50 if (memcmp(buf, "MAC ", 4) != 0)
51 {
52 return rc;
53 }
54
55 read(fd, buf + 4, MAX_PATH - 4);
56
57 fileversion = get_short_le(buf+4);
58 if (fileversion < 3970)
59 {
60 /* Not supported */
61 return false;
62 }
63
64 if (fileversion >= 3980)
65 {
66 descriptorlength = get_long_le(buf+8);
67
68 header = buf + descriptorlength;
69
70 blocksperframe = get_long_le(header+4);
71 finalframeblocks = get_long_le(header+8);
72 totalframes = get_long_le(header+12);
73 id3->frequency = get_long_le(header+20);
74 }
75 else
76 {
77 /* v3.95 and later files all have a fixed framesize */
78 blocksperframe = 73728 * 4;
79
80 finalframeblocks = get_long_le(buf+28);
81 totalframes = get_long_le(buf+24);
82 id3->frequency = get_long_le(buf+12);
83 }
84
85 id3->vbr = true; /* All APE files are VBR */
86 id3->filesize = filesize(fd);
87
88 totalsamples = finalframeblocks;
89 if (totalframes > 1)
90 totalsamples += blocksperframe * (totalframes-1);
91
92 id3->length = ((int64_t) totalsamples * 1000) / id3->frequency;
93 id3->bitrate = (id3->filesize * 8) / id3->length;
94
95 read_ape_tags(fd, id3);
96 return true;
97}