39#include <onnxruntime_c_api.h>
44#if CONFIG_DNN_ONNX_D3D12
63#if CONFIG_DNN_ONNX_D3D12
73#if CONFIG_DNN_ONNX_D3D12
85#define OFFSET(x) offsetof(ONNXOptions, x)
86#define FLAGS AV_OPT_FLAG_FILTERING_PARAM
88 {
"threads_per_operation",
"number of CPU threads per ORT operator (device=cpu only)",
100 g_ort = OrtGetApiBase()->GetApi(ORT_API_VERSION);
103#define ORT_ABORT_ON_ERROR(expr) \
105 OrtStatus *status = (expr); \
106 if (status != NULL) { \
107 const char *msg = g_ort->GetErrorMessage(status); \
108 av_log(ctx, AV_LOG_ERROR, "ONNX Runtime error: %s\n", msg); \
109 g_ort->ReleaseStatus(status); \
131 for (uint32_t
i = 0;
i <
header->nb_bboxes;
i++) {
133 if (bbox->
x < 0 || bbox->
w < 0 || bbox->
x + bbox->
w >
frame->width)
135 if (bbox->
y < 0 || bbox->
h < 0 || bbox->
y + bbox->
h >
frame->height)
185 for (uint32_t
i = 0;
i <
header->nb_bboxes;
i++) {
235#if CONFIG_DNN_ONNX_D3D12
237 request->hw_in_tensor =
NULL;
238 request->hw_out_tensor =
NULL;
258 if (!model || !*model)
276#if CONFIG_DNN_ONNX_D3D12
295#if CONFIG_DNN_ONNX_D3D12
305#if CONFIG_DNN_ONNX_D3D12
306static void append_d3d12_dml_ep(
ONNXModel *onnx_model)
314 if (!
ctx->hw_frames_ctx)
321 "dnn_onnx_d3d12: hw_frames_ctx is not backed by a D3D12VA "
322 "device; falling back to host I/O\n");
331 if (!onnx_model->hw_ctx)
336 "Failed to register the DirectML EP on the frames' D3D12 "
337 "device; D3D12 hardware-frame input will fail to configure, "
338 "only software-frame input can use the default-device DirectML EP\n");
343 ctx->zero_copy_negotiated = 1;
345 "Using DirectML execution provider on the frames' own D3D12 device%s\n",
346 is_uma ?
" (UMA)" :
"");
354 OrtTypeInfo *type_info =
NULL;
355 const OrtTensorTypeAndShapeInfo *tensor_info =
NULL;
357 size_t input_count = 0;
358 size_t input_index = 0;
361 ONNXTensorElementDataType tensor_type;
364 if (!input_name || !*input_name) {
374 status =
g_ort->SessionGetInputCount(onnx_model->
session, &input_count);
375 if (status !=
NULL) {
376 const char *msg =
g_ort->GetErrorMessage(status);
378 g_ort->ReleaseStatus(status);
382 for (
size_t i = 0;
i < input_count;
i++) {
386 if (status !=
NULL) {
387 g_ort->ReleaseStatus(status);
390 if (!strcmp(
name, input_name)) {
405 status =
g_ort->SessionGetInputTypeInfo(onnx_model->
session, input_index,
407 if (status !=
NULL) {
408 const char *msg =
g_ort->GetErrorMessage(status);
410 g_ort->ReleaseStatus(status);
414 status =
g_ort->CastTypeInfoToTensorInfo(type_info, &tensor_info);
415 if (status !=
NULL) {
416 g_ort->ReleaseTypeInfo(type_info);
417 g_ort->ReleaseStatus(status);
421 status =
g_ort->GetDimensionsCount(tensor_info, &num_dims);
422 if (status !=
NULL) {
423 g_ort->ReleaseTypeInfo(type_info);
424 g_ort->ReleaseStatus(status);
430 g_ort->ReleaseTypeInfo(type_info);
436 g_ort->ReleaseTypeInfo(type_info);
440 g_ort->GetDimensions(tensor_info, dims, num_dims);
441 g_ort->GetTensorElementType(tensor_info, &tensor_type);
445 "ONNX model has fixed batch size %"PRId64
", but the backend "
446 "only supports a batch size of 1\n", dims[0]);
448 g_ort->ReleaseTypeInfo(type_info);
452 for (
size_t i = 1;
i < num_dims;
i++) {
453 if (dims[
i] > INT_MAX) {
455 "ONNX model input dimension %zu (%"PRId64
") is too large to be represented\n",
458 g_ort->ReleaseTypeInfo(type_info);
468 input->
dims[0] = dims[0] > 0 ? dims[0] : 1;
469 input->
dims[1] = dims[1] > 0 ? dims[1] : 3;
470 input->
dims[2] = dims[2] > 0 ? dims[2] : -1;
471 input->
dims[3] = dims[3] > 0 ? dims[3] : -1;
473 if (tensor_type == ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT) {
478 g_ort->ReleaseTypeInfo(type_info);
490 g_ort->ReleaseTypeInfo(type_info);
504 int ret, width_idx, height_idx, channel_idx;
506 size_t input_tensor_size;
507 OrtMemoryInfo *memory_info;
528 if (input.
dims[height_idx] < 0)
530 if (input.
dims[width_idx] < 0)
533 if (input.
dims[0] <= 0 || input.
dims[channel_idx] <= 0 ||
534 input.
dims[height_idx] <= 0 || input.
dims[width_idx] <= 0) {
541 (
unsigned)input.
dims[height_idx], 0,
ctx);
544 input.
dims[width_idx], input.
dims[height_idx]);
548 input_shape[0] = input.
dims[0];
549 input_shape[1] = input.
dims[channel_idx];
550 input_shape[2] = input.
dims[height_idx];
551 input_shape[3] = input.
dims[width_idx];
553#if CONFIG_DNN_ONNX_D3D12
569 &infer_request->hw_in_tensor,
570 &infer_request->hw_out_tensor);
582 input_tensor_size =
sizeof(
float);
583 if (
av_size_mult(input_tensor_size, (
size_t)input_shape[0], &input_tensor_size) < 0 ||
584 av_size_mult(input_tensor_size, (
size_t)input_shape[1], &input_tensor_size) < 0 ||
585 av_size_mult(input_tensor_size, (
size_t)input_shape[2], &input_tensor_size) < 0 ||
586 av_size_mult(input_tensor_size, (
size_t)input_shape[3], &input_tensor_size) < 0) {
629 status =
g_ort->CreateCpuMemoryInfo(OrtArenaAllocator, OrtMemTypeDefault, &memory_info);
630 if (status !=
NULL) {
635 status =
g_ort->CreateTensorWithDataAsOrtValue(
636 memory_info, input.
data, input_tensor_size,
637 input_shape, 4, ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT,
640 g_ort->ReleaseMemoryInfo(memory_info);
642 if (status !=
NULL) {
643 const char *msg =
g_ort->GetErrorMessage(status);
645 g_ort->ReleaseStatus(status);
666 const char *input_names[1];
682 "ONNX backend: input/output tensor name was not resolved at load time\n");
686#if CONFIG_DNN_ONNX_D3D12
687 if (infer_request->hw_in_tensor) {
688 if (!infer_request->hw_out_tensor) {
700 size_t output_count = 0;
701 int found_output = 0;
703 status =
g_ort->SessionGetOutputCount(onnx_model->
session, &output_count);
704 if (status !=
NULL) {
705 const char *msg =
g_ort->GetErrorMessage(status);
707 g_ort->ReleaseStatus(status);
711 for (uint32_t req = 0; req < task->
nb_output; req++) {
713 for (
size_t i = 0;
i < output_count;
i++) {
717 if (status !=
NULL) {
718 g_ort->ReleaseStatus(status);
729 "Output name '%s' not found in ONNX model\n",
740#if CONFIG_DNN_ONNX_D3D12
741 if (infer_request->hw_in_tensor) {
744 infer_request->hw_in_tensor,
745 infer_request->hw_out_tensor);
761 input_names, (
const OrtValue *
const *)&infer_request->
input_tensor, 1,
764 if (status !=
NULL) {
765 const char *msg =
g_ort->GetErrorMessage(status);
767 g_ort->ReleaseStatus(status);
788 OrtTensorTypeAndShapeInfo *tensor_info;
789 ONNXTensorElementDataType tensor_type;
795#if CONFIG_DNN_ONNX_D3D12
796 if (infer_request->hw_in_tensor) {
815 if (status !=
NULL) {
817 g_ort->ReleaseStatus(status);
821 status =
g_ort->GetDimensionsCount(tensor_info, &num_dims);
822 if (status !=
NULL) {
824 g_ort->ReleaseStatus(status);
825 g_ort->ReleaseTensorTypeAndShapeInfo(tensor_info);
832 g_ort->ReleaseTensorTypeAndShapeInfo(tensor_info);
836 status =
g_ort->GetDimensions(tensor_info, dims, num_dims);
837 if (status !=
NULL) {
839 g_ort->ReleaseStatus(status);
841 g_ort->ReleaseTensorTypeAndShapeInfo(tensor_info);
845 for (
size_t d = 0; d < num_dims; d++) {
846 if (dims[d] < 0 || dims[d] > INT_MAX) {
848 "Output tensor[%u] dimension %zu (%"PRId64
") is out of representable range\n",
851 g_ort->ReleaseTensorTypeAndShapeInfo(tensor_info);
856 status =
g_ort->GetTensorElementType(tensor_info, &tensor_type);
857 if (status !=
NULL) {
859 g_ort->ReleaseStatus(status);
861 g_ort->ReleaseTensorTypeAndShapeInfo(tensor_info);
864 if (tensor_type == ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT) {
868 "Unsupported output tensor[%u] data type, only float supported\n",
i);
870 g_ort->ReleaseTensorTypeAndShapeInfo(tensor_info);
875 (num_dims != 4 || dims[1] != 1)) {
877 "D3D12 zero-copy requires a [1,1,H,W] output tensor, got rank %zu with dims[1]=%"PRId64
"\n",
878 num_dims, num_dims > 1 ? dims[1] : 0);
880 g_ort->ReleaseTensorTypeAndShapeInfo(tensor_info);
893 }
else if (num_dims == 3) {
899 }
else if (num_dims == 2) {
905 }
else if (num_dims == 1) {
913 "Support for %zu-dimensional output (tensor[%u])", num_dims,
i);
915 g_ort->ReleaseTensorTypeAndShapeInfo(tensor_info);
921 "Output tensor[%u] batch size %d unsupported, must be 1\n",
924 g_ort->ReleaseTensorTypeAndShapeInfo(tensor_info);
929 if (status !=
NULL) {
931 g_ort->ReleaseStatus(status);
933 g_ort->ReleaseTensorTypeAndShapeInfo(tensor_info);
938 g_ort->ReleaseTensorTypeAndShapeInfo(tensor_info);
1004 if (lltask ==
NULL) {
1009 task = lltask->
task;
1046 const char *output_name,
int *output_width,
int *output_height)
1054 .input_name = input_name,
1055 .output_names = &output_name,
1115 model = &onnx_model->
model;
1118 if (
ctx->nireq > 1) {
1120 "nireq=%d is not supported by the ONNX Runtime backend, "
1121 "which only allocates a single, synchronous inference "
1122 "request. Rolling back to nireq=1.\n",
ctx->nireq);
1126 status =
g_ort->CreateEnv(ORT_LOGGING_LEVEL_WARNING,
"FFmpeg", &onnx_model->
env);
1127 if (status !=
NULL) {
1133 if (status !=
NULL) {
1138 if (
options->num_threads > 0 &&
1152 if (
g_ort->SessionOptionsAppendExecutionProvider_CUDA) {
1153 OrtCUDAProviderOptions cuda_options;
1154 memset(&cuda_options, 0,
sizeof(cuda_options));
1155 cuda_options.device_id =
ctx->device_id;
1157 status =
g_ort->SessionOptionsAppendExecutionProvider_CUDA(
1159 if (status !=
NULL) {
1160 const char *msg =
g_ort->GetErrorMessage(status);
1162 ctx->device_id, msg);
1163 g_ort->ReleaseStatus(status);
1168 av_log(
ctx,
AV_LOG_WARNING,
"CUDA provider function not available in this ONNX Runtime API version. Falling back to CPU\n");
1172 const char* dml_options_keys[] = {
"device_id"};
1173 const char* dml_options_values[] = {
NULL};
1174 char device_id_str[32];
1175 snprintf(device_id_str,
sizeof(device_id_str),
"%d",
ctx->device_id);
1176 dml_options_values[0] = device_id_str;
1182 g_ort->ReleaseStatus(status);
1185 g_ort->ReleaseStatus(status);
1187#if CONFIG_DNN_ONNX_D3D12
1191 append_d3d12_dml_ep(onnx_model);
1194 if (
ctx->zero_copy_negotiated) {
1196 }
else if (
g_ort->SessionOptionsAppendExecutionProvider) {
1197 status =
g_ort->SessionOptionsAppendExecutionProvider(
1199 dml_options_keys, dml_options_values, 1);
1200 if (status !=
NULL) {
1201 const char *msg =
g_ort->GetErrorMessage(status);
1203 ctx->device_id, msg);
1204 g_ort->ReleaseStatus(status);
1209 av_log(
ctx,
AV_LOG_WARNING,
"DirectML provider function not available in this ONNX Runtime API version. Falling back to CPU\n");
1215 if (
g_ort->SessionOptionsAppendExecutionProvider) {
1216 status =
g_ort->SessionOptionsAppendExecutionProvider(
1219 if (status !=
NULL) {
1220 const char *msg =
g_ort->GetErrorMessage(status);
1222 "Failed to enable VitisAI EP: %s. Falling back to CPU\n", msg);
1223 g_ort->ReleaseStatus(status);
1229 "VitisAI provider function not available in this ONNX Runtime API version. Falling back to CPU.\n");
1234 "Unknown device '%s'. Supported: cpu, cuda, dml, vitisai. Using CPU\n",
1238 "Unknown device '%s'. Supported: cpu, cuda, vitisai. Using CPU\n",
1248 wchar_t *wfilename =
NULL;
1249 if (utf8towchar(
ctx->model_filename, &wfilename)) {
1258 status =
g_ort->CreateSession(onnx_model->
env, wfilename,
1263 status =
g_ort->CreateSession(onnx_model->
env,
ctx->model_filename,
1266 if (status !=
NULL) {
1267 const char *msg =
g_ort->GetErrorMessage(status);
1269 g_ort->ReleaseStatus(status);
1273 status =
g_ort->GetAllocatorWithDefaultOptions(&onnx_model->
allocator);
1274 if (status !=
NULL) {
1284 size_t input_count = 0;
1285 status =
g_ort->SessionGetInputCount(onnx_model->
session, &input_count);
1286 if (status !=
NULL) {
1287 const char *msg =
g_ort->GetErrorMessage(status);
1289 g_ort->ReleaseStatus(status);
1292 if (input_count == 0) {
1296 if (input_count > 1) {
1298 "ONNX model exposes %zu input tensors; the ONNX backend "
1299 "supports single-input models only.\n",
1306 if (!
ctx->model_inputname || !*
ctx->model_inputname) {
1308 status =
g_ort->SessionGetInputName(onnx_model->
session, 0,
1310 if (status !=
NULL) {
1311 const char *msg =
g_ort->GetErrorMessage(status);
1313 g_ort->ReleaseStatus(status);
1319 if (!
ctx->model_inputname)
1322 ctx->model_inputname);
1326 if (!
ctx->model_outputnames) {
1327 size_t output_count = 0;
1329 status =
g_ort->SessionGetOutputCount(onnx_model->
session, &output_count);
1330 if (status !=
NULL) {
1331 const char *msg =
g_ort->GetErrorMessage(status);
1333 g_ort->ReleaseStatus(status);
1336 if (output_count == 0) {
1340 status =
g_ort->SessionGetOutputName(onnx_model->
session, 0,
1342 if (status !=
NULL) {
1343 const char *msg =
g_ort->GetErrorMessage(status);
1345 g_ort->ReleaseStatus(status);
1348 ctx->model_outputnames =
av_calloc(1,
sizeof(*
ctx->model_outputnames));
1349 if (!
ctx->model_outputnames) {
1355 if (!
ctx->model_outputnames[0]) {
1359 ctx->nb_outputs = 1;
1360 if (output_count == 1) {
1362 ctx->model_outputnames[0]);
1365 "ONNX model exposes %zu output tensors; auto-using index 0 ('%s'). "
1366 "Specify output=NAME to choose a different one.\n",
1367 output_count,
ctx->model_outputnames[0]);
SwsAArch64OpImplParams params
static const AVFilterPad outputs[]
static AVFormatContext * ctx
simple assert() macros that are a bit more flexible than ISO C assert().
#define i(width, name, range_min, range_max)
#define AV_NUM_DETECTION_BBOX_CLASSIFY
At most 4 classifications based on the detected bounding box.
static av_always_inline AVDetectionBBox * av_get_detection_bbox(const AVDetectionBBoxHeader *header, unsigned int idx)
int ff_check_exec_params(void *ctx, DNNBackendType backend, DNNFunctionType func_type, DNNExecBaseParams *exec_params)
void ff_dnn_wait_requests(SafeQueue *request_queue, int nireq)
Wait for all inference requests to complete before teardown.
DNNAsyncStatusType ff_dnn_get_result_common(Queue *task_queue, AVFrame **in, AVFrame **out)
Extract input and output frame from the Task Queue after asynchronous inference.
int ff_dnn_async_module_cleanup(DNNAsyncExecModule *async_module)
Join the Async Execution thread and set module pointers to NULL.
int ff_dnn_fill_task(TaskItem *task, DNNExecBaseParams *exec_params, void *backend_model, int async, int do_ioproc)
Fill the Task for Backend Execution.
int ff_dnn_fill_gettingoutput_task(TaskItem *task, DNNExecBaseParams *exec_params, void *backend_model, int input_height, int input_width, void *ctx)
Allocate input and output frames and fill the Task with execution parameters.
DNN common functions different backends.
#define DNN_DEFINE_CLASS(fname)
static int dnn_execute_model_onnx(const DNNModel *model, DNNExecBaseParams *exec_params)
const DNNModule ff_dnn_backend_onnx
static const AVOption dnn_onnx_options[]
static int dnn_flush_onnx(const DNNModel *model)
static DNNModel * dnn_load_model_onnx(DnnContext *ctx, DNNFunctionType func_type, AVFilterContext *filter_ctx)
static int get_output_onnx(DNNModel *model, const char *input_name, int input_width, int input_height, const char *output_name, int *output_width, int *output_height)
static int fill_model_input_onnx(ONNXModel *onnx_model, ONNXRequestItem *request)
static ONNXInferRequest * onnx_create_inference_request(void)
static void init_ort_api(void)
static void onnx_free_request(ONNXInferRequest *request)
static const OrtApi * g_ort
static void dnn_free_model_onnx(DNNModel **model)
static DNNAsyncStatusType dnn_get_result_onnx(const DNNModel *model, AVFrame **in, AVFrame **out)
static AVOnce g_ort_init_once
static int onnx_start_inference(void *args)
static int extract_lltask_from_task(DNNFunctionType func_type, TaskItem *task, Queue *lltask_queue, DNNExecBaseParams *exec_params)
static int contain_valid_detection_bbox(AVFrame *frame)
static void destroy_request_item(ONNXRequestItem **arg)
static int execute_model_onnx(ONNXModel *onnx_model, ONNXRequestItem *request, Queue *lltask_queue)
static void infer_completion_callback(void *args)
static int get_input_onnx(DNNModel *model, DNNData *input, const char *input_name)
static int dnn_get_height_idx_by_layout(DNNLayout layout)
static int dnn_get_width_idx_by_layout(DNNLayout layout)
#define DNN_GENERIC_ERROR
static int dnn_get_channel_idx_by_layout(DNNLayout layout)
int ff_proc_from_frame_to_dnn(AVFrame *frame, DNNData *input, void *log_ctx)
int ff_frame_to_dnn_detect(AVFrame *frame, DNNData *input, void *log_ctx)
int ff_frame_to_dnn_classify(AVFrame *frame, DNNData *input, uint32_t bbox_index, void *log_ctx)
int ff_proc_from_dnn_to_frame(AVFrame *frame, DNNData *output, void *log_ctx)
DNN input&output process between AVFrame and DNNData.
int ff_dnn_onnx_d3d12_probe(void *d3d12_device_void, DnnOnnxD3D12TensorMem mem, int *is_uma, void *log_ctx)
Check whether the D3D12/DirectML path is usable on d3d12_device, without creating any lasting state.
int ff_dnn_onnx_d3d12_writeback(DnnOnnxD3D12Ctx *ctx, AVFrame *out)
Step 3/3 of the per-frame pipeline: write ctx's compact GPU output tensor back into the luma plane of...
int ff_dnn_onnx_d3d12_sync(DnnOnnxD3D12Ctx *ctx)
Block until all work submitted to ctx's shared command queue, by the helper and by the DirectML execu...
void ff_dnn_onnx_d3d12_free(DnnOnnxD3D12Ctx **ctx)
Release a context created by ff_dnn_onnx_d3d12_create(), including any buffers configured via ff_dnn_...
int ff_dnn_onnx_d3d12_run(DnnOnnxD3D12Ctx *ctx, void *session_void, const char *in_name, const char *out_name, void *in_tensor_void, void *out_tensor_void)
Step 2/3 of the per-frame pipeline: run the model against the tensors produced by ff_dnn_onnx_d3d12_f...
DnnOnnxD3D12Ctx * ff_dnn_onnx_d3d12_create(void *d3d12_device_void, DnnOnnxD3D12TensorMem mem, void *log_ctx)
Create a helper context bound to d3d12_device: a DirectML device and a single dedicated DIRECT comman...
int ff_dnn_onnx_d3d12_append_ep(DnnOnnxD3D12Ctx *ctx, void *session_options_void)
Append the DirectML execution provider to session_options, built on top of ctx's DirectML device and ...
int ff_dnn_onnx_d3d12_config(DnnOnnxD3D12Ctx *ctx, int in_w, int in_h, int out_w, int out_h, DNNDataType dt, DNNLayout layout, int channels)
Configure ctx's buffers for the given model input/output tensor.
int ff_dnn_onnx_d3d12_fill_input(DnnOnnxD3D12Ctx *ctx, const AVFrame *in, void **in_tensor, void **out_tensor)
Step 1/3 of the per-frame pipeline: extract the luma plane of the D3D12 NV12 input frame into ctx's c...
Pure C interface to the D3D12/DirectML GPU pipeline helper used by the ONNX Runtime backend and the d...
@ DNN_ONNX_D3D12_TENSOR_GPU
@ AV_OPT_TYPE_INT
Underlying C type is int.
AVFrameSideData * av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
@ AV_FRAME_DATA_DETECTION_BBOXES
Bounding boxes for object detection and classification, as described by AVDetectionBBoxHeader.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_INFO
Standard information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int av_size_mult(size_t a, size_t b, size_t *r)
Multiply two size_t values checking for overflow.
int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx)
Check if the given dimension of an image is valid, meaning that all bytes of the image can be address...
int av_strcasecmp(const char *a, const char *b)
Locale-independent case-insensitive compare.
int av_strncasecmp(const char *a, const char *b, size_t n)
Locale-independent case-insensitive compare.
@ AV_HWDEVICE_TYPE_D3D12VA
An API-specific header for AV_HWDEVICE_TYPE_D3D12VA.
#define AVFILTER_DEFINE_CLASS(fname)
void avpriv_report_missing_feature(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
static int ff_thread_once(char *control, void(*routine)(void))
void * av_calloc(size_t nmemb, size_t size)
Memory handling functions.
void ff_queue_destroy(Queue *q)
Destroy the Queue instance.
void * ff_queue_pop_front(Queue *q)
Remove and free first element from the Queue.
int ff_queue_push_back(Queue *q, void *v)
Add data to the tail of the queue.
void * ff_queue_peek_front(Queue *q)
Return a pointer to the data at the head of the queue.
size_t ff_queue_size(Queue *q)
Return the length of the Queue.
Queue * ff_queue_create(void)
Create a Queue instance.
int ff_safe_queue_push_back(SafeQueue *sq, void *v)
Add data to the tail of queue in the SafeQueue after locking mutex.
void * ff_safe_queue_pop_front(SafeQueue *sq)
Remove and free first element from the queue in SafeQueue.
size_t ff_safe_queue_size(SafeQueue *sq)
Return the length of the SafeQueue.
SafeQueue * ff_safe_queue_create(void)
Create and initialize a SafeQueue instance.
void ff_safe_queue_destroy(SafeQueue *sq)
Destroy the SafeQueue instance.
static const uint8_t header[24]
This struct is allocated as AVHWDeviceContext.hwctx.
ID3D12Device * device
Device used for objects creation and access.
char detect_label[AV_DETECTION_BBOX_LABEL_NAME_MAX_SIZE]
Detect result with confidence.
int x
Distance in pixels from the left/top edge of the frame, together with width and height,...
Structure to hold side data for an AVFrame.
This structure describes decoded (raw) audio or video data.
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.
AVHWDeviceContext * device_ctx
The parent AVHWDeviceContext.
Common Async Execution Mechanism for the DNN Backends.
void * args
Argument for the execution functions.
int(* start_inference)(void *request)
Synchronous inference function for the backend with corresponding request item as the argument.
void(* callback)(void *args)
Completion Callback for the backend.
int(* get_input)(struct DNNModel *model, DNNData *input, const char *input_name)
int(* get_output)(struct DNNModel *model, const char *input_name, int input_width, int input_height, const char *output_name, int *output_width, int *output_height)
FramePrePostProc frame_pre_proc
ClassifyPostProc classify_post_proc
FramePrePostProc frame_post_proc
DetectPostProc detect_post_proc
AVFilterContext * filter_ctx
DNNFunctionType func_type
OrtValue ** output_tensors
OrtSessionOptions * session_options
SafeQueue * request_queue
DNNAsyncExecModule exec_module
ONNXInferRequest * infer_request
LastLevelTaskItem * lltask
Linear double-ended data structure.
Double-ended queue with mutex locks ensuring data consistency while multithreading.
const char ** output_names
static FilteringContext * filter_ctx