-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathid3parser.h
More file actions
35 lines (29 loc) · 1.36 KB
/
id3parser.h
File metadata and controls
35 lines (29 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#ifndef ID3PARSER_H
#define ID3PARSER_H
#define ID3_TITLE_LEN 128
#define ID3_ARTIST_LEN 128
#define ID3_ALBUM_LEN 128
#define MAX_COVER_SIZE (512 * 1024) // 512KB max album art
typedef struct {
char title[ID3_TITLE_LEN];
char artist[ID3_ARTIST_LEN];
char album[ID3_ALBUM_LEN];
int duration; // duration in seconds (estimated from bitrate)
int hasCover; // 1 if album art found
unsigned char *coverData; // JPEG/PNG raw data (malloc'd, caller frees)
int coverSize; // size of cover data in bytes
int coverWidth; // decoded width (0 until decoded)
int coverHeight; // decoded height (0 until decoded)
} ID3Info;
// Parse ID3 tags from an MP3 file. Returns 0 on success, -1 on error.
// If loadCover is 1 and hasCover is 1, coverData is malloc'd and must be freed.
// If loadCover is 0, hasCover flag is still set but coverData is NULL.
int id3_parse(const char *filepath, ID3Info *info, int loadCover);
// Free allocated cover data
void id3_free(ID3Info *info);
// Decode JPEG cover data into ABGR8888 pixel buffer for PSP display.
// Returns malloc'd pixel buffer (width*height*4 bytes). Caller frees.
// Scales image to fit within maxW x maxH.
unsigned int *id3_decode_cover(ID3Info *info, int maxW, int maxH,
int *outW, int *outH);
#endif // ID3PARSER_H