mirror of
https://mirror.skon.top/https://github.com/FFmpeg/FFmpeg
synced 2026-04-20 21:00:41 +08:00
avformat/file: respect pkt_size even in streaming mode
Also clarify the documentation a bit. Signed-off-by: Marton Balint <cus@passwd.hu>
This commit is contained in:
@@ -354,13 +354,15 @@ overriding this might speed up opening certain files at the cost of losing some
|
||||
features (e.g. accurate seeking).
|
||||
|
||||
@item pkt_size
|
||||
Set the maximum packet size used for file I/O.
|
||||
Set the maximum packet size used for file I/O. A smaller value may reduce
|
||||
memory usage. A higher value may increase throughput especially with networked
|
||||
filesystems.
|
||||
|
||||
For writing, this sets the size of each write operation. The default is
|
||||
262144 bytes.
|
||||
For reading, if explicitly set, it overrides the default internal buffer size
|
||||
(32768 bytes) and limits the maximum amount of data read per operation.
|
||||
Setting a smaller value may reduce memory usage when reading files sequentially.
|
||||
(32 KB) and limits the maximum amount of data read per operation.
|
||||
|
||||
For writing, this sets the size of each write operation. The default is 256 KB
|
||||
for regular files, 32 KB otherwise.
|
||||
@end table
|
||||
|
||||
@section ftp
|
||||
|
||||
@@ -312,14 +312,18 @@ static int file_open(URLContext *h, const char *filename, int flags)
|
||||
|
||||
h->is_streamed = !fstat(fd, &st) && S_ISFIFO(st.st_mode);
|
||||
|
||||
/* Buffer writes more than the default 32k to improve throughput especially
|
||||
* with networked file systems */
|
||||
if (!h->is_streamed) {
|
||||
if (flags & AVIO_FLAG_WRITE)
|
||||
h->min_packet_size = h->max_packet_size = c->pkt_size ? c->pkt_size : 262144;
|
||||
else if (flags & AVIO_FLAG_READ && c->pkt_size)
|
||||
h->max_packet_size = c->pkt_size;
|
||||
if (c->pkt_size) {
|
||||
h->max_packet_size = c->pkt_size;
|
||||
} else {
|
||||
/* Buffer writes more than the default 32k to improve throughput especially
|
||||
* with networked file systems */
|
||||
if (!h->is_streamed && flags & AVIO_FLAG_WRITE)
|
||||
h->max_packet_size = 262144;
|
||||
}
|
||||
/* Disable per-packet flushing by default to improve throughput especially
|
||||
* with networked file systems */
|
||||
if (!h->is_streamed && flags & AVIO_FLAG_WRITE)
|
||||
h->min_packet_size = h->max_packet_size;
|
||||
|
||||
if (c->seekable >= 0)
|
||||
h->is_streamed = !c->seekable;
|
||||
|
||||
Reference in New Issue
Block a user