Skip to content

Commit 30179dc

Browse files
committed
fix net bluray seek slow bug
1 parent 5b814a5 commit 30179dc

1 file changed

Lines changed: 19 additions & 26 deletions

File tree

patches/ffmpeg-n6.1/0027-custom-bluray-fs_access-for-network-Blu-ray-Disc-and.patch

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
From 00deddc6742a443adc34314586e0186ee515f06d Mon Sep 17 00:00:00 2001
1+
From a4c4fdb6fd792792c0528fc4b99c6ab77d55725f Mon Sep 17 00:00:00 2001
22
From: qianlongxu <qianlongxu@gmail.com>
3-
Date: Thu, 20 Mar 2025 11:07:30 +0800
4-
Subject: [PATCH 27] custom bluray fs_access for network Blu-ray Disc and BDMV,
3+
Date: Thu, 20 Mar 2025 18:48:01 +0800
4+
Subject: [PATCH 27] custom bluray fs_access for network Blu-ray Disc and BDMV,
55
use cache improve performance
66

77
---
88
libavformat/Makefile | 2 +-
9-
libavformat/bluray.c | 154 ++++++++--
9+
libavformat/bluray.c | 148 +++++++--
1010
libavformat/bluray_custom_fs.c | 536 +++++++++++++++++++++++++++++++++
1111
libavformat/bluray_custom_fs.h | 33 ++
1212
libavformat/lrucache.c | 112 +++++++
1313
libavformat/lrucache.h | 30 ++
14-
6 files changed, 848 insertions(+), 19 deletions(-)
14+
6 files changed, 842 insertions(+), 19 deletions(-)
1515
create mode 100644 libavformat/bluray_custom_fs.c
1616
create mode 100644 libavformat/bluray_custom_fs.h
1717
create mode 100644 libavformat/lrucache.c
@@ -31,7 +31,7 @@ index 19ba54e..4184bfd 100644
3131
OBJS-$(CONFIG_CONCAT_PROTOCOL) += concat.o
3232
OBJS-$(CONFIG_CONCATF_PROTOCOL) += concat.o
3333
diff --git a/libavformat/bluray.c b/libavformat/bluray.c
34-
index 1845551..fa7b9bd 100644
34+
index 1845551..c162da3 100644
3535
--- a/libavformat/bluray.c
3636
+++ b/libavformat/bluray.c
3737
@@ -20,24 +20,29 @@
@@ -69,7 +69,7 @@ index 1845551..fa7b9bd 100644
6969
} BlurayContext;
7070

