SUMMARY="An AV1-compliant encoder/decoder library core"
DESCRIPTION="The Scalable Video Technology for AV1 (SVT-AV1 Encoder and \
Decoder) is an AV1-compliant encoder/decoder library core. The SVT-AV1 encoder\
 development is a work-in-progress targeting performance levels applicable to \
both VOD and Live encoding / transcoding video applications. The SVT-AV1 \
decoder implementation is targeting future codec research activities."
HOMEPAGE="https://github.com/AOMediaCodec/SVT-AV1"
COPYRIGHT="2019, Alliance for Open Media"
LICENSE="BSD (2-clause)"
REVISION="1"
SOURCE_URI="https://github.com/AOMediaCodec/SVT-AV1/archive/v$portVersion.tar.gz"
CHECKSUM_SHA256="0bc21e302d559290a563482ddec0c9a1370de33453453bdaade6890f1f7163f7"
SOURCE_DIR="SVT-AV1-$portVersion"
PATCHES="svt_av1-$portVersion.patchset"

ARCHITECTURES="all !x86_gcc2 ?x86"
SECONDARY_ARCHITECTURES="?x86"

commandBinDir=$binDir
commandSuffix=$secondaryArchSuffix
if [ "$targetArchitecture" = x86_gcc2 ]; then
	commandSuffix=
	commandBinDir=$prefix/bin
fi

libVersion="$portVersion"
libVersionCompat="$libVersion compat >= ${libVersion%%.*}"

PROVIDES="
	svt_av1$secondaryArchSuffix = $portVersion
	cmd:SvtAv1DecApp$commandSuffix
	cmd:SvtAv1EncApp$commandSuffix
	lib:libSvtAv1Dec$secondaryArchSuffix = 0.8.7 compat >= 0
	lib:libSvtAv1Enc$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	"

PROVIDES_devel="
	svt_av1${secondaryArchSuffix}_devel = $portVersion
	devel:libSvtAv1Dec$secondaryArchSuffix = 0.8.7 compat >= 0
	devel:libSvtAv1Enc$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	svt_av1$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:gcc$secondaryArchSuffix
	cmd:ninja
	cmd:yasm >= 1.2
	"

defineDebugInfoPackage svt_av1$secondaryArchSuffix \
	"$libDir"/libSvtAv1Dec.so.0.8.7 \
	"$libDir"/libSvtAv1Enc.so.$libVersion

BUILD()
{
	cmake -B build -G Ninja \
		-DBUILD_SHARED_LIBS=ON \
		-DNATIVE=OFF \
		-DCMAKE_BUILD_TYPE=RelWithDebInfo \
		$cmakeDirArgs
	ninja -C build $jobArgs
}

INSTALL()
{
	ninja -C build install

	prepareInstalledDevelLibs libSvtAv1Dec libSvtAv1Enc
	fixPkgconfig strict
	packageEntries devel $developDir
}
