// Copyright 2018 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef MEDIA_GPU_TEST_VIDEO_FRAME_VALIDATOR_H_ #define MEDIA_GPU_TEST_VIDEO_FRAME_VALIDATOR_H_ #include <map> #include <memory> #include <string> #include <utility> #include <vector> #include "base/files/file.h" #include "base/functional/callback.h" #include "base/memory/scoped_refptr.h" #include "base/synchronization/condition_variable.h" #include "base/synchronization/lock.h" #include "base/threading/thread.h" #include "base/threading/thread_checker.h" #include "media/base/video_types.h" #include "media/gpu/test/video_frame_helpers.h" #include "ui/gfx/geometry/rect.h" namespace media { class VideoFrame; class VideoFrameMapper; namespace test { // VideoFrameValidator validates the pixel content of each video frame. // It maps a video frame by using VideoFrameMapper if needed. If the validation // fails, the frame is processed by |corrupt_frame_processor_|. // VideoFrameValidator is created by calling Create() of the child classes in // below. // Mapping and verification of a frame is a costly operation and will influence // performance measurements. class VideoFrameValidator : public VideoFrameProcessor { … }; // Returns a cropping rectangle containing the bottom |row_height| rows of the // input frame. This can be used by VideoFrameValidator::CropHelper. gfx::Rect BottomRowCrop(int row_height, const VideoFrame& frame); constexpr int kDefaultBottomRowCropHeight = …; // Validate by converting the frame to be validated to |validation_format| to // resolve pixel format differences on different platforms. Thereafter, it // compares md5 values of the mapped and converted buffer with golden md5 // values. The golden values are prepared in advance and must be identical on // all platforms. class MD5VideoFrameValidator : public VideoFrameValidator { … }; // Validate by comparing each byte of visible area of the frame to be validated. // An absolute difference equal to or less than |torelance_| is allowed on // the comparison. class RawVideoFrameValidator : public VideoFrameValidator { … }; // |tolerance_|, the validation on the frame passes. class PSNRVideoFrameValidator : public VideoFrameValidator { … }; // Validate by computing SSIM from the frame to be validated and the model frame // acquired by |get_model_frame_cb_|. If the SSIM value is equal to or more than // |tolerance_|, the validation on the frame passes. class SSIMVideoFrameValidator : public VideoFrameValidator { … }; // Validate by computing the log likelihood ratio of the frame to be validate // and the model frame acquired by |get_model_frame_cb_|. If the log likelihood // ratio is less than or equal to |tolerance_|, the validation on the frame // passes. class LogLikelihoodRatioVideoFrameValidator : public VideoFrameValidator { … }; } // namespace test } // namespace media #endif // MEDIA_GPU_TEST_VIDEO_FRAME_VALIDATOR_H_