From patchwork Wed Jun 28 12:02:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ffmpeg@a.legko.ru X-Patchwork-Id: 4143 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.1.76 with SMTP id 73csp3213506vsb; Wed, 28 Jun 2017 05:02:56 -0700 (PDT) X-Received: by 10.28.111.215 with SMTP id c84mr7343196wmi.72.1498651376313; Wed, 28 Jun 2017 05:02:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498651376; cv=none; d=google.com; s=arc-20160816; b=pKLvcPZSBqxxwd5uNICBqiI4PYivKlmHpWkxtVQefwvYMYr4uZVkVFnbBVk03CYOaE mrwm71bWLzq16J0f5IjwztDFg6UGx27KCEu35yN1kQd7e9Bao4LGtXelFL6F6rTk9CWt acJbVUrHC0jvDxxLBPbIVeRqzqzBSwyheFND9ZZQI8QgKu1/xTQPAO3J+7dkJ/4yTemH 9aHFVczm6sVXlRn8a4rnmgy/5BeY+0bFDFipdOtly25gq+d+92ZTsQ93cL1a12WTsjvL HNSqPUCq1/pk6lia57jUrWw/UtWMu1uvaZGBXH3CZE6LO7bx5nMbbVJPtdpTUwUaf9Hj UmWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:user-agent:references:message-id:in-reply-to:to:from :date:delivered-to:arc-authentication-results; bh=SBvJaAXDr3HiF5zgAbmbfjAiv+KPvUQLDtx5Qg/1VTA=; b=tbpZxpdXgTyMG+Vha+iR3Zpugzb+aLfRrgNF9+yNuvPhQufIL4/OATBEJ3FyqUVqOZ SP655Uwu28Ckw2DF+DL9SJ5tTWfjdDu4X+9kyw06+pTf/v4NCpl7A20wiAzXotTibA7x e8llMo5VkhAb5zJS50Tc7uFTG5LQr2H+NSQP0WmEj8uFf8Qy+PYFD+pyxFWHhfnt13m9 MjMEQLBCQWm6J+jnqxOI7h+sZr6vn5CRi5P1a5jR8OGdvlATr9XPDOx7wXSFSP8lE0Tm n6tGjYwU0oyQry4+JwsdSfKE/+Mgd/A9Ve4Q2aWQrWBelbI+xmqM7SiOMY8r/Wq+pDHa axOw== 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 r125si5451687wma.94.2017.06.28.05.02.55; Wed, 28 Jun 2017 05:02:56 -0700 (PDT) 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 632F868A18A; Wed, 28 Jun 2017 15:02:50 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from scil.sinp.msu.ru (scil.sinp.msu.ru [213.131.0.130]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A6DE668A04C for ; Wed, 28 Jun 2017 15:02:43 +0300 (EEST) Received: from ffmpeg (helo=localhost) by scil.sinp.msu.ru with local-esmtp (Exim 4.86) (envelope-from ) id 1dQBgA-000748-Tn for ffmpeg-devel@ffmpeg.org; Wed, 28 Jun 2017 15:02:43 +0300 Date: Wed, 28 Jun 2017 15:02:42 +0300 (MSK) From: ffmpeg@a.legko.ru X-X-Sender: ffmpeg@scil.sinp.msu.ru To: FFmpeg development discussions and patches In-Reply-To: Message-ID: References: <20170627153244.GU4727@nb4> User-Agent: Alpine 2.20 (LNX 67 2015-01-07) MIME-Version: 1.0 X-Spam-Score: 0.0 (/) X-Spam-Report: Spam detection software, running on the system "scil.sinp.msu.ru", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see vvs for details. Content preview: subject: when input sample stops, input thread stops too (withous restart), thus, breaking the streaming and loop mode does not affect this. touches only multistream (multiprog) mode, when threads are used. [...] Content analysis details: (0.0 points, 6.5 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different -0.0 NO_RELAYS Informational: message was not relayed via SMTP Subject: [FFmpeg-devel] patch 1. Correction of loop behaviour in ffpeg.c 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" subject: when input sample stops, input thread stops too (withous restart), thus, breaking the streaming and loop mode does not affect this. touches only multistream (multiprog) mode, when threads are used. From d8310311a3c1a1828eacd4b45b31f9a723b5ee2b Mon Sep 17 00:00:00 2001 From: root Date: Wed, 28 Jun 2017 14:53:40 +0300 Subject: [PATCH 1/3] add support for samples looping (threaded mode; thread stops after decoding input) --- ffmpeg.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) -- 2.7.4 diff --git a/ffmpeg.c b/ffmpeg.c index a783e6e..2866754 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -4013,6 +4013,29 @@ static void free_input_threads(void) } } +static int init_input_thread(int i) +{ + int ret; + + if (nb_input_files == 1) + return 0; + + InputFile *f = input_files[i]; + if (f->ctx->pb ? !f->ctx->pb->seekable : + strcmp(f->ctx->iformat->name, "lavfi")) + f->non_blocking = 1; + ret = av_thread_message_queue_alloc(&f->in_thread_queue, + f->thread_queue_size, sizeof(AVPacket)); + if (ret < 0) + return ret; + if ((ret = pthread_create(&f->thread, NULL, input_thread, f))) { + av_log(NULL, AV_LOG_ERROR, "pthread_create failed: %s. Try to increase `ulimit -v` or decrease `ulimit -s`.\n", strerror(ret)); + av_thread_message_queue_free(&f->in_thread_queue); + return AVERROR(ret); + } +return 0; +} + static int init_input_threads(void) { int i, ret; @@ -4191,9 +4214,13 @@ static int process_input(int file_index) ifile->eagain = 1; return ret; } + if (ret < 0 && ifile->loop) { if ((ret = seek_to_start(ifile, is)) < 0) return ret; +#if HAVE_PTHREADS + init_input_thread(file_index); +#endif ret = get_input_packet(ifile, &pkt); if (ret == AVERROR(EAGAIN)) { ifile->eagain = 1;