21#if !defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0A00
23#define _WIN32_WINNT 0x0A00
52#define TIMER_RES 1000000
53#define TIMER_RES64 INT64_C(1000000)
109#define OFFSET(x) offsetof(DdagrabContext, x)
110#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
119 {
"auto",
"let dda pick its preferred format", 0,
AV_OPT_TYPE_CONST, { .i64 = 0 }, 0, INT_MAX,
FLAGS, .unit =
"output_fmt" },
122 {
"10bit",
"only output default 10 Bit format", 0,
AV_OPT_TYPE_CONST, { .i64 = DXGI_FORMAT_R10G10B10A2_UNORM }, 0, INT_MAX,
FLAGS, .unit =
"output_fmt" },
123 {
"x2bgr10",
"only output 10 Bit X2BGR10", 0,
AV_OPT_TYPE_CONST, { .i64 = DXGI_FORMAT_R10G10B10A2_UNORM }, 0, INT_MAX,
FLAGS, .unit =
"output_fmt" },
126 {
"allow_fallback",
"don't error on fallback to default 8 Bit format",
128 {
"force_fmt",
"exclude BGRA from format list (experimental, discouraged by Microsoft)",
130 {
"dup_frames",
"duplicate frames to maintain framerate",
139 IUnknown **resp = (IUnknown**)resource;
141 IUnknown_Release(*resp);
175 IDXGIDevice *dxgi_device =
NULL;
176 IDXGIAdapter *dxgi_adapter =
NULL;
177 IDXGIOutput *dxgi_output =
NULL;
178 IDXGIOutput1 *dxgi_output1 =
NULL;
179#if HAVE_IDXGIOUTPUT5 && HAVE_DPI_AWARENESS_CONTEXT
180 IDXGIOutput5 *dxgi_output5 =
NULL;
182 typedef DPI_AWARENESS_CONTEXT (*set_thread_dpi_t)(DPI_AWARENESS_CONTEXT);
183 set_thread_dpi_t set_thread_dpi;
184 HMODULE user32_module;
189 hr = ID3D11Device_QueryInterface(dda->
device_hwctx->
device, &IID_IDXGIDevice, (
void**)&dxgi_device);
195 hr = IDXGIDevice_GetParent(dxgi_device, &IID_IDXGIAdapter, (
void**)&dxgi_adapter);
196 IDXGIDevice_Release(dxgi_device);
203 hr = IDXGIAdapter_EnumOutputs(dxgi_adapter, dda->
output_idx, &dxgi_output);
204 IDXGIAdapter_Release(dxgi_adapter);
211 hr = IDXGIOutput_GetDesc(dxgi_output, &dda->
output_desc);
213 IDXGIOutput_Release(dxgi_output);
218#if HAVE_IDXGIOUTPUT5 && HAVE_DPI_AWARENESS_CONTEXT
219 user32_module = dlopen(
"user32.dll", 0);
220 if (!user32_module) {
225 set_thread_dpi = (set_thread_dpi_t)dlsym(user32_module,
"SetThreadDpiAwarenessContext");
228 hr = IDXGIOutput_QueryInterface(dxgi_output, &IID_IDXGIOutput5, (
void**)&dxgi_output5);
230 if (set_thread_dpi && SUCCEEDED(hr)) {
231 DPI_AWARENESS_CONTEXT prev_dpi_ctx;
234 DXGI_FORMAT_R10G10B10A2_UNORM,
248 IDXGIOutput_Release(dxgi_output);
251 prev_dpi_ctx = set_thread_dpi(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
255 hr = IDXGIOutput5_DuplicateOutput1(dxgi_output5,
261 IDXGIOutput5_Release(dxgi_output5);
265 set_thread_dpi(prev_dpi_ctx);
267 dlclose(user32_module);
268 user32_module =
NULL;
269 set_thread_dpi =
NULL;
273 dlclose(user32_module);
274 user32_module =
NULL;
275 set_thread_dpi =
NULL;
286 hr = IDXGIOutput_QueryInterface(dxgi_output, &IID_IDXGIOutput1, (
void**)&dxgi_output1);
287 IDXGIOutput_Release(dxgi_output);
294 hr = IDXGIOutput1_DuplicateOutput(dxgi_output1,
297 IDXGIOutput1_Release(dxgi_output1);
301 if (hr == DXGI_ERROR_NOT_CURRENTLY_AVAILABLE) {
304 }
else if (hr == DXGI_ERROR_UNSUPPORTED) {
307 }
else if (hr == E_INVALIDARG) {
310 }
else if (hr == E_ACCESSDENIED) {
313 }
else if (FAILED(hr)) {
335 {
"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
336 {
"TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 }
343 D3D11_SAMPLER_DESC sampler_desc = { 0 };
344 D3D11_BLEND_DESC blend_desc = { 0 };
345 D3D11_BUFFER_DESC buffer_desc = { 0 };
350 hr = ID3D11Device_CreateVertexShader(dev,
360 hr = ID3D11Device_CreateInputLayout(dev,
371 hr = ID3D11Device_CreatePixelShader(dev,
384 buffer_desc.ByteWidth =
sizeof(const_data);
385 buffer_desc.Usage = D3D11_USAGE_IMMUTABLE;
386 buffer_desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
387 hr = ID3D11Device_CreateBuffer(dev,
396 sampler_desc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
397 sampler_desc.AddressU = D3D11_TEXTURE_ADDRESS_CLAMP;
398 sampler_desc.AddressV = D3D11_TEXTURE_ADDRESS_CLAMP;
399 sampler_desc.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP;
400 sampler_desc.ComparisonFunc = D3D11_COMPARISON_NEVER;
401 hr = ID3D11Device_CreateSamplerState(dev,
409 blend_desc.AlphaToCoverageEnable = FALSE;
410 blend_desc.IndependentBlendEnable = FALSE;
411 blend_desc.RenderTarget[0].BlendEnable = TRUE;
412 blend_desc.RenderTarget[0].SrcBlend = D3D11_BLEND_SRC_ALPHA;
413 blend_desc.RenderTarget[0].DestBlend = D3D11_BLEND_INV_SRC_ALPHA;
414 blend_desc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD;
415 blend_desc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE;
416 blend_desc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ZERO;
417 blend_desc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD;
418 blend_desc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL;
419 hr = ID3D11Device_CreateBlendState(dev,
427 blend_desc.RenderTarget[0].SrcBlend = D3D11_BLEND_INV_DEST_COLOR;
428 blend_desc.RenderTarget[0].DestBlend = D3D11_BLEND_INV_SRC_COLOR;
429 hr = ID3D11Device_CreateBlendState(dev,
456 DXGI_OUTDUPL_POINTER_SHAPE_INFO *shape_info,
457 ID3D11Texture2D **out_tex,
458 ID3D11ShaderResourceView **res_view)
461 D3D11_TEXTURE2D_DESC
desc = { 0 };
462 D3D11_SUBRESOURCE_DATA init_data = { 0 };
463 D3D11_SHADER_RESOURCE_VIEW_DESC resource_desc = { 0 };
469 desc.SampleDesc.Count = 1;
470 desc.SampleDesc.Quality = 0;
471 desc.Usage = D3D11_USAGE_IMMUTABLE;
472 desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
474 desc.Width = shape_info->Width;
475 desc.Height = shape_info->Height;
477 init_data.pSysMem = buf;
478 init_data.SysMemPitch = shape_info->Pitch;
480 resource_desc.Format =
desc.Format;
481 resource_desc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
482 resource_desc.Texture2D.MostDetailedMip = 0;
483 resource_desc.Texture2D.MipLevels = 1;
495 (ID3D11Resource*)*out_tex,
507static int convert_mono_buffer(uint8_t *input, uint8_t **rgba_out, uint8_t **xor_out,
int *_width,
int *_height,
int *_pitch)
509 int width = *_width,
height = *_height, pitch = *_pitch;
510 int real_height =
height / 2;
511 int size = real_height * pitch;
518 if (!output || !output_xor) {
524 for (y = 0; y < real_height; y++) {
525 for (x = 0; x <
width; x++) {
526 int in_pos = (y * pitch) + (x / 8);
527 int out_pos = 4 * ((y *
width) + x);
528 int and_val = (input[in_pos] >> (7 - (x % 8))) & 1;
529 int xor_val = (input[in_pos +
size] >> (7 - (x % 8))) & 1;
531 if (!and_val && !xor_val) {
533 memset(&output[out_pos], 0, 4);
534 output[out_pos + 3] = 0xFF;
537 memset(&output_xor[out_pos], 0, 4);
538 }
else if (and_val && !xor_val) {
540 memset(&output[out_pos], 0, 4);
543 memset(&output_xor[out_pos], 0, 4);
544 }
else if (!and_val && xor_val) {
546 memset(&output[out_pos], 0xFF, 4);
549 memset(&output_xor[out_pos], 0, 4);
550 }
else if (and_val && xor_val) {
552 memset(&output[out_pos], 0, 4);
555 memset(&output_xor[out_pos], 0xFF, 4);
561 *_height = real_height;
563 *xor_out = output_xor;
575 if (!output || !output_xor) {
581 memcpy(output, input,
size);
582 memcpy(output_xor, input,
size);
584 for (y = 0; y <
height; y++) {
585 for (x = 0; x <
width; x++) {
586 int pos = (y*pitch) + (4*x) + 3;
587 output[
pos] = input[
pos] ? 0 : 0xFF;
588 output_xor[
pos] = input[
pos] ? 0xFF : 0;
593 *xor_out = output_xor;
604 if (
frame_info->LastMouseUpdateTime.QuadPart == 0)
609 case DXGI_MODE_ROTATION_ROTATE90:
613 case DXGI_MODE_ROTATION_ROTATE180:
617 case DXGI_MODE_ROTATION_ROTATE270:
631 DXGI_OUTDUPL_POINTER_SHAPE_INFO shape_info;
632 uint8_t *rgba_buf =
NULL, *rgb_xor_buf =
NULL;
637 hr = IDXGIOutputDuplication_GetFramePointerShape(dda->
dxgi_outdupl,
648 if (shape_info.Type == DXGI_OUTDUPL_POINTER_SHAPE_TYPE_MONOCHROME) {
649 ret =
convert_mono_buffer(buf, &rgba_buf, &rgb_xor_buf, &shape_info.Width, &shape_info.Height, &shape_info.Pitch);
653 }
else if (shape_info.Type == DXGI_OUTDUPL_POINTER_SHAPE_TYPE_MASKED_COLOR) {
654 ret =
fixup_color_mask(buf, &rgba_buf, &rgb_xor_buf, shape_info.Width, shape_info.Height, shape_info.Pitch);
658 }
else if (shape_info.Type == DXGI_OUTDUPL_POINTER_SHAPE_TYPE_COLOR) {
691 IDXGIResource *desktop_resource =
NULL;
695 hr = IDXGIOutputDuplication_AcquireNextFrame(
700 if (hr == DXGI_ERROR_WAIT_TIMEOUT) {
702 }
else if (FAILED(hr)) {
738 hr = IDXGIResource_QueryInterface(desktop_resource, &IID_ID3D11Texture2D, (
void**)desktop_texture);
747 D3D11_TEXTURE2D_DESC
desc;
748 ID3D11Texture2D_GetDesc(*desktop_texture, &
desc);
749 desc.Usage = D3D11_USAGE_DEFAULT;
751 desc.CPUAccessFlags = 0;
765 (ID3D11Resource*)*desktop_texture);
772 hr = IDXGIOutputDuplication_ReleaseFrame(dda->
dxgi_outdupl);
782 D3D11_TEXTURE2D_DESC
desc;
789 }
while(ret ==
AVERROR(EAGAIN));
829 case DXGI_FORMAT_R10G10B10A2_UNORM:
847 av_log(avctx,
AV_LOG_ERROR,
"Failed to initialise hardware frames context: %d.\n", ret);
937 ID3D11Texture2D *frame_tex = (ID3D11Texture2D*)
frame->data[0];
938 D3D11_RENDER_TARGET_VIEW_DESC target_desc = { 0 };
939 ID3D11RenderTargetView* target_view =
NULL;
940 ID3D11Buffer *mouse_vertex_buffer =
NULL;
941 D3D11_TEXTURE2D_DESC tex_desc, frame_desc;
942 int num_vertices = 0;
951 ID3D11Texture2D_GetDesc(frame_tex, &frame_desc);
957 -x >= (
int)tex_desc.Width || -y >= (
int)tex_desc.Height)
960 target_desc.Format = frame_desc.Format;
962 if (frame_desc.ArraySize > 1) {
963 target_desc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DARRAY;
964 target_desc.Texture2DArray.ArraySize = 1;
965 target_desc.Texture2DArray.FirstArraySlice = (uintptr_t)
frame->data[1];
966 target_desc.Texture2DArray.MipSlice = 0;
968 target_desc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
969 target_desc.Texture2D.MipSlice = 0;
973 (ID3D11Resource*)frame_tex,
982 ID3D11DeviceContext_ClearState(devctx);
985 D3D11_VIEWPORT viewport = { 0 };
986 viewport.Width = dda->
width;
987 viewport.Height = dda->
height;
988 viewport.MinDepth = 0.0f;
989 viewport.MaxDepth = 1.0f;
991 ID3D11DeviceContext_RSSetViewports(devctx, 1, &viewport);
997 x , y + tex_desc.Height, 0.0f, 0.0f, 1.0f,
998 x , y , 0.0f, 0.0f, 0.0f,
999 x + tex_desc.Width, y + tex_desc.Height, 0.0f, 1.0f, 1.0f,
1000 x + tex_desc.Width, y , 0.0f, 1.0f, 0.0f,
1005 D3D11_SUBRESOURCE_DATA init_data = { 0 };
1006 D3D11_BUFFER_DESC
buf_desc = { 0 };
1009 case DXGI_MODE_ROTATION_ROTATE90:
1010 vertices[ 0] = x; vertices[ 1] = y;
1011 vertices[ 5] = x; vertices[ 6] = y - tex_desc.Width;
1012 vertices[10] = x + tex_desc.Height; vertices[11] = y;
1013 vertices[15] = x + tex_desc.Height; vertices[16] = y - tex_desc.Width;
1014 vertices[ 3] = 0.0f; vertices[ 4] = 0.0f;
1015 vertices[ 8] = 1.0f; vertices[ 9] = 0.0f;
1016 vertices[13] = 0.0f; vertices[14] = 1.0f;
1017 vertices[18] = 1.0f; vertices[19] = 1.0f;
1019 case DXGI_MODE_ROTATION_ROTATE180:
1020 vertices[ 0] = x - tex_desc.Width; vertices[ 1] = y;
1021 vertices[ 5] = x - tex_desc.Width; vertices[ 6] = y - tex_desc.Height;
1022 vertices[10] = x; vertices[11] = y;
1023 vertices[15] = x; vertices[16] = y - tex_desc.Height;
1024 vertices[ 3] = 1.0f; vertices[ 4] = 0.0f;
1025 vertices[ 8] = 1.0f; vertices[ 9] = 1.0f;
1026 vertices[13] = 0.0f; vertices[14] = 0.0f;
1027 vertices[18] = 0.0f; vertices[19] = 1.0f;
1029 case DXGI_MODE_ROTATION_ROTATE270:
1030 vertices[ 0] = x - tex_desc.Height; vertices[ 1] = y + tex_desc.Width;
1031 vertices[ 5] = x - tex_desc.Height; vertices[ 6] = y;
1032 vertices[10] = x; vertices[11] = y + tex_desc.Width;
1033 vertices[15] = x; vertices[16] = y;
1034 vertices[ 3] = 1.0f; vertices[ 4] = 1.0f;
1035 vertices[ 8] = 0.0f; vertices[ 9] = 1.0f;
1036 vertices[13] = 1.0f; vertices[14] = 0.0f;
1037 vertices[18] = 0.0f; vertices[19] = 0.0f;
1043 num_vertices =
sizeof(vertices) / (
sizeof(
FLOAT) * 5);
1045 buf_desc.Usage = D3D11_USAGE_DEFAULT;
1046 buf_desc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
1047 buf_desc.ByteWidth =
sizeof(vertices);
1048 init_data.pSysMem = vertices;
1053 &mouse_vertex_buffer);
1060 ID3D11DeviceContext_IASetVertexBuffers(devctx, 0, 1, &mouse_vertex_buffer, &
stride, &
offset);
1061 ID3D11DeviceContext_IASetInputLayout(devctx, dda->
input_layout);
1062 ID3D11DeviceContext_IASetPrimitiveTopology(devctx, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
1066 ID3D11DeviceContext_VSSetConstantBuffers(devctx, 0, 1, &dda->
const_buffer);
1067 ID3D11DeviceContext_PSSetSamplers(devctx, 0, 1, &dda->
sampler_state);
1071 ID3D11DeviceContext_OMSetBlendState(devctx, dda->
blend_state,
NULL, 0xFFFFFFFF);
1072 ID3D11DeviceContext_OMSetRenderTargets(devctx, 1, &target_view,
NULL);
1074 ID3D11DeviceContext_Draw(devctx, num_vertices, 0);
1080 ID3D11DeviceContext_Draw(devctx, num_vertices, 0);
1095 ID3D11Texture2D *cur_texture =
NULL;
1096 D3D11_TEXTURE2D_DESC
desc = { 0 };
1097 D3D11_BOX
box = { 0 };
1152 }
else if (ret ==
AVERROR(EAGAIN)) {
1155 }
else if (ret < 0) {
1163 ID3D11Texture2D_GetDesc(cur_texture, &
desc);
1185 ID3D11DeviceContext_CopySubresourceRegion(
1187 (ID3D11Resource*)
frame->data[0], (UINT)(intptr_t)
frame->data[1],
1189 (ID3D11Resource*)cur_texture, 0,
1194 hr = IDXGIOutputDuplication_ReleaseFrame(dda->
dxgi_outdupl);
1210 desc.Format == DXGI_FORMAT_R10G10B10A2_UNORM) {
1242 IDXGIOutputDuplication_ReleaseFrame(dda->
dxgi_outdupl);
1258 .p.name =
"ddagrab",
1259 .p.description =
NULL_IF_CONFIG_SMALL(
"Grab Windows Desktop images using Desktop Duplication API"),
1260 .p.priv_class = &ddagrab_class,
const FFFilter ff_vsrc_ddagrab
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Main libavfilter public API header.
static int FUNC frame_info(CodedBitstreamContext *ctx, RWContext *rw, APVRawFrameInfo *current)
@ DXGI_FORMAT_B8G8R8A8_UNORM
@ DXGI_FORMAT_R16G16B16A16_FLOAT
int(* init)(AVBSFContext *ctx)
static av_unused double box(double x, const double *params)
@ AV_OPT_TYPE_IMAGE_SIZE
Underlying C type is two consecutive integers.
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
@ AV_OPT_TYPE_VIDEO_RATE
Underlying C type is AVRational.
@ AV_OPT_TYPE_INT
Underlying C type is int.
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
#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_OUTPUT_CHANGED
Output changed between calls. Reconfiguration is required. (can be OR-ed with AVERROR_INPUT_CHANGED)
#define AVERROR_EXTERNAL
Generic error in an external library.
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
int av_frame_replace(AVFrame *dst, const AVFrame *src)
Ensure the destination frame refers to the same data described by the source frame,...
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_VERBOSE
Detailed information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static double av_q2d(AVRational a)
Convert an AVRational to a double.
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
int av_hwdevice_ctx_create(AVBufferRef **pdevice_ref, enum AVHWDeviceType type, const char *device, AVDictionary *opts, int flags)
Open a device of the specified type and create an AVHWDeviceContext for it.
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.
@ AV_HWDEVICE_TYPE_D3D11VA
An API-specific header for AV_HWDEVICE_TYPE_D3D11VA.
static av_cold void uninit(AVBitStreamFilterContext *ctx)
#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.
Memory handling functions.
#define AV_PIX_FMT_RGBAF16
@ AVCOL_RANGE_JPEG
Full range content.
@ AV_PIX_FMT_BGRA
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
@ AV_PIX_FMT_D3D11
Hardware surfaces for Direct3D11.
#define AV_PIX_FMT_X2BGR10
@ AVCOL_PRI_BT709
also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP 177 Annex B
@ AVCOL_TRC_LINEAR
"Linear transfer characteristics"
@ AVCOL_TRC_IEC61966_2_1
IEC 61966-2-1 (sRGB or sYCC)
@ AVCOL_SPC_RGB
order of coefficients is actually GBR, also IEC 61966-2-1 (sRGB), YZX and ST 428-1
#define FF_ARRAY_ELEMS(a)
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 BindFlags
D3D11_TEXTURE2D_DESC.BindFlags used for texture creation.
int extra_hw_frames
Sets the number of extra hardware frames which the filter will allocate on its output links for use i...
void * priv
private data for use by the filter
AVBufferRef * hw_device_ctx
For filters which will create hardware frames, sets the device the filter should create them in.
A link between two filters.
int w
agreed upon image width
int h
agreed upon image height
AVFilterContext * src
source filter
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link.
A filter pad used for either input or output.
This structure describes decoded (raw) audio or video data.
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this 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.
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.
Rational number (pair of numerator and denominator).
ID3D11Texture2D * probed_texture
ID3D11InputLayout * input_layout
ID3D11BlendState * blend_state
AVD3D11VADeviceContext * device_hwctx
ID3D11ShaderResourceView * mouse_xor_resource_view
IDXGIOutputDuplication * dxgi_outdupl
ID3D11Texture2D * buffer_texture
ID3D11ShaderResourceView * mouse_resource_view
AVD3D11VAFramesContext * frames_hwctx
ID3D11BlendState * blend_state_xor
ID3D11Texture2D * mouse_texture
AVHWDeviceContext * device_ctx
ID3D11Buffer * const_buffer
ID3D11PixelShader * pixel_shader
AVHWFramesContext * frames_ctx
ID3D11SamplerState * sampler_state
DXGI_OUTPUT_DESC output_desc
ID3D11VertexShader * vertex_shader
ID3D11Texture2D * mouse_xor_texture
Link properties exposed to filter code, but not external callers.
AVRational frame_rate
Frame rate of the stream on the link, or 1/0 if unknown or variable.
AVBufferRef * hw_frames_ctx
For hwaccel pixel formats, this should be a reference to the AVHWFramesContext describing the frames.
static void error(const char *err)
int av_usleep(unsigned usec)
Sleep for a period of time.
int64_t av_gettime_relative(void)
Get the current time in microseconds since some unspecified starting point.
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
static const AVFilterPad ddagrab_outputs[]
static int convert_mono_buffer(uint8_t *input, uint8_t **rgba_out, uint8_t **xor_out, int *_width, int *_height, int *_pitch)
static int fixup_color_mask(uint8_t *input, uint8_t **rgba_out, uint8_t **xor_out, int width, int height, int pitch)
static const D3D11_INPUT_ELEMENT_DESC vertex_shader_input_layout[]
static av_cold void ddagrab_uninit(AVFilterContext *avctx)
static int create_d3d11_pointer_tex(AVFilterContext *avctx, uint8_t *buf, DXGI_OUTDUPL_POINTER_SHAPE_INFO *shape_info, ID3D11Texture2D **out_tex, ID3D11ShaderResourceView **res_view)
static const AVOption ddagrab_options[]
static void release_resource(void *resource)
static int ddagrab_config_props(AVFilterLink *outlink)
static int draw_mouse_pointer(AVFilterContext *avctx, AVFrame *frame)
static av_cold int init_render_resources(AVFilterContext *avctx)
static av_cold int ddagrab_init(AVFilterContext *avctx)
static int ddagrab_request_frame(AVFilterLink *outlink)
static int update_mouse_pointer(AVFilterContext *avctx, DXGI_OUTDUPL_FRAME_INFO *frame_info)
static av_cold int init_hwframes_ctx(AVFilterContext *avctx)
static int next_frame_internal(AVFilterContext *avctx, ID3D11Texture2D **desktop_texture, int need_frame)
static av_cold int init_dxgi_dda(AVFilterContext *avctx)
static int probe_output_format(AVFilterContext *avctx)
static const uint8_t vertex_shader_bytes[]
static const uint8_t pixel_shader_bytes[]