summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorroman.artiukhin <bahusdrive@gmail.com>2023-08-31 02:09:40 +0300
committerSolomon Peachy <pizza@shaftnet.org>2023-09-29 08:21:27 -0400
commitd05f6aac2d51b2c284b8185bc34383e62e2fb21f (patch)
treee600bca6085e5a8270eca487be1af77326c1b5bb /lib
parentfee50135149fbec0e5973caaa528826c256c66ac (diff)
downloadrockbox-d05f6aac2d51b2c284b8185bc34383e62e2fb21f.tar.gz
rockbox-d05f6aac2d51b2c284b8185bc34383e62e2fb21f.zip
Codecs: mp4: Skip FOURCC filetype chunk check
Instead of FOURCC it needs ignore-case text match. Also value can contain \0 ('m4a\0' instead of expected 'm4a ').But let's simply skip it and let decoder handle it. Change-Id: I87eefcabbc9010481286257c26cee09e61d1221c
Diffstat (limited to 'lib')
-rw-r--r--lib/rbcodec/codecs/libm4a/demux.c17
-rw-r--r--lib/rbcodec/metadata/mp4.c23
2 files changed, 8 insertions, 32 deletions
diff --git a/lib/rbcodec/codecs/libm4a/demux.c b/lib/rbcodec/codecs/libm4a/demux.c
index 47cce9857f..2b56759b9c 100644
--- a/lib/rbcodec/codecs/libm4a/demux.c
+++ b/lib/rbcodec/codecs/libm4a/demux.c
@@ -56,22 +56,13 @@ typedef struct
56/* chunk handlers */ 56/* chunk handlers */
57static void read_chunk_ftyp(qtmovie_t *qtmovie, size_t chunk_len) 57static void read_chunk_ftyp(qtmovie_t *qtmovie, size_t chunk_len)
58{ 58{
59 fourcc_t type;
60 size_t size_remaining = chunk_len - 8; 59 size_t size_remaining = chunk_len - 8;
61 60
62 type = stream_read_uint32(qtmovie->stream); 61 // filetype (supported ignore case values: m4a, m4b, mp42, 3gp6, qt, isom)
62 char filetype[4];
63 stream_read(qtmovie->stream, 4, filetype);
63 size_remaining-=4; 64 size_remaining-=4;
64 if ((type != MAKEFOURCC('M','4','A',' ')) && 65
65 (type != MAKEFOURCC('m','4','a',' ')) &&
66 (type != MAKEFOURCC('M','4','B',' ')) &&
67 (type != MAKEFOURCC('m','p','4','2')) &&
68 (type != MAKEFOURCC('3','g','p','6')) &&
69 (type != MAKEFOURCC('q','t',' ',' ')) &&
70 (type != MAKEFOURCC('i','s','o','m')))
71 {
72 DEBUGF("not M4A file\n");
73 return;
74 }
75 /* minor_ver = */ stream_read_uint32(qtmovie->stream); 66 /* minor_ver = */ stream_read_uint32(qtmovie->stream);
76 size_remaining-=4; 67 size_remaining-=4;
77 68
diff --git a/lib/rbcodec/metadata/mp4.c b/lib/rbcodec/metadata/mp4.c
index 1540e93738..e05a588e7e 100644
--- a/lib/rbcodec/metadata/mp4.c
+++ b/lib/rbcodec/metadata/mp4.c
@@ -57,10 +57,6 @@
57#define MP4_gnre FOURCC('g', 'n', 'r', 'e') 57#define MP4_gnre FOURCC('g', 'n', 'r', 'e')
58#define MP4_hdlr FOURCC('h', 'd', 'l', 'r') 58#define MP4_hdlr FOURCC('h', 'd', 'l', 'r')
59#define MP4_ilst FOURCC('i', 'l', 's', 't') 59#define MP4_ilst FOURCC('i', 'l', 's', 't')
60#define MP4_isom FOURCC('i', 's', 'o', 'm')
61#define MP4_M4A FOURCC('M', '4', 'A', ' ')
62#define MP4_m4a FOURCC('m', '4', 'a', ' ') /*technically its "M4A "*/
63#define MP4_M4B FOURCC('M', '4', 'B', ' ') /*but files exist with lower case*/
64#define MP4_mdat FOURCC('m', 'd', 'a', 't') 60#define MP4_mdat FOURCC('m', 'd', 'a', 't')
65#define MP4_mdia FOURCC('m', 'd', 'i', 'a') 61#define MP4_mdia FOURCC('m', 'd', 'i', 'a')
66#define MP4_mdir FOURCC('m', 'd', 'i', 'r') 62#define MP4_mdir FOURCC('m', 'd', 'i', 'r')
@@ -68,8 +64,6 @@
68#define MP4_minf FOURCC('m', 'i', 'n', 'f') 64#define MP4_minf FOURCC('m', 'i', 'n', 'f')
69#define MP4_moov FOURCC('m', 'o', 'o', 'v') 65#define MP4_moov FOURCC('m', 'o', 'o', 'v')
70#define MP4_mp4a FOURCC('m', 'p', '4', 'a') 66#define MP4_mp4a FOURCC('m', 'p', '4', 'a')
71#define MP4_mp42 FOURCC('m', 'p', '4', '2')
72#define MP4_qt FOURCC('q', 't', ' ', ' ')
73#define MP4_soun FOURCC('s', 'o', 'u', 'n') 67#define MP4_soun FOURCC('s', 'o', 'u', 'n')
74#define MP4_stbl FOURCC('s', 't', 'b', 'l') 68#define MP4_stbl FOURCC('s', 't', 'b', 'l')
75#define MP4_stsd FOURCC('s', 't', 's', 'd') 69#define MP4_stsd FOURCC('s', 't', 's', 'd')
@@ -618,20 +612,11 @@ static bool read_mp4_container(int fd, struct mp3entry* id3,
618 { 612 {
619 case MP4_ftyp: 613 case MP4_ftyp:
620 { 614 {
621 uint32_t id; 615 // filetype (supported ignore case values: m4a, m4b, mp42, 3gp6, qt, isom)
622 616 char filetype[4];
623 read_uint32be(fd, &id); 617 read(fd, &filetype, 4);
618 DEBUGF("MP4 file type: '%.4s'\n", filetype);
624 size -= 4; 619 size -= 4;
625
626 if ((id != MP4_M4A) && (id != MP4_M4B) && (id != MP4_mp42)
627 && (id != MP4_qt) && (id != MP4_3gp6) && (id != MP4_m4a)
628 && (id != MP4_isom))
629 {
630 DEBUGF("Unknown MP4 file type: '%c%c%c%c'\n",
631 (int)(id >> 24 & 0xff), (int)(id >> 16 & 0xff),
632 (int)(id >> 8 & 0xff), (int)(id & 0xff));
633 return false;
634 }
635 } 620 }
636 break; 621 break;
637 622