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 E721343FD7 for ; Sun, 23 Apr 2023 18:47:03 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 07F6768BF05; Sun, 23 Apr 2023 21:47:01 +0300 (EEST) Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8D1B668A0A2 for ; Sun, 23 Apr 2023 21:46:55 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id DF637E84AE for ; Sun, 23 Apr 2023 20:46:21 +0200 (CEST) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id i5b-1pGtHDVo for ; Sun, 23 Apr 2023 20:46:19 +0200 (CEST) Received: from iq (iq [217.27.212.140]) by iq.passwd.hu (Postfix) with ESMTPS id D246AE6B32 for ; Sun, 23 Apr 2023 20:46:18 +0200 (CEST) Date: Sun, 23 Apr 2023 20:46:18 +0200 (CEST) From: Marton Balint To: FFmpeg development discussions and patches In-Reply-To: <20230415220558.16122-1-cus@passwd.hu> Message-ID: <27c1e46e-adc9-8159-2642-b15f418de8a@passwd.hu> References: <20230415220558.16122-1-cus@passwd.hu> MIME-Version: 1.0 Subject: Re: [FFmpeg-devel] [PATCH 1/6] avformat/mov: factorize reading creation time metadata 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-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On Sun, 16 Apr 2023, Marton Balint wrote: > Signed-off-by: Marton Balint > --- > libavformat/mov.c | 32 ++++++++++++-------------------- > 1 file changed, 12 insertions(+), 20 deletions(-) Will apply the series soon. Regards, Marton > > diff --git a/libavformat/mov.c b/libavformat/mov.c > index 057fd872b1..5d00ff6e8b 100644 > --- a/libavformat/mov.c > +++ b/libavformat/mov.c > @@ -1515,14 +1515,22 @@ static int mov_read_moof(MOVContext *c, AVIOContext *pb, MOVAtom atom) > return mov_read_default(c, pb, atom); > } > > -static void mov_metadata_creation_time(AVDictionary **metadata, int64_t time, void *logctx) > +static void mov_metadata_creation_time(MOVContext *c, AVIOContext *pb, AVDictionary **metadata, int version) > { > + int64_t time; > + if (version == 1) { > + time = avio_rb64(pb); > + avio_rb64(pb); > + } else { > + time = avio_rb32(pb); > + avio_rb32(pb); /* modification time */ > + } > if (time) { > if (time >= 2082844800) > time -= 2082844800; /* seconds between 1904-01-01 and Epoch */ > > if ((int64_t)(time * 1000000ULL) / 1000000 != time) { > - av_log(logctx, AV_LOG_DEBUG, "creation_time is not representable\n"); > + av_log(c->fc, AV_LOG_DEBUG, "creation_time is not representable\n"); > return; > } > > @@ -1537,7 +1545,6 @@ static int mov_read_mdhd(MOVContext *c, AVIOContext *pb, MOVAtom atom) > int version; > char language[4] = {0}; > unsigned lang; > - int64_t creation_time; > > if (c->fc->nb_streams < 1) > return 0; > @@ -1555,14 +1562,7 @@ static int mov_read_mdhd(MOVContext *c, AVIOContext *pb, MOVAtom atom) > return AVERROR_PATCHWELCOME; > } > avio_rb24(pb); /* flags */ > - if (version == 1) { > - creation_time = avio_rb64(pb); > - avio_rb64(pb); > - } else { > - creation_time = avio_rb32(pb); > - avio_rb32(pb); /* modification time */ > - } > - mov_metadata_creation_time(&st->metadata, creation_time, c->fc); > + mov_metadata_creation_time(c, pb, &st->metadata, version); > > sc->time_scale = avio_rb32(pb); > if (sc->time_scale <= 0) { > @@ -1587,18 +1587,10 @@ static int mov_read_mdhd(MOVContext *c, AVIOContext *pb, MOVAtom atom) > static int mov_read_mvhd(MOVContext *c, AVIOContext *pb, MOVAtom atom) > { > int i; > - int64_t creation_time; > int version = avio_r8(pb); /* version */ > avio_rb24(pb); /* flags */ > > - if (version == 1) { > - creation_time = avio_rb64(pb); > - avio_rb64(pb); > - } else { > - creation_time = avio_rb32(pb); > - avio_rb32(pb); /* modification time */ > - } > - mov_metadata_creation_time(&c->fc->metadata, creation_time, c->fc); > + mov_metadata_creation_time(c, pb, &c->fc->metadata, version); > c->time_scale = avio_rb32(pb); /* time scale */ > if (c->time_scale <= 0) { > av_log(c->fc, AV_LOG_ERROR, "Invalid mvhd time scale %d, defaulting to 1\n", c->time_scale); > -- > 2.35.3 > > _______________________________________________ > 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". > _______________________________________________ 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".