avcodec/d3d12va_encode: Add H264 deblock filter parameter support
add parameter `deblock` for users to explicitly enable/disable deblocking filter in d3d12 H264 encoding usage: -deblock enable or -deblock 1 -deblock disable or -deblock 0 -deblock auto or -deblock -1 sample command line: ``` .\ffmpeg.exe -hwaccel d3d12va -hwaccel_output_format d3d12 -i input.mp4 -c:v h264_d3d12va -deblock enable -y output.mp4 ```
This commit is contained in:
@@ -44,6 +44,7 @@ typedef struct D3D12VAEncodeH264Context {
|
||||
int qp;
|
||||
int profile;
|
||||
int level;
|
||||
int deblock;
|
||||
int idr_pic_id;
|
||||
|
||||
// Writer structures.
|
||||
@@ -286,6 +287,23 @@ static int d3d12va_encode_h264_get_encoder_caps(AVCodecContext *avctx)
|
||||
priv->unit_opts.cabac = 1;
|
||||
}
|
||||
|
||||
// Deblocking filter configuration
|
||||
if (priv->deblock == 1) {
|
||||
if (h264_caps.DisableDeblockingFilterSupportedModes & D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_H264_SLICES_DEBLOCKING_MODE_FLAG_0_ALL_LUMA_CHROMA_SLICE_BLOCK_EDGES_ALWAYS_FILTERED) {
|
||||
config->DisableDeblockingFilterConfig = D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_H264_SLICES_DEBLOCKING_MODE_0_ALL_LUMA_CHROMA_SLICE_BLOCK_EDGES_ALWAYS_FILTERED;
|
||||
} else {
|
||||
av_log(avctx, AV_LOG_ERROR, "Requested deblocking filter enable mode not supported by driver.\n");
|
||||
return AVERROR(ENOTSUP);
|
||||
}
|
||||
} else if (priv->deblock == 0) {
|
||||
if (h264_caps.DisableDeblockingFilterSupportedModes & D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_H264_SLICES_DEBLOCKING_MODE_FLAG_1_DISABLE_ALL_SLICE_BLOCK_EDGES) {
|
||||
config->DisableDeblockingFilterConfig = D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_H264_SLICES_DEBLOCKING_MODE_1_DISABLE_ALL_SLICE_BLOCK_EDGES;
|
||||
} else {
|
||||
av_log(avctx, AV_LOG_ERROR, "Requested deblocking filter disable mode not supported by driver.\n");
|
||||
return AVERROR(ENOTSUP);
|
||||
}
|
||||
}
|
||||
|
||||
base_ctx->surface_width = FFALIGN(avctx->width, 16);
|
||||
base_ctx->surface_height = FFALIGN(avctx->height, 16);
|
||||
|
||||
@@ -610,6 +628,12 @@ static const AVOption d3d12va_encode_h264_options[] = {
|
||||
{ LEVEL("6.2", 62) },
|
||||
#undef LEVEL
|
||||
|
||||
{ "deblock", "Deblocking filter mode",
|
||||
OFFSET(deblock), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, FLAGS, "deblock" },
|
||||
{ "auto", "Default (enabled)", 0, AV_OPT_TYPE_CONST, { .i64 = -1 }, 0, 0, FLAGS, "deblock" },
|
||||
{ "disable", "Disable deblocking filter", 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, 0, 0, FLAGS, "deblock" },
|
||||
{ "enable", "Enable deblocking filter", 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, 0, 0, FLAGS, "deblock" },
|
||||
|
||||
{ NULL },
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user