Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions libmatroska2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ project("matroska2" VERSION 0.22.3 LANGUAGES C)
option(CONFIG_ZLIB "Enable zlib (de)compression" ON)
option(CONFIG_BZLIB "Enable bzlib decompression in libmatroska2" ON)
option(CONFIG_LZO1X "Enable lzo decompression in libmatroska2" ON)
option(CONFIG_ZSTD "Enable Zstandard/zstd (de)compression in libmatroska2" ON)
option(CONFIG_CODEC_HELPER "Enable Vorbis frame durations in libmatroska2" ON)

if (CONFIG_ZLIB)
Expand All @@ -26,6 +27,30 @@ if (CONFIG_ZLIB)
endif()
endif()

if (CONFIG_ZSTD)
# find_package(Zstd)

# if(NOT Zstd_FOUND)
include(FetchContent)

set(ZSTD_BUILD_STATIC ON)
set(ZSTD_BUILD_SHARED OFF)
set(ZSTD_BUILD_PROGRAMS OFF)
set(ZSTD_BUILD_TESTS OFF)
set(ZSTD_LEGACY_SUPPORT OFF)

FetchContent_Declare(
zstd
URL "https://github.com/facebook/zstd/releases/download/v1.5.7/zstd-1.5.7.tar.gz"
URL_HASH SHA256=eb33e51f49a15e023950cd7825ca74a4a2b43db8354825ac24fc1b7ee09e6fa3
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
SOURCE_SUBDIR build/cmake
)

FetchContent_MakeAvailable(zstd)
# endif()
endif(CONFIG_ZSTD)

set(matroska2_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/matroskamain.c
${CMAKE_CURRENT_SOURCE_DIR}/matroskablock.c
Expand Down Expand Up @@ -76,6 +101,11 @@ if (CONFIG_BZLIB)
endif()
endif(CONFIG_BZLIB)

if (CONFIG_ZSTD)
target_include_directories("matroska2" PRIVATE ${zstd_SOURCE_DIR}/lib)
target_link_libraries("matroska2" PRIVATE $<BUILD_INTERFACE:libzstd_static>)
endif(CONFIG_ZSTD)

if (CONFIG_CODEC_HELPER)
add_subdirectory("tremor")
target_link_libraries("matroska2" PRIVATE $<BUILD_INTERFACE:tremor>)
Expand Down
8 changes: 8 additions & 0 deletions libmatroska2/matroska2/matroska.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,14 @@ static INLINE err_t CompressFrameZLib(const uint8_t * UNUSED_PARAM(Cursor), size
return ERR_NOT_SUPPORTED;
}
#endif // !CONFIG_ZLIB
#if defined(CONFIG_ZSTD)
MATROSKA_DLL err_t CompressFrameZstd(const uint8_t *Cursor, size_t CursorSize, uint8_t **OutBuf, size_t *OutSize);
#else // !CONFIG_ZLIB
static INLINE err_t CompressFrameZstd(const uint8_t * UNUSED_PARAM(Cursor), size_t UNUSED_PARAM(CursorSize), uint8_t ** UNUSED_PARAM(OutBuf), size_t * UNUSED_PARAM(OutSize))
{
return ERR_NOT_SUPPORTED;
}
#endif // !CONFIG_ZLIB
#endif

MATROSKA_DLL void MATROSKA_ClusterSort(matroska_cluster *Cluster); // not good with P frames!!!
Expand Down
1 change: 1 addition & 0 deletions libmatroska2/matroska2/matroska_sem.h
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ typedef enum {
MATROSKA_TRACK_ENCODING_COMP_BZLIB = 1, // bzip2 compression (BZIP2) **SHOULD NOT** be used.
MATROSKA_TRACK_ENCODING_COMP_LZO1X = 2, // Lempel-Ziv-Oberhumer compression (LZO) **SHOULD NOT** be used.
MATROSKA_TRACK_ENCODING_COMP_HEADERSTRIP = 3, // Octets in ContentCompSettings ((#contentcompsettings-element)) have been stripped from each frame.
MATROSKA_TRACK_ENCODING_COMP_ZSTD = 4, // Zstandard (zstd).
} MatroskaTrackEncodingCompAlgo;

/**
Expand Down
1 change: 1 addition & 0 deletions libmatroska2/matroska_config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#cmakedefine CONFIG_ZLIB
#cmakedefine CONFIG_LZO1X
#cmakedefine CONFIG_BZLIB
#cmakedefine CONFIG_ZSTD
#cmakedefine CONFIG_CODEC_HELPER

#define LIBMATROSKA2_PROJECT_VERSION T("@matroska2_VERSION_MAJOR@.@matroska2_VERSION_MINOR@.@matroska2_VERSION_PATCH@")
Expand Down
Loading