From fb30ff9d7e3207733bfe7acb20aa4f84a65d6ff1 Mon Sep 17 00:00:00 2001 From: Michal Janiszewski Date: Sat, 2 Nov 2019 15:55:10 -0700 Subject: [PATCH 1/3] [libmpeg2] Add new port Libmpeg2 seems to be a somewhat old project, last release was done in 2008, but it is still in use by some projects e.g. ResidualVM I have verified the mpeg2dec built for x86-64 with MSVC produces similar results as the one pre-packaged on my Arch. --- ...01-Add-naive-MSVC-support-to-sources.patch | 154 ++++++++++++++++++ .../0002-Mark-functions-as-exported.patch | 113 +++++++++++++ ports/libmpeg2/CMakeLists.txt | 111 +++++++++++++ ports/libmpeg2/CONTROL | 7 + ports/libmpeg2/portfile.cmake | 36 ++++ 5 files changed, 421 insertions(+) create mode 100644 ports/libmpeg2/0001-Add-naive-MSVC-support-to-sources.patch create mode 100644 ports/libmpeg2/0002-Mark-functions-as-exported.patch create mode 100644 ports/libmpeg2/CMakeLists.txt create mode 100644 ports/libmpeg2/CONTROL create mode 100644 ports/libmpeg2/portfile.cmake diff --git a/ports/libmpeg2/0001-Add-naive-MSVC-support-to-sources.patch b/ports/libmpeg2/0001-Add-naive-MSVC-support-to-sources.patch new file mode 100644 index 00000000000000..69a10fb1ce0b9a --- /dev/null +++ b/ports/libmpeg2/0001-Add-naive-MSVC-support-to-sources.patch @@ -0,0 +1,154 @@ +From 848fe44d0e3fe9ad9e1358986def6cdc55166daf Mon Sep 17 00:00:00 2001 +From: Michal Janiszewski +Date: Sat, 2 Nov 2019 14:50:53 -0700 +Subject: [PATCH] Add naive MSVC support to sources + +--- + libmpeg2/convert/rgb.c | 2 +- + libmpeg2/cpu_accel.c | 4 ++-- + libmpeg2/cpu_state.c | 4 ++-- + libmpeg2/idct.c | 2 +- + libmpeg2/motion_comp.c | 2 +- + libvo/video_out_dx.c | 7 ++++--- + vc++/config.h | 2 ++ + 7 files changed, 13 insertions(+), 10 deletions(-) + +diff --git a/libmpeg2/convert/rgb.c b/libmpeg2/convert/rgb.c +index 8863b0b..db6f4e3 100644 +--- a/libmpeg2/convert/rgb.c ++++ b/libmpeg2/convert/rgb.c +@@ -499,7 +499,7 @@ static int rgb_internal (mpeg2convert_rgb_order_t order, unsigned int bpp, + int convert420 = 0; + int rgb_stride_min = ((bpp + 7) >> 3) * seq->width; + +-#ifdef ARCH_X86 ++#if !defined(_MSC_VER) && defined(ARCH_X86) + if (!copy && (accel & MPEG2_ACCEL_X86_MMXEXT)) { + convert420 = 0; + copy = mpeg2convert_rgb_mmxext (order, bpp, seq); +diff --git a/libmpeg2/cpu_accel.c b/libmpeg2/cpu_accel.c +index 9b24610..a922df1 100644 +--- a/libmpeg2/cpu_accel.c ++++ b/libmpeg2/cpu_accel.c +@@ -29,7 +29,7 @@ + #include "attributes.h" + #include "mpeg2_internal.h" + +-#if defined(ARCH_X86) || defined(ARCH_X86_64) ++#if !defined(_MSC_VER) && (defined(ARCH_X86) || defined(ARCH_X86_64)) + static inline uint32_t arch_accel (uint32_t accel) + { + if (accel & (MPEG2_ACCEL_X86_3DNOW | MPEG2_ACCEL_X86_MMXEXT)) +@@ -253,7 +253,7 @@ static inline uint32_t arch_accel (uint32_t accel) + + uint32_t mpeg2_detect_accel (uint32_t accel) + { +-#if defined (ARCH_X86) || defined (ARCH_X86_64) || defined (ARCH_PPC) || defined (ARCH_ALPHA) || defined (ARCH_SPARC) ++#if !defined(_MSC_VER) && (defined (ARCH_X86) || defined (ARCH_X86_64) || defined (ARCH_PPC) || defined (ARCH_ALPHA) || defined (ARCH_SPARC)) + accel = arch_accel (accel); + #endif + return accel; +diff --git a/libmpeg2/cpu_state.c b/libmpeg2/cpu_state.c +index 2f2f64a..f4966c1 100644 +--- a/libmpeg2/cpu_state.c ++++ b/libmpeg2/cpu_state.c +@@ -36,7 +36,7 @@ + void (* mpeg2_cpu_state_save) (cpu_state_t * state) = NULL; + void (* mpeg2_cpu_state_restore) (cpu_state_t * state) = NULL; + +-#if defined(ARCH_X86) || defined(ARCH_X86_64) ++#if !defined(_MSC_VER) && (defined(ARCH_X86) || defined(ARCH_X86_64)) + static void state_restore_mmx (cpu_state_t * state) + { + emms (); +@@ -115,7 +115,7 @@ static void state_restore_altivec (cpu_state_t * state) + + void mpeg2_cpu_state_init (uint32_t accel) + { +-#if defined(ARCH_X86) || defined(ARCH_X86_64) ++#if !defined(_MSC_VER) && (defined(ARCH_X86) || defined(ARCH_X86_64)) + if (accel & MPEG2_ACCEL_X86_MMX) { + mpeg2_cpu_state_restore = state_restore_mmx; + } +diff --git a/libmpeg2/idct.c b/libmpeg2/idct.c +index 81c57e0..a057bf7 100644 +--- a/libmpeg2/idct.c ++++ b/libmpeg2/idct.c +@@ -235,7 +235,7 @@ static void mpeg2_idct_add_c (const int last, int16_t * block, + + void mpeg2_idct_init (uint32_t accel) + { +-#ifdef ARCH_X86 ++#if !defined(_MSC_VER) && defined(ARCH_X86) + if (accel & MPEG2_ACCEL_X86_SSE2) { + mpeg2_idct_copy = mpeg2_idct_copy_sse2; + mpeg2_idct_add = mpeg2_idct_add_sse2; +diff --git a/libmpeg2/motion_comp.c b/libmpeg2/motion_comp.c +index 7aed113..b00a32d 100644 +--- a/libmpeg2/motion_comp.c ++++ b/libmpeg2/motion_comp.c +@@ -33,7 +33,7 @@ mpeg2_mc_t mpeg2_mc; + + void mpeg2_mc_init (uint32_t accel) + { +-#ifdef ARCH_X86 ++#if !defined(_MSC_VER) && defined(ARCH_X86) + if (accel & MPEG2_ACCEL_X86_MMXEXT) + mpeg2_mc = mpeg2_mc_mmxext; + else if (accel & MPEG2_ACCEL_X86_3DNOW) +diff --git a/libvo/video_out_dx.c b/libvo/video_out_dx.c +index 36de68a..d41a5a6 100644 +--- a/libvo/video_out_dx.c ++++ b/libvo/video_out_dx.c +@@ -37,6 +37,7 @@ + + #include + #include ++//#include + + #define USE_OVERLAY_TRIPLE_BUFFERING 0 + +@@ -82,7 +83,7 @@ static void update_overlay (dx_instance_t * instance) + dwFlags, &ddofx); + } + +-static long FAR PASCAL event_procedure (HWND hwnd, UINT message, ++static LRESULT FAR PASCAL event_procedure (HWND hwnd, UINT message, + WPARAM wParam, LPARAM lParam) + { + RECT rect_window; +@@ -92,7 +93,7 @@ static long FAR PASCAL event_procedure (HWND hwnd, UINT message, + switch (message) { + + case WM_WINDOWPOSCHANGED: +- instance = (dx_instance_t *) GetWindowLong (hwnd, GWL_USERDATA); ++ instance = (dx_instance_t *) GetWindowLongPtr (hwnd, GWLP_USERDATA); + + /* update the window position and size */ + point_window.x = 0; +@@ -173,7 +174,7 @@ static int create_window (dx_instance_t * instance) + /* store a directx_instance pointer into the window local storage + * (for later use in event_handler). + * We need to use SetWindowLongPtr when it is available in mingw */ +- SetWindowLong (instance->window, GWL_USERDATA, (LONG) instance); ++ SetWindowLongPtr (instance->window, GWLP_USERDATA, (LONG_PTR) instance); + + ShowWindow (instance->window, SW_SHOW); + +diff --git a/vc++/config.h b/vc++/config.h +index 93719f0..a03cce6 100644 +--- a/vc++/config.h ++++ b/vc++/config.h +@@ -16,7 +16,9 @@ + /* #undef ARCH_SPARC */ + + /* x86 architecture */ ++#if defined(_M_AMD64) || defined(_M_IX86) + #define ARCH_X86 ++#endif + + /* maximum supported data alignment */ + /* #undef ATTRIBUTE_ALIGNED_MAX */ +-- +2.23.0.windows.1 + diff --git a/ports/libmpeg2/0002-Mark-functions-as-exported.patch b/ports/libmpeg2/0002-Mark-functions-as-exported.patch new file mode 100644 index 00000000000000..4150445803ef84 --- /dev/null +++ b/ports/libmpeg2/0002-Mark-functions-as-exported.patch @@ -0,0 +1,113 @@ +From 391e154c060bbe0086e406af4e05b5b9c1b426d1 Mon Sep 17 00:00:00 2001 +From: Michal Janiszewski +Date: Sat, 2 Nov 2019 15:49:13 -0700 +Subject: [PATCH] Mark functions as exported + +--- + include/mpeg2.h | 47 +++++++++++++++++++++++------------------- + include/mpeg2convert.h | 4 ++-- + 2 files changed, 28 insertions(+), 23 deletions(-) + +diff --git a/include/mpeg2.h b/include/mpeg2.h +index aff0c33..3520cbe 100644 +--- a/include/mpeg2.h ++++ b/include/mpeg2.h +@@ -41,6 +41,11 @@ + #define SEQ_VIDEO_FORMAT_MAC 0x80 + #define SEQ_VIDEO_FORMAT_UNSPECIFIED 0xa0 + ++// Set to desired linkage qualifier, e.g. __declspec(dllexport) ++#ifndef LIBMPEG2_API ++#define LIBMPEG2_API ++#endif ++ + typedef struct mpeg2_sequence_s { + unsigned int width, height; + unsigned int chroma_width, chroma_height; +@@ -148,10 +153,10 @@ typedef int mpeg2_convert_t (int stage, void * id, + const mpeg2_sequence_t * sequence, int stride, + uint32_t accel, void * arg, + mpeg2_convert_init_t * result); +-int mpeg2_convert (mpeg2dec_t * mpeg2dec, mpeg2_convert_t convert, void * arg); +-int mpeg2_stride (mpeg2dec_t * mpeg2dec, int stride); +-void mpeg2_set_buf (mpeg2dec_t * mpeg2dec, uint8_t * buf[3], void * id); +-void mpeg2_custom_fbuf (mpeg2dec_t * mpeg2dec, int custom_fbuf); ++LIBMPEG2_API int mpeg2_convert (mpeg2dec_t * mpeg2dec, mpeg2_convert_t convert, void * arg); ++LIBMPEG2_API int mpeg2_stride (mpeg2dec_t * mpeg2dec, int stride); ++LIBMPEG2_API void mpeg2_set_buf (mpeg2dec_t * mpeg2dec, uint8_t * buf[3], void * id); ++LIBMPEG2_API void mpeg2_custom_fbuf (mpeg2dec_t * mpeg2dec, int custom_fbuf); + + #define MPEG2_ACCEL_X86_MMX 1 + #define MPEG2_ACCEL_X86_3DNOW 2 +@@ -166,25 +171,25 @@ void mpeg2_custom_fbuf (mpeg2dec_t * mpeg2dec, int custom_fbuf); + #define MPEG2_ACCEL_ARM 1 + #define MPEG2_ACCEL_DETECT 0x80000000 + +-uint32_t mpeg2_accel (uint32_t accel); +-mpeg2dec_t * mpeg2_init (void); +-const mpeg2_info_t * mpeg2_info (mpeg2dec_t * mpeg2dec); +-void mpeg2_close (mpeg2dec_t * mpeg2dec); ++LIBMPEG2_API uint32_t mpeg2_accel (uint32_t accel); ++LIBMPEG2_API mpeg2dec_t * mpeg2_init (void); ++LIBMPEG2_API const mpeg2_info_t * mpeg2_info (mpeg2dec_t * mpeg2dec); ++LIBMPEG2_API void mpeg2_close (mpeg2dec_t * mpeg2dec); + +-void mpeg2_buffer (mpeg2dec_t * mpeg2dec, uint8_t * start, uint8_t * end); +-int mpeg2_getpos (mpeg2dec_t * mpeg2dec); +-mpeg2_state_t mpeg2_parse (mpeg2dec_t * mpeg2dec); ++LIBMPEG2_API void mpeg2_buffer (mpeg2dec_t * mpeg2dec, uint8_t * start, uint8_t * end); ++LIBMPEG2_API int mpeg2_getpos (mpeg2dec_t * mpeg2dec); ++LIBMPEG2_API mpeg2_state_t mpeg2_parse (mpeg2dec_t * mpeg2dec); + +-void mpeg2_reset (mpeg2dec_t * mpeg2dec, int full_reset); +-void mpeg2_skip (mpeg2dec_t * mpeg2dec, int skip); +-void mpeg2_slice_region (mpeg2dec_t * mpeg2dec, int start, int end); ++LIBMPEG2_API void mpeg2_reset (mpeg2dec_t * mpeg2dec, int full_reset); ++LIBMPEG2_API void mpeg2_skip (mpeg2dec_t * mpeg2dec, int skip); ++LIBMPEG2_API void mpeg2_slice_region (mpeg2dec_t * mpeg2dec, int start, int end); + +-void mpeg2_tag_picture (mpeg2dec_t * mpeg2dec, uint32_t tag, uint32_t tag2); ++LIBMPEG2_API void mpeg2_tag_picture (mpeg2dec_t * mpeg2dec, uint32_t tag, uint32_t tag2); + +-void mpeg2_init_fbuf (mpeg2_decoder_t * decoder, uint8_t * current_fbuf[3], ++LIBMPEG2_API void mpeg2_init_fbuf (mpeg2_decoder_t * decoder, uint8_t * current_fbuf[3], + uint8_t * forward_fbuf[3], uint8_t * backward_fbuf[3]); +-void mpeg2_slice (mpeg2_decoder_t * decoder, int code, const uint8_t * buffer); +-int mpeg2_guess_aspect (const mpeg2_sequence_t * sequence, ++LIBMPEG2_API void mpeg2_slice (mpeg2_decoder_t * decoder, int code, const uint8_t * buffer); ++LIBMPEG2_API int mpeg2_guess_aspect (const mpeg2_sequence_t * sequence, + unsigned int * pixel_width, + unsigned int * pixel_height); + +@@ -196,9 +201,9 @@ typedef enum { + MPEG2_ALLOC_CONVERTED = 4 + } mpeg2_alloc_t; + +-void * mpeg2_malloc (unsigned size, mpeg2_alloc_t reason); +-void mpeg2_free (void * buf); +-void mpeg2_malloc_hooks (void * malloc (unsigned, mpeg2_alloc_t), ++LIBMPEG2_API void * mpeg2_malloc (unsigned size, mpeg2_alloc_t reason); ++LIBMPEG2_API void mpeg2_free (void * buf); ++LIBMPEG2_API void mpeg2_malloc_hooks (void * malloc (unsigned, mpeg2_alloc_t), + int free (void *)); + + #endif /* LIBMPEG2_MPEG2_H */ +diff --git a/include/mpeg2convert.h b/include/mpeg2convert.h +index 108dee8..9bad0aa 100644 +--- a/include/mpeg2convert.h ++++ b/include/mpeg2convert.h +@@ -40,9 +40,9 @@ typedef enum { + MPEG2CONVERT_BGR = 1 + } mpeg2convert_rgb_order_t; + +-mpeg2_convert_t * mpeg2convert_rgb (mpeg2convert_rgb_order_t order, ++LIBMPEG2_API mpeg2_convert_t * mpeg2convert_rgb (mpeg2convert_rgb_order_t order, + unsigned int bpp); + +-mpeg2_convert_t mpeg2convert_uyvy; ++LIBMPEG2_API mpeg2_convert_t mpeg2convert_uyvy; + + #endif /* LIBMPEG2_MPEG2CONVERT_H */ +-- +2.23.0.windows.1 + diff --git a/ports/libmpeg2/CMakeLists.txt b/ports/libmpeg2/CMakeLists.txt new file mode 100644 index 00000000000000..8f649b730c69bb --- /dev/null +++ b/ports/libmpeg2/CMakeLists.txt @@ -0,0 +1,111 @@ +cmake_minimum_required(VERSION 3.2) +project(libmpeg2) + +option(BUILD_BINARIES "Build libmpeg2 binaries" OFF) +if (BUILD_SHARED_LIBS) + set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) +endif () + +set(MPEG2_SOURCE_FILES + libmpeg2/alloc.c + libmpeg2/cpu_accel.c + libmpeg2/cpu_state.c + libmpeg2/decode.c + libmpeg2/header.c + libmpeg2/idct.c + libmpeg2/idct_alpha.c + libmpeg2/idct_altivec.c + #libmpeg2/idct_mmx.c + libmpeg2/motion_comp.c + libmpeg2/motion_comp_alpha.c + libmpeg2/motion_comp_altivec.c + libmpeg2/motion_comp_arm.c + #libmpeg2/motion_comp_mmx.c + libmpeg2/motion_comp_vis.c + libmpeg2/slice.c + ) +set(VO_SOURCE_FILES + libvo/video_out.c + libvo/video_out_dx.c + libvo/video_out_null.c + libvo/video_out_pgm.c + libvo/video_out_sdl.c + libvo/video_out_x11.c + ) +set(MPEG2_CONVERT_SOURCES + libmpeg2/convert/rgb.c + #libmpeg2/convert/rgb_mmx.c + libmpeg2/convert/rgb_vis.c + libmpeg2/convert/uyvy.c + ) +set(GETOPT_FILES + src/getopt.c + ) +set(HEADERS + include/mpeg2.h + include/mpeg2convert.h + ) + +add_library(mpeg2 ${MPEG2_SOURCE_FILES}) +add_library(mpeg2convert ${MPEG2_CONVERT_SOURCES}) +add_library(getopt STATIC ${GETOPT_FILES}) +add_library(vo STATIC ${VO_SOURCE_FILES}) + +target_include_directories(mpeg2convert PUBLIC + "${CMAKE_SOURCE_DIR}/vc++" + "${CMAKE_SOURCE_DIR}/include" + ) +target_include_directories(getopt PUBLIC + "${CMAKE_SOURCE_DIR}/vc++" + "${CMAKE_SOURCE_DIR}/include" + ) +target_include_directories(vo PUBLIC + "${CMAKE_SOURCE_DIR}/vc++" + "${CMAKE_SOURCE_DIR}/include" + ) +target_include_directories(mpeg2 PUBLIC + "${CMAKE_SOURCE_DIR}/vc++" + "${CMAKE_SOURCE_DIR}/include" + ) +target_include_directories(mpeg2 INTERFACE + "${CMAKE_SOURCE_DIR}/include" + ) + +target_compile_definitions(getopt PUBLIC HAVE_CONFIG_H) +target_link_libraries(vo mpeg2convert) + +if (BUILD_BINARIES) + add_executable(mpeg2dec src/mpeg2dec.c src/dump_state.c src/gettimeofday.c) + add_executable(extract_mpeg2 src/extract_mpeg2.c) + add_executable(corrupt_mpeg2 src/corrupt_mpeg2.c) + + target_compile_definitions(extract_mpeg2 PUBLIC HAVE_CONFIG_H) + target_compile_definitions(corrupt_mpeg2 PUBLIC HAVE_CONFIG_H) + + target_link_libraries(mpeg2dec PRIVATE getopt vo mpeg2convert mpeg2 gdi32) + target_link_libraries(extract_mpeg2 PRIVATE getopt) + target_link_libraries(corrupt_mpeg2 PRIVATE getopt) + + target_include_directories(mpeg2dec PUBLIC + "${CMAKE_SOURCE_DIR}/vc++" + "${CMAKE_SOURCE_DIR}/include" + "${CMAKE_SOURCE_DIR}/src" + ) + target_include_directories(extract_mpeg2 PUBLIC + "${CMAKE_SOURCE_DIR}/vc++" + "${CMAKE_SOURCE_DIR}/include" + "${CMAKE_SOURCE_DIR}/src" + ) + target_include_directories(corrupt_mpeg2 PUBLIC + "${CMAKE_SOURCE_DIR}/vc++" + "${CMAKE_SOURCE_DIR}/include" + "${CMAKE_SOURCE_DIR}/src" + ) +endif (BUILD_BINARIES) + +install(TARGETS mpeg2 + EXPORT libmpeg2 + LIBRARY DESTINATION lib +) + +install(FILES ${HEADERS} DESTINATION "include/mpeg2dec") diff --git a/ports/libmpeg2/CONTROL b/ports/libmpeg2/CONTROL new file mode 100644 index 00000000000000..1dfe0983e10478 --- /dev/null +++ b/ports/libmpeg2/CONTROL @@ -0,0 +1,7 @@ +Source: libmpeg2 +Version: 0.5.1 +Homepage: http://libmpeg2.sourceforge.net/ +Description: a free MPEG-2 video stream decoder + +Feature: build_binaries +Description: Build binaries provided with libmpeg2 diff --git a/ports/libmpeg2/portfile.cmake b/ports/libmpeg2/portfile.cmake new file mode 100644 index 00000000000000..4b374edfaebfc1 --- /dev/null +++ b/ports/libmpeg2/portfile.cmake @@ -0,0 +1,36 @@ +vcpkg_fail_port_install(MESSAGE "${PORT} currently only supports Windows Desktop platform." ON_TARGET "Linux" "OSX" "uwp") +vcpkg_download_distfile(ARCHIVE + URLS "http://libmpeg2.sourceforge.net/files/libmpeg2-0.5.1.tar.gz" + FILENAME "libmpeg2-0.5.1.tar.gz" + SHA512 3648a2b3d7e2056d5adb328acd2fb983a1fa9a05ccb6f9388cc686c819445421811f42e8439418a0491a13080977f074a0d8bf8fa6bc101ff245ddea65a46fbc +) + +vcpkg_extract_source_archive_ex( + OUT_SOURCE_PATH SOURCE_PATH + ARCHIVE ${ARCHIVE} + PATCHES + 0001-Add-naive-MSVC-support-to-sources.patch + 0002-Mark-functions-as-exported.patch +) + +file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH}) + +vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS + FEATURES + build_binaries BUILD_BINARIES +) + +vcpkg_configure_cmake( + SOURCE_PATH ${SOURCE_PATH} + PREFER_NINJA + OPTIONS ${FEATURE_OPTIONS} +) + +vcpkg_install_cmake() + +# # Handle copyright +file(INSTALL ${SOURCE_PATH}/COPYING DESTINATION ${CURRENT_PACKAGES_DIR}/share/libmpeg2 RENAME copyright) + +file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include) + +vcpkg_copy_pdbs() From ecf3ec5cd6b94b67828d4d3bb4c208de268328f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Thu, 30 Apr 2020 21:19:20 +0200 Subject: [PATCH 2/3] [libmpeg2] Add ci.baseline.txt exemptions --- scripts/ci.baseline.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/ci.baseline.txt b/scripts/ci.baseline.txt index c8466ddd4f9fa5..34d5feb07c6c3e 100644 --- a/scripts/ci.baseline.txt +++ b/scripts/ci.baseline.txt @@ -820,6 +820,10 @@ libmodman:x64-uwp=fail libmodman:x64-windows-static=fail libmodplug:arm-uwp=fail libmodplug:x64-uwp=fail +libmpeg2:arm-uwp=fail +libmpeg2:x64-linux=fail +libmpeg2:x64-osx=fail +libmpeg2:x64-uwp=fail libmupdf:x64-osx=fail libmysql:x86-windows=fail libnice:x64-linux=fail From e3acda31774efe4975f47fee921a9aeaa5e354a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Fri, 6 Mar 2020 20:38:24 +0100 Subject: [PATCH 3/3] [libmpeg2] Apply review comments --- ...01-Add-naive-MSVC-support-to-sources.patch | 24 ++-- .../0002-Mark-functions-as-exported.patch | 113 ------------------ ports/libmpeg2/CMakeLists.txt | 9 +- ports/libmpeg2/CONTROL | 5 +- ports/libmpeg2/portfile.cmake | 6 +- 5 files changed, 18 insertions(+), 139 deletions(-) delete mode 100644 ports/libmpeg2/0002-Mark-functions-as-exported.patch diff --git a/ports/libmpeg2/0001-Add-naive-MSVC-support-to-sources.patch b/ports/libmpeg2/0001-Add-naive-MSVC-support-to-sources.patch index 69a10fb1ce0b9a..1bbebffc0c5dbc 100644 --- a/ports/libmpeg2/0001-Add-naive-MSVC-support-to-sources.patch +++ b/ports/libmpeg2/0001-Add-naive-MSVC-support-to-sources.patch @@ -1,4 +1,4 @@ -From 848fe44d0e3fe9ad9e1358986def6cdc55166daf Mon Sep 17 00:00:00 2001 +From ed3b6e4bca1fe5211e3d7ca06bbbf9b161c8bc19 Mon Sep 17 00:00:00 2001 From: Michal Janiszewski Date: Sat, 2 Nov 2019 14:50:53 -0700 Subject: [PATCH] Add naive MSVC support to sources @@ -9,9 +9,9 @@ Subject: [PATCH] Add naive MSVC support to sources libmpeg2/cpu_state.c | 4 ++-- libmpeg2/idct.c | 2 +- libmpeg2/motion_comp.c | 2 +- - libvo/video_out_dx.c | 7 ++++--- + libvo/video_out_dx.c | 6 +++--- vc++/config.h | 2 ++ - 7 files changed, 13 insertions(+), 10 deletions(-) + 7 files changed, 12 insertions(+), 10 deletions(-) diff --git a/libmpeg2/convert/rgb.c b/libmpeg2/convert/rgb.c index 8863b0b..db6f4e3 100644 @@ -97,18 +97,10 @@ index 7aed113..b00a32d 100644 mpeg2_mc = mpeg2_mc_mmxext; else if (accel & MPEG2_ACCEL_X86_3DNOW) diff --git a/libvo/video_out_dx.c b/libvo/video_out_dx.c -index 36de68a..d41a5a6 100644 +index 36de68a..0797cdc 100644 --- a/libvo/video_out_dx.c +++ b/libvo/video_out_dx.c -@@ -37,6 +37,7 @@ - - #include - #include -+//#include - - #define USE_OVERLAY_TRIPLE_BUFFERING 0 - -@@ -82,7 +83,7 @@ static void update_overlay (dx_instance_t * instance) +@@ -82,7 +82,7 @@ static void update_overlay (dx_instance_t * instance) dwFlags, &ddofx); } @@ -117,7 +109,7 @@ index 36de68a..d41a5a6 100644 WPARAM wParam, LPARAM lParam) { RECT rect_window; -@@ -92,7 +93,7 @@ static long FAR PASCAL event_procedure (HWND hwnd, UINT message, +@@ -92,7 +92,7 @@ static long FAR PASCAL event_procedure (HWND hwnd, UINT message, switch (message) { case WM_WINDOWPOSCHANGED: @@ -126,7 +118,7 @@ index 36de68a..d41a5a6 100644 /* update the window position and size */ point_window.x = 0; -@@ -173,7 +174,7 @@ static int create_window (dx_instance_t * instance) +@@ -173,7 +173,7 @@ static int create_window (dx_instance_t * instance) /* store a directx_instance pointer into the window local storage * (for later use in event_handler). * We need to use SetWindowLongPtr when it is available in mingw */ @@ -150,5 +142,5 @@ index 93719f0..a03cce6 100644 /* maximum supported data alignment */ /* #undef ATTRIBUTE_ALIGNED_MAX */ -- -2.23.0.windows.1 +2.25.0 diff --git a/ports/libmpeg2/0002-Mark-functions-as-exported.patch b/ports/libmpeg2/0002-Mark-functions-as-exported.patch deleted file mode 100644 index 4150445803ef84..00000000000000 --- a/ports/libmpeg2/0002-Mark-functions-as-exported.patch +++ /dev/null @@ -1,113 +0,0 @@ -From 391e154c060bbe0086e406af4e05b5b9c1b426d1 Mon Sep 17 00:00:00 2001 -From: Michal Janiszewski -Date: Sat, 2 Nov 2019 15:49:13 -0700 -Subject: [PATCH] Mark functions as exported - ---- - include/mpeg2.h | 47 +++++++++++++++++++++++------------------- - include/mpeg2convert.h | 4 ++-- - 2 files changed, 28 insertions(+), 23 deletions(-) - -diff --git a/include/mpeg2.h b/include/mpeg2.h -index aff0c33..3520cbe 100644 ---- a/include/mpeg2.h -+++ b/include/mpeg2.h -@@ -41,6 +41,11 @@ - #define SEQ_VIDEO_FORMAT_MAC 0x80 - #define SEQ_VIDEO_FORMAT_UNSPECIFIED 0xa0 - -+// Set to desired linkage qualifier, e.g. __declspec(dllexport) -+#ifndef LIBMPEG2_API -+#define LIBMPEG2_API -+#endif -+ - typedef struct mpeg2_sequence_s { - unsigned int width, height; - unsigned int chroma_width, chroma_height; -@@ -148,10 +153,10 @@ typedef int mpeg2_convert_t (int stage, void * id, - const mpeg2_sequence_t * sequence, int stride, - uint32_t accel, void * arg, - mpeg2_convert_init_t * result); --int mpeg2_convert (mpeg2dec_t * mpeg2dec, mpeg2_convert_t convert, void * arg); --int mpeg2_stride (mpeg2dec_t * mpeg2dec, int stride); --void mpeg2_set_buf (mpeg2dec_t * mpeg2dec, uint8_t * buf[3], void * id); --void mpeg2_custom_fbuf (mpeg2dec_t * mpeg2dec, int custom_fbuf); -+LIBMPEG2_API int mpeg2_convert (mpeg2dec_t * mpeg2dec, mpeg2_convert_t convert, void * arg); -+LIBMPEG2_API int mpeg2_stride (mpeg2dec_t * mpeg2dec, int stride); -+LIBMPEG2_API void mpeg2_set_buf (mpeg2dec_t * mpeg2dec, uint8_t * buf[3], void * id); -+LIBMPEG2_API void mpeg2_custom_fbuf (mpeg2dec_t * mpeg2dec, int custom_fbuf); - - #define MPEG2_ACCEL_X86_MMX 1 - #define MPEG2_ACCEL_X86_3DNOW 2 -@@ -166,25 +171,25 @@ void mpeg2_custom_fbuf (mpeg2dec_t * mpeg2dec, int custom_fbuf); - #define MPEG2_ACCEL_ARM 1 - #define MPEG2_ACCEL_DETECT 0x80000000 - --uint32_t mpeg2_accel (uint32_t accel); --mpeg2dec_t * mpeg2_init (void); --const mpeg2_info_t * mpeg2_info (mpeg2dec_t * mpeg2dec); --void mpeg2_close (mpeg2dec_t * mpeg2dec); -+LIBMPEG2_API uint32_t mpeg2_accel (uint32_t accel); -+LIBMPEG2_API mpeg2dec_t * mpeg2_init (void); -+LIBMPEG2_API const mpeg2_info_t * mpeg2_info (mpeg2dec_t * mpeg2dec); -+LIBMPEG2_API void mpeg2_close (mpeg2dec_t * mpeg2dec); - --void mpeg2_buffer (mpeg2dec_t * mpeg2dec, uint8_t * start, uint8_t * end); --int mpeg2_getpos (mpeg2dec_t * mpeg2dec); --mpeg2_state_t mpeg2_parse (mpeg2dec_t * mpeg2dec); -+LIBMPEG2_API void mpeg2_buffer (mpeg2dec_t * mpeg2dec, uint8_t * start, uint8_t * end); -+LIBMPEG2_API int mpeg2_getpos (mpeg2dec_t * mpeg2dec); -+LIBMPEG2_API mpeg2_state_t mpeg2_parse (mpeg2dec_t * mpeg2dec); - --void mpeg2_reset (mpeg2dec_t * mpeg2dec, int full_reset); --void mpeg2_skip (mpeg2dec_t * mpeg2dec, int skip); --void mpeg2_slice_region (mpeg2dec_t * mpeg2dec, int start, int end); -+LIBMPEG2_API void mpeg2_reset (mpeg2dec_t * mpeg2dec, int full_reset); -+LIBMPEG2_API void mpeg2_skip (mpeg2dec_t * mpeg2dec, int skip); -+LIBMPEG2_API void mpeg2_slice_region (mpeg2dec_t * mpeg2dec, int start, int end); - --void mpeg2_tag_picture (mpeg2dec_t * mpeg2dec, uint32_t tag, uint32_t tag2); -+LIBMPEG2_API void mpeg2_tag_picture (mpeg2dec_t * mpeg2dec, uint32_t tag, uint32_t tag2); - --void mpeg2_init_fbuf (mpeg2_decoder_t * decoder, uint8_t * current_fbuf[3], -+LIBMPEG2_API void mpeg2_init_fbuf (mpeg2_decoder_t * decoder, uint8_t * current_fbuf[3], - uint8_t * forward_fbuf[3], uint8_t * backward_fbuf[3]); --void mpeg2_slice (mpeg2_decoder_t * decoder, int code, const uint8_t * buffer); --int mpeg2_guess_aspect (const mpeg2_sequence_t * sequence, -+LIBMPEG2_API void mpeg2_slice (mpeg2_decoder_t * decoder, int code, const uint8_t * buffer); -+LIBMPEG2_API int mpeg2_guess_aspect (const mpeg2_sequence_t * sequence, - unsigned int * pixel_width, - unsigned int * pixel_height); - -@@ -196,9 +201,9 @@ typedef enum { - MPEG2_ALLOC_CONVERTED = 4 - } mpeg2_alloc_t; - --void * mpeg2_malloc (unsigned size, mpeg2_alloc_t reason); --void mpeg2_free (void * buf); --void mpeg2_malloc_hooks (void * malloc (unsigned, mpeg2_alloc_t), -+LIBMPEG2_API void * mpeg2_malloc (unsigned size, mpeg2_alloc_t reason); -+LIBMPEG2_API void mpeg2_free (void * buf); -+LIBMPEG2_API void mpeg2_malloc_hooks (void * malloc (unsigned, mpeg2_alloc_t), - int free (void *)); - - #endif /* LIBMPEG2_MPEG2_H */ -diff --git a/include/mpeg2convert.h b/include/mpeg2convert.h -index 108dee8..9bad0aa 100644 ---- a/include/mpeg2convert.h -+++ b/include/mpeg2convert.h -@@ -40,9 +40,9 @@ typedef enum { - MPEG2CONVERT_BGR = 1 - } mpeg2convert_rgb_order_t; - --mpeg2_convert_t * mpeg2convert_rgb (mpeg2convert_rgb_order_t order, -+LIBMPEG2_API mpeg2_convert_t * mpeg2convert_rgb (mpeg2convert_rgb_order_t order, - unsigned int bpp); - --mpeg2_convert_t mpeg2convert_uyvy; -+LIBMPEG2_API mpeg2_convert_t mpeg2convert_uyvy; - - #endif /* LIBMPEG2_MPEG2CONVERT_H */ --- -2.23.0.windows.1 - diff --git a/ports/libmpeg2/CMakeLists.txt b/ports/libmpeg2/CMakeLists.txt index 8f649b730c69bb..88c0c8712d112a 100644 --- a/ports/libmpeg2/CMakeLists.txt +++ b/ports/libmpeg2/CMakeLists.txt @@ -1,10 +1,7 @@ cmake_minimum_required(VERSION 3.2) project(libmpeg2) -option(BUILD_BINARIES "Build libmpeg2 binaries" OFF) -if (BUILD_SHARED_LIBS) - set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) -endif () +option(TOOLS "Build libmpeg2 tools" OFF) set(MPEG2_SOURCE_FILES libmpeg2/alloc.c @@ -74,7 +71,7 @@ target_include_directories(mpeg2 INTERFACE target_compile_definitions(getopt PUBLIC HAVE_CONFIG_H) target_link_libraries(vo mpeg2convert) -if (BUILD_BINARIES) +if (TOOLS) add_executable(mpeg2dec src/mpeg2dec.c src/dump_state.c src/gettimeofday.c) add_executable(extract_mpeg2 src/extract_mpeg2.c) add_executable(corrupt_mpeg2 src/corrupt_mpeg2.c) @@ -101,7 +98,7 @@ if (BUILD_BINARIES) "${CMAKE_SOURCE_DIR}/include" "${CMAKE_SOURCE_DIR}/src" ) -endif (BUILD_BINARIES) +endif (TOOLS) install(TARGETS mpeg2 EXPORT libmpeg2 diff --git a/ports/libmpeg2/CONTROL b/ports/libmpeg2/CONTROL index 1dfe0983e10478..380cc6493801d4 100644 --- a/ports/libmpeg2/CONTROL +++ b/ports/libmpeg2/CONTROL @@ -2,6 +2,7 @@ Source: libmpeg2 Version: 0.5.1 Homepage: http://libmpeg2.sourceforge.net/ Description: a free MPEG-2 video stream decoder +Supports: !(linux|osx|uwp) -Feature: build_binaries -Description: Build binaries provided with libmpeg2 +Feature: tools +Description: Build tools provided with libmpeg2 diff --git a/ports/libmpeg2/portfile.cmake b/ports/libmpeg2/portfile.cmake index 4b374edfaebfc1..3813e0d6e46bca 100644 --- a/ports/libmpeg2/portfile.cmake +++ b/ports/libmpeg2/portfile.cmake @@ -1,4 +1,7 @@ vcpkg_fail_port_install(MESSAGE "${PORT} currently only supports Windows Desktop platform." ON_TARGET "Linux" "OSX" "uwp") +vcpkg_check_linkage(ONLY_STATIC_LIBRARY) + +# There is archived version of releases available at https://github.com/janisozaur/libmpeg2 vcpkg_download_distfile(ARCHIVE URLS "http://libmpeg2.sourceforge.net/files/libmpeg2-0.5.1.tar.gz" FILENAME "libmpeg2-0.5.1.tar.gz" @@ -10,14 +13,13 @@ vcpkg_extract_source_archive_ex( ARCHIVE ${ARCHIVE} PATCHES 0001-Add-naive-MSVC-support-to-sources.patch - 0002-Mark-functions-as-exported.patch ) file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH}) vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS FEATURES - build_binaries BUILD_BINARIES + tools TOOLS ) vcpkg_configure_cmake(