aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/mips/vp3dsp_init_mips.c
diff options
context:
space:
mode:
authorJiaxun Yang <jiaxun.yang@flygoat.com>2020-07-18 23:35:40 +0800
committerMichael Niedermayer <michael@niedermayer.cc>2020-07-23 17:21:58 +0200
commite2fa12e3ae0494a72f5d0d4a67633805746391c1 (patch)
tree4e1a4ae3f6d719a68f63957428845d504913eef9 /libavcodec/mips/vp3dsp_init_mips.c
parente387fcd01cb84d9493f3b96158addd2a85f086c6 (diff)
downloadffmpeg-e2fa12e3ae0494a72f5d0d4a67633805746391c1.tar.gz
libavcodec: Enable runtime detection for MIPS MMI & MSA
Apply optimized functions according to cpuflags. MSA is usually put after MMI as it's generally faster than MMI. Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com> Reviewed-by: Shiyou Yin <yinshiyou-hf@loongson.cn> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec/mips/vp3dsp_init_mips.c')
-rw-r--r--libavcodec/mips/vp3dsp_init_mips.c44
1 files changed, 17 insertions, 27 deletions
diff --git a/libavcodec/mips/vp3dsp_init_mips.c b/libavcodec/mips/vp3dsp_init_mips.c
index e183db35b6..4252ff790e 100644
--- a/libavcodec/mips/vp3dsp_init_mips.c
+++ b/libavcodec/mips/vp3dsp_init_mips.c
@@ -19,42 +19,32 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "libavutil/mips/cpu.h"
#include "config.h"
#include "libavutil/attributes.h"
#include "libavcodec/avcodec.h"
#include "libavcodec/vp3dsp.h"
#include "vp3dsp_mips.h"
-#if HAVE_MSA
-static av_cold void vp3dsp_init_msa(VP3DSPContext *c, int flags)
+av_cold void ff_vp3dsp_init_mips(VP3DSPContext *c, int flags)
{
- c->put_no_rnd_pixels_l2 = ff_put_no_rnd_pixels_l2_msa;
+ int cpu_flags = av_get_cpu_flags();
- c->idct_add = ff_vp3_idct_add_msa;
- c->idct_put = ff_vp3_idct_put_msa;
- c->idct_dc_add = ff_vp3_idct_dc_add_msa;
- c->v_loop_filter = ff_vp3_v_loop_filter_msa;
- c->h_loop_filter = ff_vp3_h_loop_filter_msa;
-}
-#endif /* HAVE_MSA */
+ if (have_mmi(cpu_flags)) {
+ c->put_no_rnd_pixels_l2 = ff_put_no_rnd_pixels_l2_mmi;
-#if HAVE_MMI
-static av_cold void vp3dsp_init_mmi(VP3DSPContext *c, int flags)
-{
- c->put_no_rnd_pixels_l2 = ff_put_no_rnd_pixels_l2_mmi;
+ c->idct_add = ff_vp3_idct_add_mmi;
+ c->idct_put = ff_vp3_idct_put_mmi;
+ c->idct_dc_add = ff_vp3_idct_dc_add_mmi;
+ }
- c->idct_add = ff_vp3_idct_add_mmi;
- c->idct_put = ff_vp3_idct_put_mmi;
- c->idct_dc_add = ff_vp3_idct_dc_add_mmi;
-}
-#endif /* HAVE_MMI */
+ if (have_msa(cpu_flags)) {
+ c->put_no_rnd_pixels_l2 = ff_put_no_rnd_pixels_l2_msa;
-av_cold void ff_vp3dsp_init_mips(VP3DSPContext *c, int flags)
-{
-#if HAVE_MMI
- vp3dsp_init_mmi(c, flags);
-#endif /* HAVE_MMI */
-#if HAVE_MSA
- vp3dsp_init_msa(c, flags);
-#endif /* HAVE_MSA */
+ c->idct_add = ff_vp3_idct_add_msa;
+ c->idct_put = ff_vp3_idct_put_msa;
+ c->idct_dc_add = ff_vp3_idct_dc_add_msa;
+ c->v_loop_filter = ff_vp3_v_loop_filter_msa;
+ c->h_loop_filter = ff_vp3_h_loop_filter_msa;
+ }
}