Commit Graph

154 Commits

Author SHA1 Message Date
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
Martin Pulec
dcf882cc61 from_lavc_vid_conv: make iternal state opaque
Return just a pointer (that needs to be detroyed after that).

This is perhaps more convenient way and also it will allow eg. utlizing
GPU for the conversions.
2024-03-08 16:11:46 +01:00
Martin Pulec
1825e6a0da added API for from_lavc_vid_conv_cuda
not yet used
2024-03-08 16:11:46 +01:00
Martin Pulec
a7e9bcb0d2 to_lavc_vid_conv_cuda: disable until implemented
When to_lavc_vid_conv_cuda_init() returns nullptr, skip silently the
CUDA implementation (not yet implemented).
2024-03-08 16:11:46 +01:00
Martin Pulec
a9da4539d8 to_lavc_vid_conv: add stub for CUDA implementation 2024-03-08 16:11:46 +01:00
Martin Pulec
68b2f6cf13 to_lavc_vid_conv: pixfmt offer refactor
Factored out set_convertible_formats() from get_available_pixel_formats()
to slightly remove the complexity + readibility.

Also used early returns to reduce indetion levels.

Refactor only - the code should be idempotent.
2024-03-08 16:11:46 +01:00
Martin Piatka
30eab46369 Remove old RPI4 hw accel
This was based around the /dev/rpi_hevcmem interface, which is no longer supported or working on the current versions of raspbian
2024-03-06 13:54:09 +01:00
Martin Pulec
aa42b46397 removed debug.h from lavc_common.h
not needed here, better include in source files
2024-03-04 14:44:23 +01:00
Martin Pulec
cba9699cb8 to_lavc_vid_conv_init: set tmp_frame attributes
Set tmp_frame width, height and format. Those are not copied by
av_frame_copy_props as supposed by commit 5d3c31c115 (2023-10-31).
As such, this partially revers that commit.
2024-03-01 15:57:17 +01:00
Martin Pulec
d200796e7c ffmpeg audio channels: include channel_layout.h
Reported as missing when compiled with Debian 12 distro FFmpeg.

\+ removed config*.h from lavc_common.c - none needed
2024-02-16 13:10:48 +01:00
Martin Pulec
c14ad5f95e pixfmt_conv.h: small doxy update
\+ added some direct pixfmt_conv.h includes (in attempt to remove its
inclusion from video_codec.h, which finally didn't take place but still
it is better to include this directly)
2023-11-13 10:27:09 +01:00
Martin Pulec
9f5530df1b build: hedge lavc depends
Allow linking libavcodec conversions outside UG with reasonably small
amount of dependencies.
2023-11-10 15:49:53 +01:00
Martin Piatka
01023463a6 lavc_common: get_avpixfmts_names: Clear buf first
Since the buffer is static, it contains stuff from previous run of the
function. We need to clear it before appending new pixfmts in the loop.
2023-11-07 15:44:53 +01:00
Martin Pulec
9938f6b082 av_log_ug_callback: handle overflow
If the buffer is full, flush the output even if there is no NL at the
end and issue a warning (should be handled - either some error or some
module produces unexpectedly long output).
2023-11-01 17:01:32 +01:00
Martin Pulec
fea0d10f67 improved UG FFmpeg logger
do not prefix messages not starting on new line by timestamps, eg.:

    $ uv -s embedded -t testcard -d file:n=/dev/null -V
    [1698853041.393] [lavc]   Stream #0:0[1698853041.393] : Video: rawvideo, 1 reference frame (UYVY / 0x59565955), uyvy422, 1920x1080 (0x0), q=2-31, 829440 kb/s[1698853041.393] , [1698853041.393] 25 tbn[1698853041.393]

Flush the output only on NL and before it store it in internal
thread-local buffer.

Locking was removed as static data are now thread-local.

this improves 808b3de3
2023-11-01 17:01:31 +01:00
Martin Pulec
5d3c31c115 to_lavc_vid_conv: cp metadata out to tmp (refactor)
Set metadata to out_frame only and copy it to tmp_frame (not to repeat
every assignment and potentially forgotting something).

\+ check tmp_frame afor allocation failure
2023-10-31 11:03:36 +01:00
Martin Pulec
37ae3935e9 to_lavc_vid_conv: set AVFrame CS and range
Some encoders use `colorspace` and `color_range` from AVFrame,
eg. _hevc_videotoolbox_:

   uv -t testcard -c libavcodec:encoder=hevc_videotoolbox

