Skip to content

Add new port: libzvbi - VBI decoding library (teletext)#51729

Draft
Greisby wants to merge 8 commits into
microsoft:masterfrom
Greisby:new-libzvbi
Draft

Add new port: libzvbi - VBI decoding library (teletext)#51729
Greisby wants to merge 8 commits into
microsoft:masterfrom
Greisby:new-libzvbi

Conversation

@Greisby
Copy link
Copy Markdown
Contributor

@Greisby Greisby commented May 13, 2026

Description

libzvbi (ZVBI) is a library for decoding VBI (Vertical Blanking Interval) data services, including:

  • Teletext (ETS 300 706) — page-based text information broadcast in analogue and digital TV signals
  • Closed captions (EIA 608) — North-American captioning standard
  • VPS / WSS / XDS — programme identification and wide-screen signalling metadata

Why this port is needed

libzvbi is needed by FFmpeg to decode teletext pages from MPEG-2 Transport Streams (M2TS).
When FFmpeg is built with --enable-libzvbi, the libzvbi teletext decoder becomes available, enabling extraction of teletext subtitle pages from DVB broadcasts and recordings.

This is the standard approach used by broadcast and media-processing pipelines worldwide.
Without libzvbi, FFmpeg cannot decode teletext data embedded in DVB streams.

Build strategy

Platform Build system Notes
Windows CMake Custom CMakeLists.txt + MSVC-compat patch + pre-generated config.h/site_def.h
Linux/macOS Autotools Native ./configure via vcpkg_configure_make(AUTOCONFIG)

The upstream project uses autotools exclusively.
On Windows, a custom CMake build file is provided because autotools is impractical with MSVC.
The MSVC-compat patch (001-msvc-compat.patch) adds shim headers (unistd.h, strings.h, sys/) for POSIX APIs;
these shims are removed on non-Windows platforms before the autotools build runs.

Dependencies

Dependency Condition Purpose
libiconv Always Character set conversion (teletext)
pthreads Windows POSIX threading shim

Patches

Patch Purpose
001-msvc-compat.patch MSVC portability: adds POSIX shim headers + type aliases

  • Changes comply with the maintainer guide.
  • The packaged project shows strong association with the chosen port name. Check this box if at least one of the following criteria is met:
    • The project is in Repology: https://repology.org/project//versions
    • The project is amongst the first web search results for "" or " C++". Include a screenshot of the search engine results in the PR.
    • The port name follows the 'GitHubOrg-GitHubRepo' form or equivalent Owner-Project form.
  • Optional dependencies of the build are all controlled by the port. A dependency is controlled if it is declared an unconditional dependency in vcpkg.json, or explicitly disabled through patches or build system arguments such as CMAKE_DISABLE_FIND_PACKAGE_Xxx or VCPKG_LOCK_FIND_PACKAGE
  • The versioning scheme in vcpkg.json matches what upstream says.
  • The license declaration in vcpkg.json matches what upstream says.
  • The installed as the "copyright" file matches what upstream says.
  • The source code of the component installed comes from an authoritative source.
  • The generated "usage text" is brief and accurate. See adding-usage for context. Don't add a usage file if the automatically generated usage is correct.
  • The version database is fixed by rerunning ./vcpkg x-add-version --all and committing the result.
  • Exactly one version is added in each modified versions file.

@Greisby Greisby marked this pull request as draft May 13, 2026 12:45
Copy link
Copy Markdown
Contributor

@dg0yt dg0yt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't want to review the CMakeLists.txt before it is accepted to vendor a CMake build system into the new port.

