0
|
1 /*
|
|
2 * A Xing header may be present in the ancillary
|
|
3 * data field of the first frame of an mp3 bitstream
|
|
4 * The Xing header (optionally) contains
|
|
5 * frames total number of audio frames in the bitstream
|
|
6 * bytes total number of bytes in the bitstream
|
|
7 * toc table of contents
|
|
8 *
|
|
9 * toc (table of contents) gives seek points
|
|
10 * for random access
|
|
11 * the ith entry determines the seek point for
|
|
12 * i-percent duration
|
|
13 * seek point in bytes = (toc[i]/256.0) * total_bitstream_bytes
|
|
14 * e.g. half duration seek point = (toc[50]/256.0) * total_bitstream_bytes
|
|
15 */
|
|
16
|
|
17 #define FRAMES_FLAG 0x0001
|
|
18 #define BYTES_FLAG 0x0002
|
|
19 #define TOC_FLAG 0x0004
|
|
20 #define VBR_SCALE_FLAG 0x0008
|
|
21
|
|
22 /*
|
|
23 * structure to receive extracted header
|
|
24 */
|
|
25 typedef struct {
|
|
26 int frames; /* total bit stream frames from Xing header data */
|
|
27 int bytes; /* total bit stream bytes from Xing header data */
|
|
28 unsigned char toc[100]; /* "table of contents" */
|
|
29 } xing_header_t;
|
|
30
|
|
31 /*
|
|
32 * Returns zero on fail, non-zero on success
|
|
33 * xing structure to receive header data (output)
|
|
34 * buf bitstream input
|
|
35 */
|
|
36 int mpg123_get_xing_header(xing_header_t * xing, unsigned char *buf);
|
|
37
|
|
38
|
|
39 /*
|
|
40 * Returns seekpoint in bytes (may be at eof if percent=100.0)
|
|
41 * percent: play time percentage of total playtime. May be fractional.
|
|
42 */
|
|
43 int mpg123_seek_point(xing_header_t * xing, float percent);
|