Commit Graph

388 Commits

Author SHA1 Message Date
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
Martin Pulec
dc89a560a9 lavc video AOM AV1: updated defaults (performance)
updated defaults so that it may be achievable to compress 1080p on M1 mac
2023-05-17 11:42:57 +02:00
Martin Pulec
7d52917a85 lavc video: print also successfully set options
+ set also custom options with check_av_opt_set (to show setting info)
2023-05-17 11:42:05 +02:00
Martin Pulec
6b291e1183 lavc video: set default realtime usage for AOM 2023-05-17 11:42:05 +02:00
Martin Pulec
50c7f33227 lavc video: missing spaces in help 2023-05-17 11:42:05 +02:00
Martin Pulec
f7e29f1d81 remove more FFmpeg compat
according to FFmpeg commit 80154b1b, the current cut-off in UG was lavc
version 57.107.100 (incl), which corresponds to lavu 55.78.100 (incl).
2023-05-05 10:25:46 +02:00
Martin Pulec
00b7ebd40e lavc H.264: use option for interlaced DCT not param
make the "[disable_]interlaced_dct" regular option
2023-04-27 15:21:18 +02:00
Martin Pulec
8dcb6808eb lavc: do not unref packet in deconfigure
+ do not allocate it ahead in _init

For HuffYUV and FFV1 this caused crash (perhaps deconfigure was run twice
for those codecs with extradata /it uses a different path than usual
codecs without that data/, leaving the AVpacket pointer nullptr after
first run).

Unreferencing should not be necessary - we are not refcounting it and
FFmpeg example (decode_video.c), which works similarly, doesn't do that,
anyways. Also av_packet_free() should unreference it according to doc.
2023-04-06 14:39:10 +02:00
Martin Pulec
df211bf948 lavc: always use default slice count
Use default slice count also for JPEG with threads==1 because it is no
longer broken with current FFmpeg code.
2023-04-06 14:20:55 +02:00
Martin Pulec
9ffeba2d38 lavc: allocate at least 4 KiB buf for compressed
When compressing very small video (16x16) with libx265, first frame is
2690 B, which is more than W*H*4 (1024) leading to a crash on assert.

steps to reproduce the fixed problem:

    uv -t testcard:size=16x16 -c libavcodec:encoder=libx265
2023-03-29 12:08:40 +02:00
Martin Pulec
d2c00ff3f8 split utils/text to string.c and text.c 2023-03-14 13:21:12 +01:00
Martin Pulec
0c731e93b8 lavcd: remove unused param warnings when no sws 2023-03-13 16:26:14 +01:00
Martin Pulec
15e0448e0d lavc: set QSV default RC VBR
seems to be performing better than CBR

refer to GH-298
2023-03-09 10:40:12 +01:00
Martin Pulec
3d7ac66c12 lavc QSV QVBR: set rc_max_rate to 115% of bit rate
The key is to set (anyhow) rc_max_rate != bit_rate, otherwise FFmpeg
triggers CBR mode. But 200% as it was set was perhaps too much.
2023-03-09 10:36:50 +01:00
Martin Pulec
6d696a782f lavc QSV QVBR: set default quality to 21
Set to DEFAULT_CQP (21) instead of DEFAULT_CQP_QSV (5000). The usable
range here seem to be in tens, not thousands as for the other constant
so set it accordingly the detail to work satisfactorily when the quality
(cqp) parameter is not given explicitly.
2023-03-08 12:30:30 +01:00
Martin Pulec
e0df14ca35 lavc qsv: added QVBR RC 2023-03-08 12:00:01 +01:00
Martin Pulec
7993f04e8c lavc qsv: added ICQ RC 2023-03-08 11:39:57 +01:00
Martin Pulec
2ce0cab237 lavc qsv hevc: added cqp RC 2023-03-08 11:23:06 +01:00
Martin Pulec
aeaef446e7 lavc qsv: add rc to codec-specific usage 2023-03-08 11:09:05 +01:00
Martin Pulec
c5c35c9607 lavc: removed unneeded compat (already in common) 2023-03-08 11:09:05 +01:00
Martin Pulec
58ee16e995 lavc: do not erase opts from lavc_opts
Erasing the opt isn't reentrant, so either when reconfigure occurs or
init of first pixfmt fails (eg. with hevc_qsv), it is no longer applicable.
2023-03-08 11:09:05 +01:00
Martin Pulec
62142510c6 lavc: add support for RC for QSV
refer to GH-298
2023-03-08 11:08:30 +01:00
Martin Pulec
a43168ee06 lavc: added option to keep original pixel format
refer to GH-295
2023-03-03 16:30:33 +01:00
Martin Pulec
2f1fc85a8f lavc: set async_depth=1 for mjpeg_qsv
This option improves latency (similarly as done for QSV H.264 and HEVC).
2023-02-28 16:17:36 +01:00
Martin Pulec
2519e3593b lavc: print options set in verbose mode 2023-02-28 16:17:36 +01:00
Martin Pulec
df05601e0a lavc: set default Huffman tables only for "mjpeg"
mjpeg_qsv doesn't have such an option
2023-02-28 16:17:36 +01:00
Martin Pulec
c4dfbaf0d7 lavc: set QSV CQP defaults 2023-02-28 16:17:35 +01:00
Martin Pulec
99fd545511 lavc: set AVCodecContext::global_quality for CQP QSV
set global quality when using CQP with QuickSync

see GH-298
2023-02-28 13:12:14 +01:00
Martin Pulec
42e269f9ff lavc: if setting cqp, set particular codec flag
AV_CODEC_FLAG_QSCALE is used to signalize that fixed qscale should be
used and some codecs like QSV ones require it to signalize that CQP is
used.

refer to GH-298
2023-02-28 13:12:14 +01:00
Martin Pulec
3072321a52 mjpeg: set cqp by default
mjpeg encoders (FFmpeg embedded and QuickSync) don't respond to bitrate
setting, so set cqp by default. This gives user a guidance (via the log
msg, that cqp param may be set).
2023-02-28 13:12:14 +01:00
Martin Pulec
b3c1ab2648 lavc: removed q= parameter in favor cqp=
Setting the constant quality is quite per-codec specific so do not
provide 2 distinct options with similar semantic that are mutually
incompatible.

Instead, try to interpret the cqp parameter and set codecs' properties
individually.
2023-02-28 13:12:14 +01:00
Martin Pulec
58b59f92aa lavc: crf/cqp/bitrate/bpp are mutually exclusive 2023-02-28 13:12:12 +01:00
Martin Pulec
73dc207978 lavc/lavd: print hint to prefer keeping colorspace
Since the conversion policy is now "dsc" (depth-subs-cs) by default,
it may trigger more costly conversions so print a hint to enforce the
old behavior if not managing to keep the decode window and pixfmt change
takes at least 1/4 of overal de/compress time.
2023-02-23 12:10:10 +01:00
Martin Pulec
9e83035dd1 lavc: updated x2rgb blacklist comment
no longer valid fox hevc_qsv + explain why not tweaking FF to produce
Y444_10 for x2rgb and not blacklisting
2023-02-23 11:37:33 +01:00
Martin Pulec
51fa404871 lavc: warn of empty preset only if needed
Plenty of encoders do not utilize presets (including JPEG) so do not
warn about not having one if there is no get_preset callback for the
codec.
2023-02-23 09:06:48 +01:00
Martin Pulec
90aa548c02 lavc: allow also depth and rgb/yuv specification
This will allow user more control over compression if requiring a
different properties than would default sorting select.

This is mostly to avoid user specifying '--param lavc-use-codec', which
is not supported, anyways.
2023-02-22 10:57:39 +01:00
Martin Pulec
9c14552afd to_lavc_vid_conv: use struct for enforced params 2023-02-22 09:42:05 +01:00
Martin Pulec
aec0982f00 lavc: removed unneeded attribute 2023-02-21 16:15:00 +01:00
Martin Pulec
e03016b093 lavc: do not blacklist x2rgb10le for qsv
Since FFmpeg commit e530d38b, stream encoded with x2rgb10le is correctly
marked as YCbCr.
2023-02-21 15:36:08 +01:00
Martin Pulec
c0142b88a5 lavc: if configure fails, don't set params
Set params at the end of configure, otherwise subsequent
libavcodec_compress_tile() calls would think that encoder is configured,
which is not true, and it would probably crash.
2023-02-21 10:28:04 +01:00
Martin Pulec
c4c3ffd5dc lavc: fixed test
changed prototype of some functions:

- to_lavc_vid_conv - accept (char *) instead of (struct video_frame)
- get_av_pixfmt_details - (enum AVPixelFormat) instead of int

+ make to_lavc_vid_conv.c partially C++ compatible (I attempted first to
  include it as was it libavcodec.cpp), so leave it (just in case)
2023-02-21 10:28:04 +01:00
Martin Pulec
bd994f4bfd lavc: encapsulate input conversion
Handle conversion to codec supported input pixel format entirely in
to_lavc_vid_conv.

+ removed AVPixelFormats (both codec input and sws input) from struct
  (no longer needed)
+ cleanup - set sws pointer to NULL (prevent potential double free)
2023-02-21 10:28:04 +01:00
Martin Pulec
a8425dbed6 lavc: do not juggle with AVPixelFormat
selected pixfmt can be written directly to
state_video_compress_libav::selected_format
2023-02-21 10:28:03 +01:00
Martin Pulec
494076ca0d lavc: small updates
- free frame parts with av_frame_free
- remove very old compat guard (LIBAVCODEC_VERSION_MAJOR < 53)
- increment AVFrame::pts for the final AVFrame
  (state_video_compress_libav::in_in frame may not be passed to enc)
2023-02-21 10:28:03 +01:00