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.
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.
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)
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
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.
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.
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.
\+ 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)
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).
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
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
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
```
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.
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).
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>
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.
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)
Write uncompressed output only if user explicitly specifies NUT container
to avoid unexpected results when `-d file` is writing overwhelming amount
of data.
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.
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).