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 C8DC1411A7 for ; Fri, 25 Mar 2022 14:13:22 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A0BDE68B280; Fri, 25 Mar 2022 16:12:21 +0200 (EET) Received: from mail-lj1-f181.google.com (mail-lj1-f181.google.com [209.85.208.181]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D099368B26E for ; Fri, 25 Mar 2022 16:12:20 +0200 (EET) Received: by mail-lj1-f181.google.com with SMTP id q5so10470117ljb.11 for ; Fri, 25 Mar 2022 07:12:20 -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=gNLOjYPO4ynljmPWzagBFpIHok3mH6H0L9FkL6s4k9RnnegjebfMRO77uKMFwVILrx DxRJruFO7TQDjAeAJycmwe3GYF9Hu9BnaPiGM4sObbbH572Pob120LTTV6KcljJUMW7L Zxwaw9LAWGBJPALvMRHZsfC3R0ueKsxUAifGgCBmRZWRB7QXWe7JtYMTxCI6Im6ZWTmf vLkGzLeGz25LcAOyA9VEmbAS0zSO3wFUeY8VSZIAyfl9OijjCUKS9w40Syb5JCa1UpjG J58WLH+ac/uB8pD+fN9AH1Es8TtxO+UzgmHDA5oT5NiM2FsHRZEzNndE+TooYRR/8mXT hBMA== 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=P370d2o5yP4SsVlj5+mKTxRlupSk6ow22DmKL1c+1aK1dyCD960033h+x6rrsN+yeQ OzgcCvVcAN53pwSVtZZw9ErBmmRXuBbK05f/De78kNNscAvh1ndry55Tz24I+kFT8r+h +rTx6wNBKCY28yYjirOMOy3TnY02zkSZcu9NbPpzA3uZllrzQ8d18W4iB9wmcZ26I9I8 Ut7F0rM6JHXXofg4MJreBq0+xj536hk6GacmCT1dJNrE3LFKH9IwquU7F6VQJCj1SKUq ubNi/RlvNfTQsFn9WPH9lByL0fm9MyPqFS2SfGLzG6Ho7xOX0a4BUo5b/qGt95sD1ovJ q70Q== X-Gm-Message-State: AOAM531mAhErBvCew0Tfg48fWRI/rgET3mYvXF+8zr+48e91HaXZNlZp DRBZeGWM5VWko90Ce3sEcSaanzsdeqg= X-Google-Smtp-Source: ABdhPJz/D4lqv5+0Z2eCpfw+UwxdY3cHL5x+7w2EW4plFltU808WN/PRCtKD1Z1zi0HFmZ+8384nng== X-Received: by 2002:a05:651c:1024:b0:249:bab3:f3fa with SMTP id w4-20020a05651c102400b00249bab3f3famr1768719ljm.337.1648217539659; Fri, 25 Mar 2022 07:12:19 -0700 (PDT) Received: from localhost.localdomain (deedock.humlab.lu.se. [130.235.135.183]) by smtp.gmail.com with ESMTPSA id t5-20020ac25485000000b0044833ffc127sm717920lfk.185.2022.03.25.07.12.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Mar 2022 07:12:19 -0700 (PDT) From: Diederick Niehorster To: ffmpeg-devel@ffmpeg.org Date: Fri, 25 Mar 2022 15:10:30 +0100 Message-Id: <20220325141041.1748-12-dcnieho@gmail.com> X-Mailer: git-send-email 2.28.0.windows.1 In-Reply-To: <20220325141041.1748-1-dcnieho@gmail.com> References: <20220325141041.1748-1-dcnieho@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v4 11/22] 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".