From patchwork Sat Sep 28 02:42:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 15358 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 2E2E3448ABC for ; Sat, 28 Sep 2019 05:42:39 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1A38368A581; Sat, 28 Sep 2019 05:42:39 +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 B3B1B689884 for ; Sat, 28 Sep 2019 05:42:32 +0300 (EEST) Received: by mail-wm1-f66.google.com with SMTP id 3so7303250wmi.3 for ; Fri, 27 Sep 2019 19:42:32 -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=mrIuY/bgUcmizLQbgz+nNW5+P28LHt0yosG/P2NjnHg=; b=OKZe9m4tZeHcT5tv1NuGdVfX0+O+EctQwnjP0spz3ltivkk8efCUWL2thYnc8BRU6t 11i750UjF4GGIBnc2sceslNb4Wn6w2wijp3v/35/TQ9rZtWDyjF3mj8WZhO4ApdLD0vA r1F6PArUUMRuMz5beXUFl0dJloNK/uRT6eFAKZT59BTK0P/upjyc0eSmDreSzlmLOaBy CRmq9WVVh8VXs5X6lObfvhuiYfxaJ9+zzCCZOWBSF9MKOy027PTRSSV9JxqvM6TMMjf/ U3ONZT8+uqaBYd/9GXstW0sPImqRANdIpgoVtI3dWLPb9HYi24advmbzQ3MdRjB+FI7s kZqg== 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=mrIuY/bgUcmizLQbgz+nNW5+P28LHt0yosG/P2NjnHg=; b=h6v40A5AlIl+faj4kjKXl8zA2ImTLRCH1GdGzf2Ixww2T0Q2YI5eFHQ43FnZfC0RjC FOC9L3p0R+uVmId84VQ8rUA8k4eRMokut86wBU7B5Rqgkvex/nA0wteIQstJ5qW/uIwd LWnI1wt3YwbhiiwE0J4CMq6kwMe9VDfE31EYmRakrKcEg+rrHkChtM1D2T31UqqlarSf tRgqQ/kUK0fFyVYlk9G4YE5hXEB8nfKQ4ID56TndL4fBd7swz+JZRIOgjO/Wi0h1teT4 VX0er4uMfrohB5DkTWV8ifQfJyEWRE5T2AEP0S2hKSgE1EAZ8eWHOsa/E1i9RNKclx5A UKfA== X-Gm-Message-State: APjAAAUgoFnjmnK4FWVlJXNbfIJYxComfDnqHeNTjSYtDzYfBb4UUHRA C37Epl/X0jRnkY8uoEwDpTaz6nsg X-Google-Smtp-Source: APXvYqwRNTj98ZNvsvRM+YrBCt00aI4bXF1WhOlu7yOPl+oAElglIFc0OVJdKsGNh3E7vWXAmM8CwA== X-Received: by 2002:a1c:4d0e:: with SMTP id o14mr871563wmh.172.1569638552138; Fri, 27 Sep 2019 19:42:32 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc0f857.dynamic.kabel-deutschland.de. [188.192.248.87]) by smtp.gmail.com with ESMTPSA id u11sm6638659wmd.32.2019.09.27.19.42.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Sep 2019 19:42:31 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sat, 28 Sep 2019 04:42:24 +0200 Message-Id: <20190928024224.21707-1-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190920203916.16904-7-andreas.rheinhardt@gmail.com> References: <20190920203916.16904-7-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v5] avformat/utils: Don't create unnecessary references 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" When AVFMT_FLAG_GENPTS is set, av_read_frame would put a reference to a packet in the packet list (via av_packet_ref) and then immediately thereafter unreference the original packet. This has been changed to move the reference instead. Signed-off-by: Andreas Rheinhardt --- Updated the commit message in light of the fact that ff_packet_list_put now ensures that the packets are refcounted. libavformat/utils.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libavformat/utils.c b/libavformat/utils.c index 1292fef3df..fe40ead438 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -1858,10 +1858,11 @@ int av_read_frame(AVFormatContext *s, AVPacket *pkt) ret = ff_packet_list_put(&s->internal->packet_buffer, &s->internal->packet_buffer_end, - pkt, FF_PACKETLIST_FLAG_REF_PACKET); - av_packet_unref(pkt); - if (ret < 0) + pkt, 0); + if (ret < 0) { + av_packet_unref(pkt); return ret; + } } return_packet: