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 2D7E048651 for ; Sat, 13 Jan 2024 02:05:55 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 69B9C68CE34; Sat, 13 Jan 2024 04:05:52 +0200 (EET) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05olkn2032.outbound.protection.outlook.com [40.92.90.32]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7B36168CD6D for ; Sat, 13 Jan 2024 04:05:46 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CgkNhG6SB49gotDzyiytV03z69iZ9QjCwR87S3M/OYPIM9iZBomwg2V3JYafPW/cHcBdAFatQnMtkYXyBHtF12M5BXD3O8WaUME+Byi5fz05S+Ekz4jzHwmYetM4BmCCq6UldFUnBC8mJA32Ym1kmOR4CLl2DyTtD03DjDcMCA7RXcOHVi5JmbSj7qjB+mk+f5QCQAoZJ7VHMaDSDACapv034syRX8TabNSNkVIdhJ19mVBv89dWMRZ17PMllRCDNGZMbWc9htnyn3/hujE8kLvKNfl8JupbdDvTlxe+cmqYLDedPTRvECCqIma/bypYPWcejKRTxTGjCeMZuZh82A== 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=z7Uor7ElTtloRreVJ4XUC0Oaq1gqrCJpUuolJRSefRA=; b=LxJKrHqB2pV7q2IAF1rq3ztHCSh2KPHZQ8vvygkj8sASeCV/q3BB1nt4Bu1gW42V3wYjefM1KqMxEdOu3vNnvco0viEV9mQJ7xNirmAkTPL1YGpfVV0mprqb/fZ3uECottCnYO0GGSCzCB7HvsPmLmld8Gdy2vr2dwnfzX13q58z51K2JodNJocHj1I+5mXpTy1Xyoal0UHok+Bxue4TZxmqwXExLHWjyT7acD83V1GpEm3vxcyxRTHg7qEzwMUU39i6HNymLyBexTpoTszxXThrQC8mmbR2q6xc5ekSYcuQGRB4wMQtJLsuOTR5d27GSXsq8zcLk0Ffz9kgWcyUUQ== 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=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=z7Uor7ElTtloRreVJ4XUC0Oaq1gqrCJpUuolJRSefRA=; b=WK8Fi7HejPnwGqHoEFPQEKivFf6ysgq68WdGNQksRfPhpLj34y3Q7eHF1IRORfNsAHHTTI60IOqXHA+DJX/7Z78gXSvceV0enItsVuyLA3mkIxd58NktWNDMORMoZ3nJd2Oy04ldQCez1BepHA8760p18kDyPA9wSd9CswsLvhNW+M3m7DY0Y6Etcq1FOeMi9v0uaXIhj09G9BHLLdxyy7ZvMQq0+vscxnQ6DefvYYUL2XMr1/bK5+v347Ow6t2dChWdUtJEzptfYOzK0fOFyR7bKW+OwymOtvjzBYLR2jKX/aLI9hYiQ9LtZtBuW9aJ7IIyrbVTRBERWdN7UrmucQ== Received: from PAVPR08MB9795.eurprd08.prod.outlook.com (2603:10a6:102:31f::12) by GV1PR08MB8132.eurprd08.prod.outlook.com (2603:10a6:150:90::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7181.17; Sat, 13 Jan 2024 02:05:43 +0000 Received: from PAVPR08MB9795.eurprd08.prod.outlook.com ([fe80::83f1:da95:eae9:6b96]) by PAVPR08MB9795.eurprd08.prod.outlook.com ([fe80::83f1:da95:eae9:6b96%7]) with mapi id 15.20.7181.015; Sat, 13 Jan 2024 02:05:42 +0000 From: aybe aybe To: FFmpeg development discussions and patches Thread-Topic: Re[2]: [FFmpeg-devel] [PATCH 4/4] avformat/psxstr: basic FPS detection instead of fixed value Thread-Index: AQHaPSnGZtTdwMTaEkSLcSFow4T3nLDSZu+AgASovYA= Date: Sat, 13 Jan 2024 02:05:42 +0000 Message-ID: References: <20240110025639.GR6420@pb2> In-Reply-To: <20240110025639.GR6420@pb2> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [NxNLU9K4yGzBXgmuM4Sb7XdPd2BzY5zx9W0V8IycsosUAORtuqhHTg==] x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PAVPR08MB9795:EE_|GV1PR08MB8132:EE_ x-ms-office365-filtering-correlation-id: e0c8a2ce-da1b-47d6-1342-08dc13dc256d x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 9ZYp/A12g/NKTEsC9abGRC/xa8Rilfk8I2DqjxClgMtDJOehGMt+J6PIzeMpDyAouSC8WJuavrJvpWC7csofszqRdzPbco6CCQsUZifdPS10nRTijLHbh3hnKlsmUC9EubpZwzQAd0FJhrH/Pse2g4PyhE63uWIWdtGL+SrISB9dIOj0oMpA2kGDX5oqkzjql32P4iaPJfkjhascIazkULHA+VMCt6fGBWUI3YkphGnlEkodYZkke/JXgAKgkAxbXY52R8j4tsQE8lfUsuLHYokGogL0nFTS9TvOX+A87vOZoqTV/YHMhMJ+WcIkQ1SCo1d9eAgTZmo1wOYWZerk2OZI4ToyJxut3m2ALxQp02zPgFjObvIxHmKyva78BHT0AGqnwSIMO0Ch5UfUTTF+FtR2N93bsfagfq3Ia/XRVKg2igs9jll3NcdF4TwhqkzhIJiWILoaEdMnBJX4JjpupthbT4J6VL/6cm5Lw3fDUlM8deDh/tAq0crxEjPojjGggF3mY6QlOjjwbI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Y2sxS3h3clJTeEpHbjBwVTRSQVlkR0hrM2wrMmNHMytTVkk2eHN2dkxN?= =?utf-8?Q?pByykrMe4561UsgPRzfX?= MIME-Version: 1.0 X-OriginatorOrg: sct-15-20-4755-11-msonline-outlook-37dd7.templateTenant X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PAVPR08MB9795.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: e0c8a2ce-da1b-47d6-1342-08dc13dc256d X-MS-Exchange-CrossTenant-originalarrivaltime: 13 Jan 2024 02:05:42.1060 (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: GV1PR08MB8132 X-Content-Filtered-By: Mailman/MimeDel 2.1.29 Subject: Re: [FFmpeg-devel] [PATCH 4/4] avformat/psxstr: basic FPS detection instead of fixed value 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 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: Sorry mate but I'm currently having a lot of trouble keeping in track with the mailing list... I thought emClient would be a savior but it isn't, it's buggy and confusing as hell. Have to check mailing list online, find mail in client so I can reply to it, really boring! Anyway... for the patch I simply followed what the previous author did Previous author did put 15 there and when played in VLC you get 15 FPS. Therefore, I concluded that it is indeed the right place where this should be updated. Format itself does not store the FPS, people would know in advance movie size/speed. But as mentioned before, it is sort of possible to 'detect' that, what I've done in the patch. A good source of information about the format is the following link: https://github.com/m35/jpsxdec/blob/readme/jpsxdec/PlayStation1_STR_format.txt My approach differs with the above in the sense that I assume min FPS is definitely right. And that works on the movies I have tested so far, it returns 25/30 for PAL/NTSC versions. ------ Original Message ------ >From "Michael Niedermayer" > To "FFmpeg development discussions and patches" > Date 1/10/2024 3:56:39 AM Subject Re: [FFmpeg-devel] [PATCH 4/4] avformat/psxstr: basic FPS detection instead of fixed value On Tue, Jan 02, 2024 at 03:14:19AM +0000, aybe aybe wrote: This fourth and last patch is an attempt at removing the hard-coded value of 15 FPS. In patch 1/4, although it would render video, the audio and video were not synchronized at all, now there are. In this approach I kept it simple, grab min/max possible rates, pick min, clamp to 15/30 just in case. It appears to work quite well, the right frame rate is picked up and both streams are in sync. (tested against Wipeout introduction for both PAL and NTSC versions). Besides, there have been significant findings over the years regarding that format, specifically: https://problemkaputt.de/psxspx-macroblock-decoder-mdec.htm https://github.com/m35/jpsxdec/blob/readme/jpsxdec/PlayStation1_STR_format.txt Maybe someone versed in this topic (I'm not) could further improve support of this format according these docs... Signed-off-by: aybe > --- libavformat/psxstr.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/libavformat/psxstr.c b/libavformat/psxstr.c index 306a690f52..98897acde3 100644 --- a/libavformat/psxstr.c +++ b/libavformat/psxstr.c @@ -52,6 +52,9 @@ #define STR_MAGIC (0x80010160) +#define MDEC_STR_FPS_MIN 15 +#define MDEC_STR_FPS_MAX 30 + typedef struct StrChannel { /* video parameters */ int video_stream_index; @@ -65,6 +68,10 @@ typedef struct StrDemuxContext { /* a STR file can contain up to 32 channels of data */ StrChannel channels[32]; + /* trivial FPS detection based on sectors per frame */ + int fps_min; /* slowest FPS found */ + int fps_max; /* fastest FPS found */ + int fps_val; /* nominal FPS value */ } StrDemuxContext; static const uint8_t sync_header[12] = {0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00}; @@ -150,6 +157,10 @@ static int str_read_header(AVFormatContext *s) str->channels[i].audio_stream_index= -1; } + str->fps_min = INT_MAX; + str->fps_max = INT_MIN; + str->fps_val = 0; + s->ctx_flags |= AVFMTCTX_NOHEADER; return 0; @@ -161,7 +172,7 @@ static int str_read_packet(AVFormatContext *s, AVIOContext *pb = s->pb; StrDemuxContext *str = s->priv_data; unsigned char sector[RAW_CD_SECTOR_SIZE]; - int channel, ret; + int channel, ret, sub_mode, idx_sect, num_sect; AVPacket *pkt; AVStream *st; @@ -178,6 +189,18 @@ static int str_read_packet(AVFormatContext *s, if (channel >= 32) return AVERROR_INVALIDDATA; + sub_mode = sector[0x12]; + idx_sect = AV_RL16(§or[0x1C]); + num_sect = AV_RL16(§or[0x1E]); + + /* compute FPS from sector count @ each new video frame */ + if (sub_mode & 0x02 && idx_sect == 0x00) { + int fps = 150 / num_sect; + str->fps_min = FFMIN(str->fps_min, fps); + str->fps_max = FFMAX(str->fps_max, fps); + str->fps_val = FFMIN(MDEC_STR_FPS_MAX, FFMAX(MDEC_STR_FPS_MIN, str->fps_min)); + } + switch (sector[0x12] & CDXA_TYPE_MASK) { case CDXA_TYPE_DATA: @@ -200,7 +223,7 @@ static int str_read_packet(AVFormatContext *s, st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); - avpriv_set_pts_info(st, 64, 1, 15); + avpriv_set_pts_info(st, 64, 1, str->fps_val); This is not a FPS value, avpriv_set_pts_info() sets the timebase in which timestamps are specified I dont know psxstr but can you explain what information there is in it about the video frames ? is there some sort of information that indicates when a frame is to be displayed ? that is like a timestamp ? thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Elect your leaders based on what they did after the last election, not based on what they say before an election. _______________________________________________ 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".