From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id C130A4AF00 for ; Thu, 23 May 2024 18:03:38 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 35EBF68D38F; Thu, 23 May 2024 21:03:35 +0300 (EEST) Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6BF3F68C7E4 for ; Thu, 23 May 2024 21:03:29 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 8E798EA6EA for ; Thu, 23 May 2024 20:03:28 +0200 (CEST) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id vFASZIkRGfGA for ; Thu, 23 May 2024 20:03:25 +0200 (CEST) Received: from iq (iq [217.27.212.140]) by iq.passwd.hu (Postfix) with ESMTPS id 7BD73E86D0 for ; Thu, 23 May 2024 20:03:25 +0200 (CEST) Date: Thu, 23 May 2024 20:03:25 +0200 (CEST) From: Marton Balint To: FFmpeg development discussions and patches In-Reply-To: <20240523090339.4228-2-anton@khirnov.net> Message-ID: <89d149c4-da39-ee67-14fb-58611bbda739@passwd.hu> References: <20240523090339.4228-1-anton@khirnov.net> <20240523090339.4228-2-anton@khirnov.net> MIME-Version: 1.0 Subject: Re: [FFmpeg-devel] [PATCH 2/4] fftools/ffmpeg: rewrite checking whether codec AVOptions have been used X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On Thu, 23 May 2024, Anton Khirnov wrote: > Share the code between encoding and decoding. Instead of checking every > stream's options dictionary (which is also used for other purposes), > track all used options in a dedicated dictionary. > --- > fftools/cmdutils.c | 17 ++++++++---- > fftools/cmdutils.h | 4 ++- > fftools/ffmpeg.c | 49 ++++++++++++++++++++++++++++++++++ > fftools/ffmpeg.h | 3 ++- > fftools/ffmpeg_demux.c | 50 ++++++++--------------------------- > fftools/ffmpeg_mux.c | 1 + > fftools/ffmpeg_mux.h | 3 +++ > fftools/ffmpeg_mux_init.c | 55 +++++---------------------------------- > fftools/ffmpeg_opt.c | 18 ------------- > fftools/ffplay.c | 2 +- > fftools/ffprobe.c | 2 +- > 11 files changed, 89 insertions(+), 115 deletions(-) > [...] > --- a/fftools/ffmpeg.c > +++ b/fftools/ffmpeg.c > @@ -493,6 +493,55 @@ int check_avoptions(AVDictionary *m) > return 0; > } > > +int check_avoptions_used(const AVDictionary *opts, const AVDictionary *opts_used, > + void *logctx, int decode) > +{ > + const AVClass *class = avcodec_get_class(); > + const AVClass *fclass = avformat_get_class(); > + > + const int flag = decode ? AV_OPT_FLAG_DECODING_PARAM : > + AV_OPT_FLAG_ENCODING_PARAM; > + const AVDictionaryEntry *e = NULL; > + > + while ((e = av_dict_iterate(opts, e))) { > + const AVOption *option, *foption; > + char *optname, *p; > + > + optname = av_strdup(e->key); > + if (!optname) > + return AVERROR(ENOMEM); > + > + p = strchr(optname, ':'); > + if (p) > + *p = 0; > + > + option = av_opt_find(&class, optname, NULL, 0, > + AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ); > + foption = av_opt_find(&fclass, optname, NULL, 0, > + AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ); > + av_freep(&optname); > + if (!option || foption) > + continue; > + > + if (!(option->flags & flag)) { > + av_log(logctx, AV_LOG_ERROR, "Codec AVOption %s (%s) is not a %s " > + "option.\n", option->name, option->help ? option->help : "", Why the change of e->key to option->name? The full user specified option should be printed with specifier, so the user will know exactly which specifier matched the wrong stream type. > + decode ? "decoding" : "encoding"); > + return AVERROR(EINVAL); > + } > + > + if (!av_dict_get(opts_used, e->key, NULL, 0)) { > + av_log(logctx, AV_LOG_WARNING, "Codec AVOption %s (%s) has not been used " > + "for any stream. The most likely reason is either wrong type " > + "(e.g. a video option with no video streams) or that it is a " > + "private option of some decoder which was not actually used " > + "for any stream.\n", option->name, option->help ? option->help : ""); Same here. The non-matching specifer should also be printed, not only the option name, so please keep using e->key in the warning message. Thanks, Marton _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".