Erroring out of NVENC init early if the Max B-frames setting was higher
than the encoder's capability causes an encoder failure on NVIDIA Pascal
(10-series) and earlier GPUs due to an unfortunate interaction between
Simple Output Mode, HEVC, and our default B-frames setting of 2. Since
we already check the Max B-frames capability of the encoder, cap at that
value instead of erroring out.
Fixes#7698.
Checks to make sure that the bframe count is equal to or below the
maximum number of bframes that the encoder for the codec supports.
Fixes a bug where setting bframes higher than what the encoder supports
would cause the encoder to not start up properly.
The old NVENC preset "Default", labeled in OBS as "Performance", maps to
the new P3 preset when not using multipass. Since we previously only
enabled multipass/two-pass on "Max Quality", we can map this to P3 in
all cases.
This commit also modifies UI.
Ubuntu 20.04 and 22.04 both have the same FFmpeg versions, but FFmpeg on
20.04 was built with version 9 of NVENC headers, whereas 22.04 was built
with 11.
Unfortunately, that means we have to revert back to the old presets when
Ubuntu 20.04 is detected. The way this detection is done is a bit hacky,
but it's the only way to preserve startup performance. Otherwise we'd
have to write yet another startup subprocess test program to detect
whether the FFmpeg being used was built with older or newer NVENC, which
is both slow to start up and annoying to write. So instead, just get the
distro name/version strings and detect Ubuntu 20.04 that way.
- QSS changes fix background color on the stats dialog.
- Making OBSBasicStats derive from QFrame fixes the background color
and round bottom corners on the stats dock.
Apparently Steam running the OBS launch script makes it run
inside Rosetta as well, so it ended up launching the x86 version
even on arm64 systems.
Explicitly detect Rosetta translation and set arm64 in those cases.
Without invalidating the mach port used for sharing the IOSurface
between OBS and the application displaying the virtual camera output,
IOKit seems to run into the issue of receiving "shared" mach ports,
possibly because of port exhaustion. IOKit requires a "new" port
however and crashes upon that error otherwise.
Co-authored-by: Steven Michaud <smichaud@pobox.com>
Another call to getenv, as well as a call to the POSIX functions
setenv(), unsetenv(), and putenv() may invalidate the pointer
returned by a previous call or modify the string obtained from a
previous call.
https://en.cppreference.com/w/c/program/getenv
Selection state can change by main thread while UI thread (which
calls DrawSpacingHelpers) tries to evaluate the amount of selected
items. Get amount of selected items by enumerating over the scene data
instead (which stays within the graphics thread).
Certain programs can start the virtualcam filter, then they may choose
to call `Stop()` on the filter, call `SetFormat()` to change the
resolution, then call `Run()` again to start the filter again. The
Windows virtual camera filter did not account for this, thus if the
resolution was different, it had potential to cause a crash.
To fix this, store the last filter resolution, then check the resolution
every frame, and if it changes, reset the scaling information.
(Author note: This code is unclean. What we need to do with the virtual
camera filter is make it only create the thread on `Run()`, then join
the thread on `Stop()`. It's currently a bit complicated to make it do
that at the moment, so this code is a kind of an annoying stopgap for
now.)
The `cx`/`cy`/`interval` variables specifically specify the
OBS/placeholder resolution/interval. The resolution may not be the same
as the filter's resolution (when scaling is used).
Instead, prefix these variables with `obs_` to improve clarity.