1/* 2 * Copyright (c) 2021 Loongson Technology Corporation Limited 3 * Contributed by Hao Chen <chenhao@loongson.cn> 4 * 5 * This file is part of FFmpeg. 6 * 7 * FFmpeg is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU Lesser General Public 9 * License as published by the Free Software Foundation; either 10 * version 2.1 of the License, or (at your option) any later version. 11 * 12 * FFmpeg is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Lesser General Public License for more details. 16 * 17 * You should have received a copy of the GNU Lesser General Public 18 * License along with FFmpeg; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 */ 21 22#include "libavutil/loongarch/cpu.h" 23#include "libavutil/attributes.h" 24#include "libavcodec/vc1dsp.h" 25#include "vc1dsp_loongarch.h" 26 27#define FN_ASSIGN(OP, X, Y, INSN) \ 28 dsp->OP##vc1_mspel_pixels_tab[1][X+4*Y] = ff_##OP##vc1_mspel_mc##X##Y##INSN; \ 29 dsp->OP##vc1_mspel_pixels_tab[0][X+4*Y] = ff_##OP##vc1_mspel_mc##X##Y##_16##INSN 30 31#define FN_ASSIGN_V(OP, Y, INSN) \ 32 dsp->OP##vc1_mspel_pixels_tab[0][4*Y] = ff_##OP##vc1_mspel_mc0##Y##_16##INSN 33 34#define FN_ASSIGN_H(OP, X, INSN) \ 35 dsp->OP##vc1_mspel_pixels_tab[0][X] = ff_##OP##vc1_mspel_mc##X##0_16##INSN 36 37av_cold void ff_vc1dsp_init_loongarch(VC1DSPContext *dsp) 38{ 39 int cpu_flags = av_get_cpu_flags(); 40 41 if (have_lasx(cpu_flags)) { 42 dsp->vc1_inv_trans_8x8 = ff_vc1_inv_trans_8x8_lasx; 43 dsp->vc1_inv_trans_4x8 = ff_vc1_inv_trans_4x8_lasx; 44 dsp->vc1_inv_trans_8x4 = ff_vc1_inv_trans_8x4_lasx; 45 dsp->vc1_inv_trans_4x4 = ff_vc1_inv_trans_4x4_lasx; 46 dsp->vc1_inv_trans_8x8_dc = ff_vc1_inv_trans_8x8_dc_lasx; 47 dsp->vc1_inv_trans_4x8_dc = ff_vc1_inv_trans_4x8_dc_lasx; 48 dsp->vc1_inv_trans_8x4_dc = ff_vc1_inv_trans_8x4_dc_lasx; 49 dsp->vc1_inv_trans_4x4_dc = ff_vc1_inv_trans_4x4_dc_lasx; 50 FN_ASSIGN(put_, 1, 1, _lasx); 51 FN_ASSIGN(put_, 1, 2, _lasx); 52 FN_ASSIGN(put_, 1, 3, _lasx); 53 FN_ASSIGN(put_, 2, 1, _lasx); 54 FN_ASSIGN(put_, 2, 2, _lasx); 55 FN_ASSIGN(put_, 2, 3, _lasx); 56 FN_ASSIGN(put_, 3, 1, _lasx); 57 FN_ASSIGN(put_, 3, 2, _lasx); 58 FN_ASSIGN(put_, 3, 3, _lasx); 59 FN_ASSIGN_V(put_, 1, _lasx); 60 FN_ASSIGN_V(put_, 2, _lasx); 61 FN_ASSIGN_V(put_, 3, _lasx); 62 FN_ASSIGN_H(put_, 1, _lasx); 63 FN_ASSIGN_H(put_, 2, _lasx); 64 FN_ASSIGN_H(put_, 3, _lasx); 65 dsp->put_no_rnd_vc1_chroma_pixels_tab[0] = ff_put_no_rnd_vc1_chroma_mc8_lasx; 66 } 67} 68