47993f6730
- Added Nuklear GUI library with build script and configuration. - Introduced OpenH264 encoder/decoder with build configuration. - Added PortAudio library for audio I/O with custom build script. - Included Python Execnet for multi-Python deployment. - Added Pytest Xdist plugin for distributed testing. - Introduced Shaderc for shader compilation tools. - Added Snappy compression library with necessary patches and configuration. - Included SoundTouch audio processing library with build configuration. - Added SRT library for secure reliable transport. - Introduced VapourSynth video processing framework with configuration. - Added Vid.stab for video stabilization. - Included WebRTC Audio Processing library with build configuration. - Added X264 video encoding library with patches for POSIX compliance. - Introduced X265 video encoder with build configuration. - Added XKeyboard Config for X keyboard configuration files. - Included Xorg XKBComp for keyboard description compilation. - Added Xvidcore MPEG-4 video codec library with configuration. - Introduced ZeroMQ messaging system with patches and build configuration. - Added Zimg library for scaling and colorspace conversion.
317 lines
16 KiB
Diff
317 lines
16 KiB
Diff
From d1a32d5229602f181574c95fa0db68bcf1762606 Mon Sep 17 00:00:00 2001
|
|
From: Stephen Hutchinson <qyot27@gmail.com>
|
|
Date: Sun, 27 Jul 2025 21:57:00 -0400
|
|
Subject: [PATCH] Cache: Avoid naming collision
|
|
|
|
---
|
|
avs_core/core/avisynth.cpp | 22 +++++++++----------
|
|
avs_core/core/cache.cpp | 42 ++++++++++++++++++-------------------
|
|
avs_core/core/cache.h | 6 +++---
|
|
avs_core/include/avisynth.h | 4 ++--
|
|
4 files changed, 37 insertions(+), 37 deletions(-)
|
|
|
|
diff --git a/avs_core/core/avisynth.cpp b/avs_core/core/avisynth.cpp
|
|
index 3f4064ebb..a49038f32 100644
|
|
--- a/avs_core/core/avisynth.cpp
|
|
+++ b/avs_core/core/avisynth.cpp
|
|
@@ -1070,7 +1070,7 @@ class ScriptEnvironment {
|
|
typedef std::vector<DebugTimestampedFrame> VideoFrameArrayType;
|
|
typedef std::map<VideoFrameBuffer *, VideoFrameArrayType> FrameBufferRegistryType;
|
|
typedef std::map<size_t, FrameBufferRegistryType> FrameRegistryType2; // post r1825 P.F.
|
|
- typedef mapped_list<Cache*> CacheRegistryType;
|
|
+ typedef mapped_list<AvsCache*> CacheRegistryType;
|
|
|
|
|
|
FrameRegistryType2 FrameRegistry2; // P.F.
|
|
@@ -1080,7 +1080,7 @@ class ScriptEnvironment {
|
|
|
|
std::unique_ptr<DeviceManager> Devices;
|
|
CacheRegistryType CacheRegistry;
|
|
- Cache* FrontCache;
|
|
+ AvsCache* FrontCache;
|
|
VideoFrame* GetNewFrame(size_t vfb_size, size_t margin, Device* device);
|
|
VideoFrame* GetFrameFromRegistry(size_t vfb_size, Device* device);
|
|
void ShrinkCache(Device* device);
|
|
@@ -3605,7 +3605,7 @@ VideoFrame* ScriptEnvironment::GetNewFrame(size_t vfb_size, size_t margin, Devic
|
|
for (auto &cit: CacheRegistry)
|
|
{
|
|
cache_counter++;
|
|
- Cache* cache = cit;
|
|
+ AvsCache* cache = cit;
|
|
int cache_size = cache->SetCacheHints(CACHE_GET_SIZE, 0);
|
|
_RPT4(0, " cache#%d cache_ptr=%p cache_size=%d \n", cache_counter, (void*)cache, cache_size); // let's see what's in the cache
|
|
}
|
|
@@ -3729,7 +3729,7 @@ void ScriptEnvironment::ShrinkCache(Device *device)
|
|
|
|
// We try to shrink least recently used caches first.
|
|
|
|
- Cache* cache = cit;
|
|
+ AvsCache* cache = cit;
|
|
if (cache->GetDevice() != device) {
|
|
continue;
|
|
}
|
|
@@ -4206,7 +4206,7 @@ void* ScriptEnvironment::ManageCache(int key, void* data) {
|
|
// Called by Cache instances upon creation
|
|
case MC_RegisterCache:
|
|
{
|
|
- Cache* cache = reinterpret_cast<Cache*>(data);
|
|
+ AvsCache* cache = reinterpret_cast<AvsCache*>(data);
|
|
if (FrontCache != NULL)
|
|
CacheRegistry.push_back(FrontCache);
|
|
FrontCache = cache;
|
|
@@ -4215,7 +4215,7 @@ void* ScriptEnvironment::ManageCache(int key, void* data) {
|
|
// Called by Cache instances upon destruction
|
|
case MC_UnRegisterCache:
|
|
{
|
|
- Cache* cache = reinterpret_cast<Cache*>(data);
|
|
+ AvsCache* cache = reinterpret_cast<AvsCache*>(data);
|
|
if (FrontCache == cache)
|
|
FrontCache = NULL;
|
|
else
|
|
@@ -4225,7 +4225,7 @@ void* ScriptEnvironment::ManageCache(int key, void* data) {
|
|
// Called by Cache instances when they want to expand their limit
|
|
case MC_NodAndExpandCache:
|
|
{
|
|
- Cache* cache = reinterpret_cast<Cache*>(data);
|
|
+ AvsCache* cache = reinterpret_cast<AvsCache*>(data);
|
|
|
|
// Nod
|
|
if (cache != FrontCache)
|
|
@@ -4249,7 +4249,7 @@ void* ScriptEnvironment::ManageCache(int key, void* data) {
|
|
// If we don't have enough free reserves, take away a cache slot from
|
|
// a cache instance that hasn't been used since long.
|
|
|
|
- for (Cache* old_cache : CacheRegistry)
|
|
+ for (AvsCache* old_cache : CacheRegistry)
|
|
{
|
|
if (old_cache->GetDevice() != device) {
|
|
continue;
|
|
@@ -4272,7 +4272,7 @@ void* ScriptEnvironment::ManageCache(int key, void* data) {
|
|
// Called by Cache instances when they are accessed
|
|
case MC_NodCache:
|
|
{
|
|
- Cache* cache = reinterpret_cast<Cache*>(data);
|
|
+ AvsCache* cache = reinterpret_cast<AvsCache*>(data);
|
|
if (cache == FrontCache) {
|
|
return 0;
|
|
}
|
|
@@ -5127,11 +5127,11 @@ bool ScriptEnvironment::Invoke_(AVSValue *result, const AVSValue& implicit_last,
|
|
#ifdef _DEBUG
|
|
if (PrevFrontCache != FrontCache && FrontCache != NULL) // cache registering swaps frontcache to the current
|
|
{
|
|
- _RPT2(0, "ScriptEnvironment::Invoke done Cache::Create %s cache_id=%p\r\n", name, (void*)FrontCache);
|
|
+ _RPT2(0, "ScriptEnvironment::Invoke done AvsCache::Create %s cache_id=%p\r\n", name, (void*)FrontCache);
|
|
FrontCache->FuncName = name; // helps debugging. See also in cache.cpp
|
|
}
|
|
else {
|
|
- _RPT1(0, "ScriptEnvironment::Invoke done Cache::Create %s\r\n", name);
|
|
+ _RPT1(0, "ScriptEnvironment::Invoke done AvsCache::Create %s\r\n", name);
|
|
}
|
|
#endif
|
|
}
|
|
diff --git a/avs_core/core/cache.cpp b/avs_core/core/cache.cpp
|
|
index f731caa19..f2e61a03a 100644
|
|
--- a/avs_core/core/cache.cpp
|
|
+++ b/avs_core/core/cache.cpp
|
|
@@ -117,7 +117,7 @@ struct CachePimpl
|
|
};
|
|
|
|
|
|
-Cache::Cache(const PClip& _child, Device* device, std::mutex& CacheGuardMutex, InternalEnvironment* env) :
|
|
+AvsCache::AvsCache(const PClip& _child, Device* device, std::mutex& CacheGuardMutex, InternalEnvironment* env) :
|
|
Env(env),
|
|
_pimpl(NULL),
|
|
device(device),
|
|
@@ -125,7 +125,7 @@ Cache::Cache(const PClip& _child, Device* device, std::mutex& CacheGuardMutex, I
|
|
{
|
|
_pimpl = new CachePimpl(_child, env->GetCacheMode());
|
|
env->ManageCache(MC_RegisterCache, reinterpret_cast<void*>(this));
|
|
- _RPT5(0, "Cache::Cache registered. cache_id=%p child=%p w=%d h=%d VideoCacheSize=%Iu\n", (void*)this, (void*)_child, _pimpl->vi.width, _pimpl->vi.height, _pimpl->VideoCache->size());
|
|
+ _RPT5(0, "AvsCache::AvsCache registered. cache_id=%p child=%p w=%d h=%d VideoCacheSize=%Iu\n", (void*)this, (void*)_child, _pimpl->vi.width, _pimpl->vi.height, _pimpl->VideoCache->size());
|
|
|
|
const int dummy = 0;
|
|
// child is usually MTGuard, which forwards this request to its child filter - the real one
|
|
@@ -150,14 +150,14 @@ Cache::Cache(const PClip& _child, Device* device, std::mutex& CacheGuardMutex, I
|
|
}
|
|
}
|
|
|
|
-Cache::~Cache()
|
|
+AvsCache::~AvsCache()
|
|
{
|
|
- _RPT5(0, "Cache::Cache unregister. cache_id=%p child=%p w=%d h=%d VideoCacheSize=%Iu\n", (void *)this, (void *)_pimpl->child, _pimpl->vi.width, _pimpl->vi.height, _pimpl->VideoCache->size()); // P.F.
|
|
+ _RPT5(0, "AvsCache::AvsCache unregister. cache_id=%p child=%p w=%d h=%d VideoCacheSize=%Iu\n", (void *)this, (void *)_pimpl->child, _pimpl->vi.width, _pimpl->vi.height, _pimpl->VideoCache->size()); // P.F.
|
|
Env->ManageCache(MC_UnRegisterCache, reinterpret_cast<void*>(this));
|
|
delete _pimpl;
|
|
}
|
|
|
|
-PVideoFrame __stdcall Cache::GetFrame(int n, IScriptEnvironment* env_)
|
|
+PVideoFrame __stdcall AvsCache::GetFrame(int n, IScriptEnvironment* env_)
|
|
{
|
|
#ifdef _DEBUG
|
|
constexpr auto BUFSIZE = 255;
|
|
@@ -186,10 +186,10 @@ PVideoFrame __stdcall Cache::GetFrame(int n, IScriptEnvironment* env_)
|
|
LruLookupResult LruLookupRes = _pimpl->VideoCache->lookup(n, &cache_handle, true, result, &env->GetSupressCaching());
|
|
/*
|
|
std::string name = FuncName;
|
|
- snprintf(buf.get(), BUFSIZE, "Cache::GetFrame lookup follows: [%s] n=%6d Thread=%zu", name.c_str(), n, env->GetEnvProperty(AEP_THREAD_ID));
|
|
+ snprintf(buf.get(), BUFSIZE, "AvsCache::GetFrame lookup follows: [%s] n=%6d Thread=%zu", name.c_str(), n, env->GetEnvProperty(AEP_THREAD_ID));
|
|
_RPT0(0, buf.get());
|
|
|
|
- snprintf(buf.get(), BUFSIZE, "Cache::GetFrame lookup ready: [%s] n=%6d Thread=%zu res=%d", name.c_str(), n, env->GetEnvProperty(AEP_THREAD_ID), (int)LruLookupRes);
|
|
+ snprintf(buf.get(), BUFSIZE, "AvsCache::GetFrame lookup ready: [%s] n=%6d Thread=%zu res=%d", name.c_str(), n, env->GetEnvProperty(AEP_THREAD_ID), (int)LruLookupRes);
|
|
_RPT0(0, buf.get());
|
|
*/
|
|
|
|
@@ -208,7 +208,7 @@ PVideoFrame __stdcall Cache::GetFrame(int n, IScriptEnvironment* env_)
|
|
try
|
|
{
|
|
#ifdef _DEBUG
|
|
- snprintf(buf.get(), BUFSIZE, "Cache::GetFrame LRU_LOOKUP_NOT_FOUND: [%s] n=%6d child=%p\n", name.c_str(), n, (void*)_pimpl->child); // P.F.
|
|
+ snprintf(buf.get(), BUFSIZE, "AvsCache::GetFrame LRU_LOOKUP_NOT_FOUND: [%s] n=%6d child=%p\n", name.c_str(), n, (void*)_pimpl->child); // P.F.
|
|
_RPT0(0, buf.get());
|
|
#endif
|
|
//cache_handle.first->value = _pimpl->child->GetFrame(n, env);
|
|
@@ -238,10 +238,10 @@ PVideoFrame __stdcall Cache::GetFrame(int n, IScriptEnvironment* env_)
|
|
std::chrono::duration<double> elapsed_seconds = t_end - t_start;
|
|
std::string name = FuncName;
|
|
if (NULL == cache_handle.first->value) {
|
|
- snprintf(buf.get(), BUFSIZE, "Cache::GetFrame LRU_LOOKUP_NOT_FOUND: HEY! got nulled! [%s] n=%6d child=%p frame=%p framebefore=%p SeekTimeWithGetFrame:%f\n", name.c_str(), n, (void *)_pimpl->child, (void *)cache_handle.first->value, (void *)result, elapsed_seconds.count()); // P.F.
|
|
+ snprintf(buf.get(), BUFSIZE, "AvsCache::GetFrame LRU_LOOKUP_NOT_FOUND: HEY! got nulled! [%s] n=%6d child=%p frame=%p framebefore=%p SeekTimeWithGetFrame:%f\n", name.c_str(), n, (void *)_pimpl->child, (void *)cache_handle.first->value, (void *)result, elapsed_seconds.count()); // P.F.
|
|
_RPT0(0, buf.get());
|
|
} else {
|
|
- snprintf(buf.get(), BUFSIZE, "Cache::GetFrame LRU_LOOKUP_NOT_FOUND: [%s] n=%6d child=%p frame=%p framebefore=%p videoCacheSize=%zu SeekTimeWithGetFrame:%f\n", name.c_str(), n, (void *)_pimpl->child, (void *)cache_handle.first->value, (void *)result, _pimpl->VideoCache->size(), elapsed_seconds.count()); // P.F.
|
|
+ snprintf(buf.get(), BUFSIZE, "AvsCache::GetFrame LRU_LOOKUP_NOT_FOUND: [%s] n=%6d child=%p frame=%p framebefore=%p videoCacheSize=%zu SeekTimeWithGetFrame:%f\n", name.c_str(), n, (void *)_pimpl->child, (void *)cache_handle.first->value, (void *)result, _pimpl->VideoCache->size(), elapsed_seconds.count()); // P.F.
|
|
_RPT0(0, buf.get());
|
|
}
|
|
#endif
|
|
@@ -261,7 +261,7 @@ PVideoFrame __stdcall Cache::GetFrame(int n, IScriptEnvironment* env_)
|
|
t_end = std::chrono::high_resolution_clock::now();
|
|
std::chrono::duration<double> elapsed_seconds = t_end - t_start;
|
|
std::string name = FuncName;
|
|
- snprintf(buf.get(), BUFSIZE, "Cache::GetFrame LRU_LOOKUP_FOUND_AND_READY: [%s] n=%6d child=%p frame=%p vfb=%p videoCacheSize=%zu SeekTime :%f\n", name.c_str(), n, (void *)_pimpl->child, (void *)result, (void *)result->GetFrameBuffer(), _pimpl->VideoCache->size(), elapsed_seconds.count());
|
|
+ snprintf(buf.get(), BUFSIZE, "AvsCache::GetFrame LRU_LOOKUP_FOUND_AND_READY: [%s] n=%6d child=%p frame=%p vfb=%p videoCacheSize=%zu SeekTime :%f\n", name.c_str(), n, (void *)_pimpl->child, (void *)result, (void *)result->GetFrameBuffer(), _pimpl->VideoCache->size(), elapsed_seconds.count());
|
|
_RPT0(0, buf.get());
|
|
assert(result != NULL);
|
|
#endif
|
|
@@ -270,14 +270,14 @@ PVideoFrame __stdcall Cache::GetFrame(int n, IScriptEnvironment* env_)
|
|
case LRU_LOOKUP_NO_CACHE:
|
|
{
|
|
#ifdef _DEBUG
|
|
- snprintf(buf.get(), BUFSIZE, "Cache::GetFrame <Before GetFrame> LRU_LOOKUP_NO_CACHE: [%s] n=%6d child=%p\n", name.c_str(), n, (void*)_pimpl->child); // P.F.
|
|
+ snprintf(buf.get(), BUFSIZE, "AvsCache::GetFrame <Before GetFrame> LRU_LOOKUP_NO_CACHE: [%s] n=%6d child=%p\n", name.c_str(), n, (void*)_pimpl->child); // P.F.
|
|
_RPT0(0, buf.get());
|
|
#endif
|
|
result = _pimpl->child->GetFrame(n, env);
|
|
#ifdef _DEBUG
|
|
t_end = std::chrono::high_resolution_clock::now();
|
|
std::chrono::duration<double> elapsed_seconds = t_end - t_start;
|
|
- snprintf(buf.get(), BUFSIZE, "Cache::GetFrame <After GetFrame> LRU_LOOKUP_NO_CACHE: [%s] n=%6d child=%p frame=%p vfb=%p videoCacheSize=%zu SeekTime :%f\n", name.c_str(), n, (void *)_pimpl->child, (void *)result, (void *)result->GetFrameBuffer(), _pimpl->VideoCache->size(), elapsed_seconds.count()); // P.F.
|
|
+ snprintf(buf.get(), BUFSIZE, "AvsCache::GetFrame <After GetFrame> LRU_LOOKUP_NO_CACHE: [%s] n=%6d child=%p frame=%p vfb=%p videoCacheSize=%zu SeekTime :%f\n", name.c_str(), n, (void *)_pimpl->child, (void *)result, (void *)result->GetFrameBuffer(), _pimpl->VideoCache->size(), elapsed_seconds.count()); // P.F.
|
|
_RPT0(0, buf.get());
|
|
#endif
|
|
break;
|
|
@@ -293,13 +293,13 @@ PVideoFrame __stdcall Cache::GetFrame(int n, IScriptEnvironment* env_)
|
|
return result;
|
|
}
|
|
|
|
-void Cache::FillAudioZeros(void* buf, size_t start_offset, size_t count) {
|
|
+void AvsCache::FillAudioZeros(void* buf, size_t start_offset, size_t count) {
|
|
const int bps = _pimpl->vi.BytesPerAudioSample();
|
|
unsigned char* byte_buf = (unsigned char*)buf;
|
|
memset(byte_buf + start_offset * bps, 0, count * bps);
|
|
}
|
|
|
|
-void __stdcall Cache::GetAudio(void* buf, int64_t start, int64_t count, IScriptEnvironment* env)
|
|
+void __stdcall AvsCache::GetAudio(void* buf, int64_t start, int64_t count, IScriptEnvironment* env)
|
|
{
|
|
if (count <= 0)
|
|
return;
|
|
@@ -439,19 +439,19 @@ void __stdcall Cache::GetAudio(void* buf, int64_t start, int64_t count, IScriptE
|
|
|
|
}
|
|
|
|
-const VideoInfo& __stdcall Cache::GetVideoInfo()
|
|
+const VideoInfo& __stdcall AvsCache::GetVideoInfo()
|
|
{
|
|
return _pimpl->vi;
|
|
}
|
|
|
|
-bool __stdcall Cache::GetParity(int n)
|
|
+bool __stdcall AvsCache::GetParity(int n)
|
|
{
|
|
return _pimpl->child->GetParity(n);
|
|
}
|
|
|
|
-int __stdcall Cache::SetCacheHints(int cachehints, int frame_range)
|
|
+int __stdcall AvsCache::SetCacheHints(int cachehints, int frame_range)
|
|
{
|
|
- // _RPT3(0, "Cache::SetCacheHints called. cache=%p hint=%d frame_range=%d\n", (void *)this, cachehints, frame_range);
|
|
+ // _RPT3(0, "AvsCache::SetCacheHints called. cache=%p hint=%d frame_range=%d\n", (void *)this, cachehints, frame_range);
|
|
switch(cachehints)
|
|
{
|
|
/*********************************************
|
|
@@ -490,7 +490,7 @@ int __stdcall Cache::SetCacheHints(int cachehints, int frame_range)
|
|
_pimpl->VideoCache->limits(&min, &max);
|
|
max = frame_range;
|
|
_pimpl->VideoCache->set_limits(min, max);
|
|
- _RPT3(0, "Cache::SetCacheHints CACHE_SET_MAX_CAPACITY cache=%p hint=%d frame_range=%d\n", (void *)this, cachehints, frame_range);
|
|
+ _RPT3(0, "AvsCache::SetCacheHints CACHE_SET_MAX_CAPACITY cache=%p hint=%d frame_range=%d\n", (void *)this, cachehints, frame_range);
|
|
break;
|
|
}
|
|
|
|
@@ -636,7 +636,7 @@ PClip CacheGuard::GetCache(IScriptEnvironment* env_)
|
|
}
|
|
|
|
// not found for current device, create it
|
|
- Cache* cache = new Cache(child, device, /*ref*/mutex, static_cast<InternalEnvironment*>(globalEnv));
|
|
+ AvsCache* cache = new AvsCache(child, device, /*ref*/mutex, static_cast<InternalEnvironment*>(globalEnv));
|
|
|
|
// apply cache hints if it is changed
|
|
if (hints.min != hints.default_min)
|
|
diff --git a/avs_core/core/cache.h b/avs_core/core/cache.h
|
|
index 640b653d6..1a453be6b 100644
|
|
--- a/avs_core/core/cache.h
|
|
+++ b/avs_core/core/cache.h
|
|
@@ -43,7 +43,7 @@
|
|
struct CachePimpl;
|
|
class InternalEnvironment;
|
|
|
|
-class Cache : public IClip
|
|
+class AvsCache : public IClip
|
|
{
|
|
private:
|
|
|
|
@@ -58,8 +58,8 @@ class Cache : public IClip
|
|
#ifdef _DEBUG
|
|
std::string FuncName = ""; // P.F. Invoked function's name whose queue owns the cache object
|
|
#endif
|
|
- Cache(const PClip& child, Device* device, std::mutex &CacheGuardMutex, InternalEnvironment* env);
|
|
- ~Cache();
|
|
+ AvsCache(const PClip& child, Device* device, std::mutex &CacheGuardMutex, InternalEnvironment* env);
|
|
+ ~AvsCache();
|
|
PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env);
|
|
void __stdcall GetAudio(void* buf, int64_t start, int64_t count, IScriptEnvironment* env);
|
|
const VideoInfo& __stdcall GetVideoInfo();
|
|
diff --git a/avs_core/include/avisynth.h b/avs_core/include/avisynth.h
|
|
index 93fa0e57f..03a40c618 100644
|
|
--- a/avs_core/include/avisynth.h
|
|
+++ b/avs_core/include/avisynth.h
|
|
@@ -1007,7 +1007,7 @@ class VideoFrameBuffer {
|
|
volatile long sequence_number;
|
|
|
|
friend class VideoFrame;
|
|
- friend class Cache;
|
|
+ friend class AvsCache;
|
|
friend class ScriptEnvironment;
|
|
volatile long refcount;
|
|
|
|
@@ -1101,7 +1101,7 @@ class VideoFrame {
|
|
void Release();
|
|
|
|
friend class ScriptEnvironment;
|
|
- friend class Cache;
|
|
+ friend class AvsCache;
|
|
|
|
VideoFrame(VideoFrameBuffer* _vfb, AVSMap* avsmap, int _offset, int _pitch, int _row_size, int _height, int _pixel_type);
|
|
VideoFrame(VideoFrameBuffer* _vfb, AVSMap* avsmap, int _offset, int _pitch, int _row_size, int _height, int _offsetU, int _offsetV, int _pitchUV, int _row_sizeUV, int _heightUV, int _pixel_type);
|