From patchwork Sat May 7 11:28:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 35649 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a885:b0:7f:4be2:bd17 with SMTP id ca5csp2121579pzb; Sat, 7 May 2022 04:31:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzJVK9Vhq+oLinzDjMhTFOXLVv2I7BQmRSRUy/cOnxy7cyci9ek4XUuMexdLF3AVnIaH1LS X-Received: by 2002:a17:906:58ca:b0:6f4:444f:31ef with SMTP id e10-20020a17090658ca00b006f4444f31efmr6815898ejs.135.1651923068642; Sat, 07 May 2022 04:31:08 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id ne27-20020a1709077b9b00b006f744dbd535si3522781ejc.232.2022.05.07.04.31.08; Sat, 07 May 2022 04:31:08 -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=@outlook.com header.s=selector1 header.b=urj8i4km; arc=fail (body hash mismatch); 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=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0995968B423; Sat, 7 May 2022 14:29:40 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-oln040092073010.outbound.protection.outlook.com [40.92.73.10]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BDC4968B278 for ; Sat, 7 May 2022 14:29:33 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Z+fP8IkE44BW43Hrs9F+P1XM9g9lerE/qq+mObTZxgyhdYs6s1PpPGa14mZ9Lo7wahFZ7kywcgs3yfcOAQc2rFmbYZhb9eDOqxJmiDngyoRc8ZUSRVEzQe409dw4YWHJYRuHoLRjCYUgI+CDtvzLBVMICm/M/hN3X8EIdWYfOL9n/Y5CEwdMCbZDAyIEI23uJCAD8v5pK12VWUo+h+z0ejUUyqLc/MMVo5pXbMie/EbAZf/KGg2q1FqRKEGlHVKUZACHPYeCtG/hs8FuK/EWkoBvjPhK6yuKhJaWXk/qAHGqe5jZLzD80kA5yGITAeygfTap5x+JUO1Zowk4ZhQcCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=MWtKvORSao19r4ks8A4eZGnHTGL6J2weF/I59VgHPgc=; b=BO6WNT3nR3ClVEURKUCa1cHSZqvNgNyAhkBqrlbxdGPc7tyj8EIcDExh/4fWStOC2srqQrCYQvrhATq7+h4vjKLxKoc69bVTbnRff8ETZvAAfav9zXyREL8c/YFcJLvS+7Y91TacCOZkixRHIXwNlAlXZJ2JNuz6TlyQ9wagithOCsE051wxQzk88L6GR5cFIkjuYDELwPNTyWo/dVVkHoAdL9gYdOcBLsm7d20E5aVA26t9ranIZSovBhA2Ssu8mo1lvof+n0UGjW+vF4IGFlWNYQtieC7qiabVvDChGZZNanoSxj2wDxp2Mty1lASaZeIKYBmpe7yigsSv4nKU7w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MWtKvORSao19r4ks8A4eZGnHTGL6J2weF/I59VgHPgc=; b=urj8i4kmqcUqkFEALzOMgkchk8FVFoSL8R26Bu11/ccnNkf8ZvfXlL6McCP3c7NXZxxrR4grLc7xpUJXXmnYQFK4WwIbAcnasyOCXnTiZor7mk+QHHJdWezj9S2UQp1msXMoPiUPiGwWWxRR48/ZyoIgJpsmIiqmFpP6fLhKTU9acyfEEHBGN/jRcinCImWczkDaDX7+izqjjNoNPf5Q8hy4F1Yhs3e/KZ2OCKe0XX6Lj/JSr5pPa1oirC8BkBv80jJByCWxQZ/42Dj9VSdywdWa3ww1GyPNOaul5YP4XQcSsKqYEET4d0QdYw4mkQ3Lhzfez/Kj7NxmsdakpSK6qQ== Received: from AS8PR01MB7944.eurprd01.prod.exchangelabs.com (2603:10a6:20b:373::5) by DB6PR0102MB2663.eurprd01.prod.exchangelabs.com (2603:10a6:6:e::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.21; Sat, 7 May 2022 11:29:31 +0000 Received: from AS8PR01MB7944.eurprd01.prod.exchangelabs.com ([fe80::1854:2c30:7ba1:c431]) by AS8PR01MB7944.eurprd01.prod.exchangelabs.com ([fe80::1854:2c30:7ba1:c431%6]) with mapi id 15.20.5206.024; Sat, 7 May 2022 11:29:31 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sat, 7 May 2022 13:28:01 +0200 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [XkG47/U56BcnXCOL0zi3ZUn6KtIxu1LD] X-ClientProxiedBy: ZRAP278CA0004.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:10::14) To AS8PR01MB7944.eurprd01.prod.exchangelabs.com (2603:10a6:20b:373::5) X-Microsoft-Original-Message-ID: <20220507112830.406162-14-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c92ff568-2039-4a1c-3199-08da301cda43 X-MS-Exchange-SLBlob-MailProps: gjx25WM8ZNVZjuqTokTVdg9S7+crVfX8T1BJLRPzp5DB0BtZ8Kkd0jkdC4Sk7THqetLOlAwSgbKn3XGDdAzTa3xIxmFzl3Zcw2Fw9Va/2FG+mAA+q0XyDqtM6Rhc6HQBbmHsaUV/HYRr5o4vTwZHHK+J10ASXzIq09097UOLbNDUSDfbTZ8Rmv4k861az1o36qHcFgv9vvT3d4bzl82CAo04R+2A8QsTn6bcCv7MPeGmXCSh/IwlMv4hYMNJmquPgtB5PBnfZY8A5WA3ZEddp1LiorVc4yLLuLD00ATqBagWNdparzJWpGyDFkBHGuZ536yY/Va6nNzxCALtg3cWXEsN4K833hb9/HgcrzxJxH3kw43/MxDzKeSscjMsZgcspIa6zsjAk3LsgF5UGyZ66ShDJy6xZX0FT/+0wYMbh6w7GWCm6qFHXWgiXdQNviLHNDUgRvku0fxUy0WrTuK3qpvHZ/oNQ3t31n2b93/dyNF0fwgBDiGc8mz10/2O2+1t3kjtpaAyLqDMpXt91dOWcqYkAK4YinF69rVvkUnH4Rx/tuau3MsiqIFMvNanlkwfbLZqAMtMUmiJn3L3sKi75Aca0RX8qw7i5pW6tUB7fR6cQELUOaJCgJEY6JSzI/XtS1gxMbuqPYgrHpZ/S7XJufU4avgXo7RZaEyskYfBW7gH0opXjqGwWP851GfEQdtQUdDmI8Yik/1nEFZjCjtcHSSCY5Hj8cpzuya1OWCQExk= X-MS-TrafficTypeDiagnostic: DB6PR0102MB2663:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: z10GzvJZzNASoND6K9MHFKkhxWX2QuUHhNfKugrhf41LB7xvqMCw5Sl1fDS15EEumJqPR2KLWIGe+sKUoeSObKye4n8CTOlWVrPS3tQ0BzF0xsTvbbI8w24pZ/GN5YcZURu8OJFaxjk7U7C4XCv1JmpleQ6xPUDrySUFj3Ertrle6v9AwWhTEZlyxkdeFMrJLdDBXif9rAwdxJeaEorQIBr5GJry9i21F4gvJXj8Ns3wgP39NpkHePnubzRAVwIRhJ6ShOpReT2YSTyyp97jcWPQEVlvH3jXJ4EVlwHuqrXKmDkawqdduDzoGMcX1NUicCXgVbeIsrdUhZj6ftj4X2rz6I6xMy6V/oRWihaEElHdoBFPqFtLJOt8Ajf1z793Em6GNrITCi/fUCC8B8gxACEAJryNkqQTMTYnf2J4RpQmZGB5TlOnOvRy4yZHAIXUDXghkBHoRbYYJvQgO4FJZFlg3q2hLtmEBdaag1SdMlgNbC1cPpput1WI8+YSSBTzltqoVDgfQHoRpQVHNsWqBJd29H7k9DZY25wRnUd1HI7S0HhcNB90i564eS5ad7jrOJYn0jKbcH37YwYzdyRHE7FUfUw2MENtyeulvlvXFlVw2pShaQbI5HQ/dgJh5+Zr X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /zY+igfBo4v7bO83qloEUorUDVgV38bsp5V6Pfl122uHomzNs/a9ZOT9QNADk0f0XKu7jVx4k/A7657vnrjr+DjoD/57+06+j3Qz8tRulqY19dDJNg813z1r47gyoHuKaH4K+0U0/KPrzbc7wpCyPfQRT1Od+zvfMfLU7kTB7bqhBCaGV3m44r+Gwu0TP7DPBmQrxYfgrIERe8gub4aXFniDcRcceMCutqONK+1tgtOnwmIJ88HDW9OePXyHUXZEbRnbnG2NWiPSiMKMagkzzcY8rQ3F5o8t+L5GjNHdbXErDBMmQFJonQsSwbPl33ArKb94LGkpdsPvymA3QgK9Fek/FfdvhaTkRimCg+s8UNF3IjsWI/dlg9O/baB8ftS3Nkau5jJrXFhjvcKtfWH+zjQuvV9apq35AUlIzB0HZJdcNO2Dxbep7hXBKem3EEMbCU2GxEq7Ve9A8MGZGEHup159Jl+091opALnAjuhvmp7WSsthO3M7G9wLcgpcd5ybu2GpB/DOq4AHxdwR00n5zyalSBomL+c9iH4PHR3FkmrIyZddai7bFat1aJAuK552Cr44MXhojbcv/0DE1nYvsPUgRCUNsjN37Nxf8Vx1zeB50/WzwdPUgik0lKwuZnX4+YIO51WqsyKRgI2C1yVASVL5EQ6pZgdYCQQEFWjnLeSokCClwFXJq4QsOR8Ju8z/iWtd3Nu61XdgzC7d6P2Z34tG4FgZf65stv0JFSg6GV+Qf6jJp8E/bh1zmdnhMdT52G82BNKYoZGbiGLl020sf86U6O9sPenyiTa+Nk5YAAIvkwkDjpTqUFKUfaXxwWesXZyclvd472wAmGOBzdeMwBNPBdeY0nZdf+tuunrTSK8ZXO4nXvvSvUmGnQx5KbS0JBycXB46rGKlRcH69zrFiz82UbXXX8UJLrbbdQ+mAduwhUA1F1hpT+lqSXHdkF70QKDAJbWVuIH8MK7I8iod3KLl+iRusa1ZeKxexM7W6zrijd2xXok2jx2+oEnpKQZ+ca9UkkuifTFIxjcj8a+IAwc5OuksifPqIHQn1Hgk+o3JKZQrwUpAsKPAbx38IdAEj4XB5bQreQmWn/+9sWxGN0QcgYr7KC8QH/qVgeVOvzmLpMgFjZxEXjwimEa6g1rvy+B6np4RkOAwy0JQ0P26pmpkFv5LID3+tqnH6BGq4NBzWOVa/RBOIaAftkBKvvhxUZ+jRarlpT0zlrZ23wa1hJ3czlg32MdDowPLGq2fWTj1zD392dBSK8ucXNIis9BFvwvIyUX8oi1JxazE63nM/8x2RfJDZnyfCPG0N85KJB5cWlh8q0PX7dH6IXZTsc20e2gNI0yiQJ+6bj/FakqyO3wyJlKg1Mlr0RSSn7I8rPv/IWkBxhDc5VfPtpAW8RapIbNEeiSqSy3DAF35uWah19/lTOP6FYyjUe2/5u6aKCefWzmuFfI7R3rLVTD7+Z8w X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: c92ff568-2039-4a1c-3199-08da301cda43 X-MS-Exchange-CrossTenant-AuthSource: AS8PR01MB7944.eurprd01.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 May 2022 11:29:31.6961 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0102MB2663 Subject: [FFmpeg-devel] [PATCH 15/44] avformat/demux: Add new demux.h header 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: zKR9gr3eLd3K And move those stuff already in demuxer-only files to it. Signed-off-by: Andreas Rheinhardt --- libavdevice/libcdio.c | 1 + libavformat/aadec.c | 1 + libavformat/asfdec_f.c | 1 + libavformat/asfdec_o.c | 2 +- libavformat/avidec.c | 1 + libavformat/brstm.c | 1 + libavformat/concatdec.c | 1 + libavformat/dashdec.c | 1 + libavformat/demux.c | 2 +- libavformat/demux.h | 145 +++++++++++++++++++++++++++++++++ libavformat/hls.c | 1 + libavformat/idcin.c | 1 + libavformat/imfdec.c | 1 + libavformat/internal.h | 114 -------------------------- libavformat/matroskadec.c | 1 + libavformat/mca.c | 1 + libavformat/mlvdec.c | 3 +- libavformat/mov.c | 4 +- libavformat/mp3dec.c | 3 +- libavformat/mpc8.c | 1 + libavformat/mpeg.c | 1 + libavformat/mpegts.c | 1 + libavformat/mxfdec.c | 1 + libavformat/nutdec.c | 1 + libavformat/oggdec.c | 2 +- libavformat/oggdec.h | 1 - libavformat/options.c | 1 + libavformat/rmdec.c | 2 +- libavformat/rtpdec_asf.c | 2 +- libavformat/seek.c | 1 + libavformat/tests/seek_utils.c | 2 +- libavformat/vpk.c | 1 + libavformat/wtvdec.c | 1 + 33 files changed, 175 insertions(+), 128 deletions(-) create mode 100644 libavformat/demux.h diff --git a/libavdevice/libcdio.c b/libavdevice/libcdio.c index 4417523c57..28c339564f 100644 --- a/libavdevice/libcdio.c +++ b/libavdevice/libcdio.c @@ -37,6 +37,7 @@ #include "libavutil/opt.h" #include "libavformat/avformat.h" +#include "libavformat/demux.h" #include "libavformat/internal.h" typedef struct CDIOContext { diff --git a/libavformat/aadec.c b/libavformat/aadec.c index 19aa26e099..e7b048b1f9 100644 --- a/libavformat/aadec.c +++ b/libavformat/aadec.c @@ -24,6 +24,7 @@ */ #include "avformat.h" +#include "demux.h" #include "internal.h" #include "libavutil/avstring.h" #include "libavutil/dict.h" diff --git a/libavformat/asfdec_f.c b/libavformat/asfdec_f.c index a8f36ed286..fb8b48ed11 100644 --- a/libavformat/asfdec_f.c +++ b/libavformat/asfdec_f.c @@ -33,6 +33,7 @@ #include "avformat.h" #include "avio_internal.h" #include "avlanguage.h" +#include "demux.h" #include "internal.h" #include "riff.h" #include "asf.h" diff --git a/libavformat/asfdec_o.c b/libavformat/asfdec_o.c index fb614d42de..907be6de04 100644 --- a/libavformat/asfdec_o.c +++ b/libavformat/asfdec_o.c @@ -27,8 +27,8 @@ #include "libavutil/time_internal.h" #include "avformat.h" -#include "avio_internal.h" #include "avlanguage.h" +#include "demux.h" #include "internal.h" #include "riff.h" #include "asf.h" diff --git a/libavformat/avidec.c b/libavformat/avidec.c index 21fc2b87ff..937d9e6ffb 100644 --- a/libavformat/avidec.c +++ b/libavformat/avidec.c @@ -32,6 +32,7 @@ #include "libavutil/mathematics.h" #include "avformat.h" #include "avi.h" +#include "demux.h" #include "dv.h" #include "internal.h" #include "isom.h" diff --git a/libavformat/brstm.c b/libavformat/brstm.c index 4fb7920d7c..628c556e66 100644 --- a/libavformat/brstm.c +++ b/libavformat/brstm.c @@ -22,6 +22,7 @@ #include "libavutil/intreadwrite.h" #include "libavcodec/bytestream.h" #include "avformat.h" +#include "demux.h" #include "internal.h" typedef struct BRSTMCoeffOffset { diff --git a/libavformat/concatdec.c b/libavformat/concatdec.c index cfe1329105..e57da59e04 100644 --- a/libavformat/concatdec.c +++ b/libavformat/concatdec.c @@ -28,6 +28,7 @@ #include "libavcodec/bsf.h" #include "avformat.h" #include "avio_internal.h" +#include "demux.h" #include "internal.h" #include "url.h" diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c index 211d77fd02..6888132801 100644 --- a/libavformat/dashdec.c +++ b/libavformat/dashdec.c @@ -28,6 +28,7 @@ #include "internal.h" #include "avio_internal.h" #include "dash.h" +#include "demux.h" #define INITIAL_BUFFER_SIZE 32768 diff --git a/libavformat/demux.c b/libavformat/demux.c index ad7b5dbf83..5d83d81665 100644 --- a/libavformat/demux.c +++ b/libavformat/demux.c @@ -21,7 +21,6 @@ #include -#include "config.h" #include "config_components.h" #include "libavutil/avassert.h" @@ -42,6 +41,7 @@ #include "avformat.h" #include "avio_internal.h" +#include "demux.h" #include "id3v2.h" #include "internal.h" #include "url.h" diff --git a/libavformat/demux.h b/libavformat/demux.h new file mode 100644 index 0000000000..f003d81f52 --- /dev/null +++ b/libavformat/demux.h @@ -0,0 +1,145 @@ +/* + * copyright (c) 2001 Fabrice Bellard + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVFORMAT_DEMUX_H +#define AVFORMAT_DEMUX_H + +#include +#include "libavutil/rational.h" +#include "libavcodec/packet.h" +#include "avformat.h" + +#define RELATIVE_TS_BASE (INT64_MAX - (1LL << 48)) + +static av_always_inline int is_relative(int64_t ts) +{ + return ts > (RELATIVE_TS_BASE - (1LL << 48)); +} + +/** + * Wrap a given time stamp, if there is an indication for an overflow + * + * @param st stream + * @param timestamp the time stamp to wrap + * @return resulting time stamp + */ +int64_t ff_wrap_timestamp(const AVStream *st, int64_t timestamp); + +/** + * Read a transport packet from a media file. + * + * @param s media file handle + * @param pkt is filled + * @return 0 if OK, AVERROR_xxx on error + */ +int ff_read_packet(AVFormatContext *s, AVPacket *pkt); + +void ff_read_frame_flush(AVFormatContext *s); + +/** + * Perform a binary search using av_index_search_timestamp() and + * AVInputFormat.read_timestamp(). + * + * @param target_ts target timestamp in the time base of the given stream + * @param stream_index stream number + */ +int ff_seek_frame_binary(AVFormatContext *s, int stream_index, + int64_t target_ts, int flags); + +/** + * Update cur_dts of all streams based on the given timestamp and AVStream. + * + * Stream ref_st unchanged, others set cur_dts in their native time base. + * Only needed for timestamp wrapping or if (dts not set and pts!=dts). + * @param timestamp new dts expressed in time_base of param ref_st + * @param ref_st reference stream giving time_base of param timestamp + */ +void avpriv_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp); + +int ff_find_last_ts(AVFormatContext *s, int stream_index, int64_t *ts, int64_t *pos, + int64_t (*read_timestamp)(struct AVFormatContext *, int , int64_t *, int64_t )); + +/** + * Perform a binary search using read_timestamp(). + * + * @param target_ts target timestamp in the time base of the given stream + * @param stream_index stream number + */ +int64_t ff_gen_search(AVFormatContext *s, int stream_index, + int64_t target_ts, int64_t pos_min, + int64_t pos_max, int64_t pos_limit, + int64_t ts_min, int64_t ts_max, + int flags, int64_t *ts_ret, + int64_t (*read_timestamp)(struct AVFormatContext *, int , int64_t *, int64_t )); + +/** + * Internal version of av_index_search_timestamp + */ +int ff_index_search_timestamp(const AVIndexEntry *entries, int nb_entries, + int64_t wanted_timestamp, int flags); + +/** + * Internal version of av_add_index_entry + */ +int ff_add_index_entry(AVIndexEntry **index_entries, + int *nb_index_entries, + unsigned int *index_entries_allocated_size, + int64_t pos, int64_t timestamp, int size, int distance, int flags); + +void ff_configure_buffers_for_index(AVFormatContext *s, int64_t time_tolerance); + +/** + * Ensure the index uses less memory than the maximum specified in + * AVFormatContext.max_index_size by discarding entries if it grows + * too large. + */ +void ff_reduce_index(AVFormatContext *s, int stream_index); + +/** + * add frame for rfps calculation. + * + * @param dts timestamp of the i-th frame + * @return 0 if OK, AVERROR_xxx on error + */ +int ff_rfps_add_frame(AVFormatContext *ic, AVStream *st, int64_t dts); + +void ff_rfps_calculate(AVFormatContext *ic); + +/** + * Rescales a timestamp and the endpoints of an interval to which the temstamp + * belongs, from a timebase `tb_in` to a timebase `tb_out`. + * + * The upper (lower) bound of the output interval is rounded up (down) such that + * the output interval always falls within the intput interval. The timestamp is + * rounded to the nearest integer and halfway cases away from zero, and can + * therefore fall outside of the output interval. + * + * Useful to simplify the rescaling of the arguments of AVInputFormat::read_seek2() + * + * @param[in] tb_in Timebase of the input `min_ts`, `ts` and `max_ts` + * @param[in] tb_out Timebase of the ouput `min_ts`, `ts` and `max_ts` + * @param[in,out] min_ts Lower bound of the interval + * @param[in,out] ts Timestamp + * @param[in,out] max_ts Upper bound of the interval + */ +void ff_rescale_interval(AVRational tb_in, AVRational tb_out, + int64_t *min_ts, int64_t *ts, int64_t *max_ts); + +#endif /* AVFORMAT_DEMUX_H */ diff --git a/libavformat/hls.c b/libavformat/hls.c index 83ff4cc607..38eb346405 100644 --- a/libavformat/hls.c +++ b/libavformat/hls.c @@ -39,6 +39,7 @@ #include "libavutil/dict.h" #include "libavutil/time.h" #include "avformat.h" +#include "demux.h" #include "internal.h" #include "avio_internal.h" #include "id3v2.h" diff --git a/libavformat/idcin.c b/libavformat/idcin.c index c92ed2c237..1560d58e39 100644 --- a/libavformat/idcin.c +++ b/libavformat/idcin.c @@ -72,6 +72,7 @@ #include "libavutil/imgutils.h" #include "libavutil/intreadwrite.h" #include "avformat.h" +#include "demux.h" #include "internal.h" #define HUFFMAN_TABLE_SIZE (64 * 1024) diff --git a/libavformat/imfdec.c b/libavformat/imfdec.c index 2fe79dfbad..73baa9739c 100644 --- a/libavformat/imfdec.c +++ b/libavformat/imfdec.c @@ -63,6 +63,7 @@ */ #include "avio_internal.h" +#include "demux.h" #include "imf.h" #include "internal.h" #include "libavcodec/packet.h" diff --git a/libavformat/internal.h b/libavformat/internal.h index 16f84374f7..c123c8d1ae 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -460,21 +460,6 @@ do {\ } while(0) #endif -#define RELATIVE_TS_BASE (INT64_MAX - (1LL << 48)) - -static av_always_inline int is_relative(int64_t ts) -{ - return ts > (RELATIVE_TS_BASE - (1LL << 48)); -} - -/** - * Wrap a given time stamp, if there is an indication for an overflow - * - * @param st stream - * @param timestamp the time stamp to wrap - * @return resulting time stamp - */ -int64_t ff_wrap_timestamp(const AVStream *st, int64_t timestamp); void ff_flush_packet_queue(AVFormatContext *s); @@ -509,8 +494,6 @@ char *ff_data_to_hex(char *buf, const uint8_t *src, int size, int lowercase); */ int ff_hex_to_data(uint8_t *data, const char *p); -void ff_read_frame_flush(AVFormatContext *s); - #define NTP_OFFSET 2208988800ULL #define NTP_OFFSET_US (NTP_OFFSET * 1000000ULL) @@ -611,22 +594,6 @@ void ff_parse_key_value(const char *str, ff_parse_key_val_cb callback_get_buf, */ int ff_find_stream_index(const AVFormatContext *s, int id); -/** - * Internal version of av_index_search_timestamp - */ -int ff_index_search_timestamp(const AVIndexEntry *entries, int nb_entries, - int64_t wanted_timestamp, int flags); - -/** - * Internal version of av_add_index_entry - */ -int ff_add_index_entry(AVIndexEntry **index_entries, - int *nb_index_entries, - unsigned int *index_entries_allocated_size, - int64_t pos, int64_t timestamp, int size, int distance, int flags); - -void ff_configure_buffers_for_index(AVFormatContext *s, int64_t time_tolerance); - /** * Add a new chapter. * @@ -641,52 +608,10 @@ void ff_configure_buffers_for_index(AVFormatContext *s, int64_t time_tolerance); AVChapter *avpriv_new_chapter(AVFormatContext *s, int64_t id, AVRational time_base, int64_t start, int64_t end, const char *title); -/** - * Ensure the index uses less memory than the maximum specified in - * AVFormatContext.max_index_size by discarding entries if it grows - * too large. - */ -void ff_reduce_index(AVFormatContext *s, int stream_index); - enum AVCodecID ff_guess_image2_codec(const char *filename); const AVCodec *ff_find_decoder(AVFormatContext *s, const AVStream *st, enum AVCodecID codec_id); -/** - * Perform a binary search using av_index_search_timestamp() and - * AVInputFormat.read_timestamp(). - * - * @param target_ts target timestamp in the time base of the given stream - * @param stream_index stream number - */ -int ff_seek_frame_binary(AVFormatContext *s, int stream_index, - int64_t target_ts, int flags); - -/** - * Update cur_dts of all streams based on the given timestamp and AVStream. - * - * Stream ref_st unchanged, others set cur_dts in their native time base. - * Only needed for timestamp wrapping or if (dts not set and pts!=dts). - * @param timestamp new dts expressed in time_base of param ref_st - * @param ref_st reference stream giving time_base of param timestamp - */ -void avpriv_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp); - -int ff_find_last_ts(AVFormatContext *s, int stream_index, int64_t *ts, int64_t *pos, - int64_t (*read_timestamp)(struct AVFormatContext *, int , int64_t *, int64_t )); - -/** - * Perform a binary search using read_timestamp(). - * - * @param target_ts target timestamp in the time base of the given stream - * @param stream_index stream number - */ -int64_t ff_gen_search(AVFormatContext *s, int stream_index, - int64_t target_ts, int64_t pos_min, - int64_t pos_max, int64_t pos_limit, - int64_t ts_min, int64_t ts_max, - int flags, int64_t *ts_ret, - int64_t (*read_timestamp)(struct AVFormatContext *, int , int64_t *, int64_t )); /** * Set the time base and wrapping info for a given stream. This will be used @@ -717,15 +642,6 @@ int ff_add_param_change(AVPacket *pkt, int32_t channels, */ int ff_framehash_write_header(AVFormatContext *s); -/** - * Read a transport packet from a media file. - * - * @param s media file handle - * @param pkt is filled - * @return 0 if OK, AVERROR_xxx on error - */ -int ff_read_packet(AVFormatContext *s, AVPacket *pkt); - /** * Add an attached pic to an AVStream. * @@ -819,16 +735,6 @@ int ff_alloc_extradata(AVCodecParameters *par, int size); */ int ff_get_extradata(AVFormatContext *s, AVCodecParameters *par, AVIOContext *pb, int size); -/** - * add frame for rfps calculation. - * - * @param dts timestamp of the i-th frame - * @return 0 if OK, AVERROR_xxx on error - */ -int ff_rfps_add_frame(AVFormatContext *ic, AVStream *st, int64_t dts); - -void ff_rfps_calculate(AVFormatContext *ic); - /** * Copies the whilelists from one context to the other */ @@ -880,24 +786,4 @@ void ff_format_set_url(AVFormatContext *s, char *url); void avpriv_register_devices(const AVOutputFormat * const o[], const AVInputFormat * const i[]); -/** - * Rescales a timestamp and the endpoints of an interval to which the temstamp - * belongs, from a timebase `tb_in` to a timebase `tb_out`. - * - * The upper (lower) bound of the output interval is rounded up (down) such that - * the output interval always falls within the intput interval. The timestamp is - * rounded to the nearest integer and halfway cases away from zero, and can - * therefore fall outside of the output interval. - * - * Useful to simplify the rescaling of the arguments of AVInputFormat::read_seek2() - * - * @param[in] tb_in Timebase of the input `min_ts`, `ts` and `max_ts` - * @param[in] tb_out Timebase of the ouput `min_ts`, `ts` and `max_ts` - * @param[in,out] min_ts Lower bound of the interval - * @param[in,out] ts Timestamp - * @param[in,out] max_ts Upper bound of the interval - */ -void ff_rescale_interval(AVRational tb_in, AVRational tb_out, - int64_t *min_ts, int64_t *ts, int64_t *max_ts); - #endif /* AVFORMAT_INTERNAL_H */ diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index d97fc33d44..4715f1b7d4 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -55,6 +55,7 @@ #include "avformat.h" #include "avio_internal.h" +#include "demux.h" #include "dovi_isom.h" #include "internal.h" #include "isom.h" diff --git a/libavformat/mca.c b/libavformat/mca.c index d8278ebe72..74654c3b39 100644 --- a/libavformat/mca.c +++ b/libavformat/mca.c @@ -22,6 +22,7 @@ #include "libavutil/intreadwrite.h" #include "avformat.h" #include "avio_internal.h" +#include "demux.h" #include "internal.h" typedef struct MCADemuxContext { diff --git a/libavformat/mlvdec.c b/libavformat/mlvdec.c index a02b190620..db3b77bb9b 100644 --- a/libavformat/mlvdec.c +++ b/libavformat/mlvdec.c @@ -24,12 +24,11 @@ * Magic Lantern Video (MLV) demuxer */ -#include "libavutil/eval.h" #include "libavutil/imgutils.h" #include "libavutil/intreadwrite.h" #include "libavutil/rational.h" #include "avformat.h" -#include "avio_internal.h" +#include "demux.h" #include "internal.h" #include "riff.h" diff --git a/libavformat/mov.c b/libavformat/mov.c index 24cce47884..c59a474b7c 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -36,11 +36,9 @@ #include "libavutil/intreadwrite.h" #include "libavutil/intfloat.h" #include "libavutil/mathematics.h" -#include "libavutil/time_internal.h" #include "libavutil/avassert.h" #include "libavutil/avstring.h" #include "libavutil/dict.h" -#include "libavutil/display.h" #include "libavutil/opt.h" #include "libavutil/aes.h" #include "libavutil/aes_ctr.h" @@ -49,7 +47,6 @@ #include "libavutil/spherical.h" #include "libavutil/stereo3d.h" #include "libavutil/timecode.h" -#include "libavutil/dovi_meta.h" #include "libavcodec/ac3tab.h" #include "libavcodec/flac.h" #include "libavcodec/hevc.h" @@ -58,6 +55,7 @@ #include "avformat.h" #include "internal.h" #include "avio_internal.h" +#include "demux.h" #include "dovi_isom.h" #include "riff.h" #include "isom.h" diff --git a/libavformat/mp3dec.c b/libavformat/mp3dec.c index f617348b2e..458d6dbd03 100644 --- a/libavformat/mp3dec.c +++ b/libavformat/mp3dec.c @@ -20,14 +20,13 @@ */ #include "libavutil/opt.h" -#include "libavutil/avstring.h" #include "libavutil/intreadwrite.h" -#include "libavutil/crc.h" #include "libavutil/dict.h" #include "libavutil/mathematics.h" #include "avformat.h" #include "internal.h" #include "avio_internal.h" +#include "demux.h" #include "id3v2.h" #include "id3v1.h" #include "replaygain.h" diff --git a/libavformat/mpc8.c b/libavformat/mpc8.c index 03c67907b9..2822a08b55 100644 --- a/libavformat/mpc8.c +++ b/libavformat/mpc8.c @@ -23,6 +23,7 @@ #include "libavcodec/unary.h" #include "apetag.h" #include "avformat.h" +#include "demux.h" #include "internal.h" #include "avio_internal.h" diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c index d696183a73..864b08d8f8 100644 --- a/libavformat/mpeg.c +++ b/libavformat/mpeg.c @@ -24,6 +24,7 @@ #include "libavutil/channel_layout.h" #include "avformat.h" #include "avio_internal.h" +#include "demux.h" #include "internal.h" #include "mpeg.h" diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index 49f7735123..6e761c07f1 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -39,6 +39,7 @@ #include "mpegts.h" #include "internal.h" #include "avio_internal.h" +#include "demux.h" #include "mpeg.h" #include "isom.h" #if CONFIG_ICONV diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index 30dd40749c..6a22c33995 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -59,6 +59,7 @@ #include "libavutil/opt.h" #include "avformat.h" #include "avlanguage.h" +#include "demux.h" #include "internal.h" #include "mxf.h" diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c index 6611fbc1d7..0db3d03f6c 100644 --- a/libavformat/nutdec.c +++ b/libavformat/nutdec.c @@ -29,6 +29,7 @@ #include "libavutil/tree.h" #include "libavcodec/bytestream.h" #include "avio_internal.h" +#include "demux.h" #include "isom.h" #include "nut.h" #include "riff.h" diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c index 87f178bb7b..3b19e0bd89 100644 --- a/libavformat/oggdec.c +++ b/libavformat/oggdec.c @@ -32,10 +32,10 @@ #include "libavutil/avassert.h" #include "libavutil/intreadwrite.h" #include "avio_internal.h" +#include "demux.h" #include "oggdec.h" #include "avformat.h" #include "internal.h" -#include "vorbiscomment.h" #define MAX_PAGE_SIZE 65307 #define DECODER_BUFFER_SIZE MAX_PAGE_SIZE diff --git a/libavformat/oggdec.h b/libavformat/oggdec.h index 1d28e50aa8..43df23f4cb 100644 --- a/libavformat/oggdec.h +++ b/libavformat/oggdec.h @@ -26,7 +26,6 @@ #define AVFORMAT_OGGDEC_H #include "avformat.h" -#include "metadata.h" struct ogg_codec { const int8_t *magic; diff --git a/libavformat/options.c b/libavformat/options.c index 14ae55e3fd..d306c86c63 100644 --- a/libavformat/options.c +++ b/libavformat/options.c @@ -19,6 +19,7 @@ */ #include "avformat.h" #include "avio_internal.h" +#include "demux.h" #include "internal.h" #include "libavcodec/avcodec.h" diff --git a/libavformat/rmdec.c b/libavformat/rmdec.c index cb0ca31f40..881d7002ad 100644 --- a/libavformat/rmdec.c +++ b/libavformat/rmdec.c @@ -22,13 +22,13 @@ #include #include "libavutil/avassert.h" -#include "libavutil/avstring.h" #include "libavutil/channel_layout.h" #include "libavutil/internal.h" #include "libavutil/intreadwrite.h" #include "libavutil/dict.h" #include "avformat.h" #include "avio_internal.h" +#include "demux.h" #include "internal.h" #include "rmsipr.h" #include "rm.h" diff --git a/libavformat/rtpdec_asf.c b/libavformat/rtpdec_asf.c index eb19e85351..72ead6975a 100644 --- a/libavformat/rtpdec_asf.c +++ b/libavformat/rtpdec_asf.c @@ -28,11 +28,11 @@ #include "libavutil/base64.h" #include "libavutil/avstring.h" #include "libavutil/intreadwrite.h" -#include "rtp.h" #include "rtpdec_formats.h" #include "rtsp.h" #include "asf.h" #include "avio_internal.h" +#include "demux.h" #include "internal.h" /** diff --git a/libavformat/seek.c b/libavformat/seek.c index 890aea7f8a..3b1c75f1b1 100644 --- a/libavformat/seek.c +++ b/libavformat/seek.c @@ -27,6 +27,7 @@ #include "avformat.h" #include "avio_internal.h" +#include "demux.h" #include "internal.h" void avpriv_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp) diff --git a/libavformat/tests/seek_utils.c b/libavformat/tests/seek_utils.c index cc679dca05..4cb94ad685 100644 --- a/libavformat/tests/seek_utils.c +++ b/libavformat/tests/seek_utils.c @@ -18,7 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "libavformat/internal.h" +#include "libavformat/demux.h" int main(void) { diff --git a/libavformat/vpk.c b/libavformat/vpk.c index 10c4cf0ebe..bfd49c6307 100644 --- a/libavformat/vpk.c +++ b/libavformat/vpk.c @@ -21,6 +21,7 @@ #include "libavutil/intreadwrite.h" #include "avformat.h" +#include "demux.h" #include "internal.h" typedef struct VPKDemuxContext { diff --git a/libavformat/wtvdec.c b/libavformat/wtvdec.c index 087b44273e..98128b7201 100644 --- a/libavformat/wtvdec.c +++ b/libavformat/wtvdec.c @@ -32,6 +32,7 @@ #include "libavutil/intfloat.h" #include "libavutil/time_internal.h" #include "avformat.h" +#include "demux.h" #include "internal.h" #include "wtv.h" #include "mpegts.h"