mpv-0.33.1

10 views
Skip to first unread message

ABE Shin-ichi

unread,
Apr 24, 2021, 9:04:03 AM4/24/21
to slackware-tech
mpv-0.33.1 for slackware64-current (2021-04-22) のコンパイルについてのメモです。

1. 要求ライブラリ : libplacebo-3.120 --- せっかくなので最新版にアップデート

 ベースになるSlackBuildは SlackBuilds.org のものを使用。
https://slackbuilds.org/repository/14.2/graphics/libplacebo/

=== libplacebo.info 抜粋 ===
PRGNAM="libplacebo"
VERSION="3.120"
HOMEPAGE="https://code.videolan.org/videolan/libplacebo"
DOWNLOAD="https://code.videolan.org/videolan/libplacebo/-/archive/v3.120/libplacebo-v3.120.tar.gz"
MD5SUM="c1924f7339971a7863d89e4448faaa9d"
============================


2. mpv-0.33.1 のコンパイル
 
 ベースのSlackBuildはSlackBuilds.org (https://slackbuilds.org/repository/14.2/multimedia/mpv/ )
にあるものを使用しますが、mpv-0.33.1 オリジナルソースはそのままだとコンパイルエラーになるため、
Arch情報を参考にして以下のパッチを作成し適用します。

=== mpv-0.33.1_vo_gpu-placebo_fix.patch ===

--- mpv-0.33.1/video/out/placebo/ra_pl.c 2021-04-06 01:45:41.000000000 +0900
+++ mpv-0.33.1.new/video/out/placebo/ra_pl.c 2021-04-21 23:37:11.084000636 +0900
@@ -22,9 +22,7 @@
return ra->fns == &ra_fns_pl ? get_gpu(ra) : NULL;
}

-#if PL_API_VER >= 60
static struct pl_timer *get_active_timer(const struct ra *ra);
-#endif

struct ra *ra_create_pl(const struct pl_gpu *gpu, struct mp_log *log)
{
@@ -144,8 +142,14 @@
.blit_dst = pltex->params.blit_dst,
.host_mutable = pltex->params.host_writable,
.downloadable = pltex->params.host_readable,
+#if PL_API_VER >= 103
+ // These don't exist upstream, so just pick something reasonable
+ .src_linear = pltex->params.format->caps & PL_FMT_CAP_LINEAR,
+ .src_repeat = false,
+#else
.src_linear = pltex->params.sample_mode == PL_TEX_SAMPLE_LINEAR,
.src_repeat = pltex->params.address_mode == PL_TEX_ADDRESS_REPEAT,
+#endif
},
.priv = (void *) pltex,
};
@@ -157,32 +161,6 @@
const struct ra_tex_params *params)
{
const struct pl_gpu *gpu = get_gpu(ra);
-
- // Check size limits
- bool ok = false;
- switch (params->dimensions) {
- case 1:
- ok = params->w <= gpu->limits.max_tex_1d_dim;
- break;
-
- case 2:
- ok = params->w <= gpu->limits.max_tex_2d_dim &&
- params->h <= gpu->limits.max_tex_2d_dim;
- break;
-
- case 3:
- ok = params->w <= gpu->limits.max_tex_2d_dim &&
- params->h <= gpu->limits.max_tex_2d_dim &&
- params->d <= gpu->limits.max_tex_2d_dim;
- break;
- };
-
- if (!ok) {
- MP_ERR(ra, "Texture size %dx%dx%d exceeds dimension limits!\n",
- params->w, params->h, params->d);
- return NULL;
- }
-
const struct pl_tex *pltex = pl_tex_create(gpu, &(struct pl_tex_params) {
.w = params->w,
.h = params->dimensions >= 2 ? params->h : 0,
@@ -195,10 +173,12 @@
.blit_dst = params->blit_dst || params->render_dst,
.host_writable = params->host_mutable,
.host_readable = params->downloadable,
+#if PL_API_VER < 103
.sample_mode = params->src_linear ? PL_TEX_SAMPLE_LINEAR
: PL_TEX_SAMPLE_NEAREST,
.address_mode = params->src_repeat ? PL_TEX_ADDRESS_REPEAT
: PL_TEX_ADDRESS_CLAMP,
+#endif
.initial_data = params->initial_data,
});

@@ -209,6 +189,10 @@
return NULL;
}

