From patchwork Thu Jan 16 00:20:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 17377 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 E317B44B7CD for ; Thu, 16 Jan 2020 02:20:35 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id CCFA568AE76; Thu, 16 Jan 2020 02:20:35 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2FF3568816F for ; Thu, 16 Jan 2020 02:20:28 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 162DAE3EF3; Thu, 16 Jan 2020 01:20:28 +0100 (CET) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ZY2vBkmN1iAf; Thu, 16 Jan 2020 01:20:26 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 4B5A5E3EF0; Thu, 16 Jan 2020 01:20:26 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Thu, 16 Jan 2020 01:20:15 +0100 Message-Id: <20200116002016.4528-3-cus@passwd.hu> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20200116002016.4528-1-cus@passwd.hu> References: <20200116002016.4528-1-cus@passwd.hu> Subject: [FFmpeg-devel] [PATCH 3/4] avformat/udp: increase the default buffer size of a receiving socket to 384K 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: Marton Balint MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" It is a common mistake that people only increase fifo_size when they experience drops, unfortunately this does not help for higher bitrate (> 100 Mbps) streams when the reader thread simply might not receive the packets in time (especially under high CPU load) if the default 64 KB of kernel buffer size is used. New default is determined so that common linux systems can set this buffer size without tuning kernel parameters. Signed-off-by: Marton Balint --- doc/protocols.texi | 2 +- libavformat/udp.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/protocols.texi b/doc/protocols.texi index d2935fc666..5e8c97d164 100644 --- a/doc/protocols.texi +++ b/doc/protocols.texi @@ -1653,7 +1653,7 @@ The list of supported options follows. @item buffer_size=@var{size} Set the UDP maximum socket buffer size in bytes. This is used to set either the receive or send buffer size, depending on what the socket is used for. -Default is 64KB. See also @var{fifo_size}. +Default is 32 KB for output, 384 KB for input. See also @var{fifo_size}. @item bitrate=@var{bitrate} If set to nonzero, the output will have the specified constant bitrate if the diff --git a/libavformat/udp.c b/libavformat/udp.c index c92fcc49a1..11af9b2500 100644 --- a/libavformat/udp.c +++ b/libavformat/udp.c @@ -71,6 +71,7 @@ #endif #define UDP_TX_BUF_SIZE 32768 +#define UDP_RX_BUF_SIZE 393216 #define UDP_MAX_PKT_SIZE 65536 #define UDP_HEADER_SIZE 8 @@ -636,7 +637,7 @@ static int udp_open(URLContext *h, const char *uri, int flags) is_output = !(flags & AVIO_FLAG_READ); if (s->buffer_size < 0) - s->buffer_size = is_output ? UDP_TX_BUF_SIZE : UDP_MAX_PKT_SIZE; + s->buffer_size = is_output ? UDP_TX_BUF_SIZE : UDP_RX_BUF_SIZE; if (s->sources) { if (ff_ip_parse_sources(h, s->sources, &s->filters) < 0)