47 Commits
Author SHA1 Message Date
Martin Storsjö ac5dfb0a85 examples: Treat SDL2 headers as system headers
This makes those headers included with -isystem rather than -I,
which makes the compiler skip producing any warnings about them
(as they're expected to be out of the user code's control).

This avoids warnings with newer versions of the
dav1d-debian-unstable CI image, warnings (treated as errors in CI)
like this:

    In file included from /usr/include/SDL2/SDL_config.h:51,
                     from /usr/include/SDL2/SDL_stdinc.h:33,
                     from /usr/include/SDL2/SDL_main.h:25,
                     from /usr/include/SDL2/SDL.h:31,
                     from ../examples/dav1dplay.c:33:
    /usr/include/SDL2/SDL_config_unix.h:186:9: error: 'HAVE_GETAUXVAL' redefined [-Werror]
      186 | #define HAVE_GETAUXVAL 1
          |         ^~~~~~~~~~~~~~
    In file included from ../examples/dav1dplay.c:27:
    ./config.h:66:9: note: this is the location of the previous definition
       66 | #define HAVE_GETAUXVAL 0
          |         ^~~~~~~~~~~~~~

Recently, Debian Unstable has switched from providing the
actual SDL 2 to providing the SDL 2 API through the sdl2-compat
package on top of SDL 3.

The SDL 2 headers expose their full config.h as part of their
installed headers (that the user code ends up including). This
includes unnamespaced defines, such as "#define HAVE_GETAUXVAL 1".

This issue hasn't shown up with the original SDL 2 package in
Debian, due to a Debian packaging detail. While most SDL 2
headers are installed in /usr/include/SDL2 (and user code
includes it as <SDL.h>, requiring the build system to include
/usr/include/SDL2), the Debian packaging has replaced
/usr/include/SDL2/SDL_config.h with a header that includes
<SDL2/_real_SDL_config.h>, which then gets resolved in
/usr/include/x86_64-linux-gnu/SDL2. Due to this being included
from a compiler default system include path
(/usr/include/x86_64-linux-gnu), no warnings about the header
was printed, even though that one also produced the same kind
of conflicting redefinitions. (We could also avoid the same issue
by attempting to include <SDL2/SDL.h> instead of <SDL.h>,
avoiding the use of the build system provided include directory,
resolving that from /usr/include, and having the compiler consider
it a system header.)

The sdl2-compat package in Debian doesn't redirect that header
in the same way, but includes SDL_config_unix.h in the same
directory in /usr/include/SDL2. Due to this being included
from a user specified -I (as long as it is included as <SDL.h>,
not <SDL2/SDL.h>), it's considered a user header, and warnings
are printed for it.

It seems like SDL 3 no longer exposes their config.h headers as
part of the installed headers.

The conflict between SDL 2's config.h's HAVE_GETAUXVAL and
our stems from the fact that we only try to detect GETAUXVAL
on architectures where we want to use it (arm/aarch64, loongarch,
ppc or riscv). On x86, where we don't need it, we don't try
to detect it, and set "#define HAVE_GETAUXVAL 0" in our
config.h.

To avoid warnings due to the conflict, we can declare the
SDL 2 dependency with the argument "include_type: 'system'",
which should silence any warnings in the SDL headers. This
Meson feature is available since Meson 0.52.0 (and we currently
require Meson 0.54.0).

An alternative way to avoid the redefinition conflict would be
to always try to detect getauxval on all architectures, to make
our config.h agree with SDL 2's config headers.

