Skip to content

Commit

Permalink
Add MS-SSIM VRS file compare
Browse files Browse the repository at this point in the history
Summary:
In order to control compression quality, we need to be able to compare VRS files using an algorithm that can compare image differences and provide a score. The FileImageCompare facility will compare VRS files, using a filtered reader so we don't necessarily have to read every single frame (which can be slow).

meta:
Ocean provides an MS-SSIM implementation, which is an industry standard which we can simply depend on.

Reviewed By: kiminoue7

Differential Revision: D51345482

fbshipit-source-id: 3cc6d9c70b62cc9239ca01e2ea05bb74567620ed
  • Loading branch information
Georges Berenger authored and facebook-github-bot committed Nov 16, 2023
1 parent 638373d commit e41be16
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions vrs/test/helpers/VRSTestsHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

#pragma once

#include <functional>
#include <string>

Expand Down
4 changes: 4 additions & 0 deletions vrs/utils/PixelFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,10 @@ bool PixelFrame::normalizeToPixelFormat(
return false;
}

bool PixelFrame::ssimCompare(const PixelFrame& other, double& meanSSIM, double& meanContrast) {
XR_LOGE_ONCE("PixelFrame::ssimCompare has no open source implementation");
}

#endif // !IS_VRS_OSS_CODE()

} // namespace vrs::utils
7 changes: 7 additions & 0 deletions vrs/utils/PixelFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,13 @@ class PixelFrame {
/// @return True if the conversion was performed, false if source wasn't an RGBA frame.
bool convertRgbaToRgb(shared_ptr<PixelFrame>& outRgbFrame) const;

/// Compare this image with another image, and return an MS-SSIM score.
/// @param other: the other image to compare with.
/// @param msssim: on exit, the MS-SSIM score.
/// @return True if the images have identical dimensions and pixel formats, the pixel format is
/// supported (grey8 or rgb8), and the comparison succeeded.
bool msssimCompare(const PixelFrame& other, double& msssim);

private:
/// Conversion from an external buffer
/// @param convertedFrame: frame to convert to. May not be allocated yet.
Expand Down

0 comments on commit e41be16

Please sign in to comment.