Commit 64f6bcffaf for ffmpeg
commit 64f6bcffaf2646d76463c89f13a8ae9abe0a1b66
Author: Dong Nguyen <Dong.Nguyen@amd.com>
Date: Mon Oct 19 11:30:04 2026 -0400
avfilter/dnn: add DNN_UINT8 tensor support to ONNX Runtime and LibTorch
Add UINT8 input/output tensor support to the ONNX Runtime backend and
UINT8 input support to the LibTorch backend.
For LibTorch, add an input_dtype option (auto/float/uint8) to select
the input tensor dtype. Detecting the dtype from the model graph
doesn't work reliably: saving and reloading a TorchScript model drops
the input scalar type, and FFmpeg always loads models from disk. auto
keeps the old best effort behavior as the default; float and uint8 let
the user set it directly. Software frames support UINT8 input and
output. CUDA frames only support FLOAT input and output, and reject
UINT8 with an error.
For ONNX Runtime, fix the GRAYF32 branches in dnn_io_proc.c that
copied tensor data as float regardless of dtype, which corrupted
memory for UINT8 tensors. They now use sws_scale() for UINT8, and the
YUV/GRAY8/NV12 output branch uses the computed source format instead
of a hardcoded one.
Reject UINT8 output outside frame processing, since the detection and
classification postprocessors read the output as float and would read
past a UINT8 buffer.
Reject UINT8 input for the TensorFlow backend, which does not set the
tensor scale or convert the frame, so it would run on unconverted data.
Returns AVERROR(EIO).
input_dtype reuses the existing DNNDataType enum instead of a separate
enum, per review from guoyejun. DNNDataType gets an auto value of 0
and UINT8 changes from 4 to 2 so auto/float/uint8 sort in order. The
TensorFlow backend had one spot that cast TF_DataType straight to
DNNDataType, assuming the numeric values lined up with TF_UINT8 being
4. That now goes through an explicit switch instead, so it keeps
working with the renumbered UINT8 value.
Reject unsupported TensorFlow output types before the task is queued,
in dnn_execute_model_tf, so an unsupported type returns an error at
call time instead of reaching the async worker. This replaces the
earlier failure flag, which was written on the inference thread and
read without synchronization and could be dropped during detect
flushing.
The grayscale/luma conversion and detection output safety issues were
reported by Forgejo_Fairy in #24309.
diff --git a/doc/filters.texi b/doc/filters.texi
index fb866d24d1..c420e1c76c 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -12324,18 +12324,30 @@ when the input format qualifies; no additional options are required.
When the input format is not @code{AV_PIX_FMT_CUDA}, the backend uses
the standard CPU tensor path.
+The common @option{input_dtype} option currently selects the LibTorch
+input tensor element type: @code{auto} (default), @code{float}, or
+@code{uint8}. @code{auto} tries to detect the type from the model graph
+and falls back to @code{float} if that fails; set
+@code{input_dtype=uint8} explicitly for a model requiring UINT8 input
+when auto-detection fails. Other backends do not currently use this
+option to override their input tensor type.
+
+For LibTorch software-frame processing, input and output tensors may
+be @code{float} or @code{uint8}. Processing CUDA-backed frames requires
+a model accepting @code{float} input and returning @code{float} output.
+
@item onnx
ONNX Runtime backend. To enable this backend you need to install the
ONNX Runtime library (see @url{https://onnxruntime.ai/}) and configure
FFmpeg with @code{--enable-libonnxruntime}.
The current ONNX Runtime backend expects 4-D input and output tensors
-with NCHW layout and 32-bit floating-point element type (ONNX
-@code{FLOAT}); models with integer or other element types (e.g.
-@code{UINT8}) are not supported and will be rejected at load time.
-Models using NHWC layout or other ranks are not yet
-supported. Only single-input models are supported; the backend binds
-exactly one input tensor when running the model.
+with NCHW layout. For @code{dnn_processing}, both 32-bit floating-point
+(ONNX @code{FLOAT}) and 8-bit unsigned integer (ONNX @code{UINT8})
+element types are supported; other element types are not supported and
+will be rejected at load time. Models using NHWC layout or other ranks
+are not yet supported. Only single-input models are supported; the
+backend binds exactly one input tensor when running the model.
The @option{input} and @option{output} options are optional for the
ONNX Runtime backend; when they are omitted the backend resolves the
diff --git a/libavfilter/dnn/dnn_backend_onnx.c b/libavfilter/dnn/dnn_backend_onnx.c
index dcd843f929..48e899ba82 100644
--- a/libavfilter/dnn/dnn_backend_onnx.c
+++ b/libavfilter/dnn/dnn_backend_onnx.c
@@ -472,8 +472,11 @@ static int get_input_onnx(DNNModel *model, DNNData *input, const char *input_nam
if (tensor_type == ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT) {
input->dt = DNN_FLOAT;
+ } else if (tensor_type == ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT8) {
+ input->dt = DNN_UINT8;
} else {
- av_log(ctx, AV_LOG_ERROR, "Unsupported input tensor data type, only float is supported\n");
+ av_log(ctx, AV_LOG_ERROR, "Unsupported input tensor data type, "
+ "only float and uint8 are supported\n");
av_free(dims);
g_ort->ReleaseTypeInfo(type_info);
return AVERROR(ENOSYS);
@@ -579,7 +582,7 @@ static int fill_model_input_onnx(ONNXModel *onnx_model, ONNXRequestItem *request
* Build the byte count with checked size_t multiplications instead of
* multiplying four int64_t shape values in one expression.
*/
- input_tensor_size = sizeof(float);
+ input_tensor_size = (input.dt == DNN_UINT8) ? sizeof(uint8_t) : sizeof(float);
if (av_size_mult(input_tensor_size, (size_t)input_shape[0], &input_tensor_size) < 0 ||
av_size_mult(input_tensor_size, (size_t)input_shape[1], &input_tensor_size) < 0 ||
av_size_mult(input_tensor_size, (size_t)input_shape[2], &input_tensor_size) < 0 ||
@@ -598,7 +601,7 @@ static int fill_model_input_onnx(ONNXModel *onnx_model, ONNXRequestItem *request
switch (onnx_model->model.func_type) {
case DFT_PROCESS_FRAME:
- input.scale = 255;
+ input.scale = (input.dt == DNN_UINT8) ? 1 : 255;
if (task->do_ioproc) {
if (onnx_model->model.frame_pre_proc != NULL) {
ret = onnx_model->model.frame_pre_proc(task->in_frame, &input,
@@ -634,7 +637,9 @@ static int fill_model_input_onnx(ONNXModel *onnx_model, ONNXRequestItem *request
status = g_ort->CreateTensorWithDataAsOrtValue(
memory_info, input.data, input_tensor_size,
- input_shape, 4, ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT,
+ input_shape, 4,
+ (input.dt == DNN_UINT8) ? ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT8
+ : ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT,
&infer_request->input_tensor);
g_ort->ReleaseMemoryInfo(memory_info);
@@ -863,9 +868,21 @@ static void infer_completion_callback(void *args)
}
if (tensor_type == ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT) {
outputs[i].dt = DNN_FLOAT;
+ } else if (tensor_type == ONNX_TENSOR_ELEMENT_DATA_TYPE_UINT8) {
+ outputs[i].dt = DNN_UINT8;
} else {
av_log(ctx, AV_LOG_ERROR,
- "Unsupported output tensor[%u] data type, only float supported\n", i);
+ "Unsupported output tensor[%u] data type, "
+ "only float and uint8 are supported\n", i);
+ av_free(dims);
+ g_ort->ReleaseTensorTypeAndShapeInfo(tensor_info);
+ goto err;
+ }
+
+ if (outputs[i].dt == DNN_UINT8 &&
+ onnx_model->model.func_type != DFT_PROCESS_FRAME) {
+ av_log(ctx, AV_LOG_ERROR,
+ "UINT8 output tensors are only supported for frame processing\n");
av_free(dims);
g_ort->ReleaseTensorTypeAndShapeInfo(tensor_info);
goto err;
@@ -941,7 +958,7 @@ static void infer_completion_callback(void *args)
switch (onnx_model->model.func_type) {
case DFT_PROCESS_FRAME:
if (task->do_ioproc) {
- outputs[0].scale = 255;
+ outputs[0].scale = (outputs[0].dt == DNN_UINT8) ? 1 : 255;
if (onnx_model->model.frame_post_proc != NULL) {
onnx_model->model.frame_post_proc(task->out_frame, outputs, onnx_model->model.filter_ctx);
} else {
diff --git a/libavfilter/dnn/dnn_backend_tf.c b/libavfilter/dnn/dnn_backend_tf.c
index 51dd88ce1c..cbf2022b95 100644
--- a/libavfilter/dnn/dnn_backend_tf.c
+++ b/libavfilter/dnn/dnn_backend_tf.c
@@ -716,7 +716,18 @@ static void infer_completion_callback(void *args) {
outputs[i].dims[dnn_get_channel_idx_by_layout(outputs[i].layout)] =
TF_Dim(infer_request->output_tensors[i], 3);
outputs[i].data = TF_TensorData(infer_request->output_tensors[i]);
- outputs[i].dt = (DNNDataType)TF_TensorType(infer_request->output_tensors[i]);
+ switch (TF_TensorType(infer_request->output_tensors[i])) {
+ case TF_FLOAT:
+ outputs[i].dt = DNN_FLOAT;
+ break;
+ case TF_UINT8:
+ outputs[i].dt = DNN_UINT8;
+ break;
+ default:
+ av_log(ctx, AV_LOG_ERROR, "Unsupported output type %d in model\n",
+ TF_TensorType(infer_request->output_tensors[i]));
+ goto err;
+ }
}
switch (tf_model->model.func_type) {
case DFT_PROCESS_FRAME:
@@ -817,6 +828,24 @@ static int dnn_execute_model_tf(const DNNModel *model, DNNExecBaseParams *exec_p
return ret;
}
+ for (uint32_t i = 0; i < exec_params->nb_output; i++) {
+ TF_Output tf_output;
+ TF_DataType dt;
+
+ tf_output.oper = TF_GraphOperationByName(tf_model->graph, exec_params->output_names[i]);
+ if (!tf_output.oper || TF_OperationNumOutputs(tf_output.oper) < 1) {
+ av_log(ctx, AV_LOG_ERROR, "Could not find output \"%s\" in model\n",
+ exec_params->output_names[i]);
+ return AVERROR(EINVAL);
+ }
+ tf_output.index = 0;
+ dt = TF_OperationOutputType(tf_output);
+ if (dt != TF_FLOAT && dt != TF_UINT8) {
+ av_log(ctx, AV_LOG_ERROR, "Unsupported output type %d in model\n", dt);
+ return AVERROR(ENOSYS);
+ }
+ }
+
task = av_malloc(sizeof(*task));
if (!task) {
av_log(ctx, AV_LOG_ERROR, "unable to alloc memory for task item.\n");
diff --git a/libavfilter/dnn/dnn_backend_torch.cpp b/libavfilter/dnn/dnn_backend_torch.cpp
index 59ab0a9c72..0a3eb26789 100644
--- a/libavfilter/dnn/dnn_backend_torch.cpp
+++ b/libavfilter/dnn/dnn_backend_torch.cpp
@@ -65,7 +65,6 @@ typedef struct THRequestItem {
DNNAsyncExecModule exec_module;
} THRequestItem;
-
#define OFFSET(x) offsetof(THOptions, x)
#define FLAGS AV_OPT_FLAG_FILTERING_PARAM
static const AVOption dnn_th_options[] = {
@@ -153,13 +152,51 @@ static void dnn_free_model_th(DNNModel **model)
static int get_input_th(DNNModel *model, DNNData *input, const char *input_name)
{
- input->dt = DNN_FLOAT;
+ THModel *th_model = (THModel *)model;
+
input->order = DCO_RGB;
input->layout = DL_NCHW;
input->dims[0] = 1;
input->dims[1] = 3;
input->dims[2] = -1;
input->dims[3] = -1;
+
+ switch (th_model->ctx->input_dtype) {
+ case DNN_FLOAT:
+ input->dt = DNN_FLOAT;
+ break;
+ case DNN_UINT8:
+ input->dt = DNN_UINT8;
+ break;
+ case DNN_AUTO:
+ default:
+ input->dt = DNN_FLOAT;
+
+ /* save/reload via torch::jit::load() erases graph scalar types, so
+ * detection rarely succeeds; set input_dtype=uint8 when it fails. */
+ try {
+ auto forward_method = th_model->jit_model->get_method("forward");
+ auto graph = forward_method.graph();
+ auto graph_inputs = graph->inputs();
+ for (auto gi : graph_inputs) {
+ if (auto tt = gi->type()->cast<c10::TensorType>()) {
+ if (tt->scalarType().has_value()) {
+ if (*tt->scalarType() == c10::kByte) {
+ input->dt = DNN_UINT8;
+ av_log(th_model->ctx, AV_LOG_VERBOSE,
+ "Detected UINT8 input tensor dtype from model graph\n");
+ }
+ break;
+ }
+ }
+ }
+ } catch (const c10::Error& e) {
+ av_log(th_model->ctx, AV_LOG_VERBOSE,
+ "Could not inspect model graph for input dtype, defaulting to DNN_FLOAT\n");
+ }
+ break;
+ }
+
return 0;
}
@@ -296,7 +333,8 @@ static int fill_model_input_th(THModel *th_model, THRequestItem *request)
DnnContext *ctx = th_model->ctx;
int ret, width_idx, height_idx, channel_idx;
int batch_size = ctx->batch_size;
- float *batch_data = NULL;
+ void *batch_data = NULL;
+ size_t input_tensor_size;
int frame_size = 0;
infer_request = request->infer_request;
@@ -319,7 +357,8 @@ static int fill_model_input_th(THModel *th_model, THRequestItem *request)
input.dims[width_idx] = task->in_frame->width;
frame_size = input.dims[height_idx] * input.dims[width_idx] * input.dims[channel_idx];
- batch_data = (float *)av_malloc(batch_size * frame_size * sizeof(float));
+ input_tensor_size = (input.dt == DNN_UINT8) ? sizeof(uint8_t) : sizeof(float);
+ batch_data = av_malloc(batch_size * frame_size * input_tensor_size);
if (!batch_data) {
ret = AVERROR(ENOMEM);
goto err;
@@ -334,11 +373,11 @@ static int fill_model_input_th(THModel *th_model, THRequestItem *request)
request->lltask_count = i + 1;
task = lltask->task;
- input.data = batch_data + i * frame_size;
+ input.data = (char *)batch_data + i * frame_size * input_tensor_size;
switch (th_model->model.func_type) {
case DFT_PROCESS_FRAME:
- input.scale = 255;
+ input.scale = (input.dt == DNN_UINT8) ? 1 : 255;
if (task->do_ioproc) {
if (th_model->model.frame_pre_proc != NULL) {
th_model->model.frame_pre_proc(task->in_frame, &input, th_model->model.filter_ctx);
@@ -357,7 +396,7 @@ static int fill_model_input_th(THModel *th_model, THRequestItem *request)
infer_request->output = new torch::Tensor();
*infer_request->input_tensor = torch::from_blob(batch_data,
{request->lltask_count, input.dims[channel_idx], input.dims[height_idx], input.dims[width_idx]},
- deleter, torch::kFloat32);
+ deleter, (input.dt == DNN_UINT8) ? torch::kUInt8 : torch::kFloat32);
return 0;
@@ -427,7 +466,7 @@ static void infer_completion_callback(void *args) {
outputs.order = DCO_RGB;
outputs.layout = DL_NCHW;
- outputs.dt = DNN_FLOAT;
+ outputs.dt = (out_slice.dtype() == torch::kUInt8) ? DNN_UINT8 : DNN_FLOAT;
if (sizes.size() == 4) {
// 4 dimensions: [batch_size, channel, height, width]
@@ -446,12 +485,18 @@ static void infer_completion_callback(void *args) {
if (task->do_ioproc) {
#if CONFIG_CUDA
if (task->out_frame->format == AV_PIX_FMT_CUDA) {
+ if (outputs.dt == DNN_UINT8) {
+ av_log(th_model->ctx, AV_LOG_ERROR,
+ "UINT8 output is not supported for CUDA frames; the "
+ "model must return a FLOAT tensor for CUDA inference\n");
+ goto err;
+ }
fill_model_output_th_cuda(th_model, task, out_slice);
} else {
#endif
if (out_slice.device() != torch::kCPU)
out_slice = out_slice.to(torch::kCPU);
- outputs.scale = 255;
+ outputs.scale = (outputs.dt == DNN_UINT8) ? 1 : 255;
outputs.data = out_slice.data_ptr();
if (th_model->model.frame_post_proc != NULL) {
th_model->model.frame_post_proc(task->out_frame, &outputs,
@@ -512,6 +557,19 @@ static int execute_model_th(THRequestItem *request, Queue *lltask_queue)
#if CONFIG_CUDA
if (task->in_frame->format == AV_PIX_FMT_CUDA) {
+ DNNData input = { 0 };
+
+ ret = get_input_th(&th_model->model, &input, NULL);
+ if (ret != 0) {
+ goto err;
+ }
+ if (input.dt == DNN_UINT8) {
+ av_log(th_model->ctx, AV_LOG_ERROR,
+ "UINT8 input is not supported for CUDA frames; use software "
+ "frames, or set input_dtype=float for CUDA inference\n");
+ ret = AVERROR(ENOSYS);
+ goto err;
+ }
ret = fill_model_input_th_cuda(th_model, request);
} else {
ret = fill_model_input_th(th_model, request);
diff --git a/libavfilter/dnn/dnn_interface.c b/libavfilter/dnn/dnn_interface.c
index 2cf81793de..914a567434 100644
--- a/libavfilter/dnn/dnn_interface.c
+++ b/libavfilter/dnn/dnn_interface.c
@@ -60,6 +60,11 @@ static const AVOption dnn_base_options[] = {
OFFSET(device), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS},
{"device_id", "device ID to run model",
OFFSET(device_id), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, FLAGS},
+ {"input_dtype", "input tensor data type",
+ OFFSET(input_dtype), AV_OPT_TYPE_INT, {.i64 = DNN_AUTO}, DNN_AUTO, DNN_UINT8, FLAGS, "input_dtype"},
+ {"auto", "auto-detect from model graph, fall back to float", 0, AV_OPT_TYPE_CONST, {.i64 = DNN_AUTO}, 0, 0, FLAGS, "input_dtype"},
+ {"float", "float32 input tensor", 0, AV_OPT_TYPE_CONST, {.i64 = DNN_FLOAT}, 0, 0, FLAGS, "input_dtype"},
+ {"uint8", "uint8 input tensor", 0, AV_OPT_TYPE_CONST, {.i64 = DNN_UINT8}, 0, 0, FLAGS, "input_dtype"},
{NULL}
};
diff --git a/libavfilter/dnn/dnn_io_proc.c b/libavfilter/dnn/dnn_io_proc.c
index 7c58d5cd02..2d706d479a 100644
--- a/libavfilter/dnn/dnn_io_proc.c
+++ b/libavfilter/dnn/dnn_io_proc.c
@@ -151,9 +151,28 @@ int ff_proc_from_dnn_to_frame(AVFrame *frame, DNNData *output, void *log_ctx)
}
break;
case AV_PIX_FMT_GRAYF32:
- av_image_copy_plane(frame->data[0], frame->linesize[0],
- output->data, bytewidth,
- bytewidth, frame->height);
+ if (output->dt == DNN_FLOAT) {
+ av_image_copy_plane(frame->data[0], frame->linesize[0],
+ output->data, bytewidth,
+ bytewidth, frame->height);
+ } else {
+ av_assert0(output->dt == DNN_UINT8);
+ sws_ctx = sws_getContext(frame->width, frame->height,
+ AV_PIX_FMT_GRAY8,
+ frame->width, frame->height,
+ AV_PIX_FMT_GRAYF32,
+ 0, NULL, NULL, NULL);
+ if (!sws_ctx) {
+ ret = AVERROR(EINVAL);
+ goto err;
+ }
+ sws_scale(sws_ctx,
+ (const uint8_t *[4]){(const uint8_t *)output->data, 0, 0, 0},
+ (const int[4]){frame->width * src_datatype_size, 0, 0, 0},
+ 0, frame->height,
+ (uint8_t * const*)frame->data, frame->linesize);
+ sws_freeContext(sws_ctx);
+ }
break;
case AV_PIX_FMT_YUV420P:
case AV_PIX_FMT_YUV422P:
@@ -164,7 +183,7 @@ int ff_proc_from_dnn_to_frame(AVFrame *frame, DNNData *output, void *log_ctx)
case AV_PIX_FMT_NV12:
sws_ctx = sws_getContext(frame->width,
frame->height,
- AV_PIX_FMT_GRAYF32,
+ src_fmt,
frame->width,
frame->height,
AV_PIX_FMT_GRAY8,
@@ -293,9 +312,28 @@ int ff_proc_from_frame_to_dnn(AVFrame *frame, DNNData *input, void *log_ctx)
sws_freeContext(sws_ctx);
break;
case AV_PIX_FMT_GRAYF32:
- av_image_copy_plane(input->data, bytewidth,
- frame->data[0], frame->linesize[0],
- bytewidth, frame->height);
+ if (input->dt == DNN_FLOAT) {
+ av_image_copy_plane(input->data, bytewidth,
+ frame->data[0], frame->linesize[0],
+ bytewidth, frame->height);
+ } else {
+ sws_ctx = sws_getContext(frame->width, frame->height,
+ AV_PIX_FMT_GRAYF32,
+ frame->width, frame->height,
+ AV_PIX_FMT_GRAY8,
+ 0, NULL, NULL, NULL);
+ if (!sws_ctx) {
+ ret = AVERROR(EINVAL);
+ goto err;
+ }
+ sws_scale(sws_ctx,
+ (const uint8_t *[4]){frame->data[0], 0, 0, 0},
+ (const int[4]){frame->linesize[0], 0, 0, 0},
+ 0, frame->height,
+ (uint8_t * const[4]){input->data, 0, 0, 0},
+ (const int[4]){frame->width * dst_datatype_size, 0, 0, 0});
+ sws_freeContext(sws_ctx);
+ }
break;
case AV_PIX_FMT_YUV420P:
case AV_PIX_FMT_YUV422P:
diff --git a/libavfilter/dnn_interface.h b/libavfilter/dnn_interface.h
index 29ba2870b2..c7afaf4fde 100644
--- a/libavfilter/dnn_interface.h
+++ b/libavfilter/dnn_interface.h
@@ -39,7 +39,7 @@ typedef enum {
DNN_ONNX = 1 << 3
} DNNBackendType;
-typedef enum {DNN_FLOAT = 1, DNN_UINT8 = 4} DNNDataType;
+typedef enum {DNN_AUTO = 0, DNN_FLOAT = 1, DNN_UINT8 = 2} DNNDataType;
typedef enum {
DCO_NONE,
@@ -167,6 +167,7 @@ typedef struct DnnContext {
int batch_size;
char *device;
int device_id;
+ int input_dtype;
AVBufferRef *hw_frames_ctx;
int zero_copy_negotiated;
diff --git a/libavfilter/vf_dnn_processing.c b/libavfilter/vf_dnn_processing.c
index 96c72e09a6..d0c1721b6b 100644
--- a/libavfilter/vf_dnn_processing.c
+++ b/libavfilter/vf_dnn_processing.c
@@ -103,7 +103,8 @@ static const enum AVPixelFormat pix_fmts[] = {
av_get_pix_fmt_name(fmt), \
model_input->dims[dnn_get_channel_idx_by_layout(model_input->layout)]);
-static int check_modelinput_inlink(const DNNData *model_input, const AVFilterLink *inlink)
+static int check_modelinput_inlink(const DNNData *model_input, const AVFilterLink *inlink,
+ DNNBackendType backend_type)
{
AVFilterContext *ctx = inlink->dst;
enum AVPixelFormat fmt = inlink->format;
@@ -126,8 +127,13 @@ static int check_modelinput_inlink(const DNNData *model_input, const AVFilterLin
inlink->w);
return AVERROR(EIO);
}
- if (model_input->dt != DNN_FLOAT) {
- avpriv_report_missing_feature(ctx, "data type rather than DNN_FLOAT");
+ if (model_input->dt != DNN_FLOAT && model_input->dt != DNN_UINT8) {
+ avpriv_report_missing_feature(ctx, "data type other than DNN_FLOAT or DNN_UINT8");
+ return AVERROR(EIO);
+ }
+
+ if (model_input->dt == DNN_UINT8 && backend_type == DNN_TF) {
+ avpriv_report_missing_feature(ctx, "DNN_UINT8 input for the TensorFlow backend");
return AVERROR(EIO);
}
@@ -231,7 +237,7 @@ static int config_input(AVFilterLink *inlink)
return result;
}
- check = check_modelinput_inlink(&model_input, inlink);
+ check = check_modelinput_inlink(&model_input, inlink, ctx->dnnctx.backend_type);
if (check != 0) {
return check;
}