From patchwork Mon Jan 8 02:57:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Steven X-Patchwork-Id: 7192 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.78.2 with SMTP id r2csp2147992jaa; Sun, 7 Jan 2018 18:58:00 -0800 (PST) X-Google-Smtp-Source: ACJfBotEHTjn8Fi6fC1XBlRaqkRrJrLx5xwMMoLEO48iy13r/e7UmNgIAFoSuT64Mtz5JkrcAFPE X-Received: by 10.223.185.77 with SMTP id b13mr5481127wrg.0.1515380280667; Sun, 07 Jan 2018 18:58:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515380280; cv=none; d=google.com; s=arc-20160816; b=SUvdvpoyv37abgglNr+kqbla8EWtW44I5M9zDeskfJvlMZFxDu4PGAHLOe0Qj4LZJP 657jrDAl1Slhb3PWeNelkOQffCaqxX/d4fD1pWE8i118JVkuER/Q9eTNjP+E0dOVLC4f 207Hmsjlh9LUUSFjRocDLOjAUEMPreh7eoX2BZXiSmJly4b7cQ8k4ojqYIeSS2WzEs+T 8YsG5+wkSvIauz02SkyWok4eJIDC6PMFUBzTfZL7f0GQxcgSDS2FUUecAHgJ7DV8XQqF JlYxBAOiE+9i1ANzbwfssbygC24H/0wqxmZtYnTHwq8a2jE9eQGomUsPRzZRR1TyPVGT Ws0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:feedback-id:to:references:message-id :date:in-reply-to:from:mime-version:delivered-to :arc-authentication-results; bh=r4NpQ49WoS1d0/PB89aQ0kydxS5F2MsIDmMoEpr/HmA=; b=qTmWKoXfmKhNF2TJq9I10nvxEv3+dxkWprT8hnrrE3FRiawEvpdDuG5UgfLHywoh92 ZYhddVDiIvyp6id+8PXB/ZCvJXrF+GHTFus/uELKwKQw+cT59kC40/WgAkh2m/ERxCPJ O8Wn2lWIt6z7oxJgRVGinCuLWcTO73T54905BJlXs24d6csQwvkxBUPMnZC2R1U6SWHQ 8+Ko+bhYCLh59zD2JlOn7J53ztWRB8N5Tsq1ohbS2vcO0xLPPEQpkSUyza5dM4nZfzxD UzRCMIROMYdcg21J9HkmZ0+ltgXCGbakccUOwjMlFUar4/aQaG2dfP4fxXlMFPZYCSQk Ftvw== 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 g6si8384522wrh.101.2018.01.07.18.58.00; Sun, 07 Jan 2018 18:58:00 -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 B3D69689FD1; Mon, 8 Jan 2018 04:57:58 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from smtpproxy19.qq.com (smtpproxy19.qq.com [184.105.206.84]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 380F6689F9A for ; Mon, 8 Jan 2018 04:57:51 +0200 (EET) X-QQ-mid: bizesmtp5t1515380246takaul77o Received: from [192.168.3.21] (unknown [121.69.97.6]) by esmtp4.qq.com (ESMTP) with id ; Mon, 08 Jan 2018 10:57:25 +0800 (CST) X-QQ-SSF: 01100000004000F0FKF0000A0000000 X-QQ-FEAT: oP8qruwI8aXa2B2lo+xR9EVxfn+khEQiZiXWpcBbGGByv2qaVmnyvZsxgiA9k /GulJgJ1+PkZR5SuMjFF7H+Fo5tUA0k6iDE+5LIhssJyWWbVNN1qK1AmhvskO+0UzM2KDJK u7CmN6i+c2D2BG1q917s+IpEGV60iV3CgzmKgYNZmBOFgCGC87Ro81P/k/c/Hy98fNlQG2G /zMInqUz77JBLh/aUvqnMSebvMwIaX06XbKLKsbXvHe97JJJhNfkDCbyMTYZuYjFA2nVpu4 QJ7Crh62V7gqJbSxkChh30Dzn9BnS8VhtLKQ== X-QQ-GoodBg: 0 Mime-Version: 1.0 (Mac OS X Mail 11.1 \(3445.4.7\)) From: =?utf-8?B?5YiY5q2n?= In-Reply-To: Date: Mon, 8 Jan 2018 10:57:23 +0800 Message-Id: <47CF0C07-7CCC-4DB6-819E-8C444A891D60@chinaffmpeg.org> References: To: FFmpeg development discussions and patches X-Mailer: Apple Mail (2.3445.4.7) X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:chinaffmpeg.org:qybgforeign:qybgforeign2 X-QQ-Bgrelay: 1 Subject: Re: [FFmpeg-devel] [PATCH 4/6] dashdec: Correct seeking behaviour 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: =?utf-8?B?5YiY5q2n?= Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" > On 8 Jan 2018, at 02:46, Stefan _ wrote: > > > <0004-dashdec-Correct-seeking-behaviour.patch>_______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel >From bdf3557a400620fce66ca0237f1ff172c227609b Mon Sep 17 00:00:00 2001 From: sfan5 Date: Fri, 5 Jan 2018 00:51:32 +0100 Subject: [PATCH 4/6] dashdec: Correct seeking behaviour dash_read_seek() is called only once to issue a seek of *all* streams to the specified timestamp. But to avoid reopening each stream, do a "dry run" for streams that are in a discarded state. --- libavformat/dashdec.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c index ac0e6c6f9..1252d4156 100644 --- a/libavformat/dashdec.c +++ b/libavformat/dashdec.c @@ -1828,19 +1828,22 @@ static int dash_close(AVFormatContext *s) return 0; } -static int dash_seek(AVFormatContext *s, struct representation *pls, int64_t seek_pos_msec, int flags) +static int dash_seek(AVFormatContext *s, struct representation *pls, int64_t seek_pos_msec, int flags, int dry_run) { int ret = 0; int i = 0; int j = 0; int64_t duration = 0; - av_log(pls->parent, AV_LOG_VERBOSE, "DASH seek pos[%"PRId64"ms], playlist %d\n", seek_pos_msec, pls->rep_idx); + av_log(pls->parent, AV_LOG_VERBOSE, "DASH seek pos[%"PRId64"ms], playlist %d%s\n", + seek_pos_msec, pls->rep_idx, dry_run ? " (dry)" : ""); // single fragment mode if (pls->n_fragments == 1) { pls->cur_timestamp = 0; pls->cur_seg_offset = 0; + if (dry_run) + return 0; ff_read_frame_flush(pls->ctx); return av_seek_frame(pls->ctx, -1, seek_pos_msec * 1000, flags); } @@ -1885,14 +1888,14 @@ set_seq_num: pls->cur_timestamp = 0; pls->cur_seg_offset = 0; pls->init_sec_buf_read_offset = 0; - ret = reopen_demux_for_component(s, pls); + ret = dry_run ? 0 : reopen_demux_for_component(s, pls); return ret; } static int dash_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags) { - int ret, i; + int ret = 0, i; DASHContext *c = s->priv_data; int64_t seek_pos_msec = av_rescale_rnd(timestamp, 1000, s->streams[stream_index]->time_base.den, @@ -1901,16 +1904,14 @@ static int dash_read_seek(AVFormatContext *s, int stream_index, int64_t timestam if ((flags & AVSEEK_FLAG_BYTE) || c->is_live) return AVERROR(ENOSYS); - ret = AVERROR_EOF; + /* Seek in discarded streams with dry_run=1 to avoid reopening them */ for (i = 0; i < c->n_videos; i++) { - if (c->videos[i]->stream_index == stream_index) { - ret = dash_seek(s, c->videos[i], seek_pos_msec, flags); - } + if (!ret) + ret = dash_seek(s, c->videos[i], seek_pos_msec, flags, !c->videos[i]->ctx); } for (i = 0; i < c->n_audios; i++) { - if (c->audios[i]->stream_index == stream_index) { - ret = dash_seek(s, c->audios[i], seek_pos_msec, flags); - } + if (!ret) + ret = dash_seek(s, c->audios[i], seek_pos_msec, flags, !c->audios[i]->ctx); } return ret;