From patchwork Thu Dec 10 11:16:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 24472 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 8BC5644AF7C for ; Thu, 10 Dec 2020 13:18:53 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6DBE7689C68; Thu, 10 Dec 2020 13:18:53 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 104F16881C3 for ; Thu, 10 Dec 2020 13:18:47 +0200 (EET) Received: by mail-wr1-f68.google.com with SMTP id c5so1439085wrp.6 for ; Thu, 10 Dec 2020 03:18:47 -0800 (PST) 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:reply-to :mime-version:content-transfer-encoding; bh=EuMqLaTYCCEyf6m+VpUfNjngRf0mbaDZugkFqGzpLVc=; b=Ot5KzWGh1RYrUFJOcMO2fry+if4q/lkFiKyT/ZUDdp2uvKcFbopzAV6l06pAw88Nns ISNa/kGNWBwKsk/jz0TmclvEj3vxlOFeM78p4+/1Ylv0ZPXUYJ9k0vQB2O1HCRRlNTF7 ttGM67ymbPNFI1VbVzNcRkai5l5vzRzAkrHBSjnl6BnBYHoElWgtp0o6KCkcBVXPd6uo cTLzNuueD6nOEXW1JnzjYEgLxaWiDATF8bpk/wxLOgth/PSE/iz+PT2gDW7EpkGi6gl3 mxH2Iea3RaRL2YL+upzsBFpKrS+ue/w4X1lo3WDndg+HOztcxktiW1XlOXS1T8menr8V 1Reg== 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:reply-to:mime-version:content-transfer-encoding; bh=EuMqLaTYCCEyf6m+VpUfNjngRf0mbaDZugkFqGzpLVc=; b=MvW0PVWILtxofzVdn39ewDCiA2jb1+Ht3+12QYZD0W6HPtPQgo8Dqmt7ahoRKYHYFA Vzruqq0JfK7QxkpOwdDeKEBWtyuUwpwT+qj/YSISXySZf8uCaShplo0Vn9fnfKromd50 96wmP8vDVniFDKveqClCuUEO1HCfcub8N5IPthsB7IklwqmrmIhMCDRmaKp+MBlmscgA 2RukumEVyPPRzhchN7aRh0gocQGZhbJQ6crNOOm6dd/AlkvkBEoTTRT7XMrNCoioMs2S VQX8hacocVIFFHT6YTdu63Lqpi6a9XDftIFNTnY/bIZHEaii5hzlIooVHeRpYGs43dgX TdNg== X-Gm-Message-State: AOAM532S4RlpCystRVFBA5HQaNN9WGaP6gKKIAS30J1SSHdjHWa+hJEr h9W3BbdlsSItlOt6XM2VF+Br4n3QoD6llg== X-Google-Smtp-Source: ABdhPJz9FzHURFgCw2/PUm1vjCvUcCMSTTv3dZ17gMJ6FvIKRjo6gowScPyVMBANZCGdh74RATQcTA== X-Received: by 2002:adf:d081:: with SMTP id y1mr7699369wrh.388.1607599126138; Thu, 10 Dec 2020 03:18:46 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc1aa4b.dynamic.kabel-deutschland.de. [188.193.170.75]) by smtp.gmail.com with ESMTPSA id s133sm8942330wmf.38.2020.12.10.03.18.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Dec 2020 03:18:45 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Thu, 10 Dec 2020 12:16:19 +0100 Message-Id: <20201210111657.2276739-2-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201210111657.2276739-1-andreas.rheinhardt@gmail.com> References: <20201210111657.2276739-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 01/39] avcodec/rl: Remove nonstatic storage of RL tables 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" ff_rl_free() was added in 324e50ee95929a9491b855c5e15451145bd5d1ec, but never used; nonstatic storage was not used long before that. Signed-off-by: Andreas Rheinhardt --- The test for whether a RLTable has already been initialized will be removed once all callers are behind ff_thread_once() (same for INIT_VLC_RL). This will happen soon. libavcodec/rl.c | 50 ++++++++----------------------------------------- libavcodec/rl.h | 11 +++-------- 2 files changed, 11 insertions(+), 50 deletions(-) diff --git a/libavcodec/rl.c b/libavcodec/rl.c index 6eac306b88..c532b5bf56 100644 --- a/libavcodec/rl.c +++ b/libavcodec/rl.c @@ -25,27 +25,16 @@ #include "rl.h" -void ff_rl_free(RLTable *rl) -{ - int i; - - for (i = 0; i < 2; i++) { - av_freep(&rl->max_run[i]); - av_freep(&rl->max_level[i]); - av_freep(&rl->index_run[i]); - } -} - -av_cold int ff_rl_init(RLTable *rl, - uint8_t static_store[2][2 * MAX_RUN + MAX_LEVEL + 3]) +av_cold void ff_rl_init(RLTable *rl, + uint8_t static_store[2][2 * MAX_RUN + MAX_LEVEL + 3]) { int8_t max_level[MAX_RUN + 1], max_run[MAX_LEVEL + 1]; uint8_t index_run[MAX_RUN + 1]; int last, run, level, start, end, i; - /* If table is static, we can quit if rl->max_level[0] is not NULL */ - if (static_store && rl->max_level[0]) - return 0; + /* If rl->max_level[0] is set, this RLTable has already been initialized */ + if (rl->max_level[0]) + return; /* compute max_level[], max_run[] and index_run[] */ for (last = 0; last < 2; last++) { @@ -70,36 +59,13 @@ av_cold int ff_rl_init(RLTable *rl, if (run > max_run[level]) max_run[level] = run; } - if (static_store) - rl->max_level[last] = static_store[last]; - else { - rl->max_level[last] = av_malloc(MAX_RUN + 1); - if (!rl->max_level[last]) - goto fail; - } + rl->max_level[last] = static_store[last]; memcpy(rl->max_level[last], max_level, MAX_RUN + 1); - if (static_store) - rl->max_run[last] = static_store[last] + MAX_RUN + 1; - else { - rl->max_run[last] = av_malloc(MAX_LEVEL + 1); - if (!rl->max_run[last]) - goto fail; - } + rl->max_run[last] = static_store[last] + MAX_RUN + 1; memcpy(rl->max_run[last], max_run, MAX_LEVEL + 1); - if (static_store) - rl->index_run[last] = static_store[last] + MAX_RUN + MAX_LEVEL + 2; - else { - rl->index_run[last] = av_malloc(MAX_RUN + 1); - if (!rl->index_run[last]) - goto fail; - } + rl->index_run[last] = static_store[last] + MAX_RUN + MAX_LEVEL + 2; memcpy(rl->index_run[last], index_run, MAX_RUN + 1); } - return 0; - -fail: - ff_rl_free(rl); - return AVERROR(ENOMEM); } av_cold void ff_rl_init_vlc(RLTable *rl, unsigned static_size) diff --git a/libavcodec/rl.h b/libavcodec/rl.h index 9a767bc5fd..a83debccf7 100644 --- a/libavcodec/rl.h +++ b/libavcodec/rl.h @@ -49,17 +49,12 @@ typedef struct RLTable { } RLTable; /** - * @param static_store static uint8_t array[2][2*MAX_RUN + MAX_LEVEL + 3] which will hold - * the level and run tables, if this is NULL av_malloc() will be used + * @param static_store static uint8_t array[2][2*MAX_RUN + MAX_LEVEL + 3] + * to hold the level and run tables. */ -int ff_rl_init(RLTable *rl, uint8_t static_store[2][2*MAX_RUN + MAX_LEVEL + 3]); +void ff_rl_init(RLTable *rl, uint8_t static_store[2][2*MAX_RUN + MAX_LEVEL + 3]); void ff_rl_init_vlc(RLTable *rl, unsigned static_size); -/** - * Free the contents of a dynamically allocated table. - */ -void ff_rl_free(RLTable *rl); - #define INIT_VLC_RL(rl, static_size)\ {\ int q;\