Disable HdmvSub log.
[xy_vsfilter.git] / src / subtitles / cache_manager.h
blob03d99a1ffa014099c37b7a0193325327b5a3126c
1 /************************************************************************/
2 /* author: xy */
3 /* date: 20110926 */
4 /************************************************************************/
5 #ifndef __CACHE_MANAGER_H_310C134F_844C_4590_A4D2_AD30165AF10A__
6 #define __CACHE_MANAGER_H_310C134F_844C_4590_A4D2_AD30165AF10A__
8 #include "RTS.h"
9 #include "mru_cache.h"
11 class TextInfoCacheKey
13 public:
14 CStringW m_str;
15 FwSTSStyle m_style;
16 bool operator==(const TextInfoCacheKey& key)const;
18 friend class TextInfoCacheKeyTraits;
21 class CWordCacheKey
23 public:
24 CWordCacheKey(const CWord& word);
25 CWordCacheKey(const CWordCacheKey& key);
26 CWordCacheKey(const FwSTSStyle& style, const CStringW& str, int ktype, int kstart, int kend);
27 bool operator==(const CWordCacheKey& key)const;
28 bool operator==(const CWord& key)const;
30 CStringW m_str;
31 FwSTSStyle m_style;
32 int m_ktype, m_kstart, m_kend;
34 friend class CWordCacheKeyTraits;
37 class PathDataCacheKey
39 public:
40 PathDataCacheKey(const CWord& word):m_str(word.m_str),m_style(word.m_style){}
41 PathDataCacheKey(const PathDataCacheKey& key):m_str(key.m_str),m_style(key.m_style){}
42 PathDataCacheKey(const FwSTSStyle& style, const CStringW& str):m_str(str),m_style(style){}
43 bool operator==(const PathDataCacheKey& key)const
45 return m_str==key.m_str && ( m_style==key.m_style || CompareSTSStyle(m_style, key.m_style) );
47 bool operator==(const CWord& key)const
49 return m_str==key.m_str && ( m_style==key.m_style || CompareSTSStyle(m_style.get(), key.m_style.get()) );
52 static bool CompareSTSStyle(const STSStyle& lhs, const STSStyle& rhs);
53 protected:
54 CStringW m_str;
55 FwSTSStyle m_style;
57 friend class PathDataCacheKeyTraits;
60 class ScanLineDataCacheKey: public PathDataCacheKey
62 public:
63 ScanLineDataCacheKey(const CWord& word, const POINT& org):PathDataCacheKey(word),m_org(org) { }
64 ScanLineDataCacheKey(const ScanLineDataCacheKey& key):PathDataCacheKey(key),m_org(key.m_org) { }
65 ScanLineDataCacheKey(const FwSTSStyle& style, const CStringW& str, const POINT& org)
66 :PathDataCacheKey(style, str),m_org(org) { }
67 bool operator==(const ScanLineDataCacheKey& key)const;
69 POINT m_org;
71 friend class ScanLineDataCacheKeyTraits;
74 class OverlayNoBlurKey: public ScanLineDataCacheKey
76 public:
77 OverlayNoBlurKey(const CWord& word, const POINT& p, const POINT& org):ScanLineDataCacheKey(word,org),m_p(p) { }
78 OverlayNoBlurKey(const OverlayNoBlurKey& key):ScanLineDataCacheKey(key),m_p(key.m_p) { }
79 OverlayNoBlurKey(const FwSTSStyle& style, const CStringW& str, const POINT& p, const POINT& org)
80 :ScanLineDataCacheKey(style, str, org),m_p(p) { }
81 bool operator==(const OverlayNoBlurKey& key)const;
83 POINT m_p;
86 class OverlayKey: public OverlayNoBlurKey
88 public:
89 OverlayKey(const CWord& word, const POINT& p, const POINT& org):OverlayNoBlurKey(word, p, org) { }
90 OverlayKey(const OverlayKey& key):OverlayNoBlurKey(key){ }
92 bool operator==(const OverlayKey& key)const;
94 friend class OverlayKeyTraits;
97 class TextInfoCacheKeyTraits:public CElementTraits<TextInfoCacheKey>
99 public:
100 static ULONG Hash(const TextInfoCacheKey& key);
103 class CWordCacheKeyTraits:public CElementTraits<CWordCacheKey>
105 public:
106 static ULONG Hash(const CWordCacheKey& key);
109 class PathDataCacheKeyTraits:public CElementTraits<PathDataCacheKey>
111 public:
112 static ULONG Hash(const PathDataCacheKey& key);
115 class ScanLineDataCacheKeyTraits:public CElementTraits<ScanLineDataCacheKey>
117 public:
118 static ULONG Hash(const ScanLineDataCacheKey& key);
121 class OverlayNoBlurKeyTraits:public CElementTraits<OverlayNoBlurKey>
123 public:
124 static ULONG Hash(const OverlayNoBlurKey& key);
127 class OverlayKeyTraits:public CElementTraits<OverlayKey>
129 public:
130 static ULONG Hash(const OverlayKey& key);
133 typedef EnhancedXyMru<
134 TextInfoCacheKey,
135 CText::SharedPtrTextInfo,
136 TextInfoCacheKeyTraits
137 > TextInfoMruCache;
139 typedef EnhancedXyMru<
140 CStringW,
141 CRenderedTextSubtitle::SharedPtrConstAssTagList,
142 CStringElementTraits<CStringW>
143 > AssTagListMruCache;
145 typedef EnhancedXyMru<CWordCacheKey, SharedPtrCWord, CWordCacheKeyTraits> CWordMruCache;
147 typedef EnhancedXyMru<PathDataCacheKey, SharedPtrConstPathData, PathDataCacheKeyTraits> PathDataMruCache;
149 typedef EnhancedXyMru<ScanLineDataCacheKey, SharedPtrConstScanLineData, ScanLineDataCacheKeyTraits> ScanLineDataMruCache;
151 typedef EnhancedXyMru<OverlayNoBlurKey, SharedPtrOverlay, OverlayNoBlurKeyTraits> OverlayNoBlurMruCache;
153 typedef EnhancedXyMru<OverlayKey, SharedPtrOverlay, OverlayKeyTraits> OverlayMruCache;
155 class CacheManager
157 public:
158 static const int TEXT_INFO_CACHE_ITEM_NUM = 2048;
159 static const int ASS_TAG_LIST_CACHE_ITEM_NUM = 256;
160 static const int SUBPIXEL_VARIANCE_CACHE_ITEM_NUM = 256;
161 static const int OVERLAY_CACHE_ITEM_NUM = 256;
163 static const int OVERLAY_NO_BLUR_CACHE_ITEM_NUM = 256;
164 static const int SCAN_LINE_DATA_CACHE_ITEM_NUM = 256;
165 static const int PATH_CACHE_ITEM_NUM = 256;
166 static const int WORD_CACHE_ITEM_NUM = 512;
168 static TextInfoMruCache* GetTextInfoCache();
169 static AssTagListMruCache* GetAssTagListMruCache();
170 static OverlayMruCache* GetSubpixelVarianceCache();
171 static OverlayMruCache* GetOverlayMruCache();
172 static OverlayNoBlurMruCache* GetOverlayNoBlurMruCache();
173 static ScanLineDataMruCache* GetScanLineDataMruCache();
174 static PathDataMruCache* GetPathDataMruCache();
175 static CWordMruCache* GetCWordMruCache();
176 private:
177 static TextInfoMruCache* s_text_info_cache;
178 static AssTagListMruCache* s_ass_tag_list_cache;
179 static OverlayMruCache* s_subpixel_variance_cache;
180 static OverlayMruCache* s_overlay_mru_cache;
181 static OverlayNoBlurMruCache* s_overlay_no_blur_mru_cache;
182 static PathDataMruCache* s_path_data_mru_cache;
183 static ScanLineDataMruCache* s_scan_line_data_mru_cache;
184 static CWordMruCache* s_word_mru_cache;
187 #endif // end of __CACHE_MANAGER_H_310C134F_844C_4590_A4D2_AD30165AF10A__