From patchwork Sun Jan 7 18:46:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: sfan5 X-Patchwork-Id: 7181 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.78.2 with SMTP id r2csp1815825jaa; Sun, 7 Jan 2018 10:46:40 -0800 (PST) X-Google-Smtp-Source: ACJfBouZcSY8Uv9K0nXlU+BfgEgriND8t6uATeofcA+nCaF+J9Kgksnl9QfaszLBDknWJxbV7ASM X-Received: by 10.28.168.88 with SMTP id r85mr7808841wme.157.1515350800594; Sun, 07 Jan 2018 10:46:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515350800; cv=none; d=google.com; s=arc-20160816; b=BXGpeXZvOFziGDFPQrKS6yemKDP7Ddmr1VwDd12sEJ1Li9KvKS2d/MpMIGxLRaUPmd 3d+Co+RZgpJeqgeeQUqSCzJfYc9OZbxzToFqaRqO2HhrC5Dx6iSittPFWKPxAZ49Enva 7LMFVTNsNJCF5YD1NTOi/nXXlTA1MBnKKj5mMGY3FS+Hd+TI6u6iJpXXp0ZX6SXLXFvN xgx5pEYDQQhySDg5vtSVOXMkCOPJGmlkXTcOO2GsoMhAUPXwJaovkzo9wDQsh4xSlw4T QXO30nmes4Gg5QOlNBVmCWMES5uOKNQHqVYhLEAK1Xuhtyx7ZeCbX5WbHRgPN+MSe+57 MXKQ== 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:spamdiagnosticmetadata:spamdiagnosticoutput :content-language:accept-language:message-id:date:thread-index :thread-topic:to:from:delivered-to:arc-authentication-results; bh=6m4WZ10OEvBUgcAthCz1b2wvFwOpRr4Djs+I8LYryNc=; b=EYCgHI/GdwXtTEcZ/4bLBvd0BC+KiVI4z90HQ/R1wJBDxPHBeHOWJ39/vEkRbrQj/m MjKipWORYELJSrVSxPsgfyTg3fTCry2FYjaaAVZN/fGk8zuTQOoRNsy13PyR54sQLCkw JiZPG7uYh3wU2/lIJWDBEx4s/ym64NCK0hAxeFm/bLiKUdGuMQ4s3LEoBo1WpzSfsqpD tRfzkSzMtgFEEHMuGmlgnHE+4R7g/0jQ0HVTaJDJwXi7SF3agNHxz5d5pgA9BhZ/enld Xqc5wxZutJ3d3fahYPpx62d0yCtihfMOHyIbgxcpv/O3cMEUEEKci2qC8CZ/jl3aIWKG cJ2A== 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 m10si7891915wrm.130.2018.01.07.10.46.40; Sun, 07 Jan 2018 10:46:40 -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 63BD7689E69; Sun, 7 Jan 2018 20:46:16 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-oln040092071101.outbound.protection.outlook.com [40.92.71.101]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 06926689E43 for ; Sun, 7 Jan 2018 20:46:10 +0200 (EET) Received: from VE1EUR03FT036.eop-EUR03.prod.protection.outlook.com (10.152.18.52) by VE1EUR03HT062.eop-EUR03.prod.protection.outlook.com (10.152.19.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.20.345.12; Sun, 7 Jan 2018 18:46:09 +0000 Received: from DB3PR0202MB3452.eurprd02.prod.outlook.com (10.152.18.60) by VE1EUR03FT036.mail.protection.outlook.com (10.152.19.204) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.20.345.12 via Frontend Transport; Sun, 7 Jan 2018 18:46:09 +0000 Received: from DB3PR0202MB3452.eurprd02.prod.outlook.com ([fe80::f937:4ad2:ba75:414]) by DB3PR0202MB3452.eurprd02.prod.outlook.com ([fe80::f937:4ad2:ba75:414%13]) with mapi id 15.20.0386.008; Sun, 7 Jan 2018 18:46:09 +0000 From: Stefan _ To: FFmpeg development discussions and patches Thread-Topic: [PATCH 4/6] dashdec: Correct seeking behaviour Thread-Index: AQHTh+fInv88OmHnLE2heDMSpWs33w== Date: Sun, 7 Jan 2018 18:46:09 +0000 Message-ID: Accept-Language: de-DE, en-US Content-Language: en-US X-MS-Has-Attach: yes X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:E32E77F48C1F7F17659D2EF26968798BFC575795E0CB1DFA670C15E9F35937F3; UpperCasedChecksum:4AF4047BF2E3257A618DEF3EF65D28F9EFEC901494A26A3B9F54CAFE478CB7C6; SizeAsReceived:6913; Count:44 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [5Cmj4gPZRBlbiu4Ux884dgx5bbTg+/7G] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; VE1EUR03HT062; 7:fJFYGj/vrmHD2bgz4TpqGaVhT/VKf4toNJ2j0X2Qnl9Hm3cTBdHhXVm5GfMGrYvgUtnvn1v2RonderM4qiFHKbD+Ue9fgrTXC3V0a9Z1GD+WOJlyO3B/JzPmeBO1WGLB5VxgPw95mJ2Eso3wpAdz7vX8GjaA7bzebKjIkrbss0bWX7QNwosrFY2WvG3WTlmrtAzYjvSTc+2j8moP2XQP5HnNkqMIfWm6rRgY+SgHOTbdj+wmdVpa+X5UI2yg0f8L x-incomingheadercount: 44 x-eopattributedmessage: 0 x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(201702061074)(5061506573)(5061507331)(1603103135)(2017031320274)(2017031324274)(2017031323274)(2017031322404)(1603101448)(1601125374)(1701031045); SRVR:VE1EUR03HT062; x-ms-traffictypediagnostic: VE1EUR03HT062: x-ms-office365-filtering-correlation-id: b9ee9408-4281-4834-de9a-08d555feead4 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(444000031); SRVR:VE1EUR03HT062; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:VE1EUR03HT062; x-forefront-prvs: 0545EFAC9A x-forefront-antispam-report: SFV:NSPM; SFS:(7070007)(98901004); DIR:OUT; SFP:1901; SCL:1; SRVR:VE1EUR03HT062; H:DB3PR0202MB3452.eurprd02.prod.outlook.com; FPR:; SPF:None; LANG:; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: b9ee9408-4281-4834-de9a-08d555feead4 X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Jan 2018 18:46:09.5791 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1EUR03HT062 Subject: [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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "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; -- 2.15.1