Commit Graph

187 Commits

Author SHA1 Message Date
Martin Piatka
15ab076c4e lavc_common: Define HWACC_VULKAN if ffmpeg is new enough 2025-03-17 13:09:21 +01:00
Martin Piatka
b8208e79d7 libavcodec: Vulkan pixfmt fix inverted ifdef cond 2025-03-17 13:08:59 +01:00
Martin Pulec
b26ca14cb1 lavc get supported prop fix
There are some calls using just the codec_ctx
parameter, which fail (with the compat with
legacy FFmpeg).

eg. `uv -A Opus -s testcard` (using the old FFmpeg)
2025-02-25 23:37:54 +01:00
Martin Pulec
abd758241a debug: move some stuff to utils/debug
The rationale is to separate the config.h-dependent stuff to a separate
file to eliminate the need to transitively include config.h.

+ fix the files that need config.h directly to include it
2024-11-28 11:46:09 +01:00
Martin Pulec
a9b988f9d8 lavc_common: fixed compat
+ fixed unused parm warn with old FFmpeg
2024-11-13 14:58:45 +01:00
Martin Pulec
13fee82660 lavc_common: insufficient include guard
fixed include guard (commit 8b94de582 from yesterday)
2024-11-13 14:40:41 +01:00
Martin Pulec
8b94de582c lavc: replace deprecated items
Some AVCodec properties like pix_fmts or sample_fmts are marked as
deprecated and should be replaced by avcodec_get_supported_config()
in current FFmpeg.

Created compat functions to get rid of deprecate warnings running with
both old and new FFmpeg.
2024-11-12 14:59:19 +01:00
Martin Pulec
73fbec1c8c from_lavc_vid_conv: small refactor
Pass less data in convert_task_data and rather copy relevant
AVFrame properties to AVFrame parts. Compute then the properties in
do_av_to_uv_convert.
2024-10-09 15:08:52 +02:00
Martin Pulec
3b3a34a99a from_lavc_vid_conv: lmt_rng=1 for full-r. src RGB
Set lmt_rng=0 for full-range src YCbCr only - the color conversions are
used for both (src) YCbCr->RGB and RGB->YCbCr (perhaps less often). In
the second case, the input is full-range so that output YCbCr would be
full-range YCbCr 709. which is incorrect.
2024-10-09 15:08:52 +02:00
Martin Pulec
36c47a697a CS_{601,709}: drop _LIM suffix
Since we (currently) use the same value for full-range (setting
ycbcr_bit_depth=0) this may be confusing.
2024-10-08 16:16:15 +02:00
Martin Pulec
e868262f5d from_lavc_vid_conv: handle full-range input
If CS conversion is done, handle also full-range input. This shouldn't be
the case most of the time (we use always limited range) but the case that
is handled is namely a JPEG from a webcam or so, which is 601
limited. Full YCbCr->YCbCr is not handled by this commit.
2024-10-08 16:12:34 +02:00
Martin Pulec
3f813d5a2d color: store also Y_SCALE in coeffs 2024-10-08 15:06:23 +02:00
Martin Pulec
5471e80497 removed MJPG codec_t
Remove MJPG codec_t which was complementary to JPEG. The difference was
that JPEG was used for JPEG with restart intervals and MJPG without.

But slices are now enabled for MJPG (emits reset marker every 16 lines)
which actually gives the GPUJPEG decoder a space for efficient decoding.

Measured decoding performance using Ryzen 7900X and RTX 4080:

NewZealand (UYVY, 3840x2160, frame 2500):

  encoded by\decoded by  GPUJPEG  lavd
  -c libavcodec          7.1 ms   19 ms
  -c gpujpeg             1.35 ms  14.3 ms

-t testcard:s=3840x2160:patt=text

  encoded by\decoded by  GPUJPEG  lavd
  -c libavcodec          2 ms     40 ms
  -c gpujpeg             25 ms    40 ms

The advantage is simpler maintanance (no need to handle 2 codec
identifiers) and also performance because from the above, the  GPUJPEG
decode should be faster even for JPEGs encoded by lavc.

