1cabdff1aSopenharmony_ci/* 2cabdff1aSopenharmony_ci * Copyright (c) 2015 Shivraj Patil (Shivraj.Patil@imgtec.com) 3cabdff1aSopenharmony_ci * Zhou Xiaoyong <zhouxiaoyong@loongson.cn> 4cabdff1aSopenharmony_ci * 5cabdff1aSopenharmony_ci * This file is part of FFmpeg. 6cabdff1aSopenharmony_ci * 7cabdff1aSopenharmony_ci * FFmpeg is free software; you can redistribute it and/or 8cabdff1aSopenharmony_ci * modify it under the terms of the GNU Lesser General Public 9cabdff1aSopenharmony_ci * License as published by the Free Software Foundation; either 10cabdff1aSopenharmony_ci * version 2.1 of the License, or (at your option) any later version. 11cabdff1aSopenharmony_ci * 12cabdff1aSopenharmony_ci * FFmpeg is distributed in the hope that it will be useful, 13cabdff1aSopenharmony_ci * but WITHOUT ANY WARRANTY; without even the implied warranty of 14cabdff1aSopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15cabdff1aSopenharmony_ci * Lesser General Public License for more details. 16cabdff1aSopenharmony_ci * 17cabdff1aSopenharmony_ci * You should have received a copy of the GNU Lesser General Public 18cabdff1aSopenharmony_ci * License along with FFmpeg; if not, write to the Free Software 19cabdff1aSopenharmony_ci * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20cabdff1aSopenharmony_ci */ 21cabdff1aSopenharmony_ci 22cabdff1aSopenharmony_ci#include "libavutil/attributes.h" 23cabdff1aSopenharmony_ci#include "libavutil/mips/cpu.h" 24cabdff1aSopenharmony_ci#include "config.h" 25cabdff1aSopenharmony_ci#include "h264dsp_mips.h" 26cabdff1aSopenharmony_ci#include "h264pred_mips.h" 27cabdff1aSopenharmony_ci 28cabdff1aSopenharmony_ciav_cold void ff_h264_pred_init_mips(H264PredContext *h, int codec_id, 29cabdff1aSopenharmony_ci int bit_depth, 30cabdff1aSopenharmony_ci const int chroma_format_idc) 31cabdff1aSopenharmony_ci{ 32cabdff1aSopenharmony_ci int cpu_flags = av_get_cpu_flags(); 33cabdff1aSopenharmony_ci 34cabdff1aSopenharmony_ci if (have_mmi(cpu_flags)) { 35cabdff1aSopenharmony_ci if (bit_depth == 8) { 36cabdff1aSopenharmony_ci if (chroma_format_idc == 1) { 37cabdff1aSopenharmony_ci h->pred8x8 [VERT_PRED8x8 ] = ff_pred8x8_vertical_8_mmi; 38cabdff1aSopenharmony_ci h->pred8x8 [HOR_PRED8x8 ] = ff_pred8x8_horizontal_8_mmi; 39cabdff1aSopenharmony_ci } else { 40cabdff1aSopenharmony_ci h->pred8x8 [VERT_PRED8x8 ] = ff_pred8x16_vertical_8_mmi; 41cabdff1aSopenharmony_ci h->pred8x8 [HOR_PRED8x8 ] = ff_pred8x16_horizontal_8_mmi; 42cabdff1aSopenharmony_ci } 43cabdff1aSopenharmony_ci 44cabdff1aSopenharmony_ci h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_8_mmi; 45cabdff1aSopenharmony_ci h->pred16x16[VERT_PRED8x8 ] = ff_pred16x16_vertical_8_mmi; 46cabdff1aSopenharmony_ci h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_8_mmi; 47cabdff1aSopenharmony_ci h->pred8x8l [TOP_DC_PRED ] = ff_pred8x8l_top_dc_8_mmi; 48cabdff1aSopenharmony_ci h->pred8x8l [DC_PRED ] = ff_pred8x8l_dc_8_mmi; 49cabdff1aSopenharmony_ci 50cabdff1aSopenharmony_ci #if ARCH_MIPS64 51cabdff1aSopenharmony_ci switch (codec_id) { 52cabdff1aSopenharmony_ci case AV_CODEC_ID_SVQ3: 53cabdff1aSopenharmony_ci h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_plane_svq3_8_mmi; 54cabdff1aSopenharmony_ci break; 55cabdff1aSopenharmony_ci case AV_CODEC_ID_RV40: 56cabdff1aSopenharmony_ci h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_plane_rv40_8_mmi; 57cabdff1aSopenharmony_ci break; 58cabdff1aSopenharmony_ci case AV_CODEC_ID_VP7: 59cabdff1aSopenharmony_ci case AV_CODEC_ID_VP8: 60cabdff1aSopenharmony_ci break; 61cabdff1aSopenharmony_ci default: 62cabdff1aSopenharmony_ci h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_plane_h264_8_mmi; 63cabdff1aSopenharmony_ci break; 64cabdff1aSopenharmony_ci } 65cabdff1aSopenharmony_ci #endif 66cabdff1aSopenharmony_ci 67cabdff1aSopenharmony_ci if (codec_id == AV_CODEC_ID_SVQ3 || codec_id == AV_CODEC_ID_H264) { 68cabdff1aSopenharmony_ci if (chroma_format_idc == 1) { 69cabdff1aSopenharmony_ci h->pred8x8[TOP_DC_PRED8x8 ] = ff_pred8x8_top_dc_8_mmi; 70cabdff1aSopenharmony_ci h->pred8x8[DC_PRED8x8 ] = ff_pred8x8_dc_8_mmi; 71cabdff1aSopenharmony_ci } 72cabdff1aSopenharmony_ci } 73cabdff1aSopenharmony_ci } 74cabdff1aSopenharmony_ci } 75cabdff1aSopenharmony_ci 76cabdff1aSopenharmony_ci if (have_msa(cpu_flags)) { 77cabdff1aSopenharmony_ci if (8 == bit_depth) { 78cabdff1aSopenharmony_ci if (chroma_format_idc == 1) { 79cabdff1aSopenharmony_ci h->pred8x8[VERT_PRED8x8] = ff_h264_intra_pred_vert_8x8_msa; 80cabdff1aSopenharmony_ci h->pred8x8[HOR_PRED8x8] = ff_h264_intra_pred_horiz_8x8_msa; 81cabdff1aSopenharmony_ci } 82cabdff1aSopenharmony_ci 83cabdff1aSopenharmony_ci if (codec_id != AV_CODEC_ID_VP7 && codec_id != AV_CODEC_ID_VP8) { 84cabdff1aSopenharmony_ci if (chroma_format_idc == 1) { 85cabdff1aSopenharmony_ci h->pred8x8[PLANE_PRED8x8] = ff_h264_intra_predict_plane_8x8_msa; 86cabdff1aSopenharmony_ci } 87cabdff1aSopenharmony_ci } 88cabdff1aSopenharmony_ci if (codec_id != AV_CODEC_ID_RV40 && codec_id != AV_CODEC_ID_VP7 89cabdff1aSopenharmony_ci && codec_id != AV_CODEC_ID_VP8) { 90cabdff1aSopenharmony_ci if (chroma_format_idc == 1) { 91cabdff1aSopenharmony_ci h->pred8x8[DC_PRED8x8] = ff_h264_intra_predict_dc_4blk_8x8_msa; 92cabdff1aSopenharmony_ci h->pred8x8[LEFT_DC_PRED8x8] = 93cabdff1aSopenharmony_ci ff_h264_intra_predict_hor_dc_8x8_msa; 94cabdff1aSopenharmony_ci h->pred8x8[TOP_DC_PRED8x8] = 95cabdff1aSopenharmony_ci ff_h264_intra_predict_vert_dc_8x8_msa; 96cabdff1aSopenharmony_ci h->pred8x8[ALZHEIMER_DC_L0T_PRED8x8] = 97cabdff1aSopenharmony_ci ff_h264_intra_predict_mad_cow_dc_l0t_8x8_msa; 98cabdff1aSopenharmony_ci h->pred8x8[ALZHEIMER_DC_0LT_PRED8x8] = 99cabdff1aSopenharmony_ci ff_h264_intra_predict_mad_cow_dc_0lt_8x8_msa; 100cabdff1aSopenharmony_ci h->pred8x8[ALZHEIMER_DC_L00_PRED8x8] = 101cabdff1aSopenharmony_ci ff_h264_intra_predict_mad_cow_dc_l00_8x8_msa; 102cabdff1aSopenharmony_ci h->pred8x8[ALZHEIMER_DC_0L0_PRED8x8] = 103cabdff1aSopenharmony_ci ff_h264_intra_predict_mad_cow_dc_0l0_8x8_msa; 104cabdff1aSopenharmony_ci } 105cabdff1aSopenharmony_ci } else { 106cabdff1aSopenharmony_ci if (codec_id == AV_CODEC_ID_VP7 || codec_id == AV_CODEC_ID_VP8) { 107cabdff1aSopenharmony_ci h->pred8x8[7] = ff_vp8_pred8x8_127_dc_8_msa; 108cabdff1aSopenharmony_ci h->pred8x8[8] = ff_vp8_pred8x8_129_dc_8_msa; 109cabdff1aSopenharmony_ci } 110cabdff1aSopenharmony_ci } 111cabdff1aSopenharmony_ci 112cabdff1aSopenharmony_ci if (chroma_format_idc == 1) { 113cabdff1aSopenharmony_ci h->pred8x8[DC_128_PRED8x8] = ff_h264_intra_pred_dc_128_8x8_msa; 114cabdff1aSopenharmony_ci } 115cabdff1aSopenharmony_ci 116cabdff1aSopenharmony_ci h->pred16x16[DC_PRED8x8] = ff_h264_intra_pred_dc_16x16_msa; 117cabdff1aSopenharmony_ci h->pred16x16[VERT_PRED8x8] = ff_h264_intra_pred_vert_16x16_msa; 118cabdff1aSopenharmony_ci h->pred16x16[HOR_PRED8x8] = ff_h264_intra_pred_horiz_16x16_msa; 119cabdff1aSopenharmony_ci 120cabdff1aSopenharmony_ci switch (codec_id) { 121cabdff1aSopenharmony_ci case AV_CODEC_ID_SVQ3: 122cabdff1aSopenharmony_ci case AV_CODEC_ID_RV40: 123cabdff1aSopenharmony_ci break; 124cabdff1aSopenharmony_ci case AV_CODEC_ID_VP7: 125cabdff1aSopenharmony_ci case AV_CODEC_ID_VP8: 126cabdff1aSopenharmony_ci h->pred16x16[7] = ff_vp8_pred16x16_127_dc_8_msa; 127cabdff1aSopenharmony_ci h->pred16x16[8] = ff_vp8_pred16x16_129_dc_8_msa; 128cabdff1aSopenharmony_ci break; 129cabdff1aSopenharmony_ci default: 130cabdff1aSopenharmony_ci h->pred16x16[PLANE_PRED8x8] = 131cabdff1aSopenharmony_ci ff_h264_intra_predict_plane_16x16_msa; 132cabdff1aSopenharmony_ci break; 133cabdff1aSopenharmony_ci } 134cabdff1aSopenharmony_ci 135cabdff1aSopenharmony_ci h->pred16x16[LEFT_DC_PRED8x8] = ff_h264_intra_pred_dc_left_16x16_msa; 136cabdff1aSopenharmony_ci h->pred16x16[TOP_DC_PRED8x8] = ff_h264_intra_pred_dc_top_16x16_msa; 137cabdff1aSopenharmony_ci h->pred16x16[DC_128_PRED8x8] = ff_h264_intra_pred_dc_128_16x16_msa; 138cabdff1aSopenharmony_ci } 139cabdff1aSopenharmony_ci } 140cabdff1aSopenharmony_ci} 141