From: michaelni via ffmpeg-devel <ffmpeg-devel@ffmpeg.org>
To: ffmpeg-devel@ffmpeg.org
Cc: michaelni <code@ffmpeg.org>
Subject: [FFmpeg-devel] [PATCH] avformat/dhav: Factrorize some code in get_duration() (PR #20560)
Date: Sat, 20 Sep 2025 00:08:44 -0000
Message-ID: <175832692680.25.9462233820252835352@463a07221176> (raw)
PR #20560 opened by michaelni
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20560
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20560.patch
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
>From 798c4c50d53a01eb24f172575869738c9e26d93c Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <michael@niedermayer.cc>
Date: Sat, 20 Sep 2025 01:56:20 +0200
Subject: [PATCH] avformat/dhav: Factrorize some code in get_duration()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
libavformat/dhav.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/libavformat/dhav.c b/libavformat/dhav.c
index 21c9c530d6..e28631770d 100644
--- a/libavformat/dhav.c
+++ b/libavformat/dhav.c
@@ -242,7 +242,7 @@ static int64_t get_duration(AVFormatContext *s)
int64_t start_pos = avio_tell(s->pb);
int64_t pos = -1;
- int64_t start = 0, end = 0;
+ int64_t start = 0;
struct tm timeinfo;
uint8_t *buffer;
int64_t buffer_size;
@@ -250,6 +250,7 @@ static int64_t get_duration(AVFormatContext *s)
int64_t offset;
unsigned date;
int64_t size = avio_size(s->pb);
+ int64_t ret = 0;
if (start_pos + 16 > size)
return 0;
@@ -284,17 +285,12 @@ static int64_t get_duration(AVFormatContext *s)
date = AV_RL32(buffer + (pos - buffer_pos) + 16);
get_timeinfo(date, &timeinfo);
- end = av_timegm(&timeinfo) * 1000LL;
- av_freep(&buffer);
-
- avio_seek(s->pb, start_pos, SEEK_SET);
-
- return end - start;
+ ret = av_timegm(&timeinfo) * 1000LL - start;
fail:
av_freep(&buffer);
avio_seek(s->pb, start_pos, SEEK_SET);
- return 0;
+ return ret;
}
static int dhav_read_header(AVFormatContext *s)
--
2.49.1
_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org
reply other threads:[~2025-09-20 0:09 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=175832692680.25.9462233820252835352@463a07221176 \
--to=ffmpeg-devel@ffmpeg.org \
--cc=code@ffmpeg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git