Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

linuxarm64: enable rkmpp and rkrga for portable builds #403

Merged
merged 10 commits into from
Jul 24, 2024
154 changes: 154 additions & 0 deletions builder/patches/rkmpp/0000-fix-vpx-collisions.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
From 154a74b0a75eaecd5022cef3cb520ee949b578d9 Mon Sep 17 00:00:00 2001
From: Brett Jia <[email protected]>
Date: Wed, 19 Jun 2024 11:44:23 -0400
Subject: [PATCH] namespace vars that conflict with vpx
nyanmisaka marked this conversation as resolved.
Show resolved Hide resolved

---
mpp/hal/rkdec/vp9d/hal_vp9d_com.c | 30 +++++++++++++++---------------
mpp/hal/rkdec/vp9d/hal_vp9d_com.h | 6 +++---
2 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/mpp/hal/rkdec/vp9d/hal_vp9d_com.c b/mpp/hal/rkdec/vp9d/hal_vp9d_com.c
index c1913893..898970a8 100644
--- a/mpp/hal/rkdec/vp9d/hal_vp9d_com.c
+++ b/mpp/hal/rkdec/vp9d/hal_vp9d_com.c
@@ -838,7 +838,7 @@ static const RK_U8 vp9_default_coef_probs[4][2][2][6][6][3] = {
}
};

