Commit Graph

5151 Commits

Author SHA1 Message Date
Marvin Scholz
d67c6c7f6f lavu: use address-of operator checking clock_gettime
When targeting a recent enough macOS/iOS version that has clock_gettime
it won't be a weak symbol, in which case clang warns for this check
as it's always true:

  warning: address of function 'clock_gettime' will always
  evaluate to 'true'

This warning is silenced by using the address-of operator to make
the intent explicit.
2020-12-28 01:12:26 -03:00
Lynne
b51b9bbd42
hwcontext_vulkan: wait and signal semaphores when transferring to CUDA
Same as when downloading. Not sure why this isn't done, probably
because the CUDA code predates the sync mechanism we settled on.
2020-12-05 23:53:23 +01:00
Limin Wang
48235c8263 avutil/opt: add AV_OPT_FLAG_DEPRECATED option
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-12-05 09:00:53 +08:00
Marton Balint
eca12f4d5a avutil/timecode: add av_timecode_init_from_components
Signed-off-by: Marton Balint <cus@passwd.hu>
2020-12-03 18:32:54 +01:00
Marton Balint
2d90d51c56 avutil/timecode: allow drop frame timecodes for multiples of 30000/1001 fps
Signed-off-by: Marton Balint <cus@passwd.hu>
2020-12-03 18:32:13 +01:00
James Almer
53b4550bdd avutil/film_grain_params: fix doxy for ar_coeff_* fields
Signed-off-by: James Almer <jamrial@gmail.com>
2020-12-03 13:25:21 -03:00
Paul B Mahol
13df9bfbcb avutil/avsscanf: fix possible overreads when dealing with %c or %s 2020-12-02 13:54:53 +01:00
Lynne
659e6e9c88
hwcontext_vulkan: reduce priority for PACK32 formats
Due to some endian-dependent overlap, these should be used last.
2020-11-27 02:58:02 +01:00
James Almer
ee61d4dc68 avutil/film_grain_params: add more details to some AVFilmGrainAOMParams fields
Signed-off-by: James Almer <jamrial@gmail.com>
2020-11-26 22:35:40 -03:00
Lynne
2ba04670c3
lavu/film_grain_params: fix typo in type enum
Ref: xkcd #1015
2020-11-27 02:30:01 +01:00
Niklas Haas
3fbc74582f
hwcontext_vulkan: optionally enable more functionality
These two extensions and two features are both optionally used by
libplacebo to speed up rendering, so it makes sense for libavutil to
automatically enable them as well.
2020-11-25 23:14:47 +01:00
Lynne
2aeb152653
hwcontext_vulkan: support additional pixel formats
We support every single packed format possible now.
There are some fringe leftover mappings which are uninteresting.
2020-11-25 23:14:47 +01:00
Lynne
48b3532183
hwcontext_vulkan: fix incorrect A/0BGR mapping
Vulkan formats with a PACK suffix define native endianess.
Vulkan formats without a PACK suffix are in bytestream order.

Pixel formats with a LE/BE suffix define endianess.
Pixel formats without LE/BE suffix are in bytestream order.
2020-11-25 23:14:46 +01:00
Lynne
3aa8de12ab
hwcontext_vulkan: simplify plane size calculations and support 4-plane formats
Needed to support YUVA.
2020-11-25 23:14:46 +01:00
Lynne
7b274a9b89
hwcontext_vulkan: do not segfault when failing to init a AVHWFramesContext
frames_uninit is always called on failure, and the free_exec_ctx function
did not zero the pool when freeing it, so it resulted in a double free.
2020-11-25 23:14:46 +01:00
Lynne
18a6535b08
hwcontext_vulkan: always attempt to map host memory when transferring
This relies on the fact that host memory is always going to be required
to be aligned to the platform's page size, which means we can adjust
the pointers when we map them to buffers and therefore skip an entire
copy. This has already had extensive testing in libplacebo without
problems, so its safe to use here as well.

Speeds up downloads and uploads on platforms which do not pool their
memory hugely, but less so on platforms that do.

We can pool the buffers ourselves, but that can come as a later patch
if necessary.
2020-11-25 23:14:01 +01:00
Lynne
9cf1811d3d
hwcontext_vulkan: check for memory size before choosing type
It makes allocation a bit more robust in case some weird device with
weird drivers which segments memory in weird ways appears.
2020-11-25 23:06:36 +01:00
Lynne
ff29ca2f1f
hwcontext_vulkan: correctly access the p->extensions bitmask
Its a 64-bit bitfield being put directly into an int.
2020-11-25 23:06:36 +01:00
Lynne
b83e0560f7
hwcontext_vulkan: unify download/upload functions
They were identical, save for variable names and order.
2020-11-25 23:06:35 +01:00
Lynne
b4f9d05301
hwcontext_vulkan: add VkExternalMemoryBufferCreateInfo to imported buffers
Its a validation layer thing.
2020-11-25 23:06:35 +01:00
Lynne
10b3c9b533
hwcontext_vulkan: do not use uninitialized variables on errors in CUDA code 2020-11-25 23:06:35 +01:00
Lynne
993d8d9429
hwcontext_drm: issue DMA_BUF_IOCTL_SYNC when mapping FDs
This improves performance and helps a little when given FDs without
any synchronization fences.
2020-11-25 23:06:34 +01:00
Lynne
4f9ee87253
libavutil: introduce AVFilmGrainParams side data
This patch introduces a new frame side data type AVFilmGrainParams for use
with video codecs which support it.

It can save a lot of memory used for duplicate processed reference frames and
reduce copies when applying film grain during presentation.
2020-11-25 23:06:33 +01:00
Anton Khirnov
800feae5d6 lavu: add missing stddef.h includes for size_t. 2020-11-20 15:20:24 +01:00
Gil Pedersen
7ac1dc2364 avutil/frame: fix potential leaks in av_frame_ref()
Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: James Almer <jamrial@gmail.com>
2020-11-19 10:12:58 -03:00
Gil Pedersen
2b6b19dd9b avutil/frame: use av_buffer_replace() to simplify code
Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Gil Pedersen <git@gpost.dk>
Signed-off-by: James Almer <jamrial@gmail.com>
2020-11-19 10:09:47 -03:00
Timo Rothenpieler
98d3f23598 avutil/hwcontext_cuda: fix edge case with non-even frame heights 2020-11-04 01:36:48 +01:00
Timo Rothenpieler
2f3cb5ccca avutil/hwcontext_cuda: query correct alignment from device 2020-11-04 01:36:39 +01:00
Timo Rothenpieler
d5763edab2 avutil/hwcontext_cuda: increase CUDA frame alignment to 512
At least on Turing, a frame without 512 byte alignment cannot be passed
to cuTexObjectCreate.
2020-11-03 18:17:35 +01:00
Michael Niedermayer
ac8cebd48e avutil/mathematics: Use av_sat_add64() for the last addition in av_add_stable()
Fixes: signed integer overflow: 9223372036854770375 + 5450 cannot be represented in type 'long'
Fixes: 26471/clusterfuzz-testcase-minimized-ffmpeg_dem_MXG_fuzzer-6229617557635072

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-10-25 09:49:21 +01:00
Michael Niedermayer
4e9514e99b avutil/common: Implement av_sat_add64_c() with fewer branches
No benchmark because this is not used in any speed relevant pathes nor is it
used where __builtin_add_overflow is available.
So I do not know how to realistically benchmark it.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-10-24 19:11:12 +02:00
James Almer
979cc0c7cb avutil/pixdesc: add missing FF_API_PSEUDOPAL check
Signed-off-by: James Almer <jamrial@gmail.com>
2020-10-02 00:18:13 -03:00
Anton Khirnov
68918d3b7f lavu/buffer: add a convenience function for replacing buffers
A common pattern e.g. in libavcodec is replacing/updating buffer
references: unref old one, ref new one. This function allows simplifying
such code and avoiding unnecessary refs+unrefs if the references are
already equivalent.
2020-09-28 11:33:35 +02:00
Jan Ekström
d8ce8e8ed3 avutil/pixfmt: improve definition of AVColorRange
As it was brought up that the current documentation leaves things
as specific to YCbCr only, ICtCp and RGB are now mentioned.
Additionally, the specifications on which these definitions of
narrow and full range are defined are mentioned.

This way, the documentation of AVColorRange should now match how
most people seem to read interpret it at this point, and thus
flagging RGB AVFrames as full range is valid not only according to
common sense, but also the enum definition.
2020-09-23 19:14:45 +03:00
Michael Niedermayer
4a02ae49c2 avutil/fixed_dsp: Fix integer overflows in butterflies_fixed_c()
Fixes: signed integer overflow: 0 - -2147483648 cannot be represented in type 'int'
Fixes: 23646/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AAC_FIXED_fuzzer-5480991098667008

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-09-19 00:37:45 +02:00
James Almer
7cc8a2bb0b avutil/cuda_check: add missing dynlink_loader.h include
Fixes make checkheaders

Signed-off-by: James Almer <jamrial@gmail.com>
2020-09-15 19:29:37 -03:00
Marton Balint
837b6eb90e avutil/timecode: add av_timecode_make_smpte_tc_string2
Signed-off-by: Marton Balint <cus@passwd.hu>
2020-09-13 17:51:57 +02:00
Marton Balint
5357401671 avutil/timecode: do not trash bits on invalid av_timecode_get_smpte arguments
The function has no way to return error, so let's clip or calculate modulo.

Signed-off-by: Marton Balint <cus@passwd.hu>
2020-09-13 17:51:57 +02:00
Marton Balint
d0596e0bb0 avutil/timecode: cosmetics on av_timecode_get_smpte
Signed-off-by: Marton Balint <cus@passwd.hu>
2020-09-13 17:51:57 +02:00
Marton Balint
00117e28c1 avutil/timecode: fix av_timecode_get_smpte_from_framenum with 50/60 fps
SMPTE 12M timecode can only count frames up to 39, because the tens-of-frames
value is stored in 2 bit. In order to resolve this 50/60 fps SMPTE timecode is
using the field bit (which is the same bit as the phase correction bit) to
signal the least significant bit of a 50/60 fps timecode. See SMPTE ST
12-1:2014 section 12.1.

Therefore we slightly change the format of the return value of
av_timecode_get_smpte_from_framenum and AV_FRAME_DATA_S12M_TIMECODE and start
using the previously unused Phase Correction bit as Field bit. (As the SMPTE
standard suggests)

We add 50/60 fps support to av_timecode_get_smpte_from_framenum by calling the
recently added av_timecode_get_smpte function in it which already handles this
properly.

This change affects the decklink indev and the DV and MXF muxers. MXF has no
fate test for 50/60fps content, DV does, therefore the changes.

MediaInfo (a recent version) confirms that half-frame timecode must be inserted
to DV. MXFInspect confirms valid timecode insertion to the System Item of MXF
files. For MXF, also see EBU R122.

Note that for DV the field flag is not used because in the HDV specs (SMPTE
370M) it is still defined as biphase mark polarity correction flag. So it
should not matter that the DV muxer overrides the field bit.

Signed-off-by: Marton Balint <cus@passwd.hu>
2020-09-13 17:51:57 +02:00
Mark Thompson
303d252a4b hwcontext_vaapi: Don't require a render node when deriving from DRM
The V4L2 driver does not actually have an associated DRM device at all, so
users work around the requirement by giving libva an unrelated display-only
device instead (which is fine, because it doesn't actually do anything with
that device).  This was broken by bc9b6358fb
forcing a render node, because the display-only device did not have an
associated render node to use.  Fix that by just passing through the
original non-render DRM fd if we can't find a render node.

Reported-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Tested-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
2020-08-31 21:42:14 +01:00
Nicolas George
2b71cd3e0b lavu/buffer: forward av_buffer_realloc() error code.
Fix CID 1457235.
2020-08-21 11:44:30 +02:00
Nicolas George
06f2651204 lavu/avstring: deprecate av_d2str().
It is no longer used in our code base and does not seem
to be used much in other projects.
2020-08-21 11:01:39 +02:00
leozhang
3b7036bc1d avutil/video_enc_params: fix code comment
Reviewed-by: Zhao Zhili <zhilizhao@tencent.com>
Signed-off-by: leozhang <leozhang@qiyi.com>
2020-08-20 17:45:00 +08:00
Jan Ekström
34de0abbe7 avutil/channel_layout: add 22.2 layout
Requires some extraneous top side and bottom front channels to be
defined.

According to STD-B59v2, the defined channel layout is:
- FL
- FR
- FC
- LFE1
- BL
- BR
- FLc
- FRc
- BC
- LFE2
- SiL
- SiR
- TpFL
- TpFR
- TpFC
- TpC
- TpBL
- TpBR
- TpSiL
- TpSiR
- TpBC
- BtFC
- BtFL
- BtFR
2020-08-04 00:17:56 +03:00
Lynne
fe3ea13131
hwcontext_vulkan: remove plane size alignment checks when host importing
The process space is guaranteed to be aligned to the page size, hence we're
never going to map outside of our address space.
There are more optimizations to do with respect to chroma plane alignment and
buffer offsets, but that can be done later.
2020-08-02 22:48:51 +02:00
James Almer
134a48a880 tests/imgutils: test the output of av_image_fill_* functions
Signed-off-by: James Almer <jamrial@gmail.com>
2020-07-30 19:33:09 -03:00
Shiyou Yin
0e0a9ca048 avutil/mips/generic_macros_msa: Fix prob that 'ulw' and 'uld' unsupported by clang.
GCC support these two synthesized instruction, but clang does not yet.
Use machine instruction instead to adapt clang compiler.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-07-30 00:23:45 +02:00
Haihao Xiang
fa3da243e6 hwcontext_vaapi: remove duplicate formats from sw_format list
hwcontext_vaapi maps different VA fourcc to the same pix_fmt for U/V
plane swap cases, however duplicate formats are not expected in sw_format
list when merging formats.

For example:
ffmpeg -loglevel debug -init_hw_device vaapi -filter_hw_device vaapi0 \
-f lavfi -i smptebars -vf \
"hwupload=derive_device=vaapi,scale_vaapi,hwdownload,format=yuv420p" \
-vframes 1 -f null -

Without this fix, an auto scaler is required for the above command
   Duplicate formats in ff_merge_formats detected
   [auto_scaler_0 @ 0x560df58f4550] Setting 'flags' to value 'bicubic'
   [auto_scaler_0 @ 0x560df58f4550] w:iw h:ih flags:'bicubic' interl:0
   [Parsed_hwupload_0 @ 0x560df58f0ec0] auto-inserting filter
   'auto_scaler_0' between the filter 'graph 0 input from stream 0:0' and
   the filter 'Parsed_hwupload_0'

Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
2020-07-27 16:06:30 +01:00
Haihao Xiang
d951eea6fd hwcontext_vaapi: avoid fd leak in vaapi_device_derive 2020-07-27 15:41:32 +01:00