From patchwork Thu Feb 13 15:07:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 17774 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 23CFC44B522 for ; Thu, 13 Feb 2020 17:08:19 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id F3C2568AFCD; Thu, 13 Feb 2020 17:08:18 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qk1-f193.google.com (mail-qk1-f193.google.com [209.85.222.193]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5497968AF70 for ; Thu, 13 Feb 2020 17:08:12 +0200 (EET) Received: by mail-qk1-f193.google.com with SMTP id c188so5958498qkg.4 for ; Thu, 13 Feb 2020 07:08:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=DC4e6rwIk5k3DQy1sGMZhL20pio+mqPN7OKGWCEWxrc=; b=SEbJYEOZEGIpDwk70bUPDczGMT1zopUV01jXJAMXvUlBCCvxLf6dC4WlDW/mBbwdbL y01rEdZc5ywh6daqh2qYSgwADv3tFoPVUjOykClmhXW1nKOlC73lvNdJBsnGKkpehH3b /EhBv5c0OZHTfeDxGhDlNokNSPljYwJAy+uKx6XUzoGRYUYY8XTADnSE1eOsdko1shEV GGPwoNgEQetV2q3yZcP1zcE2/ZKVEe5evnh1C4TrjSmS4iHacP7Y690OmsMRhVnb7PP4 zw3PzlUyODWdPaarnyd7wDg3N3NMVIMtHzl9FQA55rmGjmysf0rUHbJEs9RCFGVZXuyy 6fOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DC4e6rwIk5k3DQy1sGMZhL20pio+mqPN7OKGWCEWxrc=; b=SvEpevzH6jx6/HmBxnPhjXn8a2PMk5ErL+FAztE92eSbeYBcGoJ60MecWD2DkjA2LD xNL+jQtq0fWk0P4DTi5MMrvs0/5Oi/I35+cX9E7peJq3h+8Fm8h+a/hhiPge7I/WC0JW Vrytrgn6tFwrPceJanzkrCxUqO8INjjXNESuiMz/Kj1Gx1x+4yNLCAyb3SxsGEM1kga9 91IuIu1BYN0JK2LIfke89cM3rqMMXjTri5qgVbZLwO9dDXmcQuvZ9SSs1Kzx3Z90D2XR ADvNX2GFYYz6/bZ3hkDe6Mz/Kb7+kWvNidUR9gTnj0y99f20gSXkj99BvSwXTgJpBjaG dwPA== X-Gm-Message-State: APjAAAU228ORMWkep+vWl8BnKac0xwUQAURJ5PU8WpOWoIrlXAMBGBF5 wxUf1ZT/3rTOvf+IM3/ipbvWkYOo X-Google-Smtp-Source: APXvYqxBUTQ8QWiB42EsvkmJInyzr+HVAwuiUBpURO9c0plu1Fkpd8hK+HXQn+1ZBf3j8YiEhIaXZg== X-Received: by 2002:a05:620a:1535:: with SMTP id n21mr9168644qkk.205.1581606490741; Thu, 13 Feb 2020 07:08:10 -0800 (PST) Received: from localhost.localdomain ([181.23.83.80]) by smtp.gmail.com with ESMTPSA id l184sm1417061qkc.107.2020.02.13.07.08.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Feb 2020 07:08:10 -0800 (PST) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Thu, 13 Feb 2020 12:07:33 -0300 Message-Id: <20200213150733.2515-1-jamrial@gmail.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200213025914.5451-1-jamrial@gmail.com> References: <20200213025914.5451-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2] avcodec/cbs_av1: add missing value constrains to point_y_value, point_cb_value and point_cr_value X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" If i is greater than 0, it is a requirement of bitstream conformance that point_y_value[ i ] is greater than point_y_value[ i - 1 ]. If i is greater than 0, it is a requirement of bitstream conformance that point_cb_value[ i ] is greater than point_cb_value[ i - 1 ]. If i is greater than 0, it is a requirement of bitstream conformance that point_cr_value[ i ] is greater than point_cr_value[ i - 1 ]. Signed-off-by: James Almer --- Better version. Now it can't overflow the min value, and will also constrain the max value to ensure v[i] > v[i-1] is always true. libavcodec/cbs_av1_syntax_template.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/libavcodec/cbs_av1_syntax_template.c b/libavcodec/cbs_av1_syntax_template.c index b62e07fb11..0855f7306f 100644 --- a/libavcodec/cbs_av1_syntax_template.c +++ b/libavcodec/cbs_av1_syntax_template.c @@ -1156,7 +1156,10 @@ static int FUNC(film_grain_params)(CodedBitstreamContext *ctx, RWContext *rw, fc(4, num_y_points, 0, 14); for (i = 0; i < current->num_y_points; i++) { - fbs(8, point_y_value[i], 1, i); + fcs(8, point_y_value[i], + i ? current->point_y_value[i - 1] + 1 : 0, + MAX_UINT_BITS(8) - (current->num_y_points - i - 1), + 1, i); fbs(8, point_y_scaling[i], 1, i); } @@ -1175,12 +1178,18 @@ static int FUNC(film_grain_params)(CodedBitstreamContext *ctx, RWContext *rw, } else { fc(4, num_cb_points, 0, 10); for (i = 0; i < current->num_cb_points; i++) { - fbs(8, point_cb_value[i], 1, i); + fcs(8, point_cb_value[i], + i ? current->point_cb_value[i - 1] + 1 : 0, + MAX_UINT_BITS(8) - (current->num_cb_points - i - 1), + 1, i); fbs(8, point_cb_scaling[i], 1, i); } fc(4, num_cr_points, 0, 10); for (i = 0; i < current->num_cr_points; i++) { - fbs(8, point_cr_value[i], 1, i); + fcs(8, point_cr_value[i], + i ? current->point_cr_value[i - 1] + 1 : 0, + MAX_UINT_BITS(8) - (current->num_cr_points - i - 1), + 1, i); fbs(8, point_cr_scaling[i], 1, i); } }