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 6BBD140A3C for ; Sat, 5 Mar 2022 16:59:04 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9AF7968B148; Sat, 5 Mar 2022 18:58:51 +0200 (EET) Received: from haasn.dev (haasn.dev [78.46.187.166]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id AF04968B0FB for ; Sat, 5 Mar 2022 18:58:43 +0200 (EET) Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id 6E35B47027; Sat, 5 Mar 2022 17:58:42 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1646499522; bh=svxFl3uwrYVHtcEMY91onsPmvVZBHgrydG3hLUuFCmA=; h=From:To:Cc:Subject:Date:From; b=ZBv5n7HyhgEihTMi2mjXm86C3vjsPzsx2QUf0IVfgzt2iq/7SnkTDDhZ2cGvU4m8t 9ANp+tK95m7Iun7/WEOkDc0lqUwIKPw25ruvp1yS6EMhUhmEwoxYLrc1tiU3aophcO OMNi4EScbakaD713bi5RRuGfcdxSDK3QNudxf044= From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Sat, 5 Mar 2022 17:58:31 +0100 Message-Id: <20220305165833.18668-1-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/3] h274: correctly infer missing comp model values 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: Niklas Haas 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: From: Niklas Haas The ITU-R H.274 spec mentions defined behavior for what to do when num_comp_model_values is less than the amount expected by the fg model algorithm. The current behavior is basically undefined behavior in this case. In addition to fixing this, also defer the index offset calculation very slightly to better lead into the following commit. Signed-off-by: Niklas Haas --- libavcodec/h274.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libavcodec/h274.c b/libavcodec/h274.c index a69f941142..170086543f 100644 --- a/libavcodec/h274.c +++ b/libavcodec/h274.c @@ -162,6 +162,7 @@ static av_always_inline void generate(int8_t *out, int out_stride, { const uint8_t shift = h274->log2_scale_factor + 6; const uint16_t avg = avg_8x8_c(in, in_stride); + const uint8_t num_values = h274->num_model_values[c]; int16_t scale; uint8_t h, v; int8_t s = -1; @@ -191,8 +192,8 @@ static av_always_inline void generate(int8_t *out, int out_stride, return; } - h = av_clip(h274->comp_model_value[c][s][1], 2, 14) - 2; - v = av_clip(h274->comp_model_value[c][s][2], 2, 14) - 2; + h = num_values > 1 ? av_clip(h274->comp_model_value[c][s][1], 2, 14) - 2 : 6; + v = num_values > 2 ? av_clip(h274->comp_model_value[c][s][2], 2, 14) - 2 : h; init_slice(database, h, v); scale = h274->comp_model_value[c][s][0]; -- 2.35.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".