| 161 | } |
| 162 | |
| 163 | bool GraphicsImageDifferencePass::GetQueryResult(uint32_t queryIndex, float outPerChannelMSE[4], |
| 164 | float* outOverallMSE, float* outOverallPSNR, int channels, float maxSignalValue) |
| 165 | { |
| 166 | if (queryIndex >= m_maxQueries) |
| 167 | return false; |
| 168 | |
| 169 | // Check that ReadResults() has been called after executing queries, to avoid returning garbage. |
| 170 | // We can't really check if the comparison command list has been executed by the caller, |
| 171 | // but this is better than nothing. |
| 172 | if (!m_resultsRead) |
| 173 | return false; |
| 174 | |
| 175 | float overallMSE = 0.f; |
| 176 | for (int ch = 0; ch < channels; ++ch) |
| 177 | { |
| 178 | float const mse = m_mseValues[queryIndex * ChannelsPerQuery + ch]; |
| 179 | overallMSE += mse / float(channels); |
| 180 | |
| 181 | if (outPerChannelMSE) |
| 182 | outPerChannelMSE[ch] = mse; |
| 183 | } |
| 184 | |
| 185 | if (outOverallMSE) |
| 186 | *outOverallMSE = overallMSE; |
| 187 | |
| 188 | if (outOverallPSNR) |
| 189 | *outOverallPSNR = ntc::LossToPSNR(overallMSE / (maxSignalValue * maxSignalValue)); |
| 190 | |
| 191 | return true; |
| 192 | } |
| 193 |
no outgoing calls