1cabdff1aSopenharmony_ci/* 2cabdff1aSopenharmony_ci * Copyright (c) 2015 Henrik Gramner 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/h264qpel.h" 24cabdff1aSopenharmony_ci#include "libavutil/common.h" 25cabdff1aSopenharmony_ci#include "libavutil/internal.h" 26cabdff1aSopenharmony_ci#include "libavutil/intreadwrite.h" 27cabdff1aSopenharmony_ci#include "libavutil/mem_internal.h" 28cabdff1aSopenharmony_ci 29cabdff1aSopenharmony_cistatic const uint32_t pixel_mask[3] = { 0xffffffff, 0x01ff01ff, 0x03ff03ff }; 30cabdff1aSopenharmony_ci 31cabdff1aSopenharmony_ci#define SIZEOF_PIXEL ((bit_depth + 7) / 8) 32cabdff1aSopenharmony_ci#define BUF_SIZE (2 * 16 * (16 + 3 + 4)) 33cabdff1aSopenharmony_ci 34cabdff1aSopenharmony_ci#define randomize_buffers() \ 35cabdff1aSopenharmony_ci do { \ 36cabdff1aSopenharmony_ci uint32_t mask = pixel_mask[bit_depth - 8]; \ 37cabdff1aSopenharmony_ci int k; \ 38cabdff1aSopenharmony_ci for (k = 0; k < BUF_SIZE; k += 4) { \ 39cabdff1aSopenharmony_ci uint32_t r = rnd() & mask; \ 40cabdff1aSopenharmony_ci AV_WN32A(buf0 + k, r); \ 41cabdff1aSopenharmony_ci AV_WN32A(buf1 + k, r); \ 42cabdff1aSopenharmony_ci r = rnd(); \ 43cabdff1aSopenharmony_ci AV_WN32A(dst0 + k, r); \ 44cabdff1aSopenharmony_ci AV_WN32A(dst1 + k, r); \ 45cabdff1aSopenharmony_ci } \ 46cabdff1aSopenharmony_ci } while (0) 47cabdff1aSopenharmony_ci 48cabdff1aSopenharmony_ci#define src0 (buf0 + 3 * 2 * 16) /* h264qpel functions read data from negative src pointer offsets */ 49cabdff1aSopenharmony_ci#define src1 (buf1 + 3 * 2 * 16) 50cabdff1aSopenharmony_ci 51cabdff1aSopenharmony_civoid checkasm_check_h264qpel(void) 52cabdff1aSopenharmony_ci{ 53cabdff1aSopenharmony_ci LOCAL_ALIGNED_16(uint8_t, buf0, [BUF_SIZE]); 54cabdff1aSopenharmony_ci LOCAL_ALIGNED_16(uint8_t, buf1, [BUF_SIZE]); 55cabdff1aSopenharmony_ci LOCAL_ALIGNED_16(uint8_t, dst0, [BUF_SIZE]); 56cabdff1aSopenharmony_ci LOCAL_ALIGNED_16(uint8_t, dst1, [BUF_SIZE]); 57cabdff1aSopenharmony_ci H264QpelContext h; 58cabdff1aSopenharmony_ci int op, bit_depth, i, j; 59cabdff1aSopenharmony_ci declare_func_emms(AV_CPU_FLAG_MMX | AV_CPU_FLAG_MMXEXT, void, uint8_t *dst, const uint8_t *src, ptrdiff_t stride); 60cabdff1aSopenharmony_ci 61cabdff1aSopenharmony_ci for (op = 0; op < 2; op++) { 62cabdff1aSopenharmony_ci qpel_mc_func (*tab)[16] = op ? h.avg_h264_qpel_pixels_tab : h.put_h264_qpel_pixels_tab; 63cabdff1aSopenharmony_ci const char *op_name = op ? "avg" : "put"; 64cabdff1aSopenharmony_ci 65cabdff1aSopenharmony_ci for (bit_depth = 8; bit_depth <= 10; bit_depth++) { 66cabdff1aSopenharmony_ci ff_h264qpel_init(&h, bit_depth); 67cabdff1aSopenharmony_ci for (i = 0; i < (op ? 3 : 4); i++) { 68cabdff1aSopenharmony_ci int size = 16 >> i; 69cabdff1aSopenharmony_ci for (j = 0; j < 16; j++) 70cabdff1aSopenharmony_ci if (check_func(tab[i][j], "%s_h264_qpel_%d_mc%d%d_%d", op_name, size, j & 3, j >> 2, bit_depth)) { 71cabdff1aSopenharmony_ci randomize_buffers(); 72cabdff1aSopenharmony_ci call_ref(dst0, src0, size * SIZEOF_PIXEL); 73cabdff1aSopenharmony_ci call_new(dst1, src1, size * SIZEOF_PIXEL); 74cabdff1aSopenharmony_ci if (memcmp(buf0, buf1, BUF_SIZE) || memcmp(dst0, dst1, BUF_SIZE)) 75cabdff1aSopenharmony_ci fail(); 76cabdff1aSopenharmony_ci bench_new(dst1, src1, size * SIZEOF_PIXEL); 77cabdff1aSopenharmony_ci } 78cabdff1aSopenharmony_ci } 79cabdff1aSopenharmony_ci } 80cabdff1aSopenharmony_ci report("%s", op_name); 81cabdff1aSopenharmony_ci } 82cabdff1aSopenharmony_ci} 83