1cabdff1aSopenharmony_ci/* 2cabdff1aSopenharmony_ci * Copyright (c) 2015 James Almer 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 "checkasm.h" 22cabdff1aSopenharmony_ci#include "libavcodec/jpeg2000dsp.h" 23cabdff1aSopenharmony_ci#include "libavutil/common.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 BUF_SIZE 512 29cabdff1aSopenharmony_ci 30cabdff1aSopenharmony_ci#define randomize_buffers() \ 31cabdff1aSopenharmony_ci do { \ 32cabdff1aSopenharmony_ci int i; \ 33cabdff1aSopenharmony_ci for (i = 0; i < BUF_SIZE*3; i++) \ 34cabdff1aSopenharmony_ci src[i] = rnd(); \ 35cabdff1aSopenharmony_ci } while (0) 36cabdff1aSopenharmony_ci 37cabdff1aSopenharmony_ci#define randomize_buffers_float() \ 38cabdff1aSopenharmony_ci do { \ 39cabdff1aSopenharmony_ci int i; \ 40cabdff1aSopenharmony_ci for (i = 0; i < BUF_SIZE*3; i++) \ 41cabdff1aSopenharmony_ci src[i] = (float)rnd() / (UINT_MAX >> 5); \ 42cabdff1aSopenharmony_ci } while (0) 43cabdff1aSopenharmony_ci 44cabdff1aSopenharmony_cistatic void check_rct_int(void) 45cabdff1aSopenharmony_ci{ 46cabdff1aSopenharmony_ci LOCAL_ALIGNED_32(int32_t, src, [BUF_SIZE*3]); 47cabdff1aSopenharmony_ci LOCAL_ALIGNED_32(int32_t, ref, [BUF_SIZE*3]); 48cabdff1aSopenharmony_ci LOCAL_ALIGNED_32(int32_t, new, [BUF_SIZE*3]); 49cabdff1aSopenharmony_ci int32_t *ref0 = &ref[BUF_SIZE*0], *new0 = &new[BUF_SIZE*0]; 50cabdff1aSopenharmony_ci int32_t *ref1 = &ref[BUF_SIZE*1], *new1 = &new[BUF_SIZE*1]; 51cabdff1aSopenharmony_ci int32_t *ref2 = &ref[BUF_SIZE*2], *new2 = &new[BUF_SIZE*2]; 52cabdff1aSopenharmony_ci 53cabdff1aSopenharmony_ci declare_func(void, void *src0, void *src1, void *src2, int csize); 54cabdff1aSopenharmony_ci 55cabdff1aSopenharmony_ci randomize_buffers(); 56cabdff1aSopenharmony_ci memcpy(ref, src, BUF_SIZE * 3 * sizeof(*src)); 57cabdff1aSopenharmony_ci memcpy(new, src, BUF_SIZE * 3 * sizeof(*src)); 58cabdff1aSopenharmony_ci call_ref(ref0, ref1, ref2, BUF_SIZE); 59cabdff1aSopenharmony_ci call_new(new0, new1, new2, BUF_SIZE); 60cabdff1aSopenharmony_ci if (memcmp(ref0, new0, BUF_SIZE * sizeof(*src)) || 61cabdff1aSopenharmony_ci memcmp(ref1, new1, BUF_SIZE * sizeof(*src)) || 62cabdff1aSopenharmony_ci memcmp(ref2, new2, BUF_SIZE * sizeof(*src))) 63cabdff1aSopenharmony_ci fail(); 64cabdff1aSopenharmony_ci memcpy(new, src, BUF_SIZE * 3 * sizeof(*src)); 65cabdff1aSopenharmony_ci bench_new(new0, new1, new2, BUF_SIZE); 66cabdff1aSopenharmony_ci} 67cabdff1aSopenharmony_ci 68cabdff1aSopenharmony_cistatic void check_ict_float(void) 69cabdff1aSopenharmony_ci{ 70cabdff1aSopenharmony_ci LOCAL_ALIGNED_32(float, src, [BUF_SIZE*3]); 71cabdff1aSopenharmony_ci LOCAL_ALIGNED_32(float, ref, [BUF_SIZE*3]); 72cabdff1aSopenharmony_ci LOCAL_ALIGNED_32(float, new, [BUF_SIZE*3]); 73cabdff1aSopenharmony_ci float *ref0 = &ref[BUF_SIZE*0], *new0 = &new[BUF_SIZE*0]; 74cabdff1aSopenharmony_ci float *ref1 = &ref[BUF_SIZE*1], *new1 = &new[BUF_SIZE*1]; 75cabdff1aSopenharmony_ci float *ref2 = &ref[BUF_SIZE*2], *new2 = &new[BUF_SIZE*2]; 76cabdff1aSopenharmony_ci 77cabdff1aSopenharmony_ci declare_func(void, void *src0, void *src1, void *src2, int csize); 78cabdff1aSopenharmony_ci 79cabdff1aSopenharmony_ci randomize_buffers_float(); 80cabdff1aSopenharmony_ci memcpy(ref, src, BUF_SIZE * 3 * sizeof(*src)); 81cabdff1aSopenharmony_ci memcpy(new, src, BUF_SIZE * 3 * sizeof(*src)); 82cabdff1aSopenharmony_ci call_ref(ref0, ref1, ref2, BUF_SIZE); 83cabdff1aSopenharmony_ci call_new(new0, new1, new2, BUF_SIZE); 84cabdff1aSopenharmony_ci if (!float_near_abs_eps_array(ref0, new0, 1.0e-5, BUF_SIZE) || 85cabdff1aSopenharmony_ci !float_near_abs_eps_array(ref1, new1, 1.0e-5, BUF_SIZE) || 86cabdff1aSopenharmony_ci !float_near_abs_eps_array(ref2, new2, 1.0e-5, BUF_SIZE)) 87cabdff1aSopenharmony_ci fail(); 88cabdff1aSopenharmony_ci memcpy(new, src, BUF_SIZE * 3 * sizeof(*src)); 89cabdff1aSopenharmony_ci bench_new(new0, new1, new2, BUF_SIZE); 90cabdff1aSopenharmony_ci} 91cabdff1aSopenharmony_ci 92cabdff1aSopenharmony_civoid checkasm_check_jpeg2000dsp(void) 93cabdff1aSopenharmony_ci{ 94cabdff1aSopenharmony_ci Jpeg2000DSPContext h; 95cabdff1aSopenharmony_ci 96cabdff1aSopenharmony_ci ff_jpeg2000dsp_init(&h); 97cabdff1aSopenharmony_ci 98cabdff1aSopenharmony_ci if (check_func(h.mct_decode[FF_DWT53], "jpeg2000_rct_int")) 99cabdff1aSopenharmony_ci check_rct_int(); 100cabdff1aSopenharmony_ci if (check_func(h.mct_decode[FF_DWT97], "jpeg2000_ict_float")) 101cabdff1aSopenharmony_ci check_ict_float(); 102cabdff1aSopenharmony_ci 103cabdff1aSopenharmony_ci report("mct_decode"); 104cabdff1aSopenharmony_ci} 105