1 /*
2 * Copyright (c) 2015 Parag Salasakar (Parag.Salasakar@imgtec.com)
3 * Copyright (c) 2015 Zhou Xiaoyong <zhouxiaoyong@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/mips/cpu.h"
23 #include "h264dsp_mips.h"
24
ff_h264dsp_init_mips(H264DSPContext * c,const int bit_depth,const int chroma_format_idc)25 av_cold void ff_h264dsp_init_mips(H264DSPContext *c, const int bit_depth,
26 const int chroma_format_idc)
27 {
28 int cpu_flags = av_get_cpu_flags();
29
30 if (have_mmi(cpu_flags)) {
31 if (bit_depth == 8) {
32 c->h264_add_pixels4_clear = ff_h264_add_pixels4_8_mmi;
33 c->h264_idct_add = ff_h264_idct_add_8_mmi;
34 c->h264_idct8_add = ff_h264_idct8_add_8_mmi;
35 c->h264_idct_dc_add = ff_h264_idct_dc_add_8_mmi;
36 c->h264_idct8_dc_add = ff_h264_idct8_dc_add_8_mmi;
37 c->h264_idct_add16 = ff_h264_idct_add16_8_mmi;
38 c->h264_idct_add16intra = ff_h264_idct_add16intra_8_mmi;
39 c->h264_idct8_add4 = ff_h264_idct8_add4_8_mmi;
40
41 if (chroma_format_idc <= 1)
42 c->h264_idct_add8 = ff_h264_idct_add8_8_mmi;
43 else
44 c->h264_idct_add8 = ff_h264_idct_add8_422_8_mmi;
45
46 c->h264_luma_dc_dequant_idct = ff_h264_luma_dc_dequant_idct_8_mmi;
47
48 if (chroma_format_idc <= 1)
49 c->h264_chroma_dc_dequant_idct =
50 ff_h264_chroma_dc_dequant_idct_8_mmi;
51 else
52 c->h264_chroma_dc_dequant_idct =
53 ff_h264_chroma422_dc_dequant_idct_8_mmi;
54
55 c->weight_h264_pixels_tab[0] = ff_h264_weight_pixels16_8_mmi;
56 c->weight_h264_pixels_tab[1] = ff_h264_weight_pixels8_8_mmi;
57 c->weight_h264_pixels_tab[2] = ff_h264_weight_pixels4_8_mmi;
58
59 c->biweight_h264_pixels_tab[0] = ff_h264_biweight_pixels16_8_mmi;
60 c->biweight_h264_pixels_tab[1] = ff_h264_biweight_pixels8_8_mmi;
61 c->biweight_h264_pixels_tab[2] = ff_h264_biweight_pixels4_8_mmi;
62
63 c->h264_v_loop_filter_chroma = ff_deblock_v_chroma_8_mmi;
64 c->h264_v_loop_filter_chroma_intra = ff_deblock_v_chroma_intra_8_mmi;
65
66 if (chroma_format_idc <= 1) {
67 c->h264_h_loop_filter_chroma =
68 ff_deblock_h_chroma_8_mmi;
69 c->h264_h_loop_filter_chroma_intra =
70 ff_deblock_h_chroma_intra_8_mmi;
71 }
72
73 c->h264_v_loop_filter_luma = ff_deblock_v_luma_8_mmi;
74 c->h264_v_loop_filter_luma_intra = ff_deblock_v_luma_intra_8_mmi;
75 c->h264_h_loop_filter_luma = ff_deblock_h_luma_8_mmi;
76 c->h264_h_loop_filter_luma_intra = ff_deblock_h_luma_intra_8_mmi;
77 }
78 }
79
80 if (have_msa(cpu_flags)) {
81 if (bit_depth == 8) {
82 c->h264_v_loop_filter_luma = ff_h264_v_lpf_luma_inter_msa;
83 c->h264_h_loop_filter_luma = ff_h264_h_lpf_luma_inter_msa;
84 c->h264_h_loop_filter_luma_mbaff =
85 ff_h264_h_loop_filter_luma_mbaff_msa;
86 c->h264_v_loop_filter_luma_intra = ff_h264_v_lpf_luma_intra_msa;
87 c->h264_h_loop_filter_luma_intra = ff_h264_h_lpf_luma_intra_msa;
88 c->h264_h_loop_filter_luma_mbaff_intra =
89 ff_h264_h_loop_filter_luma_mbaff_intra_msa;
90 c->h264_v_loop_filter_chroma = ff_h264_v_lpf_chroma_inter_msa;
91
92 if (chroma_format_idc <= 1)
93 c->h264_h_loop_filter_chroma = ff_h264_h_lpf_chroma_inter_msa;
94 else
95 c->h264_h_loop_filter_chroma =
96 ff_h264_h_loop_filter_chroma422_msa;
97
98 if (chroma_format_idc > 1)
99 c->h264_h_loop_filter_chroma_mbaff =
100 ff_h264_h_loop_filter_chroma422_mbaff_msa;
101
102 c->h264_v_loop_filter_chroma_intra =
103 ff_h264_v_lpf_chroma_intra_msa;
104
105 if (chroma_format_idc <= 1)
106 c->h264_h_loop_filter_chroma_intra =
107 ff_h264_h_lpf_chroma_intra_msa;
108
109 /* Weighted MC */
110 c->weight_h264_pixels_tab[0] = ff_weight_h264_pixels16_8_msa;
111 c->weight_h264_pixels_tab[1] = ff_weight_h264_pixels8_8_msa;
112 c->weight_h264_pixels_tab[2] = ff_weight_h264_pixels4_8_msa;
113
114 c->biweight_h264_pixels_tab[0] = ff_biweight_h264_pixels16_8_msa;
115 c->biweight_h264_pixels_tab[1] = ff_biweight_h264_pixels8_8_msa;
116 c->biweight_h264_pixels_tab[2] = ff_biweight_h264_pixels4_8_msa;
117
118 c->h264_idct_add = ff_h264_idct_add_msa;
119 c->h264_idct8_add = ff_h264_idct8_addblk_msa;
120 c->h264_idct_dc_add = ff_h264_idct4x4_addblk_dc_msa;
121 c->h264_idct8_dc_add = ff_h264_idct8_dc_addblk_msa;
122 c->h264_idct_add16 = ff_h264_idct_add16_msa;
123 c->h264_idct8_add4 = ff_h264_idct8_add4_msa;
124
125 if (chroma_format_idc <= 1)
126 c->h264_idct_add8 = ff_h264_idct_add8_msa;
127 else
128 c->h264_idct_add8 = ff_h264_idct_add8_422_msa;
129
130 c->h264_idct_add16intra = ff_h264_idct_add16_intra_msa;
131 c->h264_luma_dc_dequant_idct = ff_h264_deq_idct_luma_dc_msa;
132 }
133 }
134 }
135