From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id B161142972 for ; Sat, 7 May 2022 11:31:17 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id DA95868B445; Sat, 7 May 2022 14:29:40 +0300 (EEST) 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 1649A68B278 for ; Sat, 7 May 2022 14:29:39 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TQdnRLFL0d7it9h45SafswTm5RWG60UGez0yion+YC+vev5YU/yh3BvWSQaq+7u2nxxZzU9uPpOVUia6PXQYiI5ssnP6m87wYKO16kP+T2wPKNy8JqyBhjnj53Uhdzv5lDt8clLKoKWO/t5oSGToGXfBGE7LCmuZRW/nsbOb4SzYgPzO/zNOgvajvjgf/9mJ6zIu1yWiUxr8KDNkwGvMqMQf+4XZ8ymLJyrNCwMHEgu3metgzZ4g2bilAoUeByYmcXPrNF6+se3b32LSSdvxxh4hOOy+hasBm5wtYbvSg/LG+RrHyy/u/SBUD+Uf5MI2GM6tjy7Yk5pzaiEAZVMYJQ== 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=45OAZDjzxBPdEtp3jVp5c8/rzxVATULFhSA/Kr5j09o=; b=abWvVtUp8iVQvJaxtDwxjj4iHXi44auUO9tfiGPPN1ZMhJ+t35rHwfY5oNiXCr/04LE+spopkw6fqUnhcA4Yc8GQdirqNc9U/QWoNpURiZCGNOkO3xHICMUdTnrwAxncLaXCrqya806oDN93z5u0K6VrJUE8MHoUyYrMgsp5VdRlggirViflKvhed8/usiw2W9rYVszL41q8B5idc7stZjR0mN0V4Am1Fy42YuYKkMbW0Z2Au1Y2MFHY1oCqyS15nOnQ5iYn2y7FBbgxaYGqzVTlKxpl9VgjZZCkmmlG5gZcJMMs18USQ1m5YgteCjYg5R1q+yCejjIMqAEyko+zbg== 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=45OAZDjzxBPdEtp3jVp5c8/rzxVATULFhSA/Kr5j09o=; b=DPLHhug/dJNJPtaNmrq7EfkH8V79UWFDiNdPmVhbsC9nr2JDI9hi/a5O98UXTNRMTX2E0FEMZfi3xikq25rYpxjl1RZ0zyl53u9FYpId2xGqlWgOiWMb4kdJd0fRUnmvMU7rpi9hGt1Qn6ocpIX7NGtbVBUUrgywRbjZc/++o7NqnUDXFHMHaajgxetf88eMMGxXEY6JpQqQDiiHuc5NoCvbuxlSIXrVORHcmGB34kXn4qA+xYlje0iVof3PV6aOiEbi8Ebl8GRT4Go8m30TR43UPGV8EFCdPSMxFdmgeMKWGL0IsgpIGuV4aKWxME5zXMu3+zNhe5xGTnUW5/vHMg== 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:34 +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:34 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sat, 7 May 2022 13:28:02 +0200 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [8jph9hl/afl5UDQgVl6w6encNSvMlKdx] 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-15-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4c2634d4-3660-43db-ae34-08da301cdbd1 X-MS-Exchange-SLBlob-MailProps: S/btQ8cKWiRIovyFjHwHllp74iOQFItwz8FNp4PLGShweW2Iwd6Rpk8u29bcbar+MpGKV79BrhGag/MHNfgFlhQapESHRDuht4wmqvYrJDdh7dhM/OZhEcdTKNmWVY5UjZkeGeBFpMxh6Jq7xsmh+EOSABhP43452oVIchSmAEptP8Gt4bSZURGo9NA0wApuejkyZenrHoq+T1M27KkTyItXfWtbCXtnIOgwn44b0sbWoRGRY/2MtXUymXWCgZINmRHUeIrUEv/StuFxts99qZ9NM/fXgHUBzfZXtjB/fCUkAAdENKFpOha1IrdDN1lNUDIq4gq85oo87lrzZKFn90iTVnSM7n8tvYvh5fb2WgiLGJW6C5OvPub5UldkTgaXFkabGlo2tAfgRybi8QmOfPheWEakBLIvK5SEVKwcuLKxLLqwu+Hx2EwqMYRruacsA4/c7TPY/JRRNt6gloSRJGOspreaHcvhCreopb/ODnLji/ULZrE2J+NxC8TEPqWovwi5yJeJoHlr3fQCVjBB0iBYtvhW+oVX+EqydIsWVTyUznNliuEDTODzkeAz3/q+aFaq5eKopTRD2cGGI0voFzQ7akTkikkyep1xIiI6IFv7Pr8/MTFItqEa7OKUCNjU1XOJbUU/tQE3L/f6od+u4vm6U/fu3Pv3xJrbVemcjPduKHbXAUTC/D+mZiRpYaw34VVor7Gux3V9ZK7ciWQKK87zfkMr/lbxs7U8gxiEMPvyE/oKcR06SvgPsXl1buhz+W+DG9olCJc= X-MS-TrafficTypeDiagnostic: DB6PR0102MB2663:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hYI6g/RMyYpo1Og9FwRASnqzbGKajbULIm+P+YyrzDEdI6cmhHPRURP3oyxurepM9DhG6bDZ65a1VDSLnXuBhyMpO/+mMqwcZxg6TceudRGRgSCRrecZmJH0yFIKRuXG9UOWqly0hjS6oj5T4kiq64Qw7QuIXyMqGYn6N/EUqVphuj9WS3qLWd/Swv9Y3TTJJy3AJuDKYAuLWaL1+L6SdslXjGOHUwU7ZxPMcQJMrHbS+q9Sx8xmJCZ0Bq+9DwNoVnzJClJuiyWLeLPZnSHsZcEyRsxWZsc9YilC6I+ZR0OaGQWAD5wt8QX7X96QSwgt0qIEsb/iY4MLZimKfA36eQ9PqV0dVUdUEDuA4N4bbLTCHYU800RkLKoUmgKmjCoUSMEVyZsRMINnZac8pcOwuF4bQJOXiz4LHi0O5qMDNJTPWE41XrtvNvfV75T4px/oC/ocVW1EcoRxPKCx7FeQZ3mfjdeZAJbbxlwpNC5OCze4/rlu9zt33TfbkDVnT0I2z5EUl3tSAT7LhW/d+9QqpEykk6Ll8lRtVi8gspwGZfE572El0reNVznlGPgrn4QtKkv/4rzjgKHWmtbhkEaLcinKgxWJWiaYU4Obtk2lMANvxm3AMu+gosa60RaMc45/ X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?tM0zfG8WFO5h4eM6GTrK9aBfX/DOw3IFB5tMxxO25yNghaXw4ryPakTMy91f?= =?us-ascii?Q?MYE4ss4ysMLc9vbXamWskN9jlDuxXeS9zrQ+7CTOmE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t8GeUNiGH4dXNPpUkole1PO3HfXG+RrUhiMEVANQktg9DT70WWRja?= =?us-ascii?Q?R20l6Ol1NSofe2ktZkmmWBaKcFJTthjLMJhwHqn5OcIaIpyquul8+TidYoe5?= =?us-ascii?Q?+g4cp885ZszRjCOBCzZnAVSOsxxdhRB0/AkOa/ScUDigKWfn5n4ixDEtF54m?= =?us-ascii?Q?cFdvQvU5cG+i2UEV6USuT9nBEWMVa5KBN/FWLsHIsNMG25Ku9ptMrmakhOAi?= =?us-ascii?Q?XuV4bP6QssVYY1fF5ZrOk+fEMhW6MOKpgncc1c6LyJW6nRHRmd/7N3gtr40A?= =?us-ascii?Q?yYrqOgpoxBhdPd+DdZfujEI3r+oPtgcv0F+WZ2gu1vICFdifge9gfJTcXh2Z?= =?us-ascii?Q?Mi7DHd8z95H/dGDZtDrBMkUBYJoXRc033S8oHj8zpzQraTZ7jQBbSgC6O8+6?= =?us-ascii?Q?zeLuZFucjFMK1umSNhels1BOQC3n8KaofbG1btOaq1X4XtzfJ4K+p9578a19?= =?us-ascii?Q?ODGlIwJNTlv01Mj+6MB0+2E18z4l6buO?= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4c2634d4-3660-43db-ae34-08da301cdbd1 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:34.1531 (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 16/44] avformat/internal: Move definition of FFStream->info to demux.h 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: It is only used by avformat_find_stream_info(). Signed-off-by: Andreas Rheinhardt --- libavformat/demux.c | 45 +++++++++++++++++++++--------------------- libavformat/demux.h | 29 +++++++++++++++++++++++++++ libavformat/internal.h | 30 +--------------------------- libavformat/utils.c | 1 + 4 files changed, 54 insertions(+), 51 deletions(-) diff --git a/libavformat/demux.c b/libavformat/demux.c index 5d83d81665..1620716716 100644 --- a/libavformat/demux.c +++ b/libavformat/demux.c @@ -2173,59 +2173,60 @@ static int tb_unreliable(AVCodecContext *c) int ff_rfps_add_frame(AVFormatContext *ic, AVStream *st, int64_t ts) { FFStream *const sti = ffstream(st); - int64_t last = sti->info->last_dts; + FFStreamInfo *info = sti->info; + int64_t last = info->last_dts; if ( ts != AV_NOPTS_VALUE && last != AV_NOPTS_VALUE && ts > last && ts - (uint64_t)last < INT64_MAX) { double dts = (is_relative(ts) ? ts - RELATIVE_TS_BASE : ts) * av_q2d(st->time_base); int64_t duration = ts - last; - if (!sti->info->duration_error) - sti->info->duration_error = av_mallocz(sizeof(sti->info->duration_error[0])*2); - if (!sti->info->duration_error) + if (!info->duration_error) + info->duration_error = av_mallocz(sizeof(info->duration_error[0])*2); + if (!info->duration_error) return AVERROR(ENOMEM); // if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) // av_log(NULL, AV_LOG_ERROR, "%f\n", dts); for (int i = 0; i < MAX_STD_TIMEBASES; i++) { - if (sti->info->duration_error[0][1][i] < 1e10) { + if (info->duration_error[0][1][i] < 1e10) { int framerate = get_std_framerate(i); double sdts = dts*framerate/(1001*12); for (int j = 0; j < 2; j++) { int64_t ticks = llrint(sdts+j*0.5); double error = sdts - ticks + j*0.5; - sti->info->duration_error[j][0][i] += error; - sti->info->duration_error[j][1][i] += error*error; + info->duration_error[j][0][i] += error; + info->duration_error[j][1][i] += error*error; } } } - if (sti->info->rfps_duration_sum <= INT64_MAX - duration) { - sti->info->duration_count++; - sti->info->rfps_duration_sum += duration; + if (info->rfps_duration_sum <= INT64_MAX - duration) { + info->duration_count++; + info->rfps_duration_sum += duration; } - if (sti->info->duration_count % 10 == 0) { - int n = sti->info->duration_count; + if (info->duration_count % 10 == 0) { + int n = info->duration_count; for (int i = 0; i < MAX_STD_TIMEBASES; i++) { - if (sti->info->duration_error[0][1][i] < 1e10) { - double a0 = sti->info->duration_error[0][0][i] / n; - double error0 = sti->info->duration_error[0][1][i] / n - a0*a0; - double a1 = sti->info->duration_error[1][0][i] / n; - double error1 = sti->info->duration_error[1][1][i] / n - a1*a1; + if (info->duration_error[0][1][i] < 1e10) { + double a0 = info->duration_error[0][0][i] / n; + double error0 = info->duration_error[0][1][i] / n - a0*a0; + double a1 = info->duration_error[1][0][i] / n; + double error1 = info->duration_error[1][1][i] / n - a1*a1; if (error0 > 0.04 && error1 > 0.04) { - sti->info->duration_error[0][1][i] = 2e10; - sti->info->duration_error[1][1][i] = 2e10; + info->duration_error[0][1][i] = 2e10; + info->duration_error[1][1][i] = 2e10; } } } } // ignore the first 4 values, they might have some random jitter - if (sti->info->duration_count > 3 && is_relative(ts) == is_relative(last)) - sti->info->duration_gcd = av_gcd(sti->info->duration_gcd, duration); + if (info->duration_count > 3 && is_relative(ts) == is_relative(last)) + info->duration_gcd = av_gcd(info->duration_gcd, duration); } if (ts != AV_NOPTS_VALUE) - sti->info->last_dts = ts; + info->last_dts = ts; return 0; } diff --git a/libavformat/demux.h b/libavformat/demux.h index f003d81f52..c667f304a5 100644 --- a/libavformat/demux.h +++ b/libavformat/demux.h @@ -26,6 +26,35 @@ #include "libavcodec/packet.h" #include "avformat.h" +#define MAX_STD_TIMEBASES (30*12+30+3+6) +typedef struct FFStreamInfo { + int64_t last_dts; + int64_t duration_gcd; + int duration_count; + int64_t rfps_duration_sum; + double (*duration_error)[2][MAX_STD_TIMEBASES]; + int64_t codec_info_duration; + int64_t codec_info_duration_fields; + int frame_delay_evidence; + + /** + * 0 -> decoder has not been searched for yet. + * >0 -> decoder found + * <0 -> decoder with codec_id == -found_decoder has not been found + */ + int found_decoder; + + int64_t last_duration; + + /** + * Those are used for average framerate estimation. + */ + int64_t fps_first_dts; + int fps_first_dts_idx; + int64_t fps_last_dts; + int fps_last_dts_idx; +} FFStreamInfo; + #define RELATIVE_TS_BASE (INT64_MAX - (1LL << 48)) static av_always_inline int is_relative(int64_t ts) diff --git a/libavformat/internal.h b/libavformat/internal.h index c123c8d1ae..b72c051afe 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -245,38 +245,10 @@ typedef struct FFStream { FFFrac *priv_pts; -#define MAX_STD_TIMEBASES (30*12+30+3+6) /** * Stream information used internally by avformat_find_stream_info() */ - struct { - int64_t last_dts; - int64_t duration_gcd; - int duration_count; - int64_t rfps_duration_sum; - double (*duration_error)[2][MAX_STD_TIMEBASES]; - int64_t codec_info_duration; - int64_t codec_info_duration_fields; - int frame_delay_evidence; - - /** - * 0 -> decoder has not been searched for yet. - * >0 -> decoder found - * <0 -> decoder with codec_id == -found_decoder has not been found - */ - int found_decoder; - - int64_t last_duration; - - /** - * Those are used for average framerate estimation. - */ - int64_t fps_first_dts; - int fps_first_dts_idx; - int64_t fps_last_dts; - int fps_last_dts_idx; - - } *info; + struct FFStreamInfo *info; AVIndexEntry *index_entries; /**< Only used if the format does not support seeking natively. */ diff --git a/libavformat/utils.c b/libavformat/utils.c index 5bda45d124..175f9caf8a 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -40,6 +40,7 @@ #include "avformat.h" #include "avio_internal.h" +#include "demux.h" #include "internal.h" #if CONFIG_NETWORK #include "network.h" -- 2.32.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".