pkuvcl / davs2

An open-source decoder of AVS2-P2/IEEE1857.4 video coding standard
GNU General Public License v2.0
129 stars 52 forks source link

Build ffmpeg with avs2 for android #14

Closed CathyXuBUPT closed 5 years ago

CathyXuBUPT commented 5 years ago

Hi,I want to build a shared library of ffmpeg with avs2 for android. \ Before that,I have built libxavs2.so and libdavs2.so successfully by using android_build.sh in xavs2/build/linux. \ But when I try to build FFmpegAVS2 with the following script,it cannot find davs2.

The script is :

#!/bin/zsh
ARCH=arm64
SDK_VERSION=21

TOOLCHAIN=/home/xu/my_toolchains_r17c/${ARCH}
NDKROOT=$TOOLCHAIN/sysroot
build_dir=`pwd`  # current dir

# ------------------------------------------------------
if [ "$ARCH" = "arm64" ]
then
    PLATFORM_PREFIX="aarch64-linux-android-"
    HOST="aarch64"
    PLATFORM_VERSION=4.9
    EXTRA_CFLAGS="-march=armv8-a -D__ARM_ARCH_7__ -D__ARM_ARCH_7A__ -fPIE -pie -D__ANDROID_API__=21"
else
    PLATFORM_PREFIX="arm-linux-androideabi-"
    HOST="arm"
    PLATFORM_VERSION=4.9
    EXTRA_CFLAGS="-march=armv7-a -mfloat-abi=softfp -mfpu=neon -D__ARM_ARCH_7__ -D__ARM_ARCH_7A__ -fPIE -pie"
fi

PREFIX=$(pwd)/android/${ARCH}
CROSS_PREFIX=$TOOLCHAIN/bin/${PLATFORM_PREFIX}
ADDI_LDFLAGS="-L$TOOLCHAIN/sysroot/usr/lib -fPIE -pie -shared"

#rm -f $(pwd)/compat/strtod.o
export PKG_CONFIG_PATH=$(pwd)/android/${ARCH}/lib/pkgconfig

function build_one
{
./configure \
--prefix=$PREFIX \
--enable-gpl \
--enable-libxavs2 \
--enable-libdavs2 \
--enable-shared \
--enable-static \
--disable-doc \
--enable-cross-compile \
--cross-prefix=$CROSS_PREFIX \
--target-os=android \
--arch=aarch64 \
--sysroot=$NDKROOT \
--extra-cflags="-Os -fpic $EXTRA_CFLAGS" \
--extra-ldflags="$ADDI_LDFLAGS" \
--enable-protocol=file \
--enable-pic \
--enable-small \
--disable-programs \
--disable-symver \
$ADDITIONAL_CONFIG_FLAG
}

ADDITIONAL_CONFIG_FLAG="--enable-yasm"

cd FFmpegAVS2
echo "Starting build_one"
build_one
echo "build_one done!"
#make clean
#make
#echo "make done!"
#make install
#echo "make install done!"

It report an error:

ERROR: davs2 >= 1.6.0 not found using pkg-config

But in PKG_CONFIG_PATH($(pwd)/android/${ARCH}/lib/pkgconfig),there exsits a davs2.pc:

prefix=/home/xu/test/ffmpeg-AVS2-Android/android/arm64
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include

Name: davs2
Description: AVS2 (IEEE 1857.4) decoder library
Version: 1.6.181
Libs: -L${exec_prefix}/lib -ldavs2 
Libs.private: -lm
Cflags: -I${prefix}/include

and the version >= 1.6.0.

The ffbuild/config.log is :

check_complexfunc cexp 1
test_ld cc
test_cc
BEGIN /tmp/ffconf.xk5VqWQQ/test.c
    1   #include <complex.h>
    2   #include <math.h>
    3   float foo(complex float f, complex float g) { return cexp(f * I); }
    4   int main(void){ return (int) foo; }
END /tmp/ffconf.xk5VqWQQ/test.c
/home/xu/my_toolchains/arm64/bin/aarch64-linux-android-gcc --sysroot=/home/xu/my_toolchains/arm64/sysroot -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Dstrtod=avpriv_strtod -DPIC -Os -fpic -march=armv8-a -D__ARM_ARCH_7__ -D__ARM_ARCH_7A__ -fPIE -pie -D__ANDROID_API__=21 -std=c11 -fomit-frame-pointer -fPIC -pthread -c -o /tmp/ffconf.xk5VqWQQ/test.o /tmp/ffconf.xk5VqWQQ/test.c
/tmp/ffconf.xk5VqWQQ/test.c: In function 'foo':
/tmp/ffconf.xk5VqWQQ/test.c:3:1: warning: implicit declaration of function 'cexp' [-Wimplicit-function-declaration]
 float foo(complex float f, complex float g) { return cexp(f * I); }
 ^
/tmp/ffconf.xk5VqWQQ/test.c:3:54: warning: incompatible implicit declaration of built-in function 'cexp'
 float foo(complex float f, complex float g) { return cexp(f * I); }
                                                      ^
/tmp/ffconf.xk5VqWQQ/test.c: In function 'main':
/tmp/ffconf.xk5VqWQQ/test.c:4:24: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
 int main(void){ return (int) foo; }
                        ^
/home/xu/my_toolchains/arm64/bin/aarch64-linux-android-gcc -L/home/xu/my_toolchains/arm64/sysroot/usr/lib -fPIE -pie -shared --sysroot=/home/xu/my_toolchains/arm64/sysroot -Wl,--as-needed -Wl,-z,noexecstack -o /tmp/ffconf.xk5VqWQQ/test /tmp/ffconf.xk5VqWQQ/test.o
require_pkg_config libdavs2 davs2 >= 1.6.0 davs2.h davs2_decoder_open
check_pkg_config libdavs2 davs2 >= 1.6.0 davs2.h davs2_decoder_open
test_pkg_config libdavs2 davs2 >= 1.6.0 davs2.h davs2_decoder_open
false --exists --print-errors davs2 >= 1.6.0
ERROR: davs2 >= 1.6.0 not found using pkg-config
luofalei commented 5 years ago

It seems the linker could not find the library in the directory as follows. Could libx264 be integrated to ffmpeg in this way?

CathyXuBUPT commented 5 years ago

I tried it and found the reason for this error: configure does not use the default pkg-config, which is resolved when using configure with the pkg-config tool.Thanks.