Commit graph

213 commits

Author SHA1 Message Date
derrod 79632f96dd libobs: Fix buffer overrun in video_frame_init 2024-05-25 17:12:34 -07:00
pkv 5b2e2a9c68 libobs/media-io: Fix media-remux channel layout for 5 channels
FFmpeg has 5.0 as default layout for 5 channels.
But obs-studio uses 4.1. This is a fix when remuxing.

Signed-off-by: pkv <pkv@obsproject.com>
2024-05-09 10:27:20 -04:00
tt2468 fa482b6b49 libobs: Fix I40A plane height calculation for fourth plane
The commit 2fc13540 introduced a typo bug causing the defined height of
the fourth plane in I40A to be 0, instead of the original frame height.

This changes a 0 to a 3, in order to populate that value correctly.
2024-05-03 21:05:13 -07:00
Norihiro Kamae d81dd24f38 libobs/media-io: Fix copying different line-size video frame
The commit 2fc13540f implemented to copy a video frame into a different
line-size video frame.
However, when the line-size was different, the frame was not correctly
copied.
2024-04-28 09:58:40 -07:00
tt2468 2fc13540f0 libobs: Rewrite video-frame
Rewrites the `struct video_frame` implementation, resolving a few
hidden bugs, and improving memory alignment reliability. Should also
make it much easier to implement and maintain texture formats in this
part of the codebase.
2024-04-26 08:25:26 -07:00
derrod 567e35ac69 libobs: Set channel layout for remux output 2024-03-18 19:41:46 -04:00
derrod 2963959e71 libobs: Replace circlebuf with deque 2024-01-16 16:45:09 +01:00
Robert Wittams 73e9561633 mac-capture: Allow selection of channels on core audio devices 2023-12-19 18:33:53 -05:00
Stephen Seo cd784644f5 libobs: Fence off unnecessary code due to FFmpeg v6.1 changes
Fixes for using FFmpeg 6.1 due to deprecations. Uses `#if` macros to
allow builds for using older versions of FFmpeg.

This commit prevents obs from using the "fenced" code if using FFmpeg
6.1, since in FFmpeg commit [1] the "side_data" is added to
`AVCodecParameters`, and therefore the existing/following
`avcodec_parameters_copy(...)` will account for the metadata.

[1]: avcodec/codec_par: add side data to AVCodecParameters
21d7cc6fa9
2023-12-02 17:43:18 -06:00
Norihiro Kamae 16fed06927 libobs/media-io: Fix link error including a header file from C++ 2023-11-25 17:04:47 -06:00
derrod 845a4a6f64 libobs: Remove superfluous NULL checks 2023-11-17 11:04:33 -05:00
jpark37 40edda536d libobs/media-io: Relax color space comparison
Allow VIDEO_CS_DEFAULT to avoid slow conversions.
2023-08-15 13:15:45 -07:00
jpark37 7669da1ea8 libobs: Add VIDEO_FORMAT_R10L
Support 10-bit packed format that DeckLink uses.
2023-07-29 16:41:31 -07:00
derrod c939525f77 libobs: Remove legacy FFmpeg compatibility 2023-07-12 15:57:43 -04:00
Ruwen Hahn 6cdfb0a8b9 libobs: Allow configuring frame rate divisor for encoders
This allows encoders/outputs to output at a frame rate that is lower
than the configured base frame rate
2023-07-03 09:35:06 -07:00
Lain 106c7aa61f Update copyrights/names 2023-05-20 01:31:18 -07:00
jpark37 5a46c1e513 libobs: Fix v210 display name 2023-04-05 21:54:25 +02:00
Kurt Kartaltepe 36409f01cf libobs/media-io: Use inputs_mutex during close
This code assumed that no one would be racing after we stopped the input
thread, however the obs output thread also races and can free the inputs
during disconnect before we finish closing the video mix.

Instead keep the locks around after stop and use them during close to
avoid races.

Fixes crashes when stopping virtual webcam on linux.

