From patchwork Tue Aug 23 19:03:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukas Fellechner X-Patchwork-Id: 37417 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:139a:b0:8f:1db5:eae2 with SMTP id w26csp2071502pzh; Tue, 23 Aug 2022 12:04:16 -0700 (PDT) X-Google-Smtp-Source: AA6agR6OckHGHGNyVmzeyBxOqajcRHuNFAEuP78OCormQhZ1JyUxctYrlXTyTcojCesFBzq/kJ0k X-Received: by 2002:a17:907:1c87:b0:6f0:29ea:cc01 with SMTP id nb7-20020a1709071c8700b006f029eacc01mr608898ejc.671.1661281456183; Tue, 23 Aug 2022 12:04:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661281456; cv=none; d=google.com; s=arc-20160816; b=fOrv9svTTB2vPD+KPrWNIzTZIsOP8K5VWKJBnS8/9bgvZbZxdCz25eq07oBwQa/VhZ K2IlP/LoQezUJsk44vW/Y8s5HUv66qpYr6K9vtnrs5KFqxq6QAo++pHn5gIzC0fH1heo tJIZV6zv/3ymggxqD9wooVGHpZKSZUncweWjAsXgWDB7p8Zczeu5qLNNVvNIUsRjqxbd LffaFzVwSryPxiGYmN7xv3rCC7vazX1NH2MT+NELD3l7QBA/l1ci3nuKt66PT++MOhhl PryzmnuS8cyvdxTDxZoAmD8gonGbTGxKSNERKDxA/wmgfrfAonWmuOJ9gTaohTB8eF0W SLdw== 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:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=hpsqdkoAQwGr2E67b45Rt2Xt3sxYi7eJ/Uu/A8fNdq8=; b=A4DVySjod7QdvTv1897OVROQaYIX7vsdzkA5qQ4rWP8B3aeSM6DEne3Z0K/R5qaY4d OtBULwZHivsgTHlkkV3OIACPX5eIEgfHxnirEI2oXhUcqzXzHtuDlc9iTtosMVrlbD73 kX6i0gVn0+U9iscZnJkmjIdYdNYSB8N+4qLOHkksmrzId0PlvxvPr9y9VBD1qYXNzjaC tB0z2VzRfmIsA4Qti7wQ2kvLmxuVTvvWYv69iJ9G7fQ0V7bpPtP8qOKCvgV9JW7rWZyB 8SxTQjzAhAt/HoUsqJR3KlNEtRs+ATTKDrr3LnGamXv5OTCpmZ0pc8nqPgYV/IxrEniK AD7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmx.net header.s=badeba3b8450 header.b=MAIhSfHu; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmx.net Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id s16-20020a056402521000b0043dcf90c94asi2973059edd.67.2022.08.23.12.04.15; Tue, 23 Aug 2022 12:04:16 -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; dkim=neutral (body hash did not verify) header.i=@gmx.net header.s=badeba3b8450 header.b=MAIhSfHu; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmx.net Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5212168B9C5; Tue, 23 Aug 2022 22:04:13 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 55CA268B9B3 for ; Tue, 23 Aug 2022 22:04:06 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1661281445; bh=MMpaMgmJIGP+HIBWki62KsjwFXB6/7cxNdEqsL2Ggjs=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=MAIhSfHuO7D5BUT6k0kyXyoUWPzvf719IG5/Y4yXXG8IzAhHcfe2Xyys42nL3THTB fSZW6tRAjq7oM4CDU+ER12AyGov4L1+AYaEqRv4ZQijr/FRRA52zq537yqkkVpYy0A RIpH8e6U9uraHBOGi2KAprYNHplcv021/FLenL/Q= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from localhost.localdomain ([94.134.107.162]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MrhQ6-1pByl72VU4-00nfB6; Tue, 23 Aug 2022 21:04:05 +0200 From: Lukas Fellechner To: ffmpeg-devel@ffmpeg.org Date: Tue, 23 Aug 2022 21:03:24 +0200 Message-Id: <20220823190326.249-2-lukas.fellechner@gmx.net> X-Mailer: git-send-email 2.31.1.windows.1 In-Reply-To: <20220823190326.249-1-lukas.fellechner@gmx.net> References: <20220823190326.249-1-lukas.fellechner@gmx.net> MIME-Version: 1.0 X-Provags-ID: V03:K1:I90Y64tqy0MOinZDmcqJxn/nPAULKnCP1i5AmetLBftRzlux0p4 txcXXU4ArtpY7jKCZvFJKPzdUPPBxL8H0HVIfG3uJZisTu78fazyE5Kmg8dWE8oRIxxyk7a M01Emv6DiOR2GSTMJQhYikcCJw3Xw252ML1EtdrN95AhQThegZFa6U6etJBYMXBwHZwrVT/ FTXF0CURLR7yCtkJz5CoA== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:p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1txtQOxgUckcXocL+f5y4jh/tYtoLX86j6I8xKc9JgTR9OusgGEAczk+Et FqIsGH5e/0WRqhDqty8cPis49KA3nZokXqw3PK0dAnJVNLLviE/dmMj5A== Subject: [FFmpeg-devel] [PATCH v3 1/3] lavf/dashdec: Prepare DASH decoder for multithreading X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Lukas Fellechner Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: YfDw2jraIHBP For adding multithreading to the DASH decoder initialization, the open_demux_for_component() method must be split up into two parts: begin_open_demux_for_component(): Opens the stream and does probing and format detection. This can be run in parallel. end_open_demux_for_component(): Creates the AVStreams and adds them to the common parent AVFormatContext. This method must always be run synchronously, after all threads are finished. --- libavformat/dashdec.c | 42 ++++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) -- 2.31.1.windows.1 diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c index 63bf7e96a5..e82da45e43 100644 --- a/libavformat/dashdec.c +++ b/libavformat/dashdec.c @@ -1918,10 +1918,9 @@ fail: return ret; } -static int open_demux_for_component(AVFormatContext *s, struct representation *pls) +static int begin_open_demux_for_component(AVFormatContext *s, struct representation *pls) { int ret = 0; - int i; pls->parent = s; pls->cur_seq_no = calc_cur_seg_no(s, pls); @@ -1931,9 +1930,15 @@ static int open_demux_for_component(AVFormatContext *s, struct representation *p } ret = reopen_demux_for_component(s, pls); - if (ret < 0) { - goto fail; - } + + return ret; +} + +static int end_open_demux_for_component(AVFormatContext *s, struct representation *pls) +{ + int ret = 0; + int i; + for (i = 0; i < pls->ctx->nb_streams; i++) { AVStream *st = avformat_new_stream(s, NULL); AVStream *ist = pls->ctx->streams[i]; @@ -1965,6 +1970,19 @@ fail: return ret; } +static int open_demux_for_component(AVFormatContext* s, struct representation* pls) +{ + int ret = 0; + + ret = begin_open_demux_for_component(s, pls); + if (ret < 0) + return ret; + + ret = end_open_demux_for_component(s, pls); + + return ret; +} + static int is_common_init_section_exist(struct representation **pls, int n_pls) { struct fragment *first_init_section = pls[0]->init_section; @@ -2040,9 +2058,15 @@ static int dash_read_header(AVFormatContext *s) av_dict_set(&c->avio_opts, "seekable", "0", 0); } - if(c->n_videos) + if (c->n_videos) c->is_init_section_common_video = is_common_init_section_exist(c->videos, c->n_videos); + if (c->n_audios) + c->is_init_section_common_audio = is_common_init_section_exist(c->audios, c->n_audios); + + if (c->n_subtitles) + c->is_init_section_common_subtitle = is_common_init_section_exist(c->subtitles, c->n_subtitles); + /* Open the demuxer for video and audio components if available */ for (i = 0; i < c->n_videos; i++) { rep = c->videos[i]; @@ -2059,9 +2083,6 @@ static int dash_read_header(AVFormatContext *s) ++stream_index; } - if(c->n_audios) - c->is_init_section_common_audio = is_common_init_section_exist(c->audios, c->n_audios); - for (i = 0; i < c->n_audios; i++) { rep = c->audios[i]; if (i > 0 && c->is_init_section_common_audio) { @@ -2077,9 +2098,6 @@ static int dash_read_header(AVFormatContext *s) ++stream_index; } - if (c->n_subtitles) - c->is_init_section_common_subtitle = is_common_init_section_exist(c->subtitles, c->n_subtitles); - for (i = 0; i < c->n_subtitles; i++) { rep = c->subtitles[i]; if (i > 0 && c->is_init_section_common_subtitle) {