diff options
author | Jörg Müller <nexyon@gmail.com> | 2022-04-22 23:36:04 +0300 |
---|---|---|
committer | Jörg Müller <nexyon@gmail.com> | 2022-04-22 23:36:04 +0300 |
commit | ac8beb4fda6f6cdfd658aeee05f9eba55ba3d8cc (patch) | |
tree | cff98a9a4faac0aa5cd46b57f13d26df18160b21 | |
parent | ff6098345a6e0fca508d0e104976d54ca199f273 (diff) |
Fix T97453: Blender crash when selecting Caching checkbox in VSE
Merge Audaspace fixes from upstream.
-rw-r--r-- | extern/audaspace/include/util/Buffer.h | 10 | ||||
-rw-r--r-- | extern/audaspace/plugins/ffmpeg/FFMPEGReader.cpp | 2 | ||||
-rw-r--r-- | extern/audaspace/plugins/ffmpeg/FFMPEGReader.h | 2 | ||||
-rw-r--r-- | extern/audaspace/plugins/ffmpeg/FFMPEGWriter.cpp | 4 | ||||
-rw-r--r-- | extern/audaspace/src/util/Buffer.cpp | 8 | ||||
-rw-r--r-- | extern/audaspace/src/util/StreamBuffer.cpp | 18 |
6 files changed, 27 insertions, 17 deletions
diff --git a/extern/audaspace/include/util/Buffer.h b/extern/audaspace/include/util/Buffer.h index 9934e53625e..2b6a16cc154 100644 --- a/extern/audaspace/include/util/Buffer.h +++ b/extern/audaspace/include/util/Buffer.h @@ -34,7 +34,7 @@ class AUD_API Buffer { private: /// The size of the buffer in bytes. - int m_size; + long long m_size; /// The pointer to the buffer memory. data_t* m_buffer; @@ -48,7 +48,7 @@ public: * Creates a new buffer. * \param size The size of the buffer in bytes. */ - Buffer(int size = 0); + Buffer(long long size = 0); /** * Destroys the buffer. @@ -63,7 +63,7 @@ public: /** * Returns the size of the buffer in bytes. */ - int getSize() const; + long long getSize() const; /** * Resizes the buffer. @@ -71,7 +71,7 @@ public: * \param keep Whether to keep the old data. If the new buffer is smaller, * the data at the end will be lost. */ - void resize(int size, bool keep = false); + void resize(long long size, bool keep = false); /** * Makes sure the buffer has a minimum size. @@ -81,7 +81,7 @@ public: * \param keep Whether to keep the old data. If the new buffer is smaller, * the data at the end will be lost. */ - void assureSize(int size, bool keep = false); + void assureSize(long long size, bool keep = false); }; AUD_NAMESPACE_END diff --git a/extern/audaspace/plugins/ffmpeg/FFMPEGReader.cpp b/extern/audaspace/plugins/ffmpeg/FFMPEGReader.cpp index 69bb45119a6..ad33c267c74 100644 --- a/extern/audaspace/plugins/ffmpeg/FFMPEGReader.cpp +++ b/extern/audaspace/plugins/ffmpeg/FFMPEGReader.cpp @@ -361,7 +361,7 @@ int FFMPEGReader::read_packet(void* opaque, uint8_t* buf, int buf_size) { FFMPEGReader* reader = reinterpret_cast<FFMPEGReader*>(opaque); - int size = std::min(buf_size, reader->m_membuffer->getSize() - reader->m_membufferpos); + long long size = std::min(static_cast<long long>(buf_size), reader->m_membuffer->getSize() - reader->m_membufferpos); if(size < 0) return -1; diff --git a/extern/audaspace/plugins/ffmpeg/FFMPEGReader.h b/extern/audaspace/plugins/ffmpeg/FFMPEGReader.h index 70f13911eca..ca0e8b024aa 100644 --- a/extern/audaspace/plugins/ffmpeg/FFMPEGReader.h +++ b/extern/audaspace/plugins/ffmpeg/FFMPEGReader.h @@ -114,7 +114,7 @@ private: /** * Reading position of the buffer. */ - int m_membufferpos; + long long m_membufferpos; /** * Whether the audio data has to be interleaved after reading. diff --git a/extern/audaspace/plugins/ffmpeg/FFMPEGWriter.cpp b/extern/audaspace/plugins/ffmpeg/FFMPEGWriter.cpp index 32eb2330594..ae6558ccfa5 100644 --- a/extern/audaspace/plugins/ffmpeg/FFMPEGWriter.cpp +++ b/extern/audaspace/plugins/ffmpeg/FFMPEGWriter.cpp @@ -23,7 +23,9 @@ extern "C" { #include <libavcodec/avcodec.h> #include <libavformat/avio.h> +#if LIBAVCODEC_VERSION_MAJOR >= 59 #include <libavutil/channel_layout.h> +#endif } AUD_NAMESPACE_BEGIN @@ -398,7 +400,7 @@ FFMPEGWriter::FFMPEGWriter(std::string filename, DeviceSpecs specs, Container fo m_specs.rate = m_codecCtx->sample_rate; #ifdef FFMPEG_OLD_CODE - m_codecCtx->codec_id = outputFmt->audio_codec; + m_codecCtx->codec_id = audio_codec; #endif m_codecCtx->codec_type = AVMEDIA_TYPE_AUDIO; diff --git a/extern/audaspace/src/util/Buffer.cpp b/extern/audaspace/src/util/Buffer.cpp index d212278cacc..9c0314b4bea 100644 --- a/extern/audaspace/src/util/Buffer.cpp +++ b/extern/audaspace/src/util/Buffer.cpp @@ -25,7 +25,7 @@ AUD_NAMESPACE_BEGIN -Buffer::Buffer(int size) +Buffer::Buffer(long long size) { m_size = size; m_buffer = (data_t*) std::malloc(size + ALIGNMENT); @@ -41,12 +41,12 @@ sample_t* Buffer::getBuffer() const return (sample_t*) ALIGN(m_buffer); } -int Buffer::getSize() const +long long Buffer::getSize() const { return m_size; } -void Buffer::resize(int size, bool keep) +void Buffer::resize(long long size, bool keep) { if(keep) { @@ -63,7 +63,7 @@ void Buffer::resize(int size, bool keep) m_size = size; } -void Buffer::assureSize(int size, bool keep) +void Buffer::assureSize(long long size, bool keep) { if(m_size < size) resize(size, keep); diff --git a/extern/audaspace/src/util/StreamBuffer.cpp b/extern/audaspace/src/util/StreamBuffer.cpp index b87b363377d..68d199d23a2 100644 --- a/extern/audaspace/src/util/StreamBuffer.cpp +++ b/extern/audaspace/src/util/StreamBuffer.cpp @@ -18,8 +18,12 @@ #include "util/BufferReader.h" #include "util/Buffer.h" +#include <algorithm> + // 5 sec * 48000 samples/sec * 4 bytes/sample * 6 channels #define BUFFER_RESIZE_BYTES 5760000 +// 90 min * 60 sec/min * 48000 samples/sec * 4 bytes/sample * 2 channels +#define MAXIMUM_INITIAL_BUFFER_SIZE_BYTES 2073600000 AUD_NAMESPACE_BEGIN @@ -32,14 +36,15 @@ StreamBuffer::StreamBuffer(std::shared_ptr<ISound> sound) : int sample_size = AUD_SAMPLE_SIZE(m_specs); int length; - int index = 0; + long long index = 0; bool eos = false; // get an approximated size if possible - int size = reader->getLength(); + long long size = std::min(reader->getLength(), MAXIMUM_INITIAL_BUFFER_SIZE_BYTES / sample_size); + long long size_increase = BUFFER_RESIZE_BYTES / sample_size; if(size <= 0) - size = BUFFER_RESIZE_BYTES / sample_size; + size = size_increase; else size += m_specs.rate; @@ -47,13 +52,16 @@ StreamBuffer::StreamBuffer(std::shared_ptr<ISound> sound) : while(!eos) { // increase - m_buffer->resize(size*sample_size, true); + m_buffer->resize(static_cast<long long>(size) * sample_size, true); // read more length = size-index; reader->read(length, eos, m_buffer->getBuffer() + index * m_specs.channels); if(index == m_buffer->getSize() / sample_size) - size += BUFFER_RESIZE_BYTES / sample_size; + { + size += size_increase; + size_increase <<= 1; + } index += length; } |