Co-authored-by: Norihiro Kamae <norihiro@nagater.net>
2023-03-27 01:14:32 -07:00
PatTheMav 90f46a9d4d libobs: Add missing VIDEO_FORMAT_V210 handling in switch statements
Format was added to enum but not handled in all switch statement
handling the enum.
2023-03-26 13:48:01 -04:00
jpark37 97843dd7d7 libobs: Add VIDEO_FORMAT_V210
Support 10-bit packed format that DeckLink uses.
2023-03-26 01:52:44 -07:00
derrod dcee4fc61a libobs: Allow encoders to request unclamped audio mix
This is useful for formats such as 32-bit float PCM which providers
greater flexibility in editing by retaining information that would
otherwise be clipped.
2023-03-25 10:38:18 +01:00
Chris (Flaeri) 0eb496e8cf libobs/media-io: Add color range and space to conversion
By adding the range data we can get successful handling of full range
color via custom FFmpeg output. Previously it would always default to 0
which would yield partial/limited output. Without the colorspace info
the output file is correctly tagged, but not undergone the actual
conversion.
2023-03-03 21:48:09 +00:00
jpark37 463bf0dff5 libobs,UI: Add P216/P416 pixel formats
Will be useful for ProRes.
2023-02-21 18:48:44 +01:00
PatTheMav fb7a9edadc libobs: Fix non-exhaustive switch statements 2023-02-18 15:22:33 -08:00
tuduweb e36163ce89 libobs/media-io: Correctly check codec tag compatibility for out stream 2023-02-15 18:21:09 +01:00
Jim 1f469e4f7c libobs/media-io: Add get_total_audio_size()
get_audio_size() gets the size of individual planes.
get_total_audio_size() gets the size if you include all planes.
2023-02-05 02:55:24 -08:00
tytan652 ca896dbce7 media-io: Fix FF_API_BUFFER_SIZE_T not being defined on Ubuntu 20.04 2023-01-19 13:08:46 -05:00
pkv2 252e352a51 libobs: Change audio resampler to new channel API
The channel_layout API was overhauled by FFmpeg [1-5]. The previous
bitmask channel_layout is replaced by a struct ch_layout which combines
the number of channels, a bitmask and other infos.
The resampler needs to be updated whenever using swresample > 4.5.100.
This commit makes the necessary changes.

[1] Bump minor versions after the channel layout changes
FFmpeg/FFmpeg@cdba98b
[2] lavc: switch to the new channel layout API
FFmpeg/FFmpeg@548aeb9
[3] avutil/channel_layout: Add a new channel layout API
FFmpeg/FFmpeg@086a804
[4] avframe: switch to the new channel layout API db6efa18
FFmpeg/FFmpeg@db6efa1
[5] swresample: convert to new channel layout API
FFmpeg/FFmpeg@8a5896e

Signed-off-by: pkv <pkv@obsproject.com>
2022-11-10 19:37:07 -05:00
PatTheMav bbb3dc0059 libobs: Force hvc1 codec tag for HEVC video and respect input tags 2022-11-02 22:44:20 +01:00
jpark37 3dd0f895f8 libobs/media-io: Restore color range conversion
FFmpeg needs color range during context init to handle conversions.
sws_setColorspaceDetails after the fact is too late.
2022-09-26 21:26:01 -07:00
jpark37 5af9c87e1b libobs/media-io: Avoid scaler for range diff
Green tint appears when using converting full NV12 to limited NV12 with
swscale, so just avoid creating scaler by color range for now.
2022-09-24 16:45:01 -07:00
jpark37 70f8e83353 libobs/media-io: Create scaler in more cases
Check for other data mismatches the scaler can fix up.
2022-09-10 15:36:27 -07:00
Claude Heiland-Allen 06f66f3120 libobs: Clamp audio NaN to 0.0f
Add comparison check so that NaN is caught.
Comparisons with NaN always result in false.
NaNs cause problems later in audio encoder.

Note: may break with -ffast-math compiler flag.

Fixes #4885.
2022-05-21 02:24:43 +02:00
pkv e66542075d libobs: Fix missing include due to FFmpeg 5 changes
Since [1], avcodec/version.h is not included anymore in codec.h and
therefore is not included any more  in avformat.h.
As a result, LIBAVCODEC_VERSION_INT is no longer defined. This commit
fixes the include.
Since obviously we can't ifdef the avcodec include by referring to an
avcodec version, we ifdef it with the avformat version which was bumped
at the same time [2].

[1] libavcodec: Split version.h
f2da2e1458
[2] doc: Add an entry to APIchanges about changes to version.h and
 version_major.h
f3a0e2ee2b

Signed-off-by: pkv <pkv@obsproject.com>
2022-05-16 16:17:32 -04:00
Norihiro Kamae d044231bfc libobs/media-io: Sleep to next audio time accurately
Prior to this change, the audio thread roughly waits the time of
`AUDIO_OUTPUT_FRAMES`, and consecutively processes twice or more if the
latency is accumulated. This behavior causes fluctuation of timing to
output audio packets. This change introduces `os_sleepto_ns_fast` so
that the audio packets will be periodically output.
2022-05-15 02:31:31 -07:00
Jim 952988d9ec
Merge pull request #6231 from mvji/prores_pix_fmt
Add support for GPU conversion of YUV422P10LE, YUV444P12LE, YUVA444P12LE
2022-05-04 02:01:27 -07:00
jpark37 7ce8cf8477 libobs/media-io: Preserve video side data on remux 2022-04-30 16:05:01 -07:00
mvji 93490da4c2 obs-ffmpeg: Use YVYU for FFmpeg pix fmt YVYU422
This commit also modifies deps/media-playback and libobs.
2022-04-19 19:39:22 +02:00
mvji d3a8ef7128 libobs: Add support for YUV422P10LE, YUV444P12LE, YUVA444P12LE 2022-04-19 19:37:07 +02:00
jpark37 59dbc3eb81 libobs: Rename Rec. 2020 to Rec. 2100
Rec. 2020 is really an SDR spec, but I think HDR10 made it okay to slap
PQ on it, call it an HDR spec. Rec. 2100 came along after and formally
allowed the use of PQ/HLG, so we should use 2100 instead.
2022-04-10 00:13:52 -07:00
jpark37 94fa6d064b libobs: Add video_format_get_parameters_for_format
Video matrix is slightly different based on the number of bits per
channel, so derive from video_format for convenience.
2022-04-07 19:28:51 -07:00
jpark37 0ed0f2cdb4 libobs: Add I010/P010 support, TRC enum 2022-04-03 00:01:25 -07:00
jpark37 6fc5566f38 libobs: Add SWS_CS_BT2020 support 2022-04-02 20:14:31 -07:00
jpark37 692ca7efce libobs: Add Rec. 2020 video_colorspace enum values
One for PQ, and one for HLG. Including transfer function as part of the
color space simplifies logic by avoid invalid combinations.
2022-03-24 20:56:19 -07:00
Ryan Foster 5f68991911 clang-format: Commit file changes for clang-format 12 2021-10-13 20:00:04 +11:00
jpark37 e582879303 libobs/media-io: Register audio thread with MMCSS
Ensure audio gets more priority to help prevent glitching.
2021-10-10 19:19:01 -07:00
jpark37 0c208f1e62 libobs/media-io: Fix leaks and error handling 2021-08-23 22:57:07 -07:00
jpark37 8440a53da3 libobs: Round up chroma sizes for odd resolutions
When playing video, OBS can overflow and crash, or render video edges
incorrectly if the video resolution does not divide into 2 for trivial
chroma subsampling. This is fixed by rounding chroma plane sizes up
instead of down, and maintaining that through the video pipeline.
2021-07-23 12:02:06 -07:00
Richard Stanway e5c6839904 libobs, obs-ffmpeg: Use correct value for EINVAL error check
FFmpeg functions such as av_interleaved_write_frame return negative
on error, so all errno values are negated.
2020-12-21 18:37:49 +01:00
Richard Stanway e00feef7ab libobs: Ignore non-fatal ffmpeg return values during remux
Similar to 315fbd6 and 6071098, ignore non-fatal errors during the
remux process. It's possible OBS itself writes a file that generates
these errors when remuxed.
2020-12-02 21:05:43 +01:00