Showing the changes to libavfilter (20 of 20 files). Show all
Unified · Split
| @@ -208,7 +208,7 @@ DNNModel *ff_dnn_load_model_native(const char *model_filename, const char *optio · 207 unmodified lines | |||
| 208 | } | 208 | } |
| 209 | 209 | ||
| 210 | native_model->layers[layer].type = layer_type; | 210 | native_model->layers[layer].type = layer_type; |
| 211 | parsed_size = layer_funcs[layer_type].pf_load(&native_model->layers[layer], model_file_context, file_size, native_model->operands_num); | 211 | parsed_size = ff_layer_funcs[layer_type].pf_load(&native_model->layers[layer], model_file_context, file_size, native_model->operands_num); |
| 212 | if (!parsed_size) { | 212 | if (!parsed_size) { |
| 213 | goto fail; | 213 | goto fail; |
| 214 | } | 214 | } |
| @@ -300,7 +300,7 @@ static DNNReturnType execute_model_native(const DNNModel *model, const char *inp · 85 unmodified lines | |||
| 300 | oprd->dims[2] = in_frame->width; | 300 | oprd->dims[2] = in_frame->width; |
| 301 | 301 | ||
| 302 | av_freep(&oprd->data); | 302 | av_freep(&oprd->data); |
| 303 | oprd->length = calculate_operand_data_length(oprd); | 303 | oprd->length = ff_calculate_operand_data_length(oprd); |
| 304 | if (oprd->length <= 0) { | 304 | if (oprd->length <= 0) { |
| 305 | av_log(ctx, AV_LOG_ERROR, "The input data length overflow\n"); | 305 | av_log(ctx, AV_LOG_ERROR, "The input data length overflow\n"); |
| 306 | return DNN_ERROR; | 306 | return DNN_ERROR; |
| @@ -333,7 +333,7 @@ static DNNReturnType execute_model_native(const DNNModel *model, const char *inp · 26 unmodified lines | |||
| 333 | 333 | ||
| 334 | for (layer = 0; layer < native_model->layers_num; ++layer){ | 334 | for (layer = 0; layer < native_model->layers_num; ++layer){ |
| 335 | DNNLayerType layer_type = native_model->layers[layer].type; | 335 | DNNLayerType layer_type = native_model->layers[layer].type; |
| 336 | if (layer_funcs[layer_type].pf_exec(native_model->operands, | 336 | if (ff_layer_funcs[layer_type].pf_exec(native_model->operands, |
| 337 | native_model->layers[layer].input_operand_indexes, | 337 | native_model->layers[layer].input_operand_indexes, |
| 338 | native_model->layers[layer].output_operand_index, | 338 | native_model->layers[layer].output_operand_index, |
| 339 | native_model->layers[layer].params, | 339 | native_model->layers[layer].params, |
| @@ -398,7 +398,7 @@ DNNReturnType ff_dnn_execute_model_native(const DNNModel *model, const char *inp · 58 unmodified lines | |||
| 398 | return execute_model_native(model, input_name, in_frame, output_names, nb_output, out_frame, 1); | 398 | return execute_model_native(model, input_name, in_frame, output_names, nb_output, out_frame, 1); |
| 399 | } | 399 | } |
| 400 | 400 | ||
| 401 | int32_t calculate_operand_dims_count(const DnnOperand *oprd) | 401 | int32_t ff_calculate_operand_dims_count(const DnnOperand *oprd) |
| 402 | { | 402 | { |
| 403 | int32_t result = 1; | 403 | int32_t result = 1; |
| 404 | for (int i = 0; i < 4; ++i) | 404 | for (int i = 0; i < 4; ++i) |
| @@ -407,7 +407,7 @@ int32_t calculate_operand_dims_count(const DnnOperand *oprd) · 2 unmodified lines | |||
| 407 | return result; | 407 | return result; |
| 408 | } | 408 | } |
| 409 | 409 | ||
| 410 | int32_t calculate_operand_data_length(const DnnOperand* oprd) | 410 | int32_t ff_calculate_operand_data_length(const DnnOperand* oprd) |
| 411 | { | 411 | { |
| 412 | // currently, we just support DNN_FLOAT | 412 | // currently, we just support DNN_FLOAT |
| 413 | uint64_t len = sizeof(float); | 413 | uint64_t len = sizeof(float); |
| @@ -137,6 +137,6 @@ void ff_dnn_free_model_native(DNNModel **model); · 136 unmodified lines | |||
| 137 | 137 | ||
| 138 | // NOTE: User must check for error (return value <= 0) to handle | 138 | // NOTE: User must check for error (return value <= 0) to handle |
| 139 | // case like integer overflow. | 139 | // case like integer overflow. |
| 140 | int32_t calculate_operand_data_length(const DnnOperand *oprd); | 140 | int32_t ff_calculate_operand_data_length(const DnnOperand *oprd); |
| 141 | int32_t calculate_operand_dims_count(const DnnOperand *oprd); | 141 | int32_t ff_calculate_operand_dims_count(const DnnOperand *oprd); |
| 142 | #endif | 142 | #endif |
| @@ -26,7 +26,7 @@ · 25 unmodified lines | |||
| 26 | #include "libavutil/avassert.h" | 26 | #include "libavutil/avassert.h" |
| 27 | #include "dnn_backend_native_layer_avgpool.h" | 27 | #include "dnn_backend_native_layer_avgpool.h" |
| 28 | 28 | ||
| 29 | int dnn_load_layer_avg_pool(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num) | 29 | int ff_dnn_load_layer_avg_pool(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num) |
| 30 | { | 30 | { |
| 31 | AvgPoolParams *avgpool_params; | 31 | AvgPoolParams *avgpool_params; |
| 32 | int dnn_size = 0; | 32 | int dnn_size = 0; |
| @@ -55,8 +55,8 @@ int dnn_load_layer_avg_pool(Layer *layer, AVIOContext *model_file_context, int f · 22 unmodified lines | |||
| 55 | return dnn_size; | 55 | return dnn_size; |
| 56 | } | 56 | } |
| 57 | 57 | ||
| 58 | int dnn_execute_layer_avg_pool(DnnOperand *operands, const int32_t *input_operand_indexes, | 58 | int ff_dnn_execute_layer_avg_pool(DnnOperand *operands, const int32_t *input_operand_indexes, |
| 59 | int32_t output_operand_index, const void *parameters, NativeContext *ctx) | 59 | int32_t output_operand_index, const void *parameters, NativeContext *ctx) |
| 60 | { | 60 | { |
| 61 | float *output; | 61 | float *output; |
| 62 | int height_end, width_end, height_radius, width_radius, output_height, output_width, kernel_area; | 62 | int height_end, width_end, height_radius, width_radius, output_height, output_width, kernel_area; |
| @@ -106,7 +106,7 @@ int dnn_execute_layer_avg_pool(DnnOperand *operands, const int32_t *input_operan · 43 unmodified lines | |||
| 106 | // not support pooling in channel dimension now | 106 | // not support pooling in channel dimension now |
| 107 | output_operand->dims[3] = channel; | 107 | output_operand->dims[3] = channel; |
| 108 | output_operand->data_type = operands[input_operand_index].data_type; | 108 | output_operand->data_type = operands[input_operand_index].data_type; |
| 109 | output_operand->length = calculate_operand_data_length(output_operand); | 109 | output_operand->length = ff_calculate_operand_data_length(output_operand); |
| 110 | if (output_operand->length <= 0) { | 110 | if (output_operand->length <= 0) { |
| 111 | av_log(ctx, AV_LOG_ERROR, "The output data length overflow\n"); | 111 | av_log(ctx, AV_LOG_ERROR, "The output data length overflow\n"); |
| 112 | return DNN_ERROR; | 112 | return DNN_ERROR; |
| @@ -33,8 +33,8 @@ typedef struct AvgPoolParams{ · 32 unmodified lines | |||
| 33 | DNNPaddingParam padding_method; | 33 | DNNPaddingParam padding_method; |
| 34 | } AvgPoolParams; | 34 | } AvgPoolParams; |
| 35 | 35 | ||
| 36 | int dnn_load_layer_avg_pool(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num); | 36 | int ff_dnn_load_layer_avg_pool(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num); |
| 37 | int dnn_execute_layer_avg_pool(DnnOperand *operands, const int32_t *input_operand_indexes, | 37 | int ff_dnn_execute_layer_avg_pool(DnnOperand *operands, const int32_t *input_operand_indexes, |
| 38 | int32_t output_operand_index, const void *parameters, NativeContext *ctx); | 38 | int32_t output_operand_index, const void *parameters, NativeContext *ctx); |
| 39 | 39 | ||
| 40 | #endif | 40 | #endif |
| @@ -40,7 +40,7 @@ typedef struct ThreadParam{ · 39 unmodified lines | |||
| 40 | int thread_start, thread_end; | 40 | int thread_start, thread_end; |
| 41 | } ThreadParam; | 41 | } ThreadParam; |
| 42 | 42 | ||
| 43 | int dnn_load_layer_conv2d(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num) | 43 | int ff_dnn_load_layer_conv2d(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num) |
| 44 | { | 44 | { |
| 45 | ConvolutionalParams *conv_params; | 45 | ConvolutionalParams *conv_params; |
| 46 | int kernel_size; | 46 | int kernel_size; |
| @@ -181,8 +181,8 @@ static void * dnn_execute_layer_conv2d_thread(void *threadarg) · 134 unmodified lines | |||
| 181 | } | 181 | } |
| 182 | 182 | ||
| 183 | 183 | ||
| 184 | int dnn_execute_layer_conv2d(DnnOperand *operands, const int32_t *input_operand_indexes, | 184 | int ff_dnn_execute_layer_conv2d(DnnOperand *operands, const int32_t *input_operand_indexes, |
| 185 | int32_t output_operand_index, const void *parameters, NativeContext *ctx) | 185 | int32_t output_operand_index, const void *parameters, NativeContext *ctx) |
| 186 | { | 186 | { |
| 187 | int thread_num = (ctx->options.conv2d_threads <= 0 || ctx->options.conv2d_threads > av_cpu_count()) | 187 | int thread_num = (ctx->options.conv2d_threads <= 0 || ctx->options.conv2d_threads > av_cpu_count()) |
| 188 | ? (av_cpu_count() + 1) : (ctx->options.conv2d_threads); | 188 | ? (av_cpu_count() + 1) : (ctx->options.conv2d_threads); |
| @@ -203,7 +203,7 @@ int dnn_execute_layer_conv2d(DnnOperand *operands, const int32_t *input_operand_ · 14 unmodified lines | |||
| 203 | output_operand->dims[2] = width - pad_size * 2; | 203 | output_operand->dims[2] = width - pad_size * 2; |
| 204 | output_operand->dims[3] = conv_params->output_num; | 204 | output_operand->dims[3] = conv_params->output_num; |
| 205 | output_operand->data_type = operands[input_operand_indexes[0]].data_type; | 205 | output_operand->data_type = operands[input_operand_indexes[0]].data_type; |
| 206 | output_operand->length = calculate_operand_data_length(output_operand); | 206 | output_operand->length = ff_calculate_operand_data_length(output_operand); |
| 207 | if (output_operand->length <= 0) { | 207 | if (output_operand->length <= 0) { |
| 208 | av_log(ctx, AV_LOG_ERROR, "The output data length overflow\n"); | 208 | av_log(ctx, AV_LOG_ERROR, "The output data length overflow\n"); |
| 209 | return DNN_ERROR; | 209 | return DNN_ERROR; |
| @@ -34,7 +34,7 @@ typedef struct ConvolutionalParams{ · 33 unmodified lines | |||
| 34 | float *biases; | 34 | float *biases; |
| 35 | } ConvolutionalParams; | 35 | } ConvolutionalParams; |
| 36 | 36 | ||
| 37 | int dnn_load_layer_conv2d(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num); | 37 | int ff_dnn_load_layer_conv2d(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num); |
| 38 | int dnn_execute_layer_conv2d(DnnOperand *operands, const int32_t *input_operand_indexes, | 38 | int ff_dnn_execute_layer_conv2d(DnnOperand *operands, const int32_t *input_operand_indexes, |
| 39 | int32_t output_operand_index, const void *parameters, NativeContext *ctx); | 39 | int32_t output_operand_index, const void *parameters, NativeContext *ctx); |
| 40 | #endif | 40 | #endif |
| @@ -21,7 +21,7 @@ · 20 unmodified lines | |||
| 21 | #include "libavutil/avassert.h" | 21 | #include "libavutil/avassert.h" |
| 22 | #include "dnn_backend_native_layer_dense.h" | 22 | #include "dnn_backend_native_layer_dense.h" |
| 23 | 23 | ||
| 24 | int dnn_load_layer_dense(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num) | 24 | int ff_dnn_load_layer_dense(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num) |
| 25 | { | 25 | { |
| 26 | DenseParams *dense_params; | 26 | DenseParams *dense_params; |
| 27 | int kernel_size; | 27 | int kernel_size; |
| @@ -82,8 +82,8 @@ int dnn_load_layer_dense(Layer *layer, AVIOContext *model_file_context, int file · 54 unmodified lines | |||
| 82 | return dnn_size; | 82 | return dnn_size; |
| 83 | } | 83 | } |
| 84 | 84 | ||
| 85 | int dnn_execute_layer_dense(DnnOperand *operands, const int32_t *input_operand_indexes, | 85 | int ff_dnn_execute_layer_dense(DnnOperand *operands, const int32_t *input_operand_indexes, |
| 86 | int32_t output_operand_index, const void *parameters, NativeContext *ctx) | 86 | int32_t output_operand_index, const void *parameters, NativeContext *ctx) |
| 87 | { | 87 | { |
| 88 | float *output; | 88 | float *output; |
| 89 | int32_t input_operand_index = input_operand_indexes[0]; | 89 | int32_t input_operand_index = input_operand_indexes[0]; |
| @@ -101,7 +101,7 @@ int dnn_execute_layer_dense(DnnOperand *operands, const int32_t *input_operand_i · 11 unmodified lines | |||
| 101 | output_operand->dims[2] = width; | 101 | output_operand->dims[2] = width; |
| 102 | output_operand->dims[3] = dense_params->output_num; | 102 | output_operand->dims[3] = dense_params->output_num; |
| 103 | output_operand->data_type = operands[input_operand_index].data_type; | 103 | output_operand->data_type = operands[input_operand_index].data_type; |
| 104 | output_operand->length = calculate_operand_data_length(output_operand); | 104 | output_operand->length = ff_calculate_operand_data_length(output_operand); |
| 105 | if (output_operand->length <= 0) { | 105 | if (output_operand->length <= 0) { |
| 106 | av_log(ctx, AV_LOG_ERROR, "The output data length overflow\n"); | 106 | av_log(ctx, AV_LOG_ERROR, "The output data length overflow\n"); |
| 107 | return DNN_ERROR; | 107 | return DNN_ERROR; |
| @@ -31,7 +31,7 @@ typedef struct DenseParams{ · 30 unmodified lines | |||
| 31 | float *biases; | 31 | float *biases; |
| 32 | } DenseParams; | 32 | } DenseParams; |
| 33 | 33 | ||
| 34 | int dnn_load_layer_dense(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num); | 34 | int ff_dnn_load_layer_dense(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num); |
| 35 | int dnn_execute_layer_dense(DnnOperand *operands, const int32_t *input_operand_indexes, | 35 | int ff_dnn_execute_layer_dense(DnnOperand *operands, const int32_t *input_operand_indexes, |
| 36 | int32_t output_operand_index, const void *parameters, NativeContext *ctx); | 36 | int32_t output_operand_index, const void *parameters, NativeContext *ctx); |
| 37 | #endif | 37 | #endif |
| @@ -27,7 +27,7 @@ · 26 unmodified lines | |||
| 27 | #include "libavutil/avassert.h" | 27 | #include "libavutil/avassert.h" |
| 28 | #include "dnn_backend_native_layer_depth2space.h" | 28 | #include "dnn_backend_native_layer_depth2space.h" |
| 29 | 29 | ||
| 30 | int dnn_load_layer_depth2space(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num) | 30 | int ff_dnn_load_layer_depth2space(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num) |
| 31 | { | 31 | { |
| 32 | DepthToSpaceParams *params; | 32 | DepthToSpaceParams *params; |
| 33 | int dnn_size = 0; | 33 | int dnn_size = 0; |
| @@ -49,8 +49,8 @@ int dnn_load_layer_depth2space(Layer *layer, AVIOContext *model_file_context, in · 15 unmodified lines | |||
| 49 | return dnn_size; | 49 | return dnn_size; |
| 50 | } | 50 | } |
| 51 | 51 | ||
| 52 | int dnn_execute_layer_depth2space(DnnOperand *operands, const int32_t *input_operand_indexes, | 52 | int ff_dnn_execute_layer_depth2space(DnnOperand *operands, const int32_t *input_operand_indexes, |
| 53 | int32_t output_operand_index, const void *parameters, NativeContext *ctx) | 53 | int32_t output_operand_index, const void *parameters, NativeContext *ctx) |
| 54 | { | 54 | { |
| 55 | float *output; | 55 | float *output; |
| 56 | const DepthToSpaceParams *params = (const DepthToSpaceParams *)parameters; | 56 | const DepthToSpaceParams *params = (const DepthToSpaceParams *)parameters; |
| @@ -74,7 +74,7 @@ int dnn_execute_layer_depth2space(DnnOperand *operands, const int32_t *input_ope · 17 unmodified lines | |||
| 74 | output_operand->dims[2] = width * block_size; | 74 | output_operand->dims[2] = width * block_size; |
| 75 | output_operand->dims[3] = new_channels; | 75 | output_operand->dims[3] = new_channels; |
| 76 | output_operand->data_type = operands[input_operand_index].data_type; | 76 | output_operand->data_type = operands[input_operand_index].data_type; |
| 77 | output_operand->length = calculate_operand_data_length(output_operand); | 77 | output_operand->length = ff_calculate_operand_data_length(output_operand); |
| 78 | if (output_operand->length <= 0) { | 78 | if (output_operand->length <= 0) { |
| 79 | av_log(ctx, AV_LOG_ERROR, "The output data length overflow\n"); | 79 | av_log(ctx, AV_LOG_ERROR, "The output data length overflow\n"); |
| 80 | return DNN_ERROR; | 80 | return DNN_ERROR; |
| @@ -34,8 +34,8 @@ typedef struct DepthToSpaceParams{ · 33 unmodified lines | |||
| 34 | int block_size; | 34 | int block_size; |
| 35 | } DepthToSpaceParams; | 35 | } DepthToSpaceParams; |
| 36 | 36 | ||
| 37 | int dnn_load_layer_depth2space(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num); | 37 | int ff_dnn_load_layer_depth2space(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num); |
| 38 | int dnn_execute_layer_depth2space(DnnOperand *operands, const int32_t *input_operand_indexes, | 38 | int ff_dnn_execute_layer_depth2space(DnnOperand *operands, const int32_t *input_operand_indexes, |
| 39 | int32_t output_operand_index, const void *parameters, NativeContext *ctx); | 39 | int32_t output_operand_index, const void *parameters, NativeContext *ctx); |
| 40 | 40 | ||
| 41 | #endif | 41 | #endif |
| @@ -59,7 +59,7 @@ static void math_binary_commutative(FunType pfun, const DnnLayerMathBinaryParams · 58 unmodified lines | |||
| 59 | int dims_count; | 59 | int dims_count; |
| 60 | const float *src; | 60 | const float *src; |
| 61 | float *dst; | 61 | float *dst; |
| 62 | dims_count = calculate_operand_dims_count(output); | 62 | dims_count = ff_calculate_operand_dims_count(output); |
| 63 | src = input->data; | 63 | src = input->data; |
| 64 | dst = output->data; | 64 | dst = output->data; |
| 65 | if (params->input0_broadcast || params->input1_broadcast) { | 65 | if (params->input0_broadcast || params->input1_broadcast) { |
| @@ -79,7 +79,7 @@ static void math_binary_not_commutative(FunType pfun, const DnnLayerMathBinaryPa · 13 unmodified lines | |||
| 79 | int dims_count; | 79 | int dims_count; |
| 80 | const float *src; | 80 | const float *src; |
| 81 | float *dst; | 81 | float *dst; |
| 82 | dims_count = calculate_operand_dims_count(output); | 82 | dims_count = ff_calculate_operand_dims_count(output); |
| 83 | src = input->data; | 83 | src = input->data; |
| 84 | dst = output->data; | 84 | dst = output->data; |
| 85 | if (params->input0_broadcast) { | 85 | if (params->input0_broadcast) { |
| @@ -98,7 +98,7 @@ static void math_binary_not_commutative(FunType pfun, const DnnLayerMathBinaryPa · 12 unmodified lines | |||
| 98 | } | 98 | } |
| 99 | } | 99 | } |
| 100 | } | 100 | } |
| 101 | int dnn_load_layer_math_binary(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num) | 101 | int ff_dnn_load_layer_math_binary(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num) |
| 102 | { | 102 | { |
| 103 | DnnLayerMathBinaryParams *params; | 103 | DnnLayerMathBinaryParams *params; |
| 104 | int dnn_size = 0; | 104 | int dnn_size = 0; |
| @@ -147,8 +147,8 @@ int dnn_load_layer_math_binary(Layer *layer, AVIOContext *model_file_context, in · 42 unmodified lines | |||
| 147 | return dnn_size; | 147 | return dnn_size; |
| 148 | } | 148 | } |
| 149 | 149 | ||
| 150 | int dnn_execute_layer_math_binary(DnnOperand *operands, const int32_t *input_operand_indexes, | 150 | int ff_dnn_execute_layer_math_binary(DnnOperand *operands, const int32_t *input_operand_indexes, |
| 151 | int32_t output_operand_index, const void *parameters, NativeContext *ctx) | 151 | int32_t output_operand_index, const void *parameters, NativeContext *ctx) |
| 152 | { | 152 | { |
| 153 | const DnnOperand *input = &operands[input_operand_indexes[0]]; | 153 | const DnnOperand *input = &operands[input_operand_indexes[0]]; |
| 154 | DnnOperand *output = &operands[output_operand_index]; | 154 | DnnOperand *output = &operands[output_operand_index]; |
| @@ -158,7 +158,7 @@ int dnn_execute_layer_math_binary(DnnOperand *operands, const int32_t *input_ope · 3 unmodified lines | |||
| 158 | output->dims[i] = input->dims[i]; | 158 | output->dims[i] = input->dims[i]; |
| 159 | 159 | ||
| 160 | output->data_type = input->data_type; | 160 | output->data_type = input->data_type; |
| 161 | output->length = calculate_operand_data_length(output); | 161 | output->length = ff_calculate_operand_data_length(output); |
| 162 | if (output->length <= 0) { | 162 | if (output->length <= 0) { |
| 163 | av_log(ctx, AV_LOG_ERROR, "The output data length overflow\n"); | 163 | av_log(ctx, AV_LOG_ERROR, "The output data length overflow\n"); |
| 164 | return DNN_ERROR; | 164 | return DNN_ERROR; |
| @@ -47,8 +47,8 @@ typedef struct DnnLayerMathBinaryParams{ · 46 unmodified lines | |||
| 47 | float v; | 47 | float v; |
| 48 | } DnnLayerMathBinaryParams; | 48 | } DnnLayerMathBinaryParams; |
| 49 | 49 | ||
| 50 | int dnn_load_layer_math_binary(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num); | 50 | int ff_dnn_load_layer_math_binary(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num); |
| 51 | int dnn_execute_layer_math_binary(DnnOperand *operands, const int32_t *input_operand_indexes, | 51 | int ff_dnn_execute_layer_math_binary(DnnOperand *operands, const int32_t *input_operand_indexes, |
| 52 | int32_t output_operand_index, const void *parameters, NativeContext *ctx); | 52 | int32_t output_operand_index, const void *parameters, NativeContext *ctx); |
| 53 | 53 | ||
| 54 | #endif | 54 | #endif |
| @@ -29,7 +29,7 @@ · 28 unmodified lines | |||
| 29 | #include "libavutil/avassert.h" | 29 | #include "libavutil/avassert.h" |
| 30 | #include "dnn_backend_native_layer_mathunary.h" | 30 | #include "dnn_backend_native_layer_mathunary.h" |
| 31 | 31 | ||
| 32 | int dnn_load_layer_math_unary(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num) | 32 | int ff_dnn_load_layer_math_unary(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num) |
| 33 | { | 33 | { |
| 34 | DnnLayerMathUnaryParams *params; | 34 | DnnLayerMathUnaryParams *params; |
| 35 | int dnn_size = 0; | 35 | int dnn_size = 0; |
| @@ -52,8 +52,8 @@ int dnn_load_layer_math_unary(Layer *layer, AVIOContext *model_file_context, int · 16 unmodified lines | |||
| 52 | 52 | ||
| 53 | } | 53 | } |
| 54 | 54 | ||
| 55 | int dnn_execute_layer_math_unary(DnnOperand *operands, const int32_t *input_operand_indexes, | 55 | int ff_dnn_execute_layer_math_unary(DnnOperand *operands, const int32_t *input_operand_indexes, |
| 56 | int32_t output_operand_index, const void *parameters, NativeContext *ctx) | 56 | int32_t output_operand_index, const void *parameters, NativeContext *ctx) |
| 57 | { | 57 | { |
| 58 | const DnnOperand *input = &operands[input_operand_indexes[0]]; | 58 | const DnnOperand *input = &operands[input_operand_indexes[0]]; |
| 59 | DnnOperand *output = &operands[output_operand_index]; | 59 | DnnOperand *output = &operands[output_operand_index]; |
| @@ -66,7 +66,7 @@ int dnn_execute_layer_math_unary(DnnOperand *operands, const int32_t *input_oper · 6 unmodified lines | |||
| 66 | output->dims[i] = input->dims[i]; | 66 | output->dims[i] = input->dims[i]; |
| 67 | 67 | ||
| 68 | output->data_type = input->data_type; | 68 | output->data_type = input->data_type; |
| 69 | output->length = calculate_operand_data_length(output); | 69 | output->length = ff_calculate_operand_data_length(output); |
| 70 | if (output->length <= 0) { | 70 | if (output->length <= 0) { |
| 71 | av_log(ctx, AV_LOG_ERROR, "The output data length overflow\n"); | 71 | av_log(ctx, AV_LOG_ERROR, "The output data length overflow\n"); |
| 72 | return DNN_ERROR; | 72 | return DNN_ERROR; |
| @@ -77,7 +77,7 @@ int dnn_execute_layer_math_unary(DnnOperand *operands, const int32_t *input_oper · 4 unmodified lines | |||
| 77 | return DNN_ERROR; | 77 | return DNN_ERROR; |
| 78 | } | 78 | } |
| 79 | 79 | ||
| 80 | dims_count = calculate_operand_dims_count(output); | 80 | dims_count = ff_calculate_operand_dims_count(output); |
| 81 | src = input->data; | 81 | src = input->data; |
| 82 | dst = output->data; | 82 | dst = output->data; |
| 83 | 83 | ||
| @@ -53,8 +53,8 @@ typedef struct DnnLayerMathUnaryParams{ · 52 unmodified lines | |||
| 53 | DNNMathUnaryOperation un_op; | 53 | DNNMathUnaryOperation un_op; |
| 54 | } DnnLayerMathUnaryParams; | 54 | } DnnLayerMathUnaryParams; |
| 55 | 55 | ||
| 56 | int dnn_load_layer_math_unary(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num); | 56 | int ff_dnn_load_layer_math_unary(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num); |
| 57 | int dnn_execute_layer_math_unary(DnnOperand *operands, const int32_t *input_operand_indexes, | 57 | int ff_dnn_execute_layer_math_unary(DnnOperand *operands, const int32_t *input_operand_indexes, |
| 58 | int32_t output_operand_index, const void *parameters, NativeContext *ctx); | 58 | int32_t output_operand_index, const void *parameters, NativeContext *ctx); |
| 59 | 59 | ||
| 60 | #endif | 60 | #endif |
| @@ -27,7 +27,7 @@ · 26 unmodified lines | |||
| 27 | #include "libavutil/avassert.h" | 27 | #include "libavutil/avassert.h" |
| 28 | #include "dnn_backend_native_layer_maximum.h" | 28 | #include "dnn_backend_native_layer_maximum.h" |
| 29 | 29 | ||
| 30 | int dnn_load_layer_maximum(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num) | 30 | int ff_dnn_load_layer_maximum(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num) |
| 31 | { | 31 | { |
| 32 | DnnLayerMaximumParams *params; | 32 | DnnLayerMaximumParams *params; |
| 33 | int dnn_size = 0; | 33 | int dnn_size = 0; |
| @@ -49,8 +49,8 @@ int dnn_load_layer_maximum(Layer *layer, AVIOContext *model_file_context, int fi · 15 unmodified lines | |||
| 49 | return dnn_size; | 49 | return dnn_size; |
| 50 | } | 50 | } |
| 51 | 51 | ||
| 52 | int dnn_execute_layer_maximum(DnnOperand *operands, const int32_t *input_operand_indexes, | 52 | int ff_dnn_execute_layer_maximum(DnnOperand *operands, const int32_t *input_operand_indexes, |
| 53 | int32_t output_operand_index, const void *parameters, NativeContext *ctx) | 53 | int32_t output_operand_index, const void *parameters, NativeContext *ctx) |
| 54 | { | 54 | { |
| 55 | const DnnOperand *input = &operands[input_operand_indexes[0]]; | 55 | const DnnOperand *input = &operands[input_operand_indexes[0]]; |
| 56 | DnnOperand *output = &operands[output_operand_index]; | 56 | DnnOperand *output = &operands[output_operand_index]; |
| @@ -63,7 +63,7 @@ int dnn_execute_layer_maximum(DnnOperand *operands, const int32_t *input_operand · 6 unmodified lines | |||
| 63 | output->dims[i] = input->dims[i]; | 63 | output->dims[i] = input->dims[i]; |
| 64 | 64 | ||
| 65 | output->data_type = input->data_type; | 65 | output->data_type = input->data_type; |
| 66 | output->length = calculate_operand_data_length(output); | 66 | output->length = ff_calculate_operand_data_length(output); |
| 67 | if (output->length <= 0) { | 67 | if (output->length <= 0) { |
| 68 | av_log(ctx, AV_LOG_ERROR, "The output data length overflow\n"); | 68 | av_log(ctx, AV_LOG_ERROR, "The output data length overflow\n"); |
| 69 | return DNN_ERROR; | 69 | return DNN_ERROR; |
| @@ -74,7 +74,7 @@ int dnn_execute_layer_maximum(DnnOperand *operands, const int32_t *input_operand · 4 unmodified lines | |||
| 74 | return DNN_ERROR; | 74 | return DNN_ERROR; |
| 75 | } | 75 | } |
| 76 | 76 | ||
| 77 | dims_count = calculate_operand_dims_count(output); | 77 | dims_count = ff_calculate_operand_dims_count(output); |
| 78 | src = input->data; | 78 | src = input->data; |
| 79 | dst = output->data; | 79 | dst = output->data; |
| 80 | for (int i = 0; i < dims_count; ++i) | 80 | for (int i = 0; i < dims_count; ++i) |
| @@ -37,8 +37,8 @@ typedef struct DnnLayerMaximumParams{ · 36 unmodified lines | |||
| 37 | }val; | 37 | }val; |
| 38 | } DnnLayerMaximumParams; | 38 | } DnnLayerMaximumParams; |
| 39 | 39 | ||
| 40 | int dnn_load_layer_maximum(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num); | 40 | int ff_dnn_load_layer_maximum(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num); |
| 41 | int dnn_execute_layer_maximum(DnnOperand *operands, const int32_t *input_operand_indexes, | 41 | int ff_dnn_execute_layer_maximum(DnnOperand *operands, const int32_t *input_operand_indexes, |
| 42 | int32_t output_operand_index, const void *parameters, NativeContext *ctx); | 42 | int32_t output_operand_index, const void *parameters, NativeContext *ctx); |
| 43 | 43 | ||
| 44 | #endif | 44 | #endif |
| @@ -22,7 +22,7 @@ · 21 unmodified lines | |||
| 22 | #include "libavutil/avassert.h" | 22 | #include "libavutil/avassert.h" |
| 23 | #include "dnn_backend_native_layer_pad.h" | 23 | #include "dnn_backend_native_layer_pad.h" |
| 24 | 24 | ||
| 25 | int dnn_load_layer_pad(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num) | 25 | int ff_dnn_load_layer_pad(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num) |
| 26 | { | 26 | { |
| 27 | LayerPadParams *params; | 27 | LayerPadParams *params; |
| 28 | int dnn_size = 0; | 28 | int dnn_size = 0; |
| @@ -75,8 +75,8 @@ static int after_get_buddy(int given, int border, LayerPadModeParam mode) · 46 unmodified lines | |||
| 75 | } | 75 | } |
| 76 | } | 76 | } |
| 77 | 77 | ||
| 78 | int dnn_execute_layer_pad(DnnOperand *operands, const int32_t *input_operand_indexes, | 78 | int ff_dnn_execute_layer_pad(DnnOperand *operands, const int32_t *input_operand_indexes, |
| 79 | int32_t output_operand_index, const void *parameters, NativeContext *ctx) | 79 | int32_t output_operand_index, const void *parameters, NativeContext *ctx) |
| 80 | { | 80 | { |
| 81 | int32_t before_paddings; | 81 | int32_t before_paddings; |
| 82 | int32_t after_paddings; | 82 | int32_t after_paddings; |
| @@ -110,7 +110,7 @@ int dnn_execute_layer_pad(DnnOperand *operands, const int32_t *input_operand_ind · 27 unmodified lines | |||
| 110 | output_operand->dims[2] = new_width; | 110 | output_operand->dims[2] = new_width; |
| 111 | output_operand->dims[3] = new_channel; | 111 | output_operand->dims[3] = new_channel; |
| 112 | output_operand->data_type = operands[input_operand_index].data_type; | 112 | output_operand->data_type = operands[input_operand_index].data_type; |
| 113 | output_operand->length = calculate_operand_data_length(output_operand); | 113 | output_operand->length = ff_calculate_operand_data_length(output_operand); |
| 114 | if (output_operand->length <= 0) { | 114 | if (output_operand->length <= 0) { |
| 115 | av_log(ctx, AV_LOG_ERROR, "The output data length overflow\n"); | 115 | av_log(ctx, AV_LOG_ERROR, "The output data length overflow\n"); |
| 116 | return DNN_ERROR; | 116 | return DNN_ERROR; |
| @@ -36,8 +36,8 @@ typedef struct LayerPadParams{ · 35 unmodified lines | |||
| 36 | float constant_values; | 36 | float constant_values; |
| 37 | } LayerPadParams; | 37 | } LayerPadParams; |
| 38 | 38 | ||
| 39 | int dnn_load_layer_pad(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num); | 39 | int ff_dnn_load_layer_pad(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num); |
| 40 | int dnn_execute_layer_pad(DnnOperand *operands, const int32_t *input_operand_indexes, | 40 | int ff_dnn_execute_layer_pad(DnnOperand *operands, const int32_t *input_operand_indexes, |
| 41 | int32_t output_operand_index, const void *parameters, NativeContext *ctx); | 41 | int32_t output_operand_index, const void *parameters, NativeContext *ctx); |
| 42 | 42 | ||
| 43 | #endif | 43 | #endif |
| @@ -29,14 +29,14 @@ · 28 unmodified lines | |||
| 29 | #include "dnn_backend_native_layer_avgpool.h" | 29 | #include "dnn_backend_native_layer_avgpool.h" |
| 30 | #include "dnn_backend_native_layer_dense.h" | 30 | #include "dnn_backend_native_layer_dense.h" |
| 31 | 31 | ||
| 32 | const LayerFunc layer_funcs[DLT_COUNT] = { | 32 | const LayerFunc ff_layer_funcs[DLT_COUNT] = { |
| 33 | {NULL, NULL}, | 33 | {NULL, NULL}, |
| 34 | {dnn_execute_layer_conv2d, dnn_load_layer_conv2d}, | 34 | {ff_dnn_execute_layer_conv2d, ff_dnn_load_layer_conv2d}, |
| 35 | {dnn_execute_layer_depth2space, dnn_load_layer_depth2space}, | 35 | {ff_dnn_execute_layer_depth2space, ff_dnn_load_layer_depth2space}, |
| 36 | {dnn_execute_layer_pad, dnn_load_layer_pad}, | 36 | {ff_dnn_execute_layer_pad, ff_dnn_load_layer_pad}, |
| 37 | {dnn_execute_layer_maximum, dnn_load_layer_maximum}, | 37 | {ff_dnn_execute_layer_maximum, ff_dnn_load_layer_maximum}, |
| 38 | {dnn_execute_layer_math_binary, dnn_load_layer_math_binary}, | 38 | {ff_dnn_execute_layer_math_binary, ff_dnn_load_layer_math_binary}, |
| 39 | {dnn_execute_layer_math_unary, dnn_load_layer_math_unary}, | 39 | {ff_dnn_execute_layer_math_unary, ff_dnn_load_layer_math_unary}, |
| 40 | {dnn_execute_layer_avg_pool, dnn_load_layer_avg_pool}, | 40 | {ff_dnn_execute_layer_avg_pool, ff_dnn_load_layer_avg_pool}, |
| 41 | {dnn_execute_layer_dense, dnn_load_layer_dense}, | 41 | {ff_dnn_execute_layer_dense, ff_dnn_load_layer_dense}, |
| 42 | }; | 42 | }; |
| @@ -33,6 +33,6 @@ typedef struct LayerFunc { · 32 unmodified lines | |||
| 33 | LAYER_LOAD_FUNC pf_load; | 33 | LAYER_LOAD_FUNC pf_load; |
| 34 | }LayerFunc; | 34 | }LayerFunc; |
| 35 | 35 | ||
| 36 | extern const LayerFunc layer_funcs[DLT_COUNT]; | 36 | extern const LayerFunc ff_layer_funcs[DLT_COUNT]; |
| 37 | 37 | ||
| 38 | #endif | 38 | #endif |