PR #25967 opened by witaly-iwanow
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25967
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25967.patch

Crop and transpose for D3D12 frames.


>From 322da9997c8b7f4f6e2c74edfb89e117beac0ef2 Mon Sep 17 00:00:00 2001
From: Vitaly Ivanov <[email protected]>
Date: Thu, 12 Nov 2026 15:46:53 +0700
Subject: [PATCH 1/2] avfilter/vf_scale_d3d12: honor input frame cropping

Take the source rectangle from the input frame's crop fields, so that
crop can precede scale_d3d12 on D3D12 frames as it precedes scale_vaapi
on VAAPI ones. The output is the whole picture, so its crop fields are
now always reset, not only when the size changes.

Signed-off-by: Vitaly Ivanov <[email protected]>
---
 doc/filters.texi             |  4 ++++
 libavfilter/vf_scale_d3d12.c | 29 +++++++++++++++++++----------
 2 files changed, 23 insertions(+), 10 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index ec23628067a..eef694cbbac 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -22411,6 +22411,10 @@ are expressed in pixel coordinates of the old size 
(motion vectors,
 detection bounding boxes, ROI, ...) is removed when the size actually
 changes, also the same way @ref{scale} does it.
 
+Only the part of the input frame left by its cropping fields is scaled, so
+@code{crop}, which on hardware frames only sets those fields, can precede
+this filter.
+
 Which input/output pixel format and color space combinations are actually
 supported depends on the GPU and driver. The filter first rejects color
 descriptions it cannot represent using DXGI. For representable
diff --git a/libavfilter/vf_scale_d3d12.c b/libavfilter/vf_scale_d3d12.c
index cadd48e5a02..e3376e5c24c 100644
--- a/libavfilter/vf_scale_d3d12.c
+++ b/libavfilter/vf_scale_d3d12.c
@@ -1122,6 +1122,7 @@ static int scale_d3d12_filter_frame(AVFilterLink *inlink, 
AVFrame *in)
     ID3D12CommandAllocator *command_allocator = NULL;
     HRESULT removed_reason;
     int gpu_confirmed_done;
+    int src_w, src_h;
 
     if (!in) {
         av_log(ctx, AV_LOG_ERROR, "Null input frame\n");
@@ -1179,6 +1180,12 @@ static int scale_d3d12_filter_frame(AVFilterLink 
*inlink, AVFrame *in)
         goto fail;
     }
 
