diff options
| author | Linus Nielsen Feltzing <linus@haxx.se> | 2003-03-10 18:25:40 +0000 |
|---|---|---|
| committer | Linus Nielsen Feltzing <linus@haxx.se> | 2003-03-10 18:25:40 +0000 |
| commit | 2c07e78efc0e8ab7150eef7ae92af32b2389146a (patch) | |
| tree | 3c599a72a1ad318f3deaaf6d02334c4f0c936a0f /firmware/mp3data.c | |
| parent | 6475aa0c85fcca7a37a7aa4316173270fcb6d038 (diff) | |
| download | rockbox-2c07e78efc0e8ab7150eef7ae92af32b2389146a.zip rockbox-2c07e78efc0e8ab7150eef7ae92af32b2389146a.tar.gz rockbox-2c07e78efc0e8ab7150eef7ae92af32b2389146a.tar.bz2 rockbox-2c07e78efc0e8ab7150eef7ae92af32b2389146a.tar.xz | |
Don't accidentally add Xing headers to CBR files
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3419 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/mp3data.c')
| -rw-r--r-- | firmware/mp3data.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/firmware/mp3data.c b/firmware/mp3data.c index 21f01ea..f38b51c 100644 --- a/firmware/mp3data.c +++ b/firmware/mp3data.c @@ -555,9 +555,9 @@ int count_mp3_frames(int fd, int startpos, int filesize, int cnt; int progress_chunk = filesize / 50; /* Max is 50%, in 1% increments */ int progress_cnt = 0; + bool is_vbr = false; + int last_bitrate = 0; - /* Nasty stuff to avoid passing the file handle around */ - if(lseek(fd, startpos, SEEK_SET) < 0) return -1; @@ -569,6 +569,14 @@ int count_mp3_frames(int fd, int startpos, int filesize, while((header = buf_find_next_frame(fd, &bytes, -1, header))) { mp3headerinfo(&info, header); + + /* See if this really is a VBR file */ + if(last_bitrate && info.bitrate != last_bitrate) + { + is_vbr = true; + } + last_bitrate = info.bitrate; + buf_seek(fd, info.frame_size-4); num_frames++; if(progressfunc) @@ -583,8 +591,14 @@ int count_mp3_frames(int fd, int startpos, int filesize, } } DEBUGF("Total number of frames: %d\n", num_frames); - - return num_frames; + + if(is_vbr) + return num_frames; + else + { + DEBUGF("Not a VBR file\n"); + return 0; + } } int create_xing_header(int fd, int startpos, int filesize, |