带有 Neon 优化的 FFMPEG

发布于 2024-12-17 04:59:38 字数 2353 浏览 2 评论 0原文

我正在使用 ffmpeg 在 Android 上解码 h.264 视频文件。性能非常低。我想在 ffmpeg 中启用 neon 优化以提高性能。尽管在配置文件中添加了 neon 相关命令,但我没有看到性能提升。有人可以告诉我我是否在任何地方出错了?我的配置文件如下所示。

    function build_one_r6
{
make clean
./configure \
    --prefix=$PREFIX \
    --disable-shared \
    --enable-static \
    --enable-version3 \
    --disable-doc \
    --disable-ffmpeg \
    --disable-ffplay \
    --disable-ffprobe \
    --disable-ffserver \
    --disable-avdevice \
    --disable-avfilter \
    --disable-postproc \
    --enable-small \
    --cross-prefix=$PREBUILT/bin/arm-linux-androideabi- \
    --enable-cross-compile \
    --target-os=linux \
    --extra-cflags="-I$PLATFORM/usr/include -fpic -DANDROID -DHAVE_SYS_UIO_H=1 -fasm -Wno-psabi -fno-short-enums -fno-strict-aliasing $OPTIMIZE_CFLAGS" \
    --extra-ldflags="-Wl,-rpath-link=$PLATFORM/usr/lib -L$PLATFORM/usr/lib -nostdlib -lc -lm -ldl -llog" \
    --arch=arm \
    --disable-symver \
    --disable-debug \
    --disable-indevs \
    --disable-encoders \
    --disable-bsfs \
    --disable-filters \
$ADDITIONAL_CONFIGURE_FLAG || exit 1;
sed -i 's/HAVE_LRINT 0/HAVE_LRINT 1/g' config.h
sed -i 's/HAVE_LRINTF 0/HAVE_LRINTF 1/g' config.h
sed -i 's/HAVE_ROUND 0/HAVE_ROUND 1/g' config.h
sed -i 's/HAVE_ROUNDF 0/HAVE_ROUNDF 1/g' config.h
sed -i 's/HAVE_TRUNC 0/HAVE_TRUNC 1/g' config.h
sed -i 's/HAVE_TRUNCF 0/HAVE_TRUNCF 1/g' config.h
make  -j4 install || exit 1;
$PREBUILT/bin/arm-linux-androideabi-ar d libavcodec/libavcodec.a inverse.o || exit 1;
$PREBUILT/bin/arm-linux-androideabi-ld -rpath-link=$PLATFORM/usr/lib -L$PLATFORM/usr/lib  -soname libffmpeg.so -shared -nostdlib  -z,noexecstack -Bsymbolic --whole-archive --no-undefined -o $PREFIX/lib/libffmpeg.so libavcodec/libavcodec.a libavformat/libavformat.a libavutil/libavutil.a libswscale/libswscale.a -lc -lm -lz -ldl -llog  --warn-once  --dynamic-linker=/system/bin/linker $PREBUILT/lib/gcc/arm-linux-androideabi/4.4.3/libgcc.a || exit 1;

}


#armv5te
CPU=armv5te
OPTIMIZE_CFLAGS="-marm -march=$CPU "
PREFIX=../../build/android/armeabi
ADDITIONAL_CONFIGURE_FLAG=
build_one_r6


#arm v7n
CPU=armv7-a
OPTIMIZE_CFLAGS="-mfloat-abi=softfp -mfpu=neon -marm -march=$CPU -mtune=cortex-a8"
PREFIX=../../build/android/armeabi-v7a
ADDITIONAL_CONFIGURE_FLAG="--enable-neon --disable-armv5te --disable-armv6 --disable-armv6t2"
build_one_r6enter code here

I am decoding an h.264 video file on android using ffmpeg. The performace is very low. I would like to enable neon optimzation in ffmpeg to improve the performace. Inspite of adding the neon related commands in the config file, I don't see performance gain. Can someone tell me if I am going wrong anywhere? My config file is as given below.

    function build_one_r6
{
make clean
./configure \
    --prefix=$PREFIX \
    --disable-shared \
    --enable-static \
    --enable-version3 \
    --disable-doc \
    --disable-ffmpeg \
    --disable-ffplay \
    --disable-ffprobe \
    --disable-ffserver \
    --disable-avdevice \
    --disable-avfilter \
    --disable-postproc \
    --enable-small \
    --cross-prefix=$PREBUILT/bin/arm-linux-androideabi- \
    --enable-cross-compile \
    --target-os=linux \
    --extra-cflags="-I$PLATFORM/usr/include -fpic -DANDROID -DHAVE_SYS_UIO_H=1 -fasm -Wno-psabi -fno-short-enums -fno-strict-aliasing $OPTIMIZE_CFLAGS" \
    --extra-ldflags="-Wl,-rpath-link=$PLATFORM/usr/lib -L$PLATFORM/usr/lib -nostdlib -lc -lm -ldl -llog" \
    --arch=arm \
    --disable-symver \
    --disable-debug \
    --disable-indevs \
    --disable-encoders \
    --disable-bsfs \
    --disable-filters \
$ADDITIONAL_CONFIGURE_FLAG || exit 1;
sed -i 's/HAVE_LRINT 0/HAVE_LRINT 1/g' config.h
sed -i 's/HAVE_LRINTF 0/HAVE_LRINTF 1/g' config.h
sed -i 's/HAVE_ROUND 0/HAVE_ROUND 1/g' config.h
sed -i 's/HAVE_ROUNDF 0/HAVE_ROUNDF 1/g' config.h
sed -i 's/HAVE_TRUNC 0/HAVE_TRUNC 1/g' config.h
sed -i 's/HAVE_TRUNCF 0/HAVE_TRUNCF 1/g' config.h
make  -j4 install || exit 1;
$PREBUILT/bin/arm-linux-androideabi-ar d libavcodec/libavcodec.a inverse.o || exit 1;
$PREBUILT/bin/arm-linux-androideabi-ld -rpath-link=$PLATFORM/usr/lib -L$PLATFORM/usr/lib  -soname libffmpeg.so -shared -nostdlib  -z,noexecstack -Bsymbolic --whole-archive --no-undefined -o $PREFIX/lib/libffmpeg.so libavcodec/libavcodec.a libavformat/libavformat.a libavutil/libavutil.a libswscale/libswscale.a -lc -lm -lz -ldl -llog  --warn-once  --dynamic-linker=/system/bin/linker $PREBUILT/lib/gcc/arm-linux-androideabi/4.4.3/libgcc.a || exit 1;

}


#armv5te
CPU=armv5te
OPTIMIZE_CFLAGS="-marm -march=$CPU "
PREFIX=../../build/android/armeabi
ADDITIONAL_CONFIGURE_FLAG=
build_one_r6


#arm v7n
CPU=armv7-a
OPTIMIZE_CFLAGS="-mfloat-abi=softfp -mfpu=neon -marm -march=$CPU -mtune=cortex-a8"
PREFIX=../../build/android/armeabi-v7a
ADDITIONAL_CONFIGURE_FLAG="--enable-neon --disable-armv5te --disable-armv6 --disable-armv6t2"
build_one_r6enter code here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

美男兮 2024-12-24 04:59:38

我已经使用位于此处的脚本为 android 编译了 ffmpeg-0.10:tools/build_libstagefright.sh。如果你不需要 libStagefright(对我来说它仍然不起作用),最好删除启动 android 库和标头下载以及 android 选项。它具有适用于 NEON 的正确工作选项。我总结的构建选项:

configuration: 
--target-os=linux \
--cross-prefix=arm-linux-androideabi- \
--arch=arm --cpu=armv7-a \
--sysroot=/home/grid/Android/Android_NDK_r6b/platforms/android-9/arch-arm \
--disable-avdevice \
--enable-decoder=h264 \
--prefix=build/stagefright/armeabi-v7a \
--extra-cflags=' -march=armv7-a -mfloat-abi=softfp -mfpu=neon' \
--extra-ldflags='-Wl, --fix-cortex-a8' \
--extra-cxxflags='-Wno-multichar -fno-exceptions -fno-rtti'

I have compiled ffmpeg-0.10 for android using its script situated here: tools/build_libstagefright.sh. If you dont need libStagefright (as for me its still not working) it`s better to delete start android libs and headers download and android options. It has properly working options for NEON. My summary build options:

configuration: 
--target-os=linux \
--cross-prefix=arm-linux-androideabi- \
--arch=arm --cpu=armv7-a \
--sysroot=/home/grid/Android/Android_NDK_r6b/platforms/android-9/arch-arm \
--disable-avdevice \
--enable-decoder=h264 \
--prefix=build/stagefright/armeabi-v7a \
--extra-cflags=' -march=armv7-a -mfloat-abi=softfp -mfpu=neon' \
--extra-ldflags='-Wl, --fix-cortex-a8' \
--extra-cxxflags='-Wno-multichar -fno-exceptions -fno-rtti'
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文