+ // Keep track of these, so we can correctly bind them later
+ ratex->params.src_repeat = params->src_repeat;
+ ratex->params.src_linear = params->src_linear;
+
return ratex;
}

@@ -230,9 +214,7 @@
.buf = params->buf ? params->buf->priv : NULL,
.buf_offset = params->buf_offset,
.ptr = (void *) params->src,
-#if PL_API_VER >= 60
.timer = get_active_timer(ra),
-#endif
};

const struct pl_buf *staging = NULL;
@@ -285,9 +267,7 @@
.tex = tex,
.ptr = params->dst,
.stride_w = params->stride / texel_size,
-#if PL_API_VER >= 60
.timer = get_active_timer(ra),
-#endif
};

uint8_t *staging = NULL;
@@ -320,19 +300,7 @@
[RA_BUF_TYPE_SHARED_MEMORY] = 0,
};

- const struct pl_gpu *gpu = get_gpu(ra);
- size_t max_size[] = {
- [PL_BUF_TEX_TRANSFER] = gpu->limits.max_xfer_size,
- [PL_BUF_UNIFORM] = gpu->limits.max_ubo_size,
- [PL_BUF_STORAGE] = gpu->limits.max_ssbo_size,
- };
-
- if (params->size > max_size[buf_type[params->type]]) {
- MP_ERR(ra, "Buffer size %zu exceeds size limits!\n", params->size);
- return NULL;
- }
-
- const struct pl_buf *plbuf = pl_buf_create(gpu, &(struct pl_buf_params) {
+ const struct pl_buf *plbuf = pl_buf_create(get_gpu(ra), &(struct pl_buf_params) {
.type = buf_type[params->type],
.size = params->size,
.host_mapped = params->host_mapped,
@@ -399,7 +367,18 @@
pldst.y1 = MPMIN(MPMAX(dst_rc->y1, 0), dst->params.h);
}

+#if PL_API_VER >= 103
+ pl_tex_blit(get_gpu(ra), &(struct pl_tex_blit_params) {
+ .src = src->priv,
+ .dst = dst->priv,
+ .src_rc = plsrc,
+ .dst_rc = pldst,
+ .sample_mode = src->params.src_linear ? PL_TEX_SAMPLE_LINEAR
+ : PL_TEX_SAMPLE_NEAREST,
+ });
+#else
pl_tex_blit(get_gpu(ra), dst->priv, src->priv, pldst, plsrc);
+#endif
}

static const enum pl_var_type var_type[RA_VARTYPE_COUNT] = {
@@ -627,9 +606,17 @@
struct pl_desc_binding bind;
switch (inp->type) {
case RA_VARTYPE_TEX:
- case RA_VARTYPE_IMG_W:
- bind.object = (* (struct ra_tex **) val->data)->priv;
+ case RA_VARTYPE_IMG_W: {
+ struct ra_tex *tex = *((struct ra_tex **) val->data);
+ bind.object = tex->priv;
+#if PL_API_VER >= 103
+ bind.sample_mode = tex->params.src_linear ? PL_TEX_SAMPLE_LINEAR
+ : PL_TEX_SAMPLE_NEAREST;
+ bind.address_mode = tex->params.src_repeat ? PL_TEX_ADDRESS_REPEAT
+ : PL_TEX_ADDRESS_CLAMP;
+#endif
break;
+ }
case RA_VARTYPE_BUF_RO:
case RA_VARTYPE_BUF_RW:
bind.object = (* (struct ra_buf **) val->data)->priv;
@@ -666,8 +653,6 @@
pl_pass_run(get_gpu(ra), &pl_params);
}

-#if PL_API_VER >= 60
-
struct ra_timer_pl {
// Because libpplacebo only supports one operation per timer, we need
// to use multiple pl_timers to sum up multiple passes/transfers
@@ -739,8 +724,6 @@
return t->timers[t->idx_timers++];
}

-#endif // PL_API_VER >= 60
-
static struct ra_fns ra_fns_pl = {
.destroy = destroy_ra_pl,
.tex_create = tex_create_pl,
@@ -759,11 +742,9 @@
.renderpass_create = renderpass_create_pl,
.renderpass_destroy = renderpass_destroy_pl,
.renderpass_run = renderpass_run_pl,
-#if PL_API_VER >= 60
.timer_create = timer_create_pl,
.timer_destroy = timer_destroy_pl,
.timer_start = timer_start_pl,
.timer_stop = timer_stop_pl,
-#endif
};

======================================================


mpv.SlackBuildの例
======================================================
#!/bin/sh

# Slackware build script for mpv

# Copyright 2015 John Vogel Corning, NY USA
# All rights reserved.
#
# Redistribution and use of this script, with or without modification, is
# permitted provided that the following conditions are met:
#
# 1. Redistributions of this script must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

PRGNAM=mpv
VERSION=${VERSION:-0.33.1}
BUILD=${BUILD:-2}
# 2020-06-17 : Rebuild with "--enable-libplacebo" Option
# 2021-04-21 : minor version bump to 0.33.1 and subversion 2jw (against libplacebo-3.120)
TAG=${TAG:-_SBo}

if [ -z "$ARCH" ]; then
case "$( uname -m )" in
i?86) ARCH=i586 ;;
arm*) ARCH=arm ;;
*) ARCH=$( uname -m ) ;;
esac
fi

