Commit Graph

181 Commits (master)

Author SHA1 Message Date
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
jpark37 b6afaceeae Update VIDEO_CS_DEFAULT to mean 709 instead of 601
Consistent with modified default UI setting.
2020-09-06 20:51:28 -07:00
Richard Stanway d7e8f115e8 libobs/media-io: Fix suspicious memset behavior 2020-09-04 21:46:18 +02:00
Jim bfdf5dc947
Merge pull request #2356 from jpark37/sycc-color-space
Color space refinements
2020-08-05 08:58:21 -07:00
jpark37 06e4b10675 libobs/media-io: Add missing codec_tag set 2020-07-18 23:35:35 -07:00
jpark37 a69151e204 libobs: Add VIDEO_CS_SRGB support 2020-07-18 19:43:04 -07:00
jpark37 40b4db0c0c libobs/media-io: Fix FFmpeg deprecation warnings 2020-07-18 18:47:52 -07:00
jpark37 cf911744f7 libobs: Fix video scalar copy heights
Use plane height instead of overall height for copying planes to fix
memory stomp.
2020-07-07 12:48:49 -07:00
Jim 3b11e170b7
Merge pull request #2836 from jpark37/yuv-image-fix
Fix FFmpeg YUV to RGB conversion by adding extra destination padding to line sizes
2020-06-26 06:13:45 -07:00
jpark37 d9fa5de572 libobs: Fix right edge for "video scaler"
FFmpeg YUV to RGB conversions require extra destination padding.

This code only appears to be exercised for DeckLink.
2020-06-14 20:26:10 -07:00
jpark37 886bf5ceb7 libobs/media-io: Remove unused code 2020-06-07 11:16:24 -07:00
Hans Petter Selasky 0e4ea14ba1 libobs: Implement and use better scaling function for 64-bit integers
As os_gettime_ns() gets large the current scaling methods, mostly by casting
to uint64_t, may lead to numerical overflows. Sweep the code and use
util_mul_div64() where applicable.

Signed-off-by: Hans Petter Selasky <hps@selasky.org>
2020-04-05 20:27:28 +02:00
Clayton Groeneveld 4e3a0180ba libobs, obs-x264: Fix compiler warnings 2020-01-21 15:18:09 -06:00
jpark37 8134a116be libobs: Add VIDEO_CS_SRGB enum value
Can't implement all at once because of AMF submodule.
2020-01-18 08:21:42 -08:00
Peter Geis 08b1b66439 libobs: fix building modules once installed
sse-intrin.h is a required header now, but the implicit path
breaks building addons once the headers are installed.

Fix this by making the path explicit.
2019-11-27 14:00:15 -05:00
Peter Geis 64d0b7fcb4 libobs: Enable compilation on aarch64
Add arch checks to enable aarch-compat layer on aarch64, retain normal
gcc intrinsics on x86 and ppc64.
2019-11-25 13:04:21 -05:00
jpark37 42bf026a49 libobs: Fix video warnings 2019-08-30 22:13:03 -07:00
Jim 444991ba21
Merge pull request #2021 from jpark37/yuva-format
Add support for YUV alpha formats
2019-08-11 20:38:17 -07:00
jpark37 3d6f5c8ad6 libobs: Add YUV alpha formats
This will allow YUV alpha formats to be converted to RGBA on the GPU.
2019-08-11 11:26:22 -07:00
SCG82 5bc1b3bc76 libobs: Add missing pixel format to format_is_yuv and get_video_format_name 2019-08-03 05:42:30 -07:00
jp9000 68a5a40df9 libobs, obs-ffmpeg, win-dshow: Fix FFmpeg 4.0 deprecation
Fixes FFmpeg 4.0 deprecation warnings.
2019-07-29 20:34:13 -07:00
James Park 37f663a789 libobs: obs-ffmpeg: win-dshow: Planar 4:2:2 video
This format has been seen when using FFmpeg MJPEG decompression.
2019-07-25 20:11:37 -07:00
jp9000 f53df7da64 clang-format: Apply formatting
Code submissions have continually suffered from formatting
inconsistencies that constantly have to be addressed.  Using
clang-format simplifies this by making code formatting more consistent,
and allows automation of the code formatting so that maintainers can
focus more on the code itself instead of code formatting.
2019-06-23 23:49:10 -07:00
James Park 614025742b libobs: linux-v412: obs-ffmpeg: Add packed BGR3 video support
Someone mentioned this format preserves the most quality for a
particular capture card using V4L2.
2019-05-30 06:05:53 -07:00
jp9000 8d125dc01d libobs: Add better default source color range handling
Fixes handling of the `obs_source_frame::full_range` member variable,
which is often set to false by default by many plugins even when using
RGB, which would cause RGB to be marked as "partial range".  This change
is crucial for when partial range RBG support is implemented.

