Commit Graph

7089 Commits

Author SHA1 Message Date
Martin Pulec
d9fef1ac32 vcap/ndi: ndi_disp_convert_Y416_to_PA16 fix 2024-10-11 16:31:38 +02:00
Martin Pulec
f12577f0b9 fix vc_copylineRG48toY216
incorrectly braced

Actually not obvious until 2f450060 (2024-09-24) because the chroma x1.5
was used but clamped, which has somehow hidden that.
2024-10-11 16:14:00 +02:00
Martin Pulec
fd08c583eb improved including in few files 2024-10-11 16:13:39 +02:00
Martin Pulec
2b022dd1d8 ndi_common.h: lib loading debug messages
print NDI lib loaded path
2024-10-11 14:06:55 +02:00
Martin Pulec
5ce4e45d12 ndi_common.h: simplify - use static cstr length 2024-10-11 14:06:54 +02:00
Martin Pulec
9c18c7e8e7 vdisp/ndi: refactor init
Use parse_fmt and do not use cumbersome pseudo-C++ exceptions imitation.
2024-10-11 14:05:28 +02:00
Martin Pulec
b9c012737f jpeg_reader: add additional SPIFF CS
Add all color space parameter specifications from T.81 - map known ones,
add commented-out case for the rest.
2024-10-09 15:08:52 +02:00
Martin Pulec
f2d2fcdb8d jpeg_reader: support for spiff pictures
+ hint for GPUJPEG to set limited 601
2024-10-09 15:08:52 +02: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 Piatka
6475aa7358 vdisp/multiplier: Copy frame metadata
The metadate is useful in some cases like the decklink synchronized
mode. Fixes GH-419
2024-10-09 10:16:34 +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
14554b8777 moved internal macros from color.h to .c 2024-10-08 15:18:23 +02:00
Martin Pulec
5daca13530 GL: compute coeffs dynamically 2024-10-08 15:14:13 +02:00
Martin Pulec
3f813d5a2d color: store also Y_SCALE in coeffs 2024-10-08 15:06:23 +02:00
Martin Pulec
6b7422e56a vdec/gpujpeg: toggle on itu601->709 override
If the JPEG is interpreted as FFmpeg encoded limited range 601
(CS=ITU601), override the CS to BT.709 (UG encodes BT.709).
2024-10-08 14:35:30 +02:00
Martin Pulec
49604293e5 vdec/lavd: override colorspace only for FF JPEGs
Check if range is MPEG and CS=BT470GB (JPEG compressed with FFmpeg in
UltraGrid). Otherwise do not override the props - JPEGs from webcamse
etc. that almost certailny have the JPEG (full) range.
2024-10-08 14:26:23 +02:00
Martin Pulec
88d8769524 vdisp/sdl2: set BT709 conversions explicitly
(if BT601 is not set by --param)

The default value is SDL_YUV_CONVERSION_AUTO, which is 601 for SD and 709
for HD. UltraGrid doesn't distinguish and implictly assumes 709 always
(although 601 for SD makes sense).
2024-10-08 13:53:08 +02:00
Martin Pulec
a0f8794153 vdec/gpujpeg: include directly used sys headers
do not use config*.h
2024-10-08 12:35:24 +02:00
Martin Pulec
3aa91f67ad vcomp,vdec/gpujpeg: toggle on profiling in debug
If log_level >= LOG_LEVEL_DEBUG, set the perf_stats option, which with
current GPUJPEG prints the performance stats to stdout.
2024-10-08 12:32:02 +02:00
Martin Pulec
22e9b7cfee import: accept video.info written by Win in *nix
In MSW it seems like the video.info is written in text mode, so that line
ending is CRLF. When read in POSIX systems, \r is not consumated so that
expect it can be present.
2024-10-08 12:32:02 +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
4e13bc903c add MSG_ONCE
refer to GH-411
2024-10-08 12:31:59 +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
f08f56f6b5 vcapf,vopp/matrix: hint to use matrix2 + improve
Hint to use matrix2 - matrix (1) is somehow special, especially when
handling UYVY that is handled (historically) very unorthodoxly - after
matrix applied, marked as RGB (YUV expanded to 4:4:4).

also improved including (IWYU)
2024-10-03 15:13:37 +02:00
Martin Pulec
7db0b8dfc9 added matrix2 capf/vopp
Matrix (1) doesn't seem to be generic enough in case of UYVY.

THe aim is, among others, last resort fix of the BT.601 problem when
got from QSV compression and no YCbCr->RGB conversion took place.
2024-10-03 15:13:35 +02:00
Martin Pulec
295c3c764d vdisp/sdl2: handle --param color-601 2024-10-02 16:31:58 +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
fa9e3ec24e vdec/lavd: do not print JPEG warning
The JPEG is either BT.709 (lavc-encoded, YCbCr encoded by GPUJPEG)
or Adobe RGB (if encoded by GPUJPEG). Both are processed correctly
by the lavd decoder - BT.709 is assumed if YCbCr, RGB is decoded
to GBRP (so either no conversion to RGB PF or default handling
if the output PF is YCbCr).
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
9c5015661f lavd: override JPEG color-space to BT.701
FFmpeg returns always bt470b, even with GPUJPEG SPIFF JPEGs (only the
color_range can be either tv or pc depending if sender sets range as
JPEG or MPEG - we're setting MPEG for YCbCr always).

Also alter the JPEG message.
2024-10-02 16:31:57 +02:00
Martin Pulec
2448f92bea vdec/lavd: print codec characteristics in verbose 2024-10-02 16:31:57 +02:00
Martin Pulec
792c06d4f6 vcomp/lavc: set limited-range BT.601 for QSV 2024-10-02 16:31:54 +02:00
Martin Pulec
fc6efc9a5b vcomp/lavc: remove unneeded code
The same assignment is later in the get_av_pixfmt_details() call (this
is the relict from the times when function was implemented differently
- 23ca8f37).
2024-09-30 15:26:01 +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
745c7f9aee support conversions with BT.601 chromicities
Added experimental support for conversions with BT.601 primaries. The
command-line interface will most likely change.
2024-09-27 17:14:13 +02:00
Martin Pulec
7d5b94af9d pixfmt_conv.c,video_codec.c: updated Doxy 2024-09-27 17:06:29 +02:00
Martin Pulec
16cfc6a3e2 color.c: generalize the macros
do not assume just BT.709 coefficients
2024-09-27 17:06:29 +02:00
Martin Pulec
7168c8763b color.h: rm no longer needed macros (_709_SCALED)
+ moved the coefficient computing ones to color.c
2024-09-27 17:06:18 +02:00
Martin Pulec
6e9339133b fixed the test to use new coeffs API
+ wrap the function with obligatory extern "C" for C++ code (as the
test is)
2024-09-27 17:06:18 +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