36 #define CHECK_CU(x) FF_CUDA_CHECK_DL(avctx, dl_fn->cuda_dl, x) 38 #define NVENC_CAP 0x30 39 #define IS_CBR(rc) (rc == NV_ENC_PARAMS_RC_CBR || \ 40 rc == NV_ENC_PARAMS_RC_CBR_LOWDELAY_HQ || \ 41 rc == NV_ENC_PARAMS_RC_CBR_HQ) 69 #define IS_10BIT(pix_fmt) (pix_fmt == AV_PIX_FMT_P010 || \ 70 pix_fmt == AV_PIX_FMT_P016 || \ 71 pix_fmt == AV_PIX_FMT_YUV444P16) 73 #define IS_YUV444(pix_fmt) (pix_fmt == AV_PIX_FMT_YUV444P || \ 74 pix_fmt == AV_PIX_FMT_YUV444P16) 81 { NV_ENC_SUCCESS, 0,
"success" },
82 { NV_ENC_ERR_NO_ENCODE_DEVICE,
AVERROR(ENOENT),
"no encode device" },
83 { NV_ENC_ERR_UNSUPPORTED_DEVICE,
AVERROR(ENOSYS),
"unsupported device" },
84 { NV_ENC_ERR_INVALID_ENCODERDEVICE,
AVERROR(EINVAL),
"invalid encoder device" },
85 { NV_ENC_ERR_INVALID_DEVICE,
AVERROR(EINVAL),
"invalid device" },
86 { NV_ENC_ERR_DEVICE_NOT_EXIST,
AVERROR(EIO),
"device does not exist" },
87 { NV_ENC_ERR_INVALID_PTR,
AVERROR(EFAULT),
"invalid ptr" },
88 { NV_ENC_ERR_INVALID_EVENT,
AVERROR(EINVAL),
"invalid event" },
89 { NV_ENC_ERR_INVALID_PARAM,
AVERROR(EINVAL),
"invalid param" },
90 { NV_ENC_ERR_INVALID_CALL,
AVERROR(EINVAL),
"invalid call" },
91 { NV_ENC_ERR_OUT_OF_MEMORY,
AVERROR(ENOMEM),
"out of memory" },
92 { NV_ENC_ERR_ENCODER_NOT_INITIALIZED,
AVERROR(EINVAL),
"encoder not initialized" },
93 { NV_ENC_ERR_UNSUPPORTED_PARAM,
AVERROR(ENOSYS),
"unsupported param" },
94 { NV_ENC_ERR_LOCK_BUSY,
AVERROR(EAGAIN),
"lock busy" },
96 { NV_ENC_ERR_INVALID_VERSION,
AVERROR(EINVAL),
"invalid version" },
97 { NV_ENC_ERR_MAP_FAILED,
AVERROR(EIO),
"map failed" },
98 { NV_ENC_ERR_NEED_MORE_INPUT,
AVERROR(EAGAIN),
"need more input" },
99 { NV_ENC_ERR_ENCODER_BUSY,
AVERROR(EAGAIN),
"encoder busy" },
100 { NV_ENC_ERR_EVENT_NOT_REGISTERD,
AVERROR(EBADF),
"event not registered" },
102 { NV_ENC_ERR_INCOMPATIBLE_CLIENT_KEY,
AVERROR(EINVAL),
"incompatible client key" },
103 { NV_ENC_ERR_UNIMPLEMENTED,
AVERROR(ENOSYS),
"unimplemented" },
104 { NV_ENC_ERR_RESOURCE_REGISTER_FAILED,
AVERROR(EIO),
"resource register failed" },
105 { NV_ENC_ERR_RESOURCE_NOT_REGISTERED,
AVERROR(EBADF),
"resource not registered" },
106 { NV_ENC_ERR_RESOURCE_NOT_MAPPED,
AVERROR(EBADF),
"resource not mapped" },
120 *desc =
"unknown error";
125 const char *error_string)
128 const char *details =
"(no details)";
131 #ifdef NVENC_HAVE_GETLASTERRORSTRING 136 details = p_nvenc->nvEncGetLastErrorString(ctx->
nvencoder);
146 #if NVENCAPI_CHECK_VERSION(9, 2) 147 const char *minver =
"(unknown)";
148 #elif NVENCAPI_CHECK_VERSION(9, 1) 149 # if defined(_WIN32) || defined(__CYGWIN__) 150 const char *minver =
"436.15";
152 const char *minver =
"435.21";
154 #elif NVENCAPI_CHECK_VERSION(9, 0) 155 # if defined(_WIN32) || defined(__CYGWIN__) 156 const char *minver =
"418.81";
158 const char *minver =
"418.30";
160 #elif NVENCAPI_CHECK_VERSION(8, 2) 161 # if defined(_WIN32) || defined(__CYGWIN__) 162 const char *minver =
"397.93";
164 const char *minver =
"396.24";
166 #elif NVENCAPI_CHECK_VERSION(8, 1) 167 # if defined(_WIN32) || defined(__CYGWIN__) 168 const char *minver =
"390.77";
170 const char *minver =
"390.25";
173 # if defined(_WIN32) || defined(__CYGWIN__) 174 const char *minver =
"378.66";
176 const char *minver =
"378.13";
179 av_log(avctx, level,
"The minimum required Nvidia driver for nvenc is %s or newer\n", minver);
187 uint32_t nvenc_max_ver;
190 ret = cuda_load_functions(&dl_fn->
cuda_dl, avctx);
194 ret = nvenc_load_functions(&dl_fn->
nvenc_dl, avctx);
200 err = dl_fn->
nvenc_dl->NvEncodeAPIGetMaxSupportedVersion(&nvenc_max_ver);
201 if (err != NV_ENC_SUCCESS)
206 if ((NVENCAPI_MAJOR_VERSION << 4 | NVENCAPI_MINOR_VERSION) > nvenc_max_ver) {
207 av_log(avctx,
AV_LOG_ERROR,
"Driver does not support the required nvenc API version. " 208 "Required: %d.%d Found: %d.%d\n",
209 NVENCAPI_MAJOR_VERSION, NVENCAPI_MINOR_VERSION,
210 nvenc_max_ver >> 4, nvenc_max_ver & 0xf);
215 dl_fn->
nvenc_funcs.version = NV_ENCODE_API_FUNCTION_LIST_VER;
218 if (err != NV_ENC_SUCCESS)
251 NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS params = { 0 };
256 params.version = NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS_VER;
257 params.apiVersion = NVENCAPI_VERSION;
260 params.deviceType = NV_ENC_DEVICE_TYPE_DIRECTX;
263 params.deviceType = NV_ENC_DEVICE_TYPE_CUDA;
266 ret = p_nvenc->nvEncOpenEncodeSessionEx(¶ms, &ctx->
nvencoder);
267 if (ret != NV_ENC_SUCCESS) {
279 int i, ret, count = 0;
282 ret = p_nvenc->nvEncGetEncodeGUIDCount(ctx->
nvencoder, &count);
284 if (ret != NV_ENC_SUCCESS || !count)
291 ret = p_nvenc->nvEncGetEncodeGUIDs(ctx->
nvencoder, guids, count, &count);
292 if (ret != NV_ENC_SUCCESS) {
298 for (i = 0; i < count; i++) {
315 NV_ENC_CAPS_PARAM params = { 0 };
318 params.version = NV_ENC_CAPS_PARAM_VER;
319 params.capsToQuery = cap;
323 if (ret == NV_ENC_SUCCESS)
352 if (ret < avctx->
width) {
359 if (ret < avctx->
height) {
366 if (ret < avctx->max_b_frames) {
376 "Interlaced encoding is not supported. Supported level: %d\n",
406 if (ctx->
coder == NV_ENC_H264_ENTROPY_CODING_MODE_CABAC && ret <= 0) {
411 #ifdef NVENC_HAVE_BFRAME_REF_MODE 413 if (ctx->
b_ref_mode == NV_ENC_BFRAME_REF_MODE_EACH && ret != 1) {
416 }
else if (ctx->
b_ref_mode != NV_ENC_BFRAME_REF_MODE_DISABLED && ret == 0) {
427 #ifdef NVENC_HAVE_MULTIPLE_REF_FRAMES 429 if(avctx->
refs != NV_ENC_NUM_REF_FRAMES_AUTOSELECT && ret <= 0) {
434 if(avctx->
refs != 0) {
449 NV_ENCODE_API_FUNCTION_LIST *p_nvenc = &dl_fn->
nvenc_funcs;
450 char name[128] = { 0};
462 ret =
CHECK_CU(dl_fn->
cuda_dl->cuDeviceGetName(name,
sizeof(name), cu_device));
466 ret =
CHECK_CU(dl_fn->
cuda_dl->cuDeviceComputeCapability(&major, &minor, cu_device));
470 av_log(avctx, loglevel,
"[ GPU #%d - < %s > has Compute SM %d.%d ]\n", idx, name, major, minor);
471 if (((major << 4) | minor) <
NVENC_CAP) {
472 av_log(avctx, loglevel,
"does not support NVENC\n");
495 av_log(avctx, loglevel,
"supports NVENC\n");
506 p_nvenc->nvEncDestroyEncoder(ctx->
nvencoder);
558 cuda_device_hwctx = hwdev_ctx->
hwctx;
561 d3d11_device_hwctx = hwdev_ctx->
hwctx;
569 if (cuda_device_hwctx) {
574 else if (d3d11_device_hwctx) {
586 av_log(avctx,
AV_LOG_FATAL,
"Provided device doesn't support required NVENC features\n");
590 int i, nb_devices = 0;
606 for (i = 0; i < nb_devices; ++
i) {
631 #define PRESET_ALIAS(alias, name, ...) \ 632 [PRESET_ ## alias] = { NV_ENC_PRESET_ ## name ## _GUID, __VA_ARGS__ } 634 #define PRESET(name, ...) PRESET_ALIAS(name, name, __VA_ARGS__) 667 rc->rateControlMode = NV_ENC_PARAMS_RC_CONSTQP;
675 rc->constQP.qpIntra = av_clip(
677 rc->constQP.qpInterB = av_clip(
680 rc->constQP.qpIntra = rc->constQP.qpInterP;
681 rc->constQP.qpInterB = rc->constQP.qpInterP;
683 }
else if (ctx->
cqp >= 0) {
684 rc->constQP.qpInterP = rc->constQP.qpInterB = rc->constQP.qpIntra = ctx->
cqp;
701 if (avctx->
qmin >= 0 && avctx->
qmax >= 0) {
705 rc->minQP.qpInterB = avctx->
qmin;
706 rc->minQP.qpInterP = avctx->
qmin;
707 rc->minQP.qpIntra = avctx->
qmin;
709 rc->maxQP.qpInterB = avctx->
qmax;
710 rc->maxQP.qpInterP = avctx->
qmax;
711 rc->maxQP.qpIntra = avctx->
qmax;
713 qp_inter_p = (avctx->
qmax + 3 * avctx->
qmin) / 4;
714 }
else if (avctx->
qmin >= 0) {
717 rc->minQP.qpInterB = avctx->
qmin;
718 rc->minQP.qpInterP = avctx->
qmin;
719 rc->minQP.qpIntra = avctx->
qmin;
721 qp_inter_p = avctx->
qmin;
726 rc->enableInitialRCQP = 1;
729 rc->initialRCQP.qpInterP = qp_inter_p;
731 rc->initialRCQP.qpInterP = ctx->
init_qp_p;
736 rc->initialRCQP.qpIntra = av_clip(
739 rc->initialRCQP.qpIntra = rc->initialRCQP.qpInterP;
742 rc->initialRCQP.qpIntra = ctx->
init_qp_i;
747 rc->initialRCQP.qpInterB = av_clip(
750 rc->initialRCQP.qpInterB = rc->initialRCQP.qpInterP;
753 rc->initialRCQP.qpInterB = ctx->
init_qp_b;
762 rc->rateControlMode = NV_ENC_PARAMS_RC_CONSTQP;
763 rc->constQP.qpInterB = 0;
764 rc->constQP.qpInterP = 0;
765 rc->constQP.qpIntra = 0;
777 case NV_ENC_PARAMS_RC_CONSTQP:
780 case NV_ENC_PARAMS_RC_VBR_MINQP:
781 if (avctx->
qmin < 0) {
783 "The variable bitrate rate-control requires " 784 "the 'qmin' option set.\n");
789 case NV_ENC_PARAMS_RC_VBR_HQ:
790 case NV_ENC_PARAMS_RC_VBR:
793 case NV_ENC_PARAMS_RC_CBR:
794 case NV_ENC_PARAMS_RC_CBR_HQ:
795 case NV_ENC_PARAMS_RC_CBR_LOWDELAY_HQ:
799 rc->rateControlMode = ctx->
rc;
818 "Defined rc_lookahead requires more surfaces, " 819 "increasing used surfaces %d -> %d\n", ctx->
nb_surfaces, nb_surfaces);
826 "Defined b-frame requires more surfaces, " 827 "increasing used surfaces %d -> %d\n", ctx->
nb_surfaces, nb_surfaces);
846 av_log(avctx,
AV_LOG_WARNING,
"Using global_quality with nvenc is deprecated. Use qp instead.\n");
871 ctx->
rc = NV_ENC_PARAMS_RC_CBR_LOWDELAY_HQ;
873 ctx->
rc = NV_ENC_PARAMS_RC_CBR;
875 }
else if (ctx->
cqp >= 0) {
876 ctx->
rc = NV_ENC_PARAMS_RC_CONSTQP;
878 ctx->
rc = NV_ENC_PARAMS_RC_VBR_HQ;
879 }
else if (avctx->
qmin >= 0 && avctx->
qmax >= 0) {
880 ctx->
rc = NV_ENC_PARAMS_RC_VBR_MINQP;
896 }
else if (ctx->
rc >= 0) {
899 ctx->
encode_config.rcParams.rateControlMode = NV_ENC_PARAMS_RC_VBR;
926 "Lookahead not enabled. Increase buffer delay (-delay).\n");
933 "Lookahead enabled: depth %d, scenecut %s, B-adapt %s.\n",
935 ctx->
encode_config.rcParams.disableIadapt ?
"disabled" :
"enabled",
936 ctx->
encode_config.rcParams.disableBadapt ?
"disabled" :
"enabled");
953 int tmp_quality = (
int)(ctx->
quality * 256.0f);
970 NV_ENC_CONFIG_H264 *h264 = &cc->encodeCodecConfig.h264Config;
971 NV_ENC_CONFIG_H264_VUI_PARAMETERS *vui = &h264->h264VUIParameters;
975 vui->transferCharacteristics = avctx->
color_trc;
979 vui->colourDescriptionPresentFlag =
982 vui->videoSignalTypePresentFlag =
983 (vui->colourDescriptionPresentFlag
984 || vui->videoFormat != 5
985 || vui->videoFullRangeFlag != 0);
988 h264->sliceModeData = 1;
992 h264->outputAUD = ctx->
aud;
996 h264->maxNumRefFrames = ctx->
dpb_size;
999 h264->idrPeriod = cc->gopLength;
1002 if (
IS_CBR(cc->rcParams.rateControlMode)) {
1003 h264->outputBufferingPeriodSEI = 1;
1006 h264->outputPictureTimingSEI = 1;
1008 if (cc->rcParams.rateControlMode == NV_ENC_PARAMS_RC_CBR_LOWDELAY_HQ ||
1009 cc->rcParams.rateControlMode == NV_ENC_PARAMS_RC_CBR_HQ ||
1010 cc->rcParams.rateControlMode == NV_ENC_PARAMS_RC_VBR_HQ) {
1011 h264->adaptiveTransformMode = NV_ENC_H264_ADAPTIVE_TRANSFORM_ENABLE;
1012 h264->fmoMode = NV_ENC_H264_FMO_DISABLE;
1016 h264->qpPrimeYZeroTransformBypassFlag = 1;
1020 cc->profileGUID = NV_ENC_H264_PROFILE_BASELINE_GUID;
1024 cc->profileGUID = NV_ENC_H264_PROFILE_MAIN_GUID;
1028 cc->profileGUID = NV_ENC_H264_PROFILE_HIGH_GUID;
1032 cc->profileGUID = NV_ENC_H264_PROFILE_HIGH_444_GUID;
1040 cc->profileGUID = NV_ENC_H264_PROFILE_HIGH_444_GUID;
1046 h264->level = ctx->
level;
1048 if (ctx->
coder >= 0)
1049 h264->entropyCodingMode = ctx->
coder;
1051 #ifdef NVENC_HAVE_BFRAME_REF_MODE 1055 #ifdef NVENC_HAVE_MULTIPLE_REF_FRAMES 1056 h264->numRefL0 = avctx->
refs;
1057 h264->numRefL1 = avctx->
refs;
1067 NV_ENC_CONFIG_HEVC *hevc = &cc->encodeCodecConfig.hevcConfig;
1068 NV_ENC_CONFIG_HEVC_VUI_PARAMETERS *vui = &hevc->hevcVUIParameters;
1072 vui->transferCharacteristics = avctx->
color_trc;
1076 vui->colourDescriptionPresentFlag =
1079 vui->videoSignalTypePresentFlag =
1080 (vui->colourDescriptionPresentFlag
1081 || vui->videoFormat != 5
1082 || vui->videoFullRangeFlag != 0);
1084 hevc->sliceMode = 3;
1085 hevc->sliceModeData = 1;
1089 hevc->outputAUD = ctx->
aud;
1093 hevc->maxNumRefFramesInDPB = ctx->
dpb_size;
1096 hevc->idrPeriod = cc->gopLength;
1099 if (
IS_CBR(cc->rcParams.rateControlMode)) {
1100 hevc->outputBufferingPeriodSEI = 1;
1103 hevc->outputPictureTimingSEI = 1;
1107 cc->profileGUID = NV_ENC_HEVC_PROFILE_MAIN_GUID;
1111 cc->profileGUID = NV_ENC_HEVC_PROFILE_MAIN10_GUID;
1115 cc->profileGUID = NV_ENC_HEVC_PROFILE_FREXT_GUID;
1122 cc->profileGUID = NV_ENC_HEVC_PROFILE_MAIN10_GUID;
1128 cc->profileGUID = NV_ENC_HEVC_PROFILE_FREXT_GUID;
1136 hevc->level = ctx->
level;
1138 hevc->tier = ctx->
tier;
1140 #ifdef NVENC_HAVE_HEVC_BFRAME_REF_MODE 1144 #ifdef NVENC_HAVE_MULTIPLE_REF_FRAMES 1145 hevc->numRefL0 = avctx->
refs;
1146 hevc->numRefL1 = avctx->
refs;
1183 NV_ENCODE_API_FUNCTION_LIST *p_nvenc = &dl_fn->
nvenc_funcs;
1185 NV_ENC_PRESET_CONFIG preset_config = { 0 };
1186 NVENCSTATUS nv_status = NV_ENC_SUCCESS;
1201 preset_config.version = NV_ENC_PRESET_CONFIG_VER;
1202 preset_config.presetCfg.version = NV_ENC_CONFIG_VER;
1204 nv_status = p_nvenc->nvEncGetEncodePresetConfig(ctx->
nvencoder,
1208 if (nv_status != NV_ENC_SUCCESS)
1209 return nvenc_print_error(avctx, nv_status,
"Cannot get the preset configuration");
1242 ctx->
level = NV_ENC_LEVEL_HEVC_51;
1243 ctx->
tier = NV_ENC_TIER_HEVC_HIGH;
1265 ctx->
encode_config.frameFieldMode = NV_ENC_PARAMS_FRAME_FIELD_MODE_FIELD;
1267 ctx->
encode_config.frameFieldMode = NV_ENC_PARAMS_FRAME_FIELD_MODE_FRAME;
1279 if (nv_status != NV_ENC_SUCCESS) {
1284 #ifdef NVENC_HAVE_CUSTREAM_PTR 1287 if (nv_status != NV_ENC_SUCCESS) {
1318 return NV_ENC_BUFFER_FORMAT_YV12_PL;
1320 return NV_ENC_BUFFER_FORMAT_NV12_PL;
1323 return NV_ENC_BUFFER_FORMAT_YUV420_10BIT;
1325 return NV_ENC_BUFFER_FORMAT_YUV444_PL;
1327 return NV_ENC_BUFFER_FORMAT_YUV444_10BIT;
1329 return NV_ENC_BUFFER_FORMAT_ARGB;
1331 return NV_ENC_BUFFER_FORMAT_ABGR;
1333 return NV_ENC_BUFFER_FORMAT_UNDEFINED;
1341 NV_ENCODE_API_FUNCTION_LIST *p_nvenc = &dl_fn->
nvenc_funcs;
1344 NVENCSTATUS nv_status;
1345 NV_ENC_CREATE_BITSTREAM_BUFFER allocOut = { 0 };
1346 allocOut.version = NV_ENC_CREATE_BITSTREAM_BUFFER_VER;
1353 NV_ENC_CREATE_INPUT_BUFFER allocSurf = { 0 };
1356 if (ctx->
surfaces[idx].
format == NV_ENC_BUFFER_FORMAT_UNDEFINED) {
1362 allocSurf.version = NV_ENC_CREATE_INPUT_BUFFER_VER;
1363 allocSurf.width = avctx->
width;
1364 allocSurf.height = avctx->
height;
1367 nv_status = p_nvenc->nvEncCreateInputBuffer(ctx->
nvencoder, &allocSurf);
1368 if (nv_status != NV_ENC_SUCCESS) {
1377 nv_status = p_nvenc->nvEncCreateBitstreamBuffer(ctx->
nvencoder, &allocOut);
1378 if (nv_status != NV_ENC_SUCCESS) {
1397 int i, res = 0, res2;
1439 NV_ENCODE_API_FUNCTION_LIST *p_nvenc = &dl_fn->
nvenc_funcs;
1441 NVENCSTATUS nv_status;
1442 uint32_t outSize = 0;
1443 char tmpHeader[256];
1444 NV_ENC_SEQUENCE_PARAM_PAYLOAD payload = { 0 };
1445 payload.version = NV_ENC_SEQUENCE_PARAM_PAYLOAD_VER;
1447 payload.spsppsBuffer = tmpHeader;
1448 payload.inBufferSize =
sizeof(tmpHeader);
1449 payload.outSPSPPSPayloadSize = &outSize;
1451 nv_status = p_nvenc->nvEncGetSequenceParams(ctx->
nvencoder, &payload);
1452 if (nv_status != NV_ENC_SUCCESS) {
1463 memcpy(avctx->
extradata, tmpHeader, outSize);
1472 NV_ENCODE_API_FUNCTION_LIST *p_nvenc = &dl_fn->
nvenc_funcs;
1477 NV_ENC_PIC_PARAMS params = { .version = NV_ENC_PIC_PARAMS_VER,
1478 .encodePicFlags = NV_ENC_PIC_FLAG_EOS };
1484 p_nvenc->nvEncEncodePicture(ctx->
nvencoder, ¶ms);
1514 p_nvenc->nvEncDestroyEncoder(ctx->
nvencoder);
1533 nvenc_free_functions(&dl_fn->
nvenc_dl);
1534 cuda_free_functions(&dl_fn->
cuda_dl);
1552 "hw_frames_ctx must be set when using GPU frames as input\n");
1558 "hw_frames_ctx must match the GPU frame type\n");
1599 NV_ENC_LOCK_INPUT_BUFFER *lock_buffer_params,
const AVFrame *
frame)
1601 int dst_linesize[4] = {
1602 lock_buffer_params->pitch,
1603 lock_buffer_params->pitch,
1604 lock_buffer_params->pitch,
1605 lock_buffer_params->pitch
1611 dst_linesize[1] = dst_linesize[2] >>= 1;
1614 lock_buffer_params->bufferDataPtr, dst_linesize);
1632 NV_ENCODE_API_FUNCTION_LIST *p_nvenc = &dl_fn->
nvenc_funcs;
1633 NVENCSTATUS nv_status;
1638 for (first_round = 1; first_round >= 0; first_round--) {
1645 if (nv_status != NV_ENC_SUCCESS)
1646 return nvenc_print_error(avctx, nv_status,
"Failed unregistering unused input resource");
1666 NV_ENCODE_API_FUNCTION_LIST *p_nvenc = &dl_fn->
nvenc_funcs;
1669 NV_ENC_REGISTER_RESOURCE reg;
1683 reg.version = NV_ENC_REGISTER_RESOURCE_VER;
1684 reg.width = frames_ctx->
width;
1685 reg.height = frames_ctx->
height;
1687 reg.resourceToRegister = frame->
data[0];
1690 reg.resourceType = NV_ENC_INPUT_RESOURCE_TYPE_CUDADEVICEPTR;
1693 reg.resourceType = NV_ENC_INPUT_RESOURCE_TYPE_DIRECTX;
1694 reg.subResourceIndex = (intptr_t)frame->
data[1];
1698 if (reg.bufferFormat == NV_ENC_BUFFER_FORMAT_UNDEFINED) {
1704 ret = p_nvenc->nvEncRegisterResource(ctx->
nvencoder, ®);
1705 if (ret != NV_ENC_SUCCESS) {
1721 NV_ENCODE_API_FUNCTION_LIST *p_nvenc = &dl_fn->
nvenc_funcs;
1724 NVENCSTATUS nv_status;
1741 if (nv_status != NV_ENC_SUCCESS) {
1749 nvenc_frame->
reg_idx = reg_idx;
1756 NV_ENC_LOCK_INPUT_BUFFER lockBufferParams = { 0 };
1758 lockBufferParams.version = NV_ENC_LOCK_INPUT_BUFFER_VER;
1761 nv_status = p_nvenc->nvEncLockInputBuffer(ctx->
nvencoder, &lockBufferParams);
1762 if (nv_status != NV_ENC_SUCCESS) {
1763 return nvenc_print_error(avctx, nv_status,
"Failed locking nvenc input buffer");
1766 nvenc_frame->
pitch = lockBufferParams.pitch;
1770 if (nv_status != NV_ENC_SUCCESS) {
1779 NV_ENC_PIC_PARAMS *params,
1780 NV_ENC_SEI_PAYLOAD *sei_data)
1786 params->codecPicParams.h264PicParams.sliceMode =
1788 params->codecPicParams.h264PicParams.sliceModeData =
1789 ctx->
encode_config.encodeCodecConfig.h264Config.sliceModeData;
1791 params->codecPicParams.h264PicParams.seiPayloadArray = sei_data;
1792 params->codecPicParams.h264PicParams.seiPayloadArrayCnt = 1;
1797 params->codecPicParams.hevcPicParams.sliceMode =
1799 params->codecPicParams.hevcPicParams.sliceModeData =
1800 ctx->
encode_config.encodeCodecConfig.hevcConfig.sliceModeData;
1802 params->codecPicParams.hevcPicParams.seiPayloadArray = sei_data;
1803 params->codecPicParams.hevcPicParams.seiPayloadArrayCnt = 1;
1825 NV_ENC_LOCK_BITSTREAM *params,
1830 pkt->
pts = params->outputTimeStamp;
1842 NV_ENCODE_API_FUNCTION_LIST *p_nvenc = &dl_fn->
nvenc_funcs;
1844 uint32_t slice_mode_data;
1845 uint32_t *slice_offsets =
NULL;
1846 NV_ENC_LOCK_BITSTREAM lock_params = { 0 };
1847 NVENCSTATUS nv_status;
1854 slice_mode_data = ctx->
encode_config.encodeCodecConfig.h264Config.sliceModeData;
1857 slice_mode_data = ctx->
encode_config.encodeCodecConfig.hevcConfig.sliceModeData;
1864 slice_offsets =
av_mallocz(slice_mode_data *
sizeof(*slice_offsets));
1866 if (!slice_offsets) {
1871 lock_params.version = NV_ENC_LOCK_BITSTREAM_VER;
1873 lock_params.doNotWait = 0;
1875 lock_params.sliceOffsets = slice_offsets;
1877 nv_status = p_nvenc->nvEncLockBitstream(ctx->
nvencoder, &lock_params);
1878 if (nv_status != NV_ENC_SUCCESS) {
1884 ff_alloc_packet2(avctx, pkt, lock_params.bitstreamSizeInBytes, lock_params.bitstreamSizeInBytes) :
1892 memcpy(pkt->
data, lock_params.bitstreamBufferPtr, lock_params.bitstreamSizeInBytes);
1895 if (nv_status != NV_ENC_SUCCESS) {
1896 res =
nvenc_print_error(avctx, nv_status,
"Failed unlocking bitstream buffer, expect the gates of mordor to open");
1905 if (nv_status != NV_ENC_SUCCESS) {
1919 switch (lock_params.pictureType) {
1920 case NV_ENC_PIC_TYPE_IDR:
1922 case NV_ENC_PIC_TYPE_I:
1925 case NV_ENC_PIC_TYPE_P:
1928 case NV_ENC_PIC_TYPE_B:
1931 case NV_ENC_PIC_TYPE_BI:
1935 av_log(avctx,
AV_LOG_ERROR,
"Unknown picture type encountered, expect the output to be broken.\n");
1936 av_log(avctx,
AV_LOG_ERROR,
"Please report this error and include as much information on how to reproduce it as possible.\n");
1941 #if FF_API_CODED_FRAME 1970 int nb_ready, nb_pending;
1975 return nb_ready > 0;
1976 return (nb_ready > 0) && (nb_ready + nb_pending >= ctx->
async_depth);
1985 NV_ENC_RECONFIGURE_PARAMS params = { 0 };
1986 int needs_reconfig = 0;
1987 int needs_encode_config = 0;
1988 int reconfig_bitrate = 0, reconfig_dar = 0;
1991 params.version = NV_ENC_RECONFIGURE_PARAMS_VER;
1997 "aspect ratio change (DAR): %d:%d -> %d:%d\n",
2001 params.reInitEncodeParams.darHeight = dh;
2002 params.reInitEncodeParams.darWidth = dw;
2009 if (avctx->
bit_rate > 0 && params.reInitEncodeParams.encodeConfig->rcParams.averageBitRate != avctx->
bit_rate) {
2011 "avg bitrate change: %d -> %d\n",
2012 params.reInitEncodeParams.encodeConfig->rcParams.averageBitRate,
2015 params.reInitEncodeParams.encodeConfig->rcParams.averageBitRate = avctx->
bit_rate;
2016 reconfig_bitrate = 1;
2021 "max bitrate change: %d -> %d\n",
2022 params.reInitEncodeParams.encodeConfig->rcParams.maxBitRate,
2025 params.reInitEncodeParams.encodeConfig->rcParams.maxBitRate = avctx->
rc_max_rate;
2026 reconfig_bitrate = 1;
2031 "vbv buffer size change: %d -> %d\n",
2032 params.reInitEncodeParams.encodeConfig->rcParams.vbvBufferSize,
2035 params.reInitEncodeParams.encodeConfig->rcParams.vbvBufferSize = avctx->
rc_buffer_size;
2036 reconfig_bitrate = 1;
2039 if (reconfig_bitrate) {
2040 params.resetEncoder = 1;
2041 params.forceIDR = 1;
2043 needs_encode_config = 1;
2048 if (!needs_encode_config)
2049 params.reInitEncodeParams.encodeConfig =
NULL;
2051 if (needs_reconfig) {
2052 ret = p_nvenc->nvEncReconfigureEncoder(ctx->
nvencoder, ¶ms);
2053 if (ret != NV_ENC_SUCCESS) {
2061 if (reconfig_bitrate) {
2062 ctx->
encode_config.rcParams.averageBitRate = params.reInitEncodeParams.encodeConfig->rcParams.averageBitRate;
2063 ctx->
encode_config.rcParams.maxBitRate = params.reInitEncodeParams.encodeConfig->rcParams.maxBitRate;
2064 ctx->
encode_config.rcParams.vbvBufferSize = params.reInitEncodeParams.encodeConfig->rcParams.vbvBufferSize;
2073 NVENCSTATUS nv_status;
2076 NV_ENC_SEI_PAYLOAD *sei_data =
NULL;
2081 NV_ENCODE_API_FUNCTION_LIST *p_nvenc = &dl_fn->
nvenc_funcs;
2083 NV_ENC_PIC_PARAMS pic_params = { 0 };
2084 pic_params.version = NV_ENC_PIC_PARAMS_VER;
2118 pic_params.bufferFmt = in_surf->
format;
2119 pic_params.inputWidth = in_surf->
width;
2120 pic_params.inputHeight = in_surf->
height;
2121 pic_params.inputPitch = in_surf->
pitch;
2126 pic_params.pictureStruct = NV_ENC_PIC_STRUCT_FIELD_TOP_BOTTOM;
2128 pic_params.pictureStruct = NV_ENC_PIC_STRUCT_FIELD_BOTTOM_TOP;
2130 pic_params.pictureStruct = NV_ENC_PIC_STRUCT_FRAME;
2134 pic_params.encodePicFlags =
2135 ctx->
forced_idr ? NV_ENC_PIC_FLAG_FORCEIDR : NV_ENC_PIC_FLAG_FORCEINTRA;
2137 pic_params.encodePicFlags = 0;
2140 pic_params.inputTimeStamp = frame->
pts;
2143 if (
ff_alloc_a53_sei(frame,
sizeof(NV_ENC_SEI_PAYLOAD), (
void**)&sei_data, &sei_size) < 0) {
2148 sei_data->payloadSize = (uint32_t)sei_size;
2149 sei_data->payloadType = 4;
2150 sei_data->payload = (
uint8_t*)(sei_data + 1);
2156 pic_params.encodePicFlags = NV_ENC_PIC_FLAG_EOS;
2164 nv_status = p_nvenc->nvEncEncodePicture(ctx->
nvencoder, &pic_params);
2171 if (nv_status != NV_ENC_SUCCESS &&
2172 nv_status != NV_ENC_ERR_NEED_MORE_INPUT)
2181 if (nv_status == NV_ENC_SUCCESS) {
2242 }
else if (res < 0) {
#define FF_PROFILE_H264_MAIN
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e.
const struct AVCodec * codec
av_cold int ff_nvenc_encode_close(AVCodecContext *avctx)
static enum AVPixelFormat pix_fmt
NV_ENC_BUFFER_FORMAT format
This structure describes decoded (raw) audio or video data.
static av_cold int nvenc_setup_codec_config(AVCodecContext *avctx)
AVFifoBuffer * timestamp_list
int ff_side_data_set_encoder_stats(AVPacket *pkt, int quality, int64_t *error, int error_count, int pict_type)
static void flush(AVCodecContext *avctx)
NvencFunctions * nvenc_dl
#define AV_CODEC_FLAG_INTERLACED_DCT
Use interlaced DCT.
static av_cold void set_vbr(AVCodecContext *avctx)
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
#define AV_LOG_WARNING
Something somehow does not look correct.
int64_t bit_rate
the average bitrate
#define RC_MODE_DEPRECATED
Memory handling functions.
static av_cold int nvenc_setup_device(AVCodecContext *avctx)
#define HW_CONFIG_ENCODER_FRAMES(format, device_type_)
int max_bitrate
Maximum bitrate of the stream, in bits per second.
int max_b_frames
maximum number of B-frames between non-B-frames Note: The output will be delayed by max_b_frames+1 re...
enum AVColorRange color_range
MPEG vs JPEG YUV range.
#define PRESET_ALIAS(alias, name,...)
static av_cold int nvenc_setup_surfaces(AVCodecContext *avctx)
NV_ENCODE_API_FUNCTION_LIST nvenc_funcs
NvencDynLoadFunctions nvenc_dload_funcs
ID3D11Device * d3d11_device
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel...
int width
The allocated dimensions of the frames in this pool.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
enum AVPixelFormat format
The pixel format identifying the underlying HW surface type.
int ff_nvenc_receive_packet(AVCodecContext *avctx, AVPacket *pkt)
static av_cold int nvenc_recalc_surfaces(AVCodecContext *avctx)
static void error(const char *err)
float i_quant_offset
qscale offset between P and I-frames
static void nvenc_override_rate_control(AVCodecContext *avctx)
static NvencSurface * get_free_frame(NvencContext *ctx)
static av_cold void nvenc_setup_rate_control(AVCodecContext *avctx)
int av_fifo_generic_write(AVFifoBuffer *f, void *src, int size, int(*func)(void *, void *, int))
Feed data from a user-supplied callback to an AVFifoBuffer.
#define FF_PROFILE_H264_HIGH_444_PREDICTIVE
NV_ENC_INPUT_PTR input_surface
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
AVFrameSideData * av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type)
AVBufferRef * hw_frames_ctx
For hwaccel-format frames, this should be a reference to the AVHWFramesContext describing the frame...
int ff_alloc_packet2(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int64_t min_size)
Check AVPacket size and/or allocate data.
#define FF_PROFILE_H264_BASELINE
AVFifoBuffer * unused_surface_queue
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
enum AVPixelFormat ff_nvenc_pix_fmts[]
float b_quant_factor
qscale factor between IP and B-frames If > 0 then the last P-frame quantizer will be used (q= lastp_q...
static int nvenc_pop_context(AVCodecContext *avctx)
#define FF_PROFILE_HEVC_MAIN
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
NV_ENC_INITIALIZE_PARAMS init_encode_params
void * hwctx
The format-specific data, allocated and freed by libavutil along with this context.
static av_cold int nvenc_alloc_surface(AVCodecContext *avctx, int idx)
ID3D11Device * device
Device used for texture creation and access.
#define MAX_REGISTERED_FRAMES
static av_cold int nvenc_setup_extradata(AVCodecContext *avctx)
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
#define AVERROR_EOF
End of file.
#define AV_LOG_VERBOSE
Detailed information.
static int nvenc_check_capabilities(AVCodecContext *avctx)
#define AV_PIX_FMT_YUV444P16
static int nvenc_register_frame(AVCodecContext *avctx, const AVFrame *frame)
int buffer_size
The size of the buffer to which the ratecontrol is applied, in bits.
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
#define HW_CONFIG_ENCODER_DEVICE(format, device_type_)
#define FF_PROFILE_HEVC_MAIN_10
AVFifoBuffer * output_surface_ready_queue
CUcontext cu_context_internal
An API-specific header for AV_HWDEVICE_TYPE_CUDA.
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
#define i(width, name, range_min, range_max)
static av_cold int nvenc_open_session(AVCodecContext *avctx)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int has_b_frames
Size of the frame reordering buffer in the decoder.
static void timestamp_queue_enqueue(AVFifoBuffer *queue, int64_t timestamp)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
int qmax
maximum quantizer
static int nvenc_map_error(NVENCSTATUS err, const char **desc)
ATSC A53 Part 4 Closed Captions.
int av_fifo_generic_read(AVFifoBuffer *f, void *dest, int buf_size, void(*func)(void *, void *, int))
Feed data from an AVFifoBuffer to a user-supplied callback.
#define FF_PROFILE_H264_HIGH
int flags
AV_CODEC_FLAG_*.
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
simple assert() macros that are a bit more flexible than ISO C assert().
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
#define AV_PIX_FMT_0BGR32
float i_quant_factor
qscale factor between P- and I-frames If > 0 then the last P-frame quantizer will be used (q = lastp_...
const AVCodecHWConfigInternal * ff_nvenc_hw_configs[]
int ff_nvenc_send_frame(AVCodecContext *avctx, const AVFrame *frame)
enum AVHWDeviceType type
This field identifies the underlying API used for hardware access.
static av_cold int nvenc_setup_hevc_config(AVCodecContext *avctx)
static NV_ENC_BUFFER_FORMAT nvenc_map_buffer_format(enum AVPixelFormat pix_fmt)
static av_cold void set_constqp(AVCodecContext *avctx)
void av_image_copy(uint8_t *dst_data[4], int dst_linesizes[4], const uint8_t *src_data[4], const int src_linesizes[4], enum AVPixelFormat pix_fmt, int width, int height)
Copy image in src_data to dst_data.
int flags
A combination of AV_PKT_FLAG values.
int rc_buffer_size
decoder bitstream buffer size
static int nvenc_check_codec_support(AVCodecContext *avctx)
int refs
number of reference frames
struct NvencContext::@111 registered_frames[MAX_REGISTERED_FRAMES]
enum AVPictureType pict_type
Picture type of the frame.
static int nvenc_upload_frame(AVCodecContext *avctx, const AVFrame *frame, NvencSurface *nvenc_frame)
NV_ENC_REGISTERED_PTR regptr
static av_cold int nvenc_setup_encoder(AVCodecContext *avctx)
#define AVERROR_BUFFER_TOO_SMALL
Buffer too small.
AVHWDeviceContext * device_ctx
The parent AVHWDeviceContext.
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
av_cold int ff_nvenc_encode_init(AVCodecContext *avctx)
static int process_output_surface(AVCodecContext *avctx, AVPacket *pkt, NvencSurface *tmpoutsurf)
int ff_nvenc_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
int width
picture width / height.
AVBufferRef * hw_frames_ctx
A reference to the AVHWFramesContext describing the input (for encoding) or output (decoding) frames...
enum AVColorPrimaries color_primaries
Chromaticity coordinates of the source primaries.
static int nvenc_copy_frame(AVCodecContext *avctx, NvencSurface *nv_surface, NV_ENC_LOCK_INPUT_BUFFER *lock_buffer_params, const AVFrame *frame)
#define IS_YUV444(pix_fmt)
int ticks_per_frame
For some codecs, the time base is closer to the field rate than the frame rate.
AVFifoBuffer * output_surface_queue
static void nvenc_print_driver_requirement(AVCodecContext *avctx, int level)
#define AVERROR_EXIT
Immediate exit was requested; the called function should not be restarted.
HW acceleration through CUDA.
static av_cold int nvenc_setup_h264_config(AVCodecContext *avctx)
int draining
checks API usage: after codec draining, flush is required to resume operation
#define FF_ARRAY_ELEMS(a)
the normal 2^n-1 "JPEG" YUV ranges
enum AVPixelFormat data_pix_fmt
#define IS_10BIT(pix_fmt)
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
This structure describes the bitrate properties of an encoded bitstream.
#define AV_LOG_INFO
Standard information.
NV_ENC_CONFIG encode_config
static int nvenc_push_context(AVCodecContext *avctx)
int av_image_fill_pointers(uint8_t *data[4], enum AVPixelFormat pix_fmt, int height, uint8_t *ptr, const int linesizes[4])
Fill plane data pointers for an image with pixel format pix_fmt and height height.
int av_fifo_size(const AVFifoBuffer *f)
Return the amount of data in bytes in the AVFifoBuffer, that is the amount of data you can read from ...
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
main external API structure.
uint8_t * data
The data buffer.
int qmin
minimum quantizer
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
This struct is allocated as AVHWDeviceContext.hwctx.
static int nvenc_check_cap(AVCodecContext *avctx, NV_ENC_CAPS cap)
static void nvenc_codec_specific_pic_params(AVCodecContext *avctx, NV_ENC_PIC_PARAMS *params, NV_ENC_SEI_PAYLOAD *sei_data)
enum AVColorSpace colorspace
YUV colorspace type.
enum AVColorTransferCharacteristic color_trc
Color Transfer Characteristic.
This struct describes a set or pool of "hardware" frames (i.e.
av_cold void ff_nvenc_encode_flush(AVCodecContext *avctx)
float b_quant_offset
qscale offset between IP and B-frames
static int nvenc_find_free_reg_resource(AVCodecContext *avctx)
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
int global_quality
Global quality for codecs which cannot change it per frame.
#define flags(name, subs,...)
static void compute_dar(AVCodecContext *avctx, int *dw, int *dh)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
#define AV_CODEC_FLAG_GLOBAL_HEADER
Place global headers in extradata instead of every keyframe.
Hardware surfaces for Direct3D11.
static const struct @105 nvenc_errors[]
int gop_size
the number of pictures in a group of pictures, or 0 for intra_only
static int64_t timestamp_queue_dequeue(AVFifoBuffer *queue)
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
#define FF_DISABLE_DEPRECATION_WARNINGS
common internal api header.
static int output_ready(AVCodecContext *avctx, int flush)
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
attribute_deprecated AVFrame * coded_frame
the picture in the bitstream
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
NV_ENC_MAP_INPUT_RESOURCE in_map
AVCPBProperties * ff_add_cpb_side_data(AVCodecContext *avctx)
Add a CPB properties side data to an encoding context.
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
static void reconfig_encoder(AVCodecContext *avctx, const AVFrame *frame)
#define FF_PROFILE_HEVC_REXT
static int nvenc_set_timestamp(AVCodecContext *avctx, NV_ENC_LOCK_BITSTREAM *params, AVPacket *pkt)
#define xf(width, name, var, range_min, range_max, subs,...)
#define FF_ENABLE_DEPRECATION_WARNINGS
AVFifoBuffer * av_fifo_alloc(unsigned int size)
Initialize an AVFifoBuffer.
int top_field_first
If the content is interlaced, is top field displayed first.
static av_cold int nvenc_load_libraries(AVCodecContext *avctx)
static av_cold int nvenc_check_device(AVCodecContext *avctx, int idx)
int avg_bitrate
Average bitrate of the stream, in bits per second.
struct AVCodecInternal * internal
Private context used for internal data.
#define FF_QP2LAMBDA
factor to convert from H.263 QP to lambda
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
int ff_alloc_a53_sei(const AVFrame *frame, size_t prefix_len, void **data, size_t *sei_size)
Check AVFrame for A53 side data and allocate and fill SEI message with A53 info.
This struct is allocated as AVHWDeviceContext.hwctx.
static int nvenc_print_error(AVCodecContext *avctx, NVENCSTATUS err, const char *error_string)
static av_cold void set_lossless(AVCodecContext *avctx)
void av_fifo_freep(AVFifoBuffer **f)
Free an AVFifoBuffer and reset pointer to NULL.
#define AV_LOG_FATAL
Something went wrong and recovery is not possible.
#define FFSWAP(type, a, b)
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
void av_fifo_reset(AVFifoBuffer *f)
Reset the AVFifoBuffer to the state right after av_fifo_alloc, in particular it is emptied...
AVBufferRef * hw_device_ctx
A reference to the AVHWDeviceContext describing the device which will be used by a hardware encoder/d...
enum AVPixelFormat sw_format
The pixel format identifying the actual data layout of the hardware frames.
#define AVERROR_EXTERNAL
Generic error in an external library.
AVPixelFormat
Pixel format.
static double val(void *priv, double ch)
This structure stores compressed data.
NV_ENC_OUTPUT_PTR output_surface
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
#define AV_NOPTS_VALUE
Undefined timestamp value.
static void nvenc_map_preset(NvencContext *ctx)
#define AV_PIX_FMT_0RGB32
int64_t rc_max_rate
maximum bitrate
void * av_mallocz_array(size_t nmemb, size_t size)
Allocate a memory block for an array with av_mallocz().