-const vp9_prob vp9_kf_y_mode_prob[INTRA_MODES][INTRA_MODES][INTRA_MODES - 1] = {
+const vp9_prob mpp_vp9_kf_y_mode_prob[INTRA_MODES][INTRA_MODES][INTRA_MODES - 1] = {
{
// above = dc
{ 137, 30, 42, 148, 151, 207, 70, 52, 91 }, // left = dc
@@ -953,7 +953,7 @@ const vp9_prob vp9_kf_y_mode_prob[INTRA_MODES][INTRA_MODES][INTRA_MODES - 1] = {
}
};

-const vp9_prob vp9_kf_uv_mode_prob[INTRA_MODES][INTRA_MODES - 1] = {
+const vp9_prob mpp_vp9_kf_uv_mode_prob[INTRA_MODES][INTRA_MODES - 1] = {
{ 144, 11, 54, 157, 195, 130, 46, 58, 108 }, // y = dc
{ 118, 15, 123, 148, 131, 101, 44, 93, 131 }, // y = v
{ 113, 12, 23, 188, 226, 142, 26, 32, 125 }, // y = h
@@ -966,7 +966,7 @@ const vp9_prob vp9_kf_uv_mode_prob[INTRA_MODES][INTRA_MODES - 1] = {
{ 102, 19, 66, 162, 182, 122, 35, 59, 128 } // y = tm
};

-const vp9_prob vp9_kf_partition_probs[PARTITION_CONTEXTS][PARTITION_TYPES - 1] = {
+const vp9_prob mpp_vp9_kf_partition_probs[PARTITION_CONTEXTS][PARTITION_TYPES - 1] = {
// 8x8 -> 4x4
{ 158, 97, 94 }, // a/l both not split
{ 93, 24, 99 }, // a split, l not split
@@ -1013,8 +1013,8 @@ MPP_RET hal_vp9d_output_probe(void *buf, void *dxva)
memset(buf, 0, 304 * 8);

if (intraFlag) {
- memcpy(partition_probs, vp9_kf_partition_probs, sizeof(partition_probs));
- memcpy(uv_mode_prob, vp9_kf_uv_mode_prob, sizeof(uv_mode_prob));
+ memcpy(partition_probs, mpp_vp9_kf_partition_probs, sizeof(partition_probs));
+ memcpy(uv_mode_prob, mpp_vp9_kf_uv_mode_prob, sizeof(uv_mode_prob));
} else {
memcpy(partition_probs, pic_param->prob.partition, sizeof(partition_probs));
memcpy(uv_mode_prob, pic_param->prob.uv_mode, sizeof(uv_mode_prob));
@@ -1073,11 +1073,11 @@ MPP_RET hal_vp9d_output_probe(void *buf, void *dxva)
}

//intra mode prob 80 x 128 bit
- for (i = 0; i < INTRA_MODES; i++) { //vp9_kf_y_mode_prob
+ for (i = 0; i < INTRA_MODES; i++) { //mpp_vp9_kf_y_mode_prob
RK_S32 byte_count = 0;
for (j = 0; j < INTRA_MODES; j++)
for (k = 0; k < INTRA_MODES - 1; k++) {
- mpp_put_bits(&bp, vp9_kf_y_mode_prob[i][j][k], 8);
+ mpp_put_bits(&bp, mpp_vp9_kf_y_mode_prob[i][j][k], 8);
byte_count++;
if (byte_count == 27) {
byte_count = 0;
@@ -1087,7 +1087,7 @@ MPP_RET hal_vp9d_output_probe(void *buf, void *dxva)
}
if (i < 4) {
for (m = 0; m < (i < 3 ? 23 : 21); m++)
- mpp_put_bits(&bp, ((vp9_prob *)(&vp9_kf_uv_mode_prob[0][0]))[i * 23 + m], 8);
+ mpp_put_bits(&bp, ((vp9_prob *)(&mpp_vp9_kf_uv_mode_prob[0][0]))[i * 23 + m], 8);
for (; m < 23; m++)
mpp_put_bits(&bp, 0, 8);
} else {
@@ -1462,7 +1462,7 @@ MPP_RET hal_vp9d_prob_flag_delta(void *buf, void *dxva)
memset(buf, 0, PROB_SIZE);

if (intraFlag) {
- memcpy(partition_probs, vp9_kf_partition_probs, sizeof(partition_probs));
+ memcpy(partition_probs, mpp_vp9_kf_partition_probs, sizeof(partition_probs));
} else {
memcpy(partition_flag, prob_flag->partition, sizeof(partition_flag));
memcpy(partition_delta, prob_delta->partition, sizeof(partition_delta));
@@ -1575,11 +1575,11 @@ MPP_RET hal_vp9d_prob_flag_delta(void *buf, void *dxva)
}

//intra mode prob 80 x 128 bit
- for (i = 0; i < INTRA_MODES; i++) { //vp9_kf_y_mode_prob
+ for (i = 0; i < INTRA_MODES; i++) { //mpp_vp9_kf_y_mode_prob
RK_S32 byte_count = 0;
for (j = 0; j < INTRA_MODES; j++)
for (k = 0; k < INTRA_MODES - 1; k++) {
- mpp_put_bits(&bp, vp9_kf_y_mode_prob[i][j][k], 8);
+ mpp_put_bits(&bp, mpp_vp9_kf_y_mode_prob[i][j][k], 8);
byte_count++;
if (byte_count == 27) {
byte_count = 0;
@@ -1589,7 +1589,7 @@ MPP_RET hal_vp9d_prob_flag_delta(void *buf, void *dxva)
}
if (i < 4) {
for (m = 0; m < (i < 3 ? 23 : 21); m++)
- mpp_put_bits(&bp, ((vp9_prob *)(&vp9_kf_uv_mode_prob[0][0]))[i * 23 + m], 8);
+ mpp_put_bits(&bp, ((vp9_prob *)(&mpp_vp9_kf_uv_mode_prob[0][0]))[i * 23 + m], 8);
for (; m < 23; m++)
mpp_put_bits(&bp, 0, 8);
} else {
@@ -1936,7 +1936,7 @@ MPP_RET hal_vp9d_prob_kf(void *buf)

for (i = 0; i < 16; i++)//kf_partition_prob
for (j = 0; j < 3; j++)
- mpp_put_bits(&bp, vp9_kf_partition_probs[i][j], 8);
+ mpp_put_bits(&bp, mpp_vp9_kf_partition_probs[i][j], 8);

//intra mode prob 80 x 128 bit, 10x 8x 128bit
for (i = 0; i < 10; i++) {
@@ -1944,7 +1944,7 @@ MPP_RET hal_vp9d_prob_kf(void *buf)
RK_U8 val = 0;
for (j = 0; j < 10; j++)
for (k = 0; k < 9; k++) {
- mpp_put_bits(&bp, vp9_kf_y_mode_prob[i][j][k], 8);
+ mpp_put_bits(&bp, mpp_vp9_kf_y_mode_prob[i][j][k], 8);
byte_count++;
if (byte_count == 27) {
byte_count = 0;
@@ -1954,7 +1954,7 @@ MPP_RET hal_vp9d_prob_kf(void *buf)
// 6x128 bit, 23x4 bytes
if (i < 4) {
for (m = 0; m < (i < 3 ? 23 : 21); m++) {
- val = ((RK_U8 *)(&vp9_kf_uv_mode_prob[0][0]))[i * 23 + m];
+ val = ((RK_U8 *)(&mpp_vp9_kf_uv_mode_prob[0][0]))[i * 23 + m];
mpp_put_bits(&bp, val, 8);
}
for (; m < 23; m++)
diff --git a/mpp/hal/rkdec/vp9d/hal_vp9d_com.h b/mpp/hal/rkdec/vp9d/hal_vp9d_com.h
index 8dee8e56..3c41a935 100644
--- a/mpp/hal/rkdec/vp9d/hal_vp9d_com.h
+++ b/mpp/hal/rkdec/vp9d/hal_vp9d_com.h
@@ -77,9 +77,9 @@ do{\
}} while (0)


-extern const vp9_prob vp9_kf_y_mode_prob[INTRA_MODES][INTRA_MODES][INTRA_MODES - 1];
-extern const vp9_prob vp9_kf_uv_mode_prob[INTRA_MODES][INTRA_MODES - 1];
-extern const vp9_prob vp9_kf_partition_probs[PARTITION_CONTEXTS][PARTITION_TYPES - 1];
+extern const vp9_prob mpp_vp9_kf_y_mode_prob[INTRA_MODES][INTRA_MODES][INTRA_MODES - 1];
+extern const vp9_prob mpp_vp9_kf_uv_mode_prob[INTRA_MODES][INTRA_MODES - 1];
+extern const vp9_prob mpp_vp9_kf_partition_probs[PARTITION_CONTEXTS][PARTITION_TYPES - 1];

#ifdef __cplusplus
extern "C" {
--
2.34.1

27 changes: 27 additions & 0 deletions builder/patches/rkrga/0000-build-static.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
From 2a8381af76eab5bec53b74ca72f7855576ba780d Mon Sep 17 00:00:00 2001
From: Brett Jia <[email protected]>
Date: Wed, 19 Jun 2024 21:52:59 -0400
Subject: [PATCH] switch meson to build static lib

---
meson.build | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/meson.build b/meson.build
index be2c2e9bb249..6f774754d628 100644
--- a/meson.build
+++ b/meson.build
@@ -30,12 +30,11 @@ librga_srcs = [

incdir = include_directories('include', 'im2d_api', 'core/hardware', 'core/utils', 'core/3rdparty/libdrm/include/drm')

-librga = shared_library(
+librga = static_library(
bjia56 marked this conversation as resolved.
Show resolved Hide resolved
'rga',
librga_srcs,
dependencies : [libthreads_dep],
include_directories : incdir,
- version : meson.project_version(),
cpp_args : ['-w'],
install : true,
)
45 changes: 45 additions & 0 deletions builder/scripts.d/60-rkmpp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash

SCRIPT_REPO="https://github.com/nyanmisaka/mpp.git"
SCRIPT_COMMIT="2218dc0fc57062c0d33d06d350aea73d9fef5d57"

ffbuild_enabled() {
[[ $TARGET == linux* ]] && [[ $TARGET == *arm64 ]] && return 0
return -1
}

ffbuild_dockerstage() {
to_df "RUN --mount=src=${SELF},dst=/stage.sh --mount=src=patches/rkmpp,dst=/patches run_stage /stage.sh"
}

ffbuild_dockerbuild() {
git clone "$SCRIPT_REPO" mpp
cd mpp
git checkout "$SCRIPT_COMMIT"

for patch in /patches/*.patch; do
echo "Applying $patch"
patch -p1 < "$patch"
done

mkdir rkmpp_build
cd rkmpp_build
cmake \
-DCMAKE_INSTALL_PREFIX="$FFBUILD_PREFIX" \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=OFF \
..

make -j$(nproc)
make install

echo "Libs.private: -lstdc++" >> "$FFBUILD_PREFIX"/lib/pkgconfig/rockchip_mpp.pc
}
bjia56 marked this conversation as resolved.
Show resolved Hide resolved

ffbuild_configure() {
echo --enable-rkmpp
}

ffbuild_unconfigure() {
echo --disable-rkmpp
}
48 changes: 48 additions & 0 deletions builder/scripts.d/60-rkrga.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash

SCRIPT_REPO="https://github.com/nyanmisaka/rk-mirrors.git"
SCRIPT_COMMIT="a9fc19e6b906d7cecd6bcefbd45e5e151831d33f"

ffbuild_enabled() {
[[ $TARGET == linux* ]] && [[ $TARGET == *arm64 ]] && return 0
return -1
}

ffbuild_dockerstage() {
to_df "RUN --mount=src=${SELF},dst=/stage.sh --mount=src=patches/rkrga,dst=/patches run_stage /stage.sh"
}

ffbuild_dockerbuild() {
git clone "$SCRIPT_REPO" rkrga
cd rkrga
git checkout "$SCRIPT_COMMIT"

for patch in /patches/*.patch; do
echo "Applying $patch"
patch -p1 < "$patch"
done

cd ..

meson setup rkrga rkrga_build \
--cross-file=/cross.meson \
--prefix=${FFBUILD_PREFIX} \
--buildtype=release \
--default-library=static \
-Dcpp_args=-fpermissive \
-Dlibdrm=false \
-Dlibrga_demo=false

meson configure rkrga_build
ninja -C rkrga_build install

echo "Libs.private: -lstdc++" >> "$FFBUILD_PREFIX"/lib/pkgconfig/librga.pc
}
bjia56 marked this conversation as resolved.
Show resolved Hide resolved

ffbuild_configure() {
echo --enable-rkrga
}

ffbuild_unconfigure() {
echo --disable-rkrga
}
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ Index: jellyfin-ffmpeg/configure
{ enabled libdrm ||
die "ERROR: rkmpp requires --enable-libdrm"; }
}
+enabled rkrga && require rkrga rga/RgaApi.h c_RkRgaBlit -lrga &&
+ { require rkrga rga/im2d.h querystring -lrga &&
+enabled rkrga && require_pkg_config rkrga librga rga/RgaApi.h c_RkRgaBlit&&
bjia56 marked this conversation as resolved.
Show resolved Hide resolved
+ { require_pkg_config rkrga librga rga/im2d.h querystring &&
+ { enabled rkmpp ||
+ die "ERROR: rkrga requires --enable-rkmpp"; }
+ }
Expand Down
Loading