| 251 | } |
| 252 | |
| 253 | void videoHandlerDifference::reportFirstDifferencePosition(QList<InfoItem> &infoList) const |
| 254 | { |
| 255 | if (!inputsValid()) |
| 256 | return; |
| 257 | |
| 258 | if (functions::clipToUnsigned(currentImage.width()) != frameSize.width || |
| 259 | functions::clipToUnsigned(currentImage.height()) != frameSize.height) |
| 260 | return; |
| 261 | |
| 262 | if (codingOrder == CodingOrder::HEVC) |
| 263 | { |
| 264 | // Assume the following: |
| 265 | // - The picture is split into LCUs of 64x64 pixels which are scanned in raster scan |
| 266 | // - Each LCU is scanned in a hierarchical tree until the smallest unit size (4x4 pixels) is |
| 267 | // reached This is exactly what we are going to do here now |
| 268 | |
| 269 | int widthLCU = (frameSize.width + 63) / 64; // Round up |
| 270 | int heightLCU = (frameSize.height + 63) / 64; |
| 271 | |
| 272 | for (int y = 0; y < heightLCU; y++) |
| 273 | { |
| 274 | for (int x = 0; x < widthLCU; x++) |
| 275 | { |
| 276 | // Now take the tree approach |
| 277 | int firstX, firstY, partIndex = 0; |
| 278 | |
| 279 | auto videoYUV0 = dynamic_cast<yuv::videoHandlerYUV *>(inputVideo[0].data()); |
| 280 | if (videoYUV0 != NULL && videoYUV0->isDiffReady()) |
| 281 | { |
| 282 | // find first difference using YUV instead of QImage. The latter does not work for 10bit |
| 283 | // videos and very small differences, since it only supports 8bit |
| 284 | if (hierarchicalPositionYUV(x * 64, |
| 285 | y * 64, |
| 286 | 64, |
| 287 | firstX, |
| 288 | firstY, |
| 289 | partIndex, |
| 290 | videoYUV0->getDiffYUV(), |
| 291 | videoYUV0->getDiffYUVFormat())) |
| 292 | { |
| 293 | // We found a difference in this block |
| 294 | infoList.append(InfoItem("First diff LCU", QString::number(y * widthLCU + x))); |
| 295 | infoList.append(InfoItem("First diff X,Y", QString("%1,%2").arg(firstX).arg(firstY))); |
| 296 | infoList.append(InfoItem("First diff partIndex", QString::number(partIndex))); |
| 297 | return; |
| 298 | } |
| 299 | } |
| 300 | else |
| 301 | { |
| 302 | if (hierarchicalPosition(x * 64, y * 64, 64, firstX, firstY, partIndex, currentImage)) |
| 303 | { |
| 304 | // We found a difference in this block |
| 305 | infoList.append(InfoItem("First diff LCU", QString::number(y * widthLCU + x))); |
| 306 | infoList.append(InfoItem("First diff X,Y", QString("%1,%2").arg(firstX).arg(firstY))); |
| 307 | infoList.append(InfoItem("First diff partIndex", QString::number(partIndex))); |
| 308 | return; |
| 309 | } |
| 310 | } |
no test coverage detected