From patchwork Thu May 21 02:36:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 19789 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 ECE18448A5C for ; Thu, 21 May 2020 05:37:35 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D6B2768AA7F; Thu, 21 May 2020 05:37:35 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4429168AB96 for ; Thu, 21 May 2020 05:37:29 +0300 (EEST) Received: by mail-wm1-f65.google.com with SMTP id z72so4876321wmc.2 for ; Wed, 20 May 2020 19:37:29 -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=kbe/ZkT+aoGXLKT//OZupuoJmo+gYH+Pl2ayNmksC/E=; b=IZAfbShm94KCAVYrhcYdVcje+tdcDH3ra+ylylPh7c2SykyUKwapqKSif2RJ+Y2YOi nI0Pm/h2GVoWgMk0BNfci1UZVm7KdkpFWguidsxuEvFzwgaTUNFnldyO/+mKlklnJZSi GMZbC1w+hMZ9AJz+74UfWYpmC78NrOlOIrm65wTdqFIrfqEex+hGTJRDErxvQd7RbqWC IxuM3anDiT97YJO5RYMtw4T6nL3p4sAnciDyUL7EBhARdam6m2PV5HgmA3Q4J+PuD08D TlF9R6yTQpd50ErZIy13SHwx1uZxC5JisWA13pOINenfd3yLwpWi6EaDBZtO1KqqGcVl GavQ== 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=kbe/ZkT+aoGXLKT//OZupuoJmo+gYH+Pl2ayNmksC/E=; b=EopnALuOzcsqS8l+2NC4zocYf0VCsXFqEuBypfgyPRfKX+fQe9roT8YSu7vGoTH9e6 8EtA6x/rsyS8lQgI1pA4BICyaMzohvYyhtnVSCAIRL9XJeSCSKq949k/PQERWtVi1rOP 65oR6Qx/BhrP/8pRHZGBRd6CqGfnu5u1gqB5hz4d6PI9lgsLD2ulvunWY8LJtY3uMeKN NZX2d6EcYskQOcRW/Wv70b5JiQK4QiwGDndvdiTyoK7zJmxPAOxmpv5GD6T/Iu2hNp71 FTufmfxQ+mWsudoIx7CpmmSaVRC8Y8frRuEZpG0r7lEwC5XPRrXqumpMJynxWzwHrQqi fzNw== X-Gm-Message-State: AOAM533BalK75Dyl1vGQO+oKZMRhWLnlgfopV/AxGkNVHon9GjHtLfvr ZJU47zoMXLz5nFzbkVbdVWvX5pbQ X-Google-Smtp-Source: ABdhPJx1ArWgC+Bt8C6ZDK/VpTdmZSFjxM9OFgfQNn5wTEI3Csg5BwXKIP4You8W/xPNM8Xo6wH+fA== X-Received: by 2002:a1c:b4d4:: with SMTP id d203mr6959499wmf.188.1590028648470; Wed, 20 May 2020 19:37:28 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id w15sm4654073wrl.73.2020.05.20.19.37.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 May 2020 19:37:27 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Thu, 21 May 2020 04:36:46 +0200 Message-Id: <20200521023647.27847-2-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200521023647.27847-1-andreas.rheinhardt@gmail.com> References: <20200521023647.27847-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/3] avformat/ttaenc: Defer freeing dynamic buffer 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" The TTA muxer writes a seektable in a dynamic buffer as it receives packets and when writing the trailer, closes the dynamic buffer using avio_close_dyn_buf(), writes the seektable and frees the buffer. But the TTA muxer already has a deinit function which unconditionally calls ffio_free_dyn_buf() on the dynamic buffer, so switching to avio_get_dyn_buf() means that one can remove the code to free the buffer; furthermore, it also might save an allocation if the seektable is so small that it fits into the dynamic buffer's write buffer or if adding the padding that avio_close_dyn_buf() adds necessitated reallocating of the underlying buffer. Signed-off-by: Andreas Rheinhardt --- libavformat/ttaenc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libavformat/ttaenc.c b/libavformat/ttaenc.c index 4860aab4c1..becd3e7153 100644 --- a/libavformat/ttaenc.c +++ b/libavformat/ttaenc.c @@ -145,10 +145,8 @@ static int tta_write_trailer(AVFormatContext *s) /* Write Seek table */ crc = ffio_get_checksum(tta->seek_table) ^ UINT32_MAX; avio_wl32(tta->seek_table, crc); - size = avio_close_dyn_buf(tta->seek_table, &ptr); + size = avio_get_dyn_buf(tta->seek_table, &ptr); avio_write(s->pb, ptr, size); - tta->seek_table = NULL; - av_free(ptr); /* Write audio data */ tta_queue_flush(s);