1 /* 2 * Copyright 2020 The libgav1 Authors 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef LIBGAV1_TESTS_BLOCK_UTILS_H_ 18 #define LIBGAV1_TESTS_BLOCK_UTILS_H_ 19 20 #include <cstdint> 21 22 namespace libgav1 { 23 namespace test_utils { 24 25 //------------------------------------------------------------------------------ 26 // Prints |block| pixel by pixel with |width| pixels per row if |print_padding| 27 // is false, |stride| otherwise. If |print_padding| is true padding pixels are 28 // surrounded in '[]'. 29 template <typename Pixel> 30 void PrintBlock(const Pixel* block, int width, int height, int stride, 31 bool print_padding = false); 32 33 extern template void PrintBlock(const uint8_t* block, int width, int height, 34 int stride, bool print_padding /*= false*/); 35 extern template void PrintBlock(const uint16_t* block, int width, int height, 36 int stride, bool print_padding /*= false*/); 37 38 //------------------------------------------------------------------------------ 39 // Compares |block1| and |block2| pixel by pixel checking |width| pixels per row 40 // if |check_padding| is false, min(|stride1|, |stride2|) pixels otherwise. 41 // Prints the blocks with differences marked with a '*' if |print_diff| is 42 // true (the default). 43 44 template <typename Pixel> 45 bool CompareBlocks(const Pixel* block1, const Pixel* block2, int width, 46 int height, int stride1, int stride2, bool check_padding, 47 bool print_diff = true); 48 49 extern template bool CompareBlocks(const uint8_t* block1, const uint8_t* block2, 50 int width, int height, int stride1, 51 int stride2, bool check_padding, 52 bool print_diff /*= true*/); 53 extern template bool CompareBlocks(const uint16_t* block1, 54 const uint16_t* block2, int width, 55 int height, int stride1, int stride2, 56 bool check_padding, 57 bool print_diff /*= true*/); 58 59 } // namespace test_utils 60 } // namespace libgav1 61 62 #endif // LIBGAV1_TESTS_BLOCK_UTILS_H_ 63