summaryrefslogtreecommitdiff
path: root/firmware/export
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2003-03-10 14:55:31 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2003-03-10 14:55:31 +0000
commita039091187f40d018b6353b8c13de7a01d3a6fe0 (patch)
tree08f7eb86e86e2c61f4d36f9c91731cb93252ba84 /firmware/export
parent22cbe938feb48895d7488449835d3ee577399057 (diff)
downloadrockbox-a039091187f40d018b6353b8c13de7a01d3a6fe0.zip
rockbox-a039091187f40d018b6353b8c13de7a01d3a6fe0.tar.gz
rockbox-a039091187f40d018b6353b8c13de7a01d3a6fe0.tar.bz2
rockbox-a039091187f40d018b6353b8c13de7a01d3a6fe0.tar.xz
New ID3 and MP3 stream parser, plus not-yet-ready Xing header generation code
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3410 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/export')
-rw-r--r--firmware/export/id3.h9
-rw-r--r--firmware/export/mp3data.h66
-rw-r--r--firmware/export/mpeg.h1
3 files changed, 71 insertions, 5 deletions
diff --git a/firmware/export/id3.h b/firmware/export/id3.h
index 55ce002..30be4bf 100644
--- a/firmware/export/id3.h
+++ b/firmware/export/id3.h
@@ -39,15 +39,18 @@ struct mp3entry {
unsigned int first_frame_offset; /* Byte offset to first real MP3 frame.
Used for skipping leading garbage to
avoid gaps between tracks. */
+ unsigned int xing_header_pos;
unsigned int filesize; /* in bytes */
unsigned int length; /* song length */
unsigned int elapsed; /* ms played */
+
+ /* MP3 stream specific info */
long bpf; /* bytes per frame */
long tpf; /* time per frame */
/* Xing VBR fields */
bool vbr;
- unsigned char vbrflags;
+ bool has_toc; /* True if there is a VBR header in the file */
unsigned char toc[100];/* table of contents */
/* these following two fields are used for local buffering */
@@ -59,10 +62,6 @@ struct mp3entry {
int index; /* playlist index */
};
-#define VBR_FRAMES_FLAG 0x01
-#define VBR_BYTES_FLAG 0x02
-#define VBR_TOC_FLAG 0x04
-
enum {
ID3_VER_1_0 = 1,
ID3_VER_1_1,
diff --git a/firmware/export/mp3data.h b/firmware/export/mp3data.h
new file mode 100644
index 0000000..a1018eb
--- /dev/null
+++ b/firmware/export/mp3data.h
@@ -0,0 +1,66 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2002 by Linus Nielsen Feltzing
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#ifndef _MP3DATA_H_
+#define _MP3DATA_H_
+
+#define MPEG_VERSION2_5 0
+#define MPEG_VERSION1 1
+#define MPEG_VERSION2 2
+
+struct mp3info {
+ /* Standard MP3 frame header fields */
+ int version;
+ int layer;
+ bool protection;
+ int bitrate;
+ int frequency;
+ int padding;
+ int channel_mode;
+ int mode_extension;
+ int emphasis;
+ int frame_size; /* Frame size in bytes */
+ int frame_time; /* Frame duration in milliseconds */
+
+ bool is_vbr; /* True if the file is VBR */
+ bool has_toc; /* True if there is a VBR header in the file */
+ bool is_xing_vbr; /* True if the VBR header is of Xing type */
+ bool is_vbri_vbr; /* True if the VBR header is of VBRI type */
+ unsigned char toc[100];
+ int frame_count; /* Number of frames in the file (if VBR) */
+ int byte_count; /* File size in bytes */
+ int file_time; /* Length of the whole file in milliseconds */
+ int xing_header_pos;
+};
+
+/* Xing header information */
+#define VBR_FRAMES_FLAG 0x01
+#define VBR_BYTES_FLAG 0x02
+#define VBR_TOC_FLAG 0x04
+
+
+unsigned long find_next_frame(int fd, int *offset, int max_offset, unsigned long last_header);
+int get_mp3file_info(int fd, struct mp3info *info);
+int count_mp3_frames(int fd, int startpos, int filesize,
+ void (*progressfunc)(int));
+int create_xing_header(int fd, int startpos, int filesize,
+ unsigned char *buf, int num_frames,
+ void (*progressfunc)(int));
+
+#endif
diff --git a/firmware/export/mpeg.h b/firmware/export/mpeg.h
index 6b44363..9ce03da 100644
--- a/firmware/export/mpeg.h
+++ b/firmware/export/mpeg.h
@@ -90,6 +90,7 @@ unsigned long mpeg_num_recorded_bytes(void);
#endif
void mpeg_get_debugdata(struct mpeg_debug *dbgdata);
void mpeg_set_buffer_margin(int seconds);
+int mpeg_create_xing_header(char *filename, void (*progressfunc)(int));
#define SOUND_VOLUME 0
#define SOUND_BASS 1