A third (and much more hacky way) around the conflict would be
to avoid the public SDL headers including the SDL_config header
by defining "SDL_config_h_" before including SDL.h. Doing this
also requires manually including a couple more standard headers
before SDL.h (stdint.h, stdio.h, stddef.h).
2026-05-06 14:00:31 +03:00
Cameron Cawley 84792e61c8 dav1dplay: Print more error messages when window/context creation fails 2025-11-27 20:49:55 +00:00
Cameron Cawley e60603a9f2 dav1dplay: Ensure a newer OpenGL version is used when creating the context 2025-11-27 20:49:41 +00:00
Michael Bradshaw dd32cd5027 Use #if HAVE_* instead of #ifdef HAVE_* 2024-09-12 20:40:08 +00:00
Cameron Cawley 507b697ec0 Allow software renderers with placebo-gl 2024-09-04 18:29:59 +00:00
Cameron Cawley 312972d69b Disable the mouse cursor in dav1dplay 2024-09-04 12:15:11 +00:00
Cameron Cawley b9cc27d5ff Allow quitting dav1dplay with the escape key 2024-09-04 12:15:11 +00:00
Cameron Cawley 2f9fc727e1 Allow playing videos in full-screen mode 2024-09-04 12:15:11 +00:00
Cameron Cawley 4e1a8b4510 dav1dplay: Ensure that SDL is shut down when the application quits 2024-09-04 11:24:47 +00:00
Henrik Gramner 53efaa9bba dav1dplay: Update to new libplacebo API 2022-12-13 13:06:45 +00:00
Henrik Gramner 12b0d9be3c dav1dplay: Update threading --help text 2022-02-02 17:02:18 +01:00
Martin Storsjö d80eb3cfb3 dav1dplay: Fix a typo in an error message 2022-01-30 22:28:47 +02:00
Niklas Haas 7048ed6218 dav1dplay: Suppress compiler warning
The signature of pl_allocate/release_dav1dpic takes a void *cookie,
which the compiler warns about if we don't implicitly cast.
2021-10-31 13:18:22 +01:00
Henrik Gramner 316342457f dav1dplay: Avoid using external libplacebo data symbols
Fixes segfaults on Windows.
2021-10-06 19:11:43 +02:00
Victorien Le Couviour--TuffetandRonald S. Bultje 753eef833b Merge the 3 threading models into a single one
Merges the 3 threading parameters into a single `--threads=` argument.
Frame threading can still be controlled via the `--framedelay=` argument.
Internally, the threading model is now a global thread/task pool design.

Co-authored-by: Ronald S. Bultje <rsbultje@gmail.com>
2021-09-03 16:06:31 +00:00
James Almer 27f0b245e0 build: add -Wstrict-prototypes to the compiler arguments 2021-06-20 20:24:48 +00:00
Emmanuel Gil Peyrot 58cb4cf005 dav1dplay: Add -lm for llround() support
Neither --buildtype=plain nor --buildtype=debug set -ffast-math, so
llround() is kept as a function call and isn’t optimised out into
cvttsd2siq (on amd64), thus requiring the math lib to be linked.

Note that even with -ffast-math, it isn’t guaranteed that a call to
llround() will always be omitted (I have reproduced this on PowerPC), so
this fix is correct even if we ever decide to enable -ffast-math in
other build types.
2021-02-11 14:18:14 +01:00
Niklas Haas eab4ef6a5e dav1dplay: Only repaint the window when necessary
The current playback loop triggers a repaint on any single event,
including spammy events such as SDL_MOUSEMOTION.

Fix this by only repainting on SDL_WINDOWEVENT_EXPOSED, which is defined
as the event sent when the window was damaged and needs to be repainted,
as well as on new frames.

Fixes https://code.videolan.org/videolan/dav1d/-/issues/356
2021-02-06 10:50:52 +01:00
Niklas Haas 61b6545678 dav1dplay: Update/modernize placebo-based renderer
Upstream libplacebo added support for dav1d integration directly,
allowing us to vastly simplify all of this code. In order to take
advantage of new optimizations, I had to allow update_frame to unref the
Dav1dPicture. (This is fine, since double unref is a no-op)

In addition, some of the functions we use were deprecated in recent
libplacebo versions, so since we're taking a new dependency we might as
well fix the deprecation warnings.
2021-02-06 10:50:52 +01:00
Niklas Haas 06e8ed37d3 dav1dplay: Disable zerocopy on placebo-gl
These functions are not thread-safe on GL, because they are not called
from the thread holding the GL context. Work around this by simply
disabling it.

