diff --git a/.gitignore b/.gitignore index f841751f..6a9b7db1 100644 --- a/.gitignore +++ b/.gitignore @@ -82,3 +82,6 @@ tests/granulepos_theoraenc tests/noop tests/noop_theora tests/noop_theoraenc + +.vs/ +out/ \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..39966879 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,114 @@ +cmake_minimum_required(VERSION 3.0) +project(theora LANGUAGES C) + +enable_testing() + +set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}") +FIND_PACKAGE(Ogg REQUIRED) + +file(GLOB HEADERS + "include/theora/codec.h" + "include/theora/theora.h" + "include/theora/theoradec.h" + "include/theora/theoraenc.h" +) + +set(LIBTHEORA_COMMON + "lib/apiwrapper.c" + "lib/bitpack.c" + "lib/dequant.c" + "lib/fragment.c" + "lib/idct.c" + "lib/info.c" + "lib/internal.c" + "lib/state.c" + "lib/quant.c" + + "lib/x86_vc/mmxfrag.c" + "lib/x86_vc/mmxidct.c" + "lib/x86_vc/mmxstate.c" + "lib/x86_vc/x86cpu.c" + "lib/x86_vc/x86state.c" +) + +set(LIBTHEORA_ENC + "lib/analyze.c" + "lib/encapiwrapper.c" + "lib/encfrag.c" + "lib/encinfo.c" + "lib/encode.c" + "lib/enquant.c" + "lib/fdct.c" + "lib/huffenc.c" + "lib/mathops.c" + "lib/mcenc.c" + "lib/rate.c" + "lib/tokenize.c" + + "lib/x86_vc/mmxencfrag.c" + "lib/x86_vc/mmxfdct.c" + "lib/x86_vc/x86enc.c" +) + +set(LIBTHEORA_DEC + "lib/decapiwrapper.c" + "lib/decinfo.c" + "lib/decode.c" + "lib/huffdec.c" +) + +add_definitions(-D_CRT_SECURE_NO_DEPRECATE) +add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE) + +option(USE_X86 "Use x86 optimization" OFF) +if(USE_X86) + add_definitions(-DOC_X86_ASM) +endif() + +add_library(theora-common OBJECT ${LIBTHEORA_COMMON} ${HEADERS}) +target_link_libraries(theora-common PUBLIC Ogg::ogg) +target_include_directories(theora-common PUBLIC $ $) +add_library(theora-enc OBJECT ${LIBTHEORA_ENC} ${HEADERS}) +target_link_libraries(theora-enc PUBLIC Ogg::ogg) +target_include_directories(theora-enc PUBLIC $ $) +add_library(theora-dec OBJECT ${LIBTHEORA_DEC} ${HEADERS}) +target_link_libraries(theora-dec PUBLIC Ogg::ogg) +target_include_directories(theora-dec PUBLIC $ $) + +add_library(theora $ $ $ "win32/xmingw32/libtheora.def") +target_link_libraries(theora PUBLIC Ogg::ogg) +target_include_directories(theora PUBLIC $ $) + +add_library(theoraenc $ $ "win32/xmingw32/libtheoraenc-all.def") +target_link_libraries(theoraenc PUBLIC Ogg::ogg) +target_include_directories(theoraenc PUBLIC $ $) + +add_library(theoradec $ $ "win32/xmingw32/libtheoradec-all.def") +target_link_libraries(theoradec PUBLIC Ogg::ogg) +target_include_directories(theoradec PUBLIC $ $) + +include(CMakePackageConfigHelpers) + +configure_package_config_file(theora-config.cmake.in theora-config.cmake + INSTALL_DESTINATION "lib/theora") + +install(FILES ${HEADERS} DESTINATION include/theora) + +install( + FILES "${CMAKE_CURRENT_BINARY_DIR}/theora-config.cmake" + DESTINATION "lib/theora" +) + +install(TARGETS theora theoraenc theoradec + EXPORT theora-targets + RUNTIME DESTINATION bin + LIBRARY DESTINATION bin + ARCHIVE DESTINATION lib +) + +install(EXPORT theora-targets + NAMESPACE theora:: + DESTINATION "lib/theora" +) + +add_subdirectory(tests) \ No newline at end of file diff --git a/CMakeSettings.json b/CMakeSettings.json new file mode 100644 index 00000000..78e0fcb5 --- /dev/null +++ b/CMakeSettings.json @@ -0,0 +1,76 @@ +{ + "configurations": [ + { + "name": "x86-Debug", + "generator": "Ninja", + "configurationType": "Debug", + "buildRoot": "${projectDir}\\out\\build\\${name}", + "installRoot": "${projectDir}\\out\\install\\${name}", + "cmakeCommandArgs": "", + "buildCommandArgs": "", + "ctestCommandArgs": "", + "inheritEnvironments": [ "msvc_x86" ], + "variables": [ + { + "name": "USE_X86", + "value": "True", + "type": "BOOL" + } + ] + }, + { + "name": "x86-Release", + "generator": "Ninja", + "configurationType": "RelWithDebInfo", + "buildRoot": "${projectDir}\\out\\build\\${name}", + "installRoot": "${projectDir}\\out\\install\\${name}", + "cmakeCommandArgs": "", + "buildCommandArgs": "", + "ctestCommandArgs": "", + "inheritEnvironments": [ "msvc_x86" ], + "variables": [ + { + "name": "USE_X86", + "value": "True", + "type": "BOOL" + } + ] + }, + { + "name": "x64-Debug", + "generator": "Ninja", + "configurationType": "Debug", + "inheritEnvironments": [ "msvc_x64_x64" ], + "buildRoot": "${projectDir}\\out\\build\\${name}", + "installRoot": "${projectDir}\\out\\install\\${name}", + "cmakeCommandArgs": "", + "buildCommandArgs": "", + "ctestCommandArgs": "", + "variables": [ + { + "name": "USE_X86", + "value": "False", + "type": "BOOL" + } + ] + }, + { + "name": "x64-Release", + "generator": "Ninja", + "configurationType": "RelWithDebInfo", + "buildRoot": "${projectDir}\\out\\build\\${name}", + "installRoot": "${projectDir}\\out\\install\\${name}", + "cmakeCommandArgs": "", + "buildCommandArgs": "", + "ctestCommandArgs": "", + "inheritEnvironments": [ "msvc_x64_x64" ], + "variables": [ + { + "name": "USE_X86", + "value": "False", + "type": "BOOL" + } + ] + } + ] +} \ No newline at end of file diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 00000000..c653ebb6 --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,21 @@ +cmake_minimum_required(VERSION 3.0) +project(tests LANGUAGES C) + +add_executable(comment comment.c) +add_executable(comment_theora comment_theora.c) +add_executable(granulepos granulepos.c) +add_executable(granulepos_theora granulepos_theora.c) +add_executable(noop noop.c) +add_executable(noop_theora noop_theora.c) +target_link_libraries(comment PRIVATE theora) +target_link_libraries(comment_theora PRIVATE theora) +target_link_libraries(granulepos PRIVATE theora) +target_link_libraries(granulepos_theora PRIVATE theora) +target_link_libraries(noop PRIVATE theora) +target_link_libraries(noop_theora PRIVATE theora) +add_test(test_comment comment) +add_test(test_comment_theora comment_theora) +add_test(test_granulepos granulepos) +add_test(test_granulepos_theora granulepos_theora) +add_test(test_noop noop) +add_test(test_noop_theora noop_theora) diff --git a/tests/tests.h b/tests/tests.h index dd420b21..21c6bf33 100644 --- a/tests/tests.h +++ b/tests/tests.h @@ -15,7 +15,9 @@ ********************************************************************/ -#include "config.h" +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif #include #include diff --git a/theora-config.cmake.in b/theora-config.cmake.in new file mode 100644 index 00000000..561c906f --- /dev/null +++ b/theora-config.cmake.in @@ -0,0 +1,3 @@ +@PACKAGE_INIT@ + +include("${CMAKE_CURRENT_LIST_DIR}/theora-targets.cmake") diff --git a/win32/xmingw32/libtheora.def b/win32/xmingw32/libtheora.def new file mode 100644 index 00000000..9755b81e --- /dev/null +++ b/win32/xmingw32/libtheora.def @@ -0,0 +1,61 @@ +EXPORTS +; Old alpha API + theora_version_string + theora_version_number + theora_decode_header + theora_decode_init + theora_decode_packetin + theora_decode_YUVout + theora_control + theora_packet_isheader + theora_packet_iskeyframe + theora_granule_shift + theora_granule_frame + theora_granule_time + theora_info_init + theora_info_clear + theora_clear + theora_comment_init + theora_comment_add + theora_comment_add_tag + theora_comment_query + theora_comment_query_count + theora_comment_clear +; New theora-exp API + th_version_string + th_version_number + th_decode_headerin + th_decode_alloc + th_setup_free + th_decode_ctl + th_decode_packetin + th_decode_ycbcr_out + th_decode_free + th_packet_isheader + th_packet_iskeyframe + th_granule_frame + th_granule_time + th_info_init + th_info_clear + th_comment_init + th_comment_add + th_comment_add_tag + th_comment_query + th_comment_query_count + th_comment_clear +; Old alpha API + theora_encode_init + theora_encode_YUVin + theora_encode_packetout + theora_encode_header + theora_encode_comment + theora_encode_tables +; New theora-exp API + th_encode_alloc + th_encode_ctl + th_encode_flushheader + th_encode_ycbcr_in + th_encode_packetout + th_encode_free + TH_VP31_QUANT_INFO + TH_VP31_HUFF_CODES