You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-10 06:10:52 +02:00
avfilter/dnn: Remove a level of dereference
For code such as 'model->model = ov_model' is confusing. We can just drop the member variable and use cast to get the subclass. Signed-off-by: Zhao Zhili <zhilizhao@tencent.com> Reviewed-by: Wenbin Chen <wenbin.chen@intel.com> Reviewed-by: Guo Yejun <yejun.guo@intel.com>
This commit is contained in:
@@ -517,7 +517,7 @@ static void dnn_free_model_ov(DNNModel **model)
|
||||
if (!model || !*model)
|
||||
return;
|
||||
|
||||
ov_model = (*model)->model;
|
||||
ov_model = (OVModel *)(*model);
|
||||
while (ff_safe_queue_size(ov_model->request_queue) != 0) {
|
||||
OVRequestItem *item = ff_safe_queue_pop_front(ov_model->request_queue);
|
||||
if (item && item->infer_request) {
|
||||
@@ -1059,9 +1059,9 @@ err:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int get_input_ov(void *model, DNNData *input, const char *input_name)
|
||||
static int get_input_ov(DNNModel *model, DNNData *input, const char *input_name)
|
||||
{
|
||||
OVModel *ov_model = model;
|
||||
OVModel *ov_model = (OVModel *)model;
|
||||
DnnContext *ctx = ov_model->ctx;
|
||||
int input_resizable = ctx->ov_option.input_resizable;
|
||||
|
||||
@@ -1255,7 +1255,7 @@ static int extract_lltask_from_task(DNNFunctionType func_type, TaskItem *task, Q
|
||||
}
|
||||
}
|
||||
|
||||
static int get_output_ov(void *model, const char *input_name, int input_width, int input_height,
|
||||
static int get_output_ov(DNNModel *model, const char *input_name, int input_width, int input_height,
|
||||
const char *output_name, int *output_width, int *output_height)
|
||||
{
|
||||
#if HAVE_OPENVINO2
|
||||
@@ -1268,7 +1268,7 @@ static int get_output_ov(void *model, const char *input_name, int input_width, i
|
||||
input_shapes_t input_shapes;
|
||||
#endif
|
||||
int ret;
|
||||
OVModel *ov_model = model;
|
||||
OVModel *ov_model = (OVModel *)model;
|
||||
DnnContext *ctx = ov_model->ctx;
|
||||
TaskItem task;
|
||||
OVRequestItem *request;
|
||||
@@ -1383,7 +1383,6 @@ static DNNModel *dnn_load_model_ov(DnnContext *ctx, DNNFunctionType func_type, A
|
||||
return NULL;
|
||||
ov_model->ctx = ctx;
|
||||
model = &ov_model->model;
|
||||
model->model = ov_model;
|
||||
|
||||
#if HAVE_OPENVINO2
|
||||
status = ov_core_create(&core);
|
||||
@@ -1470,7 +1469,7 @@ err:
|
||||
|
||||
static int dnn_execute_model_ov(const DNNModel *model, DNNExecBaseParams *exec_params)
|
||||
{
|
||||
OVModel *ov_model = model->model;
|
||||
OVModel *ov_model = (OVModel *)model;
|
||||
DnnContext *ctx = ov_model->ctx;
|
||||
OVRequestItem *request;
|
||||
TaskItem *task;
|
||||
@@ -1558,13 +1557,13 @@ static int dnn_execute_model_ov(const DNNModel *model, DNNExecBaseParams *exec_p
|
||||
|
||||
static DNNAsyncStatusType dnn_get_result_ov(const DNNModel *model, AVFrame **in, AVFrame **out)
|
||||
{
|
||||
OVModel *ov_model = model->model;
|
||||
OVModel *ov_model = (OVModel *)model;
|
||||
return ff_dnn_get_result_common(ov_model->task_queue, in, out);
|
||||
}
|
||||
|
||||
static int dnn_flush_ov(const DNNModel *model)
|
||||
{
|
||||
OVModel *ov_model = model->model;
|
||||
OVModel *ov_model = (OVModel *)model;
|
||||
DnnContext *ctx = ov_model->ctx;
|
||||
OVRequestItem *request;
|
||||
#if HAVE_OPENVINO2
|
||||
|
@@ -262,9 +262,9 @@ static TF_Tensor *allocate_input_tensor(const DNNData *input)
|
||||
input_dims[1] * input_dims[2] * input_dims[3] * size);
|
||||
}
|
||||
|
||||
static int get_input_tf(void *model, DNNData *input, const char *input_name)
|
||||
static int get_input_tf(DNNModel *model, DNNData *input, const char *input_name)
|
||||
{
|
||||
TFModel *tf_model = model;
|
||||
TFModel *tf_model = (TFModel *)model;
|
||||
DnnContext *ctx = tf_model->ctx;
|
||||
TF_Status *status;
|
||||
TF_DataType dt;
|
||||
@@ -310,11 +310,11 @@ static int get_input_tf(void *model, DNNData *input, const char *input_name)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_output_tf(void *model, const char *input_name, int input_width, int input_height,
|
||||
static int get_output_tf(DNNModel *model, const char *input_name, int input_width, int input_height,
|
||||
const char *output_name, int *output_width, int *output_height)
|
||||
{
|
||||
int ret;
|
||||
TFModel *tf_model = model;
|
||||
TFModel *tf_model = (TFModel *)model;
|
||||
DnnContext *ctx = tf_model->ctx;
|
||||
TaskItem task;
|
||||
TFRequestItem *request;
|
||||
@@ -486,7 +486,7 @@ static void dnn_free_model_tf(DNNModel **model)
|
||||
if (!model || !*model)
|
||||
return;
|
||||
|
||||
tf_model = (*model)->model;
|
||||
tf_model = (TFModel *)(*model);
|
||||
while (ff_safe_queue_size(tf_model->request_queue) != 0) {
|
||||
TFRequestItem *item = ff_safe_queue_pop_front(tf_model->request_queue);
|
||||
destroy_request_item(&item);
|
||||
@@ -530,7 +530,6 @@ static DNNModel *dnn_load_model_tf(DnnContext *ctx, DNNFunctionType func_type, A
|
||||
if (!tf_model)
|
||||
return NULL;
|
||||
model = &tf_model->model;
|
||||
model->model = tf_model;
|
||||
tf_model->ctx = ctx;
|
||||
|
||||
if (load_tf_model(tf_model, ctx->model_filename) != 0){
|
||||
@@ -611,7 +610,7 @@ static int fill_model_input_tf(TFModel *tf_model, TFRequestItem *request) {
|
||||
task = lltask->task;
|
||||
request->lltask = lltask;
|
||||
|
||||
ret = get_input_tf(tf_model, &input, task->input_name);
|
||||
ret = get_input_tf(&tf_model->model, &input, task->input_name);
|
||||
if (ret != 0) {
|
||||
goto err;
|
||||
}
|
||||
@@ -803,7 +802,7 @@ err:
|
||||
|
||||
static int dnn_execute_model_tf(const DNNModel *model, DNNExecBaseParams *exec_params)
|
||||
{
|
||||
TFModel *tf_model = model->model;
|
||||
TFModel *tf_model = (TFModel *)model;
|
||||
DnnContext *ctx = tf_model->ctx;
|
||||
TaskItem *task;
|
||||
TFRequestItem *request;
|
||||
@@ -851,13 +850,13 @@ static int dnn_execute_model_tf(const DNNModel *model, DNNExecBaseParams *exec_p
|
||||
|
||||
static DNNAsyncStatusType dnn_get_result_tf(const DNNModel *model, AVFrame **in, AVFrame **out)
|
||||
{
|
||||
TFModel *tf_model = model->model;
|
||||
TFModel *tf_model = (TFModel *)model;
|
||||
return ff_dnn_get_result_common(tf_model->task_queue, in, out);
|
||||
}
|
||||
|
||||
static int dnn_flush_tf(const DNNModel *model)
|
||||
{
|
||||
TFModel *tf_model = model->model;
|
||||
TFModel *tf_model = (TFModel *)model;
|
||||
DnnContext *ctx = tf_model->ctx;
|
||||
TFRequestItem *request;
|
||||
int ret;
|
||||
|
@@ -119,7 +119,7 @@ static void dnn_free_model_th(DNNModel **model)
|
||||
if (!model || !*model)
|
||||
return;
|
||||
|
||||
th_model = (THModel *) (*model)->model;
|
||||
th_model = (THModel *) (*model);
|
||||
while (ff_safe_queue_size(th_model->request_queue) != 0) {
|
||||
THRequestItem *item = (THRequestItem *)ff_safe_queue_pop_front(th_model->request_queue);
|
||||
destroy_request_item(&item);
|
||||
@@ -144,7 +144,7 @@ static void dnn_free_model_th(DNNModel **model)
|
||||
*model = NULL;
|
||||
}
|
||||
|
||||
static int get_input_th(void *model, DNNData *input, const char *input_name)
|
||||
static int get_input_th(DNNModel *model, DNNData *input, const char *input_name)
|
||||
{
|
||||
input->dt = DNN_FLOAT;
|
||||
input->order = DCO_RGB;
|
||||
@@ -179,7 +179,7 @@ static int fill_model_input_th(THModel *th_model, THRequestItem *request)
|
||||
task = lltask->task;
|
||||
infer_request = request->infer_request;
|
||||
|
||||
ret = get_input_th(th_model, &input, NULL);
|
||||
ret = get_input_th(&th_model->model, &input, NULL);
|
||||
if ( ret != 0) {
|
||||
goto err;
|
||||
}
|
||||
@@ -356,7 +356,7 @@ err:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int get_output_th(void *model, const char *input_name, int input_width, int input_height,
|
||||
static int get_output_th(DNNModel *model, const char *input_name, int input_width, int input_height,
|
||||
const char *output_name, int *output_width, int *output_height)
|
||||
{
|
||||
int ret = 0;
|
||||
@@ -421,7 +421,6 @@ static DNNModel *dnn_load_model_th(DnnContext *ctx, DNNFunctionType func_type, A
|
||||
if (!th_model)
|
||||
return NULL;
|
||||
model = &th_model->model;
|
||||
model->model = th_model;
|
||||
th_model->ctx = ctx;
|
||||
|
||||
c10::Device device = c10::Device(device_name);
|
||||
@@ -489,7 +488,7 @@ fail:
|
||||
|
||||
static int dnn_execute_model_th(const DNNModel *model, DNNExecBaseParams *exec_params)
|
||||
{
|
||||
THModel *th_model = (THModel *)model->model;
|
||||
THModel *th_model = (THModel *)model;
|
||||
DnnContext *ctx = th_model->ctx;
|
||||
TaskItem *task;
|
||||
THRequestItem *request;
|
||||
@@ -538,13 +537,13 @@ static int dnn_execute_model_th(const DNNModel *model, DNNExecBaseParams *exec_p
|
||||
|
||||
static DNNAsyncStatusType dnn_get_result_th(const DNNModel *model, AVFrame **in, AVFrame **out)
|
||||
{
|
||||
THModel *th_model = (THModel *)model->model;
|
||||
THModel *th_model = (THModel *)model;
|
||||
return ff_dnn_get_result_common(th_model->task_queue, in, out);
|
||||
}
|
||||
|
||||
static int dnn_flush_th(const DNNModel *model)
|
||||
{
|
||||
THModel *th_model = (THModel *)model->model;
|
||||
THModel *th_model = (THModel *)model;
|
||||
THRequestItem *request;
|
||||
|
||||
if (ff_queue_size(th_model->lltask_queue) == 0)
|
||||
|
Reference in New Issue
Block a user