From patchwork Thu May 23 08:32:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: llyyr X-Patchwork-Id: 49169 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:542:0:b0:460:55fa:d5ed with SMTP id 63csp880886vqf; Thu, 23 May 2024 01:33:03 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXFv4jNWh1F/PlUKbbEOtbwb3JRw6GHOzRBgkwiBNMeazYXrRv+RsD1/Z1QZsBqhfq+Eoxedn2XBaF1zHMvUrfoFy7T8YIt1e+FbQ== X-Google-Smtp-Source: AGHT+IG/MOGaingJkJmPRhPwCUxYM/AOGjajAJ4EIloSseiWF2QpdTyF1tN5Z227nmKpnWHCWXPC X-Received: by 2002:a50:9f26:0:b0:573:5c38:fec5 with SMTP id 4fb4d7f45d1cf-57832a88ee6mr2431419a12.16.1716453183627; Thu, 23 May 2024 01:33:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1716453183; cv=none; d=google.com; s=arc-20160816; b=WeVEpVhCLyW/ZuWHv9Me7vzM4q7wJKpHGUZRkYF0VjvitdL5QKjrwprFgUgC2r9TNe +HVpIToQWhodG5CZF+ds/S6i0GVJFL+A7g3VTi047EwMb3e6zk5pBuGK5bt2deFFxEmV z/Vi6K0QkwmMw21gP9MUGQOmN8GvFuOMy0cOcWu4F8DXrDAcWREg6TTxpwutBIPoU7np 4+mtFzpkhrQekyPex3kjXdZAsgOfE+zvGkorLWO5fUvK2/lWlNyGp4vl6AYZ46mpGVwb 8N0UZOhTfMqlrKWEc9kIBjc0w2p+WlPMG24GtLML1+ww97/8rZ0LMKZuJ3uIEib1AkBW LKjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:message-id:date:to:from :dkim-signature:delivered-to; bh=cn3RcsAAWlnewgMYL1t3eQ1bLV3xGQwhn2IluR20WTU=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=lqUIiVP0Mq8cFDzp9Li5r2zS9TGZiz17wIHbwrif4+A3pUw8b6JnsGUVUgFeebawtV lZr8R+Fg22vBrGuUiLA4ifS5KwW8EWWLxhzVGgt/UlXqXazLncB+j+qMebui3Sxr90aM pACSRSQG32twVd6XVT5Xmznjnz8TlKyY8XA+9jkwVDDMRpDnUk/axCssSJVNHPJvab33 plvY4g1ks7TEuArGo46X2jwhUcY6eRCCJmqr/0ch0BeleGZAM8zHqgDHhk2Mozkuv+hc vWnzilL/7zfZPALyhzxNe3fWjGZtiUdSM9AHZ9H4byadNRYBRxdQRYdl4yOITPexwmVy ISkg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=DDmM6tAE; 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 4fb4d7f45d1cf-574f7ff1ed5si9675268a12.113.2024.05.23.01.33.03; Thu, 23 May 2024 01:33:03 -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=20230601 header.b=DDmM6tAE; 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 25E2E68D3C6; Thu, 23 May 2024 11:33:01 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1546A68C682 for ; Thu, 23 May 2024 11:32:54 +0300 (EEST) Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-1f05b669b6cso18019305ad.3 for ; Thu, 23 May 2024 01:32:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716453171; x=1717057971; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=hs8114GRhX5lgr3lHIZHKS7SDu7xUu6KGlPE55FHzho=; b=DDmM6tAEiPGr7enQGb5gUQS7CECzDH2YNQ8GbyKMK3YPyIsR8W0H7g5eripzi7sLz6 9qm8+kefZ/2VJKzkZE0HvEPQCmnz9Yf000OS1u3pfyA3EHzWqHyulRdomi0hIyONiOye LCAOvCVpDgJSPWIg3KU3RseketRkNapKPVl/R+4wkNWc+P/lEv8XUl1x2UIXUgWxTY4s wQNX/1asVGxkCFhy4N+Hz4yWywbht2yLBLgjehIraZFnTNbSO+Mv+i9ImkA65jwbly3V 7Xct0vvcahWaP9qRPa1vWrJwvONr5mAe9RdLNFr5qtn4hJgsUIYDTeEGFZUpF9H07ixK oEBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716453171; x=1717057971; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=hs8114GRhX5lgr3lHIZHKS7SDu7xUu6KGlPE55FHzho=; b=sI+yIaMdiCVK4Bva4PHZhJfd7GDqorcBpBysptxSXeMVVpzVv0UBU+dzFvLvVcXEyE v3xwDehBMdVS6fbWg8uedPnjsB1sJ+CS7pLT2Ot8NeFblFpBPBKXv3Qnpw8FMfOLOEjy sZ9x4MqolHBB8EmWASimcQaQBWKuHV8zvBob6iDQny0RAI5Q8z6u6tOmKmhZC6nNlUdJ kB08e/LK/3s0Lft0UDldA8IrPR5i8sJVZSSccyKuhPECQ8ykOEO8cL4FbHbuUfZZ3Zxh xY/Op4lxKej4xJEBGpkPxrEQ1i+moMDxWDNoBDwE+2M2jTz9jxSrBUVqgetlVOA4Q8Dt y5TA== X-Gm-Message-State: AOJu0YygBCuZ2QzlrkC/PHjWs2V/dsvFV4G4fk5yDWZi0ITR8WKBmK14 y9maqO/monHShGv9BlUbfjSloOxvXj4pwf97p4YdJuXj+zTdXVnFlt7Nkw== X-Received: by 2002:a17:902:9a94:b0:1f3:465:2869 with SMTP id d9443c01a7336-1f31c984a71mr36901685ad.31.1716453171441; Thu, 23 May 2024 01:32:51 -0700 (PDT) Received: from localhost.localdomain ([103.208.20.250]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f2f9b4c020sm74568335ad.186.2024.05.23.01.32.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 May 2024 01:32:50 -0700 (PDT) From: llyyr.public@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Thu, 23 May 2024 14:02:46 +0530 Message-ID: <20240523083246.31844-1-llyyr.public@gmail.com> X-Mailer: git-send-email 2.45.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] lavc/vp9: reset segmentation fields when segmentation isn't enabled 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: AhSXubqLmfUy From: llyyr Fields under the segmentation switch are never reset on a new frame, and retain the value from the previous frame. This bugs out a bunch of hwaccel drivers when segmentation is disabled but update_map isn't reset because they don't ignore values behind switches. This commit also resets the temporal field, though it may not be required. We also do this for vp8 [1] so this commit is just mirroring the vp8 logic. This fixes an issue with certain samples [2] that causes blocky artifacts with vaapi, d3d11va and cuda (and possibly others). Mesa worked around [3] this by ignoring these fields if segmentation.enabled is 0, but d3d11va still displays blocky artifacts. [1] https://git.ffmpeg.org/gitweb/ffmpeg.git/blob/HEAD:/libavcodec/vp8.c#l811 [2] https://github.com/mpv-player/mpv/issues/13533 [3] https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27816 Signed-off-by: llyyr --- libavcodec/vp9.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c index 6e2d18bf9595..8ede2e2eb358 100644 --- a/libavcodec/vp9.c +++ b/libavcodec/vp9.c @@ -709,6 +709,12 @@ static int decode_frame_header(AVCodecContext *avctx, s->s.h.segmentation.feat[i].skip_enabled = get_bits1(&s->gb); } } + } else { + // Reset fields under segmentation switch if segmentation is disabled. + // This is necessary because some hwaccels don't ignore these fields + // if segmentation is disabled. + s->s.h.segmentation.temporal = 0; + s->s.h.segmentation.update_map = 0; } // set qmul[] based on Y/UV, AC/DC and segmentation Q idx deltas