Not very optimal, but better than crashing.
2021-02-06 10:50:52 +01:00
Victorien Le Couviour--Tuffet 288ed4b8ec dav1dplay: Add pause and seek features 2021-02-01 11:18:04 +01:00
Victorien Le Couviour--Tuffet 549086e4d3 Add post-filters threading model 2021-01-28 15:08:10 +01:00
Marvin Scholz f55cd4c6f3 dav1dplay: Fix type mismatch warning 2020-07-20 13:31:57 +02:00
Niklas Haas 12a64ec7a0 dav1dplay: use new pl_chroma_location API
This one correctly sets the subsampling mode based on whether or not the
plane is actually subsampled, and also infers PL_CHROMA_UNKNOWN as
PL_CHROMA_TOP_LEFT in such cases.
2020-05-26 15:18:17 +02:00
Niklas Haas a1e7a329b2 dav1dplay: allow resizing the window
libplacebo v66 got helper functions that make preserving the aspect
ratio in this case trivial. But we still need to make sure to clear the
FBO to black if the image doesn't cover it fully.
2020-05-25 11:54:24 +02:00
Niklas Haas df40d36d84 dav1dplay: don't freeze on render errors
Returning out of this function when pl_render_image() fails is the wrong
thing to do, since that leaves the swapchain frame acquired but never
submitted. Instead, just clear the target FBO to blank red (to make it
clear that something went wrong) and continue on with presentation.
2020-05-20 07:08:04 +02:00
Niklas Haas cbe05cf439 dav1dplay: support on-GPU film grain synthesis
Annoying minor differences in this struct layout mean we can't just
memcpy the entire thing. Oh well.

Note: technically, PL_API_VER 33 added this API, but PL_API_VER 63 is
the minimum version of libplacebo that doesn't have glaring bugs when
generating chroma grain, so we require that as a minimum instead.

(I tested this version on some 4:2:2 and 4:2:0, 8-bit and 10-bit grain
samples I had lying around and made sure the output was identical up to
differences in rounding / dithering.)
2020-05-18 08:24:26 +02:00
Niklas Haas 7bbebdb463 dav1dplay: handle all supported csps/reprs/bitdepths
Generalize the code to set the right pl_image metadata based on the
values signaled in the Dav1dPictureParameters / Dav1dSequenceHeader.

Some values are not mapped, in which case stdout will be spammed.
Whatever. Hopefully somebody sees that error spam and opens a bug report
for libplacebo to implement it.
2020-05-18 08:19:28 +02:00
Niklas Haas f01fd0f1e5 dav1dplay: move and simplify pl_image generation
Having the pl_image generation live in upload_planes() rather than
render() will make it easier to set the correct pl_image metadata based
on the Dav1dPicture headers moving forwards. Rename the function to make
more sense, semantically.

Reduce some code duplication by turning per-plane fields into arrays
wherever appropriate.

