aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/nvenc.c
diff options
context:
space:
mode:
authorTimo Rothenpieler <timo@rothenpieler.org>2023-10-03 17:31:11 +0200
committerTimo Rothenpieler <timo@rothenpieler.org>2023-10-09 20:17:44 +0200
commite006680d8ef0c7cdcbc18a4c6d83d5dac48bea75 (patch)
tree4704f1b0bdb5e85f6584b1bd0a63d543fa0c72d5 /libavcodec/nvenc.c
parent3914abf76e3d1e65c41f7483ba76bc61f5057670 (diff)
downloadffmpeg-e006680d8ef0c7cdcbc18a4c6d83d5dac48bea75.tar.gz
avcodec/nvenc: add option to control subsampling of packed rgb input
Diffstat (limited to 'libavcodec/nvenc.c')
-rw-r--r--libavcodec/nvenc.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index 02486c2043..626f10d20a 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -92,10 +92,18 @@ const AVCodecHWConfigInternal *const ff_nvenc_hw_configs[] = {
pix_fmt == AV_PIX_FMT_X2BGR10 || \
pix_fmt == AV_PIX_FMT_GBRP16)
+#define IS_RGB(pix_fmt) (pix_fmt == AV_PIX_FMT_0RGB32 || \
+ pix_fmt == AV_PIX_FMT_RGB32 || \
+ pix_fmt == AV_PIX_FMT_0BGR32 || \
+ pix_fmt == AV_PIX_FMT_BGR32 || \
+ pix_fmt == AV_PIX_FMT_X2RGB10 || \
+ pix_fmt == AV_PIX_FMT_X2BGR10)
+
#define IS_YUV444(pix_fmt) (pix_fmt == AV_PIX_FMT_YUV444P || \
pix_fmt == AV_PIX_FMT_YUV444P16 || \
pix_fmt == AV_PIX_FMT_GBRP || \
- pix_fmt == AV_PIX_FMT_GBRP16)
+ pix_fmt == AV_PIX_FMT_GBRP16 || \
+ (ctx->rgb_mode == NVENC_RGB_MODE_444 && IS_RGB(pix_fmt)))
#define IS_GBRP(pix_fmt) (pix_fmt == AV_PIX_FMT_GBRP || \
pix_fmt == AV_PIX_FMT_GBRP16)
@@ -1951,6 +1959,11 @@ av_cold int ff_nvenc_encode_init(AVCodecContext *avctx)
ctx->data_pix_fmt = avctx->pix_fmt;
}
+ if (ctx->rgb_mode == NVENC_RGB_MODE_DISABLED && IS_RGB(ctx->data_pix_fmt)) {
+ av_log(avctx, AV_LOG_ERROR, "Packed RGB input, but RGB support is disabled.\n");
+ return AVERROR(EINVAL);
+ }
+
ctx->frame = av_frame_alloc();
if (!ctx->frame)
return AVERROR(ENOMEM);