Bug 204345 - [patch] multimedia/ffmpeg: add VFP and NEON options for armv6
Summary: [patch] multimedia/ffmpeg: add VFP and NEON options for armv6
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: arm Any
: --- Affects Some People
Assignee: Thomas Zander
Keywords: needs-qa, patch
Depends on:
Reported: 2015-11-07 00:18 UTC by Oleksandr Tymoshenko
Modified: 2015-11-22 07:34 UTC (History)
3 users (show)

See Also:
bugzilla: maintainer-feedback? (multimedia)

Add NEON and VFP options for ARMv6 build (787 bytes, patch)
2015-11-07 00:18 UTC, Oleksandr Tymoshenko
no flags Details | Diff
Re-add NEON option (1.19 KB, patch)
2015-11-13 08:22 UTC, Jan Beich
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Oleksandr Tymoshenko freebsd_committer freebsd_triage 2015-11-07 00:18:49 UTC
Created attachment 162861 [details]
Add NEON and VFP options for ARMv6 build

ffmpeg package enables VFP and NEON optimization for ARMv6 build, but not all CPU support vectorized VFP operations. So to cover as many devices as possible it should be disabled by default though for custom builds people should be able to enable it.
Comment 1 Thomas Zander freebsd_committer 2015-11-08 17:40:47 UTC
VFP seems to work, but NEON does not. It is testing for NEON during the configure stage but after encountering this

BEGIN /tmp/ffconf.VspKMTmG.c
    1   #include <arm_neon.h>
    2   int main(void) { int16x8_t test = vdupq_n_s16(0); return 0; }
END /tmp/ffconf.VspKMTmG.c
cc -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -DPIC -O -pipe -mfloat-abi=softfp -fno-strict-aliasing -I/usr/local/in
clude/vorbis -I/usr/local/include -march=armv6zk -std=c99 -fomit-frame-pointer -marm -fPIC -c -o /tmp/ffconf.Q7ANNGnS.o /tmp/ffconf.V
In file included from /tmp/ffconf.VspKMTmG.c:1:
/usr/include/clang/3.4.1/arm_neon.h:28:2: error: "NEON support not enabled"
#error "NEON support not enabled"
/usr/include/clang/3.4.1/arm_neon.h:47:24: error: 'neon_vector_type' attribute is not supported for this target
typedef __attribute__((neon_vector_type(8)))  int8_t int8x8_t;

it decides to set HAVE_NEON and similar config vars to 0 in config.h

I tested on 10/stable. Is this working on current?
Comment 2 Oleksandr Tymoshenko freebsd_committer freebsd_triage 2015-11-08 18:03:15 UTC
No, I've just checked - looks like clang does not have NEON support enabled on CURRENT. I didn't test actual config.h values for NEON, only that it doesn't break configure step.

Could you drop NEON option and commit only VFP part?
Comment 3 Thomas Zander freebsd_committer 2015-11-08 19:30:48 UTC
(In reply to Oleksandr Tymoshenko from comment #2)

Sure, no worries. Thank you!
Comment 4 commit-hook freebsd_committer 2015-11-08 20:10:03 UTC
A commit references this bug:

Author: riggs
Date: Sun Nov  8 20:09:02 UTC 2015
New revision: 401071
URL: https://svnweb.freebsd.org/changeset/ports/401071

  Add non-default OPTION to support VFP on armv6

  PR:		204345
  Submitted by:	gonzo@FreeBSD.org

Comment 5 Jan Beich freebsd_committer 2015-11-13 08:22:51 UTC
Created attachment 163081 [details]
Re-add NEON option

> /usr/include/clang/3.4.1/arm_neon.h:28:2: error: "NEON support not enabled"

NEON requires at least ARMv7-A which FFmpeg by default doesn't force when building for ARMv6. And FreeBSD lacks runtime CPU detection.

Try the attached patch, it also exposes VFP/NEON for armv6hf.
Comment 6 Jan Beich freebsd_committer 2015-11-21 00:51:10 UTC
Re-open per my followup, so it's not forgotten.
Comment 7 Thomas Zander freebsd_committer 2015-11-21 14:11:48 UTC
(In reply to Jan Beich from comment #6)

Thanks for the patch! Just a question: Does the majority of armv6 we support actually have ARMv7-A? I was under the impression that e.g. the RPI 1 (the single core) does not. And if we don't have runtime CPU detection, I'd suggest to include a caveat in the OPTION description. What do you think?
Comment 8 commit-hook freebsd_committer 2015-11-22 07:20:18 UTC
A commit references this bug:

Author: riggs
Date: Sun Nov 22 07:19:55 UTC 2015
New revision: 402216
URL: https://svnweb.freebsd.org/changeset/ports/402216

  Add non-default OPTION to support NEON instructions on arm

  Include new patch from jbeich:
  - Add NEON OPTION on arm; no changes in default OPTIONs
  - Port now assumes at least armv7-a if user selects NEON

  PR:		204345
  Submitted by:	gonzo@FreeBSD.org, jbeich@FreeBSD.org