From 9c91e1f58a79b3be3fc7a4f9fa3a030e76ba5174 Mon Sep 17 00:00:00 2001 From: Jamiras Date: Wed, 1 Jan 2025 11:54:05 -0700 Subject: [PATCH 1/3] update libchdr --- Makefile.common | 66 ++++++++++++++----------- src/libchdr | 2 +- src/libchdr.vcxproj | 97 +++++++++++++++++-------------------- src/libchdr.vcxproj.filters | 96 +++++++++++++++++++++++++----------- 4 files changed, 154 insertions(+), 107 deletions(-) diff --git a/Makefile.common b/Makefile.common index a803a29..aadaae7 100644 --- a/Makefile.common +++ b/Makefile.common @@ -51,33 +51,45 @@ endif ifdef HAVE_CHD CXXFLAGS += -DHAVE_CHD -I./src/libchdr/include - CFLAGS += -D_7ZIP_ST -I./src/libchdr/include -I./src/libchdr/deps/lzma-22.01/include -I./src/libchdr/deps/zlib-1.2.12 - CHD_OBJS = src/libchdr/deps/lzma-22.01/src/Alloc.o \ - src/libchdr/deps/lzma-22.01/src/Bra86.o \ - src/libchdr/deps/lzma-22.01/src/BraIA64.o \ - src/libchdr/deps/lzma-22.01/src/CpuArch.o \ - src/libchdr/deps/lzma-22.01/src/Delta.o \ - src/libchdr/deps/lzma-22.01/src/LzFind.o \ - src/libchdr/deps/lzma-22.01/src/Lzma86Dec.o \ - src/libchdr/deps/lzma-22.01/src/Lzma86Enc.o \ - src/libchdr/deps/lzma-22.01/src/LzmaDec.o \ - src/libchdr/deps/lzma-22.01/src/LzmaEnc.o \ - src/libchdr/deps/lzma-22.01/src/Sort.o \ - src/libchdr/deps/zlib-1.2.12/adler32.o \ - src/libchdr/deps/zlib-1.2.12/compress.o \ - src/libchdr/deps/zlib-1.2.12/crc32.o \ - src/libchdr/deps/zlib-1.2.12/deflate.o \ - src/libchdr/deps/zlib-1.2.12/gzclose.o \ - src/libchdr/deps/zlib-1.2.12/gzlib.o \ - src/libchdr/deps/zlib-1.2.12/gzread.o \ - src/libchdr/deps/zlib-1.2.12/gzwrite.o \ - src/libchdr/deps/zlib-1.2.12/infback.o \ - src/libchdr/deps/zlib-1.2.12/inffast.o \ - src/libchdr/deps/zlib-1.2.12/inflate.o \ - src/libchdr/deps/zlib-1.2.12/inftrees.o \ - src/libchdr/deps/zlib-1.2.12/trees.o \ - src/libchdr/deps/zlib-1.2.12/uncompr.o \ - src/libchdr/deps/zlib-1.2.12/zutil.o \ + CFLAGS += -DZ7_ST -I./src/libchdr/include -I./src/libchdr/deps/lzma-24.05/include -I./src/libchdr/deps/zlib-1.3.1 -I./src/libchdr/deps/zstd-1.5.6/lib + CHD_OBJS = src/libchdr/deps/lzma-24.05/src/Alloc.o \ + src/libchdr/deps/lzma-24.05/src/Bra86.o \ + src/libchdr/deps/lzma-24.05/src/BraIA64.o \ + src/libchdr/deps/lzma-24.05/src/CpuArch.o \ + src/libchdr/deps/lzma-24.05/src/Delta.o \ + src/libchdr/deps/lzma-24.05/src/LzFind.o \ + src/libchdr/deps/lzma-24.05/src/Lzma86Dec.o \ + src/libchdr/deps/lzma-24.05/src/Lzma86Enc.o \ + src/libchdr/deps/lzma-24.05/src/LzmaDec.o \ + src/libchdr/deps/lzma-24.05/src/LzmaEnc.o \ + src/libchdr/deps/lzma-24.05/src/Sort.o \ + src/libchdr/deps/zlib-1.3.1/adler32.o \ + src/libchdr/deps/zlib-1.3.1/compress.o \ + src/libchdr/deps/zlib-1.3.1/crc32.o \ + src/libchdr/deps/zlib-1.3.1/deflate.o \ + src/libchdr/deps/zlib-1.3.1/gzclose.o \ + src/libchdr/deps/zlib-1.3.1/gzlib.o \ + src/libchdr/deps/zlib-1.3.1/gzread.o \ + src/libchdr/deps/zlib-1.3.1/gzwrite.o \ + src/libchdr/deps/zlib-1.3.1/infback.o \ + src/libchdr/deps/zlib-1.3.1/inffast.o \ + src/libchdr/deps/zlib-1.3.1/inflate.o \ + src/libchdr/deps/zlib-1.3.1/inftrees.o \ + src/libchdr/deps/zlib-1.3.1/trees.o \ + src/libchdr/deps/zlib-1.3.1/uncompr.o \ + src/libchdr/deps/zlib-1.3.1/zutil.o \ + src/libchdr/deps/zstd-1.5.6/lib/common/debug.o \ + src/libchdr/deps/zstd-1.5.6/lib/common/entropy_common.o \ + src/libchdr/deps/zstd-1.5.6/lib/common/error_private.o \ + src/libchdr/deps/zstd-1.5.6/lib/common/fse_decompress.o \ + src/libchdr/deps/zstd-1.5.6/lib/common/pool.o \ + src/libchdr/deps/zstd-1.5.6/lib/common/threading.o \ + src/libchdr/deps/zstd-1.5.6/lib/common/xxhash.o \ + src/libchdr/deps/zstd-1.5.6/lib/common/zstd_common.o \ + src/libchdr/deps/zstd-1.5.6/lib/decompress/huf_decompress.o \ + src/libchdr/deps/zstd-1.5.6/lib/decompress/zstd_ddict.o \ + src/libchdr/deps/zstd-1.5.6/lib/decompress/zstd_decompress.o \ + src/libchdr/deps/zstd-1.5.6/lib/decompress/zstd_decompress_block.o \ src/libchdr/src/libchdr_bitstream.o \ src/libchdr/src/libchdr_cdrom.o \ src/libchdr/src/libchdr_chd.o \ diff --git a/src/libchdr b/src/libchdr index fec8ab9..cb07733 160000 --- a/src/libchdr +++ b/src/libchdr @@ -1 +1 @@ -Subproject commit fec8ab94212cc65d9d9a62cb3da924f5830c04b0 +Subproject commit cb077337d53392454e7100a0fd07139ca678e527 diff --git a/src/libchdr.vcxproj b/src/libchdr.vcxproj index b8bed85..ec49b97 100644 --- a/src/libchdr.vcxproj +++ b/src/libchdr.vcxproj @@ -55,9 +55,9 @@ MaxSpeed true true - WIN32;_7ZIP_ST;NDEBUG;_LIB;%(PreprocessorDefinitions) + WIN32;Z7_ST;NDEBUG;_LIB;%(PreprocessorDefinitions) CompileAsC - $(ProjectDir)libchdr\include;$(ProjectDir)libchdr\deps\lzma-22.01\include;$(ProjectDir)libchdr\deps\zlib-1.2.12;%(AdditionalIncludeDirectories) + $(ProjectDir)libchdr\include;$(ProjectDir)libchdr\deps\lzma-24.05\include;$(ProjectDir)libchdr\deps\zstd-1.5.6\lib;$(ProjectDir)libchdr\deps\zlib-1.3.1;%(AdditionalIncludeDirectories) false true Level2 @@ -69,22 +69,18 @@ true true - true - - IF NOT EXIST $(ProjectDir)libchdr\deps\zalib-1.2.12\zconf.h COPY $(ProjectDir)libchdr\deps\zlib-1.2.12\zconf.h.included $(ProjectDir)libchdr\deps\zlib-1.2.12\zconf.h - MaxSpeed true true - WIN32;_7ZIP_ST;NDEBUG;_LIB;%(PreprocessorDefinitions) + WIN32;Z7_ST;NDEBUG;_LIB;%(PreprocessorDefinitions) CompileAsC - $(ProjectDir)libchdr\include;$(ProjectDir)libchdr\deps\lzma-22.01\include;$(ProjectDir)libchdr\deps\zlib-1.2.12;%(AdditionalIncludeDirectories) + $(ProjectDir)libchdr\include;$(ProjectDir)libchdr\deps\lzma-24.05\include;$(ProjectDir)libchdr\deps\zstd-1.5.6\lib;$(ProjectDir)libchdr\deps\zlib-1.3.1;%(AdditionalIncludeDirectories) false true Level2 @@ -97,20 +93,16 @@ true true - true - - IF NOT EXIST $(ProjectDir)libchdr\deps\zalib-1.2.12\zconf.h COPY $(ProjectDir)libchdr\deps\zlib-1.2.12\zconf.h.included $(ProjectDir)libchdr\deps\zlib-1.2.12\zconf.h - Disabled - WIN32;_7ZIP_ST;_DEBUG;_LIB;%(PreprocessorDefinitions) + WIN32;Z7_ST;_DEBUG;_LIB;%(PreprocessorDefinitions) CompileAsC - $(ProjectDir)libchdr\include;$(ProjectDir)libchdr\deps\lzma-22.01\include;$(ProjectDir)libchdr\deps\zlib-1.2.12;%(AdditionalIncludeDirectories) + $(ProjectDir)libchdr\include;$(ProjectDir)libchdr\deps\lzma-24.05\include;$(ProjectDir)libchdr\deps\zstd-1.5.6\lib;$(ProjectDir)libchdr\deps\zlib-1.3.1;%(AdditionalIncludeDirectories) false MultiThreadedDebug true @@ -120,18 +112,13 @@ Windows true - - - - IF NOT EXIST $(ProjectDir)libchdr\deps\zalib-1.2.12\zconf.h COPY $(ProjectDir)libchdr\deps\zlib-1.2.12\zconf.h.included $(ProjectDir)libchdr\deps\zlib-1.2.12\zconf.h - Disabled - WIN32;_7ZIP_ST;_DEBUG;_LIB;%(PreprocessorDefinitions) + WIN32;Z7_ST;_DEBUG;_LIB;%(PreprocessorDefinitions) CompileAsC - $(ProjectDir)libchdr\include;$(ProjectDir)libchdr\deps\lzma-22.01\include;$(ProjectDir)libchdr\deps\zlib-1.2.12;%(AdditionalIncludeDirectories) + $(ProjectDir)libchdr\include;$(ProjectDir)libchdr\deps\lzma-24.05\include;$(ProjectDir)libchdr\deps\zstd-1.5.6\lib;$(ProjectDir)libchdr\deps\zlib-1.3.1;%(AdditionalIncludeDirectories) false MultiThreadedDebug true @@ -142,39 +129,45 @@ Windows true - - - - IF NOT EXIST $(ProjectDir)libchdr\deps\zalib-1.2.12\zconf.h COPY $(ProjectDir)libchdr\deps\zlib-1.2.12\zconf.h.included $(ProjectDir)libchdr\deps\zlib-1.2.12\zconf.h - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/libchdr.vcxproj.filters b/src/libchdr.vcxproj.filters index c70f5b3..330f484 100644 --- a/src/libchdr.vcxproj.filters +++ b/src/libchdr.vcxproj.filters @@ -10,6 +10,15 @@ {ad972f61-02df-4c5a-af25-b997be37894e} + + {b2f0fccc-ffbd-4f14-8ca3-932cbaa6f40a} + + + {71dd06ce-b02e-479d-b4a3-925e844d3690} + + + {c00242e4-c3dc-4570-8f3f-ee04033a440c} + @@ -27,83 +36,116 @@ libchdr - + zlib - + zlib - + zlib - + zlib - + zlib - + zlib - + zlib - + zlib - + zlib - + zlib - + zlib - + zlib - + zlib - + zlib - + zlib - + lzma - + lzma - + lzma - + lzma - + lzma - + lzma - + lzma - + lzma - + lzma - + lzma - - lzma + + zstd\common + + + zstd\common + + + zstd\common + + + zstd\common + + + zstd\common + + + zstd\common + + + zstd\common + + + zstd\common + + + zstd\decompress + + + zstd\decompress + + + zstd\decompress + + + zstd\decompress \ No newline at end of file From 8e941cf4f4d13bf7b3ade075a36b98ce32b4484c Mon Sep 17 00:00:00 2001 From: Jamiras Date: Wed, 1 Jan 2025 12:46:03 -0700 Subject: [PATCH 2/3] fix linux build of RAHasher --- Makefile.common | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Makefile.common b/Makefile.common index aadaae7..954d405 100644 --- a/Makefile.common +++ b/Makefile.common @@ -51,7 +51,7 @@ endif ifdef HAVE_CHD CXXFLAGS += -DHAVE_CHD -I./src/libchdr/include - CFLAGS += -DZ7_ST -I./src/libchdr/include -I./src/libchdr/deps/lzma-24.05/include -I./src/libchdr/deps/zlib-1.3.1 -I./src/libchdr/deps/zstd-1.5.6/lib + CFLAGS += -DZ7_ST -DZSTD_DISABLE_ASM -I./src/libchdr/include -I./src/libchdr/deps/lzma-24.05/include -I./src/libchdr/deps/zlib-1.3.1 -I./src/libchdr/deps/zstd-1.5.6/lib CHD_OBJS = src/libchdr/deps/lzma-24.05/src/Alloc.o \ src/libchdr/deps/lzma-24.05/src/Bra86.o \ src/libchdr/deps/lzma-24.05/src/BraIA64.o \ @@ -59,7 +59,6 @@ ifdef HAVE_CHD src/libchdr/deps/lzma-24.05/src/Delta.o \ src/libchdr/deps/lzma-24.05/src/LzFind.o \ src/libchdr/deps/lzma-24.05/src/Lzma86Dec.o \ - src/libchdr/deps/lzma-24.05/src/Lzma86Enc.o \ src/libchdr/deps/lzma-24.05/src/LzmaDec.o \ src/libchdr/deps/lzma-24.05/src/LzmaEnc.o \ src/libchdr/deps/lzma-24.05/src/Sort.o \ @@ -95,4 +94,4 @@ ifdef HAVE_CHD src/libchdr/src/libchdr_chd.o \ src/libchdr/src/libchdr_flac.o \ src/libchdr/src/libchdr_huffman.o -endif \ No newline at end of file +endif From c393db63f0643572eaa2fc76a2e40fe911368a06 Mon Sep 17 00:00:00 2001 From: Jamiras Date: Thu, 2 Jan 2025 08:30:24 -0700 Subject: [PATCH 3/3] provide basic CHD DVD track support --- src/HashCHD.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/HashCHD.cpp b/src/HashCHD.cpp index a54aa94..76ed98b 100644 --- a/src/HashCHD.cpp +++ b/src/HashCHD.cpp @@ -92,6 +92,21 @@ static bool rc_hash_get_chd_metadata(chd_file* file, uint32_t idx, metadata_t* m return true; } + /* DVD formatted track is not yet supported by libchdr, but we can fake it. A DVD only has one track, so + * if we're looking for the first metadata, and haven't found it yet, look for the DVD tag and go with it. */ + if (idx == 0) + { + err = chd_get_metadata(file, CHD_MAKE_TAG('D', 'V', 'D', ' '), idx, meta, sizeof(meta), &meta_size, NULL, NULL); + if (err == CHDERR_NONE) + { + /* DVD-ROM track doesn't have metadata. It's just raw 2048 byte sectors with no header/footer (MODE1) */ + memset(metadata, 0, sizeof(metadata)); + metadata->track = 1; + memcpy(metadata->type, "MODE1", strlen("MODE1") + 1); + return true; + } + } + return false; } @@ -240,7 +255,7 @@ static void* rc_hash_handle_chd_open_track(const char* path, uint32_t track) chd_error err = chd_open(path, CHD_OPEN_READ, NULL, &file); if (err != CHDERR_NONE) { char errmessage[128]; - snprintf(errmessage, sizeof(errmessage), "CHD %s", chd_error_string(err)); + snprintf(errmessage, sizeof(errmessage), "chd_open failed: %s", chd_error_string(err)); rc_hash_error(errmessage); return NULL; }