Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH] avformat/dhav: Factrorize some code in get_duration() (PR #20560)
@ 2025-09-20  0:08 michaelni via ffmpeg-devel
  0 siblings, 0 replies; only message in thread
From: michaelni via ffmpeg-devel @ 2025-09-20  0:08 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: michaelni

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2025-09-20  0:09 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-20  0:08 [FFmpeg-devel] [PATCH] avformat/dhav: Factrorize some code in get_duration() (PR #20560) michaelni via ffmpeg-devel

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