libav/ffi.lisp
Run body with the floating-point environment FFmpeg's own code expects.
FFmpeg computes with floats that raise invalid-operation and divide-by-zero as a matter of course -- probing stream timing alone will do it -- and SBCL traps those by default, so an unmasked call dies inside avformat_find_stream_info rather than returning an error luv could handle. This is the same masking luv's SDL and Vulkan boundaries use.
~A was groveled against major version ~D but the loaded ~ library reports major version ~D. The FFmpeg headers and ~ shared libraries in this environment are from different builds.
Loading.
The sonames are built from the groveled majors rather than written out, so
the version this system was compiled against is stated exactly once.
luv_FFMPEG_LIBDIR, which the Nix environment sets to the exact store path,
is consulted before the platform search: on both Darwin and Linux CFFI
explodes LD_library_PATH itself before consulting the system loader, so an
unqualified soname would otherwise be free to find some other FFmpeg that
happens to be installed.
Pinned FFmpeg library directory captured when this system was loaded.
A saved standalone image retains this build-environment fallback so it can be
launched directly. An explicit load-libav argument or the current process
environment still takes precedence.
Return the names to try for libSTEM at major version major, most exact first.
Load libavutil, libavcodec, and libavformat, and check their versions.
directory is useful for builds which have not been installed. When it is NIL,
luv_FFMPEG_LIBDIR is consulted before the platform soname search. Signals
libav-version-mismatch when a loaded library disagrees with the headers this
system was groveled against.
Split an AV_version_INT into its major, minor, and micro parts.
Signal unless every loaded library matches the headers we groveled.
AV-FRAME spells its arrays as a literal 8 because :COUNT cannot hold a constant; this is what keeps that literal honest.
Return the ./configure line this FFmpeg was built with.
Errors.
Return FFmpeg's own description of condition's error code.
Return code, or signal libav-error when FFmpeg reported a failure.
Formats and hardware devices.
The iteration and naming entry points are declared with :INT rather than the groveled enums on purpose. A CFFI enum translation errors on a value it has never heard of, and the set of hardware device types a given FFmpeg was built with is exactly the thing we are asking about -- so the answer comes back through FFmpeg's own name strings, and an unlisted type still arrives as a perfectly good keyword.
Return FFmpeg's name for format, a PIXEL-FORMAT keyword or raw integer.
Return the hardware device types this FFmpeg was built with, as keywords.
The list is whatever the library reports, so a type this system does not name in its HARDWARE-DEVICE-TYPE enumeration still appears, keyed by FFmpeg's own name for it.
Return FFmpeg's name for type, a HARDWARE-DEVICE-TYPE keyword.
Return true when this FFmpeg has a decoder called name, such as "h264".
Frames.
(&optional directory)Load libavutil, libavcodec, and libavformat, and check their versions. DIRECTORY is useful for builds which have not been installed. When it is NIL, LUV_FFMPEG_LIBDIR is consulted before the platform soname search. Signals LIBAV-VERSION-MISMATCH when a loaded library disagrees with the headers this system was…
(&body body)Run BODY with the floating-point environment FFmpeg's own code expects. FFmpeg computes with floats that raise invalid-operation and divide-by-zero as a matter of course -- probing stream timing alone will do it -- and SBCL traps those by default, so an unmasked call dies inside avformat_find_stream_info rather than…
Logical conjunction of tests and raw truth values.
Logical negation of one test or raw truth value.
Logical disjunction of tests and raw truth values.
(condition)The library band: eyebrow, site name, and the three doors.
The loaded libav* libraries, or NIL before anything asked for one.
Pinned FFmpeg library directory captured when this system was loaded. A saved standalone image retains this build-environment fallback so it can be launched directly. An explicit LOAD-LIBAV argument or the current process environment still takes precedence.
(stem major)(version)Extract the unsigned bit field (BYTE SIZE POSITION) of one unsigned scalar.
Test whether two compatible scalars are equal.
(code operation)Headings, paragraphs, figures and their IDs, mentions, marks.
(format)(name)()Return the hardware device types this FFmpeg was built with, as keywords. The list is whatever the library reports, so a type this system does not name in its HARDWARE-DEVICE-TYPE enumeration still appears, keyed by FFmpeg's own name for it.
An explicitly owned AVFrame.
Loading FFmpeg, and the slice of its C ABI luv speaks directly.
The libraries come in together because they version together: libavutil owns AVFrame, libavcodec owns the decoders, libavformat owns the demuxers, libswscale owns pixel conversion, and FFmpeg only supports combinations from a single build. The groveled LIBAV*_VERSION_MAJOR constants are the compile-time half of that agreement;
load-libavchecks them against what the loaded libraries say at run time, because a mismatch here does not fail loudly at the call site -- it silently reads a field from the wrong offset.