+    /* The processor is created for one source size */
+    src_w = in->width  - in->crop_left - in->crop_right;
+    src_h = in->height - in->crop_top  - in->crop_bottom;
+    if (src_w != s->input_width || src_h != s->input_height)
+        s->configured = 0;
+
     if (!s->configured) {
         AVHWFramesContext *input_frames_ctx = (AVHWFramesContext 
*)in->hw_frames_ctx->data;
         const D3D12ScaleFormatMap *in_map, *out_map;
@@ -1187,8 +1194,8 @@ static int scale_d3d12_filter_frame(AVFilterLink *inlink, 
AVFrame *in)
         enum AVColorPrimaries out_primaries;
         enum AVColorTransferCharacteristic out_trc;
 
-        s->input_width  = in->width;
-        s->input_height = in->height;
+        s->input_width  = src_w;
+        s->input_height = src_h;
 
         AVD3D12VAFramesContext *input_hwctx = (AVD3D12VAFramesContext 
*)input_frames_ctx->hwctx;
         s->input_format = input_hwctx->format;
@@ -1438,8 +1445,10 @@ static int scale_d3d12_filter_frame(AVFilterLink 
*inlink, AVFrame *in)
      * slice and must be passed through as-is. */
     input_args.InputStream[0].pTexture2D  = input_resource;
     input_args.InputStream[0].Subresource = input_frame->subresource_index;
-    input_args.Transform.SourceRectangle.right       = s->input_width;
-    input_args.Transform.SourceRectangle.bottom      = s->input_height;
+    input_args.Transform.SourceRectangle.left        = in->crop_left;
+    input_args.Transform.SourceRectangle.top         = in->crop_top;
+    input_args.Transform.SourceRectangle.right       = in->crop_left + src_w;
+    input_args.Transform.SourceRectangle.bottom      = in->crop_top  + src_h;
     input_args.Transform.DestinationRectangle.right  = s->width;
     input_args.Transform.DestinationRectangle.bottom = s->height;
     input_args.Transform.Orientation = D3D12_VIDEO_PROCESS_ORIENTATION_DEFAULT;
@@ -1564,18 +1573,18 @@ static int scale_d3d12_filter_frame(AVFilterLink 
*inlink, AVFrame *in)
     out->width = s->width;
     out->height = s->height;
     out->format = AV_PIX_FMT_D3D12;
+    out->crop_left = out->crop_right = out->crop_top = out->crop_bottom = 0;
 
-    if (out->width != in_width || out->height != in_height)
+    if (out->width != src_w || out->height != src_h)
         av_reduce(&out->sample_aspect_ratio.num, &out->sample_aspect_ratio.den,
-                 (int64_t)in->sample_aspect_ratio.num * out->height * in_width,
-                 (int64_t)in->sample_aspect_ratio.den * out->width * in_height,
+                 (int64_t)in->sample_aspect_ratio.num * out->height * src_w,
+                 (int64_t)in->sample_aspect_ratio.den * out->width * src_h,
                  INT_MAX);
 
-    if (out->width != in_width || out->height != in_height) {
+    if (out->width != in_width || out->height != in_height ||
+        src_w != in_width || src_h != in_height)
         av_frame_side_data_remove_by_props(&out->side_data, &out->nb_side_data,
                                            AV_SIDE_DATA_PROP_SIZE_DEPENDENT);
-        out->crop_left = out->crop_right = out->crop_top = out->crop_bottom = 
0;
-    }
 
     out->colorspace      = s->output_av_colorspace;
     out->color_range     = s->output_av_color_range;
-- 
2.54.0


>From 97d6a26750f78ba0b67bad51897043cdbdb5cade Mon Sep 17 00:00:00 2001
From: Vitaly Ivanov <[email protected]>
Date: Thu, 12 Nov 2026 15:51:52 +0700
Subject: [PATCH 2/2] avfilter: add transpose_d3d12 filter

The D3D12 counterpart of transpose_vaapi, with the same options. It
shares the video processor code of scale_d3d12, so it honors input
cropping as well.

The orientations that combine a quarter turn with a flip follow the
D3D12 documentation, rotation first. NVIDIA's driver flips first, which
swaps cclock_flip and clock_flip there; every other direction matches
the software filters on both Intel and NVIDIA.

Signed-off-by: Vitaly Ivanov <[email protected]>
---
 Changelog                    |   1 +
 configure                    |   1 +
 doc/filters.texi             |  53 +++++++++++
 libavfilter/Makefile         |   1 +
 libavfilter/allfilters.c     |   1 +
 libavfilter/version.h        |   2 +-
 libavfilter/vf_scale_d3d12.c | 168 +++++++++++++++++++++++++++++++----
 7 files changed, 210 insertions(+), 17 deletions(-)

diff --git a/Changelog b/Changelog
index bce79b181f7..c7fbf1c8fd1 100644
--- a/Changelog
+++ b/Changelog
@@ -6,6 +6,7 @@ version <next>:
 - LCEVC raw demuxer and muxer
 - AVS+ (AVS1-P16, Broadcasting profile) support in the Chinese AVS decoder
 - PCM PAMF decoder
+- transpose_d3d12 filter
 
 version 9.1:
 - ASTC image encoding and decoding via libastcenc, with .astc and KTX 1.0 
muxers and demuxers
diff --git a/configure b/configure
index 0db2edd57de..9c602c145e2 100755
--- a/configure
+++ b/configure
@@ -3568,6 +3568,7 @@ gfxcapture_filter_extralibs="-lstdc++"
 scale_d3d11_filter_deps="d3d11va"
 scale_d3d12_filter_deps="d3d12va ID3D12VideoProcessor"
 deinterlace_d3d12_filter_deps="d3d12va ID3D12VideoProcessor"
+transpose_d3d12_filter_deps="d3d12va ID3D12VideoProcessor"
 mestimate_d3d12_filter_deps="d3d12va ID3D12VideoMotionEstimator 
d3d12_motion_estimator"
 dnn_onnx_d3d12_deps="libonnxruntime d3d12va"
 
diff --git a/doc/filters.texi b/doc/filters.texi
index eef694cbbac..ab4763a5a01 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -25178,6 +25178,59 @@ The command above can also be specified as:
 transpose=1:portrait
 @end example
 
+@section transpose_d3d12
+
+Transpose rows with columns in the input video and optionally flip it, using
+Direct3D 12 hardware-accelerated video processing. It requires the input to be
+in @code{d3d12} hardware pixel format. As with @code{scale_d3d12}, only the 
part
+of the input frame left by its cropping fields is transposed.
+
+It accepts the following parameters:
+
+@table @option
+
+@item dir
+Specify the transposition direction.
+
+Can assume the following values:
+@table @samp
+@item cclock_flip
+Rotate by 90 degrees counterclockwise and vertically flip. (default)
+
+@item clock
+Rotate by 90 degrees clockwise.
+
+@item cclock
+Rotate by 90 degrees counterclockwise.
+
+@item clock_flip
+Rotate by 90 degrees clockwise and vertically flip.
+
+@item reversal
+Rotate by 180 degrees.
+
+@item hflip
+Flip the input video horizontally.
+
+@item vflip
+Flip the input video vertically.
+
+@end table
+
+@item passthrough
+Do not apply the transposition if the input geometry matches the one
+specified by the specified value. It accepts the following values:
+@table @samp
+@item none
+Always apply transposition. (default)
+@item portrait
+Preserve portrait geometry (when @var{height} >= @var{width}).
+@item landscape
+Preserve landscape geometry (when @var{width} >= @var{height}).
+@end table
+
+@end table
+
 @section trim
 Trim the input so that the output contains one continuous subpart of the input.
 
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index dc5c083f013..cead9f6d25f 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -549,6 +549,7 @@ OBJS-$(CONFIG_TONEMAP_OPENCL_FILTER)         += 
vf_tonemap_opencl.o opencl.o \
 OBJS-$(CONFIG_TONEMAP_VAAPI_FILTER)          += vf_tonemap_vaapi.o vaapi_vpp.o
 OBJS-$(CONFIG_TPAD_FILTER)                   += vf_tpad.o
 OBJS-$(CONFIG_TRANSPOSE_FILTER)              += vf_transpose.o
+OBJS-$(CONFIG_TRANSPOSE_D3D12_FILTER)        += vf_scale_d3d12.o scale_eval.o
 OBJS-$(CONFIG_TRANSPOSE_CUDA_FILTER)         += vf_transpose_cuda.o 
vf_transpose_cuda.ptx.o \
                                                 cuda/load_helper.o
 OBJS-$(CONFIG_TRANSPOSE_OPENCL_FILTER)       += vf_transpose_opencl.o opencl.o 
opencl/transpose.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index 9f07bf83dce..591acfe1966 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -516,6 +516,7 @@ extern const FFFilter ff_vf_tonemap_opencl;
 extern const FFFilter ff_vf_tonemap_vaapi;
 extern const FFFilter ff_vf_tpad;
 extern const FFFilter ff_vf_transpose;
+extern const FFFilter ff_vf_transpose_d3d12;
 extern const FFFilter ff_vf_transpose_cuda;
 extern const FFFilter ff_vf_transpose_opencl;
 extern const FFFilter ff_vf_transpose_vaapi;
diff --git a/libavfilter/version.h b/libavfilter/version.h
index 64cd692ab67..537df129cd3 100644
--- a/libavfilter/version.h
+++ b/libavfilter/version.h
@@ -31,7 +31,7 @@
 
 #include "version_major.h"
 
-#define LIBAVFILTER_VERSION_MINOR  12
+#define LIBAVFILTER_VERSION_MINOR  13
 #define LIBAVFILTER_VERSION_MICRO 100
 
 
diff --git a/libavfilter/vf_scale_d3d12.c b/libavfilter/vf_scale_d3d12.c
index e3376e5c24c..6c8deae2e94 100644
--- a/libavfilter/vf_scale_d3d12.c
+++ b/libavfilter/vf_scale_d3d12.c
@@ -31,6 +31,7 @@
 #include "filters.h"
 #include "formats.h"
 #include "scale_eval.h"
+#include "transpose.h"
 #include "video.h"
 
 typedef struct D3D12ScaleCommandAllocator {
@@ -79,6 +80,13 @@ typedef struct ScaleD3D12Context {
     char *h_expr;
     enum AVPixelFormat format;
 
+    /* transpose_d3d12 */
+    int dir;
+    int passthrough;
+    int transpose; ///< the output swaps width and height
+    D3D12_VIDEO_PROCESS_ORIENTATION orientation;
+    D3D12_VIDEO_PROCESS_FEATURE_FLAGS orientation_features;
+
     char *color_matrix_string;
     char *color_transfer_string;
     char *color_primaries_string;
@@ -977,6 +985,13 @@ static int 
scale_d3d12_configure_processor(ScaleD3D12Context *s, AVFilterContext
         return AVERROR(ENOSYS);
     }
 
+    if ((s->process_support.FeatureSupport & s->orientation_features) != 
s->orientation_features) {
+        av_log(ctx, AV_LOG_ERROR, "Rotation or flip not supported on this 
device\n");
+        release_d3d12_resources(s, ctx);
+
+        return AVERROR(ENOSYS);
+    }
+
     int want_alpha_passthrough = s->input_has_alpha && s->output_has_alpha;
     if (want_alpha_passthrough &&
         !(s->process_support.FeatureSupport & 
D3D12_VIDEO_PROCESS_FEATURE_FLAG_ALPHA_FILL)) {
@@ -1007,7 +1022,7 @@ static int 
scale_d3d12_configure_processor(ScaleD3D12Context *s, AVFilterContext
         .StereoFormat           = D3D12_VIDEO_FRAME_STEREO_FORMAT_NONE,
         .FieldType              = D3D12_VIDEO_FIELD_TYPE_NONE,
         .DeinterlaceMode        = D3D12_VIDEO_PROCESS_DEINTERLACE_FLAG_NONE,
-        .EnableOrientation      = FALSE,
+        .EnableOrientation      = s->orientation != 
D3D12_VIDEO_PROCESS_ORIENTATION_DEFAULT,
         .FilterFlags            = D3D12_VIDEO_PROCESS_FILTER_FLAG_NONE,
         .SourceSizeRange        = {
             .MaxWidth  = s->input_width,
@@ -1129,6 +1144,9 @@ static int scale_d3d12_filter_frame(AVFilterLink *inlink, 
AVFrame *in)
         return AVERROR(EINVAL);
     }
 
+    if (s->passthrough)
+        return ff_filter_frame(outlink, in);
+
     if (!in->hw_frames_ctx) {
         av_log(ctx, AV_LOG_ERROR, "No hardware frames context in input 
frame\n");
         av_frame_free(&in);
@@ -1451,7 +1469,7 @@ static int scale_d3d12_filter_frame(AVFilterLink *inlink, 
AVFrame *in)
     input_args.Transform.SourceRectangle.bottom      = in->crop_top  + src_h;
     input_args.Transform.DestinationRectangle.right  = s->width;
     input_args.Transform.DestinationRectangle.bottom = s->height;
-    input_args.Transform.Orientation = D3D12_VIDEO_PROCESS_ORIENTATION_DEFAULT;
+    input_args.Transform.Orientation = s->orientation;
 
     input_args.Flags = D3D12_VIDEO_PROCESS_INPUT_STREAM_FLAG_NONE;
 
@@ -1575,10 +1593,19 @@ static int scale_d3d12_filter_frame(AVFilterLink 
*inlink, AVFrame *in)
     out->format = AV_PIX_FMT_D3D12;
     out->crop_left = out->crop_right = out->crop_top = out->crop_bottom = 0;
 
+    AVRational sar = in->sample_aspect_ratio;
+    if (s->transpose) {
+        /* Compare the output with the source rectangle as it lands on it */
+        FFSWAP(int, src_w, src_h);
+        if (sar.num)
+            sar = av_inv_q(sar);
+        out->sample_aspect_ratio = sar;
+    }
+
     if (out->width != src_w || out->height != src_h)
         av_reduce(&out->sample_aspect_ratio.num, &out->sample_aspect_ratio.den,
-                 (int64_t)in->sample_aspect_ratio.num * out->height * src_w,
-                 (int64_t)in->sample_aspect_ratio.den * out->width * src_h,
+                 (int64_t)sar.num * out->height * src_w,
+                 (int64_t)sar.den * out->width * src_h,
                  INT_MAX);
 
     if (out->width != in_width || out->height != in_height ||
@@ -1669,7 +1696,8 @@ fail:
     return ret;
 }
 
-static int scale_d3d12_config_props(AVFilterLink *outlink)
+/* Sets up the output link for s->width x s->height. */
+static int scale_d3d12_config_output(AVFilterLink *outlink)
 {
     AVFilterContext *ctx = outlink->src;
     ScaleD3D12Context *s = ctx->priv;
@@ -1688,17 +1716,6 @@ static int scale_d3d12_config_props(AVFilterLink 
*outlink)
     av_buffer_unref(&s->hw_frames_ctx_out);
     av_buffer_unref(&s->hw_device_ctx);
 
-    ret = ff_scale_eval_dimensions(s, s->w_expr, s->h_expr, inlink, outlink, 
&s->width, &s->height);
-    if (ret < 0) {
-        av_log(ctx, AV_LOG_ERROR, "Failed to evaluate dimensions\n");
-        return ret;
-    }
-
-    /* Adjust dimensions to meet codec/hardware alignment requirements */
-    ret = ff_scale_adjust_dimensions(inlink, &s->width, &s->height, 0, 1, 1.f);
-    if (ret < 0)
-        return ret;
-
     outlink->w = s->width;
     outlink->h = s->height;
 
@@ -1808,6 +1825,27 @@ static int scale_d3d12_config_props(AVFilterLink 
*outlink)
     return 0;
 }
 
+static int scale_d3d12_config_props(AVFilterLink *outlink)
+{
+    AVFilterContext *ctx = outlink->src;
+    ScaleD3D12Context *s = ctx->priv;
+    AVFilterLink *inlink = ctx->inputs[0];
+    int ret;
+
+    ret = ff_scale_eval_dimensions(s, s->w_expr, s->h_expr, inlink, outlink, 
&s->width, &s->height);
+    if (ret < 0) {
+        av_log(ctx, AV_LOG_ERROR, "Failed to evaluate dimensions\n");
+        return ret;
+    }
+
+    /* Adjust dimensions to meet codec/hardware alignment requirements */
+    ret = ff_scale_adjust_dimensions(inlink, &s->width, &s->height, 0, 1, 1.f);
+    if (ret < 0)
+        return ret;
+
+    return scale_d3d12_config_output(outlink);
+}
+
 static av_cold void scale_d3d12_uninit(AVFilterContext *ctx) {
     ScaleD3D12Context *s = ctx->priv;
 
@@ -1953,3 +1991,101 @@ const FFFilter ff_vf_scale_d3d12 = {
     .p.flags          = AVFILTER_FLAG_HWDEVICE,
     .flags_internal   = FF_FILTER_FLAG_HWFRAME_AWARE,
 };
+
+#define ROTATION D3D12_VIDEO_PROCESS_FEATURE_FLAG_ROTATION
+#define FLIP     D3D12_VIDEO_PROCESS_FEATURE_FLAG_FLIP
+static const struct {
+    D3D12_VIDEO_PROCESS_ORIENTATION orientation;
+    D3D12_VIDEO_PROCESS_FEATURE_FLAGS features;
+} transpose_d3d12_dirs[] = {
+    [TRANSPOSE_CCLOCK_FLIP] = { 
D3D12_VIDEO_PROCESS_ORIENTATION_CLOCKWISE_90_FLIP_HORIZONTAL,  ROTATION | FLIP 
},
+    [TRANSPOSE_CLOCK]       = { D3D12_VIDEO_PROCESS_ORIENTATION_CLOCKWISE_90,  
                ROTATION },
+    [TRANSPOSE_CCLOCK]      = { D3D12_VIDEO_PROCESS_ORIENTATION_CLOCKWISE_270, 
                ROTATION },
+    [TRANSPOSE_CLOCK_FLIP]  = { 
D3D12_VIDEO_PROCESS_ORIENTATION_CLOCKWISE_270_FLIP_HORIZONTAL, ROTATION | FLIP 
},
+    [TRANSPOSE_REVERSAL]    = { D3D12_VIDEO_PROCESS_ORIENTATION_CLOCKWISE_180, 
                ROTATION },
+    [TRANSPOSE_HFLIP]       = { 
D3D12_VIDEO_PROCESS_ORIENTATION_FLIP_HORIZONTAL,               FLIP },
+    [TRANSPOSE_VFLIP]       = { D3D12_VIDEO_PROCESS_ORIENTATION_FLIP_VERTICAL, 
                FLIP },
+};
+#undef ROTATION
+#undef FLIP
+
+static av_cold int transpose_d3d12_init(AVFilterContext *ctx)
+{
+    ScaleD3D12Context *s = ctx->priv;
+
+    s->format               = AV_PIX_FMT_NONE;
+    s->transpose            = s->dir <= TRANSPOSE_CLOCK_FLIP;
+    s->orientation          = transpose_d3d12_dirs[s->dir].orientation;
+    s->orientation_features = transpose_d3d12_dirs[s->dir].features;
+
+    return scale_d3d12_init(ctx);
+}
+
+static int transpose_d3d12_config_props(AVFilterLink *outlink)
+{
+    AVFilterContext *ctx = outlink->src;
+    ScaleD3D12Context *s = ctx->priv;
+    AVFilterLink *inlink = ctx->inputs[0];
+    int ret;
+
+    if ((inlink->w >= inlink->h && s->passthrough == 
TRANSPOSE_PT_TYPE_LANDSCAPE) ||
+        (inlink->w <= inlink->h && s->passthrough == 
TRANSPOSE_PT_TYPE_PORTRAIT)) {
+        FilterLink *outl = ff_filter_link(outlink);
+
+        outl->hw_frames_ctx = 
av_buffer_ref(ff_filter_link(inlink)->hw_frames_ctx);
+        return outl->hw_frames_ctx ? 0 : AVERROR(ENOMEM);
+    }
+    s->passthrough = TRANSPOSE_PT_TYPE_NONE;
+
+    s->width  = s->transpose ? inlink->h : inlink->w;
+    s->height = s->transpose ? inlink->w : inlink->h;
+
+    ret = scale_d3d12_config_output(outlink);
+    if (ret >= 0 && s->transpose && inlink->sample_aspect_ratio.num)
+        outlink->sample_aspect_ratio = av_inv_q(inlink->sample_aspect_ratio);
+
+    return ret;
+}
+
+static const AVFilterPad transpose_d3d12_outputs[] = {
+    {
+        .name         = "default",
+        .type         = AVMEDIA_TYPE_VIDEO,
+        .config_props = transpose_d3d12_config_props,
+    },
+};
+
+static const AVOption transpose_d3d12_options[] = {
+    { "dir", "set transpose direction", OFFSET(dir), AV_OPT_TYPE_INT, { .i64 = 
TRANSPOSE_CCLOCK_FLIP }, 0, 6, FLAGS, .unit = "dir" },
+        { "cclock_flip",   "rotate counter-clockwise with vertical flip", 0, 
AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_CCLOCK_FLIP }, .flags=FLAGS, .unit = 
"dir" },
+        { "clock",         "rotate clockwise",                            0, 
AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_CLOCK       }, .flags=FLAGS, .unit = 
"dir" },
+        { "cclock",        "rotate counter-clockwise",                    0, 
AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_CCLOCK      }, .flags=FLAGS, .unit = 
"dir" },
+        { "clock_flip",    "rotate clockwise with vertical flip",         0, 
AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_CLOCK_FLIP  }, .flags=FLAGS, .unit = 
"dir" },
+        { "reversal",      "rotate by half-turn",                         0, 
AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_REVERSAL    }, .flags=FLAGS, .unit = 
"dir" },
+        { "hflip",         "flip horizontally",                           0, 
AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_HFLIP       }, .flags=FLAGS, .unit = 
"dir" },
+        { "vflip",         "flip vertically",                             0, 
AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_VFLIP       }, .flags=FLAGS, .unit = 
"dir" },
+
+    { "passthrough", "do not apply transposition if the input matches the 
specified geometry",
+      OFFSET(passthrough), AV_OPT_TYPE_INT, {.i64=TRANSPOSE_PT_TYPE_NONE},  0, 
INT_MAX, FLAGS, .unit = "passthrough" },
+        { "none",      "always apply transposition",   0, AV_OPT_TYPE_CONST, 
{.i64=TRANSPOSE_PT_TYPE_NONE},      INT_MIN, INT_MAX, FLAGS, .unit = 
"passthrough" },
+        { "portrait",  "preserve portrait geometry",   0, AV_OPT_TYPE_CONST, 
{.i64=TRANSPOSE_PT_TYPE_PORTRAIT},  INT_MIN, INT_MAX, FLAGS, .unit = 
"passthrough" },
+        { "landscape", "preserve landscape geometry",  0, AV_OPT_TYPE_CONST, 
{.i64=TRANSPOSE_PT_TYPE_LANDSCAPE}, INT_MIN, INT_MAX, FLAGS, .unit = 
"passthrough" },
+
+    { NULL }
+};
+
+AVFILTER_DEFINE_CLASS(transpose_d3d12);
+
+const FFFilter ff_vf_transpose_d3d12 = {
+    .p.name           = "transpose_d3d12",
+    .p.description    = NULL_IF_CONFIG_SMALL("Transpose video using 
Direct3D12"),
+    .priv_size        = sizeof(ScaleD3D12Context),
+    .p.priv_class     = &transpose_d3d12_class,
+    .init             = transpose_d3d12_init,
+    .uninit           = scale_d3d12_uninit,
+    FILTER_INPUTS(scale_d3d12_inputs),
+    FILTER_OUTPUTS(transpose_d3d12_outputs),
+    FILTER_QUERY_FUNC2(scale_d3d12_query_formats),
+    .p.flags          = AVFILTER_FLAG_HWDEVICE,
+    .flags_internal   = FF_FILTER_FLAG_HWFRAME_AWARE,
+};
-- 
2.54.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to