| 1 | /***************************************************************************** |
| 2 | * Copyright (C) 2013 x265 project |
| 3 | * |
| 4 | * Authors: Steve Borho <steve@borho.org> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. |
| 19 | * |
| 20 | * This program is also available under a commercial proprietary license. |
| 21 | * For more information, contact us at license @ x265.com. |
| 22 | *****************************************************************************/ |
| 23 | |
| 24 | #ifndef _PIXELHARNESS_H_1 |
| 25 | #define _PIXELHARNESS_H_1 1 |
| 26 | |
| 27 | #include "testharness.h" |
| 28 | #include "primitives.h" |
| 29 | |
| 30 | class PixelHarness : public TestHarness |
| 31 | { |
| 32 | protected: |
| 33 | |
| 34 | enum { INCR = 32 }; |
| 35 | enum { STRIDE = 64 }; |
| 36 | enum { ITERS = 100 }; |
| 37 | enum { MAX_HEIGHT = 64 }; |
| 38 | enum { PAD_ROWS = 64 }; |
| 39 | enum { BUFFSIZE = STRIDE * (MAX_HEIGHT + PAD_ROWS) + INCR * ITERS }; |
| 40 | enum { TEST_CASES = 3 }; |
| 41 | enum { SMAX = 1 << 12 }; |
| 42 | enum { SMIN = -1 << 12 }; |
| 43 | |
| 44 | ALIGN_VAR_32(pixel, pbuf1[BUFFSIZE]); |
| 45 | pixel pbuf2[BUFFSIZE]; |
| 46 | pixel pbuf3[BUFFSIZE]; |
| 47 | pixel pbuf4[BUFFSIZE]; |
| 48 | int ibuf1[BUFFSIZE]; |
| 49 | int8_t psbuf1[BUFFSIZE]; |
| 50 | |
| 51 | int16_t sbuf1[BUFFSIZE]; |
| 52 | int16_t sbuf2[BUFFSIZE]; |
| 53 | int16_t sbuf3[BUFFSIZE]; |
| 54 | |
| 55 | pixel pixel_test_buff[TEST_CASES][BUFFSIZE]; |
| 56 | int16_t short_test_buff[TEST_CASES][BUFFSIZE]; |
| 57 | int16_t short_test_buff1[TEST_CASES][BUFFSIZE]; |
| 58 | int16_t short_test_buff2[TEST_CASES][BUFFSIZE]; |
| 59 | int int_test_buff[TEST_CASES][BUFFSIZE]; |
| 60 | uint16_t ushort_test_buff[TEST_CASES][BUFFSIZE]; |
| 61 | uint8_t uchar_test_buff[TEST_CASES][BUFFSIZE]; |
| 62 | |
| 63 | bool check_pixelcmp(pixelcmp_t ref, pixelcmp_t opt); |
| 64 | bool check_pixelcmp_sp(pixelcmp_sp_t ref, pixelcmp_sp_t opt); |
| 65 | bool check_pixelcmp_ss(pixelcmp_ss_t ref, pixelcmp_ss_t opt); |
| 66 | bool check_pixelcmp_x3(pixelcmp_x3_t ref, pixelcmp_x3_t opt); |
| 67 | bool check_pixelcmp_x4(pixelcmp_x4_t ref, pixelcmp_x4_t opt); |
| 68 | bool check_copy_pp(copy_pp_t ref, copy_pp_t opt); |
| 69 | bool check_copy_sp(copy_sp_t ref, copy_sp_t opt); |
| 70 | bool check_copy_ps(copy_ps_t ref, copy_ps_t opt); |
| 71 | bool check_copy_ss(copy_ss_t ref, copy_ss_t opt); |
| 72 | bool check_pixelavg_pp(pixelavg_pp_t ref, pixelavg_pp_t opt); |
| 73 | bool check_pixel_sub_ps(pixel_sub_ps_t ref, pixel_sub_ps_t opt); |
| 74 | bool check_pixel_add_ps(pixel_add_ps_t ref, pixel_add_ps_t opt); |
| 75 | bool check_scale_pp(scale_t ref, scale_t opt); |
| 76 | bool check_ssd_s(pixel_ssd_s_t ref, pixel_ssd_s_t opt); |
| 77 | bool check_blockfill_s(blockfill_s_t ref, blockfill_s_t opt); |
| 78 | bool check_calresidual(calcresidual_t ref, calcresidual_t opt); |
| 79 | bool check_transpose(transpose_t ref, transpose_t opt); |
| 80 | bool check_weightp(weightp_pp_t ref, weightp_pp_t opt); |
| 81 | bool check_weightp(weightp_sp_t ref, weightp_sp_t opt); |
| 82 | bool check_downscale_t(downscale_t ref, downscale_t opt); |
| 83 | bool check_cpy2Dto1D_shl_t(cpy2Dto1D_shl_t ref, cpy2Dto1D_shl_t opt); |
| 84 | bool check_cpy2Dto1D_shr_t(cpy2Dto1D_shr_t ref, cpy2Dto1D_shr_t opt); |
| 85 | bool check_cpy1Dto2D_shl_t(cpy1Dto2D_shl_t ref, cpy1Dto2D_shl_t opt); |
| 86 | bool check_cpy1Dto2D_shr_t(cpy1Dto2D_shr_t ref, cpy1Dto2D_shr_t opt); |
| 87 | bool check_copy_cnt_t(copy_cnt_t ref, copy_cnt_t opt); |
| 88 | bool check_pixel_var(var_t ref, var_t opt); |
| 89 | bool check_ssim_4x4x2_core(ssim_4x4x2_core_t ref, ssim_4x4x2_core_t opt); |
| 90 | bool check_ssim_end(ssim_end4_t ref, ssim_end4_t opt); |
| 91 | bool check_addAvg(addAvg_t, addAvg_t); |
| 92 | bool check_saoCuOrgE0_t(saoCuOrgE0_t ref, saoCuOrgE0_t opt); |
| 93 | bool check_planecopy_sp(planecopy_sp_t ref, planecopy_sp_t opt); |
| 94 | bool check_planecopy_cp(planecopy_cp_t ref, planecopy_cp_t opt); |
| 95 | |
| 96 | public: |
| 97 | |
| 98 | PixelHarness(); |
| 99 | |
| 100 | const char *getName() const { return "pixel"; } |
| 101 | |
| 102 | bool testCorrectness(const EncoderPrimitives& ref, const EncoderPrimitives& opt); |
| 103 | bool testPartition(int part, const EncoderPrimitives& ref, const EncoderPrimitives& opt); |
| 104 | |
| 105 | void measureSpeed(const EncoderPrimitives& ref, const EncoderPrimitives& opt); |
| 106 | void measurePartition(int part, const EncoderPrimitives& ref, const EncoderPrimitives& opt); |
| 107 | }; |
| 108 | |
| 109 | #endif // ifndef _PIXELHARNESS_H_1 |