Commit Graph

209 Commits

Author SHA1 Message Date
Martin Pulec
f9b950f6d9 vcomp/lavc: add Advanced Professional Video
+ reindent av_to_uv_map struct
2025-10-24 11:22:59 +02:00
Martin Pulec
434d23ddd6 color.{c,h}: rename to color_space
color is too much general - the declarations relate to color spaces
2025-10-08 15:19:36 +02:00
Martin Pulec
4517c15526 testcard patt=bars: annotate font sz in pt
multiples of base font bitmap font height is used
2025-10-03 12:22:03 +02:00
Martin Pulec
00898f90fa from_lavc_vid_conv bench tool compat
Fix the benchmark tool build when src/config.h present and CUDA
conversions enabled there. The appropriate CUDA files will be required
if HAVE_LAVC_CUDA_CONV is defined.
2025-10-02 14:15:47 +02:00
Martin Pulec
90b6ec7bbe from_lavc_vid_conv: supporess unused fn warn 2025-09-29 08:10:39 +02:00
Martin Pulec
7c882baa98 lavc: add mapping VUYA<->AV_PIX_FMT_VUYX
should allow FF codecs with VUYX supported without conversion
2025-07-02 08:41:06 +02:00
Martin Pulec
5d5ebd6812 lavc VUYA compat
use already existing VUYX_PRESENT (VUYA was added by 6ab8a9d3 in Jul
2022 a month earlier than VUYX)
2025-07-01 09:02:59 +02:00
Martin Pulec
7aa204d574 from_lavc_pf_priority: fine-grain selection
If there is no direct conversion from a AV PF compatible with internal
format, penalize a bit.

This may be mostly unneeded but just in case. It can be safely reverted,
anyways.
2025-06-26 11:13:34 +02:00
Martin Pulec
647d8627c4 from_lavc_pf_priority: get supported pf from convs
Assume that the output pixel format (ugc) is supported if there is at
least one conversion. This may not be optimal but it is just as it was
until now, we just remove the hard coded list.

Effectively this is just a refactor, except:
- VDEC_PRIO_NOT_PREFERRED now not returned if internal.rgb !=
codec_is_rgb(ugc) - doesn't seem relevant, because the codec is already
probed and ugc determined. So any alternative decompress will need to do
the conversion as well.
2025-06-26 11:13:34 +02:00
Martin Pulec
fcdb58e669 vdec/lavc: get_priority - delegate to from_lavc
Since the pixfmt conversion is responsibility of from_lavc conversion,
delegate the get_priority query there (after we know that we can decode
codec).
2025-06-26 11:13:34 +02:00
Martin Pulec
fb15e67b15 lavc/utils.c: IWYU 2025-06-24 11:52:09 +02:00
Martin Pulec
4a0714a1b8 lavc,v4l2: add mappings fro VUYA 2025-06-24 11:51:55 +02:00
Martin Pulec
e4d896e90e from_lavc_vid_conv: add conv YCbCr 444->VUYA
When supported by the display, this eliminates the conversion eg. to
Y416 for video display because UYVY or v210 are 4:2:2. But the conversion
went over UYVY anyways (there was no conv from Y444 keeping subsampling), eg:
`$ uv -t testcard:c=vuya -d gl`
was originally:
```
./src/libavcodec/from_lavc_vid_conv.c: selected conversion from yuv444p to Y416 with UYVY intermediate.
```

now VUYA is selected
2025-06-24 10:30:12 +02:00
Martin Pulec
bfdb477476 get_av_to_uv_conversion_int: avoid NULL dereference
Avoid NULL pointer dereference for VERBOSE msg - in that case SWS fallback
can be used but if --verbose passed, UG crashes on nullptr dereference.
2025-06-24 08:39:59 +02:00
Martin Pulec
42134848a6 to_lavc_vid_conv: set uv_to_av metadata later
Set the metadata for parallel conversion later - av_frame_make_writable()
may actually alter that (at least pointer but perhaps also linesize), those
old values might have been invalidated by that lavc call.
2025-06-20 14:59:17 +02:00
Ben Roeder
a62fe80c3f Fix spelling errors throughout codebase
Corrected various spelling mistakes in comments, documentation, and
variable names across the project. Changes include:
- Documentation files (CONTRIBUTING.md, README.md, etc.)
- Source code comments in C/C++ files
- Function parameter names and descriptions

No functional changes were made.
2025-06-01 18:03:40 +01:00
Martin Pulec
19f19c300a from_lavc_vid_conv: fix -Wcast-align (clang) 2025-05-05 12:59:36 +02:00
Martin Pulec
33b222c34c from_lavc_vid_conv: CS warn only once 2025-04-30 16:08:23 +02:00
Martin Pulec
fa764db2d6 share some more convs between sdl3, to_lavc, testc
1. to SDL3 nv12 (not supported before)

2. to_lavc - use rgba_to_bgra - the vc_copyline version was not keeping alpha
(if ever used - this may cause regressions, unfortunately, if alpha is
assumed to be 100%, because the orig version set it always)

3. uyvy_to_i420 use by testcard and to_lavc

uyvy_to_i420: do not write out of bounds

If width % 2 = 1, 1 extra luma on first line of pair will override the
first luma on the second.
2025-04-01 14:02:30 +02:00
Martin Pulec
faf1367cb7 y216_to_p010le: make it usable also for FFmpeg
to_lavc conversion
2025-04-01 14:02:30 +02:00
Martin Pulec
6c4d62413c sdl3: support AV_PIX_FMT_P010LE
v210_to_p010le moved 1:1 to pixfmt_conv.c (with different signature)
2025-04-01 14:02:29 +02:00
Martin Piatka
206b05f180 lavc: Add AV_PIX_FMT_VULKAN to supported pix fmts 2025-03-17 13:09:21 +01:00
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