As an aside, also apply the correct chroma location rather than
hard-coding it as PL_CHROMA_LEFT.
2020-05-18 02:10:43 +02:00
Niklas Haas 3bb0aed103 dav1dplay: don't write directly to iparams.extensions
This is turned into a const array in upstream libplacebo, which
generates warnings due to the implicit cast. Rewrite the code to have
the mutable array live inside a separate variable `extensions` and only
set `iparams.extensions` to this, rather than directly manipulating it.
2020-05-18 02:10:38 +02:00
Emmanuel Gil Peyrot 239b87f071 Fix swapped define guards in dav1dplay’s libplacebo renderer
Signed-off-by: Marvin Scholz <epirat07@gmail.com>
2020-05-16 18:55:11 +02:00
Marvin Scholz e4a4c8c60b Dav1dPlay: Split placebo renderer into two
This allows selecting at runtime if placebo should use OpenGL
or Vulkan for rendering.
2020-05-15 11:57:02 +02:00
Marvin Scholz 7f50fc3719 Dav1dPlay: Remove redundant log message 2020-05-15 10:49:14 +02:00
Marvin Scholz 2987b78a36 Dav1dPlay: Remove unused renderer_info member 2020-05-15 10:49:14 +02:00
Marvin Scholz c1c41ff098 Dav1dPlay: Allow runtime renderer selection 2020-05-15 10:49:14 +02:00
Marvin Scholz 7f5cf34d06 Dav1dPlay: Fix renderer selection 2020-05-15 02:23:19 +02:00
Marvin Scholz e8fc62fc2a Dav1dPlay: Split renderers into different files 2020-05-15 00:42:32 +02:00
Marvin Scholz 41e0819960 Dav1dPlay: Add support for OpenGL with libplacebo 2020-05-14 22:44:50 +02:00
Marvin Scholz 9c56be26dc Dav1dPlay: Split FIFO to different files
To un-clutter the main dav1dplay.c, move the fifo to its own
file and header.
2020-05-14 22:44:50 +02:00
Konstantin Pavlov e36ebb6fc2 examples: fail when SDL is not found
Now when -Denable_examples=true is requested, meson will fail as
expected if there is no SDL available.
2020-03-07 01:12:07 +03:00
Jan Beich e04227c5f6 examples: chase cacc8e350c
../examples/dav1dplay.c:1030:5: warning: implicit declaration of function 'init_demuxers' is invalid in C99 [-Wimplicit-function-declaration]
    init_demuxers();
    ^
/usr/bin/ld.bfd: examples/c590b3c@@dav1dplay@exe/dav1dplay.c.o: in function `decoder_thread_main':
dav1dplay.c:(.text+0x1243): undefined reference to `init_demuxers'
cc: error: linker command failed with exit code 1 (use -v to see invocation)
2020-03-06 11:16:13 +00:00
Niklas Haas 490a1420f3 dav1dplay: initial support for --zerocopy
Right now this just allocates a new buffer for every frame, uses it,
then discards it immediately. This is not optimal, either dav1d should
start reusing buffers internally or we need to pool them in dav1dplay.

As it stands, this is not really a performance gain. I'll have to
investigate why, but my suspicion is that seeing any gains might require
reusing buffers somewhere.

Note: Thrashing buffers is not as bad as it seems, initially. Not only
does libplacebo pool and reuse GPU memory and buffer state objects
internally, but this also absolves us from having to do any manual
polling to figure out when the buffer is reusable again. Creating, using
and immediately destroying buffers actually isn't as bad an approach as
it might otherwise seem.

It's entirely possible that this is only bad because of lock contention.
As said, I'll have to investigate further...
2019-09-28 00:31:02 +02:00
Niklas Haas 3f35ef1f31 dav1dplay: add --untimed for benchmarking purposes
Useful to test the effects of performance changes to the
decoding/rendering loop as a whole.
2019-09-28 00:31:02 +02:00
Niklas Haas f6ae8c9c77 dav1dplay: add --highquality to toggle render quality
Only meaningful with libplacebo. The defaults are higher quality than
SDL so it's an unfair comparison and definitely too much for slow iGPUs
at 4K res. Make the defaults fast/dumb processing only, and guard the
debanding/dithering/upscaling/etc. behind a new --highquality flag.
2019-09-28 00:31:02 +02:00
Henrik Gramner 6751c98036 Utilize the constraints in assertions to improve code generation
When compiling in release mode, instead of just deleting assertions,
use them to give hints to the compiler. This allows for slightly
better code generation in some cases.
2019-08-19 00:02:29 +02:00
James Almer dff0a08cd3 dav1dplay: abort if no input filename is provided 2019-08-10 15:55:09 -03:00
James Almer 3a77c57b0c meson: move dav1dplay to a new examples section
dav1dplay shouldn't be built by default. And it's an example more than a tool.
2019-08-10 11:26:17 -03:00