[FFmpeg-devel] [PATCH WIP v2 1/9] avfilter/dnn: Refactor DNN parameter configuration system

Chen, Wenbin wenbin.chen at intel.com
Tue Apr 30 08:54:57 EEST 2024


> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces at ffmpeg.org> On Behalf Of Zhao
> Zhili
> Sent: Sunday, April 28, 2024 2:47 PM
> To: ffmpeg-devel at ffmpeg.org
> Cc: Zhao Zhili <zhilizhao at tencent.com>
> Subject: [FFmpeg-devel] [PATCH WIP v2 1/9] avfilter/dnn: Refactor DNN
> parameter configuration system
> 
> From: Zhao Zhili <zhilizhao at tencent.com>
> +
> +void *ff_dnn_child_next(DnnContext *obj, void *prev) {
> +    size_t pre_offset;
> +    char *ptr;
> +
> +    if (!prev) {
> +        obj->clazz = &dnn_base_class;
> +        return obj;
> +    }
> +
> +    pre_offset = (char *)prev - (char *)obj;
> +    for (int i = 0; i < FF_ARRAY_ELEMS(dnn_backend_info_list) - 1; i++) {
> +        if (dnn_backend_info_list[i].offset == pre_offset) {
> +            ptr = (char *)obj + dnn_backend_info_list[i + 1].offset;
> +            *(const AVClass **) ptr = dnn_backend_info_list[i + 1].class;
> +            return ptr;
> +        }
> +    }
> +
> +    return NULL;
> +}

Can this function be simplified by implementing AVFilter.preinit interface in each dnn filter
and assign class to DNNContext and TF/OV/THOption in preinit function?  I don't think setting AVClass
in child_next() function is the proper way.

wenbin

> +
> +const AVClass *ff_dnn_child_class_iterate(void **iter)
> +{
> +    uintptr_t i = (uintptr_t) *iter;
> +
> +    if (i < FF_ARRAY_ELEMS(dnn_backend_info_list)) {
> +        *iter = (void *)(i + 1);
> +        return dnn_backend_info_list[i].class;
> +    }
> +
> +    return NULL;
> +}


More information about the ffmpeg-devel mailing list