From patchwork Sat Dec 18 20:46:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John-Paul Stewart X-Patchwork-Id: 32711 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp2880546iog; Sat, 18 Dec 2021 12:46:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJyq8W5InbhEKFemhYpgTFFGyO2pxUYce5A6/KRfAhMS1ly97uJ0pfPb5lF4Eg6RCRFEeDCB X-Received: by 2002:aa7:c658:: with SMTP id z24mr8587031edr.187.1639860414791; Sat, 18 Dec 2021 12:46:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639860414; cv=none; d=google.com; s=arc-20160816; b=LfLVYTI+KaMKs0CHW+xf223kKkumrHveM0VTleoLyht3QlpROeZxiZU25GbP2r7WeV kdXPoDfJc5TDer19WwWFpVvGVWwzviNFJHFrdgjEaeuF9LpsyWN4ikejJV/WaPSnvJRl FRYXVJUOWNhAcxZS3Mzl51wkog+957N++0ZwCPgjjnoD73cE0pQLcZgSkEwY+8g9EeA1 d23mbw2ffuXH1Wv9PyS56HNVPCDYfHmuVHvvPwVjjcxvrk4VwASdibxjNgmMTuW+HEly DWQMKQ/sglzFWeK+i21hXko4xe140t3lYS0yUiOuuFyh/wFnYI2mKmO9CCDm7/fyXL/D zmhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:message-id:date:to:from :dkim-signature:delivered-to; bh=bHH0xbG4sRVLxfF06YLSvSwe4hz3NMgmDrBDwenLgUs=; b=Z6jTxXArV7Gs1W31zhCq1bxEAk0sTr1PeDHjBA7/wSytIepAszPBKME5WEFtbF1z90 Kv4Eejd36dYXeUii1+GIY8I2DR3c/KIipvN2VmSDQREGnW8FRFt3/zG5HYk7IR/2oxTS mMl7BZ40ohYcZr7h5YBXO2cvvBZO9nmilxUjv+lbQqdzXWHPae58VY96BU4wNRBIlbNW lpl9v8RPZpCHpEuR+FV91x3NX77ynOOgY5lEZWNkSYb8yPRNS0a1rYgA440ChqVl+pWF JeK5vpjk9OhM+E+Ijkwn8ch+Sir52Y03Yuhn+yBtMRTyTI3ItSMcJ+vSuhHQWzznG1Eb 7GrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@personalprojects.net header.s=20211201 header.b=UYNNlZgt; 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=QUARANTINE sp=REJECT dis=NONE) header.from=personalprojects.net Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id ga27si7685218ejc.20.2021.12.18.12.46.54; Sat, 18 Dec 2021 12:46:54 -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; dkim=neutral (body hash did not verify) header.i=@personalprojects.net header.s=20211201 header.b=UYNNlZgt; 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=QUARANTINE sp=REJECT dis=NONE) header.from=personalprojects.net Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 51F2068AF36; Sat, 18 Dec 2021 22:46:51 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail.personalprojects.net (mail.personalprojects.net [51.79.67.80]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id AACA768AE51 for ; Sat, 18 Dec 2021 22:46:44 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=personalprojects.net; s=20211201; h=Content-Transfer-Encoding:MIME-Version: Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=R9LA7k7ImU0eiXlezcdkb0KUxpnEqXJWBst4V2UwADg=; b=UYNNlZgtTIHySvEsgEyYaQyxH+ WmsH1GFskyaD0yY4AZ1cvZmm0DwMOUaB96wthE+FEHwbt6LFXLd0RQ5ffYGmACKB31LqM2f5TfPA9 sYBgy6VTbgEd19edM/yQx7SjcyI05yNoiot3zkUtgkP1B0FmQKytFBgBS+xm/zhHBDbs=; Received: from bras-base-simcon3012w-grc-05-64-231-188-105.dsl.bell.ca ([64.231.188.105] helo=courtney.binaryfoundry.ca) by mail.personalprojects.net with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mygbL-0005m3-7I for ffmpeg-devel@ffmpeg.org; Sat, 18 Dec 2021 15:46:43 -0500 From: John-Paul Stewart To: ffmpeg-devel@ffmpeg.org Date: Sat, 18 Dec 2021 15:46:27 -0500 Message-Id: <20211218204628.22664-1-jpstewart@personalprojects.net> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/2] avformat/mvdec: read frame rate from data stream 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: oEFtYu82i8CY Prior to this patch, for version 2 of the file format the frame rate was hard-coded at 15 fps. This uses the 64-bit floating-point value from the data stream, similar to what is already done for version 3 of the file format (around line 206). Signed-off-by: John-Paul Stewart --- libavformat/mvdec.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/libavformat/mvdec.c b/libavformat/mvdec.c index 5d184f20a4..a5c5b205a6 100644 --- a/libavformat/mvdec.c +++ b/libavformat/mvdec.c @@ -26,6 +26,7 @@ #include "libavutil/channel_layout.h" #include "libavutil/eval.h" +#include "libavutil/intfloat.h" #include "libavutil/intreadwrite.h" #include "libavutil/rational.h" @@ -300,8 +301,9 @@ static int mv_read_header(AVFormatContext *avctx) uint64_t timestamp; int v; uint32_t bytes_per_sample; + AVRational fps; - avio_skip(pb, 22); + avio_skip(pb, 10); /* allocate audio track first to prevent unnecessary seeking * (audio packet always precede video packet for a given frame) */ @@ -312,9 +314,11 @@ static int mv_read_header(AVFormatContext *avctx) vst = avformat_new_stream(avctx, NULL); if (!vst) return AVERROR(ENOMEM); - avpriv_set_pts_info(vst, 64, 1, 15); + fps = av_d2q(av_int2double(avio_rb64(pb)), INT_MAX); + avpriv_set_pts_info(vst, 64, fps.den, fps.num); + avio_skip(pb, 4); vst->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; - vst->avg_frame_rate = av_inv_q(vst->time_base); + vst->avg_frame_rate = fps; vst->nb_frames = avio_rb32(pb); v = avio_rb32(pb); switch (v) {