Only situation where lavd performs better is a stream without restart
intervals at all (either `-c lavc:slices=1`, `-c gpujpeg:r=0` or from
a webcam), let say 28 ms for lavd and 40 for GPUJPEG. But it is not worth
keeping it for such a case - it will be better implemented using struct
pixfmt_desc to return rst count and picking the decoder according to
this if really needed.
2024-10-08 12:32:02 +02:00
Martin Pulec
0cc939da56 from_lavc_vid_conv: full-range warn once
As this can occur if the source is eg. a webcam-compressed JPEG and
cannot be easily work-arounded, print the warning just once.

Also update the message - it is not problem that is not being unsupported
but clipping the values (also redundant "may", because we can be sure).
2024-10-08 12:32:02 +02:00
Martin Pulec
d693e74068 vcapf,vopp/matrix2: supp fmts converted over Y416
+ do not print the BT.601 hint if matrix with 601->709 conv used
2024-10-03 15:13:37 +02:00
Martin Pulec
8f063708d3 from_lavc_vid_conv: handle BT.601 conv if possible
If converting from YCbCr to RGB, use BT.601 coefficients.

refer to GH-341
2024-10-02 16:31:57 +02:00
Martin Pulec
34c72bf55b from_lavc_vid_conf: pass params in struct to conv
This will make easier further changes.

Also it is somehow more readable (although the amount of code is actually
200 lines more).
2024-10-02 16:31:57 +02:00
Martin Pulec
ab008cc0b6 vdec/lavd: do not pass widht/height
already member ov AVFrame
2024-10-02 16:31:57 +02:00
Martin Pulec
dc96946582 vdec/lavd: print warning on unspported cs/range 2024-10-02 16:31:57 +02:00
Martin Pulec
bdce8d7ae8 tools: add ug_stub.c to substitute host.cpp
Because host.cpp has extensive dependencies on UG internals, it is a
bit tricky to link-in. Created a replacement instead.
2024-09-30 11:07:37 +02:00
Martin Pulec
9adf7b6101 compat/htonl.->compat/net.h
It can be used in place of other network-related headers, not just for
htonl and family.

+ compat for fd_t and INVALID_SOCKET (that has been in config_*.h)
2024-09-30 10:54:14 +02:00
Martin Pulec
b3a5cdb309 from_lavc_vid_conv: use generic coeffs 2024-09-27 17:06:18 +02:00
Martin Pulec
4542f9d1c6 tools/benchmark_ff_conv: add bench for from_lavc 2024-09-27 17:06:18 +02:00
Martin Pulec
e0ad7892aa to_lavc_vid_conv_init: assert thread_count>0
0 (auto) is not accepted by this function
2024-09-27 17:06:18 +02:00
Martin Pulec
4f613d6a50 get_color_coeffs: copy the pointed struct
to allow the compiler better optimize (see Doxy note for
get_color_coeffs())
2024-09-27 17:06:17 +02:00
Martin Pulec
5a08f9a78f to_lavc_vid_conv: use generic coefficients 2024-09-27 17:06:17 +02:00
Martin Pulec
4fe65769f0 color coeff computing updates
Mainly depth is included in Y_ and CBCR_LIMIT - the used denominator
255.0 matched only 8 bits.

Add (substract) epsilon 0.5 when converting the to integer to round the
value correctly.
2024-09-27 17:06:15 +02:00
Martin Pulec
cad561ead6 from_lavc_vid_conv: yuv444p10le_to_rgb - in 10b
copute in 10 bits, not 8

+ substracted Y floor from Y, which was not before
2024-09-27 17:06:15 +02:00
Martin Pulec
707e4af458 get rid of WORDS_BIGENDIAN
WORDS_BIGENDIAN is defiend by config.h

Use __BYTE_ORDER__  defined by GNU compilers (POSIX 2024 further defines
endian.h header but not yet in macOS /15/),
2024-09-26 14:36:42 +02:00
Martin Pulec
002bb4dc7f tv.h (+others): get rid of NS_IN_MS[_DBL]
Use rather the more comprehensible NS_TO_MS and NS_TO_MS function-like
macros (obvious from what to what the conversion is performed).
2024-09-10 16:40:29 +02:00
Martin Pulec
62dece8d97 to_lavc_vid_conv: extra padding for alloc
fixes `uv -t testcard:codec=R12L:size=1921x1080 -c lavc`
2024-09-03 09:14:23 +02:00
Martin Pulec
4a2b934759 av_to_uv_log: write more clearly 2024-08-14 11:28:09 +02:00
Martin Pulec
6a86eb89b0 lavc_common: simplify logging setting
1. do not call av_log_set_level if using custom callback - seemingly not
used for custom callbacks
2. simplify lavc-log-level (rename from lavcd-...) and keep it only for FFmpeg
values only (+ use FFmpeg default logger)

