From patchwork Tue Jul 16 17:11:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 50576 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:40f5:b0:482:c625:d099 with SMTP id lb53csp442047vqb; Tue, 16 Jul 2024 10:27:01 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV7X75MpfZIz4K0zhVevIX2UfUNDkHwgQuCzAQbRm4qqnmvpSuUn4csARDmSqMRW5CAtq7/YlXYvmM7NreV2nXKzxH1B8gvfsgLuw== X-Google-Smtp-Source: AGHT+IHhzNA+hABn6jI8dcFQ5NoxSaFl4xgsN1ixceboVRvKIk8eFFdTCk1p71ov2HwAjiVTfLdp X-Received: by 2002:a2e:9bc9:0:b0:2ec:1f9f:a876 with SMTP id 38308e7fff4ca-2eef415febemr19067431fa.6.1721150821611; Tue, 16 Jul 2024 10:27:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721150821; cv=none; d=google.com; s=arc-20160816; b=xP7C726K+XpAFY137H/BCMjXfPzPNykVo7mmpI21kCTbLJlCZhscgExDTh2rIQdbjd 0aqXKlxNkMmSrt1MZ0ii5/kWkG42KV5F+Hs7PTacdd0g9k3MbEK1G6I3IG7Zk6y9anY9 R1rj6Bd2/qneTkNUx002ifIEbwV/7aqUz8OXSoteztchl15fli3T+/GKo16RBZNMetIX qpfsYpkTkZjRFZWBvFameff75oXdsxqYjtpBQ/zUl7MXbkgwwKDmrULL5EFMzLt0GQmy Yl6teA9MNBeXMjVUBiIM+7zvyOd+FUSpo3dsDmQbIZ5eL8u8i5tof4amxIkxJ8YoXBGW atwQ== 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:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=oZnmgGByCRadvJUr1rj9l9i+YtASih1Ho9oDuVYicew=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=fRudicEhpX1pTv33hyOwhNBLKsA1f8Qrs0IVLjC63Ed7HdoO/26kTp/1voFCTdK1kt aGrJt4JGtdBvN6qkmzMLw8cwoNmmPJy30icvFQxnogOryo1ZeL8lrGqgca5WDB8vQ8Mg pcW9RSVLGmFFhAHf+m89oLS0As2V0TOVI2I9SzYj/IXOTS4ZTKcoKXqYxd6COo2d0HY3 twLCXT88N5WsjJeQTTgit+EJciqsP1dlOEQZTLRRd0hAPfm8PD//qSqF+xdZNmwmfsQ9 7yae1seT5x5JVK/YhkgTJGr5cRZ81zk2kLRJsKGMJwNxDq9DVPsMv/DAz0ik/yZvHhoA n7mQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=qYeqsALA; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 38308e7fff4ca-2eee191040dsi20060241fa.276.2024.07.16.10.27.01; Tue, 16 Jul 2024 10:27:01 -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=@khirnov.net header.s=mail header.b=qYeqsALA; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C7C9668DAF5; Tue, 16 Jul 2024 20:16:49 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 49E3B68DA94 for ; Tue, 16 Jul 2024 20:16:37 +0300 (EEST) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=qYeqsALA; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 7DD664DF4 for ; Tue, 16 Jul 2024 19:16:33 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id 6M1d5nLiYGiu for ; Tue, 16 Jul 2024 19:16:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1721150187; bh=njpfhvXhJRcoBkER2BiSFbBL1FkurRsjekYRnivFTlY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=qYeqsALAZTC0M3aEjZbOcT+Xe1ZVMs8m9PVJGbklBwiLMooNGrRvZ0n7pqgb6EN8s kPfNyFcXXPXcjN/lRnhcQtCVhq5EWxpctNpaVK5LcQ4sy4YOnpW+AOw/HzKgyEDLv9 e99/lRkKi/dMJuBJxqbAasQHuAPQr4p7kuS18UIzvZmgoxD61KeikbvpcovEFm7/M1 oYA2m1ReOv/UQziTrx89CLET83Jlr95+s6A+2i5pY01qTjmpyEPpdymayBiQkN8sjp OExBAK46an3WPbIdmjVo7Zhbyoaot7I2J9p6kP1ua5NHNbY2W1H9+6XfryG9XPfhXE GQl/mwMdy6iZw== Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id AE6E94DFC for ; Tue, 16 Jul 2024 19:16:27 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id D59163A2B1D for ; Tue, 16 Jul 2024 19:16:20 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Tue, 16 Jul 2024 19:11:30 +0200 Message-ID: <20240716171155.31838-15-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240716171155.31838-1-anton@khirnov.net> References: <20240716171155.31838-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 15/39] lavc/ffv1: always use the main context values of plane_count/transparency 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: rsCI90GX58ne They cannot change between slices. --- libavcodec/ffv1.c | 2 -- libavcodec/ffv1dec.c | 5 ++--- libavcodec/ffv1dec_template.c | 2 +- libavcodec/ffv1enc.c | 2 +- libavcodec/ffv1enc_template.c | 2 +- 5 files changed, 5 insertions(+), 8 deletions(-) diff --git a/libavcodec/ffv1.c b/libavcodec/ffv1.c index 6a0aca6429..06a77c3a26 100644 --- a/libavcodec/ffv1.c +++ b/libavcodec/ffv1.c @@ -56,8 +56,6 @@ av_cold int ff_ffv1_init_slice_state(const FFV1Context *f, FFV1Context *fs) { int j, i; - fs->plane_count = f->plane_count; - fs->transparency = f->transparency; for (j = 0; j < f->plane_count; j++) { PlaneContext *const p = &fs->plane[j]; diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c index 618020d10f..6d3db25279 100644 --- a/libavcodec/ffv1dec.c +++ b/libavcodec/ffv1dec.c @@ -270,7 +270,6 @@ static int decode_slice(AVCodecContext *c, void *arg) if(f->fsrc && !(p->flags & AV_FRAME_FLAG_KEY)) { FFV1Context *fssrc = f->fsrc->slice_context[si]; - av_assert1(fs->plane_count == fssrc->plane_count); if (!(p->flags & AV_FRAME_FLAG_KEY)) fs->slice_damaged |= fssrc->slice_damaged; @@ -330,7 +329,7 @@ static int decode_slice(AVCodecContext *c, void *arg) } av_assert1(width && height); - if (f->colorspace == 0 && (f->chroma_planes || !fs->transparency)) { + if (f->colorspace == 0 && (f->chroma_planes || !f->transparency)) { const int chroma_width = AV_CEIL_RSHIFT(width, f->chroma_h_shift); const int chroma_height = AV_CEIL_RSHIFT(height, f->chroma_v_shift); const int cx = x >> f->chroma_h_shift; @@ -341,7 +340,7 @@ static int decode_slice(AVCodecContext *c, void *arg) decode_plane(f, fs, sc, &gb, p->data[1] + ps*cx+cy*p->linesize[1], chroma_width, chroma_height, p->linesize[1], 1, 1); decode_plane(f, fs, sc, &gb, p->data[2] + ps*cx+cy*p->linesize[2], chroma_width, chroma_height, p->linesize[2], 1, 1); } - if (fs->transparency) + if (f->transparency) decode_plane(f, fs, sc, &gb, p->data[3] + ps*x + y*p->linesize[3], width, height, p->linesize[3], (f->version >= 4 && !f->chroma_planes) ? 1 : 2, 1); } else if (f->colorspace == 0) { decode_plane(f, fs, sc, &gb, p->data[0] + ps*x + y*p->linesize[0] , width, height, p->linesize[0], 0, 2); diff --git a/libavcodec/ffv1dec_template.c b/libavcodec/ffv1dec_template.c index 97a28b085a..d868617de9 100644 --- a/libavcodec/ffv1dec_template.c +++ b/libavcodec/ffv1dec_template.c @@ -140,7 +140,7 @@ static int RENAME(decode_rgb_frame)(FFV1Context *f, int lbd = s->avctx->bits_per_raw_sample <= 8; int bits = s->avctx->bits_per_raw_sample > 0 ? s->avctx->bits_per_raw_sample : 8; int offset = 1 << bits; - int transparency = s->transparency; + int transparency = f->transparency; for (x = 0; x < 4; x++) { sample[x][0] = RENAME(sc->sample_buffer) + x * 2 * (w + 6) + 3; diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c index 714e007659..d334220e13 100644 --- a/libavcodec/ffv1enc.c +++ b/libavcodec/ffv1enc.c @@ -1072,7 +1072,7 @@ retry: ret |= encode_plane(f, fs, sc, p->data[1] + ps*cx+cy*p->linesize[1], chroma_width, chroma_height, p->linesize[1], 1, 1); ret |= encode_plane(f, fs, sc, p->data[2] + ps*cx+cy*p->linesize[2], chroma_width, chroma_height, p->linesize[2], 1, 1); } - if (fs->transparency) + if (f->transparency) ret |= encode_plane(f, fs, sc, p->data[3] + ps*x + y*p->linesize[3], width, height, p->linesize[3], 2, 1); } else if (c->pix_fmt == AV_PIX_FMT_YA8) { ret = encode_plane(f, fs, sc, p->data[0] + ps*x + y*p->linesize[0], width, height, p->linesize[0], 0, 2); diff --git a/libavcodec/ffv1enc_template.c b/libavcodec/ffv1enc_template.c index 4a5580e1a5..0f47a0b424 100644 --- a/libavcodec/ffv1enc_template.c +++ b/libavcodec/ffv1enc_template.c @@ -138,7 +138,7 @@ static int RENAME(encode_rgb_frame)(FFV1Context *f, int packed = !src[1]; int bits = s->bits_per_raw_sample > 0 ? s->bits_per_raw_sample : 8; int offset = 1 << bits; - int transparency = s->transparency; + int transparency = f->transparency; int packed_size = (3 + transparency)*2; sc->run_index = 0;