| 2128 | } // SetSink |
| 2129 | |
| 2130 | STDMETHODIMP CBaseVideoRenderer::Notify(IBaseFilter *pSelf, Quality q) |
| 2131 | { |
| 2132 | // NOTE: We are NOT getting any locks here. We could be called |
| 2133 | // asynchronously and possibly even on a time critical thread of |
| 2134 | // someone else's - so we do the minumum. We only set one state |
| 2135 | // variable (an integer) and if that happens to be in the middle |
| 2136 | // of another thread reading it they will just get either the new |
| 2137 | // or the old value. Locking would achieve no more than this. |
| 2138 | |
| 2139 | // It might be nice to check that we are being called from m_pGraph, but |
| 2140 | // it turns out to be a millisecond or so per throw! |
| 2141 | |
| 2142 | // This is heuristics, these numbers are aimed at being "what works" |
| 2143 | // rather than anything based on some theory. |
| 2144 | // We use a hyperbola because it's easy to calculate and it includes |
| 2145 | // a panic button asymptote (which we push off just to the left) |
| 2146 | // The throttling fits the following table (roughly) |
| 2147 | // Proportion Throttle (msec) |
| 2148 | // >=1000 0 |
| 2149 | // 900 3 |
| 2150 | // 800 7 |
| 2151 | // 700 11 |
| 2152 | // 600 17 |
| 2153 | // 500 25 |
| 2154 | // 400 35 |
| 2155 | // 300 50 |
| 2156 | // 200 72 |
| 2157 | // 125 100 |
| 2158 | // 100 112 |
| 2159 | // 50 146 |
| 2160 | // 0 200 |
| 2161 | |
| 2162 | // (some evidence that we could go for a sharper kink - e.g. no throttling |
| 2163 | // until below the 750 mark - might give fractionally more frames on a |
| 2164 | // P60-ish machine). The easy way to get these coefficients is to use |
| 2165 | // Renbase.xls follow the instructions therein using excel solver. |
| 2166 | |
| 2167 | if (q.Proportion >= 1000) |
| 2168 | { |
| 2169 | m_trThrottle = 0; |
| 2170 | } |
| 2171 | else |
| 2172 | { |
| 2173 | // The DWORD is to make quite sure I get unsigned arithmetic |
| 2174 | // as the constant is between 2**31 and 2**32 |
| 2175 | m_trThrottle = -330000 + (388880000 / (q.Proportion + 167)); |
| 2176 | } |
| 2177 | return NOERROR; |
| 2178 | } // Notify |
| 2179 | |
| 2180 | // Send a message to indicate what our supplier should do about quality. |
| 2181 | // Theory: |
no outgoing calls
no test coverage detected