FFmpeg
vf_scale_d3d11.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2025 MulticorewWare, Inc.
3  *
4  * Authors: Dash Santosh <dash.sathanatayanan@multicorewareinc.com>
5  * Sachin <sachin.prakash@multicorewareinc.com>
6  *
7  * This file is part of FFmpeg.
8  *
9  * FFmpeg is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * FFmpeg is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with FFmpeg; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22  */
23 
24 #include "libavutil/opt.h"
25 #include "libavutil/pixdesc.h"
26 #include "compat/w32dlfcn.h"
27 
28 #include <initguid.h>
29 #include "libavutil/hwcontext.h"
31 
32 #include "filters.h"
33 #include "scale_eval.h"
34 #include "video.h"
35 
36 typedef struct ScaleD3D11Context {
37  const AVClass *classCtx;
38  char *w_expr;
39  char *h_expr;
41 
42  ///< D3D11 objects
44  ID3D11DeviceContext *context;
45  ID3D11VideoDevice *videoDevice;
46  ID3D11VideoProcessor *processor;
47  ID3D11VideoProcessorEnumerator *enumerator;
48  ID3D11VideoProcessorOutputView *outputView;
49  ID3D11VideoProcessorInputView *inputView;
50 
51  ///< Buffer references
54 
55  ///< Dimensions and formats
56  int width, height;
58  DXGI_FORMAT input_format;
59  DXGI_FORMAT output_format;
61 
63  ///< all real work is done in config_props and filter_frame
64  return 0;
65 }
66 
68  if (s->outputView) {
69  s->outputView->lpVtbl->Release(s->outputView);
70  s->outputView = NULL;
71  }
72 
73  if (s->processor) {
74  s->processor->lpVtbl->Release(s->processor);
75  s->processor = NULL;
76  }
77 
78  if (s->enumerator) {
79  s->enumerator->lpVtbl->Release(s->enumerator);
80  s->enumerator = NULL;
81  }
82 
83  if (s->videoDevice) {
84  s->videoDevice->lpVtbl->Release(s->videoDevice);
85  s->videoDevice = NULL;
86  }
87 }
88 
90  HRESULT hr;
91 
92  switch (s->format) {
93  case AV_PIX_FMT_NV12:
94  s->output_format = DXGI_FORMAT_NV12;
95  break;
96  case AV_PIX_FMT_P010:
97  s->output_format = DXGI_FORMAT_P010;
98  break;
99  default:
100  av_log(ctx, AV_LOG_ERROR, "Invalid output format specified\n");
101  return AVERROR(EINVAL);
102  }
103 
104  ///< Get D3D11 device and context from hardware device context
105  AVHWDeviceContext *hwctx = (AVHWDeviceContext *)s->hw_device_ctx->data;
106  AVD3D11VADeviceContext *d3d11_hwctx = (AVD3D11VADeviceContext *)hwctx->hwctx;
107  s->device = d3d11_hwctx->device;
108  s->context = d3d11_hwctx->device_context;
109 
110  av_log(ctx, AV_LOG_VERBOSE, "Configuring D3D11 video processor: %dx%d -> %dx%d\n",
111  s->inputWidth, s->inputHeight, s->width, s->height);
112 
113  ///< Define the video processor content description
114  D3D11_VIDEO_PROCESSOR_CONTENT_DESC contentDesc = {
115  .InputFrameFormat = D3D11_VIDEO_FRAME_FORMAT_PROGRESSIVE,
116  .InputWidth = s->inputWidth,
117  .InputHeight = s->inputHeight,
118  .OutputWidth = s->width,
119  .OutputHeight = s->height,
120  .Usage = D3D11_VIDEO_USAGE_PLAYBACK_NORMAL,
121  };
122 
123  ///< Query video device interface
124  hr = s->device->lpVtbl->QueryInterface(s->device, &IID_ID3D11VideoDevice, (void **)&s->videoDevice);
125  if (FAILED(hr)) {
126  av_log(ctx, AV_LOG_ERROR, "Failed to get D3D11 video device interface: HRESULT 0x%lX\n", hr);
127  return AVERROR_EXTERNAL;
128  }
129 
130  ///< Create video processor enumerator
131  hr = s->videoDevice->lpVtbl->CreateVideoProcessorEnumerator(s->videoDevice, &contentDesc, &s->enumerator);
132  if (FAILED(hr)) {
133  av_log(ctx, AV_LOG_ERROR, "Failed to create video processor enumerator: HRESULT 0x%lX\n", hr);
134  return AVERROR_EXTERNAL;
135  }
136 
137  ///< Create the video processor
138  hr = s->videoDevice->lpVtbl->CreateVideoProcessor(s->videoDevice, s->enumerator, 0, &s->processor);
139  if (FAILED(hr)) {
140  av_log(ctx, AV_LOG_ERROR, "Failed to create video processor: HRESULT 0x%lX\n", hr);
141  return AVERROR_EXTERNAL;
142  }
143 
144  av_log(ctx, AV_LOG_VERBOSE, "D3D11 video processor successfully configured\n");
145  return 0;
146 }
147 
149 {
150  AVFilterContext *ctx = inlink->dst;
151  ScaleD3D11Context *s = ctx->priv;
152  AVFilterLink *outlink = ctx->outputs[0];
153  ID3D11VideoProcessorInputView *inputView = NULL;
154  ID3D11VideoContext *videoContext = NULL;
155  AVFrame *out = NULL;
156  int ret = 0;
157  HRESULT hr;
158 
159  ///< Validate input frame
160  if (!in) {
161  av_log(ctx, AV_LOG_ERROR, "Null input frame\n");
162  return AVERROR(EINVAL);
163  }
164 
165  if (!in->hw_frames_ctx) {
166  av_log(ctx, AV_LOG_ERROR, "No hardware frames context in input frame\n");
167  av_frame_free(&in);
168  return AVERROR(EINVAL);
169  }
170 
171  ///< Verify hardware device contexts
173 
174  if (!s->hw_device_ctx) {
175  av_log(ctx, AV_LOG_ERROR, "Filter hardware device context is uninitialized\n");
176  av_frame_free(&in);
177  return AVERROR(EINVAL);
178  }
179 
180  AVHWDeviceContext *input_device_ctx = (AVHWDeviceContext *)frames_ctx->device_ref->data;
181  AVHWDeviceContext *filter_device_ctx = (AVHWDeviceContext *)s->hw_device_ctx->data;
182 
183  if (input_device_ctx->type != filter_device_ctx->type) {
184  av_log(ctx, AV_LOG_ERROR, "Mismatch between input and filter hardware device types\n");
185  av_frame_free(&in);
186  return AVERROR(EINVAL);
187  }
188 
189  ///< Allocate output frame
190  out = av_frame_alloc();
191  if (!out) {
192  av_log(ctx, AV_LOG_ERROR, "Failed to allocate output frame\n");
193  av_frame_free(&in);
194  return AVERROR(ENOMEM);
195  }
196 
197  ret = av_hwframe_get_buffer(s->hw_frames_ctx_out, out, 0);
198  if (ret < 0) {
199  av_log(ctx, AV_LOG_ERROR, "Failed to get output frame from pool\n");
200  goto fail;
201  }
202 
203  ///< Configure the D3D11 video processor if not already configured
204  if (!s->processor) {
205  ///< Get info from input texture
206  D3D11_TEXTURE2D_DESC textureDesc;
207  ID3D11Texture2D *input_texture = (ID3D11Texture2D *)in->data[0];
208  input_texture->lpVtbl->GetDesc(input_texture, &textureDesc);
209 
210  s->inputWidth = textureDesc.Width;
211  s->inputHeight = textureDesc.Height;
212  s->input_format = textureDesc.Format;
213 
215  if (ret < 0) {
216  av_log(ctx, AV_LOG_ERROR, "Failed to configure processor\n");
217  goto fail;
218  }
219  }
220 
221  ///< Get input texture and prepare input view
222  ID3D11Texture2D *d3d11_texture = (ID3D11Texture2D *)in->data[0];
223  int subIdx = (int)(intptr_t)in->data[1];
224 
225  D3D11_VIDEO_PROCESSOR_INPUT_VIEW_DESC inputViewDesc = {
226  .FourCC = s->input_format,
227  .ViewDimension = D3D11_VPIV_DIMENSION_TEXTURE2D,
228  .Texture2D.ArraySlice = subIdx
229  };
230 
231  hr = s->videoDevice->lpVtbl->CreateVideoProcessorInputView(
232  s->videoDevice, (ID3D11Resource *)d3d11_texture, s->enumerator, &inputViewDesc, &inputView);
233  if (FAILED(hr)) {
234  av_log(ctx, AV_LOG_ERROR, "Failed to create input view: HRESULT 0x%lX\n", hr);
236  goto fail;
237  }
238 
239  ///< Create output view for current texture
240  ID3D11Texture2D *output_texture = (ID3D11Texture2D *)out->data[0];
241  D3D11_VIDEO_PROCESSOR_OUTPUT_VIEW_DESC outputViewDesc = {
242  .ViewDimension = D3D11_VPOV_DIMENSION_TEXTURE2D,
243  .Texture2D = { .MipSlice = 0 },
244  };
245 
246  hr = s->videoDevice->lpVtbl->CreateVideoProcessorOutputView(
247  s->videoDevice, (ID3D11Resource *)output_texture, s->enumerator, &outputViewDesc, &s->outputView);
248  if (FAILED(hr)) {
249  av_log(ctx, AV_LOG_ERROR, "Failed to create output view: HRESULT 0x%lX\n", hr);
251  goto fail;
252  }
253 
254  ///< Set up processing stream
255  D3D11_VIDEO_PROCESSOR_STREAM stream = {
256  .Enable = TRUE,
257  .pInputSurface = inputView,
258  .OutputIndex = 0
259  };
260 
261  ///< Get video context
262  hr = s->context->lpVtbl->QueryInterface(s->context, &IID_ID3D11VideoContext, (void **)&videoContext);
263  if (FAILED(hr)) {
264  av_log(ctx, AV_LOG_ERROR, "Failed to get video context: HRESULT 0x%lX\n", hr);
266  goto fail;
267  }
268 
269  ///< Process the frame
270  hr = videoContext->lpVtbl->VideoProcessorBlt(videoContext, s->processor, s->outputView, 0, 1, &stream);
271  if (FAILED(hr)) {
272  av_log(ctx, AV_LOG_ERROR, "VideoProcessorBlt failed: HRESULT 0x%lX\n", hr);
274  goto fail;
275  }
276 
277  ///< Set up output frame
278  ret = av_frame_copy_props(out, in);
279  if (ret < 0) {
280  av_log(ctx, AV_LOG_ERROR, "Failed to copy frame properties\n");
281  goto fail;
282  }
283 
284  out->data[0] = (uint8_t *)output_texture;
285  out->data[1] = (uint8_t *)(intptr_t)0;
286  out->width = s->width;
287  out->height = s->height;
288  out->format = AV_PIX_FMT_D3D11;
289 
290  ///< Clean up resources
291  inputView->lpVtbl->Release(inputView);
292  videoContext->lpVtbl->Release(videoContext);
293  if (s->outputView) {
294  s->outputView->lpVtbl->Release(s->outputView);
295  s->outputView = NULL;
296  }
297  av_frame_free(&in);
298 
299  ///< Forward the frame
300  return ff_filter_frame(outlink, out);
301 
302 fail:
303  if (inputView)
304  inputView->lpVtbl->Release(inputView);
305  if (videoContext)
306  videoContext->lpVtbl->Release(videoContext);
307  if (s->outputView) {
308  s->outputView->lpVtbl->Release(s->outputView);
309  s->outputView = NULL;
310  }
311  av_frame_free(&in);
312  av_frame_free(&out);
313  return ret;
314 }
315 
317 {
318  AVFilterContext *ctx = outlink->src;
319  ScaleD3D11Context *s = ctx->priv;
320  AVFilterLink *inlink = ctx->inputs[0];
322  FilterLink *outl = ff_filter_link(outlink);
323  int ret;
324 
325  ///< Clean up any previous resources
327 
328  ///< Evaluate output dimensions
329  ret = ff_scale_eval_dimensions(s, s->w_expr, s->h_expr, inlink, outlink, &s->width, &s->height);
330  if (ret < 0) {
331  av_log(ctx, AV_LOG_ERROR, "Failed to evaluate dimensions\n");
332  return ret;
333  }
334 
335  outlink->w = s->width;
336  outlink->h = s->height;
337 
338  ///< Validate input hw_frames_ctx
339  if (!inl->hw_frames_ctx) {
340  av_log(ctx, AV_LOG_ERROR, "No hw_frames_ctx available on input link\n");
341  return AVERROR(EINVAL);
342  }
343 
344  ///< Propagate hw_frames_ctx to output
346  if (!outl->hw_frames_ctx) {
347  av_log(ctx, AV_LOG_ERROR, "Failed to propagate hw_frames_ctx to output\n");
348  return AVERROR(ENOMEM);
349  }
350 
351  ///< Initialize filter's hardware device context
352  if (!s->hw_device_ctx) {
353  AVHWFramesContext *in_frames_ctx = (AVHWFramesContext *)inl->hw_frames_ctx->data;
354  s->hw_device_ctx = av_buffer_ref(in_frames_ctx->device_ref);
355  if (!s->hw_device_ctx) {
356  av_log(ctx, AV_LOG_ERROR, "Failed to initialize filter hardware device context\n");
357  return AVERROR(ENOMEM);
358  }
359  }
360 
361  ///< Get D3D11 device and context (but don't initialize processor yet - done in filter_frame)
362  AVHWDeviceContext *hwctx = (AVHWDeviceContext *)s->hw_device_ctx->data;
363  AVD3D11VADeviceContext *d3d11_hwctx = (AVD3D11VADeviceContext *)hwctx->hwctx;
364 
365  s->device = d3d11_hwctx->device;
366  s->context = d3d11_hwctx->device_context;
367 
368  if (!s->device || !s->context) {
369  av_log(ctx, AV_LOG_ERROR, "Failed to get valid D3D11 device or context\n");
370  return AVERROR(EINVAL);
371  }
372 
373  ///< Create new hardware frames context for output
374  s->hw_frames_ctx_out = av_hwframe_ctx_alloc(s->hw_device_ctx);
375  if (!s->hw_frames_ctx_out)
376  return AVERROR(ENOMEM);
377 
378  AVHWFramesContext *frames_ctx = (AVHWFramesContext *)s->hw_frames_ctx_out->data;
379  frames_ctx->format = AV_PIX_FMT_D3D11;
380  frames_ctx->sw_format = s->format;
381  frames_ctx->width = s->width;
382  frames_ctx->height = s->height;
383  frames_ctx->initial_pool_size = 10;
384 
385  if (ctx->extra_hw_frames > 0)
386  frames_ctx->initial_pool_size += ctx->extra_hw_frames;
387 
388  AVD3D11VAFramesContext *frames_hwctx = frames_ctx->hwctx;
389  frames_hwctx->MiscFlags = 0;
390  frames_hwctx->BindFlags = D3D11_BIND_RENDER_TARGET | D3D11_BIND_VIDEO_ENCODER;
391 
392  ret = av_hwframe_ctx_init(s->hw_frames_ctx_out);
393  if (ret < 0) {
394  av_buffer_unref(&s->hw_frames_ctx_out);
395  return ret;
396  }
397 
398  outl->hw_frames_ctx = av_buffer_ref(s->hw_frames_ctx_out);
399  if (!outl->hw_frames_ctx)
400  return AVERROR(ENOMEM);
401 
402  av_log(ctx, AV_LOG_VERBOSE, "D3D11 scale config: %dx%d -> %dx%d\n",
403  inlink->w, inlink->h, outlink->w, outlink->h);
404  return 0;
405 }
406 
408  ScaleD3D11Context *s = ctx->priv;
409 
410  ///< Release D3D11 resources
412 
413  ///< Free the hardware device context reference
414  av_buffer_unref(&s->hw_frames_ctx_out);
415  av_buffer_unref(&s->hw_device_ctx);
416 
417  ///< Free option strings
418  av_freep(&s->w_expr);
419  av_freep(&s->h_expr);
420 }
421 
422 static const AVFilterPad scale_d3d11_inputs[] = {
423  {
424  .name = "default",
425  .type = AVMEDIA_TYPE_VIDEO,
426  .filter_frame = scale_d3d11_filter_frame,
427  },
428 };
429 
431  {
432  .name = "default",
433  .type = AVMEDIA_TYPE_VIDEO,
434  .config_props = scale_d3d11_config_props,
435  },
436 };
437 
438 #define OFFSET(x) offsetof(ScaleD3D11Context, x)
439 #define FLAGS (AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
440 
441 static const AVOption scale_d3d11_options[] = {
442  { "width", "Output video width", OFFSET(w_expr), AV_OPT_TYPE_STRING, {.str = "iw"}, .flags = FLAGS },
443  { "height", "Output video height", OFFSET(h_expr), AV_OPT_TYPE_STRING, {.str = "ih"}, .flags = FLAGS },
444  { "format", "Output video pixel format", OFFSET(format), AV_OPT_TYPE_PIXEL_FMT, { .i64 = AV_PIX_FMT_NONE }, INT_MIN, INT_MAX, .flags=FLAGS },
445  { NULL }
446 };
447 
448 AVFILTER_DEFINE_CLASS(scale_d3d11);
449 
451  .p.name = "scale_d3d11",
452  .p.description = NULL_IF_CONFIG_SMALL("Scale video using Direct3D11"),
453  .priv_size = sizeof(ScaleD3D11Context),
454  .p.priv_class = &scale_d3d11_class,
455  .init = scale_d3d11_init,
456  .uninit = scale_d3d11_uninit,
460  .p.flags = AVFILTER_FLAG_HWDEVICE,
461  .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
462 };
ScaleD3D11Context
Definition: vf_scale_d3d11.c:36
AVHWDeviceContext::hwctx
void * hwctx
The format-specific data, allocated and freed by libavutil along with this context.
Definition: hwcontext.h:88
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
scale_d3d11_options
static const AVOption scale_d3d11_options[]
Definition: vf_scale_d3d11.c:441
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
opt.h
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(scale_d3d11)
out
static FILE * out
Definition: movenc.c:55
ScaleD3D11Context::output_format
DXGI_FORMAT output_format
Definition: vf_scale_d3d11.c:59
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1068
AVBufferRef::data
uint8_t * data
The data buffer.
Definition: buffer.h:90
AVHWFramesContext::format
enum AVPixelFormat format
The pixel format identifying the underlying HW surface type.
Definition: hwcontext.h:200
av_cold
#define av_cold
Definition: attributes.h:119
inlink
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
Definition: filter_design.txt:212
FF_FILTER_FLAG_HWFRAME_AWARE
#define FF_FILTER_FLAG_HWFRAME_AWARE
The filter is aware of hardware frames, and any hardware frame context should not be automatically pr...
Definition: filters.h:208
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:64
av_hwframe_ctx_init
int av_hwframe_ctx_init(AVBufferRef *ref)
Finalize the context before use.
Definition: hwcontext.c:337
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:466
pixdesc.h
AVD3D11VAFramesContext::MiscFlags
UINT MiscFlags
D3D11_TEXTURE2D_DESC.MiscFlags used for texture creation.
Definition: hwcontext_d3d11va.h:180
av_hwframe_ctx_alloc
AVBufferRef * av_hwframe_ctx_alloc(AVBufferRef *device_ref_in)
Allocate an AVHWFramesContext tied to a given device context.
Definition: hwcontext.c:263
AVOption
AVOption.
Definition: opt.h:428
FILTER_SINGLE_PIXFMT
#define FILTER_SINGLE_PIXFMT(pix_fmt_)
Definition: filters.h:254
scale_d3d11_filter_frame
static int scale_d3d11_filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: vf_scale_d3d11.c:148
filters.h
AV_LOG_VERBOSE
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:226
ff_scale_eval_dimensions
int ff_scale_eval_dimensions(void *log_ctx, const char *w_expr, const char *h_expr, AVFilterLink *inlink, AVFilterLink *outlink, int *ret_w, int *ret_h)
Parse and evaluate string expressions for width and height.
Definition: scale_eval.c:58
av_buffer_ref
AVBufferRef * av_buffer_ref(const AVBufferRef *buf)
Create a new reference to an AVBuffer.
Definition: buffer.c:103
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:219
AVHWFramesContext::width
int width
The allocated dimensions of the frames in this pool.
Definition: hwcontext.h:220
video.h
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:487
scale_d3d11_init
static av_cold int scale_d3d11_init(AVFilterContext *ctx)
Definition: vf_scale_d3d11.c:62
AVD3D11VAFramesContext::BindFlags
UINT BindFlags
D3D11_TEXTURE2D_DESC.BindFlags used for texture creation.
Definition: hwcontext_d3d11va.h:174
OFFSET
#define OFFSET(x)
Definition: vf_scale_d3d11.c:438
ScaleD3D11Context::device
ID3D11Device * device
Definition: vf_scale_d3d11.c:43
ScaleD3D11Context::classCtx
const AVClass * classCtx
Definition: vf_scale_d3d11.c:37
AVFilterPad
A filter pad used for either input or output.
Definition: filters.h:40
AVHWDeviceContext
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e.
Definition: hwcontext.h:63
ScaleD3D11Context::input_format
DXGI_FORMAT input_format
Definition: vf_scale_d3d11.c:58
av_frame_alloc
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Definition: frame.c:52
scale_d3d11_configure_processor
static int scale_d3d11_configure_processor(ScaleD3D11Context *s, AVFilterContext *ctx)
Definition: vf_scale_d3d11.c:89
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:210
scale_d3d11_outputs
static const AVFilterPad scale_d3d11_outputs[]
Definition: vf_scale_d3d11.c:430
AVHWFramesContext::height
int height
Definition: hwcontext.h:220
FFFilter
Definition: filters.h:267
ScaleD3D11Context::processor
ID3D11VideoProcessor * processor
Definition: vf_scale_d3d11.c:46
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: filters.h:265
ScaleD3D11Context::context
ID3D11DeviceContext * context
Definition: vf_scale_d3d11.c:44
ff_filter_link
static FilterLink * ff_filter_link(AVFilterLink *link)
Definition: filters.h:199
ScaleD3D11Context::format
enum AVPixelFormat format
D3D11 objects.
Definition: vf_scale_d3d11.c:40
ctx
static AVFormatContext * ctx
Definition: movenc.c:49
if
if(ret)
Definition: filter_design.txt:179
fail
#define fail
Definition: test.h:478
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:76
NULL
#define NULL
Definition: coverity.c:32
AVHWFramesContext::sw_format
enum AVPixelFormat sw_format
The pixel format identifying the actual data layout of the hardware frames.
Definition: hwcontext.h:213
av_frame_copy_props
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition: frame.c:599
format
New swscale design to change SwsGraph is what coordinates multiple passes These can include cascaded scaling error diffusion and so on Or we could have separate passes for the vertical and horizontal scaling In between each SwsPass lies a fully allocated image buffer Graph passes may have different levels of e g we can have a single threaded error diffusion pass following a multi threaded scaling pass SwsGraph is internally recreated whenever the image format
Definition: swscale-v2.txt:14
av_buffer_unref
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
Definition: buffer.c:139
AVHWFramesContext::device_ref
AVBufferRef * device_ref
A reference to the parent AVHWDeviceContext.
Definition: hwcontext.h:129
ScaleD3D11Context::videoDevice
ID3D11VideoDevice * videoDevice
Definition: vf_scale_d3d11.c:45
ff_vf_scale_d3d11
const FFFilter ff_vf_scale_d3d11
Definition: vf_scale_d3d11.c:450
AVD3D11VAFramesContext
This struct is allocated as AVHWFramesContext.hwctx.
Definition: hwcontext_d3d11va.h:145
scale_d3d11_uninit
static av_cold void scale_d3d11_uninit(AVFilterContext *ctx)
Definition: vf_scale_d3d11.c:407
scale_d3d11_config_props
static int scale_d3d11_config_props(AVFilterLink *outlink)
Definition: vf_scale_d3d11.c:316
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:88
AVFILTER_FLAG_HWDEVICE
#define AVFILTER_FLAG_HWDEVICE
The filter can create hardware frames using AVFilterContext.hw_device_ctx.
Definition: avfilter.h:187
ScaleD3D11Context::inputHeight
int inputHeight
Definition: vf_scale_d3d11.c:57
scale_eval.h
ScaleD3D11Context::inputWidth
int inputWidth
Definition: vf_scale_d3d11.c:57
AVERROR_EXTERNAL
#define AVERROR_EXTERNAL
Generic error in an external library.
Definition: error.h:59
AV_PIX_FMT_D3D11
@ AV_PIX_FMT_D3D11
Hardware surfaces for Direct3D11.
Definition: pixfmt.h:336
ScaleD3D11Context::w_expr
char * w_expr
Definition: vf_scale_d3d11.c:38
FLAGS
#define FLAGS
Definition: vf_scale_d3d11.c:439
ScaleD3D11Context::height
int height
Definition: vf_scale_d3d11.c:56
AVD3D11VADeviceContext
This struct is allocated as AVHWDeviceContext.hwctx.
Definition: hwcontext_d3d11va.h:45
s
uint8_t s
Definition: llvidencdsp.c:39
ScaleD3D11Context::outputView
ID3D11VideoProcessorOutputView * outputView
Definition: vf_scale_d3d11.c:48
AVFilterPad::name
const char * name
Pad name.
Definition: filters.h:46
ScaleD3D11Context::hw_frames_ctx_out
AVBufferRef * hw_frames_ctx_out
Dimensions and formats.
Definition: vf_scale_d3d11.c:53
AVHWFramesContext
This struct describes a set or pool of "hardware" frames (i.e.
Definition: hwcontext.h:118
ret
ret
Definition: filter_design.txt:187
AVHWDeviceContext::type
enum AVHWDeviceType type
This field identifies the underlying API used for hardware access.
Definition: hwcontext.h:75
AV_PIX_FMT_NV12
@ AV_PIX_FMT_NV12
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
Definition: pixfmt.h:96
AVHWFramesContext::hwctx
void * hwctx
The format-specific data, allocated and freed automatically along with this context.
Definition: hwcontext.h:153
ScaleD3D11Context::width
int width
Definition: vf_scale_d3d11.c:56
ScaleD3D11Context::enumerator
ID3D11VideoProcessorEnumerator * enumerator
Definition: vf_scale_d3d11.c:47
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: filters.h:264
AVFrame::hw_frames_ctx
AVBufferRef * hw_frames_ctx
For hwaccel-format frames, this should be a reference to the AVHWFramesContext describing the frame.
Definition: frame.h:763
release_d3d11_resources
static void release_d3d11_resources(ScaleD3D11Context *s)
Definition: vf_scale_d3d11.c:67
scale_d3d11_inputs
static const AVFilterPad scale_d3d11_inputs[]
Definition: vf_scale_d3d11.c:422
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
ScaleD3D11Context::hw_device_ctx
AVBufferRef * hw_device_ctx
Definition: vf_scale_d3d11.c:52
Windows::Graphics::DirectX::Direct3D11::p
IDirect3DDxgiInterfaceAccess _COM_Outptr_ void ** p
Definition: vsrc_gfxcapture_winrt.hpp:53
AV_OPT_TYPE_PIXEL_FMT
@ AV_OPT_TYPE_PIXEL_FMT
Underlying C type is enum AVPixelFormat.
Definition: opt.h:306
AVFilterContext
An instance of a filter.
Definition: avfilter.h:273
AV_PIX_FMT_P010
#define AV_PIX_FMT_P010
Definition: pixfmt.h:602
AVHWFramesContext::initial_pool_size
int initial_pool_size
Initial size of the frame pool.
Definition: hwcontext.h:190
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:200
FFFilter::p
AVFilter p
The public AVFilter.
Definition: filters.h:271
AVBufferRef
A reference to a data buffer.
Definition: buffer.h:82
ScaleD3D11Context::inputView
ID3D11VideoProcessorInputView * inputView
Buffer references.
Definition: vf_scale_d3d11.c:49
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:35
ScaleD3D11Context::h_expr
char * h_expr
Definition: vf_scale_d3d11.c:39
hwcontext.h
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
ID3D11Device
void ID3D11Device
Definition: nvenc.h:28
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
Definition: opt.h:275
av_hwframe_get_buffer
int av_hwframe_get_buffer(AVBufferRef *hwframe_ref, AVFrame *frame, int flags)
Allocate a new frame attached to the given AVHWFramesContext.
Definition: hwcontext.c:506
hwcontext_d3d11va.h
w32dlfcn.h