1cabdff1aSopenharmony_ci/* 2cabdff1aSopenharmony_ci * Copyright (c) 2016 Alexandra Hájková 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 23cabdff1aSopenharmony_ci#include "libavutil/common.h" 24cabdff1aSopenharmony_ci#include "libavutil/intreadwrite.h" 25cabdff1aSopenharmony_ci#include "libavutil/mem_internal.h" 26cabdff1aSopenharmony_ci 27cabdff1aSopenharmony_ci#include "libavcodec/lossless_videoencdsp.h" 28cabdff1aSopenharmony_ci 29cabdff1aSopenharmony_ci#include "checkasm.h" 30cabdff1aSopenharmony_ci 31cabdff1aSopenharmony_ci#define randomize_buffers(buf, size) \ 32cabdff1aSopenharmony_ci do { \ 33cabdff1aSopenharmony_ci int j; \ 34cabdff1aSopenharmony_ci for (j = 0; j < size; j+=4) \ 35cabdff1aSopenharmony_ci AV_WN32(buf + j, rnd()); \ 36cabdff1aSopenharmony_ci } while (0) 37cabdff1aSopenharmony_ci 38cabdff1aSopenharmony_cistatic const struct {uint8_t w, h, s;} planes[] = { 39cabdff1aSopenharmony_ci {16,16,16}, {21,23,25}, {32,17,48}, {15,128,16}, {128,127,128} 40cabdff1aSopenharmony_ci}; 41cabdff1aSopenharmony_ci 42cabdff1aSopenharmony_ci#define MAX_STRIDE 128 43cabdff1aSopenharmony_ci#define MAX_HEIGHT 127 44cabdff1aSopenharmony_ci 45cabdff1aSopenharmony_cistatic void check_diff_bytes(LLVidEncDSPContext *c) 46cabdff1aSopenharmony_ci{ 47cabdff1aSopenharmony_ci int i; 48cabdff1aSopenharmony_ci LOCAL_ALIGNED_32(uint8_t, dst0, [MAX_STRIDE]); 49cabdff1aSopenharmony_ci LOCAL_ALIGNED_32(uint8_t, dst1, [MAX_STRIDE]); 50cabdff1aSopenharmony_ci LOCAL_ALIGNED_32(uint8_t, src0, [MAX_STRIDE]); 51cabdff1aSopenharmony_ci LOCAL_ALIGNED_32(uint8_t, src1, [MAX_STRIDE]); 52cabdff1aSopenharmony_ci LOCAL_ALIGNED_32(uint8_t, src2, [MAX_STRIDE]); 53cabdff1aSopenharmony_ci LOCAL_ALIGNED_32(uint8_t, src3, [MAX_STRIDE]); 54cabdff1aSopenharmony_ci 55cabdff1aSopenharmony_ci declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *dst, const uint8_t *src1, 56cabdff1aSopenharmony_ci const uint8_t *src2, intptr_t w); 57cabdff1aSopenharmony_ci 58cabdff1aSopenharmony_ci memset(dst0, 0, MAX_STRIDE); 59cabdff1aSopenharmony_ci memset(dst1, 0, MAX_STRIDE); 60cabdff1aSopenharmony_ci randomize_buffers(src0, MAX_STRIDE); 61cabdff1aSopenharmony_ci memcpy(src1, src0, MAX_STRIDE); 62cabdff1aSopenharmony_ci randomize_buffers(src2, MAX_STRIDE); 63cabdff1aSopenharmony_ci memcpy(src3, src2, MAX_STRIDE); 64cabdff1aSopenharmony_ci 65cabdff1aSopenharmony_ci if (check_func(c->diff_bytes, "diff_bytes")) { 66cabdff1aSopenharmony_ci for (i = 0; i < 5; i ++) { 67cabdff1aSopenharmony_ci call_ref(dst0, src0, src2, planes[i].w); 68cabdff1aSopenharmony_ci call_new(dst1, src1, src3, planes[i].w); 69cabdff1aSopenharmony_ci if (memcmp(dst0, dst1, planes[i].w)) 70cabdff1aSopenharmony_ci fail(); 71cabdff1aSopenharmony_ci } 72cabdff1aSopenharmony_ci bench_new(dst1, src0, src2, planes[4].w); 73cabdff1aSopenharmony_ci } 74cabdff1aSopenharmony_ci} 75cabdff1aSopenharmony_ci 76cabdff1aSopenharmony_cistatic void check_sub_left_pred(LLVidEncDSPContext *c) 77cabdff1aSopenharmony_ci{ 78cabdff1aSopenharmony_ci int i; 79cabdff1aSopenharmony_ci LOCAL_ALIGNED_32(uint8_t, dst0, [MAX_STRIDE * MAX_HEIGHT]); 80cabdff1aSopenharmony_ci LOCAL_ALIGNED_32(uint8_t, dst1, [MAX_STRIDE * MAX_HEIGHT]); 81cabdff1aSopenharmony_ci LOCAL_ALIGNED_32(uint8_t, src0, [MAX_STRIDE * MAX_HEIGHT]); 82cabdff1aSopenharmony_ci LOCAL_ALIGNED_32(uint8_t, src1, [MAX_STRIDE * MAX_HEIGHT]); 83cabdff1aSopenharmony_ci 84cabdff1aSopenharmony_ci declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *dst, const uint8_t *src, 85cabdff1aSopenharmony_ci ptrdiff_t stride, ptrdiff_t width, int height); 86cabdff1aSopenharmony_ci 87cabdff1aSopenharmony_ci memset(dst0, 0, MAX_STRIDE * MAX_HEIGHT); 88cabdff1aSopenharmony_ci memset(dst1, 0, MAX_STRIDE * MAX_HEIGHT); 89cabdff1aSopenharmony_ci randomize_buffers(src0, MAX_STRIDE * MAX_HEIGHT); 90cabdff1aSopenharmony_ci memcpy(src1, src0, MAX_STRIDE * MAX_HEIGHT); 91cabdff1aSopenharmony_ci 92cabdff1aSopenharmony_ci if (check_func(c->sub_left_predict, "sub_left_predict")) { 93cabdff1aSopenharmony_ci for (i = 0; i < 5; i ++) { 94cabdff1aSopenharmony_ci call_ref(dst0, src0, planes[i].s, planes[i].w, planes[i].h); 95cabdff1aSopenharmony_ci call_new(dst1, src1, planes[i].s, planes[i].w, planes[i].h); 96cabdff1aSopenharmony_ci if (memcmp(dst0, dst1, planes[i].w * planes[i].h)) 97cabdff1aSopenharmony_ci fail(); 98cabdff1aSopenharmony_ci break; 99cabdff1aSopenharmony_ci } 100cabdff1aSopenharmony_ci bench_new(dst1, src0, planes[4].s, planes[4].w, planes[4].h); 101cabdff1aSopenharmony_ci } 102cabdff1aSopenharmony_ci} 103cabdff1aSopenharmony_ci 104cabdff1aSopenharmony_civoid checkasm_check_llviddspenc(void) 105cabdff1aSopenharmony_ci{ 106cabdff1aSopenharmony_ci LLVidEncDSPContext c; 107cabdff1aSopenharmony_ci ff_llvidencdsp_init(&c); 108cabdff1aSopenharmony_ci 109cabdff1aSopenharmony_ci check_diff_bytes(&c); 110cabdff1aSopenharmony_ci report("diff_bytes"); 111cabdff1aSopenharmony_ci 112cabdff1aSopenharmony_ci check_sub_left_pred(&c); 113cabdff1aSopenharmony_ci report("sub_left_predict"); 114cabdff1aSopenharmony_ci} 115