CWD=$(pwd)
TMP=${TMP:-/tmp/SBo}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}

# The SLKFLAGS aren't currently used. They do no harm and can
# be left as a placeholder in case they are ever needed.
if [ "$ARCH" = "i586" ]; then
SLKCFLAGS="-O2 -march=i586 -mtune=i686"
LIBDIRSUFFIX=""
elif [ "$ARCH" = "i686" ]; then
SLKCFLAGS="-O2 -march=i686 -mtune=i686"
LIBDIRSUFFIX=""
elif [ "$ARCH" = "x86_64" ]; then
SLKCFLAGS="-O2 -fPIC"
LIBDIRSUFFIX="64"
else
SLKCFLAGS="-O2"
LIBDIRSUFFIX=""
fi

set -e

rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf $PRGNAM-$VERSION
tar xvf $CWD/$PRGNAM-$VERSION.tar.gz
#cp $CWD/waf-2.0.9 $PRGNAM-$VERSION/waf
#cp $CWD/waf-2.0.22 $PRGNAM-$VERSION/waf
#chmod +x $PRGNAM-$VERSION/waf
cd $PRGNAM-$VERSION
# vo_gpu: placebo: update for upstream API changes
zcat $CWD/mpv-0.33.1_vo_gpu-placebo_fix.patch.gz | patch -p1 --verbose || exit 1

chown -R root:root .
find -L . \
\( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
-o -perm 511 \) -exec chmod 755 {} \; -o \
\( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
-o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;

DOCS="Copyright LICENSE.GPL LICENSE.LGPL README.md RELEASE_NOTES VERSION"
MANUAL="DOCS/*.md DOCS/*.rst DOCS/*.txt"

# This leaves an opening for build options.
BUILD_OPTS=${BUILD_OPTS:-""}

PKG_CONFIG_PATH="/usr/lib${LIBDIRSUFFIX}/pkgconfig"
export PKG_CONFIG_PATH

# Setting CFLAGS and CXXFLAGS breaks configure.
./bootstrap.py
./waf configure \
--prefix=/usr \
--libdir=/usr/lib${LIBDIRSUFFIX} \
--enable-libbluray \
--enable-dvdnav \
--enable-libplacebo \
--enable-libmpv-shared \
--confdir=/etc/$PRGNAM \
--mandir=/usr/man \
--docdir=/usr/doc/$PRGNAM-$VERSION \
$BUILD_OPTS

./waf build
./waf --destdir=$PKG install

for f in $PKG/etc/mpv/*.conf ; do
mv $f{,.new}
done

find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" \
| grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true

if [ -d $PKG/usr/man ]; then
find $PKG/usr/man -type f -exec gzip -9 {} \;
for i in $( find $PKG/usr/man -type l ) ; do
ln -s $( readlink $i ).gz $i.gz
rm $i
done
fi

mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
cp -a $DOCS $PKG/usr/doc/$PRGNAM-$VERSION
mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION/manual
for f in $MANUAL; do
cp -a $f $PKG/usr/doc/$PRGNAM-$VERSION/manual/
done
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild

mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cat $CWD/doinst.sh > $PKG/install/doinst.sh

cd $PKG
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-txz}

==================================================

補足)
 mpvは独自のGUIフロントエンドを持たないため、GUIで使用したい場合は smplayerを
 インストールすれば可能。




--
JW (ABE Shin-ichi ) <shin...@nifty.com>
Reply all
Reply to author
Forward
0 new messages