core/FilterGraph.h
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #ifndef _AVS_FILTER_GRAPH_H | ||
| 2 | #define _AVS_FILTER_GRAPH_H | ||
| 3 | |||
| 4 | #include "internal.h" | ||
| 5 | #include <vector> | ||
| 6 | #include <map> | ||
| 7 | #include <memory> | ||
| 8 | #include <mutex> | ||
| 9 | |||
| 10 | class FilterGraph; | ||
| 11 | |||
| 12 | class Device; | ||
| 13 | // no DeviceManager classic avs+ | ||
| 14 | |||
| 15 | class GraphMemoryNode { | ||
| 16 | public: | ||
| 17 | struct MemoryInfo { | ||
| 18 | int numAllocation; | ||
| 19 | size_t totalBytes; | ||
| 20 | }; | ||
| 21 | std::map<Device*, MemoryInfo> memory; | ||
| 22 | void OnAllocate(size_t bytes, Device* dev); | ||
| 23 | void OnFree(size_t bytes, Device* dev); | ||
| 24 | private: | ||
| 25 | friend class PGraphMemoryNode; | ||
| 26 | int refcnt; | ||
| 27 | ✗ | void AddRef() { ++refcnt; } | |
| 28 | ✗ | void Release() { if (--refcnt <= 0) delete this; } | |
| 29 | }; | ||
| 30 | |||
| 31 | class PGraphMemoryNode | ||
| 32 | { | ||
| 33 | public: | ||
| 34 | 891 | PGraphMemoryNode() { Init(0); } | |
| 35 | ✗ | PGraphMemoryNode(GraphMemoryNode* p) { Init(p); } | |
| 36 | ✗ | PGraphMemoryNode(const PGraphMemoryNode& p) { Init(p.e); } | |
| 37 | ✗ | PGraphMemoryNode& operator=(GraphMemoryNode* p) { Set(p); return *this; } | |
| 38 | ✗ | PGraphMemoryNode& operator=(const PGraphMemoryNode& p) { Set(p.e); return *this; } | |
| 39 | int operator!() const { return !e; } | ||
| 40 | 1794 | operator void*() const { return e; } | |
| 41 | ✗ | GraphMemoryNode* operator->() const { return e; } | |
| 42 | 891 | ~PGraphMemoryNode() { Release(); } | |
| 43 | |||
| 44 | private: | ||
| 45 | GraphMemoryNode* e; | ||
| 46 |
1/2✗ Branch 2 → 3 not taken.
✓ Branch 2 → 4 taken 891 times.
|
891 | void Init(GraphMemoryNode* p) { e = p; if (e) e->AddRef(); } |
| 47 | ✗ | void Set(GraphMemoryNode* p) { if (p) p->AddRef(); if (e) e->Release(); e = p; } | |
| 48 |
1/2✗ Branch 2 → 3 not taken.
✓ Branch 2 → 4 taken 891 times.
|
891 | void Release() { if (e) e->Release(); } |
| 49 | }; | ||
| 50 | |||
| 51 | class FilterGraphNode : public IClip | ||
| 52 | { | ||
| 53 | IScriptEnvironment* Env; | ||
| 54 | PClip child; | ||
| 55 | |||
| 56 | std::string name; | ||
| 57 | AVSValue args; | ||
| 58 | std::vector<std::unique_ptr<AVSValue[]>> arrays; | ||
| 59 | std::vector<std::string> argnames; | ||
| 60 | |||
| 61 | PGraphMemoryNode memory; | ||
| 62 | |||
| 63 | friend FilterGraph; | ||
| 64 | public: | ||
| 65 | FilterGraphNode(PClip child, const char* name, const AVSValue& last, | ||
| 66 | const AVSValue& args, const char* const* arg_names, IScriptEnvironment* env); | ||
| 67 | ~FilterGraphNode(); | ||
| 68 | |||
| 69 | ✗ | virtual int __stdcall GetVersion() { return child->GetVersion(); } | |
| 70 | virtual PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env); | ||
| 71 | ✗ | virtual bool __stdcall GetParity(int n) { return child->GetParity(n); } | |
| 72 | ✗ | virtual void __stdcall GetAudio(void* buf, int64_t start, int64_t count, IScriptEnvironment* env) | |
| 73 | { | ||
| 74 | ✗ | return child->GetAudio(buf, start, count, env); | |
| 75 | } | ||
| 76 | ✗ | virtual int __stdcall SetCacheHints(int cachehints, int frame_range) | |
| 77 | { | ||
| 78 | ✗ | return child->SetCacheHints(cachehints, frame_range); | |
| 79 | } | ||
| 80 | ✗ | virtual const VideoInfo& __stdcall GetVideoInfo() { return child->GetVideoInfo(); } | |
| 81 | |||
| 82 | ✗ | PGraphMemoryNode GetMemoryNode() { return memory; } | |
| 83 | }; | ||
| 84 | |||
| 85 | void DoDumpGraph(const std::vector<FilterGraphNode*>& roots, const char* path, IScriptEnvironment* env); | ||
| 86 | |||
| 87 | #endif // _AVS_FILTER_GRAPH_H | ||
| 88 |