[FFmpeg-cvslog] hwcontext_cuda: implement frames_get_constraints
wm4
git at videolan.org
Tue Sep 26 22:30:06 EEST 2017
ffmpeg | branch: master | wm4 <nfxjfg at googlemail.com> | Mon Jan 16 16:42:17 2017 +0100| [3ad825793a43253154bed05827f27425fc0757df] | committer: Anton Khirnov
hwcontext_cuda: implement frames_get_constraints
Copied and modified from hwcontext_qsv.c.
Signed-off-by: Anton Khirnov <anton at khirnov.net>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3ad825793a43253154bed05827f27425fc0757df
---
libavutil/hwcontext_cuda.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/libavutil/hwcontext_cuda.c b/libavutil/hwcontext_cuda.c
index 260783426a..fc9b8b4298 100644
--- a/libavutil/hwcontext_cuda.c
+++ b/libavutil/hwcontext_cuda.c
@@ -37,6 +37,31 @@ static const enum AVPixelFormat supported_formats[] = {
AV_PIX_FMT_YUV444P16,
};
+static int cuda_frames_get_constraints(AVHWDeviceContext *ctx,
+ const void *hwconfig,
+ AVHWFramesConstraints *constraints)
+{
+ int i;
+
+ constraints->valid_sw_formats = av_malloc_array(FF_ARRAY_ELEMS(supported_formats) + 1,
+ sizeof(*constraints->valid_sw_formats));
+ if (!constraints->valid_sw_formats)
+ return AVERROR(ENOMEM);
+
+ for (i = 0; i < FF_ARRAY_ELEMS(supported_formats); i++)
+ constraints->valid_sw_formats[i] = supported_formats[i];
+ constraints->valid_sw_formats[FF_ARRAY_ELEMS(supported_formats)] = AV_PIX_FMT_NONE;
+
+ constraints->valid_hw_formats = av_malloc_array(2, sizeof(*constraints->valid_hw_formats));
+ if (!constraints->valid_hw_formats)
+ return AVERROR(ENOMEM);
+
+ constraints->valid_hw_formats[0] = AV_PIX_FMT_CUDA;
+ constraints->valid_hw_formats[1] = AV_PIX_FMT_NONE;
+
+ return 0;
+}
+
static void cuda_buffer_free(void *opaque, uint8_t *data)
{
AVHWFramesContext *ctx = opaque;
@@ -326,6 +351,7 @@ const HWContextType ff_hwcontext_type_cuda = {
.frames_priv_size = sizeof(CUDAFramesContext),
.device_create = cuda_device_create,
+ .frames_get_constraints = cuda_frames_get_constraints,
.frames_init = cuda_frames_init,
.frames_get_buffer = cuda_get_buffer,
.transfer_get_formats = cuda_transfer_get_formats,
More information about the ffmpeg-cvslog
mailing list