(defaults to bgra, because other foramts don't keep 4:2:2 subsampling,
supported at the time: videotoolbox_vld nv12 yuv420p bgra p010le).

Fixed error was producing this message:
````
[lavc hevc_videotoolbox @ 0x12fc04190] Could not get pixel format for color format 'bgra' range 'unknown'.
[lavc hevc_videotoolbox @ 0x12fc04190] Error: Cannot convert format 28 color_range 0: -22
```
2023-10-31 10:57:07 +01:00
Martin Pulec
c3e4e2cc5d to_lavc_vid_conv: added rgb_to_yuv444p
For following command, deduced conversion is to 10-bit YUV:

    $ uv -t testcard:c=RGB -c libavcodec:enc=libx264 -d gl
    [to_lavc_vid_conv] converting RGB to yuv444p10le over R12L

(and over R10k for RGBA) which is correct, because we don't have any
8-bit YUV pixfmt keeping 4:4:4 subsampling.

But this is quite ineffective because the conversions are more expensive
and we are needlessly compressing 10-bit YUV instead of 8-bit.

Thus (as we don't have any UG 8-bit YUV444 pixfmt) the rgb_to_yuv444p
conversion was added.
2023-10-12 10:21:08 +02:00
Martin Pulec
2a73855c05 fixed new Coverity issues
fixes CID 41741{7,8}
2023-10-10 08:16:09 +02:00
Martin Pulec
778fd40fb1 lavd video: use get_avpixfmts_names
Simplifies the code + removed in that function leading space (used in
original code but the function shouldn't produce leading space).
2023-10-06 16:44:15 +02:00
Martin Pulec
15fe21df4f lavd video: check vid subs from sw_pix_fmt
Check if video subsampling is 4:2:0 from sw_pix_fmt than iterating over
received pix_fmts. This is simplier and more effective since the SW
format is set the get_format() callback to the nominal SW format (if any).
2023-10-06 11:19:11 +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
11bf11c784 removed DPX10 pixfmt
Not used anymore by any module. Actually the Bluefish444 that seem to
have handled that doesn't advertise other codec than UYVY by get_property.
2023-10-06 11:19:06 +02:00
Martin Pulec
b62566ca72 lavd: advertise accelerated codesc if probed
Advertise conversion to HW-accelerated codecs (eg. HW_VDPAU, RPI4_8)
only if probe (which now works in the same way as regular init since
HEAD^) would initialize to an accelerated codec.

This would prevent situations, when eg. `--param use-hw-accel=vaapi -d
gl` is used, in which case HW_VDPAU was selected as a display codec,
although not intended.
2023-10-06 08:07:19 +02:00
Martin Pulec
d72d1cf3c4 document pixfmt conversion files 2023-09-21 09:07:22 +02:00
Martin Pulec
c44d4bd78d file: old channel_layout API format
added compatibility with older FFmpeg libraries

see also
<7544fcb525 (r126660408)>
2023-09-11 10:54:45 +02:00
Martin Pulec
fa60441fde display file: make other audio compress working
Make working compressions other than Opus, taking sample format other
than S16 (interleaved).

Accept also S16P and FLTP (needed for AAC, MP3, Vorbis).

\+ also process stereo input (as currently only mono are accepted)
2023-09-07 16:07:44 +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
7544fcb525 file display: added audio output 2023-09-06 12:43:47 +02:00
Martin Pulec
fc742b69de lavc_common.h: do not define R,G,B globally
When included prior to (Mingw-W64) windows.h, it causes compilation
fail, because "R" is used as a param name in transitively included
avx512fp16intrin.h.
2023-09-05 09:37:07 +02:00
Martin Pulec
4fbe76085e lavd_flush: print error msgs, not only numbers 2023-08-15 16:26:59 +02:00
Martin Pulec
0017e57134 compat/qsort_s.h: do not require include 1st
Do not enforce the file to be either included before stdlib.h or stdlib.h
to be using __STDC_WANT_LIB_EXT1__ = 1. The bound checking API is
currently nowhere implemented, anyways, and we may use system native secure
qsort implementation (qsort_r in *NIX, MS variant of qsort_s).
2023-08-14 16:06:15 +02:00
Martin Pulec
ef751e16ff print_decoder_error: no extra space after mod_name
mod_name usually already contains trailing space (eg. "[lavd] ") so do
not produce an extra one.

+ reindent
2023-06-15 11:29:58 +02:00
Martin Pulec
2961fe2f44 lavc video: print used thread count and mode 2023-05-17 11:48:08 +02:00