From patchwork Tue Jul 16 17:11:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 50584 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:40f5:b0:482:c625:d099 with SMTP id lb53csp466848vqb; Tue, 16 Jul 2024 11:14:59 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXbr/Ju3EP0uQUTKPO+YGnGuUTYi54Io2C2TdAVFvOvJvYNYjmN3xV1/BRrx1K0/OwdIhgNt5Zc0CYSvBwFcU3NdQJPZ3/+XmuqlQ== X-Google-Smtp-Source: AGHT+IEfsyx8A/KCTc5RwdQvTGCpd75DHiDhQy2hnG6KayyoRcX4MEz3n9X8mhltw5SiWN3kDjpl X-Received: by 2002:a05:6402:27c6:b0:59f:68e0:fcab with SMTP id 4fb4d7f45d1cf-59f68e10105mr1649264a12.33.1721153699204; Tue, 16 Jul 2024 11:14:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721153699; cv=none; d=google.com; s=arc-20160816; b=g7ScjpWI+4aG/pR1IOdOr+kX2sbkOXMujUs+OiUct/8ZnXYdGSqk4xmPTrVvFcrOGS xlYH51+djWkLFTr/WszPT8JuiTy3v7pPtiERdlaAgZKZ3G7pfjL1cKH4ZAqv1IIrdu64 OnAVDRZe+Uy4qM5Me3t0AWqXki/cbHq3gA/cge8UN0KXs/buvUdLTcFjn6BF1QtFOl6T 4WVR+5HpH/iMaiaIehVjqX4+LXk14IDbgBO4HD0K6hfRzvZJEjFBJDkboIGWd0IoMF9M eY9cXF3zuCx9CgPPPxgNfZW2EwkOUhVM6XPzXFOs1goTpyHzjQ9bW1yvt2ahIPh1udQb hLsw== 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=II7oWydZ1I/Lpx3m6epYJ21Bd9/LhwyKLxKdF8TKUCY=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=PM7CaEIFlpsBDrdOOyqJvNzE3tLxlvVuXTMVMk/rZnIxd5xgVaNYKcUR9R9WhB9bFR fNuPnZ545VmQK98FRe+IP6kV0UR1KqE6P0NWPGpYp9Wj+RHjSR6kqMTBMxZmdGxSqQqh Wv3aUPTHcLL5Pra3OBBgguN36tHDRAev56Lms1C9F0L8ZiCP7dLkQoorOHXcbxvLgJF2 TI/jy3aa2xB/m+rsrGn6pCtm1IItXKrdGMV/v3CiyGcWnFLxNZ7k63vEDP3Tn7u4H9Ne iwwrpE4686YSib0TD4H6kYO/mTAA/7WduBJ+YIdtYw/1wxVciB3opTyOwHsqbz2tlTz6 P8wA==; 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="kCqjpYD/"; 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 4fb4d7f45d1cf-59b26f66263si4014259a12.365.2024.07.16.11.14.58; Tue, 16 Jul 2024 11:14:59 -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="kCqjpYD/"; 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 4914168DB1A; Tue, 16 Jul 2024 21:14:15 +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 845CD68D88A for ; Tue, 16 Jul 2024 21:14:04 +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=kCqjpYD/; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 23F7A4DE6 for ; Tue, 16 Jul 2024 19:16:32 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id mWt5e_RMDTDz for ; Tue, 16 Jul 2024 19:16:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1721150187; bh=D0Njjaajs3DtGw2fXNWC0Zw5V6ekugRhmfTGKDjhHzg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=kCqjpYD/42TH/w5IiJ6DEJXMOv9OIUh3ZRVqqyOWC4Mk4DUBGuRFwAbM4OGfXoiFD Hm1Om+XTPKGz1uuZgaLKBNQsW1tjpxt6WCRMGl8nFpbXZAftEe7FMDXyXumEEb3tvA I2jmDcIkfidYsCyYPuTRJWKzcvicCgiNkWqcos4bj5+Y9LOmiG6lWn2ddpOkYeTBsl S8HoBOsIA2Fd90ekFlRG9QgEvfvO3RNMRa20u9h5ghq+K6UFuTVZK2UXNKDaqNnxe6 pviGqvzRejBcMHqJj/9YWfZJ804rAxna46HdPoU+c8tUh/d5L36LXSKro3QdK5/TqI 2IR3hZxBqLVKQ== 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 655DE4DF1 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 547223A083F 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:19 +0200 Message-ID: <20240716171155.31838-4-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 04/39] lavc/ffv1dec: drop FFV1Context.cur 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: 9tDaQgdZ3f3F It is merely a pointer to FFV1Context.picture.f, which can just as well be used directly. --- libavcodec/ffv1.h | 1 - libavcodec/ffv1dec.c | 33 +++++++++++++++++---------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/libavcodec/ffv1.h b/libavcodec/ffv1.h index acec22e83e..d99367ce81 100644 --- a/libavcodec/ffv1.h +++ b/libavcodec/ffv1.h @@ -89,7 +89,6 @@ typedef struct FFV1Context { ProgressFrame picture, last_picture; struct FFV1Context *fsrc; - AVFrame *cur; const AVFrame *cur_enc_frame; int plane_count; int ac; ///< 1=range coder <-> 0=golomb rice diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c index 7066146477..60d04f04b9 100644 --- a/libavcodec/ffv1dec.c +++ b/libavcodec/ffv1dec.c @@ -163,7 +163,8 @@ static int decode_plane(FFV1Context *s, uint8_t *src, return 0; } -static int decode_slice_header(const FFV1Context *f, FFV1Context *fs) +static int decode_slice_header(const FFV1Context *f, FFV1Context *fs, + AVFrame *frame) { RangeCoder *c = &fs->c; uint8_t state[CONTEXT_SIZE]; @@ -217,23 +218,23 @@ static int decode_slice_header(const FFV1Context *f, FFV1Context *fs) ps = get_symbol(c, state, 0); if (ps == 1) { - f->cur->flags |= AV_FRAME_FLAG_INTERLACED; - f->cur->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST; + frame->flags |= AV_FRAME_FLAG_INTERLACED; + frame->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST; } else if (ps == 2) { - f->cur->flags |= AV_FRAME_FLAG_INTERLACED; - f->cur->flags &= ~AV_FRAME_FLAG_TOP_FIELD_FIRST; + frame->flags |= AV_FRAME_FLAG_INTERLACED; + frame->flags &= ~AV_FRAME_FLAG_TOP_FIELD_FIRST; } else if (ps == 3) { - f->cur->flags &= ~AV_FRAME_FLAG_INTERLACED; + frame->flags &= ~AV_FRAME_FLAG_INTERLACED; } - f->cur->sample_aspect_ratio.num = get_symbol(c, state, 0); - f->cur->sample_aspect_ratio.den = get_symbol(c, state, 0); + frame->sample_aspect_ratio.num = get_symbol(c, state, 0); + frame->sample_aspect_ratio.den = get_symbol(c, state, 0); if (av_image_check_sar(f->width, f->height, - f->cur->sample_aspect_ratio) < 0) { + frame->sample_aspect_ratio) < 0) { av_log(f->avctx, AV_LOG_WARNING, "ignoring invalid SAR: %u/%u\n", - f->cur->sample_aspect_ratio.num, - f->cur->sample_aspect_ratio.den); - f->cur->sample_aspect_ratio = (AVRational){ 0, 1 }; + frame->sample_aspect_ratio.num, + frame->sample_aspect_ratio.den); + frame->sample_aspect_ratio = (AVRational){ 0, 1 }; } if (fs->version > 3) { @@ -258,7 +259,7 @@ static int decode_slice(AVCodecContext *c, void *arg) FFV1Context *f = fs->avctx->priv_data; int width, height, x, y, ret; const int ps = av_pix_fmt_desc_get(c->pix_fmt)->comp[0].step; - AVFrame * const p = f->cur; + AVFrame * const p = f->picture.f; const int si = (FFV1Context**)arg - f->slice_context; if (f->fsrc && !(p->flags & AV_FRAME_FLAG_KEY) && f->last_picture.f) @@ -299,7 +300,7 @@ static int decode_slice(AVCodecContext *c, void *arg) if (f->version > 2) { if (ff_ffv1_init_slice_state(f, fs) < 0) return AVERROR(ENOMEM); - if (decode_slice_header(f, fs) < 0) { + if (decode_slice_header(f, fs, p) < 0) { fs->slice_x = fs->slice_y = fs->slice_height = fs->slice_width = 0; fs->slice_damaged = 1; return AVERROR_INVALIDDATA; @@ -307,7 +308,7 @@ static int decode_slice(AVCodecContext *c, void *arg) } if ((ret = ff_ffv1_init_slice_state(f, fs)) < 0) return ret; - if ((f->cur->flags & AV_FRAME_FLAG_KEY) || fs->slice_reset_contexts) { + if ((p->flags & AV_FRAME_FLAG_KEY) || fs->slice_reset_contexts) { ff_ffv1_clear_slice_state(f, fs); } else if (fs->slice_damaged) { return AVERROR_INVALIDDATA; @@ -920,7 +921,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *rframe, if (ret < 0) return ret; - f->cur = p = f->picture.f; + p = f->picture.f; p->pict_type = AV_PICTURE_TYPE_I; //FIXME I vs. P p->flags = (p->flags & ~AV_FRAME_FLAG_KEY) | key_frame;