From patchwork Thu Nov 17 10:16:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 39312 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:999a:b0:a4:2148:650a with SMTP id ve26csp997262pzb; Thu, 17 Nov 2022 02:17:11 -0800 (PST) X-Google-Smtp-Source: AA0mqf42DkAK5mWIfA5ZULonWqVRfOurikHWk+FA3mYCNxyAYzeSCOSswHhCDHEJEh0IPUNjrsgZ X-Received: by 2002:a17:906:3096:b0:7ae:eae9:25a5 with SMTP id 22-20020a170906309600b007aeeae925a5mr1568256ejv.394.1668680231649; Thu, 17 Nov 2022 02:17:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668680231; cv=none; d=google.com; s=arc-20160816; b=FricKpyF27NA+cnQJUBHyJ3GwBqgmEP7Q9rfLjtXjBj2oaPqSQHyV40nmlrY/m0nBA Wzikum2A5HNCmEcBbzNRVVUE4JHpdiWFXdiUu/fwhVTCby3MsLWWnsYMMcOu5anI7IQz F3fTjLsVgQ0bIXh8M58vubecG5X6FjdTcRFydb2Kh2sy2DSGv91yVjp7ytohzJYhTnFo 73CzF5aC2xx6kmNKvQRGW+QhG5h5wh4h9X+G1Q+qVqUmB+9dVbo6rMnsQ/HfBROWka3a a24ljxPXIm/kBgx8QXfKY+4E2emAf5GuUs1ujhKSTG4Yun56Kn0SvKCFeobcblmKjGNN Ut9A== 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:message-id:date:to:from :delivered-to; bh=8g3nkLYkCsjasWkU8VbyUIExlohjtjfcXGzauMfe+i4=; b=u1cWon9xyTp3rbg7b4g468x5wUXtFLmCr+fs7fkJTreGjog4a8lStcccxgRjHq6yNn GOw83DfdqPBE8Aego5u6zy6O8O85JJndYGVZOQsC8Z88A40t/fMe6RmV6urww8FxLZdO ET1H60EFVvTlIDX+cXy02d1WZg5kuqcLKM7Jczmx3XceQ1L+scHb16U5i2DgtZbA5S7p FRUwNq6Ee3osg+cIka4fGCXd0vjWnU36+CzIT/+jLpFWwi5+U5DcyFxZ8zLHon3zdqsa oNKya+x2R6iZsZNP7Sxo09lXhEAkNcFyHPnaxBhKZhMOZ2rB7ows+UgoZOq3Lu9SWvyr UsKA== ARC-Authentication-Results: i=1; mx.google.com; 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 x14-20020a05640226ce00b00459dc4e4b7fsi530948edd.143.2022.11.17.02.17.10; Thu, 17 Nov 2022 02:17:11 -0800 (PST) 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; 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 A849568BD2B; Thu, 17 Nov 2022 12:16:53 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1FAB168BA62 for ; Thu, 17 Nov 2022 12:16:45 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id D710A240591 for ; Thu, 17 Nov 2022 11:16:44 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id N9a8i2IsGVHz for ; Thu, 17 Nov 2022 11:16:44 +0100 (CET) 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 mail0.khirnov.net (Postfix) with ESMTPS id 47E132404F8 for ; Thu, 17 Nov 2022 11:16:43 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id E8D653A01E5 for ; Thu, 17 Nov 2022 11:16:42 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Thu, 17 Nov 2022 11:16:31 +0100 Message-Id: <20221117101640.6789-1-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 01/10] fftools/ffmpeg: move freeing an input stream into a separate function 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: SKtBLf/DXPgo --- fftools/ffmpeg.c | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index dfdfad3ce4..25155e155e 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -502,6 +502,28 @@ static int decode_interrupt_cb(void *ctx) const AVIOInterruptCB int_cb = { decode_interrupt_cb, NULL }; +static void ist_free(InputStream **pist) +{ + InputStream *ist = *pist; + + if (!ist) + return; + + av_frame_free(&ist->decoded_frame); + av_packet_free(&ist->pkt); + av_dict_free(&ist->decoder_opts); + avsubtitle_free(&ist->prev_sub.subtitle); + av_frame_free(&ist->sub2video.frame); + av_freep(&ist->filters); + av_freep(&ist->hwaccel_device); + av_freep(&ist->dts_buffer); + + avcodec_free_context(&ist->dec_ctx); + avcodec_parameters_free(&ist->par); + + av_freep(pist); +} + static void ffmpeg_cleanup(int ret) { int i, j; @@ -558,23 +580,8 @@ static void ffmpeg_cleanup(int ret) for (i = 0; i < nb_input_files; i++) ifile_close(&input_files[i]); - for (i = 0; i < nb_input_streams; i++) { - InputStream *ist = input_streams[i]; - - av_frame_free(&ist->decoded_frame); - av_packet_free(&ist->pkt); - av_dict_free(&ist->decoder_opts); - avsubtitle_free(&ist->prev_sub.subtitle); - av_frame_free(&ist->sub2video.frame); - av_freep(&ist->filters); - av_freep(&ist->hwaccel_device); - av_freep(&ist->dts_buffer); - - avcodec_free_context(&ist->dec_ctx); - avcodec_parameters_free(&ist->par); - - av_freep(&input_streams[i]); - } + for (i = 0; i < nb_input_streams; i++) + ist_free(&input_streams[i]); if (vstats_file) { if (fclose(vstats_file))