Add more FFmpeg VA-API patches (#1751)
* enable global header with AMD H264 * fix setting VUI parameters with H265 * fix surface alignment with AMD H265
This commit is contained in:
parent
f0b7564052
commit
c73046a081
|
@ -0,0 +1,70 @@
|
|||
From 3d142fff33196e284b9c9df7d33c2becf609ea60 Mon Sep 17 00:00:00 2001
|
||||
From: nyanmisaka <nst799610810@gmail.com>
|
||||
Date: Thu, 15 Jun 2023 23:01:58 +0800
|
||||
Subject: [PATCH] Add AV_VAAPI_DRIVER_QUIRK_HEVC_ENCODER_ALIGN_64_16 for AMD
|
||||
VA-API
|
||||
|
||||
Signed-off-by: nyanmisaka <nst799610810@gmail.com>
|
||||
---
|
||||
libavcodec/vaapi_encode_h265.c | 10 ++++++++--
|
||||
libavutil/hwcontext_vaapi.c | 5 +++++
|
||||
libavutil/hwcontext_vaapi.h | 6 ++++++
|
||||
3 files changed, 19 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c
|
||||
index aa7e532f9a..4ea0cf54be 100644
|
||||
--- a/libavcodec/vaapi_encode_h265.c
|
||||
+++ b/libavcodec/vaapi_encode_h265.c
|
||||
@@ -1236,8 +1236,14 @@ static av_cold int vaapi_encode_h265_get_encoder_caps(AVCodecContext *avctx)
|
||||
"min CB size %dx%d.\n", priv->ctu_size, priv->ctu_size,
|
||||
priv->min_cb_size, priv->min_cb_size);
|
||||
|
||||
- ctx->surface_width = FFALIGN(avctx->width, priv->min_cb_size);
|
||||
- ctx->surface_height = FFALIGN(avctx->height, priv->min_cb_size);
|
||||
+ if (priv->common.hwctx->driver_quirks &
|
||||
+ AV_VAAPI_DRIVER_QUIRK_HEVC_ENCODER_ALIGN_64_16) {
|
||||
+ ctx->surface_width = FFALIGN(avctx->width, 64);
|
||||
+ ctx->surface_height = FFALIGN(avctx->height, 16);
|
||||
+ } else {
|
||||
+ ctx->surface_width = FFALIGN(avctx->width, priv->min_cb_size);
|
||||
+ ctx->surface_height = FFALIGN(avctx->height, priv->min_cb_size);
|
||||
+ }
|
||||
|
||||
ctx->slice_block_width = ctx->slice_block_height = priv->ctu_size;
|
||||
|
||||
diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c
|
||||
index 6c3a227ddd..337a69344e 100644
|
||||
--- a/libavutil/hwcontext_vaapi.c
|
||||
+++ b/libavutil/hwcontext_vaapi.c
|
||||
@@ -380,6 +380,11 @@ static const struct {
|
||||
"Splitted-Desktop Systems VDPAU backend for VA-API",
|
||||
AV_VAAPI_DRIVER_QUIRK_SURFACE_ATTRIBUTES,
|
||||
},
|
||||
+ {
|
||||
+ "AMD Radeon",
|
||||
+ "AMD Radeon",
|
||||
+ AV_VAAPI_DRIVER_QUIRK_HEVC_ENCODER_ALIGN_64_16,
|
||||
+ }
|
||||
};
|
||||
|
||||
static int vaapi_device_init(AVHWDeviceContext *hwdev)
|
||||
diff --git a/libavutil/hwcontext_vaapi.h b/libavutil/hwcontext_vaapi.h
|
||||
index 0b2e071cb3..e4ee2de9a4 100644
|
||||
--- a/libavutil/hwcontext_vaapi.h
|
||||
+++ b/libavutil/hwcontext_vaapi.h
|
||||
@@ -58,6 +58,12 @@ enum {
|
||||
* and the results of the vaQuerySurfaceAttributes() call will be faked.
|
||||
*/
|
||||
AV_VAAPI_DRIVER_QUIRK_SURFACE_ATTRIBUTES = (1 << 3),
|
||||
+
|
||||
+ /**
|
||||
+ * The driver requires to align the surface with 64x16 for the HEVC encoder,
|
||||
+ * and it does not use the min_cb_size like other hardware implementations.
|
||||
+ */
|
||||
+ AV_VAAPI_DRIVER_QUIRK_HEVC_ENCODER_ALIGN_64_16 = (1 << 4),
|
||||
};
|
||||
|
||||
/**
|
||||
--
|
||||
2.34.1
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
From 03e6b5617c94bf6073a17a0a7054e70345b512ae Mon Sep 17 00:00:00 2001
|
||||
From: David Rosca <nowrep@gmail.com>
|
||||
Date: Sat, 1 Jul 2023 10:35:16 +0200
|
||||
Subject: [PATCH] vaapi_encode: Force enable global header
|
||||
|
||||
---
|
||||
libavcodec/vaapi_encode.c | 3 +--
|
||||
1 file changed, 1 insertion(+), 2 deletions(-)
|
||||
|
||||
diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
|
||||
index bfca315a7a..ecce9bd721 100644
|
||||
--- a/libavcodec/vaapi_encode.c
|
||||
+++ b/libavcodec/vaapi_encode.c
|
||||
@@ -2719,8 +2719,7 @@ av_cold int ff_vaapi_encode_init(AVCodecContext *avctx)
|
||||
}
|
||||
}
|
||||
|
||||
- if (ctx->va_packed_headers & VA_ENC_PACKED_HEADER_SEQUENCE &&
|
||||
- ctx->codec->write_sequence_header &&
|
||||
+ if (ctx->codec->write_sequence_header &&
|
||||
avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) {
|
||||
char data[MAX_PARAM_BUFFER_SIZE];
|
||||
size_t bit_len = 8 * sizeof(data);
|
||||
--
|
||||
2.41.0
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
From d96227806cab0de91c4db6b808b842c5b1477ebd Mon Sep 17 00:00:00 2001
|
||||
From: David Rosca <nowrep@gmail.com>
|
||||
Date: Fri, 21 Jul 2023 21:55:56 +0200
|
||||
Subject: [PATCH] vaapi_encode_h265: Set vui_parameters_present_flag
|
||||
|
||||
---
|
||||
libavcodec/vaapi_encode_h265.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c
|
||||
index aa7e532f9a..91212dfb58 100644
|
||||
--- a/libavcodec/vaapi_encode_h265.c
|
||||
+++ b/libavcodec/vaapi_encode_h265.c
|
||||
@@ -690,7 +690,7 @@ static int vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx)
|
||||
sps->log2_min_pcm_luma_coding_block_size_minus3 +
|
||||
sps->log2_diff_max_min_pcm_luma_coding_block_size,
|
||||
|
||||
- .vui_parameters_present_flag = 0,
|
||||
+ .vui_parameters_present_flag = 1,
|
||||
};
|
||||
|
||||
*vpic = (VAEncPictureParameterBufferHEVC) {
|
||||
--
|
||||
2.41.0
|
||||
|
Loading…
Reference in New Issue