Adds `obs_source_frame2` structure that replaces the `full_range` member
variable with a `range` variable, which uses the `video_range_type` enum
to allow handling default range values.  This member variable treats
VIDEO_RANGE_DEFAULT as full range if the format is RGB, and partial
range if the format is YUV.

Also adds `obs_source_output_video2` and `obs_source_preload_video2`
functions which use the `obs_source_frame2` structure instead of the
`obs_source_frame` structure.

When using the original `obs_source_frame`, `obs_source_output_video`,
and `obs_source_preload_video` functions, RGB will always be full range
by default for backward compatibility purposes.
2019-04-25 15:12:08 -07:00
Dmitry-Me eea71e5e7f libobs: Fix output type specifiers 2019-03-19 18:29:09 +03:00
pkv 918fc6d6c2 libobs/media-io: Fix mono upmix
A mono source is currently upmixed by swresampler in the following way:
- for stereo output, FL=FR=input/sqrt(2)
- for other speaker layouts of the outputs, FC=input, other channels
are zeroed.

In the case of stereo output, this leads to a 3dB level decrease which
users have issue with [1].
The obvious fix of adding a 3dB gain is reported to be adding distortions
on some setups [2].
Note that the "Downmix to Mono" does not fix this upmix problem, since
it just makes all output channels identical by summing all input channels
and normalizing (by dividing by the number of output channels). This last
normalization step results in a level reduction for a mono input.

[1] This fixes https://obsproject.com/mantis/view.php?id=960.
[2] See also: https://obsproject.com/forum/threads/please-allow-for-mono-recording-of-microphones-ill-explain-why.84834
2019-02-24 14:00:57 +01:00
jp9000 36ffa65b68 libobs/media-io: Add frame funcs for separate GPU thread
Normally, the total and skipped frame count for the encoder is performed
in the video-io thread.  However, because a new thread is being
introduced for texture-based encoding, the frontend has no way of being
able to query that.  So, instead of making the frontend query that data
separately, just make the texture encoder thread increment the values of
video-io.  That way, the frontend doesn't need to change any code, and
can continue using the same functions for determining the total/skipped
frame count.

This can cause the frame count to be doubled if both a texture-based
encoder and a raw data encoder is active at the same time, but it's an
acceptable alternative.
2019-02-07 17:00:46 -08:00
Richard Stanway 41b7f85332
libobs/media-io: Prevent overwriting of remux input 2018-08-12 17:06:39 +02:00
Ryan Foster 797c9d330c libobs: Copy metadata for tracks/streams when remuxing 2018-06-02 10:15:13 -04:00
Shaolin ffd2303a36 libobs: Log YUV space/range on video reset
Closes jp9000/obs-studio#1196
2018-02-20 04:26:29 -08:00
pkviet 645d6ae8dd libobs/media-io: Change speaker layout to match FFmpeg aac.
(This commit also modifies the obs-ffmpeg module)

The default channel layouts from aac spec are implemented in FFmpeg
native aac encoder as follows:

    AV_CH_LAYOUT_MONO,
    AV_CH_LAYOUT_STEREO,
    AV_CH_LAYOUT_SURROUND,
    AV_CH_LAYOUT_4POINT0,
    AV_CH_LAYOUT_5POINT0_BACK,
    AV_CH_LAYOUT_5POINT1_BACK,
    AV_CH_LAYOUT_7POINT1,

The correspondence of speaker layouts to AV_CH_LAYOUT from FFmpeg is
changed to reflect the previous table.

Although FFmpeg native aac encoder can now encode all the layouts listed
in avutil channel_layout.h (on master), there might be issues with older
FFmpeg binaries.

Note that 2.1 speaker layout will be encoded as AV_CH_LAYOUT_SURROUND
(FL FR FC) because it is not listed as the default layout for three
channels.

This just means some optimizations for LFE channel will not be used by
the encoder which will treat it as an SCE (single channel element).

Closes jp9000/obs-studio#1182
2018-02-06 06:14:24 -08:00
Jim 77643cce1e
Merge pull request #1139 from takev/pulseaudio-surround-selection
linux-pulseaudio: Surround speaker map
2018-01-19 16:14:04 -08:00