From patchwork Fri Jun 11 20:30:53 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: 28213 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a5e:c91a:0:0:0:0:0 with SMTP id z26csp765830iol; Fri, 11 Jun 2021 13:38:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyiys0JqCqxcLkrBKN0yW5bZt2q5LEe/4QHmDF/HiFWHOeBivXKXYSrJoNhlVYmxbeFV4Fz X-Received: by 2002:a17:906:ce4a:: with SMTP id se10mr5459666ejb.235.1623443882075; Fri, 11 Jun 2021 13:38:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623443882; cv=none; d=google.com; s=arc-20160816; b=Hu5y7BhZ2me1GchIvWliSogzFPEZ0Jd7n8Xh4egBq8lsCJPAqJVPRh1jybVN4qEQ0E aBxw4TSpZCN72Tk1VcwW/phq8WX0HOywnHjHoxGu/UchbI31taJx0J8yl1RfkGoexh5S HCdvzsR2p78utATmW00dmdx9NPp5KweVkabSAd9mxT8Zd4a6XAz9P6OlOl3oha+IUqBt i8Sux6LSwHWPOQoqdVXvzlA2HFmWtQiXEdLZgdVOi2V2K2ltIzo7xnApV6PifCvIruwL fF9dIgudYS1AInucyrpJ7t9BSnxk1xPuY1MmqYvLwkR9bOwVbC01363VGrvKXStXsAro ztdQ== 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=iNQ4O9x6epDd9kjcHFF+f/bH81fJXpQmp3sPhsK4tIs=; b=Q91Hewa3VwPhWirdLg8xc49Vh/6rIHlNqv7FI2J/25jvnFwx1++EklwDzyztkug2T/ 4lVhODCF6CrdZGXigkL/kluQwhBszIlO4DXR+g+PYyEgyoSQDr6SG6sdGl42K28cQZgn FGcQIHfChqQ0PQv4uNCoc29SjTKGZHmunUK5qEvAJ99cF2AN4eXz7O115ATGkkMjV+Dp KzT17V9BkLXXpNQiSxrqvzLFeNsAX+nsSuSqNqFUJaxFTPqnYIQ2akVkQG87mCmpgGF0 EbHE5LbOXFTiAxUjyKgntM33GwXWNjJVHvB6URHZjOIqvL18Bi/5Qwy2s/HB88QW1TOa 4Adw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=TsauhrBU; 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 t27si5418809ejd.372.2021.06.11.13.38.01; Fri, 11 Jun 2021 13:38:02 -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=TsauhrBU; 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 02A6A689ADA; Fri, 11 Jun 2021 23:37:53 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lj1-f177.google.com (mail-lj1-f177.google.com [209.85.208.177]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EE8EF68995F for ; Fri, 11 Jun 2021 23:37:51 +0300 (EEST) Received: by mail-lj1-f177.google.com with SMTP id z22so11295774ljh.8 for ; Fri, 11 Jun 2021 13:37:51 -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=hWUOtf3fx0nNSVFiY2Jq7UBL6A6pYL8afp8Eutfhcts=; b=TsauhrBU8xZdmzRKXQylymIjFKDOvmwAV4UgGhZX3AhRPuuYCfWIceRkrCzjha7G2d 4u4J2jbQvt5vcbZtXP1g683VrlgmYnoW17j7SPks+vFr5J9Shp+gCgI7O7UlxXtWFWBl mlsSij8vasp7qAPNA0QxFE2HBoRE7oenGT8jsceyNgQxCsKFmbqK2eEzDa+8Ycg/8Mui imBPifPD/25JPo7gjq1cFZXx0MHm1fC4Qh2cHc3SUjkXIO1hkp4YBjkmlmRtBC/Ofh8s DxTzxB52B6UvTwXsZcjDy3TnH1HWo4dVKu2uwPG1GgD9wubRP8bG7FDH8SruRoZruR5J 3MVw== 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=hWUOtf3fx0nNSVFiY2Jq7UBL6A6pYL8afp8Eutfhcts=; b=gperY036xqa/JrvyG6Ew6w4RIAo0r6kjUYyx5xmtDb5q6dy75WKGQft5Qz03/ON8RH caVuLqa9tn+Y0pn7I+LrBCBWe0NlpWQGHWwop/vsGG7QXc9K3ul4tF4XHdli0m+Emrxj bqG/bX+ukdnr16ACKNSyVhqLhG20pbpOeQS3fRb0Cv9pAZU/MqSnCCqC+SNEy4gQBM1X MLFmiHXCq15AF+xeGlwuYVIM/xjK8xWTFtKuaMHBhZWHHP24jd6Lbqi7En2Xn90/r0JC C27u20c2h2AtIU113hrUW+Q3U3Z5qBEiqRUWx+9UULMndWowqi72KyHQ9UdZQpp7ugKr cHoA== X-Gm-Message-State: AOAM530hAHB5YoKdBxB0gJx7kB3hAy12MBcxtUNBsMSjD32jl6jm5Bpz GUPnAm3Th5/QERj93L5GkLWdktO3RzWWrA== X-Received: by 2002:a2e:9b8f:: with SMTP id z15mr4255849lji.304.1623443871090; Fri, 11 Jun 2021 13:37:51 -0700 (PDT) Received: from localhost.localdomain ([196.196.203.214]) by smtp.gmail.com with ESMTPSA id t16sm843803lji.136.2021.06.11.13.37.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Jun 2021 13:37:50 -0700 (PDT) From: Diederick Niehorster To: ffmpeg-devel@ffmpeg.org Date: Fri, 11 Jun 2021 22:30:53 +0200 Message-Id: <20210611203104.1692-23-dcnieho@gmail.com> X-Mailer: git-send-email 2.28.0.windows.1 In-Reply-To: <20210611203104.1692-1-dcnieho@gmail.com> References: <20210611203104.1692-1-dcnieho@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 22/33] 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: hJp4IXRLrc0J AVOptionRange needs a way to encode that an options 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. 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; /**