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 9EB4B4276A for ; Wed, 30 Mar 2022 12:20:04 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 05F5C68B264; Wed, 30 Mar 2022 15:19:29 +0300 (EEST) Received: from mail-lj1-f178.google.com (mail-lj1-f178.google.com [209.85.208.178]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7568C68B159 for ; Wed, 30 Mar 2022 15:19:26 +0300 (EEST) Received: by mail-lj1-f178.google.com with SMTP id g24so27398982lja.7 for ; Wed, 30 Mar 2022 05:19:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=e67rJjxL3/70KyO3YUb1luBz3oVKcQTD1Fo5/Lm7BoY=; b=Km7Cav6ce7UUTTKOk+aE2AjlNZbtHPp2SeZfrUOFAqNGiAD/895AXRhffOFjF5RhLU tRdStnsp4jm8wpfVrMcWguHnldg7+fhrJNJdF3QJ8AWbtFBPctWWAuqKGlImTW/9f/fk EozN7j/C/pP5/wrt5L4AiVi4DFNhp3LQ0KDlULyIxhkAaw0AA3YGqN+x1aoRIDqigAwT pXxVVEh+gnRrJg8rjTUmZXdxCUOlLiADCNZUDvXOomLqVunU848oLEQP0kLz1/+RiiO4 y3/AXrxEJ+QxziEqNKdZEMtcwGsCCzYe16IXd+Ktip5P5/coEhau7sc/IQhZil7WGhdc rkdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=e67rJjxL3/70KyO3YUb1luBz3oVKcQTD1Fo5/Lm7BoY=; b=d/K7Ozod9FymPoI2nzyvy0AuYqoJli+w060Ozma0Zd6EQNFGs2/SlNUyzRmKXh9FGV 4Nqy0uqFPEzdluozFU4odB2nSt6D6dq0cT+jzl2JLVKNBzDTujiVWqDSNWa0Gp3QHZyM UTvEw8VAkwdlE0RKDttSucexsFXe8+hKmO809YfDGvngtMDiFcvEujFsHwNma8OVsKCP hNxb8eBbRYW3+8YDD+Wpsc7TPMiwRzllsg826a+V1rTsnX+IsJ26RfGVBE4fNgPTLgv/ EZogZQZrCD78iWazDvx1JfPEZSN7b9Qtlr3/LTax25oGRWX2ANZCDsRTpAED/3aDoQZJ wZJQ== X-Gm-Message-State: AOAM531QOcn8bsUwTowcsssmiVnStlYl2vZ3dmNuqSA2vdKV8woG/Gf1 uXsv+BdNyND575xulOjS89wGNXPLrFY= X-Google-Smtp-Source: ABdhPJyTmqqJPd6h2JEYI+79qn2APrnvnGx6eKFLHDWbesj3Ft3n63+IId+I7qu0B6WNDYR+FDPD7w== X-Received: by 2002:a2e:9cc5:0:b0:24a:c452:33a3 with SMTP id g5-20020a2e9cc5000000b0024ac45233a3mr6378550ljj.348.1648642765474; Wed, 30 Mar 2022 05:19:25 -0700 (PDT) Received: from localhost.localdomain (deedock.humlab.lu.se. [130.235.135.183]) by smtp.gmail.com with ESMTPSA id b14-20020a0565120b8e00b0044a29806f79sm2313181lfv.259.2022.03.30.05.19.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Mar 2022 05:19:25 -0700 (PDT) From: Diederick Niehorster To: ffmpeg-devel@ffmpeg.org Date: Wed, 30 Mar 2022 14:17:55 +0200 Message-Id: <20220330121806.822-11-dcnieho@gmail.com> X-Mailer: git-send-email 2.28.0.windows.1 In-Reply-To: <20220330121806.822-1-dcnieho@gmail.com> References: <20220330121806.822-1-dcnieho@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v5 10/21] avutil/opt: document AVOptionRange min_value > max_value 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 Cc: Diederick Niehorster 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: AVOptionRange needs a way to encode that an option is not set. Here i provide a documentation solution. When a range is invalid (value_min > value_max), it should be considered unset/value not available. When querying a range of formats of an avdevice, sometimes for a given format the queried option is not available. This is not an error as the user is asking for a valid capability, it just doesn't always apply to all the matching formats of the device. This cannot be communicated through a single special value (like 0 or -1) as that has the same problem asany special value solution. Documenting that an invalid range means value not available allows communicating this situation without adding a field to the AVOptionRange struct. This further documents that an AVOptionRange denotes a single value when value_min == value_max, and a range only when value_max > value_min. This makes the is_range field superfluous. Signed-off-by: Diederick Niehorster --- libavutil/opt.c | 2 +- libavutil/opt.h | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/libavutil/opt.c b/libavutil/opt.c index 8ffb10449b..ebffbb2f36 100644 --- a/libavutil/opt.c +++ b/libavutil/opt.c @@ -1979,9 +1979,9 @@ int av_opt_query_ranges_default(AVOptionRanges **ranges_arg, void *obj, const ch ranges->range[0] = range; ranges->nb_ranges = 1; ranges->nb_components = 1; - range->is_range = 1; range->value_min = field->min; range->value_max = field->max; + range->is_range = field->max > field->min; switch (field->type) { case AV_OPT_TYPE_BOOL: diff --git a/libavutil/opt.h b/libavutil/opt.h index 461b5d3b6b..4e7d7433e9 100644 --- a/libavutil/opt.h +++ b/libavutil/opt.h @@ -316,6 +316,11 @@ typedef struct AVOptionRange { * Value range. * For string ranges this represents the min/max length. * For dimensions this represents the min/max pixel count or width/height in multi-component case. + * If value_min < value_max, the struct encodes a range. + * If value_min == value_max, the struct encodes a single value. + * If value_min > value_max, the range is empty (a value is not available). + * Good sentinel values to use when a range is empty + * are value_min=0, value_max=-1, but this is not required. */ double value_min, value_max; /** -- 2.28.0.windows.1 _______________________________________________ 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".