diff --git a/Plugins/MAD/MADDecoder.m b/Plugins/MAD/MADDecoder.m index 7aa7b8f24..a909a758b 100644 --- a/Plugins/MAD/MADDecoder.m +++ b/Plugins/MAD/MADDecoder.m @@ -178,6 +178,8 @@ } free(tagBuffer); + } else if(stream.error == MAD_ERROR_BADDATAPTR) { + goto framedecoded; } continue; @@ -190,6 +192,7 @@ break; } } + framedecoded: framesDecoded++; if(framesDecoded == 1) { diff --git a/ThirdParty/libmad/README.md b/ThirdParty/libmad/README.md index 8e6dbd2e8..c23d5642d 100644 --- a/ThirdParty/libmad/README.md +++ b/ThirdParty/libmad/README.md @@ -1,6 +1,8 @@ -Built with the Homebrew defaults, sort of: +Built with the Homebrew defaults, sort of. Plus a patch to fix weird LAME/Xing +headers: ``` +patch -Np1 -i libmad_ancdata.patch touch NEWS touch AUTHORS touch ChangeLog @@ -9,4 +11,4 @@ autoreconf -fiv make -j8 CFLAGS="-Os -arch x86_64 -arch arm64 -mmacosx-version-min=10.12" LDFLAGS="-arch x86_64 -arch arm64 -mmacosx-version-min=10.12" ``` -Version 0.15.1b was used. +Version 0.15.1b was used, with the minor patch listed above. diff --git a/ThirdParty/libmad/lib/libmad.a b/ThirdParty/libmad/lib/libmad.a index 4122a9d1d..38609e294 100644 Binary files a/ThirdParty/libmad/lib/libmad.a and b/ThirdParty/libmad/lib/libmad.a differ diff --git a/ThirdParty/libmad/patches/libmad_ancdata.patch b/ThirdParty/libmad/patches/libmad_ancdata.patch new file mode 100644 index 000000000..0e3c56d07 --- /dev/null +++ b/ThirdParty/libmad/patches/libmad_ancdata.patch @@ -0,0 +1,29 @@ +diff -urN libmad-0.15.1b.orig/frame.c libmad-0.15.1b.patched/frame.c +--- libmad-0.15.1b.orig/frame.c 2022-06-19 17:20:02.000000000 -0700 ++++ libmad-0.15.1b.patched/frame.c 2022-06-19 18:18:39.000000000 -0700 +@@ -473,7 +473,9 @@ + return 0; + + fail: +- stream->anc_bitlen = 0; ++ if(stream->error != MAD_ERROR_BADDATAPTR) { ++ stream->anc_bitlen = 0; ++ } + return -1; + } + +diff -urN libmad-0.15.1b.orig/layer3.c libmad-0.15.1b.patched/layer3.c +--- libmad-0.15.1b.orig/layer3.c 2022-06-19 17:20:02.000000000 -0700 ++++ libmad-0.15.1b.patched/layer3.c 2022-06-19 18:18:47.000000000 -0700 +@@ -2656,6 +2656,11 @@ + stream->anc_ptr = ptr; + stream->anc_bitlen = md_len * CHAR_BIT - data_bitlen; + } ++ else { ++ /* Give it the rest of the frame */ ++ stream->anc_ptr = stream->ptr; ++ stream->anc_bitlen = frame_free * CHAR_BIT; ++ } + + # if 0 && defined(DEBUG) + fprintf(stderr,