1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

dnn: remove type cast which is not necessary

This commit is contained in:
Guo, Yejun 2021-01-22 22:20:15 +08:00
parent a163aa6cf7
commit 06c01f1763
11 changed files with 30 additions and 30 deletions

View File

@ -50,7 +50,7 @@ static DNNReturnType execute_model_native(const DNNModel *model, const char *inp
static DNNReturnType get_input_native(void *model, DNNData *input, const char *input_name)
{
NativeModel *native_model = (NativeModel *)model;
NativeModel *native_model = model;
NativeContext *ctx = &native_model->ctx;
for (int i = 0; i < native_model->operands_num; ++i) {
@ -78,7 +78,7 @@ static DNNReturnType get_output_native(void *model, const char *input_name, int
const char *output_name, int *output_width, int *output_height)
{
DNNReturnType ret;
NativeModel *native_model = (NativeModel *)model;
NativeModel *native_model = model;
NativeContext *ctx = &native_model->ctx;
AVFrame *in_frame = av_frame_alloc();
AVFrame *out_frame = NULL;
@ -269,7 +269,7 @@ static DNNReturnType execute_model_native(const DNNModel *model, const char *inp
const char **output_names, uint32_t nb_output, AVFrame *out_frame,
int do_ioproc)
{
NativeModel *native_model = (NativeModel *)model->model;
NativeModel *native_model = model->model;
NativeContext *ctx = &native_model->ctx;
int32_t layer;
DNNData input, output;
@ -382,7 +382,7 @@ static DNNReturnType execute_model_native(const DNNModel *model, const char *inp
DNNReturnType ff_dnn_execute_model_native(const DNNModel *model, const char *input_name, AVFrame *in_frame,
const char **output_names, uint32_t nb_output, AVFrame *out_frame)
{
NativeModel *native_model = (NativeModel *)model->model;
NativeModel *native_model = model->model;
NativeContext *ctx = &native_model->ctx;
if (!in_frame) {
@ -428,7 +428,7 @@ void ff_dnn_free_model_native(DNNModel **model)
if (*model)
{
if ((*model)->model) {
native_model = (NativeModel *)(*model)->model;
native_model = (*model)->model;
if (native_model->layers) {
for (layer = 0; layer < native_model->layers_num; ++layer){
if (native_model->layers[layer].type == DLT_CONV2D){

View File

@ -66,7 +66,7 @@ int ff_dnn_execute_layer_avg_pool(DnnOperand *operands, const int32_t *input_ope
int width = operands[input_operand_index].dims[2];
int channel = operands[input_operand_index].dims[3];
const float *input = operands[input_operand_index].data;
const AvgPoolParams *avgpool_params = (const AvgPoolParams *)parameters;
const AvgPoolParams *avgpool_params = parameters;
int kernel_strides = avgpool_params->strides;
int src_linesize = width * channel;

View File

@ -116,7 +116,7 @@ static void * dnn_execute_layer_conv2d_thread(void *threadarg)
int width = operands[input_operand_index].dims[2];
int channel = operands[input_operand_index].dims[3];
const float *input = operands[input_operand_index].data;
const ConvolutionalParams *conv_params = (const ConvolutionalParams *)(thread_common_param->parameters);
const ConvolutionalParams *conv_params = thread_common_param->parameters;
int radius = conv_params->kernel_size >> 1;
int src_linesize = width * conv_params->input_num;
@ -192,7 +192,7 @@ int ff_dnn_execute_layer_conv2d(DnnOperand *operands, const int32_t *input_opera
#endif
ThreadParam **thread_param = av_malloc_array(thread_num, sizeof(*thread_param));
ThreadCommonParam thread_common_param;
const ConvolutionalParams *conv_params = (const ConvolutionalParams *)(parameters);
const ConvolutionalParams *conv_params = parameters;
int height = operands[input_operand_indexes[0]].dims[1];
int width = operands[input_operand_indexes[0]].dims[2];
int pad_size = (conv_params->padding_method == VALID) ? (conv_params->kernel_size - 1) / 2 * conv_params->dilation : 0;

View File

@ -92,7 +92,7 @@ int ff_dnn_execute_layer_dense(DnnOperand *operands, const int32_t *input_operan
int width = operands[input_operand_index].dims[2];
int channel = operands[input_operand_index].dims[3];
const float *input = operands[input_operand_index].data;
const DenseParams *dense_params = (const DenseParams *)parameters;
const DenseParams *dense_params = parameters;
int src_linesize = width * channel;
DnnOperand *output_operand = &operands[output_operand_index];

View File

@ -53,7 +53,7 @@ int ff_dnn_execute_layer_depth2space(DnnOperand *operands, const int32_t *input_
int32_t output_operand_index, const void *parameters, NativeContext *ctx)
{
float *output;
const DepthToSpaceParams *params = (const DepthToSpaceParams *)parameters;
const DepthToSpaceParams *params = parameters;
int block_size = params->block_size;
int32_t input_operand_index = input_operand_indexes[0];
int number = operands[input_operand_index].dims[0];

View File

@ -152,7 +152,7 @@ int ff_dnn_execute_layer_math_binary(DnnOperand *operands, const int32_t *input_
{
const DnnOperand *input = &operands[input_operand_indexes[0]];
DnnOperand *output = &operands[output_operand_index];
const DnnLayerMathBinaryParams *params = (const DnnLayerMathBinaryParams *)parameters;
const DnnLayerMathBinaryParams *params = parameters;
for (int i = 0; i < 4; ++i)
output->dims[i] = input->dims[i];

View File

@ -57,7 +57,7 @@ int ff_dnn_execute_layer_math_unary(DnnOperand *operands, const int32_t *input_o
{
const DnnOperand *input = &operands[input_operand_indexes[0]];
DnnOperand *output = &operands[output_operand_index];
const DnnLayerMathUnaryParams *params = (const DnnLayerMathUnaryParams *)parameters;
const DnnLayerMathUnaryParams *params = parameters;
int dims_count;
const float *src;
float *dst;

View File

@ -54,7 +54,7 @@ int ff_dnn_execute_layer_maximum(DnnOperand *operands, const int32_t *input_oper
{
const DnnOperand *input = &operands[input_operand_indexes[0]];
DnnOperand *output = &operands[output_operand_index];
const DnnLayerMaximumParams *params = (const DnnLayerMaximumParams *)parameters;
const DnnLayerMaximumParams *params = parameters;
int dims_count;
const float *src;
float *dst;

View File

@ -81,7 +81,7 @@ int ff_dnn_execute_layer_pad(DnnOperand *operands, const int32_t *input_operand_
int32_t before_paddings;
int32_t after_paddings;
float* output;
const LayerPadParams *params = (const LayerPadParams *)parameters;
const LayerPadParams *params = parameters;
// suppose format is <N, H, W, C>
int32_t input_operand_index = input_operand_indexes[0];

View File

@ -394,7 +394,7 @@ static DNNReturnType execute_model_ov(RequestItem *request)
static DNNReturnType get_input_ov(void *model, DNNData *input, const char *input_name)
{
OVModel *ov_model = (OVModel *)model;
OVModel *ov_model = model;
OVContext *ctx = &ov_model->ctx;
char *model_input_name = NULL;
char *all_input_names = NULL;
@ -446,7 +446,7 @@ static DNNReturnType get_output_ov(void *model, const char *input_name, int inpu
const char *output_name, int *output_width, int *output_height)
{
DNNReturnType ret;
OVModel *ov_model = (OVModel *)model;
OVModel *ov_model = model;
OVContext *ctx = &ov_model->ctx;
TaskItem task;
RequestItem request;
@ -527,7 +527,7 @@ DNNModel *ff_dnn_load_model_ov(const char *model_filename, const char *options,
av_freep(&model);
return NULL;
}
model->model = (void *)ov_model;
model->model = ov_model;
ov_model->model = model;
ov_model->ctx.class = &dnn_openvino_class;
ctx = &ov_model->ctx;
@ -569,7 +569,7 @@ err:
DNNReturnType ff_dnn_execute_model_ov(const DNNModel *model, const char *input_name, AVFrame *in_frame,
const char **output_names, uint32_t nb_output, AVFrame *out_frame)
{
OVModel *ov_model = (OVModel *)model->model;
OVModel *ov_model = model->model;
OVContext *ctx = &ov_model->ctx;
TaskItem task;
RequestItem request;
@ -623,7 +623,7 @@ DNNReturnType ff_dnn_execute_model_ov(const DNNModel *model, const char *input_n
DNNReturnType ff_dnn_execute_model_async_ov(const DNNModel *model, const char *input_name, AVFrame *in_frame,
const char **output_names, uint32_t nb_output, AVFrame *out_frame)
{
OVModel *ov_model = (OVModel *)model->model;
OVModel *ov_model = model->model;
OVContext *ctx = &ov_model->ctx;
RequestItem *request;
TaskItem *task;
@ -677,7 +677,7 @@ DNNReturnType ff_dnn_execute_model_async_ov(const DNNModel *model, const char *i
DNNAsyncStatusType ff_dnn_get_async_result_ov(const DNNModel *model, AVFrame **in, AVFrame **out)
{
OVModel *ov_model = (OVModel *)model->model;
OVModel *ov_model = model->model;
TaskItem *task = ff_queue_peek_front(ov_model->task_queue);
if (!task) {
@ -698,7 +698,7 @@ DNNAsyncStatusType ff_dnn_get_async_result_ov(const DNNModel *model, AVFrame **i
DNNReturnType ff_dnn_flush_ov(const DNNModel *model)
{
OVModel *ov_model = (OVModel *)model->model;
OVModel *ov_model = model->model;
OVContext *ctx = &ov_model->ctx;
RequestItem *request;
IEStatusCode status;
@ -741,7 +741,7 @@ DNNReturnType ff_dnn_flush_ov(const DNNModel *model)
void ff_dnn_free_model_ov(DNNModel **model)
{
if (*model){
OVModel *ov_model = (OVModel *)(*model)->model;
OVModel *ov_model = (*model)->model;
while (ff_safe_queue_size(ov_model->request_queue) != 0) {
RequestItem *item = ff_safe_queue_pop_front(ov_model->request_queue);
if (item && item->infer_request) {

View File

@ -97,7 +97,7 @@ static TF_Buffer *read_graph(const char *model_filename)
}
graph_buf = TF_NewBuffer();
graph_buf->data = (void *)graph_data;
graph_buf->data = graph_data;
graph_buf->length = size;
graph_buf->data_deallocator = free_buffer;
@ -128,7 +128,7 @@ static TF_Tensor *allocate_input_tensor(const DNNData *input)
static DNNReturnType get_input_tf(void *model, DNNData *input, const char *input_name)
{
TFModel *tf_model = (TFModel *)model;
TFModel *tf_model = model;
TFContext *ctx = &tf_model->ctx;
TF_Status *status;
int64_t dims[4];
@ -165,7 +165,7 @@ static DNNReturnType get_output_tf(void *model, const char *input_name, int inpu
const char *output_name, int *output_width, int *output_height)
{
DNNReturnType ret;
TFModel *tf_model = (TFModel *)model;
TFModel *tf_model = model;
TFContext *ctx = &tf_model->ctx;
AVFrame *in_frame = av_frame_alloc();
AVFrame *out_frame = NULL;
@ -586,7 +586,7 @@ static DNNReturnType load_native_model(TFModel *tf_model, const char *model_file
return DNN_ERROR;
}
native_model = (NativeModel *)model->model;
native_model = model->model;
tf_model->graph = TF_NewGraph();
tf_model->status = TF_NewStatus();
@ -700,7 +700,7 @@ DNNModel *ff_dnn_load_model_tf(const char *model_filename, const char *options,
}
}
model->model = (void *)tf_model;
model->model = tf_model;
model->get_input = &get_input_tf;
model->get_output = &get_output_tf;
model->options = options;
@ -714,7 +714,7 @@ static DNNReturnType execute_model_tf(const DNNModel *model, const char *input_n
int do_ioproc)
{
TF_Output *tf_outputs;
TFModel *tf_model = (TFModel *)model->model;
TFModel *tf_model = model->model;
TFContext *ctx = &tf_model->ctx;
DNNData input, output;
TF_Tensor **output_tensors;
@ -822,7 +822,7 @@ static DNNReturnType execute_model_tf(const DNNModel *model, const char *input_n
DNNReturnType ff_dnn_execute_model_tf(const DNNModel *model, const char *input_name, AVFrame *in_frame,
const char **output_names, uint32_t nb_output, AVFrame *out_frame)
{
TFModel *tf_model = (TFModel *)model->model;
TFModel *tf_model = model->model;
TFContext *ctx = &tf_model->ctx;
if (!in_frame) {
@ -843,7 +843,7 @@ void ff_dnn_free_model_tf(DNNModel **model)
TFModel *tf_model;
if (*model){
tf_model = (TFModel *)(*model)->model;
tf_model = (*model)->model;
if (tf_model->graph){
TF_DeleteGraph(tf_model->graph);
}