Comment thread ports/libzvbi/portfile.cmake Outdated
Comment on lines +32 to +42
if(VCPKG_TARGET_IS_WINDOWS)
vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}/src"
)
vcpkg_cmake_install()
vcpkg_copy_pdbs()
vcpkg_fixup_pkgconfig()
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
else()
vcpkg_find_acquire_program(PKGCONFIG)
vcpkg_configure_make(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, we want:

  • use the official build systems
  • use the same build system for all targets
  • use the latest maintainer function from port vcpkg-make instead of the legacy vcpkg_..._make functions.

Comment on lines +9 to +17
-static void init_hcrc(void) __attribute__ ((constructor));
+static void init_hcrc(void);
+
+#ifdef _MSC_VER
+/* MSVC: .CRT$XCU section provides C startup initializers (like GCC __attribute__((constructor))). */
+#pragma section(".CRT$XCU", read)
+static void __cdecl init_hcrc_crt_init(void) { init_hcrc(); }
+__declspec(allocate(".CRT$XCU")) static void (__cdecl *init_hcrc_crt_init_fn)(void) = init_hcrc_crt_init;
+#endif
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Loosing the constructor property for other toolchains. Please adjust the patch to handle both implementations. (Hint: Put #if/else/endif in front of the line, define a macro to carry the attribute when applicable.)

Comment thread ports/libzvbi/portfile.cmake Outdated
Comment on lines +16 to +20
# autopoint (gettext) is not available in vcpkg's msys2 environment (Windows)
# nor on the Android CI hosts; since NLS is disabled anyway, skip it.
if(VCPKG_TARGET_IS_WINDOWS OR VCPKG_TARGET_IS_ANDROID)
set(ENV{AUTOPOINT} true)
endif()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gettext including autopoint would be available via dependencies.

So get rid of the misleading comment, and clarify what "true" means here:

Suggested change
# autopoint (gettext) is not available in vcpkg's msys2 environment (Windows)
# nor on the Android CI hosts; since NLS is disabled anyway, skip it.
if(VCPKG_TARGET_IS_WINDOWS OR VCPKG_TARGET_IS_ANDROID)
set(ENV{AUTOPOINT} true)
endif()
if(VCPKG_TARGET_IS_WINDOWS OR VCPKG_TARGET_IS_ANDROID)
set(ENV{AUTOPOINT} true) # the program
endif()

Comment thread ports/libzvbi/portfile.cmake Outdated
Comment on lines +22 to +28
if(NOT VCPKG_TARGET_IS_WINDOWS)
# The MSVC-compat patch creates Windows-only shim headers that shadow POSIX equivalents.
# Remove them so the autotools build uses the real system headers on Unix/macOS.
file(REMOVE "${SOURCE_PATH}/src/unistd.h")
file(REMOVE "${SOURCE_PATH}/src/strings.h")
file(REMOVE_RECURSE "${SOURCE_PATH}/src/sys")
endif()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like this pattern. Avoid the shims. Or put the shims in a subdir, and adjust the include path as needed. Or create them with portfile commands in the binary dirs, between configure and build.

Comment thread ports/libzvbi/portfile.cmake Outdated
vcpkg_make_install()
vcpkg_fixup_pkgconfig()

# Remove tools (not needed; avoids RPATH/headerpad issues on macOS).
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There shouldn't be RPATH issues if upstream isn't doing crazy things.
If we don't want the tools, the port shouldn't build them.
Often it is just removing one SUBDIRS entry Makefile.am.

@Greisby
Copy link
Copy Markdown
Contributor Author

Greisby commented May 15, 2026

Well, when I originally created this port, I ended up writing a CMake build for Windows because I couldn’t get it to build otherwise.

The Azure CI suggested a neat trick — set(ENV{AUTOPOINT} true) — but it still doesn’t build without autopoint.
So I eventually asked Copilot to generate a patch removing all references to autopoint so that reconfiguration would work.
If only I’d had Copilot back then!

Ok, now I'll examine your comments from yesterday and adjust accordingly.

@dg0yt
Copy link
Copy Markdown
Contributor

dg0yt commented May 15, 2026

The Azure CI suggested a neat trick — set(ENV{AUTOPOINT} true) — but it still doesn’t build without autopoint.
So I eventually asked Copilot to generate a patch removing all references to autopoint so that reconfiguration would work.
If only I’d had Copilot back then!

I assume I know where Copilot took the idea from.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants