[FFmpeg-devel] [PATCH V2] dnn_backend_openvino.c: parse options in openvino backend
Alexander Strasser
eclipse7 at gmx.net
Fri Aug 14 15:47:10 EEST 2020
Am 14. August 2020 14:07:23 MESZ schrieb "Xu, Guangxin" <guangxin.xu at intel.com>:
>
>
>> -----Original Message-----
>> From: ffmpeg-devel <ffmpeg-devel-bounces at ffmpeg.org> On Behalf Of
>Guo,
>> Yejun
>> Sent: Friday, August 14, 2020 9:50 AM
>> To: ffmpeg-devel at ffmpeg.org
>> Subject: [FFmpeg-devel] [PATCH V2] dnn_backend_openvino.c: parse
>options
>> in openvino backend
>>
>> Signed-off-by: Guo, Yejun <yejun.guo at intel.com>
>> ---
>> libavfilter/dnn/dnn_backend_openvino.c | 37
>> +++++++++++++++++++++++++++++++++-
>> 1 file changed, 36 insertions(+), 1 deletion(-)
>>
>> diff --git a/libavfilter/dnn/dnn_backend_openvino.c
>> b/libavfilter/dnn/dnn_backend_openvino.c
>> index d343bf2..478e151 100644
>> --- a/libavfilter/dnn/dnn_backend_openvino.c
>> +++ b/libavfilter/dnn/dnn_backend_openvino.c
>> @@ -26,8 +26,14 @@
>> #include "dnn_backend_openvino.h"
>> #include "libavformat/avio.h"
>> #include "libavutil/avassert.h"
>> +#include "libavutil/avstring.h"
>> #include <c_api/ie_c_api.h>
>>
>> +typedef struct OVOptions{
>> + uint32_t batch_size;
>> + uint32_t req_num;
>> +} OVOptions;
>> +
>> typedef struct OVModel{
>> ie_core_t *core;
>> ie_network_t *network;
>> @@ -36,6 +42,7 @@ typedef struct OVModel{
>> ie_blob_t *input_blob;
>> ie_blob_t **output_blobs;
>> uint32_t nb_output;
>> + OVOptions options;
>> } OVModel;
>>
>> static DNNDataType precision_to_datatype(precision_e precision) @@
>-50,6
>> +57,32 @@ static DNNDataType precision_to_datatype(precision_e
>precision)
>> }
>> }
>>
>> +static int parse_options_ov(OVOptions *to, const char *from) {
>> + AVDictionary *dict = NULL;
>> + AVDictionaryEntry *opt = NULL;
>> + int err = av_dict_parse_string(&dict, from, "=", "&", 0);
>> + if (err < 0) {
>> + av_dict_free(&dict);
>This may not needed.
>
>> + return err;
>> + }
>> +
>> + opt = av_dict_get(dict, "nireq", opt, AV_DICT_MATCH_CASE);
>> + if (opt != NULL)
>> + to->req_num = atoi(opt->value);
>> + else
>> + to->req_num = 1;
>> +
>> + opt = av_dict_get(dict, "batch", opt, AV_DICT_MATCH_CASE);
>> + if (opt != NULL)
>> + to->batch_size = atoi(opt->value);
>> + else
>> + to->batch_size = 1;
>How about a function like this.
>Int dict_get_int(const AVDictionary *m, const char *key, int
>default_value)
If we parse the options ourselves (as opposed to pass a string into an external library function) we should look into using AVOptions. Else we will slowly but for sure create a usability nightmare.
Can't look into the code right now, but I think it should be possible to use AVOptions somehow.
Other opinions in this?
[...]
Alexander
More information about the ffmpeg-devel
mailing list