From patchwork Sat Apr 11 21:19:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 18878 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 5956644A8DB for ; Sun, 12 Apr 2020 00:20:41 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 419D068B87E; Sun, 12 Apr 2020 00:20:41 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4C42268B868 for ; Sun, 12 Apr 2020 00:20:33 +0300 (EEST) Received: by mail-wm1-f66.google.com with SMTP id x4so5827023wmj.1 for ; Sat, 11 Apr 2020 14:20:33 -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=BVYIQQjzpqopRI/rek5FoyKvrcDSVADJsfgPsNO9jXo=; b=TaXUyInLo6C/XW2gGHncRVSg6dIR9wnBimxBeNV49gl8D26Zro5S68HTy+TuSIGdzp Z2rVK2gEs+x0pmoVRb8qHUlScErviYdr63rBvhOLxrwU4G+TpDCXGJYuNyQ44/OfbfwP m8GJ/oVk8zlBqeh6QhiZpyO0Zlfb0a7IR66U1Co9xdomw0XY/HBDmkiHjytuX7+lnjST lhh7NYpGFIdNCE+DraCzkmYwds3M7iq3eJ7WSDIad5XWXwQyqdAXEvfP7mWZuj+3uNM6 Hi78EozjV+CmZL+M3n+ARcMPJgpeFkX+5p0fj/HnumygmQ9zuadObxi1vRlU09dqzhzw rn8g== 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=BVYIQQjzpqopRI/rek5FoyKvrcDSVADJsfgPsNO9jXo=; b=eurwSGUS8/mbttQlYNXgjM1radUhda1HFsQGQqFU6gF8a//zcmwFUnPiymctuJzE4U uWxFUS7+fO1NK7r9tw5I0cTz84B8/SxmeqLgiI0v2LZBTPZCVg0XU3Em9rl1KVx2z/cF 3DS1pn7KQ+ivlrPbJQCfKu0XKfOuZWmO/bpGtX8iGsj28DObE99IVeMf2OgagLOO+uQb 4LdibI4873CQMGv+I+hv3BEL9rwUTDVQRwsh37c68tWFmVFLXPMiOtIJbmjitCZAW1iO UUpiIOym4vqHhYmoXood2XZBJTWK43aDkFIMc4ntJLchTLPPhu0/zuI+FkoIGovavTSb SXNw== X-Gm-Message-State: AGi0PuaOQgxBPZk3n5tc4hgvy5RFcMKYk3cwKDlfLLohGWKQVjw+ZKIM X48JhMNCfTOOZ+EG2BKDVTPb7Qq8 X-Google-Smtp-Source: APiQypLT0yR3Cw804E+dwFh+ZVOE5WulBp4okLQdNGVVIg799Eta9HlIU8W87tGT9R+PStTeTU3zYA== X-Received: by 2002:a7b:ce88:: with SMTP id q8mr12168617wmj.161.1586640032242; Sat, 11 Apr 2020 14:20:32 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id h2sm7820650wmb.16.2020.04.11.14.20.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Apr 2020 14:20:31 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sat, 11 Apr 2020 23:19:53 +0200 Message-Id: <20200411211955.20843-4-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200411211955.20843-1-andreas.rheinhardt@gmail.com> References: <20200411211955.20843-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 4/6] avformat/mux: Remove redundant resetting 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" Now that ff_interleave_add_packet() always returns blank packets, the input packet to ff_interleave_packet_per_dts() will always be blank on return as well (if supplied) and the same goes for interleave_packet() in mux.c. Document these facts and remove the redundant resetting that happened in av_interleaved_write_frame(). The last reference to the (long removed) destruct field that AVPackets once had has been removed as well when updating the documentation of ff_interleave_packet_per_dts(). Signed-off-by: Andreas Rheinhardt --- libavformat/internal.h | 11 ++++------- libavformat/mux.c | 9 +++------ 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/libavformat/internal.h b/libavformat/internal.h index e9d7d6754a..2cb5964720 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -495,15 +495,12 @@ int ff_framehash_write_header(AVFormatContext *s); int ff_read_packet(AVFormatContext *s, AVPacket *pkt); /** - * Interleave a packet per dts in an output media file. + * Interleave an AVPacket per dts so it can be muxed. * - * Packets with pkt->destruct == av_destruct_packet will be freed inside this - * function, so they cannot be used after it. Note that calling av_packet_unref() - * on them is still safe. - * - * @param s media file handle + * @param s an AVFormatContext for output. in resp. out will be added to + * resp. taken from its packet buffer. * @param out the interleaved packet will be output here - * @param pkt the input packet + * @param pkt the input packet; will be blank on return if not NULL * @param flush 1 if no further packets are available as input and all * remaining packets should be output * @return 1 if a packet was output, 0 if no packet could be output, diff --git a/libavformat/mux.c b/libavformat/mux.c index f61dbd3c89..cae9f42d11 100644 --- a/libavformat/mux.c +++ b/libavformat/mux.c @@ -1159,7 +1159,7 @@ int ff_interleaved_peek(AVFormatContext *s, int stream, /** * Interleave an AVPacket correctly so it can be muxed. * @param out the interleaved packet will be output here - * @param in the input packet + * @param in the input packet; will always be blank on return if not NULL * @param flush 1 if no further packets are available as input and all * remaining packets should be output * @return 1 if a packet was output, 0 if no packet could be output, @@ -1214,14 +1214,11 @@ int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt) for (;; ) { AVPacket opkt; int ret = interleave_packet(s, &opkt, pkt, flush); - if (pkt) { - memset(pkt, 0, sizeof(*pkt)); - av_init_packet(pkt); - pkt = NULL; - } if (ret <= 0) return ret; + pkt = NULL; + ret = write_packet(s, &opkt); av_packet_unref(&opkt);