As indicated by the point 1, it didn't perhaps even work unless the
'D' suffix (now removed) was added to the param because the value set
was not used by the custom callback but default (UG global) log_msg was
used instead.
2024-08-14 11:15:52 +02:00
Martin Piatka
3ffc276706 Remove the rest of old RPI hwaccel
The old and now defunct hwaccel was removed in 30eab46 and was replaced
by a new DRM-PRIME based implementation that works on the recent
versions on Raspbian.

Some parts of the old implementation remained by mistake. This should
remove all the remaining stuff.
2024-05-20 10:50:22 +02:00
Martin Piatka
cb490950c6 hwaccel/drm: Store fd count 2024-05-17 13:19:49 +02:00
Martin Piatka
85493309d2 lavc: Add drm_prime av to ug frame conversion 2024-05-17 13:19:48 +02:00
Martin Pulec
c30f9a3ce5 to_lavc_vid_conv debug time dump fixed
- wrong conversion constant used
- typo - forAMt instead of format
2024-04-12 10:56:56 +02:00
Martin Pulec
ec17ed7950 fixed to_lavc_memcpy_data unset AVFrame::opaque
Fixed a crash on (dummy) conversion from Y216 to AV_PIX_FMT_Y212 (just
memcpy), because the state given in AVFrame::opaque was not passed
through task-specific AVFrames.
2024-03-22 16:35:11 +01:00
Martin Pulec
a66ee61564 Windows CUDA compilation fixes 2024-03-22 09:17:53 +01:00
Martin Pulec
673b497d34 configure: added option to disable lavc CUDA convs 2024-03-20 14:15:38 +01:00
Martin Pulec
fc46a7ab9f cuda FF convs: suggest setting CUDA dev
commented out for now
2024-03-08 16:11:48 +01:00
Martin Pulec
7baefd86a7 disable from_lavc_vid_conv_cuda now
disable until implemented
2024-03-08 16:11:48 +01:00
Martin Pulec
0385e986bd from_lavc_vid_conv_cuda.cu: do not include debug.h
string_view is incompatible with the old gcc compiler used by CI in U20.04
2024-03-08 16:11:48 +01:00
Martin Pulec
0db24671f7 from_lavc_vid_conv: handle AV pixfmt unsupported
Properly handle situations when AVPixelFromat is not handled by CUDA
implementation but CUDA is requested.

In this cases just handle the format as if CUDA was not enabled.

\+ removed Y444 (not needed for testing purposes any more)
2024-03-08 16:11:48 +01:00
Martin Pulec
6aaf4622f5 from_lavc_vid_conv_cuda integrated 2024-03-08 16:11:48 +01:00
Martin Pulec
906a696cdf to_lavc_vid_conv - cuda_conv_enabled including the condition
Now the function checks both if the CUDA implementation is available
and if it is (explicitly) enabled.
2024-03-08 16:11:47 +01:00
Martin Pulec
f741c6e53b from_lavcv_vid_conv: removed some aux functions
unnecesarry
2024-03-08 16:11:47 +01:00
Martin Pulec
60e7e6b24d renamed parallel_convert to av_to_uv_convert
This is now the API.

Original av_to_uv_convert is prefixed with do_ and it is used only
internally.
2024-03-08 16:11:47 +01:00
Martin Pulec
252ae8e76d vdec/lavd: moved parallel_convert to from_lavc_vid_conv
for better encapsulation, just moved the code now with 2 very small fixes:
- int cpu_count - added const
- explicit size_t cast "i * row_height * pitch" to satisfy clang-tidy
2024-03-08 16:11:47 +01:00
Martin Pulec
15aba5a8de lavc: msvc compat 2024-03-08 16:11:47 +01:00