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 A660648CE4 for ; Fri, 23 Feb 2024 14:32:18 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3734E68C8BA; Fri, 23 Feb 2024 16:31:42 +0200 (EET) 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --- 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. -- 2.42.0 _______________________________________________ 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".