mirror of https://github.com/FFmpeg/FFmpeg.git
* commit 'b08caa87c35a768ec0abb16b1e99c3a85f1df28e': nvenc: H264 and HEVC encoders Conflicts: Changelog configure libavcodec/Makefile libavcodec/version.h This implementation is merged under the name nvenc_b* Merged-by: Michael Niedermayer <michaelni@gmx.at>pull/136/head
commit
d8bbb99c51
9 changed files with 1512 additions and 6 deletions
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,135 @@ |
||||
/*
|
||||
* This file is part of FFmpeg. |
||||
* |
||||
* FFmpeg is free software; you can redistribute it and/or |
||||
* modify it under the terms of the GNU Lesser General Public |
||||
* License as published by the Free Software Foundation; either |
||||
* version 2.1 of the License, or (at your option) any later version. |
||||
* |
||||
* FFmpeg is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
||||
* Lesser General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU Lesser General Public |
||||
* License along with FFmpeg; if not, write to the Free Software |
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
||||
*/ |
||||
|
||||
#ifndef AVCODEC_NVENC_H |
||||
#define AVCODEC_NVENC_H |
||||
|
||||
#include <cuda.h> |
||||
#include <nvEncodeAPI.h> |
||||
|
||||
#include "libavutil/fifo.h" |
||||
#include "libavutil/opt.h" |
||||
|
||||
#include "avcodec.h" |
||||
|
||||
typedef struct NVENCInputSurface { |
||||
NV_ENC_INPUT_PTR in; |
||||
NV_ENC_BUFFER_FORMAT format; |
||||
int locked; |
||||
} NVENCInputSurface; |
||||
|
||||
typedef struct NVENCOutputSurface { |
||||
NV_ENC_OUTPUT_PTR out; |
||||
NVENCInputSurface *in; |
||||
int busy; |
||||
} NVENCOutputSurface; |
||||
|
||||
typedef CUresult(CUDAAPI *PCUINIT)(unsigned int Flags); |
||||
typedef CUresult(CUDAAPI *PCUDEVICEGETCOUNT)(int *count); |
||||
typedef CUresult(CUDAAPI *PCUDEVICEGET)(CUdevice *device, int ordinal); |
||||
typedef CUresult(CUDAAPI *PCUDEVICEGETNAME)(char *name, int len, CUdevice dev); |
||||
typedef CUresult(CUDAAPI *PCUDEVICECOMPUTECAPABILITY)(int *major, int *minor, CUdevice dev); |
||||
typedef CUresult(CUDAAPI *PCUCTXCREATE)(CUcontext *pctx, unsigned int flags, CUdevice dev); |
||||
typedef CUresult(CUDAAPI *PCUCTXPOPCURRENT)(CUcontext *pctx); |
||||
typedef CUresult(CUDAAPI *PCUCTXDESTROY)(CUcontext ctx); |
||||
|
||||
typedef NVENCSTATUS (NVENCAPI *PNVENCODEAPICREATEINSTANCE)(NV_ENCODE_API_FUNCTION_LIST *functionList); |
||||
|
||||
typedef struct NVENCLibraryContext |
||||
{ |
||||
void *cuda; |
||||
void *nvenc; |
||||
|
||||
PCUINIT cu_init; |
||||
PCUDEVICEGETCOUNT cu_device_get_count; |
||||
PCUDEVICEGET cu_device_get; |
||||
PCUDEVICEGETNAME cu_device_get_name; |
||||
PCUDEVICECOMPUTECAPABILITY cu_device_compute_capability; |
||||
PCUCTXCREATE cu_ctx_create; |
||||
PCUCTXPOPCURRENT cu_ctx_pop_current; |
||||
PCUCTXDESTROY cu_ctx_destroy; |
||||
|
||||
NV_ENCODE_API_FUNCTION_LIST nvenc_funcs; |
||||
} NVENCLibraryContext; |
||||
|
||||
enum { |
||||
PRESET_DEFAULT, |
||||
PRESET_HP, |
||||
PRESET_HQ, |
||||
PRESET_BD , |
||||
PRESET_LOW_LATENCY_DEFAULT , |
||||
PRESET_LOW_LATENCY_HQ , |
||||
PRESET_LOW_LATENCY_HP, |
||||
PRESET_LOSSLESS_DEFAULT, |
||||
PRESET_LOSSLESS_HP, |
||||
}; |
||||
|
||||
enum { |
||||
NV_ENC_H264_PROFILE_BASELINE, |
||||
NV_ENC_H264_PROFILE_MAIN, |
||||
NV_ENC_H264_PROFILE_HIGH, |
||||
NV_ENC_H264_PROFILE_HIGH_444, |
||||
NV_ENC_H264_PROFILE_CONSTRAINED_HIGH, |
||||
}; |
||||
|
||||
enum { |
||||
NVENC_LOWLATENCY = 1, |
||||
NVENC_LOSSLESS, |
||||
}; |
||||
|
||||
enum { |
||||
LIST_DEVICES = -2, |
||||
ANY_DEVICE, |
||||
}; |
||||
|
||||
typedef struct NVENCContext { |
||||
AVClass *class; |
||||
NVENCLibraryContext nvel; |
||||
|
||||
NV_ENC_INITIALIZE_PARAMS params; |
||||
NV_ENC_CONFIG config; |
||||
|
||||
CUcontext cu_context; |
||||
|
||||
int nb_surfaces; |
||||
NVENCInputSurface *in; |
||||
NVENCOutputSurface *out; |
||||
AVFifoBuffer *timestamps; |
||||
AVFifoBuffer *pending, *ready; |
||||
|
||||
int64_t last_dts; |
||||
|
||||
void *nvenc_ctx; |
||||
|
||||
int preset; |
||||
int profile; |
||||
int level; |
||||
int tier; |
||||
int rc; |
||||
int device; |
||||
int flags; |
||||
} NVENCContext; |
||||
|
||||
int ff_nvenc_encode_init(AVCodecContext *avctx); |
||||
|
||||
int ff_nvenc_encode_close(AVCodecContext *avctx); |
||||
|
||||
int ff_nvenc_encode_frame(AVCodecContext *avctx, AVPacket *pkt, |
||||
const AVFrame *frame, int *got_packet); |
||||
|
||||
#endif /* AVCODEC_NVENC_H */ |
@ -0,0 +1,110 @@ |
||||
/*
|
||||
* This file is part of FFmpeg. |
||||
* |
||||
* FFmpeg is free software; you can redistribute it and/or |
||||
* modify it under the terms of the GNU Lesser General Public |
||||
* License as published by the Free Software Foundation; either |
||||
* version 2.1 of the License, or (at your option) any later version. |
||||
* |
||||
* FFmpeg is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
||||
* Lesser General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU Lesser General Public |
||||
* License along with FFmpeg; if not, write to the Free Software |
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
||||
*/ |
||||
|
||||
#include "libavutil/internal.h" |
||||
#include "libavutil/opt.h" |
||||
|
||||
#include "avcodec.h" |
||||
#include "internal.h" |
||||
|
||||
#include "nvenc.h" |
||||
|
||||
#define OFFSET(x) offsetof(NVENCContext, x) |
||||
#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM |
||||
static const AVOption options[] = { |
||||
{ "preset", "Set the encoding preset", OFFSET(preset), AV_OPT_TYPE_INT, { .i64 = PRESET_HQ }, PRESET_DEFAULT, PRESET_LOSSLESS_HP, VE, "preset" }, |
||||
{ "default", "", 0, AV_OPT_TYPE_CONST, { .i64 = PRESET_DEFAULT }, 0, 0, VE, "preset" }, |
||||
{ "hp", "", 0, AV_OPT_TYPE_CONST, { .i64 = PRESET_HP }, 0, 0, VE, "preset" }, |
||||
{ "hq", "", 0, AV_OPT_TYPE_CONST, { .i64 = PRESET_HQ }, 0, 0, VE, "preset" }, |
||||
{ "bd", "", 0, AV_OPT_TYPE_CONST, { .i64 = PRESET_BD }, 0, 0, VE, "preset" }, |
||||
{ "ll", "low latency", 0, AV_OPT_TYPE_CONST, { .i64 = PRESET_LOW_LATENCY_DEFAULT }, 0, 0, VE, "preset" }, |
||||
{ "llhq", "low latency hq", 0, AV_OPT_TYPE_CONST, { .i64 = PRESET_LOW_LATENCY_HQ }, 0, 0, VE, "preset" }, |
||||
{ "llhp", "low latency hp", 0, AV_OPT_TYPE_CONST, { .i64 = PRESET_LOW_LATENCY_HP }, 0, 0, VE, "preset" }, |
||||
{ "profile", "Set the encoding profile", OFFSET(profile), AV_OPT_TYPE_INT, { .i64 = NV_ENC_H264_PROFILE_HIGH }, NV_ENC_H264_PROFILE_BASELINE, NV_ENC_H264_PROFILE_CONSTRAINED_HIGH, VE, "profile" }, |
||||
{ "baseline", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_H264_PROFILE_BASELINE }, 0, 0, VE, "profile" }, |
||||
{ "main", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_H264_PROFILE_MAIN }, 0, 0, VE, "profile" }, |
||||
{ "high", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_H264_PROFILE_HIGH }, 0, 0, VE, "profile" }, |
||||
{ "high_444", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_H264_PROFILE_HIGH_444 }, 0, 0, VE, "profile" }, |
||||
{ "constrained_high", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_H264_PROFILE_CONSTRAINED_HIGH }, 0, 0, VE, "profile" }, |
||||
{ "level", "Set the encoding level restriction", OFFSET(level), AV_OPT_TYPE_INT, { .i64 = NV_ENC_LEVEL_AUTOSELECT }, NV_ENC_LEVEL_AUTOSELECT, NV_ENC_LEVEL_H264_51, VE, "level" }, |
||||
{ "1.0", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LEVEL_H264_1 }, 0, 0, VE, "level" }, |
||||
{ "1.b", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LEVEL_H264_1b }, 0, 0, VE, "level" }, |
||||
{ "1.1", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LEVEL_H264_11 }, 0, 0, VE, "level" }, |
||||
{ "1.2", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LEVEL_H264_12 }, 0, 0, VE, "level" }, |
||||
{ "1.3", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LEVEL_H264_13 }, 0, 0, VE, "level" }, |
||||
{ "2.0", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LEVEL_H264_2 }, 0, 0, VE, "level" }, |
||||
{ "2.1", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LEVEL_H264_21 }, 0, 0, VE, "level" }, |
||||
{ "2.2", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LEVEL_H264_22 }, 0, 0, VE, "level" }, |
||||
{ "3.0", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LEVEL_H264_3 }, 0, 0, VE, "level" }, |
||||
{ "3.1", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LEVEL_H264_31 }, 0, 0, VE, "level" }, |
||||
{ "3.2", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LEVEL_H264_32 }, 0, 0, VE, "level" }, |
||||
{ "4.0", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LEVEL_H264_4 }, 0, 0, VE, "level" }, |
||||
{ "4.1", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LEVEL_H264_41 }, 0, 0, VE, "level" }, |
||||
{ "4.2", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LEVEL_H264_42 }, 0, 0, VE, "level" }, |
||||
{ "5.0", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LEVEL_H264_5 }, 0, 0, VE, "level" }, |
||||
{ "5.1", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LEVEL_H264_51 }, 0, 0, VE, "level" }, |
||||
{ "rc", "Override the preset rate-control", OFFSET(rc), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 0, VE }, |
||||
{ "constqp", "Constant QP mode", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_PARAMS_RC_CONSTQP }, 0, 0, VE, "rc" }, |
||||
{ "vbr", "Variable bitrate mode", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_PARAMS_RC_VBR }, 0, 0, VE, "rc" }, |
||||
{ "cbr", "Constant bitrate mode", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_PARAMS_RC_CBR }, 0, 0, VE, "rc" }, |
||||
{ "vbr_minqp", "Variable bitrate mode with MinQP", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_PARAMS_RC_VBR_MINQP }, 0, 0, VE, "rc" }, |
||||
{ "ll_2pass_quality", "Multi-pass optimized for image quality (only for low-latency presets)", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_PARAMS_RC_2_PASS_QUALITY }, 0, 0, VE, "rc" }, |
||||
{ "ll_2pass_size", "Multi-pass optimized for constant frame size (only for low-latency presets)", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_PARAMS_RC_2_PASS_FRAMESIZE_CAP }, 0, 0, VE, "rc" }, |
||||
{ "vbr_2pass", "Multi-pass variable bitrate mode", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_PARAMS_RC_2_PASS_VBR }, 0, 0, VE, "rc" }, |
||||
{ "surfaces", "Number of concurrent surfaces", OFFSET(nb_surfaces), AV_OPT_TYPE_INT, { .i64 = 32 }, 0, INT_MAX, VE }, |
||||
{ "device", "Select a specific NVENC device", OFFSET(device), AV_OPT_TYPE_INT, { .i64 = -1 }, -2, INT_MAX, VE, "device" }, |
||||
{ "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" }, |
||||
{ NULL } |
||||
}; |
||||
|
||||
static const AVClass nvenc_hevc_class = { |
||||
.class_name = "nvenc_h264", |
||||
.item_name = av_default_item_name, |
||||
.option = options, |
||||
.version = LIBAVUTIL_VERSION_INT, |
||||
}; |
||||
|
||||
static const AVCodecDefault defaults[] = { |
||||
{ "b", "0" }, |
||||
{ "qmin", "-1" }, |
||||
{ "qmax", "-1" }, |
||||
{ "qdiff", "-1" }, |
||||
{ "qblur", "-1" }, |
||||
{ "qcomp", "-1" }, |
||||
{ NULL }, |
||||
}; |
||||
|
||||
AVCodec ff_h264_nvenc_encoder = { |
||||
.name = "nvenc_h264", |
||||
.long_name = NULL_IF_CONFIG_SMALL("NVIDIA NVENC H264 encoder"), |
||||
.type = AVMEDIA_TYPE_VIDEO, |
||||
.id = AV_CODEC_ID_H264, |
||||
.init = ff_nvenc_encode_init, |
||||
.encode2 = ff_nvenc_encode_frame, |
||||
.close = ff_nvenc_encode_close, |
||||
.priv_data_size = sizeof(NVENCContext), |
||||
.priv_class = &nvenc_hevc_class, |
||||
.defaults = defaults, |
||||
.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12, |
||||
AV_PIX_FMT_YUV420P, |
||||
AV_PIX_FMT_YUV444P, |
||||
AV_PIX_FMT_NONE }, |
||||
.capabilities = CODEC_CAP_DELAY, |
||||
.caps_internal = FF_CODEC_CAP_INIT_CLEANUP, |
||||
}; |
@ -0,0 +1,108 @@ |
||||
/*
|
||||
* This file is part of FFmpeg. |
||||
* |
||||
* FFmpeg is free software; you can redistribute it and/or |
||||
* modify it under the terms of the GNU Lesser General Public |
||||
* License as published by the Free Software Foundation; either |
||||
* version 2.1 of the License, or (at your option) any later version. |
||||
* |
||||
* FFmpeg is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
||||
* Lesser General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU Lesser General Public |
||||
* License along with FFmpeg; if not, write to the Free Software |
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
||||
*/ |
||||
|
||||
#include "libavutil/internal.h" |
||||
#include "libavutil/opt.h" |
||||
|
||||
#include "avcodec.h" |
||||
#include "internal.h" |
||||
|
||||
#include "nvenc.h" |
||||
|
||||
#define OFFSET(x) offsetof(NVENCContext, x) |
||||
#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM |
||||
static const AVOption options[] = { |
||||
{ "preset", "Set the encoding preset", OFFSET(preset), AV_OPT_TYPE_INT, { .i64 = PRESET_HQ }, PRESET_DEFAULT, PRESET_LOSSLESS_HP, VE, "preset" }, |
||||
{ "default", "", 0, AV_OPT_TYPE_CONST, { .i64 = PRESET_DEFAULT }, 0, 0, VE, "preset" }, |
||||
{ "hp", "", 0, AV_OPT_TYPE_CONST, { .i64 = PRESET_HP }, 0, 0, VE, "preset" }, |
||||
{ "hq", "", 0, AV_OPT_TYPE_CONST, { .i64 = PRESET_HQ }, 0, 0, VE, "preset" }, |
||||
{ "bd", "", 0, AV_OPT_TYPE_CONST, { .i64 = PRESET_BD }, 0, 0, VE, "preset" }, |
||||
{ "ll", "low latency", 0, AV_OPT_TYPE_CONST, { .i64 = PRESET_LOW_LATENCY_DEFAULT }, 0, 0, VE, "preset" }, |
||||
{ "llhq", "low latency hq", 0, AV_OPT_TYPE_CONST, { .i64 = PRESET_LOW_LATENCY_HQ }, 0, 0, VE, "preset" }, |
||||
{ "llhp", "low latency hp", 0, AV_OPT_TYPE_CONST, { .i64 = PRESET_LOW_LATENCY_HP }, 0, 0, VE, "preset" }, |
||||
{ "lossless", "lossless", 0, AV_OPT_TYPE_CONST, { .i64 = PRESET_LOSSLESS_DEFAULT }, 0, 0, VE, "preset" }, |
||||
{ "losslesshp", "lossless hp", 0, AV_OPT_TYPE_CONST, { .i64 = PRESET_LOSSLESS_HP }, 0, 0, VE, "preset" }, |
||||
{ "profile", "Set the encoding profile", OFFSET(profile), AV_OPT_TYPE_INT, { .i64 = FF_PROFILE_HEVC_MAIN }, FF_PROFILE_HEVC_MAIN, FF_PROFILE_HEVC_MAIN, VE, "profile" }, |
||||
{ "high", "", 0, AV_OPT_TYPE_CONST, { .i64 = FF_PROFILE_HEVC_MAIN }, 0, 0, VE, "profile" }, |
||||
{ "level", "Set the encoding level restriction", OFFSET(level), AV_OPT_TYPE_INT, { .i64 = NV_ENC_LEVEL_AUTOSELECT }, NV_ENC_LEVEL_AUTOSELECT, NV_ENC_LEVEL_HEVC_62, VE, "level" }, |
||||
{ "1.0", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LEVEL_HEVC_1 }, 0, 0, VE, "level" }, |
||||
{ "2.0", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LEVEL_HEVC_2 }, 0, 0, VE, "level" }, |
||||
{ "2.1", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LEVEL_HEVC_21 }, 0, 0, VE, "level" }, |
||||
{ "3.0", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LEVEL_HEVC_3 }, 0, 0, VE, "level" }, |
||||
{ "3.1", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LEVEL_HEVC_31 }, 0, 0, VE, "level" }, |
||||
{ "4.0", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LEVEL_HEVC_4 }, 0, 0, VE, "level" }, |
||||
{ "4.1", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LEVEL_HEVC_41 }, 0, 0, VE, "level" }, |
||||
{ "5.0", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LEVEL_HEVC_5 }, 0, 0, VE, "level" }, |
||||
{ "5.1", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LEVEL_HEVC_51 }, 0, 0, VE, "level" }, |
||||
{ "5.2", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LEVEL_HEVC_52 }, 0, 0, VE, "level" }, |
||||
{ "6.0", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LEVEL_HEVC_6 }, 0, 0, VE, "level" }, |
||||
{ "6.1", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LEVEL_HEVC_61 }, 0, 0, VE, "level" }, |
||||
{ "6.2", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LEVEL_HEVC_62 }, 0, 0, VE, "level" }, |
||||
{ "tier", "Set the encoding tier", OFFSET(tier), AV_OPT_TYPE_INT, { .i64 = NV_ENC_TIER_HEVC_MAIN }, NV_ENC_TIER_HEVC_MAIN, NV_ENC_TIER_HEVC_HIGH, VE, "tier"}, |
||||
{ "main", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_TIER_HEVC_MAIN }, 0, 0, VE, "tier" }, |
||||
{ "high", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_TIER_HEVC_HIGH }, 0, 0, VE, "tier" }, |
||||
{ "rc", "Override the preset rate-control", OFFSET(rc), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 0, VE, "rc" }, |
||||
{ "constqp", "Constant QP mode", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_PARAMS_RC_CONSTQP }, 0, 0, VE, "rc" }, |
||||
{ "vbr", "Variable bitrate mode", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_PARAMS_RC_VBR }, 0, 0, VE, "rc" }, |
||||
{ "cbr", "Constant bitrate mode", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_PARAMS_RC_CBR }, 0, 0, VE, "rc" }, |
||||
{ "vbr_minqp", "Variable bitrate mode with MinQP", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_PARAMS_RC_VBR_MINQP }, 0, 0, VE, "rc" }, |
||||
{ "ll_2pass_quality", "Multi-pass optimized for image quality (only for low-latency presets)", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_PARAMS_RC_2_PASS_QUALITY }, 0, 0, VE, "rc" }, |
||||
{ "ll_2pass_size", "Multi-pass optimized for constant frame size (only for low-latency presets)", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_PARAMS_RC_2_PASS_FRAMESIZE_CAP }, 0, 0, VE, "rc" }, |
||||
{ "vbr_2pass", "Multi-pass variable bitrate mode", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_PARAMS_RC_2_PASS_VBR }, 0, 0, VE, "rc" }, |
||||
{ "surfaces", "Number of concurrent surfaces", OFFSET(nb_surfaces), AV_OPT_TYPE_INT, { .i64 = 32 }, 0, INT_MAX, VE }, |
||||
{ "device", "Select a specific NVENC device", OFFSET(device), AV_OPT_TYPE_INT, { .i64 = -1 }, -2, INT_MAX, VE, "device" }, |
||||
{ "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" }, |
||||
{ NULL } |
||||
}; |
||||
|
||||
static const AVClass nvenc_hevc_class = { |
||||
.class_name = "nvenc_hevc", |
||||
.item_name = av_default_item_name, |
||||
.option = options, |
||||
.version = LIBAVUTIL_VERSION_INT, |
||||
}; |
||||
|
||||
static const AVCodecDefault defaults[] = { |
||||
{ "b", "0" }, |
||||
{ "qmin", "-1" }, |
||||
{ "qmax", "-1" }, |
||||
{ "qdiff", "-1" }, |
||||
{ "qblur", "-1" }, |
||||
{ "qcomp", "-1" }, |
||||
{ NULL }, |
||||
}; |
||||
|
||||
AVCodec ff_hevc_nvenc_encoder = { |
||||
.name = "nvenc_hevc", |
||||
.long_name = NULL_IF_CONFIG_SMALL("NVIDIA NVENC HEVC encoder"), |
||||
.type = AVMEDIA_TYPE_VIDEO, |
||||
.id = AV_CODEC_ID_HEVC, |
||||
.init = ff_nvenc_encode_init, |
||||
.encode2 = ff_nvenc_encode_frame, |
||||
.close = ff_nvenc_encode_close, |
||||
.priv_data_size = sizeof(NVENCContext), |
||||
.priv_class = &nvenc_hevc_class, |
||||
.defaults = defaults, |
||||
.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12, |
||||
AV_PIX_FMT_YUV420P, |
||||
AV_PIX_FMT_YUV444P, |
||||
AV_PIX_FMT_NONE }, |
||||
.capabilities = CODEC_CAP_DELAY, |
||||
.caps_internal = FF_CODEC_CAP_INIT_CLEANUP, |
||||
}; |
Loading…
Reference in new issue