Commit Graph

42 Commits

Author SHA1 Message Date
Andreas Rheinhardt 3e669b24e2 avutil/hwcontext: Allocate AVHWFramesCtx jointly with its internals
This is possible because the lifetime of these structures coincide.
It has the advantage of allowing to remove AVHWFramesInternal
from the public header; given that AVHWFramesInternal.priv is no more,
most accesses to AVHWFramesInternal are no more; indeed, the only
field accessed of it outside of hwcontext.c is the internal frame pool,
making this commit very simple.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-07 08:53:31 -03:00
Andreas Rheinhardt ac7e72972c avutil/hwcontext_cuda: Allocate public and internal device ctx jointly
Reviewed-by: Timo Rothenpieler <timo@rothenpieler.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-01 18:32:40 +01:00
Andreas Rheinhardt 8d277de009 avutil/hwcontext_cuda: Don't use AVHWFramesInternal.priv
Use AVHWFramesContext.hwctx instead.
This simplifies accesses to VDPAUFramesContext as one no longer has
to go through AVHWFramesInternal.

Tested-by: Timo Rothenpieler <timo@rothenpieler.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-01 18:32:01 +01:00
Roman Arzumanyan f904e60c32 libavutil/hwcontext_cuda: don't destroy external context when using current CUDA context
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2023-09-29 19:42:11 +02:00
Roman Arzumanyan 05f8b2ca0f avutil/hwcontext_cuda: add option to use current device context
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2023-09-28 19:23:51 +02:00
Philip Langdale 41be6a5593 lavu/hwcontext_cuda: declare support for rgb32/bgr32
nvenc declares support for these formats, but if hwcontext_cuda doesn't
do that as well, then it's not possible to hwupload them for use in a
possible cuda pipeline before encoding.
2023-06-15 12:29:52 -07:00
James Almer 84fe53f6e1 avutil/hwcontext_cuda: fix compilation without Vulkan after last commit
Signed-off-by: James Almer <jamrial@gmail.com>
2022-11-12 15:54:53 -03:00
James Almer f4aa5c275f avutil/hwcontext_cuda: fix mixed declarations and code warning
Signed-off-by: James Almer <jamrial@gmail.com>
2022-11-12 15:52:10 -03:00
Timo Rothenpieler 2de6cd4ba4 avutil/hwcontext_cuda: return more useful error codes from init functions 2021-11-22 23:03:21 +01:00
Timo Rothenpieler b1f1de0844 avutil/hwcontext_cuda: add option to use primary device context 2021-11-22 23:03:21 +01:00
Lynne 4a6581e968 hwcontext_vulkan: dynamically load functions
This patch allows for alternative loader implementations.
2021-04-30 00:08:37 +02:00
Andreas Rheinhardt ef6a9e5e31 avutil/buffer: Switch AVBuffer API to size_t
Announced in 14040a1d91.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-04-27 10:43:13 -03:00
James Almer e36eb94048 avutil: use the buffer_size_t typedef where required
Signed-off-by: James Almer <jamrial@gmail.com>
2021-03-10 20:26:37 -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
Lynne 2e08b39444
hwcontext: add av_hwdevice_ctx_create_derived_opts
This allows for users who derive devices to set options for the
new device context they derive.
The main use case of this is to allow users to enable extensions
(such as surface drawing extensions) in Vulkan while deriving from
the device their frames are on. That way, users don't need to write
any initialization code themselves, since the Vulkan spec invalidates
mixing instances, physical devices and active devices.
Apart from Vulkan, other hwcontexts ignore the opts argument since they
don't support options at all (or in VAAPI and OpenCL's case, options are
currently only used for device selection, which device_derive overrides).
2020-05-23 19:07:26 +01:00
Timo Rothenpieler 30b28f9a83 avutil/hwcontext_cuda: Only handle CUDA hardware frames 2020-04-06 19:33:01 +02:00
Timo Rothenpieler d9a37af070 avutil/hwcontext_cuda: combine transfer functions
Gets rid of some mostly duplicated code and adds the ability to do
hardware to hardware transfers.
2020-03-19 17:38:36 +01:00
Yaroslav Pogrebnyak 08d46cb586 avutil/hwcontext_cuda: add YUVA420P pixel format
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2020-03-19 16:38:08 +01:00
Philip Langdale 7f149b0452 lavu/hwcontext_cuda: refactor context initialisation
There's enough going on here now that it should not be duplicated
between cuda_device_create and cuda_device_derive.
2020-02-04 23:19:48 +00:00
Lynne a88449ffb2 lavu: add Vulkan hwcontext code
This commit adds the necessary code to initialize and use a Vulkan device
within the hwcontext libavutil framework.
Currently direct mapping to VAAPI and DRM frames is functional, and
transfers to CUDA and native frames are supported.

