openh264: add recipe

This commit is contained in:
Gerasim Troeglazov
2024-08-01 20:01:57 +10:00
parent edaa8281c0
commit 0ab39de2a1
2 changed files with 169 additions and 0 deletions

View File

@@ -0,0 +1,99 @@
SUMMARY="Open Source H.264 Codec"
DESCRIPTION="OpenH264 is a codec library which supports H.264 encoding and decoding.
It is suitable for use in real time applications such as WebRTC.
Encoder Features:
* Constrained Baseline Profile up to Level 5.2 (Max frame size is 36864 macro-blocks)
* Arbitrary resolution, not constrained to multiples of 16x16
* Rate control with adaptive quantization, or constant quantization
* Slice options: 1 slice per frame, N slices per frame, N macroblocks per slice, or N bytes per slice
* Multiple threads automatically used for multiple slices
* Temporal scalability up to 4 layers in a dyadic hierarchy
* Simulcast AVC up to 4 resolutions from a single input
* Spatial simulcast up to 4 resolutions from a single input
* Long Term Reference (LTR) frames
* Memory Management Control Operation (MMCO)
* Reference picture list modification
* Single reference frame for inter prediction
* Multiple reference frames when using LTR and/or 3-4 temporal layers
* Periodic and on-demand Instantaneous Decoder Refresh (IDR) frame insertion
* Dynamic changes to bit rate, frame rate, and resolution
* Annex B byte stream output
* YUV 4:2:0 planar input
Decoder Features:
* Constrained Baseline Profile up to Level 5.2 (Max frame size is 36864 macro-blocks)
* Arbitrary resolution, not constrained to multiples of 16x16
* Single thread for all slices
* Long Term Reference (LTR) frames
* Memory Management Control Operation (MMCO)
* Reference picture list modification
* Multiple reference frames when specified in Sequence Parameter Set (SPS)
* Annex B byte stream input
* YUV 4:2:0 planar output
"
HOMEPAGE="http://www.openh264.org/"
COPYRIGHT="Cisco"
LICENSE="BSD (2-clause)"
REVISION="1"
SOURCE_URI="https://github.com/cisco/openh264/archive/refs/tags/v$portVersion.tar.gz"
CHECKSUM_SHA256="8ffbe944e74043d0d3fb53d4a2a14c94de71f58dbea6a06d0dc92369542958ea"
PATCHES="openh264-$portVersion.patchset"
ARCHITECTURES="all !x86_gcc2"
SECONDARY_ARCHITECTURES="x86"
PROVIDES="
openh264$secondaryArchSuffix = $portVersion compat >= 2
lib:libopenh264$secondaryArchSuffix = $portVersion compat >= 2
"
REQUIRES="
haiku$secondaryArchSuffix
"
PROVIDES_devel="
openh264${secondaryArchSuffix}_devel = $portVersion compat >= 2
devel:libopenh264$secondaryArchSuffix = $portVersion compat >= 2
"
REQUIRES_devel="
openh264$secondaryArchSuffix == $portVersion base
"
BUILD_REQUIRES="
haiku${secondaryArchSuffix}_devel
"
BUILD_PREREQUIRES="
cmd:gcc$secondaryArchSuffix
cmd:meson
cmd:nasm
cmd:ninja
cmd:pkg_config$secondaryArchSuffix
"
BUILD()
{
meson \
--buildtype=release \
--prefix=$prefix \
--libdir=$libDir \
--libexecdir=$binDir \
--datadir=$dataDir \
--localedir=$dataDir/locale \
--includedir=$includeDir \
--sysconfdir=$settingsDir \
builddir
ninja -C builddir
}
INSTALL()
{
ninja -C builddir install
prepareInstalledDevelLib libopenh264
fixPkgconfig
# devel package
packageEntries devel \
$developDir
}

View File

@@ -0,0 +1,70 @@
From bd18690766fc5ae07757b5ff1b39576cc9b6fe57 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Thu, 1 Aug 2024 19:54:41 +1000
Subject: Fix for Haiku
diff --git a/codec/common/src/WelsThreadLib.cpp b/codec/common/src/WelsThreadLib.cpp
index b1072e0..62b4815 100644
--- a/codec/common/src/WelsThreadLib.cpp
+++ b/codec/common/src/WelsThreadLib.cpp
@@ -50,7 +50,7 @@
#include <unistd.h>
#ifdef __EMSCRIPTEN__
#include <emscripten/threading.h>
-#elif !defined(__Fuchsia__)
+#elif !defined(__Fuchsia__) && !defined(__HAIKU__)
#include <sys/sysctl.h>
#endif
#ifdef __APPLE__
@@ -65,6 +65,9 @@
#ifdef __ANDROID__
#include <android/api-level.h>
#endif
+#ifdef __HAIKU__
+#include <OS.h>
+#endif
#include "WelsThreadLib.h"
#include <stdio.h>
@@ -234,7 +237,7 @@ WELS_THREAD_ERROR_CODE WelsThreadCreate (WELS_THREAD_HANDLE* thread, LPWELS_
err = pthread_attr_init (&at);
if (err)
return err;
-#if !defined(__ANDROID__) && !defined(__Fuchsia__)
+#if !defined(__ANDROID__) && !defined(__Fuchsia__) && !defined(__HAIKU__)
err = pthread_attr_setscope (&at, PTHREAD_SCOPE_SYSTEM);
if (err)
return err;
@@ -507,6 +510,15 @@ WELS_THREAD_ERROR_CODE WelsQueryLogicalProcessInfo (WelsLogicalProcessInfo* p
return WELS_THREAD_ERROR_OK;
+#elif defined(__HAIKU__)
+ system_info sysinfo;
+ if (get_system_info(&sysinfo) == B_OK) {
+ pInfo->ProcessorCount = sysinfo.cpu_count;
+ } else {
+ pInfo->ProcessorCount = 1;
+ }
+ return WELS_THREAD_ERROR_OK;
+
#elif defined(__EMSCRIPTEN__)
// There is not yet a way to determine CPU count in emscripten JS environment.
diff --git a/meson.build b/meson.build
index 4f4376f..d20e8fd 100644
--- a/meson.build
+++ b/meson.build
@@ -57,7 +57,7 @@ cpp_lib = '-lstdc++'
libm_dep = cpp.find_library('m', required : false)
deps += [libm_dep]
-if ['linux', 'android', 'ios', 'darwin'].contains(system)
+if ['linux', 'android', 'ios', 'darwin', 'haiku'].contains(system)
asm_format32 = 'elf'
asm_format64 = 'elf64'
if ['ios', 'darwin'].contains(system)
--
2.45.2