You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-15 14:13:16 +02:00
avcodec/nvenc: add single slice intra refresh support
Signed-off-by: Limin Wang <lance.lmwang@gmail.com> Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
This commit is contained in:
committed by
Timo Rothenpieler
parent
e6bd5171ac
commit
3756525a59
@@ -529,8 +529,21 @@ static int nvenc_check_capabilities(AVCodecContext *avctx)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef NVENC_HAVE_SINGLE_SLICE_INTRA_REFRESH
|
||||||
|
ret = nvenc_check_cap(avctx, NV_ENC_CAPS_SINGLE_SLICE_INTRA_REFRESH);
|
||||||
|
if(ctx->single_slice_intra_refresh && ret <= 0) {
|
||||||
|
av_log(avctx, AV_LOG_WARNING, "Single slice intra refresh not supported by the device\n");
|
||||||
|
return AVERROR(ENOSYS);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
if(ctx->single_slice_intra_refresh) {
|
||||||
|
av_log(avctx, AV_LOG_WARNING, "Single slice intra refresh needs SDK 11.1 at build time\n");
|
||||||
|
return AVERROR(ENOSYS);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
ret = nvenc_check_cap(avctx, NV_ENC_CAPS_SUPPORT_INTRA_REFRESH);
|
ret = nvenc_check_cap(avctx, NV_ENC_CAPS_SUPPORT_INTRA_REFRESH);
|
||||||
if(ctx->intra_refresh && ret <= 0) {
|
if((ctx->intra_refresh || ctx->single_slice_intra_refresh) && ret <= 0) {
|
||||||
av_log(avctx, AV_LOG_WARNING, "Intra refresh not supported by the device\n");
|
av_log(avctx, AV_LOG_WARNING, "Intra refresh not supported by the device\n");
|
||||||
return AVERROR(ENOSYS);
|
return AVERROR(ENOSYS);
|
||||||
}
|
}
|
||||||
@@ -1086,6 +1099,9 @@ static av_cold int nvenc_setup_h264_config(AVCodecContext *avctx)
|
|||||||
h264->enableIntraRefresh = 1;
|
h264->enableIntraRefresh = 1;
|
||||||
h264->intraRefreshPeriod = avctx->gop_size;
|
h264->intraRefreshPeriod = avctx->gop_size;
|
||||||
h264->intraRefreshCnt = avctx->gop_size - 1;
|
h264->intraRefreshCnt = avctx->gop_size - 1;
|
||||||
|
#ifdef NVENC_HAVE_SINGLE_SLICE_INTRA_REFRESH
|
||||||
|
h264->singleSliceIntraRefresh = ctx->single_slice_intra_refresh;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
h264->disableSPSPPS = (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) ? 1 : 0;
|
h264->disableSPSPPS = (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) ? 1 : 0;
|
||||||
@@ -1192,6 +1208,9 @@ static av_cold int nvenc_setup_hevc_config(AVCodecContext *avctx)
|
|||||||
hevc->enableIntraRefresh = 1;
|
hevc->enableIntraRefresh = 1;
|
||||||
hevc->intraRefreshPeriod = avctx->gop_size;
|
hevc->intraRefreshPeriod = avctx->gop_size;
|
||||||
hevc->intraRefreshCnt = avctx->gop_size - 1;
|
hevc->intraRefreshCnt = avctx->gop_size - 1;
|
||||||
|
#ifdef NVENC_HAVE_SINGLE_SLICE_INTRA_REFRESH
|
||||||
|
hevc->singleSliceIntraRefresh = ctx->single_slice_intra_refresh;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
hevc->disableSPSPPS = (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) ? 1 : 0;
|
hevc->disableSPSPPS = (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) ? 1 : 0;
|
||||||
@@ -1391,6 +1410,10 @@ static av_cold int nvenc_setup_encoder(AVCodecContext *avctx)
|
|||||||
ctx->encode_config.gopLength = 1;
|
ctx->encode_config.gopLength = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* force to enable intra refresh */
|
||||||
|
if(ctx->single_slice_intra_refresh)
|
||||||
|
ctx->intra_refresh = 1;
|
||||||
|
|
||||||
if (ctx->intra_refresh)
|
if (ctx->intra_refresh)
|
||||||
ctx->encode_config.gopLength = NVENC_INFINITE_GOPLENGTH;
|
ctx->encode_config.gopLength = NVENC_INFINITE_GOPLENGTH;
|
||||||
|
|
||||||
|
@@ -73,6 +73,7 @@ typedef void ID3D11Device;
|
|||||||
// SDK 11.1 compile time feature checks
|
// SDK 11.1 compile time feature checks
|
||||||
#if NVENCAPI_CHECK_VERSION(11, 1)
|
#if NVENCAPI_CHECK_VERSION(11, 1)
|
||||||
#define NVENC_HAVE_QP_CHROMA_OFFSETS
|
#define NVENC_HAVE_QP_CHROMA_OFFSETS
|
||||||
|
#define NVENC_HAVE_SINGLE_SLICE_INTRA_REFRESH
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct NvencSurface
|
typedef struct NvencSurface
|
||||||
@@ -231,6 +232,7 @@ typedef struct NvencContext
|
|||||||
int ldkfs;
|
int ldkfs;
|
||||||
int extra_sei;
|
int extra_sei;
|
||||||
int intra_refresh;
|
int intra_refresh;
|
||||||
|
int single_slice_intra_refresh;
|
||||||
} NvencContext;
|
} NvencContext;
|
||||||
|
|
||||||
int ff_nvenc_encode_init(AVCodecContext *avctx);
|
int ff_nvenc_encode_init(AVCodecContext *avctx);
|
||||||
|
@@ -190,6 +190,8 @@ static const AVOption options[] = {
|
|||||||
OFFSET(extra_sei), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, VE },
|
OFFSET(extra_sei), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, VE },
|
||||||
{ "intra-refresh","Use Periodic Intra Refresh instead of IDR frames",
|
{ "intra-refresh","Use Periodic Intra Refresh instead of IDR frames",
|
||||||
OFFSET(intra_refresh),AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
|
OFFSET(intra_refresh),AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
|
||||||
|
{ "single-slice-intra-refresh", "Use single slice intra refresh",
|
||||||
|
OFFSET(single_slice_intra_refresh), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
|
||||||
{ NULL }
|
{ NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -171,6 +171,8 @@ static const AVOption options[] = {
|
|||||||
OFFSET(extra_sei), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, VE },
|
OFFSET(extra_sei), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, VE },
|
||||||
{ "intra-refresh","Use Periodic Intra Refresh instead of IDR frames",
|
{ "intra-refresh","Use Periodic Intra Refresh instead of IDR frames",
|
||||||
OFFSET(intra_refresh),AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
|
OFFSET(intra_refresh),AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
|
||||||
|
{ "single-slice-intra-refresh", "Use single slice intra refresh",
|
||||||
|
OFFSET(single_slice_intra_refresh), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
|
||||||
{ NULL }
|
{ NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user