Lets hope the future Vulkan video decode extension fits well within this
framework.
2020-02-04 23:19:48 +00:00
Oleg Dobkin 32ba563cfc avutil/hwcontext_cuda: allow using primary CUDA device context
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2019-11-26 16:24:40 +01:00
Philip Langdale 52d8f35b14 avutil/hcontext_cuda: Remove unnecessary stream synchronisation
Similarly to the previous changes, we don't need to synchronise
after a memcpy to device memory. On the other hand, we need to
keep synchronising after a copy to host memory, otherwise there's
no guarantee that subsequent host reads will return valid data.
2019-03-30 10:56:49 -07:00
Philip Langdale 19d3d0c057 avutil/hwcontext_cuda: Define and use common CHECK_CU()
We have a pattern of wrapping CUDA calls to print errors and
normalise return values that is used in a couple of places. To
avoid duplication and increase consistency, let's put the wrapper
implementation in a shared place and use it everywhere.

Affects:

* avcodec/cuviddec
* avcodec/nvdec
* avcodec/nvenc
* avfilter/vf_scale_cuda
* avfilter/vf_scale_npp
* avfilter/vf_thumbnail_cuda
* avfilter/vf_transpose_npp
* avfilter/vf_yadif_cuda
2018-11-14 17:39:42 -08:00
Marton Balint 1b2471039b avutil/hwcontext_cuda: fix YUV420P cuda_get_buffer
Regression since ece068a771.

Signed-off-by: Marton Balint <cus@passwd.hu>
2018-05-15 22:18:58 +02:00
Timo Rothenpieler ece068a771 avutil/hwcontext_cuda: use generic size and pointer assignment functions 2018-05-10 00:34:22 +02:00
Timo Rothenpieler 41a18982d0 avutil/hwcontext_cuda: add support for nvenc rgb formats 2018-05-10 00:34:22 +02:00
Timo Rothenpieler 9b82e333b7 avutil/hwcontext_cuda: explicitly synchronize cuMemcpy calls 2018-05-10 00:34:22 +02:00
Timo Rothenpieler c855683427 avutil/hwcontext_cuda: add CUstream in cuda hwctx 2018-05-10 00:34:22 +02:00
Mark Thompson 1dc483a6f2 compat/cuda: Pass a logging context to load functions
Reviewed-by: Timo Rothenpieler <timo@rothenpieler.org>
2017-11-20 15:47:05 +00:00
Yogender Gupta 3407d8118c hwcontext_cuda : Support YUV444P16 format
Signed-off-by: Philip Langdale <philipl@overt.org>
2017-08-03 15:25:35 -07:00
wm4 c16fe1432d hwcontext_cuda: implement frames_get_constraints
Copied and modified from hwcontext_qsv.c.
2017-01-23 16:21:18 +01:00
Timo Rothenpieler 52773a2c68 avutil/hwcontext_cuda: check for missing pixel format 2016-11-30 12:36:23 +01:00
Philip Langdale 8d6c358ea8 libavutil/hwcontext_cuda: Support P010 and P016 formats
CUVID is now capable of returning 10bit and 12bit decoded content
in P010/P016. Let's support transfering those formats.
2016-11-22 10:09:14 -08:00
Timo Rothenpieler e6464a44ed avutil/hwcontext_cuda: use dynamically loaded CUDA 2016-11-22 10:34:27 +01:00
Timo Rothenpieler a0d7ce1406 avutil/hwcontext_cuda: align allocated frames 2016-10-03 15:49:22 +02:00
Timo Rothenpieler 97e7f03d35 avutil/hwcontext_cuda: use proper synchronization flag 2016-09-29 22:58:34 +02:00
Hendrik Leppkes c5a0c16850 Merge commit '2e219b491bcc0845248345fdad31231b081e06d1'
* commit '2e219b491bcc0845248345fdad31231b081e06d1':
  hwcontext_cuda: implement device creation

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2016-06-26 15:25:12 +02:00
Anton Khirnov 2e219b491b hwcontext_cuda: implement device creation 2016-05-26 15:40:33 +02:00
Derek Buitenhuis 6992276aca Merge commit 'ad884d100259e55cb51a4239cd8a4fd5154c2073'
* commit 'ad884d100259e55cb51a4239cd8a4fd5154c2073':
  hwcontext: add a CUDA implementation

Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2016-02-24 15:23:16 +00:00
Anton Khirnov ad884d1002 hwcontext: add a CUDA implementation 2016-02-14 22:08:33 +01:00