From patchwork Sun Sep 13 02:57:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 22318 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 C4AF1449E91 for ; Sun, 13 Sep 2020 05:58:35 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id AEC2968BBE5; Sun, 13 Sep 2020 05:58:35 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 21EE568BBBA for ; Sun, 13 Sep 2020 05:58:28 +0300 (EEST) Received: by mail-wr1-f67.google.com with SMTP id g4so15072205wrs.5 for ; Sat, 12 Sep 2020 19:58:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bRBiQ76UI9vfxdsTPwHlamClIFRF7OH/vWRi8yiV7nE=; b=piYIJ0WHLOoAFenDlvOnYbkODB1yz+sNbRS57uH+KXRyEPyC3eFpalEPpWl7MxOEfR OwWbxbsHrTzMSxyDGWhqKKXjkXe876kwo5B5+xU4Qz+Wq55Mo3+wrknrDBEJaeZYskMy mJsYyZ9Jy41xPizktLflnP5GXYpOs+F4Jikf69798cfe5NTjQdbnP974dYYeOBVtqQhn bBIOVfy00rSHTkxnZralS83sgx7Gzi0jhR7U2zFVXRtyrodSuPqAepr7cxmBeIiYHT3L pJTp1k0H/T/HD2UQxYpzSX0E4Cnt/sWRYgHkGi+kCiG+lQ1eu6oU+hAgDPjNi2hEBxWv PR6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=bRBiQ76UI9vfxdsTPwHlamClIFRF7OH/vWRi8yiV7nE=; b=qxWeWhPlr2N+2eZd/gYwDS9Ngj6xO72VbtjcLCQksHxrT8WhAq4iaoN3zWiHLk04ZX mYbU1PfRyWdJ6lW7NGqg4ZKQT7mpZUfSliZG1pmSJtWYp2yB50sJobrVKP6oWrk61g/I l9GmYjQH88vjyzaA4sxEQVuaYXxFmTp4YhinrQhPs/2Ei4w1xg+zaq1yXM3TwfGUMt2j 6YSNAWGwftD1uYdEmewcxAj7ilE43wnVGlkUl0IUIGIwpNeaSaJjmkFR79vYHPNiF0Vf /z1x0sKhqGvRZkluzbREwjQPLODwgd5qHrwU9DxeIRMb98yluIdEa5NTCSbUs7a+NgpC eRuQ== X-Gm-Message-State: AOAM531S0FTx8JTCZLcXY5sNKHe4CoPCn6niXLcUQhxyGbrQw4Ux3tNk G9wmKzF+A09Qy+32Aq/R5ZyOmw87irs= X-Google-Smtp-Source: ABdhPJyhAxW3PIL4oNh6nYy6N04aiBQe0RGkW4zVbkQGHk1876UMF5b+xMfOVZSPe9BJ/E4PYr1+1w== X-Received: by 2002:a5d:4a0c:: with SMTP id m12mr9258961wrq.83.1599965908219; Sat, 12 Sep 2020 19:58:28 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1fb0f.dynamic.kabel-deutschland.de. [188.193.251.15]) by smtp.gmail.com with ESMTPSA id f3sm11883355wmb.35.2020.09.12.19.58.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Sep 2020 19:58:27 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 13 Sep 2020 04:57:47 +0200 Message-Id: <20200913025753.274772-10-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> References: <20200913025753.274772-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 10/16] avcodec/svq3: Avoid allocations for SVQ3Frames 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 Cc: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" These frames can be made part of the SVQ3Context; notice that the pointers to the frames have been retained in order to allow to just swap them as the code already does. Signed-off-by: Andreas Rheinhardt --- libavcodec/svq3.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/libavcodec/svq3.c b/libavcodec/svq3.c index c8db08a32f..8a67836827 100644 --- a/libavcodec/svq3.c +++ b/libavcodec/svq3.c @@ -147,6 +147,7 @@ typedef struct SVQ3Context { DECLARE_ALIGNED(8, uint8_t, non_zero_count_cache)[15 * 8]; uint32_t dequant4_coeff[QP_MAX_NUM + 1][16]; int block_offset[2 * (16 * 3)]; + SVQ3Frame frames[3]; } SVQ3Context; #define FULLPEL_MODE 1 @@ -1135,13 +1136,9 @@ static av_cold int svq3_decode_init(AVCodecContext *avctx) int marker_found = 0; int ret; - s->cur_pic = av_mallocz(sizeof(*s->cur_pic)); - s->last_pic = av_mallocz(sizeof(*s->last_pic)); - s->next_pic = av_mallocz(sizeof(*s->next_pic)); - if (!s->next_pic || !s->last_pic || !s->cur_pic) { - ret = AVERROR(ENOMEM); - goto fail; - } + s->cur_pic = &s->frames[0]; + s->last_pic = &s->frames[1]; + s->next_pic = &s->frames[2]; s->cur_pic->f = av_frame_alloc(); s->last_pic->f = av_frame_alloc(); @@ -1631,9 +1628,6 @@ static av_cold int svq3_decode_end(AVCodecContext *avctx) av_frame_free(&s->cur_pic->f); av_frame_free(&s->next_pic->f); av_frame_free(&s->last_pic->f); - av_freep(&s->cur_pic); - av_freep(&s->next_pic); - av_freep(&s->last_pic); av_freep(&s->slice_buf); av_freep(&s->intra4x4_pred_mode); av_freep(&s->edge_emu_buffer);