From patchwork Tue Jul 6 09:20:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Diederick C. Niehorster" X-Patchwork-Id: 28811 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a5d:965a:0:0:0:0:0 with SMTP id d26csp4921797ios; Tue, 6 Jul 2021 02:25:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxNCvH8vVF6p54qMhRb9v+biBJyV2R35PFoIIanCpfu/LZ5KJLzowwVUDQbLv8FQxMdCzu8 X-Received: by 2002:a05:6402:c18:: with SMTP id co24mr16641398edb.307.1625563520710; Tue, 06 Jul 2021 02:25:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625563520; cv=none; d=google.com; s=arc-20160816; b=G8Ik7buk9O9yZGbjnZINLsiEUSbrBVPcp9Y35iC9RaX1dqdMEq0tXq90Cz4Yud0LHY CVmla8yG46c2ERfqrxyP3f6ru0fVV5KZ819+sxd9XSWbMyvIqNStIsLUcX/EPIk72nW4 n1vpfUizW7+Us2KK7sr6ee6RNMlEb0TDp5y9mr+VWGRLWI+y9XTn1yZTwLSXWYTus7tB GsKqN7hMBhfpXq07uyTrrFaEZuFKNHUgYGmhUGoOzYapLOBFYqyhLR4nw5OwVXhu08VE QTTqjGg3h/nCuZRS4Cmgt6hhchnTPEfqRop4Ie3rTdtomvFMj53pr+OozUp/0bHXVPLO +2NQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc: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=+Xw++F6WbKUuAy+HxNh4IfSZsGhPwIi3Vi2mgYFU10c=; b=xi3pEezAcOuyecudt0nZuwpHKoe3TX1n0WgNwTb7/6nhGZVQ9zvM+Qr4svhD2KyVPm FhYAzErC4m5u4gw3KXqDOimLE9hani9M8JIZsbTil8euCcc0okuSM9d97SKjMSICS6U3 qYqiO5cHfMp4juaaCJbww0BAFLkQn9JC/xBTY6+WPhCnARMlAqWw5jk9n/6EMtq/pRBo /fmXjCVyr8oYralurFcIJJwOEy+GCWq6rFs7j5L3Fjfos+v5rNTu7E2jZPOlNWQvlmCj mAcCIN5LdMyFUxap1+swwl7hjz3iZjm8JCgMIyNbYpc3u87VOjK9bINAbcccDPuuID+M ayBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=TAjVwnUR; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id c7si13032432ejc.373.2021.07.06.02.25.20; Tue, 06 Jul 2021 02:25:20 -0700 (PDT) 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=@gmail.com header.s=20161025 header.b=TAjVwnUR; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6EB7368A84B; Tue, 6 Jul 2021 12:25:15 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org 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 BEFA268A84B for ; Tue, 6 Jul 2021 12:25:08 +0300 (EEST) Received: by mail-lj1-f178.google.com with SMTP id a18so2039181ljk.6 for ; Tue, 06 Jul 2021 02:25:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=AJLGpPvXVoSjSGTbNo4TPl59OEh8iUg8KH0OR8wN1Z4=; b=TAjVwnURH/GtAOAaxfaJ2bV6hmAE0H9t3fs4Igw8ZQ8Y2trBVetFsyXokKKjyqUIoN xVJ60rYCAnU8BdkUZ9oQ4zIyiwVyGw+Ekh8CMfFurh4sMMQO6zwqFh0Suqzl+uemgbOi Y0+AyTn8PnB2ClSJe30Z3r+x8N+wG8j0D2EpB1WQxU8231Y/Q1klwy4AYEsqhfvquVyl BNlMqDED2DIxXnm/wxJHkCXIcraTSCN1F0lDXrzyhH4PoiLg6NS7l4qGXsqaRAKHG7VW 8PyN2m29cLDUZpThVPPP7RiSioQNCy+Zxd3rtRbDZrznBOKxzy3rOZn8TFkeiRfOyyFz vaeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AJLGpPvXVoSjSGTbNo4TPl59OEh8iUg8KH0OR8wN1Z4=; b=RkyvRGaWlkyRvND5VFjodwnfTOocbK/eA6enNdROjnwEGJvy1mHnT+7l718EKVh4Ge sykui1ApBwC5goy/OeI5nomV85erf8Ppuw2Pk7igkRkVirvwCTSU+wXVKiBweV9WymA/ iByWckrk3nqXd/GvjttpgiRO3K7iGKtiOQiLwMubXqlwQKjOhMncGS3bxnF3gwQeW3Aj pZULmmok30NTe8rp+pkMlDQlzxlRLN4C4szE3Ga+vW0irzl0qNQgSKA8SmMv91mDPFtE A2AM+h6iCYkUG8zhpA2CQjHp/YxuGqsBH2msV5sEnNgWkdkUBjo9JYc9g76x3x2pLlZ4 Q+oA== X-Gm-Message-State: AOAM532qfmKUFZ41qzgRRttpRcuEKVsXxyYKUDkv75D1iw+tDu/cGmUH kYUe6Co63/WTloiH/Wt+M58x2612A0o= X-Received: by 2002:a2e:8248:: with SMTP id j8mr14390650ljh.300.1625563507832; Tue, 06 Jul 2021 02:25:07 -0700 (PDT) Received: from localhost.localdomain (deedock.humlab.lu.se. [130.235.135.183]) by smtp.gmail.com with ESMTPSA id p4sm1336431lfk.222.2021.07.06.02.25.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jul 2021 02:25:07 -0700 (PDT) From: Diederick Niehorster To: ffmpeg-devel@ffmpeg.org Date: Tue, 6 Jul 2021 11:20:08 +0200 Message-Id: <20210706092020.1057-23-dcnieho@gmail.com> X-Mailer: git-send-email 2.28.0.windows.1 In-Reply-To: <20210706092020.1057-1-dcnieho@gmail.com> References: <20210706092020.1057-1-dcnieho@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v3 22/34] 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: uXpcr8UR3S7H 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 41284d4ecd..edb2c2ca41 100644 --- a/libavutil/opt.c +++ b/libavutil/opt.c @@ -1865,9 +1865,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 c2329e5589..3c64e8d3a5 100644 --- a/libavutil/opt.h +++ b/libavutil/opt.h @@ -313,6 +313,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; /**