1cabdff1aSopenharmony_ci/* 2cabdff1aSopenharmony_ci * Copyright (c) 2017 Jokyo Images 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 "checkasm.h" 24cabdff1aSopenharmony_ci#include "libavcodec/avcodec.h" 25cabdff1aSopenharmony_ci#include "libavcodec/utvideodsp.h" 26cabdff1aSopenharmony_ci#include "libavutil/intreadwrite.h" 27cabdff1aSopenharmony_ci#include "libavutil/mem_internal.h" 28cabdff1aSopenharmony_ci 29cabdff1aSopenharmony_ci#define WIDTH 240 30cabdff1aSopenharmony_ci#define HEIGHT 120 31cabdff1aSopenharmony_ci#define WIDTH_PADDED (WIDTH + 16) /* padded to 32 */ 32cabdff1aSopenharmony_ci#define BUFFER_SIZE (WIDTH_PADDED * HEIGHT) 33cabdff1aSopenharmony_ci 34cabdff1aSopenharmony_ci 35cabdff1aSopenharmony_ci#define randomize_plane(buf, type) \ 36cabdff1aSopenharmony_ci do { \ 37cabdff1aSopenharmony_ci int w, h; \ 38cabdff1aSopenharmony_ci type * tmp = buf; \ 39cabdff1aSopenharmony_ci for (h = 0; h < HEIGHT; h++) { \ 40cabdff1aSopenharmony_ci for (w = 0; w < WIDTH; w++) \ 41cabdff1aSopenharmony_ci tmp[w] = rnd() & 0xFF; \ 42cabdff1aSopenharmony_ci tmp += WIDTH_PADDED; \ 43cabdff1aSopenharmony_ci } \ 44cabdff1aSopenharmony_ci } while (0) 45cabdff1aSopenharmony_ci 46cabdff1aSopenharmony_ci#define cmp_plane(buf0, buf1, s) \ 47cabdff1aSopenharmony_ci do { \ 48cabdff1aSopenharmony_ci int h; \ 49cabdff1aSopenharmony_ci for (h = 0; h < HEIGHT; h++) { \ 50cabdff1aSopenharmony_ci if (memcmp(buf0 + h*WIDTH_PADDED, \ 51cabdff1aSopenharmony_ci buf1 + h*WIDTH_PADDED, WIDTH *s)) \ 52cabdff1aSopenharmony_ci fail();\ 53cabdff1aSopenharmony_ci } \ 54cabdff1aSopenharmony_ci } while (0) 55cabdff1aSopenharmony_ci 56cabdff1aSopenharmony_ci 57cabdff1aSopenharmony_ci#define CHECK_RESTORE(type)\ 58cabdff1aSopenharmony_ciLOCAL_ALIGNED_32(type, src_r0, [BUFFER_SIZE]); \ 59cabdff1aSopenharmony_ciLOCAL_ALIGNED_32(type, src_g0, [BUFFER_SIZE]); \ 60cabdff1aSopenharmony_ciLOCAL_ALIGNED_32(type, src_b0, [BUFFER_SIZE]); \ 61cabdff1aSopenharmony_ciLOCAL_ALIGNED_32(type, src_r1, [BUFFER_SIZE]); \ 62cabdff1aSopenharmony_ciLOCAL_ALIGNED_32(type, src_g1, [BUFFER_SIZE]); \ 63cabdff1aSopenharmony_ciLOCAL_ALIGNED_32(type, src_b1, [BUFFER_SIZE]); \ 64cabdff1aSopenharmony_cideclare_func(void, type *src_r, type *src_g, type *src_b, \ 65cabdff1aSopenharmony_ci ptrdiff_t linesize_r, ptrdiff_t linesize_g, \ 66cabdff1aSopenharmony_ci ptrdiff_t linesize_b, int width, int height); \ 67cabdff1aSopenharmony_cimemset(src_r0, 0, BUFFER_SIZE * sizeof(type)); \ 68cabdff1aSopenharmony_cimemset(src_g0, 0, BUFFER_SIZE * sizeof(type)); \ 69cabdff1aSopenharmony_cimemset(src_b0, 0, BUFFER_SIZE * sizeof(type)); \ 70cabdff1aSopenharmony_cirandomize_plane(src_r0, type); \ 71cabdff1aSopenharmony_cirandomize_plane(src_g0, type); \ 72cabdff1aSopenharmony_cirandomize_plane(src_b0, type); \ 73cabdff1aSopenharmony_cimemcpy(src_r1, src_r0, BUFFER_SIZE * sizeof(type)); \ 74cabdff1aSopenharmony_cimemcpy(src_g1, src_g0, BUFFER_SIZE * sizeof(type)); \ 75cabdff1aSopenharmony_cimemcpy(src_b1, src_b0, BUFFER_SIZE * sizeof(type)); \ 76cabdff1aSopenharmony_cicall_ref(src_r0, src_g0, src_b0, WIDTH_PADDED, WIDTH_PADDED, WIDTH_PADDED, WIDTH, HEIGHT);\ 77cabdff1aSopenharmony_cicall_new(src_r1, src_g1, src_b1, WIDTH_PADDED, WIDTH_PADDED, WIDTH_PADDED, WIDTH, HEIGHT);\ 78cabdff1aSopenharmony_cicmp_plane(src_r0, src_r1, sizeof(type)); \ 79cabdff1aSopenharmony_cicmp_plane(src_g0, src_g1, sizeof(type)); \ 80cabdff1aSopenharmony_cicmp_plane(src_b0, src_b1, sizeof(type)); \ 81cabdff1aSopenharmony_cibench_new(src_r1, src_g1, src_b1, WIDTH_PADDED, WIDTH_PADDED, WIDTH_PADDED, WIDTH, HEIGHT) 82cabdff1aSopenharmony_ci 83cabdff1aSopenharmony_cistatic void check_restore_rgb_planes(void) { 84cabdff1aSopenharmony_ci CHECK_RESTORE(uint8_t); 85cabdff1aSopenharmony_ci} 86cabdff1aSopenharmony_ci 87cabdff1aSopenharmony_cistatic void check_restore_rgb_planes10(void) { 88cabdff1aSopenharmony_ci CHECK_RESTORE(uint16_t); 89cabdff1aSopenharmony_ci} 90cabdff1aSopenharmony_ci 91cabdff1aSopenharmony_civoid checkasm_check_utvideodsp(void) 92cabdff1aSopenharmony_ci{ 93cabdff1aSopenharmony_ci UTVideoDSPContext h; 94cabdff1aSopenharmony_ci 95cabdff1aSopenharmony_ci ff_utvideodsp_init(&h); 96cabdff1aSopenharmony_ci 97cabdff1aSopenharmony_ci if (check_func(h.restore_rgb_planes, "restore_rgb_planes")) 98cabdff1aSopenharmony_ci check_restore_rgb_planes(); 99cabdff1aSopenharmony_ci 100cabdff1aSopenharmony_ci report("restore_rgb_planes"); 101cabdff1aSopenharmony_ci 102cabdff1aSopenharmony_ci if (check_func(h.restore_rgb_planes10, "restore_rgb_planes10")) 103cabdff1aSopenharmony_ci check_restore_rgb_planes10(); 104cabdff1aSopenharmony_ci 105cabdff1aSopenharmony_ci report("restore_rgb_planes10"); 106cabdff1aSopenharmony_ci} 107