• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2015 Manojkumar Bhosale (Manojkumar.Bhosale@imgtec.com)
3  * Copyright (c) 2016 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 /**
23  * @file
24  * VP8 compatible video decoder
25  */
26 
27 #include "libavutil/mips/cpu.h"
28 #include "config.h"
29 #include "libavutil/attributes.h"
30 #include "libavcodec/vp8dsp.h"
31 #include "vp8dsp_mips.h"
32 
33 #define VP8_MC_MIPS_FUNC(IDX, SIZE)            \
34     dsp->put_vp8_epel_pixels_tab[IDX][0][1] =  \
35         ff_put_vp8_epel##SIZE##_h4_msa;        \
36     dsp->put_vp8_epel_pixels_tab[IDX][0][2] =  \
37         ff_put_vp8_epel##SIZE##_h6_msa;        \
38     dsp->put_vp8_epel_pixels_tab[IDX][1][0] =  \
39         ff_put_vp8_epel##SIZE##_v4_msa;        \
40     dsp->put_vp8_epel_pixels_tab[IDX][1][1] =  \
41         ff_put_vp8_epel##SIZE##_h4v4_msa;      \
42     dsp->put_vp8_epel_pixels_tab[IDX][1][2] =  \
43         ff_put_vp8_epel##SIZE##_h6v4_msa;      \
44     dsp->put_vp8_epel_pixels_tab[IDX][2][0] =  \
45         ff_put_vp8_epel##SIZE##_v6_msa;        \
46     dsp->put_vp8_epel_pixels_tab[IDX][2][1] =  \
47         ff_put_vp8_epel##SIZE##_h4v6_msa;      \
48     dsp->put_vp8_epel_pixels_tab[IDX][2][2] =  \
49         ff_put_vp8_epel##SIZE##_h6v6_msa
50 
51 #define VP8_BILINEAR_MC_MIPS_FUNC(IDX, SIZE)       \
52     dsp->put_vp8_bilinear_pixels_tab[IDX][0][1] =  \
53         ff_put_vp8_bilinear##SIZE##_h_msa;         \
54     dsp->put_vp8_bilinear_pixels_tab[IDX][0][2] =  \
55         ff_put_vp8_bilinear##SIZE##_h_msa;         \
56     dsp->put_vp8_bilinear_pixels_tab[IDX][1][0] =  \
57         ff_put_vp8_bilinear##SIZE##_v_msa;         \
58     dsp->put_vp8_bilinear_pixels_tab[IDX][1][1] =  \
59         ff_put_vp8_bilinear##SIZE##_hv_msa;        \
60     dsp->put_vp8_bilinear_pixels_tab[IDX][1][2] =  \
61         ff_put_vp8_bilinear##SIZE##_hv_msa;        \
62     dsp->put_vp8_bilinear_pixels_tab[IDX][2][0] =  \
63         ff_put_vp8_bilinear##SIZE##_v_msa;         \
64     dsp->put_vp8_bilinear_pixels_tab[IDX][2][1] =  \
65         ff_put_vp8_bilinear##SIZE##_hv_msa;        \
66     dsp->put_vp8_bilinear_pixels_tab[IDX][2][2] =  \
67         ff_put_vp8_bilinear##SIZE##_hv_msa
68 
69 #define VP8_MC_MIPS_COPY(IDX, SIZE)                \
70     dsp->put_vp8_epel_pixels_tab[IDX][0][0] =      \
71         ff_put_vp8_pixels##SIZE##_msa;             \
72     dsp->put_vp8_bilinear_pixels_tab[IDX][0][0] =  \
73         ff_put_vp8_pixels##SIZE##_msa;
74 
75 
76 
ff_vp8dsp_init_mips(VP8DSPContext * dsp)77 av_cold void ff_vp8dsp_init_mips(VP8DSPContext *dsp)
78 {
79     int cpu_flags = av_get_cpu_flags();
80 
81     if (have_mmi(cpu_flags)) {
82         dsp->vp8_luma_dc_wht    = ff_vp8_luma_dc_wht_mmi;
83         dsp->vp8_luma_dc_wht_dc = ff_vp8_luma_dc_wht_dc_mmi;
84         dsp->vp8_idct_add       = ff_vp8_idct_add_mmi;
85         dsp->vp8_idct_dc_add    = ff_vp8_idct_dc_add_mmi;
86         dsp->vp8_idct_dc_add4y  = ff_vp8_idct_dc_add4y_mmi;
87         dsp->vp8_idct_dc_add4uv = ff_vp8_idct_dc_add4uv_mmi;
88 
89         dsp->put_vp8_epel_pixels_tab[0][0][1] = ff_put_vp8_epel16_h4_mmi;
90         dsp->put_vp8_epel_pixels_tab[0][0][2] = ff_put_vp8_epel16_h6_mmi;
91         dsp->put_vp8_epel_pixels_tab[0][1][0] = ff_put_vp8_epel16_v4_mmi;
92         dsp->put_vp8_epel_pixels_tab[0][1][1] = ff_put_vp8_epel16_h4v4_mmi;
93         dsp->put_vp8_epel_pixels_tab[0][1][2] = ff_put_vp8_epel16_h6v4_mmi;
94         dsp->put_vp8_epel_pixels_tab[0][2][0] = ff_put_vp8_epel16_v6_mmi;
95         dsp->put_vp8_epel_pixels_tab[0][2][1] = ff_put_vp8_epel16_h4v6_mmi;
96         dsp->put_vp8_epel_pixels_tab[0][2][2] = ff_put_vp8_epel16_h6v6_mmi;
97 
98         dsp->put_vp8_epel_pixels_tab[1][0][1] = ff_put_vp8_epel8_h4_mmi;
99         dsp->put_vp8_epel_pixels_tab[1][0][2] = ff_put_vp8_epel8_h6_mmi;
100         dsp->put_vp8_epel_pixels_tab[1][1][0] = ff_put_vp8_epel8_v4_mmi;
101         dsp->put_vp8_epel_pixels_tab[1][1][1] = ff_put_vp8_epel8_h4v4_mmi;
102         dsp->put_vp8_epel_pixels_tab[1][1][2] = ff_put_vp8_epel8_h6v4_mmi;
103         dsp->put_vp8_epel_pixels_tab[1][2][0] = ff_put_vp8_epel8_v6_mmi;
104         dsp->put_vp8_epel_pixels_tab[1][2][1] = ff_put_vp8_epel8_h4v6_mmi;
105         dsp->put_vp8_epel_pixels_tab[1][2][2] = ff_put_vp8_epel8_h6v6_mmi;
106 
107         dsp->put_vp8_epel_pixels_tab[2][0][1] = ff_put_vp8_epel4_h4_mmi;
108         dsp->put_vp8_epel_pixels_tab[2][0][2] = ff_put_vp8_epel4_h6_mmi;
109         dsp->put_vp8_epel_pixels_tab[2][1][0] = ff_put_vp8_epel4_v4_mmi;
110         dsp->put_vp8_epel_pixels_tab[2][1][1] = ff_put_vp8_epel4_h4v4_mmi;
111         dsp->put_vp8_epel_pixels_tab[2][1][2] = ff_put_vp8_epel4_h6v4_mmi;
112         dsp->put_vp8_epel_pixels_tab[2][2][0] = ff_put_vp8_epel4_v6_mmi;
113         dsp->put_vp8_epel_pixels_tab[2][2][1] = ff_put_vp8_epel4_h4v6_mmi;
114         dsp->put_vp8_epel_pixels_tab[2][2][2] = ff_put_vp8_epel4_h6v6_mmi;
115 
116         dsp->put_vp8_bilinear_pixels_tab[0][0][1] = ff_put_vp8_bilinear16_h_mmi;
117         dsp->put_vp8_bilinear_pixels_tab[0][0][2] = ff_put_vp8_bilinear16_h_mmi;
118         dsp->put_vp8_bilinear_pixels_tab[0][1][0] = ff_put_vp8_bilinear16_v_mmi;
119         dsp->put_vp8_bilinear_pixels_tab[0][1][1] = ff_put_vp8_bilinear16_hv_mmi;
120         dsp->put_vp8_bilinear_pixels_tab[0][1][2] = ff_put_vp8_bilinear16_hv_mmi;
121         dsp->put_vp8_bilinear_pixels_tab[0][2][0] = ff_put_vp8_bilinear16_v_mmi;
122         dsp->put_vp8_bilinear_pixels_tab[0][2][1] = ff_put_vp8_bilinear16_hv_mmi;
123         dsp->put_vp8_bilinear_pixels_tab[0][2][2] = ff_put_vp8_bilinear16_hv_mmi;
124 
125         dsp->put_vp8_bilinear_pixels_tab[1][0][1] = ff_put_vp8_bilinear8_h_mmi;
126         dsp->put_vp8_bilinear_pixels_tab[1][0][2] = ff_put_vp8_bilinear8_h_mmi;
127         dsp->put_vp8_bilinear_pixels_tab[1][1][0] = ff_put_vp8_bilinear8_v_mmi;
128         dsp->put_vp8_bilinear_pixels_tab[1][1][1] = ff_put_vp8_bilinear8_hv_mmi;
129         dsp->put_vp8_bilinear_pixels_tab[1][1][2] = ff_put_vp8_bilinear8_hv_mmi;
130         dsp->put_vp8_bilinear_pixels_tab[1][2][0] = ff_put_vp8_bilinear8_v_mmi;
131         dsp->put_vp8_bilinear_pixels_tab[1][2][1] = ff_put_vp8_bilinear8_hv_mmi;
132         dsp->put_vp8_bilinear_pixels_tab[1][2][2] = ff_put_vp8_bilinear8_hv_mmi;
133 
134         dsp->put_vp8_bilinear_pixels_tab[2][0][1] = ff_put_vp8_bilinear4_h_mmi;
135         dsp->put_vp8_bilinear_pixels_tab[2][0][2] = ff_put_vp8_bilinear4_h_mmi;
136         dsp->put_vp8_bilinear_pixels_tab[2][1][0] = ff_put_vp8_bilinear4_v_mmi;
137         dsp->put_vp8_bilinear_pixels_tab[2][1][1] = ff_put_vp8_bilinear4_hv_mmi;
138         dsp->put_vp8_bilinear_pixels_tab[2][1][2] = ff_put_vp8_bilinear4_hv_mmi;
139         dsp->put_vp8_bilinear_pixels_tab[2][2][0] = ff_put_vp8_bilinear4_v_mmi;
140         dsp->put_vp8_bilinear_pixels_tab[2][2][1] = ff_put_vp8_bilinear4_hv_mmi;
141         dsp->put_vp8_bilinear_pixels_tab[2][2][2] = ff_put_vp8_bilinear4_hv_mmi;
142 
143         dsp->put_vp8_epel_pixels_tab[0][0][0]     = ff_put_vp8_pixels16_mmi;
144         dsp->put_vp8_bilinear_pixels_tab[0][0][0] = ff_put_vp8_pixels16_mmi;
145 
146         dsp->put_vp8_epel_pixels_tab[1][0][0]     = ff_put_vp8_pixels8_mmi;
147         dsp->put_vp8_bilinear_pixels_tab[1][0][0] = ff_put_vp8_pixels8_mmi;
148 
149         dsp->vp8_v_loop_filter16y = ff_vp8_v_loop_filter16_mmi;
150         dsp->vp8_h_loop_filter16y = ff_vp8_h_loop_filter16_mmi;
151         dsp->vp8_v_loop_filter8uv = ff_vp8_v_loop_filter8uv_mmi;
152         dsp->vp8_h_loop_filter8uv = ff_vp8_h_loop_filter8uv_mmi;
153 
154         dsp->vp8_v_loop_filter16y_inner = ff_vp8_v_loop_filter16_inner_mmi;
155         dsp->vp8_h_loop_filter16y_inner = ff_vp8_h_loop_filter16_inner_mmi;
156         dsp->vp8_v_loop_filter8uv_inner = ff_vp8_v_loop_filter8uv_inner_mmi;
157         dsp->vp8_h_loop_filter8uv_inner = ff_vp8_h_loop_filter8uv_inner_mmi;
158 
159         dsp->vp8_v_loop_filter_simple = ff_vp8_v_loop_filter_simple_mmi;
160         dsp->vp8_h_loop_filter_simple = ff_vp8_h_loop_filter_simple_mmi;
161     }
162 
163     if (have_msa(cpu_flags)) {
164         dsp->vp8_luma_dc_wht = ff_vp8_luma_dc_wht_msa;
165         dsp->vp8_idct_add = ff_vp8_idct_add_msa;
166         dsp->vp8_idct_dc_add = ff_vp8_idct_dc_add_msa;
167         dsp->vp8_idct_dc_add4y = ff_vp8_idct_dc_add4y_msa;
168         dsp->vp8_idct_dc_add4uv = ff_vp8_idct_dc_add4uv_msa;
169 
170         VP8_MC_MIPS_FUNC(0, 16);
171         VP8_MC_MIPS_FUNC(1, 8);
172         VP8_MC_MIPS_FUNC(2, 4);
173 
174         VP8_BILINEAR_MC_MIPS_FUNC(0, 16);
175         VP8_BILINEAR_MC_MIPS_FUNC(1, 8);
176         VP8_BILINEAR_MC_MIPS_FUNC(2, 4);
177 
178         VP8_MC_MIPS_COPY(0, 16);
179         VP8_MC_MIPS_COPY(1, 8);
180 
181         dsp->vp8_v_loop_filter16y = ff_vp8_v_loop_filter16_msa;
182         dsp->vp8_h_loop_filter16y = ff_vp8_h_loop_filter16_msa;
183         dsp->vp8_v_loop_filter8uv = ff_vp8_v_loop_filter8uv_msa;
184         dsp->vp8_h_loop_filter8uv = ff_vp8_h_loop_filter8uv_msa;
185 
186         dsp->vp8_v_loop_filter16y_inner = ff_vp8_v_loop_filter16_inner_msa;
187         dsp->vp8_h_loop_filter16y_inner = ff_vp8_h_loop_filter16_inner_msa;
188         dsp->vp8_v_loop_filter8uv_inner = ff_vp8_v_loop_filter8uv_inner_msa;
189         dsp->vp8_h_loop_filter8uv_inner = ff_vp8_h_loop_filter8uv_inner_msa;
190 
191         dsp->vp8_v_loop_filter_simple = ff_vp8_v_loop_filter_simple_msa;
192         dsp->vp8_h_loop_filter_simple = ff_vp8_h_loop_filter_simple_msa;
193     }
194 }
195