7171
#define OFFSET(x) offsetof(BlurayContext, x)
72-
@@ -106,24 +111,63 @@ static int bluray_close(URLContext *h)
72+
@@ -106,23 +111,56 @@ static int bluray_close(URLContext *h)
7373
if (bd->bd) {
7474
bd_close(bd->bd);
7575
}
@@ -84,7 +84,7 @@ index 1845551..fa7b9bd 100644
8484
+#define BLURAY_DEBUG_MASK 0xFFFFF //(0xFFFFF & ~DBG_STREAM)
8585
+
8686
+static void bluray_DebugHandler(const char *psz)
87-
{
87+
+{
8888
+ size_t len = strlen(psz);
8989
+ if (len < 1)
9090
+ return;
@@ -94,7 +94,7 @@ index 1845551..fa7b9bd 100644
9494
+
9595
+static int bluray_open(URLContext *h, const char *path, int flags,
9696
+ AVDictionary **options)
97-
+{
97+
{
9898
+#ifdef DEBUG_BLURAY
9999
+ bd_set_debug_mask(BLURAY_DEBUG_MASK);
100100
+ bd_set_debug_handler(bluray_DebugHandler);
@@ -108,15 +108,15 @@ index 1845551..fa7b9bd 100644
108108
- bd->bd = bd_open(diskname, NULL);
109109
- if (!bd->bd) {
110110
+ diskname = ff_urldecode(diskname, 0);
111-
+
111+
+
112112
+ fs_access *access = NULL;
113113
+ int is_file = av_strstart(diskname, "file://", NULL) || av_strstart(diskname, "/", NULL);
114-
+
114+
+
115115
+ // file protocl can't handle AVIO_FLAG_DIRECT flag,so file not create custom access
116116
+ if (!is_file) {
117117
+ access = create_bluray_custom_access(diskname, options, &h->interrupt_callback);
118118
+ }
119-
+
119+
+
120120
+ bd->bd = bd_open_fs(diskname, NULL, access);
121121
+
122122
+ if (!bd->bd || is_bluray_custom_access_cancelled(access)) {
@@ -128,16 +128,9 @@ index 1845551..fa7b9bd 100644
128128
}
129129
+ bd->access = access;
130130

131-
+ if (!is_file) {
132-
+ // set read packet buffer size is important! the default packet size is
133-
+ // 32768, when use smb2 protocol, download speed is limited to 2MB; but
134-
+ // when set the size to 1048576, download speed is 16MB;
135-
+ h->max_packet_size = 1048576;
136-
+ }
137131
/* check if disc can be played */
138132
if (check_disc_info(h) < 0) {
139-
return AVERROR(EIO);
140-
@@ -137,7 +181,7 @@ static int bluray_open(URLContext *h, const char *path, int flags)
133+
@@ -137,7 +175,7 @@ static int bluray_open(URLContext *h, const char *path, int flags)
141134
}
142135
*/
143136

@@ -146,7 +139,7 @@ index 1845551..fa7b9bd 100644
146139
num_title_idx = bd_get_titles(bd->bd, TITLES_RELEVANT, MIN_PLAYLIST_LENGTH);
147140
av_log(h, AV_LOG_INFO, "%d usable playlists:\n", num_title_idx);
148141
if (num_title_idx < 1) {
149-
@@ -150,26 +194,31 @@ static int bluray_open(URLContext *h, const char *path, int flags)
142+
@@ -150,26 +188,31 @@ static int bluray_open(URLContext *h, const char *path, int flags)
150143
int i;
151144
for (i = 0; i < num_title_idx; i++) {
152145
BLURAY_TITLE_INFO *info = bd_get_title_info(bd->bd, i, 0);
@@ -183,23 +176,23 @@ index 1845551..fa7b9bd 100644
183176
return AVERROR(EIO);
184177
}
185178

186-
@@ -182,7 +231,6 @@ static int bluray_open(URLContext *h, const char *path, int flags)
179+
@@ -182,7 +225,6 @@ static int bluray_open(URLContext *h, const char *path, int flags)
187180
if (bd->chapter > 1) {
188181
bd_seek_chapter(bd->bd, bd->chapter - 1);
189182
}
190183
-
191184
return 0;
192185
}
193186

194-
@@ -213,7 +261,6 @@ static int64_t bluray_seek(URLContext *h, int64_t pos, int whence)
187+
@@ -213,7 +255,6 @@ static int64_t bluray_seek(URLContext *h, int64_t pos, int whence)
195188
case SEEK_CUR:
196189
case SEEK_END:
197190
return bd_seek(bd->bd, pos);
198191
-
199192
case AVSEEK_SIZE:
200193
return bd_get_title_size(bd->bd);
201194
}
202-
@@ -222,13 +269,84 @@ static int64_t bluray_seek(URLContext *h, int64_t pos, int whence)
195+
@@ -222,13 +263,84 @@ static int64_t bluray_seek(URLContext *h, int64_t pos, int whence)
203196
return AVERROR(EINVAL);
204197
}
205198

@@ -287,7 +280,7 @@ index 1845551..fa7b9bd 100644
287280
};
288281
diff --git a/libavformat/bluray_custom_fs.c b/libavformat/bluray_custom_fs.c
289282
new file mode 100644
290-
index 0000000..f51bac0
283+
index 0000000..70cb00f
291284
--- /dev/null
292285
+++ b/libavformat/bluray_custom_fs.c
293286
@@ -0,0 +1,536 @@
@@ -550,7 +543,7 @@ index 0000000..f51bac0
550543
+ int got = -1;
551544
+ int64_t pos = (int64_t)lba * UDF_BLOCK_SIZE;
552545
+ int buf_size = num_blocks * UDF_BLOCK_SIZE;
553-
+ int use_cache = io->allow_cache && (num_blocks == 1);
546+
+ int use_cache = io->allow_cache && (buf_size < 512 * 1024); // && (num_blocks == 1);
554547
+
555548
+ if (use_cache) {
556549
+ if (!io->cache) {

0 commit comments

Comments
 (0)