Commit Graph

223 Commits

Author SHA1 Message Date
Martin Pulec
9e5cb700b2 vcomp/lavc: support JXS 2026-02-17 16:50:43 +01:00
Martin Pulec
84f560b97f move countof() def from macros.h to compat/c23.h
technically it will be C2Y but the c23.h can be perhaps used for both

in c++, std::size() is rather used

This fixes compilation of pano_gl, where its implementation
of countof clashes with the macro (leaked through
debug.h->color_out.h->utils/macros.h, which no longer contains that
define).
2026-01-20 11:10:06 +01:00
Martin Pulec
b71b9231c1 from_lavc_pf_priority: do not advertise HW_VDPAU
This is handled differently and may trigger unexpected decode to HW_VDPAU
if gl display advertises that, eg. `uv -t testcard -c lavc:c=MJPG -d gl`.

This fixes the commit 647d8627 (2025-06-25) that unintentionally
enabled that.

The HW accel is hanndled actually separately ahd snouldn't be "enabled"
in this way.
2026-01-13 16:50:27 +01:00
Martin Pulec
258ef5406e replace ARR_COUNT with countof
see also recent commit 951f9648

countof seem to be upcoming C2Y language macro (and _Countof operator)
so make use of it instead of ARR_COUNT that is now removed.
2026-01-07 14:57:26 +01:00
Martin Pulec
5a10182de3 vdec/lavc: fix ProRes decode
fixes decode broken since the commit 7dd9a44 (2025-10-23)

refers to
<https://github.com/CESNET/UltraGrid/issues/479>

closes
<https://github.com/CESNET/UltraGrid/issues/481>
2025-12-05 08:46:14 +01:00
Martin Pulec
ead669c606 to_lavc_vid_conv: remove some warn in 2 last conv
+ IWYU file
2025-11-27 08:30:52 +01:00
Martin Pulec
3b2664086e to_lavc_vid_conv: reindent the recent 2 convs 2025-11-26 16:58:53 +01:00
Martin Pulec
e32dc06641 to_lavc_vid_conv: add r12l_to_ayuv64le
refers to <https://github.com/CESNET/UltraGrid/issues/479>
2025-11-26 16:21:54 +01:00
Martin Pulec
cb73002185 to_lav_vid_conv: add r12l_to_p210le
refers to <https://github.com/CESNET/UltraGrid/issues/480>
2025-11-26 16:21:54 +01:00
Martin Pulec
ecc8a510d5 from_lavc_vid_conv: applied previous commit also here 2025-11-25 15:32:20 +01:00
Martin Pulec
ed94c7a3ec to_lavc_vid_conv: watch_pixfmt_degrade improved
compare just the in codec and the MIN(intermediate, out_pixfmt)

to avoid missleading message
`[to_lavc_vid_conv] conversion is reducing subsampling from 4444 to 4440`
as eg. in:
<https://github.com/CESNET/UltraGrid/issues/480>

if converting R12L to bgra over RGBA - the alpha channel is present just
in the intermediate but both ends have 444 without alpha channel.
2025-11-25 15:31:41 +01:00
Martin Pulec
15a905676c lavc cuda conv: disable by default + note
The actual implementation has not been merged as for now, so disable
the stub by default in configure.ac.

Also add a notice suggesting the removal.
2025-11-21 11:57:58 +01:00
Martin Piatka
c4e20cf044 lavc: Fix r12l_to_gbrp12le conversion 2025-11-18 10:33:23 +01:00
Martin Pulec
9652fbc0b5 to_lavc_vid_conv: add convs R12L->yuv422p1Xle 2025-11-13 11:08:54 +01:00
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