blob: 3230b44e1ee29320bf73ee423ed499a3eb039e92 [file] [log] [blame]
/*
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "tests/cv/downsample.h"
#include <cstdint>
#include "crt/kelvin.h"
namespace kelvin::cv {
void downsample(int num_output_cols, const uint16_t* input0_row,
const uint16_t* input1_row, uint16_t* output_row) {
int vl_input_0, vl_input_1, vl_output;
int m = 2 * num_output_cols;
int n = num_output_cols;
while (n > 0) {
getvl_h_x_m(vl_input_0, m);
m -= vl_input_0;
getvl_h_x_m(vl_input_1, m);
m -= vl_input_1;
getvl_h_x_m(vl_output, n);
n -= vl_output;
vld_h_lp_xx_m(vm12, input0_row, vl_input_0);
vld_h_lp_xx_m(vm13, input0_row, vl_input_1);
vld_h_lp_xx_m(vm14, input1_row, vl_input_0);
vld_h_lp_xx_m(vm15, input1_row, vl_input_1);
vpadd_w_u_v_m(vm8, vm12);
vpadd_w_u_v_m(vm9, vm13);
vpadd_w_u_v_m(vm10, vm14);
vpadd_w_u_v_m(vm11, vm15);
vadd_w_vv_m(vm6, vm8, vm10);
vadd_w_vv_m(vm7, vm9, vm11);
vevnodd_w_vv_m(vm4, vm6, vm7);
vsransu_h_r_vx_m(vm0, vm4, 2);
vst_h_lp_xx_m(vm0, output_row, vl_output);
}
}
}; // namespace kelvin::cv