add gapless playback for Nero encoded AAC files
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22984 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
67ded6ce9d
commit
c48af23c7e
3 changed files with 38 additions and 0 deletions
|
@ -124,6 +124,21 @@ int read_uint32be(int fd, uint32_t* buf)
|
|||
*buf = betoh32(*buf);
|
||||
return n;
|
||||
}
|
||||
/* Read an unsigned 64-bit integer from a big-endian file. */
|
||||
int read_uint64be(int fd, uint64_t* buf)
|
||||
{
|
||||
size_t n;
|
||||
uint8_t data[8];
|
||||
int i;
|
||||
|
||||
n = read(fd, data, 8);
|
||||
|
||||
for (i=0, *buf=0; i<=7; i++) {
|
||||
*buf <<= 8;
|
||||
*buf |= data[i];
|
||||
}
|
||||
return n;
|
||||
}
|
||||
#else
|
||||
/* Read unsigned integers from a little-endian file. */
|
||||
int read_uint16le(int fd, uint16_t* buf)
|
||||
|
|
|
@ -42,12 +42,14 @@ int read_uint8(int fd, uint8_t* buf);
|
|||
#ifdef ROCKBOX_BIG_ENDIAN
|
||||
#define read_uint16be(fd,buf) read((fd), (buf), 2)
|
||||
#define read_uint32be(fd,buf) read((fd), (buf), 4)
|
||||
#define read_uint64be(fd,buf) read((fd), (buf), 8)
|
||||
int read_uint16le(int fd, uint16_t* buf);
|
||||
int read_uint32le(int fd, uint32_t* buf);
|
||||
int read_uint64le(int fd, uint64_t* buf);
|
||||
#else
|
||||
int read_uint16be(int fd, uint16_t* buf);
|
||||
int read_uint32be(int fd, uint32_t* buf);
|
||||
int read_uint64be(int fd, uint64_t* buf);
|
||||
#define read_uint16le(fd,buf) read((fd), (buf), 2)
|
||||
#define read_uint32le(fd,buf) read((fd), (buf), 4)
|
||||
#define read_uint64le(fd,buf) read((fd), (buf), 8)
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
#define MP4_cART MP4_ID(0xa9, 'A', 'R', 'T')
|
||||
#define MP4_cgrp MP4_ID(0xa9, 'g', 'r', 'p')
|
||||
#define MP4_cgen MP4_ID(0xa9, 'g', 'e', 'n')
|
||||
#define MP4_chpl MP4_ID('c', 'h', 'p', 'l')
|
||||
#define MP4_cnam MP4_ID(0xa9, 'n', 'a', 'm')
|
||||
#define MP4_cwrt MP4_ID(0xa9, 'w', 'r', 't')
|
||||
#define MP4_ccmt MP4_ID(0xa9, 'c', 'm', 't')
|
||||
|
@ -681,6 +682,26 @@ static bool read_mp4_container(int fd, struct mp3entry* id3,
|
|||
id3->filesize = size;
|
||||
break;
|
||||
|
||||
case MP4_chpl:
|
||||
{
|
||||
/* ADDME: add support for real chapters. Right now it's only
|
||||
* used for Nero's gapless hack */
|
||||
uint8_t chapters;
|
||||
uint64_t timestamp;
|
||||
|
||||
lseek(fd, 8, SEEK_CUR);
|
||||
read_uint8(fd, &chapters);
|
||||
size -= 9;
|
||||
|
||||
/* the first chapter will be used as the lead_trim */
|
||||
if (chapters > 0) {
|
||||
read_uint64be(fd, ×tamp);
|
||||
id3->lead_trim = (timestamp * id3->frequency) / 10000000;
|
||||
size -= 8;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue