From patchwork Fri Feb 23 13:58:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 46463 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:26a3:b0:19e:cdac:8cce with SMTP id h35csp992491pze; Fri, 23 Feb 2024 06:32:21 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXr+lhyzvEtH1i9i1PsvhchrPXwSaGm4yhDquQjZ2oacbctEZyXd5nnB/SO4zFkt/fJz/Tcdrh3B7F1oB59Z1Jnl1Twyoqz4NiTIw== X-Google-Smtp-Source: AGHT+IGdgTfeu7a9cTBbGLE78EqVs1ARPquM/AeQaoHWWX+cXcCMIITk2UHAkztGrKylqGCvgYjh X-Received: by 2002:a50:c35e:0:b0:565:8287:d69d with SMTP id q30-20020a50c35e000000b005658287d69dmr7458edb.1.1708698741340; Fri, 23 Feb 2024 06:32:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1708698741; cv=none; d=google.com; s=arc-20160816; b=bEyZncsaG9M7MpG28mDWmMGf9wG9ozR9slsG5gIypRv5fFQ3jz3ganI5j/Ur27kQTO UxOJGgdn31VPGI6S5SHYj3fRppUn7n9JZTvmkHRV9cUpoJUKGi2EwfH35/eC8wFvB/2L ynMGtdvPd9u6//UPYlSisI+mI32cV17bFsN00MFQoFdyTMQaTpORNugWyAeNGKRwQbGw XVyaU+AiDBQ3Kmb1WTgbX5DLLdPJd5V3+Yvc4gvwMS7UKESx5MJ75cYYXxlVkiCAhk2U xcOR5xhuh/E6aZax6RcIxcGumsT80V0vxqMFA77rnD/Qc5XZG+B4BUFW8cxA1538zEpt g6xQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=mY54sn3Q64wW/u+AxUOECHlRxDwUKlE03mY0ShlWqCk=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=eh3MAJr/iM60ZAdrldt2ALaAu5ojtNMrZj+/rM92RiAPu2X0WExJKKYlH1dD8yqOFh 5fDwqO10AKNwVJL16OSPyGqCzjeo8VdCAb6Pgh0eiCLFsBeasGUME5Fbpg6scSo63+qa hvHFX439cwyrAXrEcJ5zhBxbo6gczNPNwUNxK7qxBEGY42SwdBZp1QIWf1FYIFUWIav+ iXOUGVpNBGnvQiUcw8PJt+HV5TUwtZ3WmeqNcvFxmyYkSlxJpjsiiwSSZBO1qwGWIXV5 XQaOrZ89rhcbXy/iw6zqs592pLR9+vVMOTh93WZAAQSSXvTNNXuvOqv3rmnaO6/35M53 nxNA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=brdrt079; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id dh28-20020a0564021d3c00b0056400f8616csi6156428edb.566.2024.02.23.06.32.20; Fri, 23 Feb 2024 06:32:21 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=brdrt079; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7A3BD68C8CA; Fri, 23 Feb 2024 16:31:42 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5B6BC68C5EF for ; Fri, 23 Feb 2024 16:31:35 +0200 (EET) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=brdrt079; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id D8FCE4D24 for ; Fri, 23 Feb 2024 15:31:30 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id gEbNWFEe6OFx for ; Fri, 23 Feb 2024 15:31:30 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1708698687; bh=OPBlqjT+7oJtSFwZygGbnjMBLsBcdgDTCVaBDie+AUM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=brdrt079BR4xvVHVhflvzUQCCA+X5DEIxNw9T5p5QtBKH/5WgLA1qQLmJ6vRZpBXc 6ylQT9l7yP1AIzSCCH06J/4TPh7duF8HU2mZ5ywO/1+R/aDGea+R/lzURaQ6rRgHPM L2+IDeQGVfRoNbwA/hp/I4WyiXpevi6VP/vvrbhZWKKPI4r2/d38GbzZX3F6UGGaUQ ouQTJDOmirjYUABFTTXDrhEpMDLRyGQiE+y0V/PAQJH7DokNI/P5EfH6H+RZXZhZG8 30bE2PXIhbOTDUaqONAiMYccyBMy6/2Ait87lEb8+1VJ0Mtqnn6lkMUYtHUCrU19y7 ioCBfdRoQnXIA== Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id 5813F4D03 for ; Fri, 23 Feb 2024 15:31:27 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 0C2343A0CB4 for ; Fri, 23 Feb 2024 15:31:22 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Fri, 23 Feb 2024 14:58:27 +0100 Message-ID: <20240223143115.16521-6-anton@khirnov.net> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240223143115.16521-1-anton@khirnov.net> References: <20240223143115.16521-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 05/38] lavu/opt: cosmetics, group option setting function together 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: SK4nz9yZFjZy --- libavutil/opt.h | 102 +++++++++++++++++++++++++----------------------- 1 file changed, 54 insertions(+), 48 deletions(-) diff --git a/libavutil/opt.h b/libavutil/opt.h index e2b6ba1f35..6ed19888a5 100644 --- a/libavutil/opt.h +++ b/libavutil/opt.h @@ -576,6 +576,11 @@ enum { * @} */ +/** + * @defgroup opt_write Setting and modifying option values + * @{ + */ + /** * Parse the key/value pairs list in opts. For each key/value pair * found, stores the value in the field in ctx that is named like the @@ -627,16 +632,6 @@ int av_opt_set_from_string(void *ctx, const char *opts, const char *const *shorthand, const char *key_val_sep, const char *pairs_sep); -/** - * Check whether a particular flag is set in a flags field. - * - * @param field_name the name of the flag field option - * @param flag_name the name of the flag to check - * @return non-zero if the flag is set, zero if the flag isn't set, - * isn't of the right type, or the flags field doesn't exist. - */ -int av_opt_flag_is_set(void *obj, const char *field_name, const char *flag_name); - /** * Set all the options from a given dictionary on an object. * @@ -672,28 +667,23 @@ int av_opt_set_dict(void *obj, struct AVDictionary **options); int av_opt_set_dict2(void *obj, struct AVDictionary **options, int search_flags); /** - * @defgroup opt_eval_funcs Evaluating option strings - * @{ - * This group of functions can be used to evaluate option strings - * and get numbers out of them. They do the same thing as av_opt_set(), - * except the result is written into the caller-supplied pointer. + * Copy options from src object into dest object. * - * @param obj a struct whose first element is a pointer to AVClass. - * @param o an option for which the string is to be evaluated. - * @param val string to be evaluated. - * @param *_out value of the string will be written here. + * The underlying AVClass of both src and dest must coincide. The guarantee + * below does not apply if this is not fulfilled. * - * @return 0 on success, a negative number on failure. - */ -int av_opt_eval_flags (void *obj, const AVOption *o, const char *val, int *flags_out); -int av_opt_eval_int (void *obj, const AVOption *o, const char *val, int *int_out); -int av_opt_eval_int64 (void *obj, const AVOption *o, const char *val, int64_t *int64_out); -int av_opt_eval_float (void *obj, const AVOption *o, const char *val, float *float_out); -int av_opt_eval_double(void *obj, const AVOption *o, const char *val, double *double_out); -int av_opt_eval_q (void *obj, const AVOption *o, const char *val, AVRational *q_out); -/** - * @} + * Options that require memory allocation (e.g. string or binary) are malloc'ed in dest object. + * Original memory allocated for such options is freed unless both src and dest options points to the same memory. + * + * Even on error it is guaranteed that allocated options from src and dest + * no longer alias each other afterwards; in particular calling av_opt_free() + * on both src and dest is safe afterwards if dest has been memdup'ed from src. + * + * @param dest Object to copy from + * @param src Object to copy into + * @return 0 on success, negative on error */ +int av_opt_copy(void *dest, const void *src); /** * @defgroup opt_set_funcs Option setting functions @@ -761,6 +751,7 @@ int av_opt_set_dict_val(void *obj, const char *name, const AVDictionary *val, in av_int_list_length(val, term) * sizeof(*(val)), flags)) /** + * @} * @} */ @@ -805,6 +796,31 @@ int av_opt_get_dict_val(void *obj, const char *name, int search_flags, AVDiction /** * @} */ + +/** + * @defgroup opt_eval_funcs Evaluating option strings + * @{ + * This group of functions can be used to evaluate option strings + * and get numbers out of them. They do the same thing as av_opt_set(), + * except the result is written into the caller-supplied pointer. + * + * @param obj a struct whose first element is a pointer to AVClass. + * @param o an option for which the string is to be evaluated. + * @param val string to be evaluated. + * @param *_out value of the string will be written here. + * + * @return 0 on success, a negative number on failure. + */ +int av_opt_eval_flags (void *obj, const AVOption *o, const char *val, int *flags_out); +int av_opt_eval_int (void *obj, const AVOption *o, const char *val, int *int_out); +int av_opt_eval_int64 (void *obj, const AVOption *o, const char *val, int64_t *int64_out); +int av_opt_eval_float (void *obj, const AVOption *o, const char *val, float *float_out); +int av_opt_eval_double(void *obj, const AVOption *o, const char *val, double *double_out); +int av_opt_eval_q (void *obj, const AVOption *o, const char *val, AVRational *q_out); +/** + * @} + */ + /** * Gets a pointer to the requested field in a struct. * This function allows accessing a struct even when its fields are moved or @@ -835,25 +851,6 @@ void av_opt_freep_ranges(AVOptionRanges **ranges); */ int av_opt_query_ranges(AVOptionRanges **, void *obj, const char *key, int flags); -/** - * Copy options from src object into dest object. - * - * The underlying AVClass of both src and dest must coincide. The guarantee - * below does not apply if this is not fulfilled. - * - * Options that require memory allocation (e.g. string or binary) are malloc'ed in dest object. - * Original memory allocated for such options is freed unless both src and dest options points to the same memory. - * - * Even on error it is guaranteed that allocated options from src and dest - * no longer alias each other afterwards; in particular calling av_opt_free() - * on both src and dest is safe afterwards if dest has been memdup'ed from src. - * - * @param dest Object to copy from - * @param src Object to copy into - * @return 0 on success, negative on error - */ -int av_opt_copy(void *dest, const void *src); - /** * Get a default list of allowed ranges for the given option. * @@ -896,6 +893,15 @@ int av_opt_is_set_to_default(void *obj, const AVOption *o); */ int av_opt_is_set_to_default_by_name(void *obj, const char *name, int search_flags); +/** + * Check whether a particular flag is set in a flags field. + * + * @param field_name the name of the flag field option + * @param flag_name the name of the flag to check + * @return non-zero if the flag is set, zero if the flag isn't set, + * isn't of the right type, or the flags field doesn't exist. + */ +int av_opt_flag_is_set(void *obj, const char *field_name, const char *flag_name); #define AV_OPT_SERIALIZE_SKIP_DEFAULTS 0x00000001 ///< Serialize options that are not set to default values only. #define AV_OPT_SERIALIZE_OPT_FLAGS_EXACT 0x00000002 ///< Serialize options that exactly match opt_flags only.