Commit 0d021cc8 authored by Andrey Turkin's avatar Andrey Turkin Committed by Timo Rothenpieler

avcodec/nvenc: rework library load and GPU selection

Use explicit nvenc capability checks instead to determine usable devices
instead of SM versions.
Signed-off-by: 's avatarTimo Rothenpieler <timo@rothenpieler.org>
parent f052ef30
This diff is collapsed.
......@@ -29,7 +29,7 @@
#include "avcodec.h"
#if CONFIG_CUDA
#include <cuda.h>
#include "libavutil/hwcontext_cuda.h"
#else
#if defined(_WIN32)
......@@ -77,17 +77,9 @@ typedef NVENCSTATUS (NVENCAPI *PNVENCODEAPICREATEINSTANCE)(NV_ENCODE_API_FUNCTIO
typedef struct NvencDynLoadFunctions
{
#if !CONFIG_CUDA
#if defined(_WIN32)
HMODULE cuda_lib;
#else
void* cuda_lib;
#endif
#endif
#if defined(_WIN32)
HMODULE nvenc_lib;
#else
void* nvenc_lib;
void *cuda;
#endif
void *nvenc;
PCUINIT cu_init;
PCUDEVICEGETCOUNT cu_device_get_count;
......@@ -100,8 +92,6 @@ typedef struct NvencDynLoadFunctions
NV_ENCODE_API_FUNCTION_LIST nvenc_funcs;
int nvenc_device_count;
CUdevice nvenc_devices[16];
} NvencDynLoadFunctions;
enum {
......@@ -133,6 +123,11 @@ enum {
NVENC_TWO_PASSES = 8,
};
enum {
LIST_DEVICES = -2,
ANY_DEVICE,
};
typedef struct NvencContext
{
AVClass *avclass;
......@@ -173,7 +168,7 @@ typedef struct NvencContext
int rc;
int cbr;
int twopass;
int gpu;
int device;
int flags;
int async_depth;
} NvencContext;
......
......@@ -79,7 +79,9 @@ static const AVOption options[] = {
{ "surfaces", "Number of concurrent surfaces", OFFSET(nb_surfaces), AV_OPT_TYPE_INT, { .i64 = 32 }, 0, INT_MAX, VE },
{ "cbr", "Use cbr encoding mode", OFFSET(cbr), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
{ "2pass", "Use 2pass encoding mode", OFFSET(twopass), AV_OPT_TYPE_BOOL, { .i64 = -1 }, -1, 1, VE },
{ "gpu", "Selects which NVENC capable GPU to use. First GPU is 0, second is 1, and so on.", OFFSET(gpu), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE },
{ "gpu", "Selects which NVENC capable GPU to use. First GPU is 0, second is 1, and so on.", OFFSET(device), AV_OPT_TYPE_INT, { .i64 = ANY_DEVICE }, -2, INT_MAX, VE, "gpu" },
{ "any", "Pick the first device available", 0, AV_OPT_TYPE_CONST, { .i64 = ANY_DEVICE }, 0, 0, VE, "gpu" },
{ "list", "List the available devices", 0, AV_OPT_TYPE_CONST, { .i64 = LIST_DEVICES }, 0, 0, VE, "gpu" },
{ "delay", "Delay frame output by the given amount of frames", OFFSET(async_depth), AV_OPT_TYPE_INT, { .i64 = INT_MAX }, 0, INT_MAX, VE },
{ NULL }
};
......
......@@ -76,7 +76,9 @@ static const AVOption options[] = {
{ "surfaces", "Number of concurrent surfaces", OFFSET(nb_surfaces), AV_OPT_TYPE_INT, { .i64 = 32 }, 0, INT_MAX, VE },
{ "cbr", "Use cbr encoding mode", OFFSET(cbr), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
{ "2pass", "Use 2pass encoding mode", OFFSET(twopass), AV_OPT_TYPE_BOOL, { .i64 = -1 }, -1, 1, VE },
{ "gpu", "Selects which NVENC capable GPU to use. First GPU is 0, second is 1, and so on.", OFFSET(gpu), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE },
{ "gpu", "Selects which NVENC capable GPU to use. First GPU is 0, second is 1, and so on.", OFFSET(device), AV_OPT_TYPE_INT, { .i64 = ANY_DEVICE }, -2, INT_MAX, VE },
{ "any", "Pick the first device available", 0, AV_OPT_TYPE_CONST, { .i64 = ANY_DEVICE }, 0, 0, VE, "device" },
{ "list", "List the available devices", 0, AV_OPT_TYPE_CONST, { .i64 = LIST_DEVICES }, 0, 0, VE, "device" },
{ "delay", "Delay frame output by the given amount of frames", OFFSET(async_depth), AV_OPT_TYPE_INT, { .i64 = INT_MAX }, 0, INT_MAX, VE },
{ NULL }
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment