Commit Graph

431 Commits

Author SHA1 Message Date
Martin Pulec
40a7d04ec1 unit_evaluate[_dbl]: added endptr param 2023-11-29 15:27:32 +01:00
Martin Pulec
cb269cf992 lavc video: do not set interlaced DCT for libx265
Interlacing is not honored by libx265, anyways, and this saves the
eventual HWacc warning.

It is still passed to QSV even for HEVC, anyways. Not sure how the API
handles that but FFmpeg seems to pass it.
2023-10-06 16:44:18 +02:00
Martin Pulec
31af5137e7 lavc video: warn also when >8 bit depth used
\+ remove "and not 4:2:0" from subs complaint - it is perhaps needlessly
verbose (other feature doesn't name the correct value. user should be
aware, anyways, and there is also a hint below.
2023-10-06 16:44:18 +02:00
Martin Pulec
f2ac2cbdf8 lavc,lavd vid: print used subs in warn
Print used subsampling (or sw fmt in lavd) in warning if not using 4:2:0.

This may be helpful sometimes as an additional information.
2023-10-06 11:26:49 +02:00
Martin Pulec
ac110f1b49 vaapi dec.: deduce SW format to reported valid
Set AVHWFramesContext::sw_format to first of av_hwframe_transfer_get_formats().

This is consistent how MPV does that. Fixes NV12 being transmitted
despite AVHWFramesContext::sw_format was set to yuv420p causing chroma
channels corruption (because the nv12 data was misinterpreted as the
latter one) occuring on AMD cards, steps to reproduce:
```
uv -t testcard -c lavc:enc=libx264:safe -d gl --param use-hw-accel=vaapi
```

See also:
<66e30e7f2f>
2023-10-06 11:19:11 +02:00
Martin Pulec
e5d628cd79 lavc: added "safe" option
enables option for HW(-accelerated) decode compatibility:
* subsampling 420
* no intra refresh
* no interlaced DCT
2023-10-06 11:19:11 +02:00
Martin Pulec
000c8c0bdb lavc video help: cmdline print updates
* shorten lines
* print usage where can be seen that there is also fullhelp
2023-10-06 11:19:11 +02:00
Martin Pulec
e990318499 lavc video: handle incompatible subs as other features 2023-10-06 11:19:10 +02:00
Martin Pulec
4c250bd274 lavc video: do not report "lavc" shortcut in caps
would be displayed twice in GUI otherwise
2023-10-05 15:05:36 +02:00
Martin Pulec
8e1f8905d5 lavc video enc: warn on interlaced DCT as well
see also previous commit
2023-10-05 15:05:36 +02:00
Martin Pulec
17fcd1bf44 lavc video: warn when auto-enabled intra-refresh
Warn in the same way as when non-4:2:0 video is encoded - intra refresh
might be problematic as well.

Do not warn if enabled explicitly (`:intra_refresh`).
2023-10-05 15:05:36 +02:00
Martin Pulec
69a84d0b16 lavc video: increase # of tiles for rav1e and aom
Processors with 64 logical cores are quite common nowadays.

Not increased for libsvtav1 since it doesn't seem to improve performance
there.
2023-09-27 12:32:40 +02:00
Martin Pulec
5876326d5c lavc video: do not force IDR for libsvtav1
there is not such an option for SVT AV1
2023-09-27 12:32:38 +02:00
Martin Pulec
ad47f4a2f2 lavc video: disable x2rgb10 for QSV
closes GH-341
2023-09-22 15:06:35 +02:00
Martin Pulec
ea616ed6b7 lavc video: enable header-inserter for h264_omx
Enable the inserter automatically - the h264_omx is not producing SPS/PPS
periodically with plain RPi OS FFmpeg (FFmpeg needs to be patched).

The OMX API seems to getting deprecated, anyways.
2023-09-22 09:24:53 +02:00
Martin Pulec
d492a9a4e3 some include optimization 2023-09-18 07:54:10 +02:00
Martin Pulec
77bc6d5fd1 lavc: allow cmdline shortcuts
* optionally allow 'lavc' instead of 'libavcodec'
* allow shortcuts of frequent options, eg. `-c lavc:c=H.264`
2023-09-18 07:49:15 +02:00
Martin Pulec
84ba09f4f7 lavc: wrap codec lines 2023-09-15 15:36:43 +02:00
Martin Pulec
435c712acf display file: don't write uncompressed by default
Write uncompressed output only if user explicitly specifies NUT container
to avoid unexpected results when `-d file` is writing overwhelming amount
of data.
2023-09-06 14:39:40 +02:00
Martin Pulec
5e525dbe0e lavc video: try_open_remaining_pixfmts - do not crash on pix_fmts==NULL
Do not crash on codec->pix_fmts == NULL in try_open_remaining_pixfmts.

This can occur eg. for h264_v4l2m2m encoder on RPi.
2023-08-28 10:18:56 +02:00
Martin Pulec
49c859b8c2 lavc video: use aux_data also for extradata
it simplifies the things
2023-08-25 11:54:34 +02:00
Martin Pulec
4a745780e2 lavc video: header_inserter - support HEVC
\+ ignore leading AUD NALU if present (add own 4B start code instead) -
it could have produced problems when AUD+SPS+PPS is prepended to regular
frame that is not an IDR frame
2023-08-25 11:54:33 +02:00
Martin Pulec
c185014766 lavc video: added header_inserter option
The option solves a problem with streams that do not correctly prepend
video headers, namely (and currently only implemented) SPS/PPS in
H.264 stream. Support for HEVC can be added later.
2023-08-25 11:54:29 +02:00
Martin Pulec
972355db8e lavc video AMF: default usage to ultralowlatency
for H.264 and HEVC, AV1 has only lowlatency

t should be mostly the same, see pg. 16 of
[AMF_Video_Encode_API.pdf]. There is just some mysterious
AMF_VIDEO_ENCODER_LOWLATENCY_MODE option that is enabled by this.

[AMF_Video_Encode_API.pdf]:
https://github.com/GPUOpen-LibrariesAndSDKs/AMF/blob/v1.4.28/amf/doc/AMF_Video_Encode_API.pdf
2023-08-24 15:16:09 +02:00
Martin Pulec
09488b085e lavc check_av_opt_set: simplified
Actually all options can be passed as a c-string with av_opt_set(),
which then converts it to a correct type. So use to_string to convert
non-cstrings to std::string.
2023-08-23 14:49:26 +02:00
Martin Pulec
8db1db9d61 lavc video AMF: set default RC to CQP 2023-08-23 14:14:40 +02:00
Martin Pulec
9e996bd37d lavc video: set header insertion for av1_amf
Set to "gop" as with HEVC, for av1_amf, it is also possible to set to
"frame" (unsure if better).
2023-08-22 16:51:46 +02:00
Martin Pulec
9b25da71a2 show_encoder_help: don't double print default opt
some codecs have alread default value in the description, eg. profile
- _Set the profile (default main)_, thus it is unneeded to print the
information second times.

\+ do not print float default vals with "F" suffix because it can be a
little bit misleading, indicate the type in braces instead
2023-08-22 16:51:28 +02:00
Martin Pulec
eb88c64d3b lavc vid: show_encoder_help simplified 2023-08-22 16:51:17 +02:00
Martin Pulec
d2f8f2df8b lavc video: avoid nullptr dereference
When `--param keep-pixfmt` is used but the encoder doesn't produce a
packet (AVPacket.size == 0), nullptr dereference can occur.

fixes CID 416601
2023-08-22 08:57:56 +02:00
Martin Pulec
c57f2fc57b lavc video: read frames consecutively
Read and send the frames consecutively, even though the encoder presents
them at once (see previous commit description).
2023-08-18 12:25:33 +02:00
Martin Pulec
690244686a Compress sync tile API: fetch additional frames
Modified the API in order to fetch additional frames from compression
with iterative passing NULL pointer (similarly as for audio).

This is particularly usefull when inter-frame compression outputs 2
frames at once, which can occur when B-frames would be enabled. It,
however sometimes happen even when B-frames are disbled, eg. with
h264/hevc_mf HW encoder on AMD (AMDh265Encoder; see commit d70e2fb3c).

Please note that semantic of passing NUL frame is different in this API
to that in async API, where it works as a poison pill.
2023-08-18 11:07:57 +02:00
Martin Pulec
f035e43ac5 lavc video: store/restore metadata reliably
In case that the encoder buffers frame for whatever reason (NVENC
with delay, hevc_mf sometimes batching 2 frames /returned frames count
0,1,2,0,1,2.../) so that output frame doesn't match the currently
enqueued onei, metadata would be incorrect (currently enqueued copied
to non-matching dequeued one).
2023-08-16 16:10:48 +02:00
Martin Pulec
4f0fa9f5ab lavc video: small updates
- moved constexpr definitions to the (anonymous) namespace (allows
eg. detection of unused vars)
- do not import the whole std namespace
2023-08-14 16:06:16 +02:00
Martin Pulec
7e2d50af66 lavc video: set the preset threshold as px/sec
Set the threshold, that is used by some to select the preset, as a
constant in MPix/sec.
2023-08-14 16:06:16 +02:00
Martin Pulec
32b0f00e8f lavc video: removed explicit preset
removed explicit preset handling

Actually with current encoder set, having the preset is rather exceptional
- some codecs to not recognize the presets with any encoder, eg. MJPEG,
Other have a different keyword like "usage" (VP9). Even with eg. H.265
different encoders use different keywords ("scenario" for QSV and MF) etc.

So give up explicit handling of presets - those (or those under different
names) can be configure in codec specific configure callbacks.

There is also a change that the default preset is always set, previously
not if _preset_ was detected in cmdline params. This doesn't seem to be
a problem, however. The user-specified options are set after the
codec-specific configure callback so that it should override the default.
2023-08-14 16:06:15 +02:00
Martin Pulec
2d0d292f1b lavc video: support for MS MFT
set default values

Seting hw_encoding=1 (force) - otherwise, the API seems to be using SW
encode. Moreover, using _hevc_mf_ fails to init (at least in some setups)
while the GPU supports that so that enforcing that makes it work.
2023-08-14 16:06:15 +02:00
Martin Pulec
7c44a85996 lavc video: do not try already tried AV pixfmts
When trying to init _any_ codec (for the further use with swscale), do not
try already tried pixfmts. Plus do not print that we will try with swscale
when there is no AV pixfmt left (it is a bit misleading in the UG output).
2023-08-14 16:06:15 +02:00
Martin Pulec
aed1af1c9c lavc video: refactor SWS fallback pixfmt select
Moved trying remaining pix_fmts to a sepaarate function.
2023-08-14 16:06:15 +02:00
Martin Pulec
bde2735dbb lavc: NVENC: default rc_buf_size_factor = 1.5
Since 2022-06-18 (commit cbc548d3), dynamic rate limiter allows
overshooting one frame by the factor of 50% so we can safely set the
default factor to 1.5 now.

see also GH-114
2023-08-07 11:47:32 +02:00
Martin Pulec
10c280959b Revert "CI Linux FFmpeg: remove NVENC IDR patch"
This reverts commit e457ab87f7 but the
patch is updated to match current FFmpeg.

The FFmpeg commit that seemed to do the same (7eeef72c6) is not working
correctly because it assigns idrPeriod cc->gopLength, which was set to
NVENC_INFINITE_GOPLENGTH above in case of intra-refresh.

refer to GH-330
2023-07-24 16:23:44 +02:00
Martin Pulec
c2c7a2ddb8 lavc video: NVENC: update ver comparison
Current libavcodec version is still 60.22.100 so intra-refresh has been
disabled since e457ab8 because the version is still not strictly greater
(is equal). Using non-strict equality breaks the compilation with version
60.22.100 prior to FFmpeg commit e457ab8 (perhaps not a big deal).

refer to GH-330
2023-07-24 15:17:09 +02:00
Martin Pulec
e457ab87f7 CI Linux FFmpeg: remove NVENC IDR patch
Since the FFmpeg commit 7eeef72c6, the IDR period is set to gopLength
unconditinally even for intra-refresh mode, which is what the removed
patch did.

+ do not check if FFmpeg is patched (the macro is )
2023-07-17 11:36:01 +02:00
Martin Pulec
83842e5f4e lavc video: if user opt fails, log as err
Compared to codec options set by UltraGrid impliclty, if user-set option
fails, it is taken as an error. But the log message didn't indicate that
the option setting was actually fatal, so use error verbosity which
makes it more visual apparent.
2023-07-04 10:14:06 +02:00
Martin Pulec
769c2d04ed lavc video: qsv rc help hint
print how the available RCs can be shown
2023-07-04 10:14:06 +02:00
Martin Pulec
01a4f0e6aa lavc video: set MJPEG Q=7 by default
FFmpeg MJPEG provides quite poor quality with Q=21 which was used
before (also when not setting anything and leaving implicit MJPEG
quality setting).
2023-06-27 10:40:56 +02:00
Martin Pulec
2d29ea28c7 video lavc: print reconfigured format in debug 2023-06-13 12:19:34 +02:00
Martin Pulec
8b5673ec5c lavc video: set defaults for rav1e
This speeds up rav1e encoding from fractions of FPS to few FPS in
FullHD, but clearly the speed is lagging behind its AOM and SVT
counterparts.
2023-05-18 14:34:18 +02:00
Martin Pulec
5b750c2ff3 lavc video: prefer libaom-av1 for ARM macs
While on x86_64 is libsvtav1 still slightly ahead, on the M1 mac, the
AOM AV1 performs significantly better (2x faster).

The above holds for native builds, it actually looks like the x86_64
build running SVT AV1 on M1 mac doesn't run correctly at all - it
produces just blank picture (green as is zeroed YCbCr buffer).
2023-05-17 14:56:11 +02:00
Martin Pulec
2961fe2f44 lavc video: print used thread count and mode 2023-05-17 11:48:08 +02:00