69 s->outputView->lpVtbl->Release(
s->outputView);
74 s->processor->lpVtbl->Release(
s->processor);
79 s->enumerator->lpVtbl->Release(
s->enumerator);
84 s->videoDevice->lpVtbl->Release(
s->videoDevice);
85 s->videoDevice =
NULL;
94 s->output_format = DXGI_FORMAT_NV12;
97 s->output_format = DXGI_FORMAT_P010;
107 s->device = d3d11_hwctx->
device;
111 s->inputWidth,
s->inputHeight,
s->width,
s->height);
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,
124 hr =
s->device->lpVtbl->QueryInterface(
s->device, &IID_ID3D11VideoDevice, (
void **)&
s->videoDevice);
131 hr =
s->videoDevice->lpVtbl->CreateVideoProcessorEnumerator(
s->videoDevice, &contentDesc, &
s->enumerator);
138 hr =
s->videoDevice->lpVtbl->CreateVideoProcessor(
s->videoDevice,
s->enumerator, 0, &
s->processor);
153 ID3D11VideoProcessorInputView *inputView =
NULL;
154 ID3D11VideoContext *videoContext =
NULL;
174 if (!
s->hw_device_ctx) {
183 if (input_device_ctx->
type != filter_device_ctx->
type) {
206 D3D11_TEXTURE2D_DESC textureDesc;
207 ID3D11Texture2D *input_texture = (ID3D11Texture2D *)in->
data[0];
208 input_texture->lpVtbl->GetDesc(input_texture, &textureDesc);
210 s->inputWidth = textureDesc.Width;
211 s->inputHeight = textureDesc.Height;
212 s->input_format = textureDesc.Format;
222 ID3D11Texture2D *d3d11_texture = (ID3D11Texture2D *)in->
data[0];
223 int subIdx = (int)(intptr_t)in->
data[1];
225 D3D11_VIDEO_PROCESSOR_INPUT_VIEW_DESC inputViewDesc = {
226 .FourCC =
s->input_format,
227 .ViewDimension = D3D11_VPIV_DIMENSION_TEXTURE2D,
228 .Texture2D.ArraySlice = subIdx
231 hr =
s->videoDevice->lpVtbl->CreateVideoProcessorInputView(
232 s->videoDevice, (ID3D11Resource *)d3d11_texture,
s->enumerator, &inputViewDesc, &inputView);
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 },
246 hr =
s->videoDevice->lpVtbl->CreateVideoProcessorOutputView(
247 s->videoDevice, (ID3D11Resource *)output_texture,
s->enumerator, &outputViewDesc, &
s->outputView);
255 D3D11_VIDEO_PROCESSOR_STREAM stream = {
257 .pInputSurface = inputView,
262 hr =
s->context->lpVtbl->QueryInterface(
s->context, &IID_ID3D11VideoContext, (
void **)&videoContext);
270 hr = videoContext->lpVtbl->VideoProcessorBlt(videoContext,
s->processor,
s->outputView, 0, 1, &stream);
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;
291 inputView->lpVtbl->Release(inputView);
292 videoContext->lpVtbl->Release(videoContext);
294 s->outputView->lpVtbl->Release(
s->outputView);
295 s->outputView =
NULL;
304 inputView->lpVtbl->Release(inputView);
306 videoContext->lpVtbl->Release(videoContext);
308 s->outputView->lpVtbl->Release(
s->outputView);
309 s->outputView =
NULL;
335 outlink->
w =
s->width;
336 outlink->
h =
s->height;
345 if (!
s->hw_device_ctx) {
348 if (!
s->hw_device_ctx) {
358 s->device = d3d11_hwctx->
device;
361 if (!
s->device || !
s->context) {
368 if (!
s->hw_frames_ctx_out)
374 frames_ctx->
width =
s->width;
375 frames_ctx->
height =
s->height;
378 if (
ctx->extra_hw_frames > 0)
383 frames_hwctx->
BindFlags = D3D11_BIND_RENDER_TARGET | D3D11_BIND_VIDEO_ENCODER;
397 inlink->
w, inlink->
h, outlink->
w, outlink->
h);
432#define OFFSET(x) offsetof(ScaleD3D11Context, x)
433#define FLAGS (AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
445 .p.name =
"scale_d3d11",
448 .p.priv_class = &scale_d3d11_class,
static const char *const format[]
const FFFilter ff_vf_scale_d3d11
static AVFormatContext * ctx
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
@ AV_OPT_TYPE_PIXEL_FMT
Underlying C type is enum AVPixelFormat.
@ 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...
#define AVFILTER_FLAG_HWDEVICE
The filter can create hardware frames using AVFilterContext.hw_device_ctx.
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
AVBufferRef * av_buffer_ref(const AVBufferRef *buf)
Create a new reference to an AVBuffer.
#define AVERROR_EXTERNAL
Generic error in an external library.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
#define AV_LOG_VERBOSE
Detailed information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int av_hwframe_ctx_init(AVBufferRef *ref)
Finalize the context before use.
AVBufferRef * av_hwframe_ctx_alloc(AVBufferRef *device_ref_in)
Allocate an AVHWFramesContext tied to a given device context.
int av_hwframe_get_buffer(AVBufferRef *hwframe_ref, AVFrame *frame, int flags)
Allocate a new frame attached to the given AVHWFramesContext.
An API-specific header for AV_HWDEVICE_TYPE_D3D11VA.
#define FILTER_INPUTS(array)
#define FILTER_OUTPUTS(array)
#define FF_FILTER_FLAG_HWFRAME_AWARE
The filter is aware of hardware frames, and any hardware frame context should not be automatically pr...
static FilterLink * ff_filter_link(AVFilterLink *link)
#define FILTER_SINGLE_PIXFMT(pix_fmt_)
#define AVFILTER_DEFINE_CLASS(fname)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
AVPixelFormat
Pixel format.
@ 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...
@ AV_PIX_FMT_D3D11
Hardware surfaces for Direct3D11.
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.
A reference to a data buffer.
uint8_t * data
The data buffer.
Describe the class of an AVClass context structure.
This struct is allocated as AVHWDeviceContext.hwctx.
ID3D11Device * device
Device used for texture creation and access.
ID3D11DeviceContext * device_context
If unset, this will be set from the device field on init.
This struct is allocated as AVHWFramesContext.hwctx.
UINT MiscFlags
D3D11_TEXTURE2D_DESC.MiscFlags used for texture creation.
UINT BindFlags
D3D11_TEXTURE2D_DESC.BindFlags used for texture creation.
A link between two filters.
int w
agreed upon image width
int h
agreed upon image height
AVFilterContext * src
source filter
AVFilterContext * dst
dest filter
A filter pad used for either input or output.
This structure describes decoded (raw) audio or video data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
AVBufferRef * hw_frames_ctx
For hwaccel-format frames, this should be a reference to the AVHWFramesContext describing the frame.
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e.
void * hwctx
The format-specific data, allocated and freed by libavutil along with this context.
enum AVHWDeviceType type
This field identifies the underlying API used for hardware access.
This struct describes a set or pool of "hardware" frames (i.e.
enum AVPixelFormat format
The pixel format identifying the underlying HW surface type.
AVBufferRef * device_ref
A reference to the parent AVHWDeviceContext.
void * hwctx
The format-specific data, allocated and freed automatically along with this context.
enum AVPixelFormat sw_format
The pixel format identifying the actual data layout of the hardware frames.
int initial_pool_size
Initial size of the frame pool.
int width
The allocated dimensions of the frames in this pool.
Link properties exposed to filter code, but not external callers.
AVBufferRef * hw_frames_ctx
For hwaccel pixel formats, this should be a reference to the AVHWFramesContext describing the frames.
ID3D11VideoProcessor * processor
ID3D11VideoProcessorEnumerator * enumerator
ID3D11VideoProcessorInputView * inputView
Buffer references.
ID3D11VideoDevice * videoDevice
enum AVPixelFormat format
D3D11 objects.
ID3D11VideoProcessorOutputView * outputView
AVBufferRef * hw_device_ctx
AVBufferRef * hw_frames_ctx_out
Dimensions and formats.
ID3D11DeviceContext * context
DXGI_FORMAT output_format
static const AVOption scale_d3d11_options[]
static av_cold void scale_d3d11_uninit(AVFilterContext *ctx)
static void release_d3d11_resources(ScaleD3D11Context *s)
static av_cold int scale_d3d11_init(AVFilterContext *ctx)
static const AVFilterPad scale_d3d11_inputs[]
static const AVFilterPad scale_d3d11_outputs[]
static int scale_d3d11_configure_processor(ScaleD3D11Context *s, AVFilterContext *ctx)
static int scale_d3d11_config_props(AVFilterLink *outlink)
static int scale_d3d11_filter_frame(AVFilterLink *inlink, AVFrame *in)