1cabdff1aSopenharmony_ci/* 2cabdff1aSopenharmony_ci * Copyright (c) 2016 Ronald S. Bultje <rsbultje@gmail.com> 3cabdff1aSopenharmony_ci * 4cabdff1aSopenharmony_ci * This file is part of FFmpeg. 5cabdff1aSopenharmony_ci * 6cabdff1aSopenharmony_ci * FFmpeg is free software; you can redistribute it and/or modify 7cabdff1aSopenharmony_ci * it under the terms of the GNU General Public License as published by 8cabdff1aSopenharmony_ci * the Free Software Foundation; either version 2 of the License, or 9cabdff1aSopenharmony_ci * (at your option) any later version. 10cabdff1aSopenharmony_ci * 11cabdff1aSopenharmony_ci * FFmpeg is distributed in the hope that it will be useful, 12cabdff1aSopenharmony_ci * but WITHOUT ANY WARRANTY; without even the implied warranty of 13cabdff1aSopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14cabdff1aSopenharmony_ci * GNU General Public License for more details. 15cabdff1aSopenharmony_ci * 16cabdff1aSopenharmony_ci * You should have received a copy of the GNU General Public License along 17cabdff1aSopenharmony_ci * with FFmpeg; if not, write to the Free Software Foundation, Inc., 18cabdff1aSopenharmony_ci * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19cabdff1aSopenharmony_ci */ 20cabdff1aSopenharmony_ci 21cabdff1aSopenharmony_ci#include <string.h> 22cabdff1aSopenharmony_ci#include "checkasm.h" 23cabdff1aSopenharmony_ci#include "libavcodec/videodsp.h" 24cabdff1aSopenharmony_ci#include "libavutil/internal.h" 25cabdff1aSopenharmony_ci#include "libavutil/intreadwrite.h" 26cabdff1aSopenharmony_ci#include "libavutil/mem_internal.h" 27cabdff1aSopenharmony_ci 28cabdff1aSopenharmony_ci#define randomize_buffers(w, h) \ 29cabdff1aSopenharmony_ci do { \ 30cabdff1aSopenharmony_ci int i; \ 31cabdff1aSopenharmony_ci for (i = 0; i < w * h * sizeof(*src0); i += 4) \ 32cabdff1aSopenharmony_ci AV_WN32A(((uint8_t *) src0) + i, rnd()); \ 33cabdff1aSopenharmony_ci } while (0) 34cabdff1aSopenharmony_ci 35cabdff1aSopenharmony_ci#define iter_1d(type, fix, fix_val, var, var_start, var_end) \ 36cabdff1aSopenharmony_ci for (fix = fix_val, var = var_start; var <= var_end; var++) { \ 37cabdff1aSopenharmony_ci call_ref((type *) dst0, (const type *) (src0 + y * pw + x), \ 38cabdff1aSopenharmony_ci bw * sizeof(type), pw * sizeof(type), \ 39cabdff1aSopenharmony_ci bw, bh, x, y, pw, ph); \ 40cabdff1aSopenharmony_ci call_new((type *) dst1, (const type *) (src1 + y * pw + x), \ 41cabdff1aSopenharmony_ci bw * sizeof(type), pw * sizeof(type), \ 42cabdff1aSopenharmony_ci bw, bh, x, y, pw, ph); \ 43cabdff1aSopenharmony_ci if (memcmp(dst0, dst1, bw * bh * sizeof(type))) \ 44cabdff1aSopenharmony_ci fail(); \ 45cabdff1aSopenharmony_ci bench_new((type *) dst1, (const type *) (src1 + y * pw + x),\ 46cabdff1aSopenharmony_ci bw * sizeof(type), pw * sizeof(type), \ 47cabdff1aSopenharmony_ci bw, bh, x, y, pw, ph); \ 48cabdff1aSopenharmony_ci } 49cabdff1aSopenharmony_ci 50cabdff1aSopenharmony_ci#define check_emu_edge_size(type, src_w, src_h, dst_w, dst_h) \ 51cabdff1aSopenharmony_ci do { \ 52cabdff1aSopenharmony_ci LOCAL_ALIGNED_16(type, src0, [src_w * src_h]); \ 53cabdff1aSopenharmony_ci LOCAL_ALIGNED_16(type, src1, [src_w * src_h]); \ 54cabdff1aSopenharmony_ci int bw = dst_w, bh = dst_h; \ 55cabdff1aSopenharmony_ci int pw = src_w, ph = src_h; \ 56cabdff1aSopenharmony_ci int y, x; \ 57cabdff1aSopenharmony_ci randomize_buffers(src_w, src_h); \ 58cabdff1aSopenharmony_ci memcpy(src1, src0, pw * ph * sizeof(type)); \ 59cabdff1aSopenharmony_ci iter_1d(type, y, 0 - src_h, x, 0 - src_w, src_w - 0); \ 60cabdff1aSopenharmony_ci iter_1d(type, x, src_w - 0, y, 0 - src_h, src_h - 0); \ 61cabdff1aSopenharmony_ci iter_1d(type, y, src_h - 0, x, 0 - src_w, src_w - 0); \ 62cabdff1aSopenharmony_ci iter_1d(type, x, 0 - src_w, y, 0 - src_h, src_h - 0); \ 63cabdff1aSopenharmony_ci } while (0) 64cabdff1aSopenharmony_ci 65cabdff1aSopenharmony_ci#define check_emu_edge(type) \ 66cabdff1aSopenharmony_ci do { \ 67cabdff1aSopenharmony_ci LOCAL_ALIGNED_16(type, dst0, [64 * 64]); \ 68cabdff1aSopenharmony_ci LOCAL_ALIGNED_16(type, dst1, [64 * 64]); \ 69cabdff1aSopenharmony_ci declare_func_emms(AV_CPU_FLAG_MMX | AV_CPU_FLAG_MMXEXT, \ 70cabdff1aSopenharmony_ci void, type *dst, const type *src, \ 71cabdff1aSopenharmony_ci ptrdiff_t dst_linesize, \ 72cabdff1aSopenharmony_ci ptrdiff_t src_linesize, \ 73cabdff1aSopenharmony_ci int block_w, int block_h, \ 74cabdff1aSopenharmony_ci int src_x, int src_y, \ 75cabdff1aSopenharmony_ci int src_w, int src_h); \ 76cabdff1aSopenharmony_ci check_emu_edge_size(type, 16, 1, 64, 64); \ 77cabdff1aSopenharmony_ci check_emu_edge_size(type, 16, 16, 64, 64); \ 78cabdff1aSopenharmony_ci check_emu_edge_size(type, 64, 64, 64, 64); \ 79cabdff1aSopenharmony_ci } while (0) 80cabdff1aSopenharmony_ci 81cabdff1aSopenharmony_civoid checkasm_check_videodsp(void) 82cabdff1aSopenharmony_ci{ 83cabdff1aSopenharmony_ci VideoDSPContext vdsp; 84cabdff1aSopenharmony_ci 85cabdff1aSopenharmony_ci ff_videodsp_init(&vdsp, 8); 86cabdff1aSopenharmony_ci if (check_func(vdsp.emulated_edge_mc, "emulated_edge_mc_8")) 87cabdff1aSopenharmony_ci check_emu_edge(uint8_t); 88cabdff1aSopenharmony_ci 89cabdff1aSopenharmony_ci report("emulated_edge_mc"); 90cabdff1aSopenharmony_ci} 91