diff --git a/libavcodec/mips/blockdsp_init_mips.c b/libavcodec/mips/blockdsp_init_mips.c
index 55ac1c3e99..c6964fa74e 100644
--- a/libavcodec/mips/blockdsp_init_mips.c
+++ b/libavcodec/mips/blockdsp_init_mips.c
@@ -19,36 +19,26 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/mips/cpu.h"
 #include "blockdsp_mips.h"
 
-#if HAVE_MSA
-static av_cold void blockdsp_init_msa(BlockDSPContext *c)
+void ff_blockdsp_init_mips(BlockDSPContext *c)
 {
-    c->clear_block = ff_clear_block_msa;
-    c->clear_blocks = ff_clear_blocks_msa;
+    int cpu_flags = av_get_cpu_flags();
 
-    c->fill_block_tab[0] = ff_fill_block16_msa;
-    c->fill_block_tab[1] = ff_fill_block8_msa;
-}
-#endif  // #if HAVE_MSA
+    if (have_mmi(cpu_flags)) {
+        c->clear_block = ff_clear_block_mmi;
+        c->clear_blocks = ff_clear_blocks_mmi;
 
-#if HAVE_MMI
-static av_cold void blockdsp_init_mmi(BlockDSPContext *c)
-{
-    c->clear_block = ff_clear_block_mmi;
-    c->clear_blocks = ff_clear_blocks_mmi;
+        c->fill_block_tab[0] = ff_fill_block16_mmi;
+        c->fill_block_tab[1] = ff_fill_block8_mmi;
+    }
 
-    c->fill_block_tab[0] = ff_fill_block16_mmi;
-    c->fill_block_tab[1] = ff_fill_block8_mmi;
-}
-#endif /* HAVE_MMI */
+    if (have_msa(cpu_flags)) {
+        c->clear_block = ff_clear_block_msa;
+        c->clear_blocks = ff_clear_blocks_msa;
 
-void ff_blockdsp_init_mips(BlockDSPContext *c)
-{
-#if HAVE_MMI
-    blockdsp_init_mmi(c);
-#endif /* HAVE_MMI */
-#if HAVE_MSA
-    blockdsp_init_msa(c);
-#endif  // #if HAVE_MSA
+        c->fill_block_tab[0] = ff_fill_block16_msa;
+        c->fill_block_tab[1] = ff_fill_block8_msa;
+    }
 }
diff --git a/libavcodec/mips/cabac.h b/libavcodec/mips/cabac.h
index 03b5010edc..c595915eda 100644
--- a/libavcodec/mips/cabac.h
+++ b/libavcodec/mips/cabac.h
@@ -25,7 +25,7 @@
 #define AVCODEC_MIPS_CABAC_H
 
 #include "libavcodec/cabac.h"
-#include "libavutil/mips/mmiutils.h"
+#include "libavutil/mips/asmdefs.h"
 #include "config.h"
 
 #define get_cabac_inline get_cabac_inline_mips
diff --git a/libavcodec/mips/h263dsp_init_mips.c b/libavcodec/mips/h263dsp_init_mips.c
index 09bd93707d..a73eb12d87 100644
--- a/libavcodec/mips/h263dsp_init_mips.c
+++ b/libavcodec/mips/h263dsp_init_mips.c
@@ -18,19 +18,15 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/mips/cpu.h"
 #include "h263dsp_mips.h"
 
-#if HAVE_MSA
-static av_cold void h263dsp_init_msa(H263DSPContext *c)
-{
-    c->h263_h_loop_filter = ff_h263_h_loop_filter_msa;
-    c->h263_v_loop_filter = ff_h263_v_loop_filter_msa;
-}
-#endif  // #if HAVE_MSA
-
 av_cold void ff_h263dsp_init_mips(H263DSPContext *c)
 {
-#if HAVE_MSA
-    h263dsp_init_msa(c);
-#endif  // #if HAVE_MSA
+    int cpu_flags = av_get_cpu_flags();
+
+    if (have_msa(cpu_flags)){
+        c->h263_h_loop_filter = ff_h263_h_loop_filter_msa;
+        c->h263_v_loop_filter = ff_h263_v_loop_filter_msa;
+    }
 }
diff --git a/libavcodec/mips/h264chroma_init_mips.c b/libavcodec/mips/h264chroma_init_mips.c
index ae817e47ae..6bb19d3ddd 100644
--- a/libavcodec/mips/h264chroma_init_mips.c
+++ b/libavcodec/mips/h264chroma_init_mips.c
@@ -19,45 +19,34 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/mips/cpu.h"
 #include "h264chroma_mips.h"
 
-#if HAVE_MSA
-static av_cold void h264chroma_init_msa(H264ChromaContext *c, int bit_depth)
-{
-    const int high_bit_depth = bit_depth > 8;
-
-    if (!high_bit_depth) {
-        c->put_h264_chroma_pixels_tab[0] = ff_put_h264_chroma_mc8_msa;
-        c->put_h264_chroma_pixels_tab[1] = ff_put_h264_chroma_mc4_msa;
-        c->put_h264_chroma_pixels_tab[2] = ff_put_h264_chroma_mc2_msa;
-
-        c->avg_h264_chroma_pixels_tab[0] = ff_avg_h264_chroma_mc8_msa;
-        c->avg_h264_chroma_pixels_tab[1] = ff_avg_h264_chroma_mc4_msa;
-        c->avg_h264_chroma_pixels_tab[2] = ff_avg_h264_chroma_mc2_msa;
-    }
-}
-#endif  // #if HAVE_MSA
 
-#if HAVE_MMI
-static av_cold void h264chroma_init_mmi(H264ChromaContext *c, int bit_depth)
+av_cold void ff_h264chroma_init_mips(H264ChromaContext *c, int bit_depth)
 {
+    int cpu_flags = av_get_cpu_flags();
     int high_bit_depth = bit_depth > 8;
 
-    if (!high_bit_depth) {
-        c->put_h264_chroma_pixels_tab[0] = ff_put_h264_chroma_mc8_mmi;
-        c->avg_h264_chroma_pixels_tab[0] = ff_avg_h264_chroma_mc8_mmi;
-        c->put_h264_chroma_pixels_tab[1] = ff_put_h264_chroma_mc4_mmi;
-        c->avg_h264_chroma_pixels_tab[1] = ff_avg_h264_chroma_mc4_mmi;
+    /* MMI apears to be faster than MSA here */
+    if (have_msa(cpu_flags)) {
+        if (!high_bit_depth) {
+            c->put_h264_chroma_pixels_tab[0] = ff_put_h264_chroma_mc8_msa;
+            c->put_h264_chroma_pixels_tab[1] = ff_put_h264_chroma_mc4_msa;
+            c->put_h264_chroma_pixels_tab[2] = ff_put_h264_chroma_mc2_msa;
+
+            c->avg_h264_chroma_pixels_tab[0] = ff_avg_h264_chroma_mc8_msa;
+            c->avg_h264_chroma_pixels_tab[1] = ff_avg_h264_chroma_mc4_msa;
+            c->avg_h264_chroma_pixels_tab[2] = ff_avg_h264_chroma_mc2_msa;
+        }
     }
-}
-#endif /* HAVE_MMI */
 
-av_cold void ff_h264chroma_init_mips(H264ChromaContext *c, int bit_depth)
-{
-#if HAVE_MMI
-    h264chroma_init_mmi(c, bit_depth);
-#endif /* HAVE_MMI */
-#if HAVE_MSA
-    h264chroma_init_msa(c, bit_depth);
-#endif  // #if HAVE_MSA
+    if (have_mmi(cpu_flags)) {
+        if (!high_bit_depth) {
+            c->put_h264_chroma_pixels_tab[0] = ff_put_h264_chroma_mc8_mmi;
+            c->avg_h264_chroma_pixels_tab[0] = ff_avg_h264_chroma_mc8_mmi;
+            c->put_h264_chroma_pixels_tab[1] = ff_put_h264_chroma_mc4_mmi;
+            c->avg_h264_chroma_pixels_tab[1] = ff_avg_h264_chroma_mc4_mmi;
+        }
+    }
 }
diff --git a/libavcodec/mips/h264dsp_init_mips.c b/libavcodec/mips/h264dsp_init_mips.c
index dc08a25800..9cd05e0f2f 100644
--- a/libavcodec/mips/h264dsp_init_mips.c
+++ b/libavcodec/mips/h264dsp_init_mips.c
@@ -19,129 +19,116 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/mips/cpu.h"
 #include "h264dsp_mips.h"
 
-#if HAVE_MSA
-static av_cold void h264dsp_init_msa(H264DSPContext *c,
-                                     const int bit_depth,
-                                     const int chroma_format_idc)
-{
-    if (8 == bit_depth) {
-        c->h264_v_loop_filter_luma = ff_h264_v_lpf_luma_inter_msa;
-        c->h264_h_loop_filter_luma = ff_h264_h_lpf_luma_inter_msa;
-        c->h264_h_loop_filter_luma_mbaff =
-            ff_h264_h_loop_filter_luma_mbaff_msa;
-        c->h264_v_loop_filter_luma_intra = ff_h264_v_lpf_luma_intra_msa;
-        c->h264_h_loop_filter_luma_intra = ff_h264_h_lpf_luma_intra_msa;
-        c->h264_h_loop_filter_luma_mbaff_intra =
-            ff_h264_h_loop_filter_luma_mbaff_intra_msa;
-        c->h264_v_loop_filter_chroma = ff_h264_v_lpf_chroma_inter_msa;
-
-        if (chroma_format_idc <= 1)
-            c->h264_h_loop_filter_chroma = ff_h264_h_lpf_chroma_inter_msa;
-        else
-            c->h264_h_loop_filter_chroma =
-                ff_h264_h_loop_filter_chroma422_msa;
-
-        if (chroma_format_idc > 1)
-            c->h264_h_loop_filter_chroma_mbaff =
-                ff_h264_h_loop_filter_chroma422_mbaff_msa;
-
-        c->h264_v_loop_filter_chroma_intra =
-            ff_h264_v_lpf_chroma_intra_msa;
-
-        if (chroma_format_idc <= 1)
-            c->h264_h_loop_filter_chroma_intra =
-                ff_h264_h_lpf_chroma_intra_msa;
-
-        /* Weighted MC */
-        c->weight_h264_pixels_tab[0] = ff_weight_h264_pixels16_8_msa;
-        c->weight_h264_pixels_tab[1] = ff_weight_h264_pixels8_8_msa;
-        c->weight_h264_pixels_tab[2] = ff_weight_h264_pixels4_8_msa;
-
-        c->biweight_h264_pixels_tab[0] = ff_biweight_h264_pixels16_8_msa;
-        c->biweight_h264_pixels_tab[1] = ff_biweight_h264_pixels8_8_msa;
-        c->biweight_h264_pixels_tab[2] = ff_biweight_h264_pixels4_8_msa;
-
-        c->h264_idct_add = ff_h264_idct_add_msa;
-        c->h264_idct8_add = ff_h264_idct8_addblk_msa;
-        c->h264_idct_dc_add = ff_h264_idct4x4_addblk_dc_msa;
-        c->h264_idct8_dc_add = ff_h264_idct8_dc_addblk_msa;
-        c->h264_idct_add16 = ff_h264_idct_add16_msa;
-        c->h264_idct8_add4 = ff_h264_idct8_add4_msa;
-
-        if (chroma_format_idc <= 1)
-            c->h264_idct_add8 = ff_h264_idct_add8_msa;
-        else
-            c->h264_idct_add8 = ff_h264_idct_add8_422_msa;
-
-        c->h264_idct_add16intra = ff_h264_idct_add16_intra_msa;
-        c->h264_luma_dc_dequant_idct = ff_h264_deq_idct_luma_dc_msa;
-    }  // if (8 == bit_depth)
-}
-#endif  // #if HAVE_MSA
-
-#if HAVE_MMI
-static av_cold void h264dsp_init_mmi(H264DSPContext * c, const int bit_depth,
-        const int chroma_format_idc)
+av_cold void ff_h264dsp_init_mips(H264DSPContext *c, const int bit_depth,
+                                  const int chroma_format_idc)
 {
-    if (bit_depth == 8) {
-        c->h264_add_pixels4_clear = ff_h264_add_pixels4_8_mmi;
-        c->h264_idct_add = ff_h264_idct_add_8_mmi;
-        c->h264_idct8_add = ff_h264_idct8_add_8_mmi;
-        c->h264_idct_dc_add = ff_h264_idct_dc_add_8_mmi;
-        c->h264_idct8_dc_add = ff_h264_idct8_dc_add_8_mmi;
-        c->h264_idct_add16 = ff_h264_idct_add16_8_mmi;
-        c->h264_idct_add16intra = ff_h264_idct_add16intra_8_mmi;
-        c->h264_idct8_add4 = ff_h264_idct8_add4_8_mmi;
-
-        if (chroma_format_idc <= 1)
-            c->h264_idct_add8 = ff_h264_idct_add8_8_mmi;
-        else
-            c->h264_idct_add8 = ff_h264_idct_add8_422_8_mmi;
-
-        c->h264_luma_dc_dequant_idct = ff_h264_luma_dc_dequant_idct_8_mmi;
-
-        if (chroma_format_idc <= 1)
-            c->h264_chroma_dc_dequant_idct =
-                ff_h264_chroma_dc_dequant_idct_8_mmi;
-        else
-            c->h264_chroma_dc_dequant_idct =
-                ff_h264_chroma422_dc_dequant_idct_8_mmi;
-
-        c->weight_h264_pixels_tab[0] = ff_h264_weight_pixels16_8_mmi;
-        c->weight_h264_pixels_tab[1] = ff_h264_weight_pixels8_8_mmi;
-        c->weight_h264_pixels_tab[2] = ff_h264_weight_pixels4_8_mmi;
-
-        c->biweight_h264_pixels_tab[0] = ff_h264_biweight_pixels16_8_mmi;
-        c->biweight_h264_pixels_tab[1] = ff_h264_biweight_pixels8_8_mmi;
-        c->biweight_h264_pixels_tab[2] = ff_h264_biweight_pixels4_8_mmi;
-
-        c->h264_v_loop_filter_chroma       = ff_deblock_v_chroma_8_mmi;
-        c->h264_v_loop_filter_chroma_intra = ff_deblock_v_chroma_intra_8_mmi;
-
-        if (chroma_format_idc <= 1) {
-            c->h264_h_loop_filter_chroma =
-                ff_deblock_h_chroma_8_mmi;
-            c->h264_h_loop_filter_chroma_intra =
-                ff_deblock_h_chroma_intra_8_mmi;
+    int cpu_flags = av_get_cpu_flags();
+
+    if (have_mmi(cpu_flags)) {
+        if (bit_depth == 8) {
+            c->h264_add_pixels4_clear = ff_h264_add_pixels4_8_mmi;
+            c->h264_idct_add = ff_h264_idct_add_8_mmi;
+            c->h264_idct8_add = ff_h264_idct8_add_8_mmi;
+            c->h264_idct_dc_add = ff_h264_idct_dc_add_8_mmi;
+            c->h264_idct8_dc_add = ff_h264_idct8_dc_add_8_mmi;
+            c->h264_idct_add16 = ff_h264_idct_add16_8_mmi;
+            c->h264_idct_add16intra = ff_h264_idct_add16intra_8_mmi;
+            c->h264_idct8_add4 = ff_h264_idct8_add4_8_mmi;
+
+            if (chroma_format_idc <= 1)
+                c->h264_idct_add8 = ff_h264_idct_add8_8_mmi;
+            else
+                c->h264_idct_add8 = ff_h264_idct_add8_422_8_mmi;
+
+            c->h264_luma_dc_dequant_idct = ff_h264_luma_dc_dequant_idct_8_mmi;
+
+            if (chroma_format_idc <= 1)
+                c->h264_chroma_dc_dequant_idct =
+                    ff_h264_chroma_dc_dequant_idct_8_mmi;
+            else
+                c->h264_chroma_dc_dequant_idct =
+                    ff_h264_chroma422_dc_dequant_idct_8_mmi;
+
+            c->weight_h264_pixels_tab[0] = ff_h264_weight_pixels16_8_mmi;
+            c->weight_h264_pixels_tab[1] = ff_h264_weight_pixels8_8_mmi;
+            c->weight_h264_pixels_tab[2] = ff_h264_weight_pixels4_8_mmi;
+
+            c->biweight_h264_pixels_tab[0] = ff_h264_biweight_pixels16_8_mmi;
+            c->biweight_h264_pixels_tab[1] = ff_h264_biweight_pixels8_8_mmi;
+            c->biweight_h264_pixels_tab[2] = ff_h264_biweight_pixels4_8_mmi;
+
+            c->h264_v_loop_filter_chroma       = ff_deblock_v_chroma_8_mmi;
+            c->h264_v_loop_filter_chroma_intra = ff_deblock_v_chroma_intra_8_mmi;
+
+            if (chroma_format_idc <= 1) {
+                c->h264_h_loop_filter_chroma =
+                    ff_deblock_h_chroma_8_mmi;
+                c->h264_h_loop_filter_chroma_intra =
+                    ff_deblock_h_chroma_intra_8_mmi;
+            }
+
+            c->h264_v_loop_filter_luma = ff_deblock_v_luma_8_mmi;
+            c->h264_v_loop_filter_luma_intra = ff_deblock_v_luma_intra_8_mmi;
+            c->h264_h_loop_filter_luma = ff_deblock_h_luma_8_mmi;
+            c->h264_h_loop_filter_luma_intra = ff_deblock_h_luma_intra_8_mmi;
         }
-
-        c->h264_v_loop_filter_luma = ff_deblock_v_luma_8_mmi;
-        c->h264_v_loop_filter_luma_intra = ff_deblock_v_luma_intra_8_mmi;
-        c->h264_h_loop_filter_luma = ff_deblock_h_luma_8_mmi;
-        c->h264_h_loop_filter_luma_intra = ff_deblock_h_luma_intra_8_mmi;
     }
-}
-#endif /* HAVE_MMI */
 
-av_cold void ff_h264dsp_init_mips(H264DSPContext *c, const int bit_depth,
-                                  const int chroma_format_idc)
-{
-#if HAVE_MMI
-    h264dsp_init_mmi(c, bit_depth, chroma_format_idc);
-#endif /* HAVE_MMI */
-#if HAVE_MSA
-    h264dsp_init_msa(c, bit_depth, chroma_format_idc);
-#endif  // #if HAVE_MSA
+    if (have_msa(cpu_flags)) {
+        if (bit_depth == 8) {
+            c->h264_v_loop_filter_luma = ff_h264_v_lpf_luma_inter_msa;
+            c->h264_h_loop_filter_luma = ff_h264_h_lpf_luma_inter_msa;
+            c->h264_h_loop_filter_luma_mbaff =
+                ff_h264_h_loop_filter_luma_mbaff_msa;
+            c->h264_v_loop_filter_luma_intra = ff_h264_v_lpf_luma_intra_msa;
+            c->h264_h_loop_filter_luma_intra = ff_h264_h_lpf_luma_intra_msa;
+            c->h264_h_loop_filter_luma_mbaff_intra =
+                ff_h264_h_loop_filter_luma_mbaff_intra_msa;
+            c->h264_v_loop_filter_chroma = ff_h264_v_lpf_chroma_inter_msa;
+
+            if (chroma_format_idc <= 1)
+                c->h264_h_loop_filter_chroma = ff_h264_h_lpf_chroma_inter_msa;
+            else
+                c->h264_h_loop_filter_chroma =
+                    ff_h264_h_loop_filter_chroma422_msa;
+
+            if (chroma_format_idc > 1)
+                c->h264_h_loop_filter_chroma_mbaff =
+                    ff_h264_h_loop_filter_chroma422_mbaff_msa;
+
+            c->h264_v_loop_filter_chroma_intra =
+                ff_h264_v_lpf_chroma_intra_msa;
+
+            if (chroma_format_idc <= 1)
+                c->h264_h_loop_filter_chroma_intra =
+                    ff_h264_h_lpf_chroma_intra_msa;
+
+            /* Weighted MC */
+            c->weight_h264_pixels_tab[0] = ff_weight_h264_pixels16_8_msa;
+            c->weight_h264_pixels_tab[1] = ff_weight_h264_pixels8_8_msa;
+            c->weight_h264_pixels_tab[2] = ff_weight_h264_pixels4_8_msa;
+
+            c->biweight_h264_pixels_tab[0] = ff_biweight_h264_pixels16_8_msa;
+            c->biweight_h264_pixels_tab[1] = ff_biweight_h264_pixels8_8_msa;
+            c->biweight_h264_pixels_tab[2] = ff_biweight_h264_pixels4_8_msa;
+
+            c->h264_idct_add = ff_h264_idct_add_msa;
+            c->h264_idct8_add = ff_h264_idct8_addblk_msa;
+            c->h264_idct_dc_add = ff_h264_idct4x4_addblk_dc_msa;
+            c->h264_idct8_dc_add = ff_h264_idct8_dc_addblk_msa;
+            c->h264_idct_add16 = ff_h264_idct_add16_msa;
+            c->h264_idct8_add4 = ff_h264_idct8_add4_msa;
+
+            if (chroma_format_idc <= 1)
+                c->h264_idct_add8 = ff_h264_idct_add8_msa;
+            else
+                c->h264_idct_add8 = ff_h264_idct_add8_422_msa;
+
+            c->h264_idct_add16intra = ff_h264_idct_add16_intra_msa;
+            c->h264_luma_dc_dequant_idct = ff_h264_deq_idct_luma_dc_msa;
+        }
+    }
 }
diff --git a/libavcodec/mips/h264pred_init_mips.c b/libavcodec/mips/h264pred_init_mips.c
index e537ad8bd4..0fd9bb737a 100644
--- a/libavcodec/mips/h264pred_init_mips.c
+++ b/libavcodec/mips/h264pred_init_mips.c
@@ -19,134 +19,121 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/mips/cpu.h"
 #include "config.h"
 #include "h264dsp_mips.h"
 #include "h264pred_mips.h"
 
-#if HAVE_MSA
-static av_cold void h264_pred_init_msa(H264PredContext *h, int codec_id,
-                                       const int bit_depth,
-                                       const int chroma_format_idc)
+av_cold void ff_h264_pred_init_mips(H264PredContext *h, int codec_id,
+                                    int bit_depth,
+                                    const int chroma_format_idc)
 {
-    if (8 == bit_depth) {
-        if (chroma_format_idc == 1) {
-            h->pred8x8[VERT_PRED8x8] = ff_h264_intra_pred_vert_8x8_msa;
-            h->pred8x8[HOR_PRED8x8] = ff_h264_intra_pred_horiz_8x8_msa;
-        }
+    int cpu_flags = av_get_cpu_flags();
 
-        if (codec_id != AV_CODEC_ID_VP7 && codec_id != AV_CODEC_ID_VP8) {
+    if (have_mmi(cpu_flags)) {
+        if (bit_depth == 8) {
             if (chroma_format_idc == 1) {
-                h->pred8x8[PLANE_PRED8x8] = ff_h264_intra_predict_plane_8x8_msa;
-            }
-        }
-        if (codec_id != AV_CODEC_ID_RV40 && codec_id != AV_CODEC_ID_VP7
-            && codec_id != AV_CODEC_ID_VP8) {
-            if (chroma_format_idc == 1) {
-                h->pred8x8[DC_PRED8x8] = ff_h264_intra_predict_dc_4blk_8x8_msa;
-                h->pred8x8[LEFT_DC_PRED8x8] =
-                    ff_h264_intra_predict_hor_dc_8x8_msa;
-                h->pred8x8[TOP_DC_PRED8x8] =
-                    ff_h264_intra_predict_vert_dc_8x8_msa;
-                h->pred8x8[ALZHEIMER_DC_L0T_PRED8x8] =
-                    ff_h264_intra_predict_mad_cow_dc_l0t_8x8_msa;
-                h->pred8x8[ALZHEIMER_DC_0LT_PRED8x8] =
-                    ff_h264_intra_predict_mad_cow_dc_0lt_8x8_msa;
-                h->pred8x8[ALZHEIMER_DC_L00_PRED8x8] =
-                    ff_h264_intra_predict_mad_cow_dc_l00_8x8_msa;
-                h->pred8x8[ALZHEIMER_DC_0L0_PRED8x8] =
-                    ff_h264_intra_predict_mad_cow_dc_0l0_8x8_msa;
-            }
-        } else {
-            if (codec_id == AV_CODEC_ID_VP7 || codec_id == AV_CODEC_ID_VP8) {
-                h->pred8x8[7] = ff_vp8_pred8x8_127_dc_8_msa;
-                h->pred8x8[8] = ff_vp8_pred8x8_129_dc_8_msa;
+                h->pred8x8  [VERT_PRED8x8       ] = ff_pred8x8_vertical_8_mmi;
+                h->pred8x8  [HOR_PRED8x8        ] = ff_pred8x8_horizontal_8_mmi;
+            } else {
+                h->pred8x8  [VERT_PRED8x8       ] = ff_pred8x16_vertical_8_mmi;
+                h->pred8x8  [HOR_PRED8x8        ] = ff_pred8x16_horizontal_8_mmi;
             }
-        }
 
-        if (chroma_format_idc == 1) {
-            h->pred8x8[DC_128_PRED8x8] = ff_h264_intra_pred_dc_128_8x8_msa;
-        }
+            h->pred16x16[DC_PRED8x8             ] = ff_pred16x16_dc_8_mmi;
+            h->pred16x16[VERT_PRED8x8           ] = ff_pred16x16_vertical_8_mmi;
+            h->pred16x16[HOR_PRED8x8            ] = ff_pred16x16_horizontal_8_mmi;
+            h->pred8x8l [TOP_DC_PRED            ] = ff_pred8x8l_top_dc_8_mmi;
+            h->pred8x8l [DC_PRED                ] = ff_pred8x8l_dc_8_mmi;
 
-        h->pred16x16[DC_PRED8x8] = ff_h264_intra_pred_dc_16x16_msa;
-        h->pred16x16[VERT_PRED8x8] = ff_h264_intra_pred_vert_16x16_msa;
-        h->pred16x16[HOR_PRED8x8] = ff_h264_intra_pred_horiz_16x16_msa;
+    #if ARCH_MIPS64
+            switch (codec_id) {
+            case AV_CODEC_ID_SVQ3:
+                h->pred16x16[PLANE_PRED8x8      ] = ff_pred16x16_plane_svq3_8_mmi;
+                break;
+            case AV_CODEC_ID_RV40:
+                h->pred16x16[PLANE_PRED8x8      ] = ff_pred16x16_plane_rv40_8_mmi;
+                break;
+            case AV_CODEC_ID_VP7:
+            case AV_CODEC_ID_VP8:
+                break;
+            default:
+                h->pred16x16[PLANE_PRED8x8      ] = ff_pred16x16_plane_h264_8_mmi;
+                break;
+            }
+    #endif
 
-        switch (codec_id) {
-        case AV_CODEC_ID_SVQ3:
-        case AV_CODEC_ID_RV40:
-            break;
-        case AV_CODEC_ID_VP7:
-        case AV_CODEC_ID_VP8:
-            h->pred16x16[7] = ff_vp8_pred16x16_127_dc_8_msa;
-            h->pred16x16[8] = ff_vp8_pred16x16_129_dc_8_msa;
-            break;
-        default:
-            h->pred16x16[PLANE_PRED8x8] =
-                ff_h264_intra_predict_plane_16x16_msa;
-            break;
+            if (codec_id == AV_CODEC_ID_SVQ3 || codec_id == AV_CODEC_ID_H264) {
+                if (chroma_format_idc == 1) {
+                    h->pred8x8[TOP_DC_PRED8x8   ] = ff_pred8x8_top_dc_8_mmi;
+                    h->pred8x8[DC_PRED8x8       ] = ff_pred8x8_dc_8_mmi;
+                }
+            }
         }
-
-        h->pred16x16[LEFT_DC_PRED8x8] = ff_h264_intra_pred_dc_left_16x16_msa;
-        h->pred16x16[TOP_DC_PRED8x8] = ff_h264_intra_pred_dc_top_16x16_msa;
-        h->pred16x16[DC_128_PRED8x8] = ff_h264_intra_pred_dc_128_16x16_msa;
     }
-}
-#endif  // #if HAVE_MSA
-
-#if HAVE_MMI
-static av_cold void h264_pred_init_mmi(H264PredContext *h, int codec_id,
-        const int bit_depth, const int chroma_format_idc)
-{
-    if (bit_depth == 8) {
-        if (chroma_format_idc == 1) {
-            h->pred8x8  [VERT_PRED8x8       ] = ff_pred8x8_vertical_8_mmi;
-            h->pred8x8  [HOR_PRED8x8        ] = ff_pred8x8_horizontal_8_mmi;
-        } else {
-            h->pred8x8  [VERT_PRED8x8       ] = ff_pred8x16_vertical_8_mmi;
-            h->pred8x8  [HOR_PRED8x8        ] = ff_pred8x16_horizontal_8_mmi;
-        }
 
-        h->pred16x16[DC_PRED8x8             ] = ff_pred16x16_dc_8_mmi;
-        h->pred16x16[VERT_PRED8x8           ] = ff_pred16x16_vertical_8_mmi;
-        h->pred16x16[HOR_PRED8x8            ] = ff_pred16x16_horizontal_8_mmi;
-        h->pred8x8l [TOP_DC_PRED            ] = ff_pred8x8l_top_dc_8_mmi;
-        h->pred8x8l [DC_PRED                ] = ff_pred8x8l_dc_8_mmi;
+    if (have_msa(cpu_flags)) {
+        if (8 == bit_depth) {
+            if (chroma_format_idc == 1) {
+                h->pred8x8[VERT_PRED8x8] = ff_h264_intra_pred_vert_8x8_msa;
+                h->pred8x8[HOR_PRED8x8] = ff_h264_intra_pred_horiz_8x8_msa;
+            }
 
-#if ARCH_MIPS64
-        switch (codec_id) {
-        case AV_CODEC_ID_SVQ3:
-            h->pred16x16[PLANE_PRED8x8      ] = ff_pred16x16_plane_svq3_8_mmi;
-            break;
-        case AV_CODEC_ID_RV40:
-            h->pred16x16[PLANE_PRED8x8      ] = ff_pred16x16_plane_rv40_8_mmi;
-            break;
-        case AV_CODEC_ID_VP7:
-        case AV_CODEC_ID_VP8:
-            break;
-        default:
-            h->pred16x16[PLANE_PRED8x8      ] = ff_pred16x16_plane_h264_8_mmi;
-            break;
-        }
-#endif
+            if (codec_id != AV_CODEC_ID_VP7 && codec_id != AV_CODEC_ID_VP8) {
+                if (chroma_format_idc == 1) {
+                    h->pred8x8[PLANE_PRED8x8] = ff_h264_intra_predict_plane_8x8_msa;
+                }
+            }
+            if (codec_id != AV_CODEC_ID_RV40 && codec_id != AV_CODEC_ID_VP7
+                && codec_id != AV_CODEC_ID_VP8) {
+                if (chroma_format_idc == 1) {
+                    h->pred8x8[DC_PRED8x8] = ff_h264_intra_predict_dc_4blk_8x8_msa;
+                    h->pred8x8[LEFT_DC_PRED8x8] =
+                        ff_h264_intra_predict_hor_dc_8x8_msa;
+                    h->pred8x8[TOP_DC_PRED8x8] =
+                        ff_h264_intra_predict_vert_dc_8x8_msa;
+                    h->pred8x8[ALZHEIMER_DC_L0T_PRED8x8] =
+                        ff_h264_intra_predict_mad_cow_dc_l0t_8x8_msa;
+                    h->pred8x8[ALZHEIMER_DC_0LT_PRED8x8] =
+                        ff_h264_intra_predict_mad_cow_dc_0lt_8x8_msa;
+                    h->pred8x8[ALZHEIMER_DC_L00_PRED8x8] =
+                        ff_h264_intra_predict_mad_cow_dc_l00_8x8_msa;
+                    h->pred8x8[ALZHEIMER_DC_0L0_PRED8x8] =
+                        ff_h264_intra_predict_mad_cow_dc_0l0_8x8_msa;
+                }
+            } else {
+                if (codec_id == AV_CODEC_ID_VP7 || codec_id == AV_CODEC_ID_VP8) {
+                    h->pred8x8[7] = ff_vp8_pred8x8_127_dc_8_msa;
+                    h->pred8x8[8] = ff_vp8_pred8x8_129_dc_8_msa;
+                }
+            }
 
-        if (codec_id == AV_CODEC_ID_SVQ3 || codec_id == AV_CODEC_ID_H264) {
             if (chroma_format_idc == 1) {
-                h->pred8x8[TOP_DC_PRED8x8   ] = ff_pred8x8_top_dc_8_mmi;
-                h->pred8x8[DC_PRED8x8       ] = ff_pred8x8_dc_8_mmi;
+                h->pred8x8[DC_128_PRED8x8] = ff_h264_intra_pred_dc_128_8x8_msa;
+            }
+
+            h->pred16x16[DC_PRED8x8] = ff_h264_intra_pred_dc_16x16_msa;
+            h->pred16x16[VERT_PRED8x8] = ff_h264_intra_pred_vert_16x16_msa;
+            h->pred16x16[HOR_PRED8x8] = ff_h264_intra_pred_horiz_16x16_msa;
+
+            switch (codec_id) {
+            case AV_CODEC_ID_SVQ3:
+            case AV_CODEC_ID_RV40:
+                break;
+            case AV_CODEC_ID_VP7:
+            case AV_CODEC_ID_VP8:
+                h->pred16x16[7] = ff_vp8_pred16x16_127_dc_8_msa;
+                h->pred16x16[8] = ff_vp8_pred16x16_129_dc_8_msa;
+                break;
+            default:
+                h->pred16x16[PLANE_PRED8x8] =
+                    ff_h264_intra_predict_plane_16x16_msa;
+                break;
             }
+
+            h->pred16x16[LEFT_DC_PRED8x8] = ff_h264_intra_pred_dc_left_16x16_msa;
+            h->pred16x16[TOP_DC_PRED8x8] = ff_h264_intra_pred_dc_top_16x16_msa;
+            h->pred16x16[DC_128_PRED8x8] = ff_h264_intra_pred_dc_128_16x16_msa;
         }
     }
 }
-#endif /* HAVE_MMI */
-
-av_cold void ff_h264_pred_init_mips(H264PredContext *h, int codec_id,
-                                    int bit_depth,
-                                    const int chroma_format_idc)
-{
-#if HAVE_MMI
-    h264_pred_init_mmi(h, codec_id, bit_depth, chroma_format_idc);
-#endif /* HAVE_MMI */
-#if HAVE_MSA
-    h264_pred_init_msa(h, codec_id, bit_depth, chroma_format_idc);
-#endif  // #if HAVE_MSA
-}
diff --git a/libavcodec/mips/h264qpel_init_mips.c b/libavcodec/mips/h264qpel_init_mips.c
index 33bae3093a..d896a4841b 100644
--- a/libavcodec/mips/h264qpel_init_mips.c
+++ b/libavcodec/mips/h264qpel_init_mips.c
@@ -19,231 +19,221 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/mips/cpu.h"
 #include "h264dsp_mips.h"
 
-#if HAVE_MSA
-static av_cold void h264qpel_init_msa(H264QpelContext *c, int bit_depth)
+av_cold void ff_h264qpel_init_mips(H264QpelContext *c, int bit_depth)
 {
-    if (8 == bit_depth) {
-        c->put_h264_qpel_pixels_tab[0][0] = ff_put_h264_qpel16_mc00_msa;
-        c->put_h264_qpel_pixels_tab[0][1] = ff_put_h264_qpel16_mc10_msa;
-        c->put_h264_qpel_pixels_tab[0][2] = ff_put_h264_qpel16_mc20_msa;
-        c->put_h264_qpel_pixels_tab[0][3] = ff_put_h264_qpel16_mc30_msa;
-        c->put_h264_qpel_pixels_tab[0][4] = ff_put_h264_qpel16_mc01_msa;
-        c->put_h264_qpel_pixels_tab[0][5] = ff_put_h264_qpel16_mc11_msa;
-        c->put_h264_qpel_pixels_tab[0][6] = ff_put_h264_qpel16_mc21_msa;
-        c->put_h264_qpel_pixels_tab[0][7] = ff_put_h264_qpel16_mc31_msa;
-        c->put_h264_qpel_pixels_tab[0][8] = ff_put_h264_qpel16_mc02_msa;
-        c->put_h264_qpel_pixels_tab[0][9] = ff_put_h264_qpel16_mc12_msa;
-        c->put_h264_qpel_pixels_tab[0][10] = ff_put_h264_qpel16_mc22_msa;
-        c->put_h264_qpel_pixels_tab[0][11] = ff_put_h264_qpel16_mc32_msa;
-        c->put_h264_qpel_pixels_tab[0][12] = ff_put_h264_qpel16_mc03_msa;
-        c->put_h264_qpel_pixels_tab[0][13] = ff_put_h264_qpel16_mc13_msa;
-        c->put_h264_qpel_pixels_tab[0][14] = ff_put_h264_qpel16_mc23_msa;
-        c->put_h264_qpel_pixels_tab[0][15] = ff_put_h264_qpel16_mc33_msa;
+    int cpu_flags = av_get_cpu_flags();
+
+    if (have_mmi(cpu_flags)) {
+        if (bit_depth == 8) {
+            c->put_h264_qpel_pixels_tab[0][0] = ff_put_h264_qpel16_mc00_mmi;
+            c->put_h264_qpel_pixels_tab[0][1] = ff_put_h264_qpel16_mc10_mmi;
+            c->put_h264_qpel_pixels_tab[0][2] = ff_put_h264_qpel16_mc20_mmi;
+            c->put_h264_qpel_pixels_tab[0][3] = ff_put_h264_qpel16_mc30_mmi;
+            c->put_h264_qpel_pixels_tab[0][4] = ff_put_h264_qpel16_mc01_mmi;
+            c->put_h264_qpel_pixels_tab[0][5] = ff_put_h264_qpel16_mc11_mmi;
+            c->put_h264_qpel_pixels_tab[0][6] = ff_put_h264_qpel16_mc21_mmi;
+            c->put_h264_qpel_pixels_tab[0][7] = ff_put_h264_qpel16_mc31_mmi;
+            c->put_h264_qpel_pixels_tab[0][8] = ff_put_h264_qpel16_mc02_mmi;
+            c->put_h264_qpel_pixels_tab[0][9] = ff_put_h264_qpel16_mc12_mmi;
+            c->put_h264_qpel_pixels_tab[0][10] = ff_put_h264_qpel16_mc22_mmi;
+            c->put_h264_qpel_pixels_tab[0][11] = ff_put_h264_qpel16_mc32_mmi;
+            c->put_h264_qpel_pixels_tab[0][12] = ff_put_h264_qpel16_mc03_mmi;
+            c->put_h264_qpel_pixels_tab[0][13] = ff_put_h264_qpel16_mc13_mmi;
+            c->put_h264_qpel_pixels_tab[0][14] = ff_put_h264_qpel16_mc23_mmi;
+            c->put_h264_qpel_pixels_tab[0][15] = ff_put_h264_qpel16_mc33_mmi;
 
-        c->put_h264_qpel_pixels_tab[1][0] = ff_put_h264_qpel8_mc00_msa;
-        c->put_h264_qpel_pixels_tab[1][1] = ff_put_h264_qpel8_mc10_msa;
-        c->put_h264_qpel_pixels_tab[1][2] = ff_put_h264_qpel8_mc20_msa;
-        c->put_h264_qpel_pixels_tab[1][3] = ff_put_h264_qpel8_mc30_msa;
-        c->put_h264_qpel_pixels_tab[1][4] = ff_put_h264_qpel8_mc01_msa;
-        c->put_h264_qpel_pixels_tab[1][5] = ff_put_h264_qpel8_mc11_msa;
-        c->put_h264_qpel_pixels_tab[1][6] = ff_put_h264_qpel8_mc21_msa;
-        c->put_h264_qpel_pixels_tab[1][7] = ff_put_h264_qpel8_mc31_msa;
-        c->put_h264_qpel_pixels_tab[1][8] = ff_put_h264_qpel8_mc02_msa;
-        c->put_h264_qpel_pixels_tab[1][9] = ff_put_h264_qpel8_mc12_msa;
-        c->put_h264_qpel_pixels_tab[1][10] = ff_put_h264_qpel8_mc22_msa;
-        c->put_h264_qpel_pixels_tab[1][11] = ff_put_h264_qpel8_mc32_msa;
-        c->put_h264_qpel_pixels_tab[1][12] = ff_put_h264_qpel8_mc03_msa;
-        c->put_h264_qpel_pixels_tab[1][13] = ff_put_h264_qpel8_mc13_msa;
-        c->put_h264_qpel_pixels_tab[1][14] = ff_put_h264_qpel8_mc23_msa;
-        c->put_h264_qpel_pixels_tab[1][15] = ff_put_h264_qpel8_mc33_msa;
+            c->put_h264_qpel_pixels_tab[1][0] = ff_put_h264_qpel8_mc00_mmi;
+            c->put_h264_qpel_pixels_tab[1][1] = ff_put_h264_qpel8_mc10_mmi;
+            c->put_h264_qpel_pixels_tab[1][2] = ff_put_h264_qpel8_mc20_mmi;
+            c->put_h264_qpel_pixels_tab[1][3] = ff_put_h264_qpel8_mc30_mmi;
+            c->put_h264_qpel_pixels_tab[1][4] = ff_put_h264_qpel8_mc01_mmi;
+            c->put_h264_qpel_pixels_tab[1][5] = ff_put_h264_qpel8_mc11_mmi;
+            c->put_h264_qpel_pixels_tab[1][6] = ff_put_h264_qpel8_mc21_mmi;
+            c->put_h264_qpel_pixels_tab[1][7] = ff_put_h264_qpel8_mc31_mmi;
+            c->put_h264_qpel_pixels_tab[1][8] = ff_put_h264_qpel8_mc02_mmi;
+            c->put_h264_qpel_pixels_tab[1][9] = ff_put_h264_qpel8_mc12_mmi;
+            c->put_h264_qpel_pixels_tab[1][10] = ff_put_h264_qpel8_mc22_mmi;
+            c->put_h264_qpel_pixels_tab[1][11] = ff_put_h264_qpel8_mc32_mmi;
+            c->put_h264_qpel_pixels_tab[1][12] = ff_put_h264_qpel8_mc03_mmi;
+            c->put_h264_qpel_pixels_tab[1][13] = ff_put_h264_qpel8_mc13_mmi;
+            c->put_h264_qpel_pixels_tab[1][14] = ff_put_h264_qpel8_mc23_mmi;
+            c->put_h264_qpel_pixels_tab[1][15] = ff_put_h264_qpel8_mc33_mmi;
 
-        c->put_h264_qpel_pixels_tab[2][1] = ff_put_h264_qpel4_mc10_msa;
-        c->put_h264_qpel_pixels_tab[2][2] = ff_put_h264_qpel4_mc20_msa;
-        c->put_h264_qpel_pixels_tab[2][3] = ff_put_h264_qpel4_mc30_msa;
-        c->put_h264_qpel_pixels_tab[2][4] = ff_put_h264_qpel4_mc01_msa;
-        c->put_h264_qpel_pixels_tab[2][5] = ff_put_h264_qpel4_mc11_msa;
-        c->put_h264_qpel_pixels_tab[2][6] = ff_put_h264_qpel4_mc21_msa;
-        c->put_h264_qpel_pixels_tab[2][7] = ff_put_h264_qpel4_mc31_msa;
-        c->put_h264_qpel_pixels_tab[2][8] = ff_put_h264_qpel4_mc02_msa;
-        c->put_h264_qpel_pixels_tab[2][9] = ff_put_h264_qpel4_mc12_msa;
-        c->put_h264_qpel_pixels_tab[2][10] = ff_put_h264_qpel4_mc22_msa;
-        c->put_h264_qpel_pixels_tab[2][11] = ff_put_h264_qpel4_mc32_msa;
-        c->put_h264_qpel_pixels_tab[2][12] = ff_put_h264_qpel4_mc03_msa;
-        c->put_h264_qpel_pixels_tab[2][13] = ff_put_h264_qpel4_mc13_msa;
-        c->put_h264_qpel_pixels_tab[2][14] = ff_put_h264_qpel4_mc23_msa;
-        c->put_h264_qpel_pixels_tab[2][15] = ff_put_h264_qpel4_mc33_msa;
+            c->put_h264_qpel_pixels_tab[2][0] = ff_put_h264_qpel4_mc00_mmi;
+            c->put_h264_qpel_pixels_tab[2][1] = ff_put_h264_qpel4_mc10_mmi;
+            c->put_h264_qpel_pixels_tab[2][2] = ff_put_h264_qpel4_mc20_mmi;
+            c->put_h264_qpel_pixels_tab[2][3] = ff_put_h264_qpel4_mc30_mmi;
+            c->put_h264_qpel_pixels_tab[2][4] = ff_put_h264_qpel4_mc01_mmi;
+            c->put_h264_qpel_pixels_tab[2][5] = ff_put_h264_qpel4_mc11_mmi;
+            c->put_h264_qpel_pixels_tab[2][6] = ff_put_h264_qpel4_mc21_mmi;
+            c->put_h264_qpel_pixels_tab[2][7] = ff_put_h264_qpel4_mc31_mmi;
+            c->put_h264_qpel_pixels_tab[2][8] = ff_put_h264_qpel4_mc02_mmi;
+            c->put_h264_qpel_pixels_tab[2][9] = ff_put_h264_qpel4_mc12_mmi;
+            c->put_h264_qpel_pixels_tab[2][10] = ff_put_h264_qpel4_mc22_mmi;
+            c->put_h264_qpel_pixels_tab[2][11] = ff_put_h264_qpel4_mc32_mmi;
+            c->put_h264_qpel_pixels_tab[2][12] = ff_put_h264_qpel4_mc03_mmi;
+            c->put_h264_qpel_pixels_tab[2][13] = ff_put_h264_qpel4_mc13_mmi;
+            c->put_h264_qpel_pixels_tab[2][14] = ff_put_h264_qpel4_mc23_mmi;
+            c->put_h264_qpel_pixels_tab[2][15] = ff_put_h264_qpel4_mc33_mmi;
 
-        c->avg_h264_qpel_pixels_tab[0][0] = ff_avg_h264_qpel16_mc00_msa;
-        c->avg_h264_qpel_pixels_tab[0][1] = ff_avg_h264_qpel16_mc10_msa;
-        c->avg_h264_qpel_pixels_tab[0][2] = ff_avg_h264_qpel16_mc20_msa;
-        c->avg_h264_qpel_pixels_tab[0][3] = ff_avg_h264_qpel16_mc30_msa;
-        c->avg_h264_qpel_pixels_tab[0][4] = ff_avg_h264_qpel16_mc01_msa;
-        c->avg_h264_qpel_pixels_tab[0][5] = ff_avg_h264_qpel16_mc11_msa;
-        c->avg_h264_qpel_pixels_tab[0][6] = ff_avg_h264_qpel16_mc21_msa;
-        c->avg_h264_qpel_pixels_tab[0][7] = ff_avg_h264_qpel16_mc31_msa;
-        c->avg_h264_qpel_pixels_tab[0][8] = ff_avg_h264_qpel16_mc02_msa;
-        c->avg_h264_qpel_pixels_tab[0][9] = ff_avg_h264_qpel16_mc12_msa;
-        c->avg_h264_qpel_pixels_tab[0][10] = ff_avg_h264_qpel16_mc22_msa;
-        c->avg_h264_qpel_pixels_tab[0][11] = ff_avg_h264_qpel16_mc32_msa;
-        c->avg_h264_qpel_pixels_tab[0][12] = ff_avg_h264_qpel16_mc03_msa;
-        c->avg_h264_qpel_pixels_tab[0][13] = ff_avg_h264_qpel16_mc13_msa;
-        c->avg_h264_qpel_pixels_tab[0][14] = ff_avg_h264_qpel16_mc23_msa;
-        c->avg_h264_qpel_pixels_tab[0][15] = ff_avg_h264_qpel16_mc33_msa;
+            c->avg_h264_qpel_pixels_tab[0][0] = ff_avg_h264_qpel16_mc00_mmi;
+            c->avg_h264_qpel_pixels_tab[0][1] = ff_avg_h264_qpel16_mc10_mmi;
+            c->avg_h264_qpel_pixels_tab[0][2] = ff_avg_h264_qpel16_mc20_mmi;
+            c->avg_h264_qpel_pixels_tab[0][3] = ff_avg_h264_qpel16_mc30_mmi;
+            c->avg_h264_qpel_pixels_tab[0][4] = ff_avg_h264_qpel16_mc01_mmi;
+            c->avg_h264_qpel_pixels_tab[0][5] = ff_avg_h264_qpel16_mc11_mmi;
+            c->avg_h264_qpel_pixels_tab[0][6] = ff_avg_h264_qpel16_mc21_mmi;
+            c->avg_h264_qpel_pixels_tab[0][7] = ff_avg_h264_qpel16_mc31_mmi;
+            c->avg_h264_qpel_pixels_tab[0][8] = ff_avg_h264_qpel16_mc02_mmi;
+            c->avg_h264_qpel_pixels_tab[0][9] = ff_avg_h264_qpel16_mc12_mmi;
+            c->avg_h264_qpel_pixels_tab[0][10] = ff_avg_h264_qpel16_mc22_mmi;
+            c->avg_h264_qpel_pixels_tab[0][11] = ff_avg_h264_qpel16_mc32_mmi;
+            c->avg_h264_qpel_pixels_tab[0][12] = ff_avg_h264_qpel16_mc03_mmi;
+            c->avg_h264_qpel_pixels_tab[0][13] = ff_avg_h264_qpel16_mc13_mmi;
+            c->avg_h264_qpel_pixels_tab[0][14] = ff_avg_h264_qpel16_mc23_mmi;
+            c->avg_h264_qpel_pixels_tab[0][15] = ff_avg_h264_qpel16_mc33_mmi;
 
-        c->avg_h264_qpel_pixels_tab[1][0] = ff_avg_h264_qpel8_mc00_msa;
-        c->avg_h264_qpel_pixels_tab[1][1] = ff_avg_h264_qpel8_mc10_msa;
-        c->avg_h264_qpel_pixels_tab[1][2] = ff_avg_h264_qpel8_mc20_msa;
-        c->avg_h264_qpel_pixels_tab[1][3] = ff_avg_h264_qpel8_mc30_msa;
-        c->avg_h264_qpel_pixels_tab[1][4] = ff_avg_h264_qpel8_mc01_msa;
-        c->avg_h264_qpel_pixels_tab[1][5] = ff_avg_h264_qpel8_mc11_msa;
-        c->avg_h264_qpel_pixels_tab[1][6] = ff_avg_h264_qpel8_mc21_msa;
-        c->avg_h264_qpel_pixels_tab[1][7] = ff_avg_h264_qpel8_mc31_msa;
-        c->avg_h264_qpel_pixels_tab[1][8] = ff_avg_h264_qpel8_mc02_msa;
-        c->avg_h264_qpel_pixels_tab[1][9] = ff_avg_h264_qpel8_mc12_msa;
-        c->avg_h264_qpel_pixels_tab[1][10] = ff_avg_h264_qpel8_mc22_msa;
-        c->avg_h264_qpel_pixels_tab[1][11] = ff_avg_h264_qpel8_mc32_msa;
-        c->avg_h264_qpel_pixels_tab[1][12] = ff_avg_h264_qpel8_mc03_msa;
-        c->avg_h264_qpel_pixels_tab[1][13] = ff_avg_h264_qpel8_mc13_msa;
-        c->avg_h264_qpel_pixels_tab[1][14] = ff_avg_h264_qpel8_mc23_msa;
-        c->avg_h264_qpel_pixels_tab[1][15] = ff_avg_h264_qpel8_mc33_msa;
+            c->avg_h264_qpel_pixels_tab[1][0] = ff_avg_h264_qpel8_mc00_mmi;
+            c->avg_h264_qpel_pixels_tab[1][1] = ff_avg_h264_qpel8_mc10_mmi;
+            c->avg_h264_qpel_pixels_tab[1][2] = ff_avg_h264_qpel8_mc20_mmi;
+            c->avg_h264_qpel_pixels_tab[1][3] = ff_avg_h264_qpel8_mc30_mmi;
+            c->avg_h264_qpel_pixels_tab[1][4] = ff_avg_h264_qpel8_mc01_mmi;
+            c->avg_h264_qpel_pixels_tab[1][5] = ff_avg_h264_qpel8_mc11_mmi;
+            c->avg_h264_qpel_pixels_tab[1][6] = ff_avg_h264_qpel8_mc21_mmi;
+            c->avg_h264_qpel_pixels_tab[1][7] = ff_avg_h264_qpel8_mc31_mmi;
+            c->avg_h264_qpel_pixels_tab[1][8] = ff_avg_h264_qpel8_mc02_mmi;
+            c->avg_h264_qpel_pixels_tab[1][9] = ff_avg_h264_qpel8_mc12_mmi;
+            c->avg_h264_qpel_pixels_tab[1][10] = ff_avg_h264_qpel8_mc22_mmi;
+            c->avg_h264_qpel_pixels_tab[1][11] = ff_avg_h264_qpel8_mc32_mmi;
+            c->avg_h264_qpel_pixels_tab[1][12] = ff_avg_h264_qpel8_mc03_mmi;
+            c->avg_h264_qpel_pixels_tab[1][13] = ff_avg_h264_qpel8_mc13_mmi;
+            c->avg_h264_qpel_pixels_tab[1][14] = ff_avg_h264_qpel8_mc23_mmi;
+            c->avg_h264_qpel_pixels_tab[1][15] = ff_avg_h264_qpel8_mc33_mmi;
 
-        c->avg_h264_qpel_pixels_tab[2][0] = ff_avg_h264_qpel4_mc00_msa;
-        c->avg_h264_qpel_pixels_tab[2][1] = ff_avg_h264_qpel4_mc10_msa;
-        c->avg_h264_qpel_pixels_tab[2][2] = ff_avg_h264_qpel4_mc20_msa;
-        c->avg_h264_qpel_pixels_tab[2][3] = ff_avg_h264_qpel4_mc30_msa;
-        c->avg_h264_qpel_pixels_tab[2][4] = ff_avg_h264_qpel4_mc01_msa;
-        c->avg_h264_qpel_pixels_tab[2][5] = ff_avg_h264_qpel4_mc11_msa;
-        c->avg_h264_qpel_pixels_tab[2][6] = ff_avg_h264_qpel4_mc21_msa;
-        c->avg_h264_qpel_pixels_tab[2][7] = ff_avg_h264_qpel4_mc31_msa;
-        c->avg_h264_qpel_pixels_tab[2][8] = ff_avg_h264_qpel4_mc02_msa;
-        c->avg_h264_qpel_pixels_tab[2][9] = ff_avg_h264_qpel4_mc12_msa;
-        c->avg_h264_qpel_pixels_tab[2][10] = ff_avg_h264_qpel4_mc22_msa;
-        c->avg_h264_qpel_pixels_tab[2][11] = ff_avg_h264_qpel4_mc32_msa;
-        c->avg_h264_qpel_pixels_tab[2][12] = ff_avg_h264_qpel4_mc03_msa;
-        c->avg_h264_qpel_pixels_tab[2][13] = ff_avg_h264_qpel4_mc13_msa;
-        c->avg_h264_qpel_pixels_tab[2][14] = ff_avg_h264_qpel4_mc23_msa;
-        c->avg_h264_qpel_pixels_tab[2][15] = ff_avg_h264_qpel4_mc33_msa;
+            c->avg_h264_qpel_pixels_tab[2][0] = ff_avg_h264_qpel4_mc00_mmi;
+            c->avg_h264_qpel_pixels_tab[2][1] = ff_avg_h264_qpel4_mc10_mmi;
+            c->avg_h264_qpel_pixels_tab[2][2] = ff_avg_h264_qpel4_mc20_mmi;
+            c->avg_h264_qpel_pixels_tab[2][3] = ff_avg_h264_qpel4_mc30_mmi;
+            c->avg_h264_qpel_pixels_tab[2][4] = ff_avg_h264_qpel4_mc01_mmi;
+            c->avg_h264_qpel_pixels_tab[2][5] = ff_avg_h264_qpel4_mc11_mmi;
+            c->avg_h264_qpel_pixels_tab[2][6] = ff_avg_h264_qpel4_mc21_mmi;
+            c->avg_h264_qpel_pixels_tab[2][7] = ff_avg_h264_qpel4_mc31_mmi;
+            c->avg_h264_qpel_pixels_tab[2][8] = ff_avg_h264_qpel4_mc02_mmi;
+            c->avg_h264_qpel_pixels_tab[2][9] = ff_avg_h264_qpel4_mc12_mmi;
+            c->avg_h264_qpel_pixels_tab[2][10] = ff_avg_h264_qpel4_mc22_mmi;
+            c->avg_h264_qpel_pixels_tab[2][11] = ff_avg_h264_qpel4_mc32_mmi;
+            c->avg_h264_qpel_pixels_tab[2][12] = ff_avg_h264_qpel4_mc03_mmi;
+            c->avg_h264_qpel_pixels_tab[2][13] = ff_avg_h264_qpel4_mc13_mmi;
+            c->avg_h264_qpel_pixels_tab[2][14] = ff_avg_h264_qpel4_mc23_mmi;
+            c->avg_h264_qpel_pixels_tab[2][15] = ff_avg_h264_qpel4_mc33_mmi;
+        }
     }
-}
-#endif  // #if HAVE_MSA
 
-#if HAVE_MMI
-static av_cold void h264qpel_init_mmi(H264QpelContext *c, int bit_depth)
-{
-    if (8 == bit_depth) {
-        c->put_h264_qpel_pixels_tab[0][0] = ff_put_h264_qpel16_mc00_mmi;
-        c->put_h264_qpel_pixels_tab[0][1] = ff_put_h264_qpel16_mc10_mmi;
-        c->put_h264_qpel_pixels_tab[0][2] = ff_put_h264_qpel16_mc20_mmi;
-        c->put_h264_qpel_pixels_tab[0][3] = ff_put_h264_qpel16_mc30_mmi;
-        c->put_h264_qpel_pixels_tab[0][4] = ff_put_h264_qpel16_mc01_mmi;
-        c->put_h264_qpel_pixels_tab[0][5] = ff_put_h264_qpel16_mc11_mmi;
-        c->put_h264_qpel_pixels_tab[0][6] = ff_put_h264_qpel16_mc21_mmi;
-        c->put_h264_qpel_pixels_tab[0][7] = ff_put_h264_qpel16_mc31_mmi;
-        c->put_h264_qpel_pixels_tab[0][8] = ff_put_h264_qpel16_mc02_mmi;
-        c->put_h264_qpel_pixels_tab[0][9] = ff_put_h264_qpel16_mc12_mmi;
-        c->put_h264_qpel_pixels_tab[0][10] = ff_put_h264_qpel16_mc22_mmi;
-        c->put_h264_qpel_pixels_tab[0][11] = ff_put_h264_qpel16_mc32_mmi;
-        c->put_h264_qpel_pixels_tab[0][12] = ff_put_h264_qpel16_mc03_mmi;
-        c->put_h264_qpel_pixels_tab[0][13] = ff_put_h264_qpel16_mc13_mmi;
-        c->put_h264_qpel_pixels_tab[0][14] = ff_put_h264_qpel16_mc23_mmi;
-        c->put_h264_qpel_pixels_tab[0][15] = ff_put_h264_qpel16_mc33_mmi;
+    if (have_msa(cpu_flags)) {
+        if (bit_depth == 8) {
+            c->put_h264_qpel_pixels_tab[0][0] = ff_put_h264_qpel16_mc00_msa;
+            c->put_h264_qpel_pixels_tab[0][1] = ff_put_h264_qpel16_mc10_msa;
+            c->put_h264_qpel_pixels_tab[0][2] = ff_put_h264_qpel16_mc20_msa;
+            c->put_h264_qpel_pixels_tab[0][3] = ff_put_h264_qpel16_mc30_msa;
+            c->put_h264_qpel_pixels_tab[0][4] = ff_put_h264_qpel16_mc01_msa;
+            c->put_h264_qpel_pixels_tab[0][5] = ff_put_h264_qpel16_mc11_msa;
+            c->put_h264_qpel_pixels_tab[0][6] = ff_put_h264_qpel16_mc21_msa;
+            c->put_h264_qpel_pixels_tab[0][7] = ff_put_h264_qpel16_mc31_msa;
+            c->put_h264_qpel_pixels_tab[0][8] = ff_put_h264_qpel16_mc02_msa;
+            c->put_h264_qpel_pixels_tab[0][9] = ff_put_h264_qpel16_mc12_msa;
+            c->put_h264_qpel_pixels_tab[0][10] = ff_put_h264_qpel16_mc22_msa;
+            c->put_h264_qpel_pixels_tab[0][11] = ff_put_h264_qpel16_mc32_msa;
+            c->put_h264_qpel_pixels_tab[0][12] = ff_put_h264_qpel16_mc03_msa;
+            c->put_h264_qpel_pixels_tab[0][13] = ff_put_h264_qpel16_mc13_msa;
+            c->put_h264_qpel_pixels_tab[0][14] = ff_put_h264_qpel16_mc23_msa;
+            c->put_h264_qpel_pixels_tab[0][15] = ff_put_h264_qpel16_mc33_msa;
 
-        c->put_h264_qpel_pixels_tab[1][0] = ff_put_h264_qpel8_mc00_mmi;
-        c->put_h264_qpel_pixels_tab[1][1] = ff_put_h264_qpel8_mc10_mmi;
-        c->put_h264_qpel_pixels_tab[1][2] = ff_put_h264_qpel8_mc20_mmi;
-        c->put_h264_qpel_pixels_tab[1][3] = ff_put_h264_qpel8_mc30_mmi;
-        c->put_h264_qpel_pixels_tab[1][4] = ff_put_h264_qpel8_mc01_mmi;
-        c->put_h264_qpel_pixels_tab[1][5] = ff_put_h264_qpel8_mc11_mmi;
-        c->put_h264_qpel_pixels_tab[1][6] = ff_put_h264_qpel8_mc21_mmi;
-        c->put_h264_qpel_pixels_tab[1][7] = ff_put_h264_qpel8_mc31_mmi;
-        c->put_h264_qpel_pixels_tab[1][8] = ff_put_h264_qpel8_mc02_mmi;
-        c->put_h264_qpel_pixels_tab[1][9] = ff_put_h264_qpel8_mc12_mmi;
-        c->put_h264_qpel_pixels_tab[1][10] = ff_put_h264_qpel8_mc22_mmi;
-        c->put_h264_qpel_pixels_tab[1][11] = ff_put_h264_qpel8_mc32_mmi;
-        c->put_h264_qpel_pixels_tab[1][12] = ff_put_h264_qpel8_mc03_mmi;
-        c->put_h264_qpel_pixels_tab[1][13] = ff_put_h264_qpel8_mc13_mmi;
-        c->put_h264_qpel_pixels_tab[1][14] = ff_put_h264_qpel8_mc23_mmi;
-        c->put_h264_qpel_pixels_tab[1][15] = ff_put_h264_qpel8_mc33_mmi;
+            c->put_h264_qpel_pixels_tab[1][0] = ff_put_h264_qpel8_mc00_msa;
+            c->put_h264_qpel_pixels_tab[1][1] = ff_put_h264_qpel8_mc10_msa;
+            c->put_h264_qpel_pixels_tab[1][2] = ff_put_h264_qpel8_mc20_msa;
+            c->put_h264_qpel_pixels_tab[1][3] = ff_put_h264_qpel8_mc30_msa;
+            c->put_h264_qpel_pixels_tab[1][4] = ff_put_h264_qpel8_mc01_msa;
+            c->put_h264_qpel_pixels_tab[1][5] = ff_put_h264_qpel8_mc11_msa;
+            c->put_h264_qpel_pixels_tab[1][6] = ff_put_h264_qpel8_mc21_msa;
+            c->put_h264_qpel_pixels_tab[1][7] = ff_put_h264_qpel8_mc31_msa;
+            c->put_h264_qpel_pixels_tab[1][8] = ff_put_h264_qpel8_mc02_msa;
+            c->put_h264_qpel_pixels_tab[1][9] = ff_put_h264_qpel8_mc12_msa;
+            c->put_h264_qpel_pixels_tab[1][10] = ff_put_h264_qpel8_mc22_msa;
+            c->put_h264_qpel_pixels_tab[1][11] = ff_put_h264_qpel8_mc32_msa;
+            c->put_h264_qpel_pixels_tab[1][12] = ff_put_h264_qpel8_mc03_msa;
+            c->put_h264_qpel_pixels_tab[1][13] = ff_put_h264_qpel8_mc13_msa;
+            c->put_h264_qpel_pixels_tab[1][14] = ff_put_h264_qpel8_mc23_msa;
+            c->put_h264_qpel_pixels_tab[1][15] = ff_put_h264_qpel8_mc33_msa;
 
-        c->put_h264_qpel_pixels_tab[2][0] = ff_put_h264_qpel4_mc00_mmi;
-        c->put_h264_qpel_pixels_tab[2][1] = ff_put_h264_qpel4_mc10_mmi;
-        c->put_h264_qpel_pixels_tab[2][2] = ff_put_h264_qpel4_mc20_mmi;
-        c->put_h264_qpel_pixels_tab[2][3] = ff_put_h264_qpel4_mc30_mmi;
-        c->put_h264_qpel_pixels_tab[2][4] = ff_put_h264_qpel4_mc01_mmi;
-        c->put_h264_qpel_pixels_tab[2][5] = ff_put_h264_qpel4_mc11_mmi;
-        c->put_h264_qpel_pixels_tab[2][6] = ff_put_h264_qpel4_mc21_mmi;
-        c->put_h264_qpel_pixels_tab[2][7] = ff_put_h264_qpel4_mc31_mmi;
-        c->put_h264_qpel_pixels_tab[2][8] = ff_put_h264_qpel4_mc02_mmi;
-        c->put_h264_qpel_pixels_tab[2][9] = ff_put_h264_qpel4_mc12_mmi;
-        c->put_h264_qpel_pixels_tab[2][10] = ff_put_h264_qpel4_mc22_mmi;
-        c->put_h264_qpel_pixels_tab[2][11] = ff_put_h264_qpel4_mc32_mmi;
-        c->put_h264_qpel_pixels_tab[2][12] = ff_put_h264_qpel4_mc03_mmi;
-        c->put_h264_qpel_pixels_tab[2][13] = ff_put_h264_qpel4_mc13_mmi;
-        c->put_h264_qpel_pixels_tab[2][14] = ff_put_h264_qpel4_mc23_mmi;
-        c->put_h264_qpel_pixels_tab[2][15] = ff_put_h264_qpel4_mc33_mmi;
+            c->put_h264_qpel_pixels_tab[2][1] = ff_put_h264_qpel4_mc10_msa;
+            c->put_h264_qpel_pixels_tab[2][2] = ff_put_h264_qpel4_mc20_msa;
+            c->put_h264_qpel_pixels_tab[2][3] = ff_put_h264_qpel4_mc30_msa;
+            c->put_h264_qpel_pixels_tab[2][4] = ff_put_h264_qpel4_mc01_msa;
+            c->put_h264_qpel_pixels_tab[2][5] = ff_put_h264_qpel4_mc11_msa;
+            c->put_h264_qpel_pixels_tab[2][6] = ff_put_h264_qpel4_mc21_msa;
+            c->put_h264_qpel_pixels_tab[2][7] = ff_put_h264_qpel4_mc31_msa;
+            c->put_h264_qpel_pixels_tab[2][8] = ff_put_h264_qpel4_mc02_msa;
+            c->put_h264_qpel_pixels_tab[2][9] = ff_put_h264_qpel4_mc12_msa;
+            c->put_h264_qpel_pixels_tab[2][10] = ff_put_h264_qpel4_mc22_msa;
+            c->put_h264_qpel_pixels_tab[2][11] = ff_put_h264_qpel4_mc32_msa;
+            c->put_h264_qpel_pixels_tab[2][12] = ff_put_h264_qpel4_mc03_msa;
+            c->put_h264_qpel_pixels_tab[2][13] = ff_put_h264_qpel4_mc13_msa;
+            c->put_h264_qpel_pixels_tab[2][14] = ff_put_h264_qpel4_mc23_msa;
+            c->put_h264_qpel_pixels_tab[2][15] = ff_put_h264_qpel4_mc33_msa;
 
-        c->avg_h264_qpel_pixels_tab[0][0] = ff_avg_h264_qpel16_mc00_mmi;
-        c->avg_h264_qpel_pixels_tab[0][1] = ff_avg_h264_qpel16_mc10_mmi;
-        c->avg_h264_qpel_pixels_tab[0][2] = ff_avg_h264_qpel16_mc20_mmi;
-        c->avg_h264_qpel_pixels_tab[0][3] = ff_avg_h264_qpel16_mc30_mmi;
-        c->avg_h264_qpel_pixels_tab[0][4] = ff_avg_h264_qpel16_mc01_mmi;
-        c->avg_h264_qpel_pixels_tab[0][5] = ff_avg_h264_qpel16_mc11_mmi;
-        c->avg_h264_qpel_pixels_tab[0][6] = ff_avg_h264_qpel16_mc21_mmi;
-        c->avg_h264_qpel_pixels_tab[0][7] = ff_avg_h264_qpel16_mc31_mmi;
-        c->avg_h264_qpel_pixels_tab[0][8] = ff_avg_h264_qpel16_mc02_mmi;
-        c->avg_h264_qpel_pixels_tab[0][9] = ff_avg_h264_qpel16_mc12_mmi;
-        c->avg_h264_qpel_pixels_tab[0][10] = ff_avg_h264_qpel16_mc22_mmi;
-        c->avg_h264_qpel_pixels_tab[0][11] = ff_avg_h264_qpel16_mc32_mmi;
-        c->avg_h264_qpel_pixels_tab[0][12] = ff_avg_h264_qpel16_mc03_mmi;
-        c->avg_h264_qpel_pixels_tab[0][13] = ff_avg_h264_qpel16_mc13_mmi;
-        c->avg_h264_qpel_pixels_tab[0][14] = ff_avg_h264_qpel16_mc23_mmi;
-        c->avg_h264_qpel_pixels_tab[0][15] = ff_avg_h264_qpel16_mc33_mmi;
+            c->avg_h264_qpel_pixels_tab[0][0] = ff_avg_h264_qpel16_mc00_msa;
+            c->avg_h264_qpel_pixels_tab[0][1] = ff_avg_h264_qpel16_mc10_msa;
+            c->avg_h264_qpel_pixels_tab[0][2] = ff_avg_h264_qpel16_mc20_msa;
+            c->avg_h264_qpel_pixels_tab[0][3] = ff_avg_h264_qpel16_mc30_msa;
+            c->avg_h264_qpel_pixels_tab[0][4] = ff_avg_h264_qpel16_mc01_msa;
+            c->avg_h264_qpel_pixels_tab[0][5] = ff_avg_h264_qpel16_mc11_msa;
+            c->avg_h264_qpel_pixels_tab[0][6] = ff_avg_h264_qpel16_mc21_msa;
+            c->avg_h264_qpel_pixels_tab[0][7] = ff_avg_h264_qpel16_mc31_msa;
+            c->avg_h264_qpel_pixels_tab[0][8] = ff_avg_h264_qpel16_mc02_msa;
+            c->avg_h264_qpel_pixels_tab[0][9] = ff_avg_h264_qpel16_mc12_msa;
+            c->avg_h264_qpel_pixels_tab[0][10] = ff_avg_h264_qpel16_mc22_msa;
+            c->avg_h264_qpel_pixels_tab[0][11] = ff_avg_h264_qpel16_mc32_msa;
+            c->avg_h264_qpel_pixels_tab[0][12] = ff_avg_h264_qpel16_mc03_msa;
+            c->avg_h264_qpel_pixels_tab[0][13] = ff_avg_h264_qpel16_mc13_msa;
+            c->avg_h264_qpel_pixels_tab[0][14] = ff_avg_h264_qpel16_mc23_msa;
+            c->avg_h264_qpel_pixels_tab[0][15] = ff_avg_h264_qpel16_mc33_msa;
 
-        c->avg_h264_qpel_pixels_tab[1][0] = ff_avg_h264_qpel8_mc00_mmi;
-        c->avg_h264_qpel_pixels_tab[1][1] = ff_avg_h264_qpel8_mc10_mmi;
-        c->avg_h264_qpel_pixels_tab[1][2] = ff_avg_h264_qpel8_mc20_mmi;
-        c->avg_h264_qpel_pixels_tab[1][3] = ff_avg_h264_qpel8_mc30_mmi;
-        c->avg_h264_qpel_pixels_tab[1][4] = ff_avg_h264_qpel8_mc01_mmi;
-        c->avg_h264_qpel_pixels_tab[1][5] = ff_avg_h264_qpel8_mc11_mmi;
-        c->avg_h264_qpel_pixels_tab[1][6] = ff_avg_h264_qpel8_mc21_mmi;
-        c->avg_h264_qpel_pixels_tab[1][7] = ff_avg_h264_qpel8_mc31_mmi;
-        c->avg_h264_qpel_pixels_tab[1][8] = ff_avg_h264_qpel8_mc02_mmi;
-        c->avg_h264_qpel_pixels_tab[1][9] = ff_avg_h264_qpel8_mc12_mmi;
-        c->avg_h264_qpel_pixels_tab[1][10] = ff_avg_h264_qpel8_mc22_mmi;
-        c->avg_h264_qpel_pixels_tab[1][11] = ff_avg_h264_qpel8_mc32_mmi;
-        c->avg_h264_qpel_pixels_tab[1][12] = ff_avg_h264_qpel8_mc03_mmi;
-        c->avg_h264_qpel_pixels_tab[1][13] = ff_avg_h264_qpel8_mc13_mmi;
-        c->avg_h264_qpel_pixels_tab[1][14] = ff_avg_h264_qpel8_mc23_mmi;
-        c->avg_h264_qpel_pixels_tab[1][15] = ff_avg_h264_qpel8_mc33_mmi;
+            c->avg_h264_qpel_pixels_tab[1][0] = ff_avg_h264_qpel8_mc00_msa;
+            c->avg_h264_qpel_pixels_tab[1][1] = ff_avg_h264_qpel8_mc10_msa;
+            c->avg_h264_qpel_pixels_tab[1][2] = ff_avg_h264_qpel8_mc20_msa;
+            c->avg_h264_qpel_pixels_tab[1][3] = ff_avg_h264_qpel8_mc30_msa;
+            c->avg_h264_qpel_pixels_tab[1][4] = ff_avg_h264_qpel8_mc01_msa;
+            c->avg_h264_qpel_pixels_tab[1][5] = ff_avg_h264_qpel8_mc11_msa;
+            c->avg_h264_qpel_pixels_tab[1][6] = ff_avg_h264_qpel8_mc21_msa;
+            c->avg_h264_qpel_pixels_tab[1][7] = ff_avg_h264_qpel8_mc31_msa;
+            c->avg_h264_qpel_pixels_tab[1][8] = ff_avg_h264_qpel8_mc02_msa;
+            c->avg_h264_qpel_pixels_tab[1][9] = ff_avg_h264_qpel8_mc12_msa;
+            c->avg_h264_qpel_pixels_tab[1][10] = ff_avg_h264_qpel8_mc22_msa;
+            c->avg_h264_qpel_pixels_tab[1][11] = ff_avg_h264_qpel8_mc32_msa;
+            c->avg_h264_qpel_pixels_tab[1][12] = ff_avg_h264_qpel8_mc03_msa;
+            c->avg_h264_qpel_pixels_tab[1][13] = ff_avg_h264_qpel8_mc13_msa;
+            c->avg_h264_qpel_pixels_tab[1][14] = ff_avg_h264_qpel8_mc23_msa;
+            c->avg_h264_qpel_pixels_tab[1][15] = ff_avg_h264_qpel8_mc33_msa;
 
-        c->avg_h264_qpel_pixels_tab[2][0] = ff_avg_h264_qpel4_mc00_mmi;
-        c->avg_h264_qpel_pixels_tab[2][1] = ff_avg_h264_qpel4_mc10_mmi;
-        c->avg_h264_qpel_pixels_tab[2][2] = ff_avg_h264_qpel4_mc20_mmi;
-        c->avg_h264_qpel_pixels_tab[2][3] = ff_avg_h264_qpel4_mc30_mmi;
-        c->avg_h264_qpel_pixels_tab[2][4] = ff_avg_h264_qpel4_mc01_mmi;
-        c->avg_h264_qpel_pixels_tab[2][5] = ff_avg_h264_qpel4_mc11_mmi;
-        c->avg_h264_qpel_pixels_tab[2][6] = ff_avg_h264_qpel4_mc21_mmi;
-        c->avg_h264_qpel_pixels_tab[2][7] = ff_avg_h264_qpel4_mc31_mmi;
-        c->avg_h264_qpel_pixels_tab[2][8] = ff_avg_h264_qpel4_mc02_mmi;
-        c->avg_h264_qpel_pixels_tab[2][9] = ff_avg_h264_qpel4_mc12_mmi;
-        c->avg_h264_qpel_pixels_tab[2][10] = ff_avg_h264_qpel4_mc22_mmi;
-        c->avg_h264_qpel_pixels_tab[2][11] = ff_avg_h264_qpel4_mc32_mmi;
-        c->avg_h264_qpel_pixels_tab[2][12] = ff_avg_h264_qpel4_mc03_mmi;
-        c->avg_h264_qpel_pixels_tab[2][13] = ff_avg_h264_qpel4_mc13_mmi;
-        c->avg_h264_qpel_pixels_tab[2][14] = ff_avg_h264_qpel4_mc23_mmi;
-        c->avg_h264_qpel_pixels_tab[2][15] = ff_avg_h264_qpel4_mc33_mmi;
+            c->avg_h264_qpel_pixels_tab[2][0] = ff_avg_h264_qpel4_mc00_msa;
+            c->avg_h264_qpel_pixels_tab[2][1] = ff_avg_h264_qpel4_mc10_msa;
+            c->avg_h264_qpel_pixels_tab[2][2] = ff_avg_h264_qpel4_mc20_msa;
+            c->avg_h264_qpel_pixels_tab[2][3] = ff_avg_h264_qpel4_mc30_msa;
+            c->avg_h264_qpel_pixels_tab[2][4] = ff_avg_h264_qpel4_mc01_msa;
+            c->avg_h264_qpel_pixels_tab[2][5] = ff_avg_h264_qpel4_mc11_msa;
+            c->avg_h264_qpel_pixels_tab[2][6] = ff_avg_h264_qpel4_mc21_msa;
+            c->avg_h264_qpel_pixels_tab[2][7] = ff_avg_h264_qpel4_mc31_msa;
+            c->avg_h264_qpel_pixels_tab[2][8] = ff_avg_h264_qpel4_mc02_msa;
+            c->avg_h264_qpel_pixels_tab[2][9] = ff_avg_h264_qpel4_mc12_msa;
+            c->avg_h264_qpel_pixels_tab[2][10] = ff_avg_h264_qpel4_mc22_msa;
+            c->avg_h264_qpel_pixels_tab[2][11] = ff_avg_h264_qpel4_mc32_msa;
+            c->avg_h264_qpel_pixels_tab[2][12] = ff_avg_h264_qpel4_mc03_msa;
+            c->avg_h264_qpel_pixels_tab[2][13] = ff_avg_h264_qpel4_mc13_msa;
+            c->avg_h264_qpel_pixels_tab[2][14] = ff_avg_h264_qpel4_mc23_msa;
+            c->avg_h264_qpel_pixels_tab[2][15] = ff_avg_h264_qpel4_mc33_msa;
+        } 
     }
 }
-#endif /* HAVE_MMI */
-
-av_cold void ff_h264qpel_init_mips(H264QpelContext *c, int bit_depth)
-{
-#if HAVE_MMI
-    h264qpel_init_mmi(c, bit_depth);
-#endif /* HAVE_MMI */
-#if HAVE_MSA
-    h264qpel_init_msa(c, bit_depth);
-#endif  // #if HAVE_MSA
-}
diff --git a/libavcodec/mips/hevcdsp_init_mips.c b/libavcodec/mips/hevcdsp_init_mips.c
index 88337f462e..eb261e5adf 100644
--- a/libavcodec/mips/hevcdsp_init_mips.c
+++ b/libavcodec/mips/hevcdsp_init_mips.c
@@ -18,512 +18,500 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/mips/cpu.h"
 #include "libavcodec/mips/hevcdsp_mips.h"
 
-#if HAVE_MMI
-static av_cold void hevc_dsp_init_mmi(HEVCDSPContext *c,
-                                      const int bit_depth)
+void ff_hevc_dsp_init_mips(HEVCDSPContext *c, const int bit_depth)
 {
-    if (8 == bit_depth) {
-        c->put_hevc_qpel[1][0][1] = ff_hevc_put_hevc_qpel_h4_8_mmi;
-        c->put_hevc_qpel[3][0][1] = ff_hevc_put_hevc_qpel_h8_8_mmi;
-        c->put_hevc_qpel[4][0][1] = ff_hevc_put_hevc_qpel_h12_8_mmi;
-        c->put_hevc_qpel[5][0][1] = ff_hevc_put_hevc_qpel_h16_8_mmi;
-        c->put_hevc_qpel[6][0][1] = ff_hevc_put_hevc_qpel_h24_8_mmi;
-        c->put_hevc_qpel[7][0][1] = ff_hevc_put_hevc_qpel_h32_8_mmi;
-        c->put_hevc_qpel[8][0][1] = ff_hevc_put_hevc_qpel_h48_8_mmi;
-        c->put_hevc_qpel[9][0][1] = ff_hevc_put_hevc_qpel_h64_8_mmi;
-
-        c->put_hevc_qpel[1][1][1] = ff_hevc_put_hevc_qpel_hv4_8_mmi;
-        c->put_hevc_qpel[3][1][1] = ff_hevc_put_hevc_qpel_hv8_8_mmi;
-        c->put_hevc_qpel[4][1][1] = ff_hevc_put_hevc_qpel_hv12_8_mmi;
-        c->put_hevc_qpel[5][1][1] = ff_hevc_put_hevc_qpel_hv16_8_mmi;
-        c->put_hevc_qpel[6][1][1] = ff_hevc_put_hevc_qpel_hv24_8_mmi;
-        c->put_hevc_qpel[7][1][1] = ff_hevc_put_hevc_qpel_hv32_8_mmi;
-        c->put_hevc_qpel[8][1][1] = ff_hevc_put_hevc_qpel_hv48_8_mmi;
-        c->put_hevc_qpel[9][1][1] = ff_hevc_put_hevc_qpel_hv64_8_mmi;
-
-        c->put_hevc_qpel_bi[1][0][1] = ff_hevc_put_hevc_qpel_bi_h4_8_mmi;
-        c->put_hevc_qpel_bi[3][0][1] = ff_hevc_put_hevc_qpel_bi_h8_8_mmi;
-        c->put_hevc_qpel_bi[4][0][1] = ff_hevc_put_hevc_qpel_bi_h12_8_mmi;
-        c->put_hevc_qpel_bi[5][0][1] = ff_hevc_put_hevc_qpel_bi_h16_8_mmi;
-        c->put_hevc_qpel_bi[6][0][1] = ff_hevc_put_hevc_qpel_bi_h24_8_mmi;
-        c->put_hevc_qpel_bi[7][0][1] = ff_hevc_put_hevc_qpel_bi_h32_8_mmi;
-        c->put_hevc_qpel_bi[8][0][1] = ff_hevc_put_hevc_qpel_bi_h48_8_mmi;
-        c->put_hevc_qpel_bi[9][0][1] = ff_hevc_put_hevc_qpel_bi_h64_8_mmi;
-
-        c->put_hevc_qpel_bi[1][1][1] = ff_hevc_put_hevc_qpel_bi_hv4_8_mmi;
-        c->put_hevc_qpel_bi[3][1][1] = ff_hevc_put_hevc_qpel_bi_hv8_8_mmi;
-        c->put_hevc_qpel_bi[4][1][1] = ff_hevc_put_hevc_qpel_bi_hv12_8_mmi;
-        c->put_hevc_qpel_bi[5][1][1] = ff_hevc_put_hevc_qpel_bi_hv16_8_mmi;
-        c->put_hevc_qpel_bi[6][1][1] = ff_hevc_put_hevc_qpel_bi_hv24_8_mmi;
-        c->put_hevc_qpel_bi[7][1][1] = ff_hevc_put_hevc_qpel_bi_hv32_8_mmi;
-        c->put_hevc_qpel_bi[8][1][1] = ff_hevc_put_hevc_qpel_bi_hv48_8_mmi;
-        c->put_hevc_qpel_bi[9][1][1] = ff_hevc_put_hevc_qpel_bi_hv64_8_mmi;
-
-        c->put_hevc_qpel_bi[3][0][0] = ff_hevc_put_hevc_pel_bi_pixels8_8_mmi;
-        c->put_hevc_qpel_bi[5][0][0] = ff_hevc_put_hevc_pel_bi_pixels16_8_mmi;
-        c->put_hevc_qpel_bi[6][0][0] = ff_hevc_put_hevc_pel_bi_pixels24_8_mmi;
-        c->put_hevc_qpel_bi[7][0][0] = ff_hevc_put_hevc_pel_bi_pixels32_8_mmi;
-        c->put_hevc_qpel_bi[8][0][0] = ff_hevc_put_hevc_pel_bi_pixels48_8_mmi;
-        c->put_hevc_qpel_bi[9][0][0] = ff_hevc_put_hevc_pel_bi_pixels64_8_mmi;
-
-        c->put_hevc_epel_bi[3][0][0] = ff_hevc_put_hevc_pel_bi_pixels8_8_mmi;
-        c->put_hevc_epel_bi[5][0][0] = ff_hevc_put_hevc_pel_bi_pixels16_8_mmi;
-        c->put_hevc_epel_bi[6][0][0] = ff_hevc_put_hevc_pel_bi_pixels24_8_mmi;
-        c->put_hevc_epel_bi[7][0][0] = ff_hevc_put_hevc_pel_bi_pixels32_8_mmi;
-
-        c->put_hevc_epel_bi[1][1][1] = ff_hevc_put_hevc_epel_bi_hv4_8_mmi;
-        c->put_hevc_epel_bi[3][1][1] = ff_hevc_put_hevc_epel_bi_hv8_8_mmi;
-        c->put_hevc_epel_bi[4][1][1] = ff_hevc_put_hevc_epel_bi_hv12_8_mmi;
-        c->put_hevc_epel_bi[5][1][1] = ff_hevc_put_hevc_epel_bi_hv16_8_mmi;
-        c->put_hevc_epel_bi[6][1][1] = ff_hevc_put_hevc_epel_bi_hv24_8_mmi;
-        c->put_hevc_epel_bi[7][1][1] = ff_hevc_put_hevc_epel_bi_hv32_8_mmi;
-
-        c->put_hevc_qpel_uni[1][1][1] = ff_hevc_put_hevc_qpel_uni_hv4_8_mmi;
-        c->put_hevc_qpel_uni[3][1][1] = ff_hevc_put_hevc_qpel_uni_hv8_8_mmi;
-        c->put_hevc_qpel_uni[4][1][1] = ff_hevc_put_hevc_qpel_uni_hv12_8_mmi;
-        c->put_hevc_qpel_uni[5][1][1] = ff_hevc_put_hevc_qpel_uni_hv16_8_mmi;
-        c->put_hevc_qpel_uni[6][1][1] = ff_hevc_put_hevc_qpel_uni_hv24_8_mmi;
-        c->put_hevc_qpel_uni[7][1][1] = ff_hevc_put_hevc_qpel_uni_hv32_8_mmi;
-        c->put_hevc_qpel_uni[8][1][1] = ff_hevc_put_hevc_qpel_uni_hv48_8_mmi;
-        c->put_hevc_qpel_uni[9][1][1] = ff_hevc_put_hevc_qpel_uni_hv64_8_mmi;
+    int cpu_flags = av_get_cpu_flags();
+
+    if (have_mmi(cpu_flags)) {
+        if (bit_depth == 8) {
+            c->put_hevc_qpel[1][0][1] = ff_hevc_put_hevc_qpel_h4_8_mmi;
+            c->put_hevc_qpel[3][0][1] = ff_hevc_put_hevc_qpel_h8_8_mmi;
+            c->put_hevc_qpel[4][0][1] = ff_hevc_put_hevc_qpel_h12_8_mmi;
+            c->put_hevc_qpel[5][0][1] = ff_hevc_put_hevc_qpel_h16_8_mmi;
+            c->put_hevc_qpel[6][0][1] = ff_hevc_put_hevc_qpel_h24_8_mmi;
+            c->put_hevc_qpel[7][0][1] = ff_hevc_put_hevc_qpel_h32_8_mmi;
+            c->put_hevc_qpel[8][0][1] = ff_hevc_put_hevc_qpel_h48_8_mmi;
+            c->put_hevc_qpel[9][0][1] = ff_hevc_put_hevc_qpel_h64_8_mmi;
+
+            c->put_hevc_qpel[1][1][1] = ff_hevc_put_hevc_qpel_hv4_8_mmi;
+            c->put_hevc_qpel[3][1][1] = ff_hevc_put_hevc_qpel_hv8_8_mmi;
+            c->put_hevc_qpel[4][1][1] = ff_hevc_put_hevc_qpel_hv12_8_mmi;
+            c->put_hevc_qpel[5][1][1] = ff_hevc_put_hevc_qpel_hv16_8_mmi;
+            c->put_hevc_qpel[6][1][1] = ff_hevc_put_hevc_qpel_hv24_8_mmi;
+            c->put_hevc_qpel[7][1][1] = ff_hevc_put_hevc_qpel_hv32_8_mmi;
+            c->put_hevc_qpel[8][1][1] = ff_hevc_put_hevc_qpel_hv48_8_mmi;
+            c->put_hevc_qpel[9][1][1] = ff_hevc_put_hevc_qpel_hv64_8_mmi;
+
+            c->put_hevc_qpel_bi[1][0][1] = ff_hevc_put_hevc_qpel_bi_h4_8_mmi;
+            c->put_hevc_qpel_bi[3][0][1] = ff_hevc_put_hevc_qpel_bi_h8_8_mmi;
+            c->put_hevc_qpel_bi[4][0][1] = ff_hevc_put_hevc_qpel_bi_h12_8_mmi;
+            c->put_hevc_qpel_bi[5][0][1] = ff_hevc_put_hevc_qpel_bi_h16_8_mmi;
+            c->put_hevc_qpel_bi[6][0][1] = ff_hevc_put_hevc_qpel_bi_h24_8_mmi;
+            c->put_hevc_qpel_bi[7][0][1] = ff_hevc_put_hevc_qpel_bi_h32_8_mmi;
+            c->put_hevc_qpel_bi[8][0][1] = ff_hevc_put_hevc_qpel_bi_h48_8_mmi;
+            c->put_hevc_qpel_bi[9][0][1] = ff_hevc_put_hevc_qpel_bi_h64_8_mmi;
+
+            c->put_hevc_qpel_bi[1][1][1] = ff_hevc_put_hevc_qpel_bi_hv4_8_mmi;
+            c->put_hevc_qpel_bi[3][1][1] = ff_hevc_put_hevc_qpel_bi_hv8_8_mmi;
+            c->put_hevc_qpel_bi[4][1][1] = ff_hevc_put_hevc_qpel_bi_hv12_8_mmi;
+            c->put_hevc_qpel_bi[5][1][1] = ff_hevc_put_hevc_qpel_bi_hv16_8_mmi;
+            c->put_hevc_qpel_bi[6][1][1] = ff_hevc_put_hevc_qpel_bi_hv24_8_mmi;
+            c->put_hevc_qpel_bi[7][1][1] = ff_hevc_put_hevc_qpel_bi_hv32_8_mmi;
+            c->put_hevc_qpel_bi[8][1][1] = ff_hevc_put_hevc_qpel_bi_hv48_8_mmi;
+            c->put_hevc_qpel_bi[9][1][1] = ff_hevc_put_hevc_qpel_bi_hv64_8_mmi;
+
+            c->put_hevc_qpel_bi[3][0][0] = ff_hevc_put_hevc_pel_bi_pixels8_8_mmi;
+            c->put_hevc_qpel_bi[5][0][0] = ff_hevc_put_hevc_pel_bi_pixels16_8_mmi;
+            c->put_hevc_qpel_bi[6][0][0] = ff_hevc_put_hevc_pel_bi_pixels24_8_mmi;
+            c->put_hevc_qpel_bi[7][0][0] = ff_hevc_put_hevc_pel_bi_pixels32_8_mmi;
+            c->put_hevc_qpel_bi[8][0][0] = ff_hevc_put_hevc_pel_bi_pixels48_8_mmi;
+            c->put_hevc_qpel_bi[9][0][0] = ff_hevc_put_hevc_pel_bi_pixels64_8_mmi;
+
+            c->put_hevc_epel_bi[3][0][0] = ff_hevc_put_hevc_pel_bi_pixels8_8_mmi;
+            c->put_hevc_epel_bi[5][0][0] = ff_hevc_put_hevc_pel_bi_pixels16_8_mmi;
+            c->put_hevc_epel_bi[6][0][0] = ff_hevc_put_hevc_pel_bi_pixels24_8_mmi;
+            c->put_hevc_epel_bi[7][0][0] = ff_hevc_put_hevc_pel_bi_pixels32_8_mmi;
+
+            c->put_hevc_epel_bi[1][1][1] = ff_hevc_put_hevc_epel_bi_hv4_8_mmi;
+            c->put_hevc_epel_bi[3][1][1] = ff_hevc_put_hevc_epel_bi_hv8_8_mmi;
+            c->put_hevc_epel_bi[4][1][1] = ff_hevc_put_hevc_epel_bi_hv12_8_mmi;
+            c->put_hevc_epel_bi[5][1][1] = ff_hevc_put_hevc_epel_bi_hv16_8_mmi;
+            c->put_hevc_epel_bi[6][1][1] = ff_hevc_put_hevc_epel_bi_hv24_8_mmi;
+            c->put_hevc_epel_bi[7][1][1] = ff_hevc_put_hevc_epel_bi_hv32_8_mmi;
+
+            c->put_hevc_qpel_uni[1][1][1] = ff_hevc_put_hevc_qpel_uni_hv4_8_mmi;
+            c->put_hevc_qpel_uni[3][1][1] = ff_hevc_put_hevc_qpel_uni_hv8_8_mmi;
+            c->put_hevc_qpel_uni[4][1][1] = ff_hevc_put_hevc_qpel_uni_hv12_8_mmi;
+            c->put_hevc_qpel_uni[5][1][1] = ff_hevc_put_hevc_qpel_uni_hv16_8_mmi;
+            c->put_hevc_qpel_uni[6][1][1] = ff_hevc_put_hevc_qpel_uni_hv24_8_mmi;
+            c->put_hevc_qpel_uni[7][1][1] = ff_hevc_put_hevc_qpel_uni_hv32_8_mmi;
+            c->put_hevc_qpel_uni[8][1][1] = ff_hevc_put_hevc_qpel_uni_hv48_8_mmi;
+            c->put_hevc_qpel_uni[9][1][1] = ff_hevc_put_hevc_qpel_uni_hv64_8_mmi;
+        }
     }
-}
-#endif // #if HAVE_MMI
 
-#if HAVE_MSA
-static av_cold void hevc_dsp_init_msa(HEVCDSPContext *c,
-                                      const int bit_depth)
-{
-    if (8 == bit_depth) {
-        c->put_hevc_qpel[1][0][0] = ff_hevc_put_hevc_pel_pixels4_8_msa;
-        c->put_hevc_qpel[2][0][0] = ff_hevc_put_hevc_pel_pixels6_8_msa;
-        c->put_hevc_qpel[3][0][0] = ff_hevc_put_hevc_pel_pixels8_8_msa;
-        c->put_hevc_qpel[4][0][0] = ff_hevc_put_hevc_pel_pixels12_8_msa;
-        c->put_hevc_qpel[5][0][0] = ff_hevc_put_hevc_pel_pixels16_8_msa;
-        c->put_hevc_qpel[6][0][0] = ff_hevc_put_hevc_pel_pixels24_8_msa;
-        c->put_hevc_qpel[7][0][0] = ff_hevc_put_hevc_pel_pixels32_8_msa;
-        c->put_hevc_qpel[8][0][0] = ff_hevc_put_hevc_pel_pixels48_8_msa;
-        c->put_hevc_qpel[9][0][0] = ff_hevc_put_hevc_pel_pixels64_8_msa;
-
-        c->put_hevc_qpel[1][0][1] = ff_hevc_put_hevc_qpel_h4_8_msa;
-        c->put_hevc_qpel[3][0][1] = ff_hevc_put_hevc_qpel_h8_8_msa;
-        c->put_hevc_qpel[4][0][1] = ff_hevc_put_hevc_qpel_h12_8_msa;
-        c->put_hevc_qpel[5][0][1] = ff_hevc_put_hevc_qpel_h16_8_msa;
-        c->put_hevc_qpel[6][0][1] = ff_hevc_put_hevc_qpel_h24_8_msa;
-        c->put_hevc_qpel[7][0][1] = ff_hevc_put_hevc_qpel_h32_8_msa;
-        c->put_hevc_qpel[8][0][1] = ff_hevc_put_hevc_qpel_h48_8_msa;
-        c->put_hevc_qpel[9][0][1] = ff_hevc_put_hevc_qpel_h64_8_msa;
-
-        c->put_hevc_qpel[1][1][0] = ff_hevc_put_hevc_qpel_v4_8_msa;
-        c->put_hevc_qpel[3][1][0] = ff_hevc_put_hevc_qpel_v8_8_msa;
-        c->put_hevc_qpel[4][1][0] = ff_hevc_put_hevc_qpel_v12_8_msa;
-        c->put_hevc_qpel[5][1][0] = ff_hevc_put_hevc_qpel_v16_8_msa;
-        c->put_hevc_qpel[6][1][0] = ff_hevc_put_hevc_qpel_v24_8_msa;
-        c->put_hevc_qpel[7][1][0] = ff_hevc_put_hevc_qpel_v32_8_msa;
-        c->put_hevc_qpel[8][1][0] = ff_hevc_put_hevc_qpel_v48_8_msa;
-        c->put_hevc_qpel[9][1][0] = ff_hevc_put_hevc_qpel_v64_8_msa;
-
-        c->put_hevc_qpel[1][1][1] = ff_hevc_put_hevc_qpel_hv4_8_msa;
-        c->put_hevc_qpel[3][1][1] = ff_hevc_put_hevc_qpel_hv8_8_msa;
-        c->put_hevc_qpel[4][1][1] = ff_hevc_put_hevc_qpel_hv12_8_msa;
-        c->put_hevc_qpel[5][1][1] = ff_hevc_put_hevc_qpel_hv16_8_msa;
-        c->put_hevc_qpel[6][1][1] = ff_hevc_put_hevc_qpel_hv24_8_msa;
-        c->put_hevc_qpel[7][1][1] = ff_hevc_put_hevc_qpel_hv32_8_msa;
-        c->put_hevc_qpel[8][1][1] = ff_hevc_put_hevc_qpel_hv48_8_msa;
-        c->put_hevc_qpel[9][1][1] = ff_hevc_put_hevc_qpel_hv64_8_msa;
-
-        c->put_hevc_epel[1][0][0] = ff_hevc_put_hevc_pel_pixels4_8_msa;
-        c->put_hevc_epel[2][0][0] = ff_hevc_put_hevc_pel_pixels6_8_msa;
-        c->put_hevc_epel[3][0][0] = ff_hevc_put_hevc_pel_pixels8_8_msa;
-        c->put_hevc_epel[4][0][0] = ff_hevc_put_hevc_pel_pixels12_8_msa;
-        c->put_hevc_epel[5][0][0] = ff_hevc_put_hevc_pel_pixels16_8_msa;
-        c->put_hevc_epel[6][0][0] = ff_hevc_put_hevc_pel_pixels24_8_msa;
-        c->put_hevc_epel[7][0][0] = ff_hevc_put_hevc_pel_pixels32_8_msa;
-
-        c->put_hevc_epel[1][0][1] = ff_hevc_put_hevc_epel_h4_8_msa;
-        c->put_hevc_epel[2][0][1] = ff_hevc_put_hevc_epel_h6_8_msa;
-        c->put_hevc_epel[3][0][1] = ff_hevc_put_hevc_epel_h8_8_msa;
-        c->put_hevc_epel[4][0][1] = ff_hevc_put_hevc_epel_h12_8_msa;
-        c->put_hevc_epel[5][0][1] = ff_hevc_put_hevc_epel_h16_8_msa;
-        c->put_hevc_epel[6][0][1] = ff_hevc_put_hevc_epel_h24_8_msa;
-        c->put_hevc_epel[7][0][1] = ff_hevc_put_hevc_epel_h32_8_msa;
-
-        c->put_hevc_epel[1][1][0] = ff_hevc_put_hevc_epel_v4_8_msa;
-        c->put_hevc_epel[2][1][0] = ff_hevc_put_hevc_epel_v6_8_msa;
-        c->put_hevc_epel[3][1][0] = ff_hevc_put_hevc_epel_v8_8_msa;
-        c->put_hevc_epel[4][1][0] = ff_hevc_put_hevc_epel_v12_8_msa;
-        c->put_hevc_epel[5][1][0] = ff_hevc_put_hevc_epel_v16_8_msa;
-        c->put_hevc_epel[6][1][0] = ff_hevc_put_hevc_epel_v24_8_msa;
-        c->put_hevc_epel[7][1][0] = ff_hevc_put_hevc_epel_v32_8_msa;
-
-        c->put_hevc_epel[1][1][1] = ff_hevc_put_hevc_epel_hv4_8_msa;
-        c->put_hevc_epel[2][1][1] = ff_hevc_put_hevc_epel_hv6_8_msa;
-        c->put_hevc_epel[3][1][1] = ff_hevc_put_hevc_epel_hv8_8_msa;
-        c->put_hevc_epel[4][1][1] = ff_hevc_put_hevc_epel_hv12_8_msa;
-        c->put_hevc_epel[5][1][1] = ff_hevc_put_hevc_epel_hv16_8_msa;
-        c->put_hevc_epel[6][1][1] = ff_hevc_put_hevc_epel_hv24_8_msa;
-        c->put_hevc_epel[7][1][1] = ff_hevc_put_hevc_epel_hv32_8_msa;
-
-        c->put_hevc_qpel_uni[3][0][0] = ff_hevc_put_hevc_uni_pel_pixels8_8_msa;
-        c->put_hevc_qpel_uni[4][0][0] = ff_hevc_put_hevc_uni_pel_pixels12_8_msa;
-        c->put_hevc_qpel_uni[5][0][0] = ff_hevc_put_hevc_uni_pel_pixels16_8_msa;
-        c->put_hevc_qpel_uni[6][0][0] = ff_hevc_put_hevc_uni_pel_pixels24_8_msa;
-        c->put_hevc_qpel_uni[7][0][0] = ff_hevc_put_hevc_uni_pel_pixels32_8_msa;
-        c->put_hevc_qpel_uni[8][0][0] = ff_hevc_put_hevc_uni_pel_pixels48_8_msa;
-        c->put_hevc_qpel_uni[9][0][0] = ff_hevc_put_hevc_uni_pel_pixels64_8_msa;
-
-        c->put_hevc_qpel_uni[1][0][1] = ff_hevc_put_hevc_uni_qpel_h4_8_msa;
-        c->put_hevc_qpel_uni[3][0][1] = ff_hevc_put_hevc_uni_qpel_h8_8_msa;
-        c->put_hevc_qpel_uni[4][0][1] = ff_hevc_put_hevc_uni_qpel_h12_8_msa;
-        c->put_hevc_qpel_uni[5][0][1] = ff_hevc_put_hevc_uni_qpel_h16_8_msa;
-        c->put_hevc_qpel_uni[6][0][1] = ff_hevc_put_hevc_uni_qpel_h24_8_msa;
-        c->put_hevc_qpel_uni[7][0][1] = ff_hevc_put_hevc_uni_qpel_h32_8_msa;
-        c->put_hevc_qpel_uni[8][0][1] = ff_hevc_put_hevc_uni_qpel_h48_8_msa;
-        c->put_hevc_qpel_uni[9][0][1] = ff_hevc_put_hevc_uni_qpel_h64_8_msa;
-
-        c->put_hevc_qpel_uni[1][1][0] = ff_hevc_put_hevc_uni_qpel_v4_8_msa;
-        c->put_hevc_qpel_uni[3][1][0] = ff_hevc_put_hevc_uni_qpel_v8_8_msa;
-        c->put_hevc_qpel_uni[4][1][0] = ff_hevc_put_hevc_uni_qpel_v12_8_msa;
-        c->put_hevc_qpel_uni[5][1][0] = ff_hevc_put_hevc_uni_qpel_v16_8_msa;
-        c->put_hevc_qpel_uni[6][1][0] = ff_hevc_put_hevc_uni_qpel_v24_8_msa;
-        c->put_hevc_qpel_uni[7][1][0] = ff_hevc_put_hevc_uni_qpel_v32_8_msa;
-        c->put_hevc_qpel_uni[8][1][0] = ff_hevc_put_hevc_uni_qpel_v48_8_msa;
-        c->put_hevc_qpel_uni[9][1][0] = ff_hevc_put_hevc_uni_qpel_v64_8_msa;
-
-        c->put_hevc_qpel_uni[1][1][1] = ff_hevc_put_hevc_uni_qpel_hv4_8_msa;
-        c->put_hevc_qpel_uni[3][1][1] = ff_hevc_put_hevc_uni_qpel_hv8_8_msa;
-        c->put_hevc_qpel_uni[4][1][1] = ff_hevc_put_hevc_uni_qpel_hv12_8_msa;
-        c->put_hevc_qpel_uni[5][1][1] = ff_hevc_put_hevc_uni_qpel_hv16_8_msa;
-        c->put_hevc_qpel_uni[6][1][1] = ff_hevc_put_hevc_uni_qpel_hv24_8_msa;
-        c->put_hevc_qpel_uni[7][1][1] = ff_hevc_put_hevc_uni_qpel_hv32_8_msa;
-        c->put_hevc_qpel_uni[8][1][1] = ff_hevc_put_hevc_uni_qpel_hv48_8_msa;
-        c->put_hevc_qpel_uni[9][1][1] = ff_hevc_put_hevc_uni_qpel_hv64_8_msa;
-
-        c->put_hevc_epel_uni[3][0][0] = ff_hevc_put_hevc_uni_pel_pixels8_8_msa;
-        c->put_hevc_epel_uni[4][0][0] = ff_hevc_put_hevc_uni_pel_pixels12_8_msa;
-        c->put_hevc_epel_uni[5][0][0] = ff_hevc_put_hevc_uni_pel_pixels16_8_msa;
-        c->put_hevc_epel_uni[6][0][0] = ff_hevc_put_hevc_uni_pel_pixels24_8_msa;
-        c->put_hevc_epel_uni[7][0][0] = ff_hevc_put_hevc_uni_pel_pixels32_8_msa;
-
-        c->put_hevc_epel_uni[1][0][1] = ff_hevc_put_hevc_uni_epel_h4_8_msa;
-        c->put_hevc_epel_uni[2][0][1] = ff_hevc_put_hevc_uni_epel_h6_8_msa;
-        c->put_hevc_epel_uni[3][0][1] = ff_hevc_put_hevc_uni_epel_h8_8_msa;
-        c->put_hevc_epel_uni[4][0][1] = ff_hevc_put_hevc_uni_epel_h12_8_msa;
-        c->put_hevc_epel_uni[5][0][1] = ff_hevc_put_hevc_uni_epel_h16_8_msa;
-        c->put_hevc_epel_uni[6][0][1] = ff_hevc_put_hevc_uni_epel_h24_8_msa;
-        c->put_hevc_epel_uni[7][0][1] = ff_hevc_put_hevc_uni_epel_h32_8_msa;
-
-        c->put_hevc_epel_uni[1][1][0] = ff_hevc_put_hevc_uni_epel_v4_8_msa;
-        c->put_hevc_epel_uni[2][1][0] = ff_hevc_put_hevc_uni_epel_v6_8_msa;
-        c->put_hevc_epel_uni[3][1][0] = ff_hevc_put_hevc_uni_epel_v8_8_msa;
-        c->put_hevc_epel_uni[4][1][0] = ff_hevc_put_hevc_uni_epel_v12_8_msa;
-        c->put_hevc_epel_uni[5][1][0] = ff_hevc_put_hevc_uni_epel_v16_8_msa;
-        c->put_hevc_epel_uni[6][1][0] = ff_hevc_put_hevc_uni_epel_v24_8_msa;
-        c->put_hevc_epel_uni[7][1][0] = ff_hevc_put_hevc_uni_epel_v32_8_msa;
-
-        c->put_hevc_epel_uni[1][1][1] = ff_hevc_put_hevc_uni_epel_hv4_8_msa;
-        c->put_hevc_epel_uni[2][1][1] = ff_hevc_put_hevc_uni_epel_hv6_8_msa;
-        c->put_hevc_epel_uni[3][1][1] = ff_hevc_put_hevc_uni_epel_hv8_8_msa;
-        c->put_hevc_epel_uni[4][1][1] = ff_hevc_put_hevc_uni_epel_hv12_8_msa;
-        c->put_hevc_epel_uni[5][1][1] = ff_hevc_put_hevc_uni_epel_hv16_8_msa;
-        c->put_hevc_epel_uni[6][1][1] = ff_hevc_put_hevc_uni_epel_hv24_8_msa;
-        c->put_hevc_epel_uni[7][1][1] = ff_hevc_put_hevc_uni_epel_hv32_8_msa;
-
-        c->put_hevc_qpel_uni_w[1][0][0] =
-            ff_hevc_put_hevc_uni_w_pel_pixels4_8_msa;
-        c->put_hevc_qpel_uni_w[3][0][0] =
-            ff_hevc_put_hevc_uni_w_pel_pixels8_8_msa;
-        c->put_hevc_qpel_uni_w[4][0][0] =
-            ff_hevc_put_hevc_uni_w_pel_pixels12_8_msa;
-        c->put_hevc_qpel_uni_w[5][0][0] =
-            ff_hevc_put_hevc_uni_w_pel_pixels16_8_msa;
-        c->put_hevc_qpel_uni_w[6][0][0] =
-            ff_hevc_put_hevc_uni_w_pel_pixels24_8_msa;
-        c->put_hevc_qpel_uni_w[7][0][0] =
-            ff_hevc_put_hevc_uni_w_pel_pixels32_8_msa;
-        c->put_hevc_qpel_uni_w[8][0][0] =
-            ff_hevc_put_hevc_uni_w_pel_pixels48_8_msa;
-        c->put_hevc_qpel_uni_w[9][0][0] =
-            ff_hevc_put_hevc_uni_w_pel_pixels64_8_msa;
-
-        c->put_hevc_qpel_uni_w[1][0][1] = ff_hevc_put_hevc_uni_w_qpel_h4_8_msa;
-        c->put_hevc_qpel_uni_w[3][0][1] = ff_hevc_put_hevc_uni_w_qpel_h8_8_msa;
-        c->put_hevc_qpel_uni_w[4][0][1] = ff_hevc_put_hevc_uni_w_qpel_h12_8_msa;
-        c->put_hevc_qpel_uni_w[5][0][1] = ff_hevc_put_hevc_uni_w_qpel_h16_8_msa;
-        c->put_hevc_qpel_uni_w[6][0][1] = ff_hevc_put_hevc_uni_w_qpel_h24_8_msa;
-        c->put_hevc_qpel_uni_w[7][0][1] = ff_hevc_put_hevc_uni_w_qpel_h32_8_msa;
-        c->put_hevc_qpel_uni_w[8][0][1] = ff_hevc_put_hevc_uni_w_qpel_h48_8_msa;
-        c->put_hevc_qpel_uni_w[9][0][1] = ff_hevc_put_hevc_uni_w_qpel_h64_8_msa;
-
-        c->put_hevc_qpel_uni_w[1][1][0] = ff_hevc_put_hevc_uni_w_qpel_v4_8_msa;
-        c->put_hevc_qpel_uni_w[3][1][0] = ff_hevc_put_hevc_uni_w_qpel_v8_8_msa;
-        c->put_hevc_qpel_uni_w[4][1][0] = ff_hevc_put_hevc_uni_w_qpel_v12_8_msa;
-        c->put_hevc_qpel_uni_w[5][1][0] = ff_hevc_put_hevc_uni_w_qpel_v16_8_msa;
-        c->put_hevc_qpel_uni_w[6][1][0] = ff_hevc_put_hevc_uni_w_qpel_v24_8_msa;
-        c->put_hevc_qpel_uni_w[7][1][0] = ff_hevc_put_hevc_uni_w_qpel_v32_8_msa;
-        c->put_hevc_qpel_uni_w[8][1][0] = ff_hevc_put_hevc_uni_w_qpel_v48_8_msa;
-        c->put_hevc_qpel_uni_w[9][1][0] = ff_hevc_put_hevc_uni_w_qpel_v64_8_msa;
-
-        c->put_hevc_qpel_uni_w[1][1][1] = ff_hevc_put_hevc_uni_w_qpel_hv4_8_msa;
-        c->put_hevc_qpel_uni_w[3][1][1] = ff_hevc_put_hevc_uni_w_qpel_hv8_8_msa;
-        c->put_hevc_qpel_uni_w[4][1][1] =
-            ff_hevc_put_hevc_uni_w_qpel_hv12_8_msa;
-        c->put_hevc_qpel_uni_w[5][1][1] =
-            ff_hevc_put_hevc_uni_w_qpel_hv16_8_msa;
-        c->put_hevc_qpel_uni_w[6][1][1] =
-            ff_hevc_put_hevc_uni_w_qpel_hv24_8_msa;
-        c->put_hevc_qpel_uni_w[7][1][1] =
-            ff_hevc_put_hevc_uni_w_qpel_hv32_8_msa;
-        c->put_hevc_qpel_uni_w[8][1][1] =
-            ff_hevc_put_hevc_uni_w_qpel_hv48_8_msa;
-        c->put_hevc_qpel_uni_w[9][1][1] =
-            ff_hevc_put_hevc_uni_w_qpel_hv64_8_msa;
-
-        c->put_hevc_epel_uni_w[1][0][0] =
-            ff_hevc_put_hevc_uni_w_pel_pixels4_8_msa;
-        c->put_hevc_epel_uni_w[2][0][0] =
-            ff_hevc_put_hevc_uni_w_pel_pixels6_8_msa;
-        c->put_hevc_epel_uni_w[3][0][0] =
-            ff_hevc_put_hevc_uni_w_pel_pixels8_8_msa;
-        c->put_hevc_epel_uni_w[4][0][0] =
-            ff_hevc_put_hevc_uni_w_pel_pixels12_8_msa;
-        c->put_hevc_epel_uni_w[5][0][0] =
-            ff_hevc_put_hevc_uni_w_pel_pixels16_8_msa;
-        c->put_hevc_epel_uni_w[6][0][0] =
-            ff_hevc_put_hevc_uni_w_pel_pixels24_8_msa;
-        c->put_hevc_epel_uni_w[7][0][0] =
-            ff_hevc_put_hevc_uni_w_pel_pixels32_8_msa;
-
-        c->put_hevc_epel_uni_w[1][0][1] = ff_hevc_put_hevc_uni_w_epel_h4_8_msa;
-        c->put_hevc_epel_uni_w[2][0][1] = ff_hevc_put_hevc_uni_w_epel_h6_8_msa;
-        c->put_hevc_epel_uni_w[3][0][1] = ff_hevc_put_hevc_uni_w_epel_h8_8_msa;
-        c->put_hevc_epel_uni_w[4][0][1] = ff_hevc_put_hevc_uni_w_epel_h12_8_msa;
-        c->put_hevc_epel_uni_w[5][0][1] = ff_hevc_put_hevc_uni_w_epel_h16_8_msa;
-        c->put_hevc_epel_uni_w[6][0][1] = ff_hevc_put_hevc_uni_w_epel_h24_8_msa;
-        c->put_hevc_epel_uni_w[7][0][1] = ff_hevc_put_hevc_uni_w_epel_h32_8_msa;
-
-        c->put_hevc_epel_uni_w[1][1][0] = ff_hevc_put_hevc_uni_w_epel_v4_8_msa;
-        c->put_hevc_epel_uni_w[2][1][0] = ff_hevc_put_hevc_uni_w_epel_v6_8_msa;
-        c->put_hevc_epel_uni_w[3][1][0] = ff_hevc_put_hevc_uni_w_epel_v8_8_msa;
-        c->put_hevc_epel_uni_w[4][1][0] = ff_hevc_put_hevc_uni_w_epel_v12_8_msa;
-        c->put_hevc_epel_uni_w[5][1][0] = ff_hevc_put_hevc_uni_w_epel_v16_8_msa;
-        c->put_hevc_epel_uni_w[6][1][0] = ff_hevc_put_hevc_uni_w_epel_v24_8_msa;
-        c->put_hevc_epel_uni_w[7][1][0] = ff_hevc_put_hevc_uni_w_epel_v32_8_msa;
-
-        c->put_hevc_epel_uni_w[1][1][1] = ff_hevc_put_hevc_uni_w_epel_hv4_8_msa;
-        c->put_hevc_epel_uni_w[2][1][1] = ff_hevc_put_hevc_uni_w_epel_hv6_8_msa;
-        c->put_hevc_epel_uni_w[3][1][1] = ff_hevc_put_hevc_uni_w_epel_hv8_8_msa;
-        c->put_hevc_epel_uni_w[4][1][1] =
-            ff_hevc_put_hevc_uni_w_epel_hv12_8_msa;
-        c->put_hevc_epel_uni_w[5][1][1] =
-            ff_hevc_put_hevc_uni_w_epel_hv16_8_msa;
-        c->put_hevc_epel_uni_w[6][1][1] =
-            ff_hevc_put_hevc_uni_w_epel_hv24_8_msa;
-        c->put_hevc_epel_uni_w[7][1][1] =
-            ff_hevc_put_hevc_uni_w_epel_hv32_8_msa;
-
-        c->put_hevc_qpel_bi[1][0][0] = ff_hevc_put_hevc_bi_pel_pixels4_8_msa;
-        c->put_hevc_qpel_bi[3][0][0] = ff_hevc_put_hevc_bi_pel_pixels8_8_msa;
-        c->put_hevc_qpel_bi[4][0][0] = ff_hevc_put_hevc_bi_pel_pixels12_8_msa;
-        c->put_hevc_qpel_bi[5][0][0] = ff_hevc_put_hevc_bi_pel_pixels16_8_msa;
-        c->put_hevc_qpel_bi[6][0][0] = ff_hevc_put_hevc_bi_pel_pixels24_8_msa;
-        c->put_hevc_qpel_bi[7][0][0] = ff_hevc_put_hevc_bi_pel_pixels32_8_msa;
-        c->put_hevc_qpel_bi[8][0][0] = ff_hevc_put_hevc_bi_pel_pixels48_8_msa;
-        c->put_hevc_qpel_bi[9][0][0] = ff_hevc_put_hevc_bi_pel_pixels64_8_msa;
-
-        c->put_hevc_qpel_bi[1][0][1] = ff_hevc_put_hevc_bi_qpel_h4_8_msa;
-        c->put_hevc_qpel_bi[3][0][1] = ff_hevc_put_hevc_bi_qpel_h8_8_msa;
-        c->put_hevc_qpel_bi[4][0][1] = ff_hevc_put_hevc_bi_qpel_h12_8_msa;
-        c->put_hevc_qpel_bi[5][0][1] = ff_hevc_put_hevc_bi_qpel_h16_8_msa;
-        c->put_hevc_qpel_bi[6][0][1] = ff_hevc_put_hevc_bi_qpel_h24_8_msa;
-        c->put_hevc_qpel_bi[7][0][1] = ff_hevc_put_hevc_bi_qpel_h32_8_msa;
-        c->put_hevc_qpel_bi[8][0][1] = ff_hevc_put_hevc_bi_qpel_h48_8_msa;
-        c->put_hevc_qpel_bi[9][0][1] = ff_hevc_put_hevc_bi_qpel_h64_8_msa;
-
-        c->put_hevc_qpel_bi[1][1][0] = ff_hevc_put_hevc_bi_qpel_v4_8_msa;
-        c->put_hevc_qpel_bi[3][1][0] = ff_hevc_put_hevc_bi_qpel_v8_8_msa;
-        c->put_hevc_qpel_bi[4][1][0] = ff_hevc_put_hevc_bi_qpel_v12_8_msa;
-        c->put_hevc_qpel_bi[5][1][0] = ff_hevc_put_hevc_bi_qpel_v16_8_msa;
-        c->put_hevc_qpel_bi[6][1][0] = ff_hevc_put_hevc_bi_qpel_v24_8_msa;
-        c->put_hevc_qpel_bi[7][1][0] = ff_hevc_put_hevc_bi_qpel_v32_8_msa;
-        c->put_hevc_qpel_bi[8][1][0] = ff_hevc_put_hevc_bi_qpel_v48_8_msa;
-        c->put_hevc_qpel_bi[9][1][0] = ff_hevc_put_hevc_bi_qpel_v64_8_msa;
-
-        c->put_hevc_qpel_bi[1][1][1] = ff_hevc_put_hevc_bi_qpel_hv4_8_msa;
-        c->put_hevc_qpel_bi[3][1][1] = ff_hevc_put_hevc_bi_qpel_hv8_8_msa;
-        c->put_hevc_qpel_bi[4][1][1] = ff_hevc_put_hevc_bi_qpel_hv12_8_msa;
-        c->put_hevc_qpel_bi[5][1][1] = ff_hevc_put_hevc_bi_qpel_hv16_8_msa;
-        c->put_hevc_qpel_bi[6][1][1] = ff_hevc_put_hevc_bi_qpel_hv24_8_msa;
-        c->put_hevc_qpel_bi[7][1][1] = ff_hevc_put_hevc_bi_qpel_hv32_8_msa;
-        c->put_hevc_qpel_bi[8][1][1] = ff_hevc_put_hevc_bi_qpel_hv48_8_msa;
-        c->put_hevc_qpel_bi[9][1][1] = ff_hevc_put_hevc_bi_qpel_hv64_8_msa;
-
-        c->put_hevc_epel_bi[1][0][0] = ff_hevc_put_hevc_bi_pel_pixels4_8_msa;
-        c->put_hevc_epel_bi[2][0][0] = ff_hevc_put_hevc_bi_pel_pixels6_8_msa;
-        c->put_hevc_epel_bi[3][0][0] = ff_hevc_put_hevc_bi_pel_pixels8_8_msa;
-        c->put_hevc_epel_bi[4][0][0] = ff_hevc_put_hevc_bi_pel_pixels12_8_msa;
-        c->put_hevc_epel_bi[5][0][0] = ff_hevc_put_hevc_bi_pel_pixels16_8_msa;
-        c->put_hevc_epel_bi[6][0][0] = ff_hevc_put_hevc_bi_pel_pixels24_8_msa;
-        c->put_hevc_epel_bi[7][0][0] = ff_hevc_put_hevc_bi_pel_pixels32_8_msa;
-
-        c->put_hevc_epel_bi[1][0][1] = ff_hevc_put_hevc_bi_epel_h4_8_msa;
-        c->put_hevc_epel_bi[2][0][1] = ff_hevc_put_hevc_bi_epel_h6_8_msa;
-        c->put_hevc_epel_bi[3][0][1] = ff_hevc_put_hevc_bi_epel_h8_8_msa;
-        c->put_hevc_epel_bi[4][0][1] = ff_hevc_put_hevc_bi_epel_h12_8_msa;
-        c->put_hevc_epel_bi[5][0][1] = ff_hevc_put_hevc_bi_epel_h16_8_msa;
-        c->put_hevc_epel_bi[6][0][1] = ff_hevc_put_hevc_bi_epel_h24_8_msa;
-        c->put_hevc_epel_bi[7][0][1] = ff_hevc_put_hevc_bi_epel_h32_8_msa;
-
-        c->put_hevc_epel_bi[1][1][0] = ff_hevc_put_hevc_bi_epel_v4_8_msa;
-        c->put_hevc_epel_bi[2][1][0] = ff_hevc_put_hevc_bi_epel_v6_8_msa;
-        c->put_hevc_epel_bi[3][1][0] = ff_hevc_put_hevc_bi_epel_v8_8_msa;
-        c->put_hevc_epel_bi[4][1][0] = ff_hevc_put_hevc_bi_epel_v12_8_msa;
-        c->put_hevc_epel_bi[5][1][0] = ff_hevc_put_hevc_bi_epel_v16_8_msa;
-        c->put_hevc_epel_bi[6][1][0] = ff_hevc_put_hevc_bi_epel_v24_8_msa;
-        c->put_hevc_epel_bi[7][1][0] = ff_hevc_put_hevc_bi_epel_v32_8_msa;
-
-        c->put_hevc_epel_bi[1][1][1] = ff_hevc_put_hevc_bi_epel_hv4_8_msa;
-        c->put_hevc_epel_bi[2][1][1] = ff_hevc_put_hevc_bi_epel_hv6_8_msa;
-        c->put_hevc_epel_bi[3][1][1] = ff_hevc_put_hevc_bi_epel_hv8_8_msa;
-        c->put_hevc_epel_bi[4][1][1] = ff_hevc_put_hevc_bi_epel_hv12_8_msa;
-        c->put_hevc_epel_bi[5][1][1] = ff_hevc_put_hevc_bi_epel_hv16_8_msa;
-        c->put_hevc_epel_bi[6][1][1] = ff_hevc_put_hevc_bi_epel_hv24_8_msa;
-        c->put_hevc_epel_bi[7][1][1] = ff_hevc_put_hevc_bi_epel_hv32_8_msa;
-
-        c->put_hevc_qpel_bi_w[1][0][0] =
-            ff_hevc_put_hevc_bi_w_pel_pixels4_8_msa;
-        c->put_hevc_qpel_bi_w[3][0][0] =
-            ff_hevc_put_hevc_bi_w_pel_pixels8_8_msa;
-        c->put_hevc_qpel_bi_w[4][0][0] =
-            ff_hevc_put_hevc_bi_w_pel_pixels12_8_msa;
-        c->put_hevc_qpel_bi_w[5][0][0] =
-            ff_hevc_put_hevc_bi_w_pel_pixels16_8_msa;
-        c->put_hevc_qpel_bi_w[6][0][0] =
-            ff_hevc_put_hevc_bi_w_pel_pixels24_8_msa;
-        c->put_hevc_qpel_bi_w[7][0][0] =
-            ff_hevc_put_hevc_bi_w_pel_pixels32_8_msa;
-        c->put_hevc_qpel_bi_w[8][0][0] =
-            ff_hevc_put_hevc_bi_w_pel_pixels48_8_msa;
-        c->put_hevc_qpel_bi_w[9][0][0] =
-            ff_hevc_put_hevc_bi_w_pel_pixels64_8_msa;
-
-        c->put_hevc_qpel_bi_w[1][0][1] = ff_hevc_put_hevc_bi_w_qpel_h4_8_msa;
-        c->put_hevc_qpel_bi_w[3][0][1] = ff_hevc_put_hevc_bi_w_qpel_h8_8_msa;
-        c->put_hevc_qpel_bi_w[4][0][1] = ff_hevc_put_hevc_bi_w_qpel_h12_8_msa;
-        c->put_hevc_qpel_bi_w[5][0][1] = ff_hevc_put_hevc_bi_w_qpel_h16_8_msa;
-        c->put_hevc_qpel_bi_w[6][0][1] = ff_hevc_put_hevc_bi_w_qpel_h24_8_msa;
-        c->put_hevc_qpel_bi_w[7][0][1] = ff_hevc_put_hevc_bi_w_qpel_h32_8_msa;
-        c->put_hevc_qpel_bi_w[8][0][1] = ff_hevc_put_hevc_bi_w_qpel_h48_8_msa;
-        c->put_hevc_qpel_bi_w[9][0][1] = ff_hevc_put_hevc_bi_w_qpel_h64_8_msa;
-
-        c->put_hevc_qpel_bi_w[1][1][0] = ff_hevc_put_hevc_bi_w_qpel_v4_8_msa;
-        c->put_hevc_qpel_bi_w[3][1][0] = ff_hevc_put_hevc_bi_w_qpel_v8_8_msa;
-        c->put_hevc_qpel_bi_w[4][1][0] = ff_hevc_put_hevc_bi_w_qpel_v12_8_msa;
-        c->put_hevc_qpel_bi_w[5][1][0] = ff_hevc_put_hevc_bi_w_qpel_v16_8_msa;
-        c->put_hevc_qpel_bi_w[6][1][0] = ff_hevc_put_hevc_bi_w_qpel_v24_8_msa;
-        c->put_hevc_qpel_bi_w[7][1][0] = ff_hevc_put_hevc_bi_w_qpel_v32_8_msa;
-        c->put_hevc_qpel_bi_w[8][1][0] = ff_hevc_put_hevc_bi_w_qpel_v48_8_msa;
-        c->put_hevc_qpel_bi_w[9][1][0] = ff_hevc_put_hevc_bi_w_qpel_v64_8_msa;
-
-        c->put_hevc_qpel_bi_w[1][1][1] = ff_hevc_put_hevc_bi_w_qpel_hv4_8_msa;
-        c->put_hevc_qpel_bi_w[3][1][1] = ff_hevc_put_hevc_bi_w_qpel_hv8_8_msa;
-        c->put_hevc_qpel_bi_w[4][1][1] = ff_hevc_put_hevc_bi_w_qpel_hv12_8_msa;
-        c->put_hevc_qpel_bi_w[5][1][1] = ff_hevc_put_hevc_bi_w_qpel_hv16_8_msa;
-        c->put_hevc_qpel_bi_w[6][1][1] = ff_hevc_put_hevc_bi_w_qpel_hv24_8_msa;
-        c->put_hevc_qpel_bi_w[7][1][1] = ff_hevc_put_hevc_bi_w_qpel_hv32_8_msa;
-        c->put_hevc_qpel_bi_w[8][1][1] = ff_hevc_put_hevc_bi_w_qpel_hv48_8_msa;
-        c->put_hevc_qpel_bi_w[9][1][1] = ff_hevc_put_hevc_bi_w_qpel_hv64_8_msa;
-
-        c->put_hevc_epel_bi_w[1][0][0] =
-            ff_hevc_put_hevc_bi_w_pel_pixels4_8_msa;
-        c->put_hevc_epel_bi_w[2][0][0] =
-            ff_hevc_put_hevc_bi_w_pel_pixels6_8_msa;
-        c->put_hevc_epel_bi_w[3][0][0] =
-            ff_hevc_put_hevc_bi_w_pel_pixels8_8_msa;
-        c->put_hevc_epel_bi_w[4][0][0] =
-            ff_hevc_put_hevc_bi_w_pel_pixels12_8_msa;
-        c->put_hevc_epel_bi_w[5][0][0] =
-            ff_hevc_put_hevc_bi_w_pel_pixels16_8_msa;
-        c->put_hevc_epel_bi_w[6][0][0] =
-            ff_hevc_put_hevc_bi_w_pel_pixels24_8_msa;
-        c->put_hevc_epel_bi_w[7][0][0] =
-            ff_hevc_put_hevc_bi_w_pel_pixels32_8_msa;
-
-        c->put_hevc_epel_bi_w[1][0][1] = ff_hevc_put_hevc_bi_w_epel_h4_8_msa;
-        c->put_hevc_epel_bi_w[2][0][1] = ff_hevc_put_hevc_bi_w_epel_h6_8_msa;
-        c->put_hevc_epel_bi_w[3][0][1] = ff_hevc_put_hevc_bi_w_epel_h8_8_msa;
-        c->put_hevc_epel_bi_w[4][0][1] = ff_hevc_put_hevc_bi_w_epel_h12_8_msa;
-        c->put_hevc_epel_bi_w[5][0][1] = ff_hevc_put_hevc_bi_w_epel_h16_8_msa;
-        c->put_hevc_epel_bi_w[6][0][1] = ff_hevc_put_hevc_bi_w_epel_h24_8_msa;
-        c->put_hevc_epel_bi_w[7][0][1] = ff_hevc_put_hevc_bi_w_epel_h32_8_msa;
-
-        c->put_hevc_epel_bi_w[1][1][0] = ff_hevc_put_hevc_bi_w_epel_v4_8_msa;
-        c->put_hevc_epel_bi_w[2][1][0] = ff_hevc_put_hevc_bi_w_epel_v6_8_msa;
-        c->put_hevc_epel_bi_w[3][1][0] = ff_hevc_put_hevc_bi_w_epel_v8_8_msa;
-        c->put_hevc_epel_bi_w[4][1][0] = ff_hevc_put_hevc_bi_w_epel_v12_8_msa;
-        c->put_hevc_epel_bi_w[5][1][0] = ff_hevc_put_hevc_bi_w_epel_v16_8_msa;
-        c->put_hevc_epel_bi_w[6][1][0] = ff_hevc_put_hevc_bi_w_epel_v24_8_msa;
-        c->put_hevc_epel_bi_w[7][1][0] = ff_hevc_put_hevc_bi_w_epel_v32_8_msa;
-
-        c->put_hevc_epel_bi_w[1][1][1] = ff_hevc_put_hevc_bi_w_epel_hv4_8_msa;
-        c->put_hevc_epel_bi_w[2][1][1] = ff_hevc_put_hevc_bi_w_epel_hv6_8_msa;
-        c->put_hevc_epel_bi_w[3][1][1] = ff_hevc_put_hevc_bi_w_epel_hv8_8_msa;
-        c->put_hevc_epel_bi_w[4][1][1] = ff_hevc_put_hevc_bi_w_epel_hv12_8_msa;
-        c->put_hevc_epel_bi_w[5][1][1] = ff_hevc_put_hevc_bi_w_epel_hv16_8_msa;
-        c->put_hevc_epel_bi_w[6][1][1] = ff_hevc_put_hevc_bi_w_epel_hv24_8_msa;
-        c->put_hevc_epel_bi_w[7][1][1] = ff_hevc_put_hevc_bi_w_epel_hv32_8_msa;
-
-        c->sao_band_filter[0] =
-        c->sao_band_filter[1] =
-        c->sao_band_filter[2] =
-        c->sao_band_filter[3] =
-        c->sao_band_filter[4] = ff_hevc_sao_band_filter_0_8_msa;
-
-        c->sao_edge_filter[0] =
-        c->sao_edge_filter[1] =
-        c->sao_edge_filter[2] =
-        c->sao_edge_filter[3] =
-        c->sao_edge_filter[4] = ff_hevc_sao_edge_filter_8_msa;
-
-        c->hevc_h_loop_filter_luma = ff_hevc_loop_filter_luma_h_8_msa;
-        c->hevc_v_loop_filter_luma = ff_hevc_loop_filter_luma_v_8_msa;
-
-        c->hevc_h_loop_filter_chroma = ff_hevc_loop_filter_chroma_h_8_msa;
-        c->hevc_v_loop_filter_chroma = ff_hevc_loop_filter_chroma_v_8_msa;
-
-        c->hevc_h_loop_filter_luma_c = ff_hevc_loop_filter_luma_h_8_msa;
-        c->hevc_v_loop_filter_luma_c = ff_hevc_loop_filter_luma_v_8_msa;
-
-        c->hevc_h_loop_filter_chroma_c =
-            ff_hevc_loop_filter_chroma_h_8_msa;
-        c->hevc_v_loop_filter_chroma_c =
-            ff_hevc_loop_filter_chroma_v_8_msa;
-
-        c->idct[0] = ff_hevc_idct_4x4_msa;
-        c->idct[1] = ff_hevc_idct_8x8_msa;
-        c->idct[2] = ff_hevc_idct_16x16_msa;
-        c->idct[3] = ff_hevc_idct_32x32_msa;
-        c->idct_dc[0] = ff_hevc_idct_dc_4x4_msa;
-        c->idct_dc[1] = ff_hevc_idct_dc_8x8_msa;
-        c->idct_dc[2] = ff_hevc_idct_dc_16x16_msa;
-        c->idct_dc[3] = ff_hevc_idct_dc_32x32_msa;
-        c->add_residual[0] = ff_hevc_addblk_4x4_msa;
-        c->add_residual[1] = ff_hevc_addblk_8x8_msa;
-        c->add_residual[2] = ff_hevc_addblk_16x16_msa;
-        c->add_residual[3] = ff_hevc_addblk_32x32_msa;
-        c->transform_4x4_luma = ff_hevc_idct_luma_4x4_msa;
+    if (have_msa(cpu_flags)) {
+        if (bit_depth == 8) {
+            c->put_hevc_qpel[1][0][0] = ff_hevc_put_hevc_pel_pixels4_8_msa;
+            c->put_hevc_qpel[2][0][0] = ff_hevc_put_hevc_pel_pixels6_8_msa;
+            c->put_hevc_qpel[3][0][0] = ff_hevc_put_hevc_pel_pixels8_8_msa;
+            c->put_hevc_qpel[4][0][0] = ff_hevc_put_hevc_pel_pixels12_8_msa;
+            c->put_hevc_qpel[5][0][0] = ff_hevc_put_hevc_pel_pixels16_8_msa;
+            c->put_hevc_qpel[6][0][0] = ff_hevc_put_hevc_pel_pixels24_8_msa;
+            c->put_hevc_qpel[7][0][0] = ff_hevc_put_hevc_pel_pixels32_8_msa;
+            c->put_hevc_qpel[8][0][0] = ff_hevc_put_hevc_pel_pixels48_8_msa;
+            c->put_hevc_qpel[9][0][0] = ff_hevc_put_hevc_pel_pixels64_8_msa;
+
+            c->put_hevc_qpel[1][0][1] = ff_hevc_put_hevc_qpel_h4_8_msa;
+            c->put_hevc_qpel[3][0][1] = ff_hevc_put_hevc_qpel_h8_8_msa;
+            c->put_hevc_qpel[4][0][1] = ff_hevc_put_hevc_qpel_h12_8_msa;
+            c->put_hevc_qpel[5][0][1] = ff_hevc_put_hevc_qpel_h16_8_msa;
+            c->put_hevc_qpel[6][0][1] = ff_hevc_put_hevc_qpel_h24_8_msa;
+            c->put_hevc_qpel[7][0][1] = ff_hevc_put_hevc_qpel_h32_8_msa;
+            c->put_hevc_qpel[8][0][1] = ff_hevc_put_hevc_qpel_h48_8_msa;
+            c->put_hevc_qpel[9][0][1] = ff_hevc_put_hevc_qpel_h64_8_msa;
+
+            c->put_hevc_qpel[1][1][0] = ff_hevc_put_hevc_qpel_v4_8_msa;
+            c->put_hevc_qpel[3][1][0] = ff_hevc_put_hevc_qpel_v8_8_msa;
+            c->put_hevc_qpel[4][1][0] = ff_hevc_put_hevc_qpel_v12_8_msa;
+            c->put_hevc_qpel[5][1][0] = ff_hevc_put_hevc_qpel_v16_8_msa;
+            c->put_hevc_qpel[6][1][0] = ff_hevc_put_hevc_qpel_v24_8_msa;
+            c->put_hevc_qpel[7][1][0] = ff_hevc_put_hevc_qpel_v32_8_msa;
+            c->put_hevc_qpel[8][1][0] = ff_hevc_put_hevc_qpel_v48_8_msa;
+            c->put_hevc_qpel[9][1][0] = ff_hevc_put_hevc_qpel_v64_8_msa;
+
+            c->put_hevc_qpel[1][1][1] = ff_hevc_put_hevc_qpel_hv4_8_msa;
+            c->put_hevc_qpel[3][1][1] = ff_hevc_put_hevc_qpel_hv8_8_msa;
+            c->put_hevc_qpel[4][1][1] = ff_hevc_put_hevc_qpel_hv12_8_msa;
+            c->put_hevc_qpel[5][1][1] = ff_hevc_put_hevc_qpel_hv16_8_msa;
+            c->put_hevc_qpel[6][1][1] = ff_hevc_put_hevc_qpel_hv24_8_msa;
+            c->put_hevc_qpel[7][1][1] = ff_hevc_put_hevc_qpel_hv32_8_msa;
+            c->put_hevc_qpel[8][1][1] = ff_hevc_put_hevc_qpel_hv48_8_msa;
+            c->put_hevc_qpel[9][1][1] = ff_hevc_put_hevc_qpel_hv64_8_msa;
+
+            c->put_hevc_epel[1][0][0] = ff_hevc_put_hevc_pel_pixels4_8_msa;
+            c->put_hevc_epel[2][0][0] = ff_hevc_put_hevc_pel_pixels6_8_msa;
+            c->put_hevc_epel[3][0][0] = ff_hevc_put_hevc_pel_pixels8_8_msa;
+            c->put_hevc_epel[4][0][0] = ff_hevc_put_hevc_pel_pixels12_8_msa;
+            c->put_hevc_epel[5][0][0] = ff_hevc_put_hevc_pel_pixels16_8_msa;
+            c->put_hevc_epel[6][0][0] = ff_hevc_put_hevc_pel_pixels24_8_msa;
+            c->put_hevc_epel[7][0][0] = ff_hevc_put_hevc_pel_pixels32_8_msa;
+
+            c->put_hevc_epel[1][0][1] = ff_hevc_put_hevc_epel_h4_8_msa;
+            c->put_hevc_epel[2][0][1] = ff_hevc_put_hevc_epel_h6_8_msa;
+            c->put_hevc_epel[3][0][1] = ff_hevc_put_hevc_epel_h8_8_msa;
+            c->put_hevc_epel[4][0][1] = ff_hevc_put_hevc_epel_h12_8_msa;
+            c->put_hevc_epel[5][0][1] = ff_hevc_put_hevc_epel_h16_8_msa;
+            c->put_hevc_epel[6][0][1] = ff_hevc_put_hevc_epel_h24_8_msa;
+            c->put_hevc_epel[7][0][1] = ff_hevc_put_hevc_epel_h32_8_msa;
+
+            c->put_hevc_epel[1][1][0] = ff_hevc_put_hevc_epel_v4_8_msa;
+            c->put_hevc_epel[2][1][0] = ff_hevc_put_hevc_epel_v6_8_msa;
+            c->put_hevc_epel[3][1][0] = ff_hevc_put_hevc_epel_v8_8_msa;
+            c->put_hevc_epel[4][1][0] = ff_hevc_put_hevc_epel_v12_8_msa;
+            c->put_hevc_epel[5][1][0] = ff_hevc_put_hevc_epel_v16_8_msa;
+            c->put_hevc_epel[6][1][0] = ff_hevc_put_hevc_epel_v24_8_msa;
+            c->put_hevc_epel[7][1][0] = ff_hevc_put_hevc_epel_v32_8_msa;
+
+            c->put_hevc_epel[1][1][1] = ff_hevc_put_hevc_epel_hv4_8_msa;
+            c->put_hevc_epel[2][1][1] = ff_hevc_put_hevc_epel_hv6_8_msa;
+            c->put_hevc_epel[3][1][1] = ff_hevc_put_hevc_epel_hv8_8_msa;
+            c->put_hevc_epel[4][1][1] = ff_hevc_put_hevc_epel_hv12_8_msa;
+            c->put_hevc_epel[5][1][1] = ff_hevc_put_hevc_epel_hv16_8_msa;
+            c->put_hevc_epel[6][1][1] = ff_hevc_put_hevc_epel_hv24_8_msa;
+            c->put_hevc_epel[7][1][1] = ff_hevc_put_hevc_epel_hv32_8_msa;
+
+            c->put_hevc_qpel_uni[3][0][0] = ff_hevc_put_hevc_uni_pel_pixels8_8_msa;
+            c->put_hevc_qpel_uni[4][0][0] = ff_hevc_put_hevc_uni_pel_pixels12_8_msa;
+            c->put_hevc_qpel_uni[5][0][0] = ff_hevc_put_hevc_uni_pel_pixels16_8_msa;
+            c->put_hevc_qpel_uni[6][0][0] = ff_hevc_put_hevc_uni_pel_pixels24_8_msa;
+            c->put_hevc_qpel_uni[7][0][0] = ff_hevc_put_hevc_uni_pel_pixels32_8_msa;
+            c->put_hevc_qpel_uni[8][0][0] = ff_hevc_put_hevc_uni_pel_pixels48_8_msa;
+            c->put_hevc_qpel_uni[9][0][0] = ff_hevc_put_hevc_uni_pel_pixels64_8_msa;
+
+            c->put_hevc_qpel_uni[1][0][1] = ff_hevc_put_hevc_uni_qpel_h4_8_msa;
+            c->put_hevc_qpel_uni[3][0][1] = ff_hevc_put_hevc_uni_qpel_h8_8_msa;
+            c->put_hevc_qpel_uni[4][0][1] = ff_hevc_put_hevc_uni_qpel_h12_8_msa;
+            c->put_hevc_qpel_uni[5][0][1] = ff_hevc_put_hevc_uni_qpel_h16_8_msa;
+            c->put_hevc_qpel_uni[6][0][1] = ff_hevc_put_hevc_uni_qpel_h24_8_msa;
+            c->put_hevc_qpel_uni[7][0][1] = ff_hevc_put_hevc_uni_qpel_h32_8_msa;
+            c->put_hevc_qpel_uni[8][0][1] = ff_hevc_put_hevc_uni_qpel_h48_8_msa;
+            c->put_hevc_qpel_uni[9][0][1] = ff_hevc_put_hevc_uni_qpel_h64_8_msa;
+
+            c->put_hevc_qpel_uni[1][1][0] = ff_hevc_put_hevc_uni_qpel_v4_8_msa;
+            c->put_hevc_qpel_uni[3][1][0] = ff_hevc_put_hevc_uni_qpel_v8_8_msa;
+            c->put_hevc_qpel_uni[4][1][0] = ff_hevc_put_hevc_uni_qpel_v12_8_msa;
+            c->put_hevc_qpel_uni[5][1][0] = ff_hevc_put_hevc_uni_qpel_v16_8_msa;
+            c->put_hevc_qpel_uni[6][1][0] = ff_hevc_put_hevc_uni_qpel_v24_8_msa;
+            c->put_hevc_qpel_uni[7][1][0] = ff_hevc_put_hevc_uni_qpel_v32_8_msa;
+            c->put_hevc_qpel_uni[8][1][0] = ff_hevc_put_hevc_uni_qpel_v48_8_msa;
+            c->put_hevc_qpel_uni[9][1][0] = ff_hevc_put_hevc_uni_qpel_v64_8_msa;
+
+            c->put_hevc_qpel_uni[1][1][1] = ff_hevc_put_hevc_uni_qpel_hv4_8_msa;
+            c->put_hevc_qpel_uni[3][1][1] = ff_hevc_put_hevc_uni_qpel_hv8_8_msa;
+            c->put_hevc_qpel_uni[4][1][1] = ff_hevc_put_hevc_uni_qpel_hv12_8_msa;
+            c->put_hevc_qpel_uni[5][1][1] = ff_hevc_put_hevc_uni_qpel_hv16_8_msa;
+            c->put_hevc_qpel_uni[6][1][1] = ff_hevc_put_hevc_uni_qpel_hv24_8_msa;
+            c->put_hevc_qpel_uni[7][1][1] = ff_hevc_put_hevc_uni_qpel_hv32_8_msa;
+            c->put_hevc_qpel_uni[8][1][1] = ff_hevc_put_hevc_uni_qpel_hv48_8_msa;
+            c->put_hevc_qpel_uni[9][1][1] = ff_hevc_put_hevc_uni_qpel_hv64_8_msa;
+
+            c->put_hevc_epel_uni[3][0][0] = ff_hevc_put_hevc_uni_pel_pixels8_8_msa;
+            c->put_hevc_epel_uni[4][0][0] = ff_hevc_put_hevc_uni_pel_pixels12_8_msa;
+            c->put_hevc_epel_uni[5][0][0] = ff_hevc_put_hevc_uni_pel_pixels16_8_msa;
+            c->put_hevc_epel_uni[6][0][0] = ff_hevc_put_hevc_uni_pel_pixels24_8_msa;
+            c->put_hevc_epel_uni[7][0][0] = ff_hevc_put_hevc_uni_pel_pixels32_8_msa;
+
+            c->put_hevc_epel_uni[1][0][1] = ff_hevc_put_hevc_uni_epel_h4_8_msa;
+            c->put_hevc_epel_uni[2][0][1] = ff_hevc_put_hevc_uni_epel_h6_8_msa;
+            c->put_hevc_epel_uni[3][0][1] = ff_hevc_put_hevc_uni_epel_h8_8_msa;
+            c->put_hevc_epel_uni[4][0][1] = ff_hevc_put_hevc_uni_epel_h12_8_msa;
+            c->put_hevc_epel_uni[5][0][1] = ff_hevc_put_hevc_uni_epel_h16_8_msa;
+            c->put_hevc_epel_uni[6][0][1] = ff_hevc_put_hevc_uni_epel_h24_8_msa;
+            c->put_hevc_epel_uni[7][0][1] = ff_hevc_put_hevc_uni_epel_h32_8_msa;
+
+            c->put_hevc_epel_uni[1][1][0] = ff_hevc_put_hevc_uni_epel_v4_8_msa;
+            c->put_hevc_epel_uni[2][1][0] = ff_hevc_put_hevc_uni_epel_v6_8_msa;
+            c->put_hevc_epel_uni[3][1][0] = ff_hevc_put_hevc_uni_epel_v8_8_msa;
+            c->put_hevc_epel_uni[4][1][0] = ff_hevc_put_hevc_uni_epel_v12_8_msa;
+            c->put_hevc_epel_uni[5][1][0] = ff_hevc_put_hevc_uni_epel_v16_8_msa;
+            c->put_hevc_epel_uni[6][1][0] = ff_hevc_put_hevc_uni_epel_v24_8_msa;
+            c->put_hevc_epel_uni[7][1][0] = ff_hevc_put_hevc_uni_epel_v32_8_msa;
+
+            c->put_hevc_epel_uni[1][1][1] = ff_hevc_put_hevc_uni_epel_hv4_8_msa;
+            c->put_hevc_epel_uni[2][1][1] = ff_hevc_put_hevc_uni_epel_hv6_8_msa;
+            c->put_hevc_epel_uni[3][1][1] = ff_hevc_put_hevc_uni_epel_hv8_8_msa;
+            c->put_hevc_epel_uni[4][1][1] = ff_hevc_put_hevc_uni_epel_hv12_8_msa;
+            c->put_hevc_epel_uni[5][1][1] = ff_hevc_put_hevc_uni_epel_hv16_8_msa;
+            c->put_hevc_epel_uni[6][1][1] = ff_hevc_put_hevc_uni_epel_hv24_8_msa;
+            c->put_hevc_epel_uni[7][1][1] = ff_hevc_put_hevc_uni_epel_hv32_8_msa;
+
+            c->put_hevc_qpel_uni_w[1][0][0] =
+                ff_hevc_put_hevc_uni_w_pel_pixels4_8_msa;
+            c->put_hevc_qpel_uni_w[3][0][0] =
+                ff_hevc_put_hevc_uni_w_pel_pixels8_8_msa;
+            c->put_hevc_qpel_uni_w[4][0][0] =
+                ff_hevc_put_hevc_uni_w_pel_pixels12_8_msa;
+            c->put_hevc_qpel_uni_w[5][0][0] =
+                ff_hevc_put_hevc_uni_w_pel_pixels16_8_msa;
+            c->put_hevc_qpel_uni_w[6][0][0] =
+                ff_hevc_put_hevc_uni_w_pel_pixels24_8_msa;
+            c->put_hevc_qpel_uni_w[7][0][0] =
+                ff_hevc_put_hevc_uni_w_pel_pixels32_8_msa;
+            c->put_hevc_qpel_uni_w[8][0][0] =
+                ff_hevc_put_hevc_uni_w_pel_pixels48_8_msa;
+            c->put_hevc_qpel_uni_w[9][0][0] =
+                ff_hevc_put_hevc_uni_w_pel_pixels64_8_msa;
+
+            c->put_hevc_qpel_uni_w[1][0][1] = ff_hevc_put_hevc_uni_w_qpel_h4_8_msa;
+            c->put_hevc_qpel_uni_w[3][0][1] = ff_hevc_put_hevc_uni_w_qpel_h8_8_msa;
+            c->put_hevc_qpel_uni_w[4][0][1] = ff_hevc_put_hevc_uni_w_qpel_h12_8_msa;
+            c->put_hevc_qpel_uni_w[5][0][1] = ff_hevc_put_hevc_uni_w_qpel_h16_8_msa;
+            c->put_hevc_qpel_uni_w[6][0][1] = ff_hevc_put_hevc_uni_w_qpel_h24_8_msa;
+            c->put_hevc_qpel_uni_w[7][0][1] = ff_hevc_put_hevc_uni_w_qpel_h32_8_msa;
+            c->put_hevc_qpel_uni_w[8][0][1] = ff_hevc_put_hevc_uni_w_qpel_h48_8_msa;
+            c->put_hevc_qpel_uni_w[9][0][1] = ff_hevc_put_hevc_uni_w_qpel_h64_8_msa;
+
+            c->put_hevc_qpel_uni_w[1][1][0] = ff_hevc_put_hevc_uni_w_qpel_v4_8_msa;
+            c->put_hevc_qpel_uni_w[3][1][0] = ff_hevc_put_hevc_uni_w_qpel_v8_8_msa;
+            c->put_hevc_qpel_uni_w[4][1][0] = ff_hevc_put_hevc_uni_w_qpel_v12_8_msa;
+            c->put_hevc_qpel_uni_w[5][1][0] = ff_hevc_put_hevc_uni_w_qpel_v16_8_msa;
+            c->put_hevc_qpel_uni_w[6][1][0] = ff_hevc_put_hevc_uni_w_qpel_v24_8_msa;
+            c->put_hevc_qpel_uni_w[7][1][0] = ff_hevc_put_hevc_uni_w_qpel_v32_8_msa;
+            c->put_hevc_qpel_uni_w[8][1][0] = ff_hevc_put_hevc_uni_w_qpel_v48_8_msa;
+            c->put_hevc_qpel_uni_w[9][1][0] = ff_hevc_put_hevc_uni_w_qpel_v64_8_msa;
+
+            c->put_hevc_qpel_uni_w[1][1][1] = ff_hevc_put_hevc_uni_w_qpel_hv4_8_msa;
+            c->put_hevc_qpel_uni_w[3][1][1] = ff_hevc_put_hevc_uni_w_qpel_hv8_8_msa;
+            c->put_hevc_qpel_uni_w[4][1][1] =
+                ff_hevc_put_hevc_uni_w_qpel_hv12_8_msa;
+            c->put_hevc_qpel_uni_w[5][1][1] =
+                ff_hevc_put_hevc_uni_w_qpel_hv16_8_msa;
+            c->put_hevc_qpel_uni_w[6][1][1] =
+                ff_hevc_put_hevc_uni_w_qpel_hv24_8_msa;
+            c->put_hevc_qpel_uni_w[7][1][1] =
+                ff_hevc_put_hevc_uni_w_qpel_hv32_8_msa;
+            c->put_hevc_qpel_uni_w[8][1][1] =
+                ff_hevc_put_hevc_uni_w_qpel_hv48_8_msa;
+            c->put_hevc_qpel_uni_w[9][1][1] =
+                ff_hevc_put_hevc_uni_w_qpel_hv64_8_msa;
+
+            c->put_hevc_epel_uni_w[1][0][0] =
+                ff_hevc_put_hevc_uni_w_pel_pixels4_8_msa;
+            c->put_hevc_epel_uni_w[2][0][0] =
+                ff_hevc_put_hevc_uni_w_pel_pixels6_8_msa;
+            c->put_hevc_epel_uni_w[3][0][0] =
+                ff_hevc_put_hevc_uni_w_pel_pixels8_8_msa;
+            c->put_hevc_epel_uni_w[4][0][0] =
+                ff_hevc_put_hevc_uni_w_pel_pixels12_8_msa;
+            c->put_hevc_epel_uni_w[5][0][0] =
+                ff_hevc_put_hevc_uni_w_pel_pixels16_8_msa;
+            c->put_hevc_epel_uni_w[6][0][0] =
+                ff_hevc_put_hevc_uni_w_pel_pixels24_8_msa;
+            c->put_hevc_epel_uni_w[7][0][0] =
+                ff_hevc_put_hevc_uni_w_pel_pixels32_8_msa;
+
+            c->put_hevc_epel_uni_w[1][0][1] = ff_hevc_put_hevc_uni_w_epel_h4_8_msa;
+            c->put_hevc_epel_uni_w[2][0][1] = ff_hevc_put_hevc_uni_w_epel_h6_8_msa;
+            c->put_hevc_epel_uni_w[3][0][1] = ff_hevc_put_hevc_uni_w_epel_h8_8_msa;
+            c->put_hevc_epel_uni_w[4][0][1] = ff_hevc_put_hevc_uni_w_epel_h12_8_msa;
+            c->put_hevc_epel_uni_w[5][0][1] = ff_hevc_put_hevc_uni_w_epel_h16_8_msa;
+            c->put_hevc_epel_uni_w[6][0][1] = ff_hevc_put_hevc_uni_w_epel_h24_8_msa;
+            c->put_hevc_epel_uni_w[7][0][1] = ff_hevc_put_hevc_uni_w_epel_h32_8_msa;
+
+            c->put_hevc_epel_uni_w[1][1][0] = ff_hevc_put_hevc_uni_w_epel_v4_8_msa;
+            c->put_hevc_epel_uni_w[2][1][0] = ff_hevc_put_hevc_uni_w_epel_v6_8_msa;
+            c->put_hevc_epel_uni_w[3][1][0] = ff_hevc_put_hevc_uni_w_epel_v8_8_msa;
+            c->put_hevc_epel_uni_w[4][1][0] = ff_hevc_put_hevc_uni_w_epel_v12_8_msa;
+            c->put_hevc_epel_uni_w[5][1][0] = ff_hevc_put_hevc_uni_w_epel_v16_8_msa;
+            c->put_hevc_epel_uni_w[6][1][0] = ff_hevc_put_hevc_uni_w_epel_v24_8_msa;
+            c->put_hevc_epel_uni_w[7][1][0] = ff_hevc_put_hevc_uni_w_epel_v32_8_msa;
+
+            c->put_hevc_epel_uni_w[1][1][1] = ff_hevc_put_hevc_uni_w_epel_hv4_8_msa;
+            c->put_hevc_epel_uni_w[2][1][1] = ff_hevc_put_hevc_uni_w_epel_hv6_8_msa;
+            c->put_hevc_epel_uni_w[3][1][1] = ff_hevc_put_hevc_uni_w_epel_hv8_8_msa;
+            c->put_hevc_epel_uni_w[4][1][1] =
+                ff_hevc_put_hevc_uni_w_epel_hv12_8_msa;
+            c->put_hevc_epel_uni_w[5][1][1] =
+                ff_hevc_put_hevc_uni_w_epel_hv16_8_msa;
+            c->put_hevc_epel_uni_w[6][1][1] =
+                ff_hevc_put_hevc_uni_w_epel_hv24_8_msa;
+            c->put_hevc_epel_uni_w[7][1][1] =
+                ff_hevc_put_hevc_uni_w_epel_hv32_8_msa;
+
+            c->put_hevc_qpel_bi[1][0][0] = ff_hevc_put_hevc_bi_pel_pixels4_8_msa;
+            c->put_hevc_qpel_bi[3][0][0] = ff_hevc_put_hevc_bi_pel_pixels8_8_msa;
+            c->put_hevc_qpel_bi[4][0][0] = ff_hevc_put_hevc_bi_pel_pixels12_8_msa;
+            c->put_hevc_qpel_bi[5][0][0] = ff_hevc_put_hevc_bi_pel_pixels16_8_msa;
+            c->put_hevc_qpel_bi[6][0][0] = ff_hevc_put_hevc_bi_pel_pixels24_8_msa;
+            c->put_hevc_qpel_bi[7][0][0] = ff_hevc_put_hevc_bi_pel_pixels32_8_msa;
+            c->put_hevc_qpel_bi[8][0][0] = ff_hevc_put_hevc_bi_pel_pixels48_8_msa;
+            c->put_hevc_qpel_bi[9][0][0] = ff_hevc_put_hevc_bi_pel_pixels64_8_msa;
+
+            c->put_hevc_qpel_bi[1][0][1] = ff_hevc_put_hevc_bi_qpel_h4_8_msa;
+            c->put_hevc_qpel_bi[3][0][1] = ff_hevc_put_hevc_bi_qpel_h8_8_msa;
+            c->put_hevc_qpel_bi[4][0][1] = ff_hevc_put_hevc_bi_qpel_h12_8_msa;
+            c->put_hevc_qpel_bi[5][0][1] = ff_hevc_put_hevc_bi_qpel_h16_8_msa;
+            c->put_hevc_qpel_bi[6][0][1] = ff_hevc_put_hevc_bi_qpel_h24_8_msa;
+            c->put_hevc_qpel_bi[7][0][1] = ff_hevc_put_hevc_bi_qpel_h32_8_msa;
+            c->put_hevc_qpel_bi[8][0][1] = ff_hevc_put_hevc_bi_qpel_h48_8_msa;
+            c->put_hevc_qpel_bi[9][0][1] = ff_hevc_put_hevc_bi_qpel_h64_8_msa;
+
+            c->put_hevc_qpel_bi[1][1][0] = ff_hevc_put_hevc_bi_qpel_v4_8_msa;
+            c->put_hevc_qpel_bi[3][1][0] = ff_hevc_put_hevc_bi_qpel_v8_8_msa;
+            c->put_hevc_qpel_bi[4][1][0] = ff_hevc_put_hevc_bi_qpel_v12_8_msa;
+            c->put_hevc_qpel_bi[5][1][0] = ff_hevc_put_hevc_bi_qpel_v16_8_msa;
+            c->put_hevc_qpel_bi[6][1][0] = ff_hevc_put_hevc_bi_qpel_v24_8_msa;
+            c->put_hevc_qpel_bi[7][1][0] = ff_hevc_put_hevc_bi_qpel_v32_8_msa;
+            c->put_hevc_qpel_bi[8][1][0] = ff_hevc_put_hevc_bi_qpel_v48_8_msa;
+            c->put_hevc_qpel_bi[9][1][0] = ff_hevc_put_hevc_bi_qpel_v64_8_msa;
+
+            c->put_hevc_qpel_bi[1][1][1] = ff_hevc_put_hevc_bi_qpel_hv4_8_msa;
+            c->put_hevc_qpel_bi[3][1][1] = ff_hevc_put_hevc_bi_qpel_hv8_8_msa;
+            c->put_hevc_qpel_bi[4][1][1] = ff_hevc_put_hevc_bi_qpel_hv12_8_msa;
+            c->put_hevc_qpel_bi[5][1][1] = ff_hevc_put_hevc_bi_qpel_hv16_8_msa;
+            c->put_hevc_qpel_bi[6][1][1] = ff_hevc_put_hevc_bi_qpel_hv24_8_msa;
+            c->put_hevc_qpel_bi[7][1][1] = ff_hevc_put_hevc_bi_qpel_hv32_8_msa;
+            c->put_hevc_qpel_bi[8][1][1] = ff_hevc_put_hevc_bi_qpel_hv48_8_msa;
+            c->put_hevc_qpel_bi[9][1][1] = ff_hevc_put_hevc_bi_qpel_hv64_8_msa;
+
+            c->put_hevc_epel_bi[1][0][0] = ff_hevc_put_hevc_bi_pel_pixels4_8_msa;
+            c->put_hevc_epel_bi[2][0][0] = ff_hevc_put_hevc_bi_pel_pixels6_8_msa;
+            c->put_hevc_epel_bi[3][0][0] = ff_hevc_put_hevc_bi_pel_pixels8_8_msa;
+            c->put_hevc_epel_bi[4][0][0] = ff_hevc_put_hevc_bi_pel_pixels12_8_msa;
+            c->put_hevc_epel_bi[5][0][0] = ff_hevc_put_hevc_bi_pel_pixels16_8_msa;
+            c->put_hevc_epel_bi[6][0][0] = ff_hevc_put_hevc_bi_pel_pixels24_8_msa;
+            c->put_hevc_epel_bi[7][0][0] = ff_hevc_put_hevc_bi_pel_pixels32_8_msa;
+
+            c->put_hevc_epel_bi[1][0][1] = ff_hevc_put_hevc_bi_epel_h4_8_msa;
+            c->put_hevc_epel_bi[2][0][1] = ff_hevc_put_hevc_bi_epel_h6_8_msa;
+            c->put_hevc_epel_bi[3][0][1] = ff_hevc_put_hevc_bi_epel_h8_8_msa;
+            c->put_hevc_epel_bi[4][0][1] = ff_hevc_put_hevc_bi_epel_h12_8_msa;
+            c->put_hevc_epel_bi[5][0][1] = ff_hevc_put_hevc_bi_epel_h16_8_msa;
+            c->put_hevc_epel_bi[6][0][1] = ff_hevc_put_hevc_bi_epel_h24_8_msa;
+            c->put_hevc_epel_bi[7][0][1] = ff_hevc_put_hevc_bi_epel_h32_8_msa;
+
+            c->put_hevc_epel_bi[1][1][0] = ff_hevc_put_hevc_bi_epel_v4_8_msa;
+            c->put_hevc_epel_bi[2][1][0] = ff_hevc_put_hevc_bi_epel_v6_8_msa;
+            c->put_hevc_epel_bi[3][1][0] = ff_hevc_put_hevc_bi_epel_v8_8_msa;
+            c->put_hevc_epel_bi[4][1][0] = ff_hevc_put_hevc_bi_epel_v12_8_msa;
+            c->put_hevc_epel_bi[5][1][0] = ff_hevc_put_hevc_bi_epel_v16_8_msa;
+            c->put_hevc_epel_bi[6][1][0] = ff_hevc_put_hevc_bi_epel_v24_8_msa;
+            c->put_hevc_epel_bi[7][1][0] = ff_hevc_put_hevc_bi_epel_v32_8_msa;
+
+            c->put_hevc_epel_bi[1][1][1] = ff_hevc_put_hevc_bi_epel_hv4_8_msa;
+            c->put_hevc_epel_bi[2][1][1] = ff_hevc_put_hevc_bi_epel_hv6_8_msa;
+            c->put_hevc_epel_bi[3][1][1] = ff_hevc_put_hevc_bi_epel_hv8_8_msa;
+            c->put_hevc_epel_bi[4][1][1] = ff_hevc_put_hevc_bi_epel_hv12_8_msa;
+            c->put_hevc_epel_bi[5][1][1] = ff_hevc_put_hevc_bi_epel_hv16_8_msa;
+            c->put_hevc_epel_bi[6][1][1] = ff_hevc_put_hevc_bi_epel_hv24_8_msa;
+            c->put_hevc_epel_bi[7][1][1] = ff_hevc_put_hevc_bi_epel_hv32_8_msa;
+
+            c->put_hevc_qpel_bi_w[1][0][0] =
+                ff_hevc_put_hevc_bi_w_pel_pixels4_8_msa;
+            c->put_hevc_qpel_bi_w[3][0][0] =
+                ff_hevc_put_hevc_bi_w_pel_pixels8_8_msa;
+            c->put_hevc_qpel_bi_w[4][0][0] =
+                ff_hevc_put_hevc_bi_w_pel_pixels12_8_msa;
+            c->put_hevc_qpel_bi_w[5][0][0] =
+                ff_hevc_put_hevc_bi_w_pel_pixels16_8_msa;
+            c->put_hevc_qpel_bi_w[6][0][0] =
+                ff_hevc_put_hevc_bi_w_pel_pixels24_8_msa;
+            c->put_hevc_qpel_bi_w[7][0][0] =
+                ff_hevc_put_hevc_bi_w_pel_pixels32_8_msa;
+            c->put_hevc_qpel_bi_w[8][0][0] =
+                ff_hevc_put_hevc_bi_w_pel_pixels48_8_msa;
+            c->put_hevc_qpel_bi_w[9][0][0] =
+                ff_hevc_put_hevc_bi_w_pel_pixels64_8_msa;
+
+            c->put_hevc_qpel_bi_w[1][0][1] = ff_hevc_put_hevc_bi_w_qpel_h4_8_msa;
+            c->put_hevc_qpel_bi_w[3][0][1] = ff_hevc_put_hevc_bi_w_qpel_h8_8_msa;
+            c->put_hevc_qpel_bi_w[4][0][1] = ff_hevc_put_hevc_bi_w_qpel_h12_8_msa;
+            c->put_hevc_qpel_bi_w[5][0][1] = ff_hevc_put_hevc_bi_w_qpel_h16_8_msa;
+            c->put_hevc_qpel_bi_w[6][0][1] = ff_hevc_put_hevc_bi_w_qpel_h24_8_msa;
+            c->put_hevc_qpel_bi_w[7][0][1] = ff_hevc_put_hevc_bi_w_qpel_h32_8_msa;
+            c->put_hevc_qpel_bi_w[8][0][1] = ff_hevc_put_hevc_bi_w_qpel_h48_8_msa;
+            c->put_hevc_qpel_bi_w[9][0][1] = ff_hevc_put_hevc_bi_w_qpel_h64_8_msa;
+
+            c->put_hevc_qpel_bi_w[1][1][0] = ff_hevc_put_hevc_bi_w_qpel_v4_8_msa;
+            c->put_hevc_qpel_bi_w[3][1][0] = ff_hevc_put_hevc_bi_w_qpel_v8_8_msa;
+            c->put_hevc_qpel_bi_w[4][1][0] = ff_hevc_put_hevc_bi_w_qpel_v12_8_msa;
+            c->put_hevc_qpel_bi_w[5][1][0] = ff_hevc_put_hevc_bi_w_qpel_v16_8_msa;
+            c->put_hevc_qpel_bi_w[6][1][0] = ff_hevc_put_hevc_bi_w_qpel_v24_8_msa;
+            c->put_hevc_qpel_bi_w[7][1][0] = ff_hevc_put_hevc_bi_w_qpel_v32_8_msa;
+            c->put_hevc_qpel_bi_w[8][1][0] = ff_hevc_put_hevc_bi_w_qpel_v48_8_msa;
+            c->put_hevc_qpel_bi_w[9][1][0] = ff_hevc_put_hevc_bi_w_qpel_v64_8_msa;
+
+            c->put_hevc_qpel_bi_w[1][1][1] = ff_hevc_put_hevc_bi_w_qpel_hv4_8_msa;
+            c->put_hevc_qpel_bi_w[3][1][1] = ff_hevc_put_hevc_bi_w_qpel_hv8_8_msa;
+            c->put_hevc_qpel_bi_w[4][1][1] = ff_hevc_put_hevc_bi_w_qpel_hv12_8_msa;
+            c->put_hevc_qpel_bi_w[5][1][1] = ff_hevc_put_hevc_bi_w_qpel_hv16_8_msa;
+            c->put_hevc_qpel_bi_w[6][1][1] = ff_hevc_put_hevc_bi_w_qpel_hv24_8_msa;
+            c->put_hevc_qpel_bi_w[7][1][1] = ff_hevc_put_hevc_bi_w_qpel_hv32_8_msa;
+            c->put_hevc_qpel_bi_w[8][1][1] = ff_hevc_put_hevc_bi_w_qpel_hv48_8_msa;
+            c->put_hevc_qpel_bi_w[9][1][1] = ff_hevc_put_hevc_bi_w_qpel_hv64_8_msa;
+
+            c->put_hevc_epel_bi_w[1][0][0] =
+                ff_hevc_put_hevc_bi_w_pel_pixels4_8_msa;
+            c->put_hevc_epel_bi_w[2][0][0] =
+                ff_hevc_put_hevc_bi_w_pel_pixels6_8_msa;
+            c->put_hevc_epel_bi_w[3][0][0] =
+                ff_hevc_put_hevc_bi_w_pel_pixels8_8_msa;
+            c->put_hevc_epel_bi_w[4][0][0] =
+                ff_hevc_put_hevc_bi_w_pel_pixels12_8_msa;
+            c->put_hevc_epel_bi_w[5][0][0] =
+                ff_hevc_put_hevc_bi_w_pel_pixels16_8_msa;
+            c->put_hevc_epel_bi_w[6][0][0] =
+                ff_hevc_put_hevc_bi_w_pel_pixels24_8_msa;
+            c->put_hevc_epel_bi_w[7][0][0] =
+                ff_hevc_put_hevc_bi_w_pel_pixels32_8_msa;
+
+            c->put_hevc_epel_bi_w[1][0][1] = ff_hevc_put_hevc_bi_w_epel_h4_8_msa;
+            c->put_hevc_epel_bi_w[2][0][1] = ff_hevc_put_hevc_bi_w_epel_h6_8_msa;
+            c->put_hevc_epel_bi_w[3][0][1] = ff_hevc_put_hevc_bi_w_epel_h8_8_msa;
+            c->put_hevc_epel_bi_w[4][0][1] = ff_hevc_put_hevc_bi_w_epel_h12_8_msa;
+            c->put_hevc_epel_bi_w[5][0][1] = ff_hevc_put_hevc_bi_w_epel_h16_8_msa;
+            c->put_hevc_epel_bi_w[6][0][1] = ff_hevc_put_hevc_bi_w_epel_h24_8_msa;
+            c->put_hevc_epel_bi_w[7][0][1] = ff_hevc_put_hevc_bi_w_epel_h32_8_msa;
+
+            c->put_hevc_epel_bi_w[1][1][0] = ff_hevc_put_hevc_bi_w_epel_v4_8_msa;
+            c->put_hevc_epel_bi_w[2][1][0] = ff_hevc_put_hevc_bi_w_epel_v6_8_msa;
+            c->put_hevc_epel_bi_w[3][1][0] = ff_hevc_put_hevc_bi_w_epel_v8_8_msa;
+            c->put_hevc_epel_bi_w[4][1][0] = ff_hevc_put_hevc_bi_w_epel_v12_8_msa;
+            c->put_hevc_epel_bi_w[5][1][0] = ff_hevc_put_hevc_bi_w_epel_v16_8_msa;
+            c->put_hevc_epel_bi_w[6][1][0] = ff_hevc_put_hevc_bi_w_epel_v24_8_msa;
+            c->put_hevc_epel_bi_w[7][1][0] = ff_hevc_put_hevc_bi_w_epel_v32_8_msa;
+
+            c->put_hevc_epel_bi_w[1][1][1] = ff_hevc_put_hevc_bi_w_epel_hv4_8_msa;
+            c->put_hevc_epel_bi_w[2][1][1] = ff_hevc_put_hevc_bi_w_epel_hv6_8_msa;
+            c->put_hevc_epel_bi_w[3][1][1] = ff_hevc_put_hevc_bi_w_epel_hv8_8_msa;
+            c->put_hevc_epel_bi_w[4][1][1] = ff_hevc_put_hevc_bi_w_epel_hv12_8_msa;
+            c->put_hevc_epel_bi_w[5][1][1] = ff_hevc_put_hevc_bi_w_epel_hv16_8_msa;
+            c->put_hevc_epel_bi_w[6][1][1] = ff_hevc_put_hevc_bi_w_epel_hv24_8_msa;
+            c->put_hevc_epel_bi_w[7][1][1] = ff_hevc_put_hevc_bi_w_epel_hv32_8_msa;
+
+            c->sao_band_filter[0] =
+            c->sao_band_filter[1] =
+            c->sao_band_filter[2] =
+            c->sao_band_filter[3] =
+            c->sao_band_filter[4] = ff_hevc_sao_band_filter_0_8_msa;
+
+            c->sao_edge_filter[0] =
+            c->sao_edge_filter[1] =
+            c->sao_edge_filter[2] =
+            c->sao_edge_filter[3] =
+            c->sao_edge_filter[4] = ff_hevc_sao_edge_filter_8_msa;
+
+            c->hevc_h_loop_filter_luma = ff_hevc_loop_filter_luma_h_8_msa;
+            c->hevc_v_loop_filter_luma = ff_hevc_loop_filter_luma_v_8_msa;
+
+            c->hevc_h_loop_filter_chroma = ff_hevc_loop_filter_chroma_h_8_msa;
+            c->hevc_v_loop_filter_chroma = ff_hevc_loop_filter_chroma_v_8_msa;
+
+            c->hevc_h_loop_filter_luma_c = ff_hevc_loop_filter_luma_h_8_msa;
+            c->hevc_v_loop_filter_luma_c = ff_hevc_loop_filter_luma_v_8_msa;
+
+            c->hevc_h_loop_filter_chroma_c =
+                ff_hevc_loop_filter_chroma_h_8_msa;
+            c->hevc_v_loop_filter_chroma_c =
+                ff_hevc_loop_filter_chroma_v_8_msa;
+
+            c->idct[0] = ff_hevc_idct_4x4_msa;
+            c->idct[1] = ff_hevc_idct_8x8_msa;
+            c->idct[2] = ff_hevc_idct_16x16_msa;
+            c->idct[3] = ff_hevc_idct_32x32_msa;
+            c->idct_dc[0] = ff_hevc_idct_dc_4x4_msa;
+            c->idct_dc[1] = ff_hevc_idct_dc_8x8_msa;
+            c->idct_dc[2] = ff_hevc_idct_dc_16x16_msa;
+            c->idct_dc[3] = ff_hevc_idct_dc_32x32_msa;
+            c->add_residual[0] = ff_hevc_addblk_4x4_msa;
+            c->add_residual[1] = ff_hevc_addblk_8x8_msa;
+            c->add_residual[2] = ff_hevc_addblk_16x16_msa;
+            c->add_residual[3] = ff_hevc_addblk_32x32_msa;
+            c->transform_4x4_luma = ff_hevc_idct_luma_4x4_msa;
+        }
     }
 }
-#endif  // #if HAVE_MSA
-
-void ff_hevc_dsp_init_mips(HEVCDSPContext *c, const int bit_depth)
-{
-#if HAVE_MMI
-    hevc_dsp_init_mmi(c, bit_depth);
-#endif  // #if HAVE_MMI
-#if HAVE_MSA
-    hevc_dsp_init_msa(c, bit_depth);
-#endif  // #if HAVE_MSA
-}
diff --git a/libavcodec/mips/hevcpred_init_mips.c b/libavcodec/mips/hevcpred_init_mips.c
index e987698d66..f7ecb34dcc 100644
--- a/libavcodec/mips/hevcpred_init_mips.c
+++ b/libavcodec/mips/hevcpred_init_mips.c
@@ -18,32 +18,28 @@
  * 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/mips/hevcpred_mips.h"
 
-#if HAVE_MSA
-static av_cold void hevc_pred_init_msa(HEVCPredContext *c, const int bit_depth)
-{
-    if (8 == bit_depth) {
-        c->intra_pred[2] = ff_intra_pred_8_16x16_msa;
-        c->intra_pred[3] = ff_intra_pred_8_32x32_msa;
-        c->pred_planar[0] = ff_hevc_intra_pred_planar_0_msa;
-        c->pred_planar[1] = ff_hevc_intra_pred_planar_1_msa;
-        c->pred_planar[2] = ff_hevc_intra_pred_planar_2_msa;
-        c->pred_planar[3] = ff_hevc_intra_pred_planar_3_msa;
-        c->pred_dc = ff_hevc_intra_pred_dc_msa;
-        c->pred_angular[0] = ff_pred_intra_pred_angular_0_msa;
-        c->pred_angular[1] = ff_pred_intra_pred_angular_1_msa;
-        c->pred_angular[2] = ff_pred_intra_pred_angular_2_msa;
-        c->pred_angular[3] = ff_pred_intra_pred_angular_3_msa;
-    }
-}
-#endif  // #if HAVE_MSA
-
 void ff_hevc_pred_init_mips(HEVCPredContext *c, const int bit_depth)
 {
-#if HAVE_MSA
-    hevc_pred_init_msa(c, bit_depth);
-#endif  // #if HAVE_MSA
+    int cpu_flags = av_get_cpu_flags();
+
+    if (have_msa(cpu_flags)) {
+        if (bit_depth == 8) {
+            c->intra_pred[2] = ff_intra_pred_8_16x16_msa;
+            c->intra_pred[3] = ff_intra_pred_8_32x32_msa;
+            c->pred_planar[0] = ff_hevc_intra_pred_planar_0_msa;
+            c->pred_planar[1] = ff_hevc_intra_pred_planar_1_msa;
+            c->pred_planar[2] = ff_hevc_intra_pred_planar_2_msa;
+            c->pred_planar[3] = ff_hevc_intra_pred_planar_3_msa;
+            c->pred_dc = ff_hevc_intra_pred_dc_msa;
+            c->pred_angular[0] = ff_pred_intra_pred_angular_0_msa;
+            c->pred_angular[1] = ff_pred_intra_pred_angular_1_msa;
+            c->pred_angular[2] = ff_pred_intra_pred_angular_2_msa;
+            c->pred_angular[3] = ff_pred_intra_pred_angular_3_msa;
+        }
+    }
 }
diff --git a/libavcodec/mips/hpeldsp_init_mips.c b/libavcodec/mips/hpeldsp_init_mips.c
index d6f7a9793d..77cbe99fa4 100644
--- a/libavcodec/mips/hpeldsp_init_mips.c
+++ b/libavcodec/mips/hpeldsp_init_mips.c
@@ -19,104 +19,94 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/mips/cpu.h"
 #include "../hpeldsp.h"
 #include "libavcodec/mips/hpeldsp_mips.h"
 
-#if HAVE_MSA
-static void ff_hpeldsp_init_msa(HpelDSPContext *c, int flags)
-{
-    c->put_pixels_tab[0][0] = ff_put_pixels16_msa;
-    c->put_pixels_tab[0][1] = ff_put_pixels16_x2_msa;
-    c->put_pixels_tab[0][2] = ff_put_pixels16_y2_msa;
-    c->put_pixels_tab[0][3] = ff_put_pixels16_xy2_msa;
-
-    c->put_pixels_tab[1][0] = ff_put_pixels8_msa;
-    c->put_pixels_tab[1][1] = ff_put_pixels8_x2_msa;
-    c->put_pixels_tab[1][2] = ff_put_pixels8_y2_msa;
-    c->put_pixels_tab[1][3] = ff_put_pixels8_xy2_msa;
-
-    c->put_pixels_tab[2][1] = ff_put_pixels4_x2_msa;
-    c->put_pixels_tab[2][2] = ff_put_pixels4_y2_msa;
-    c->put_pixels_tab[2][3] = ff_put_pixels4_xy2_msa;
-
-    c->put_no_rnd_pixels_tab[0][0] = ff_put_pixels16_msa;
-    c->put_no_rnd_pixels_tab[0][1] = ff_put_no_rnd_pixels16_x2_msa;
-    c->put_no_rnd_pixels_tab[0][2] = ff_put_no_rnd_pixels16_y2_msa;
-    c->put_no_rnd_pixels_tab[0][3] = ff_put_no_rnd_pixels16_xy2_msa;
-
-    c->put_no_rnd_pixels_tab[1][0] = ff_put_pixels8_msa;
-    c->put_no_rnd_pixels_tab[1][1] = ff_put_no_rnd_pixels8_x2_msa;
-    c->put_no_rnd_pixels_tab[1][2] = ff_put_no_rnd_pixels8_y2_msa;
-    c->put_no_rnd_pixels_tab[1][3] = ff_put_no_rnd_pixels8_xy2_msa;
-
-    c->avg_pixels_tab[0][0] = ff_avg_pixels16_msa;
-    c->avg_pixels_tab[0][1] = ff_avg_pixels16_x2_msa;
-    c->avg_pixels_tab[0][2] = ff_avg_pixels16_y2_msa;
-    c->avg_pixels_tab[0][3] = ff_avg_pixels16_xy2_msa;
-
-    c->avg_pixels_tab[1][0] = ff_avg_pixels8_msa;
-    c->avg_pixels_tab[1][1] = ff_avg_pixels8_x2_msa;
-    c->avg_pixels_tab[1][2] = ff_avg_pixels8_y2_msa;
-    c->avg_pixels_tab[1][3] = ff_avg_pixels8_xy2_msa;
-
-    c->avg_pixels_tab[2][0] = ff_avg_pixels4_msa;
-    c->avg_pixels_tab[2][1] = ff_avg_pixels4_x2_msa;
-    c->avg_pixels_tab[2][2] = ff_avg_pixels4_y2_msa;
-    c->avg_pixels_tab[2][3] = ff_avg_pixels4_xy2_msa;
-}
-#endif  // #if HAVE_MSA
-
-#if HAVE_MMI
-static void ff_hpeldsp_init_mmi(HpelDSPContext *c, int flags)
-{
-    c->put_pixels_tab[0][0] = ff_put_pixels16_8_mmi;
-    c->put_pixels_tab[0][1] = ff_put_pixels16_x2_8_mmi;
-    c->put_pixels_tab[0][2] = ff_put_pixels16_y2_8_mmi;
-    c->put_pixels_tab[0][3] = ff_put_pixels16_xy2_8_mmi;
-
-    c->put_pixels_tab[1][0] = ff_put_pixels8_8_mmi;
-    c->put_pixels_tab[1][1] = ff_put_pixels8_x2_8_mmi;
-    c->put_pixels_tab[1][2] = ff_put_pixels8_y2_8_mmi;
-    c->put_pixels_tab[1][3] = ff_put_pixels8_xy2_8_mmi;
-
-    c->put_pixels_tab[2][0] = ff_put_pixels4_8_mmi;
-    c->put_pixels_tab[2][1] = ff_put_pixels4_x2_8_mmi;
-    c->put_pixels_tab[2][2] = ff_put_pixels4_y2_8_mmi;
-    c->put_pixels_tab[2][3] = ff_put_pixels4_xy2_8_mmi;
-
-    c->put_no_rnd_pixels_tab[0][0] = ff_put_pixels16_8_mmi;
-    c->put_no_rnd_pixels_tab[0][1] = ff_put_no_rnd_pixels16_x2_8_mmi;
-    c->put_no_rnd_pixels_tab[0][2] = ff_put_no_rnd_pixels16_y2_8_mmi;
-    c->put_no_rnd_pixels_tab[0][3] = ff_put_no_rnd_pixels16_xy2_8_mmi;
-
-    c->put_no_rnd_pixels_tab[1][0] = ff_put_pixels8_8_mmi;
-    c->put_no_rnd_pixels_tab[1][1] = ff_put_no_rnd_pixels8_x2_8_mmi;
-    c->put_no_rnd_pixels_tab[1][2] = ff_put_no_rnd_pixels8_y2_8_mmi;
-    c->put_no_rnd_pixels_tab[1][3] = ff_put_no_rnd_pixels8_xy2_8_mmi;
-
-    c->avg_pixels_tab[0][0] = ff_avg_pixels16_8_mmi;
-    c->avg_pixels_tab[0][1] = ff_avg_pixels16_x2_8_mmi;
-    c->avg_pixels_tab[0][2] = ff_avg_pixels16_y2_8_mmi;
-    c->avg_pixels_tab[0][3] = ff_avg_pixels16_xy2_8_mmi;
-
-    c->avg_pixels_tab[1][0] = ff_avg_pixels8_8_mmi;
-    c->avg_pixels_tab[1][1] = ff_avg_pixels8_x2_8_mmi;
-    c->avg_pixels_tab[1][2] = ff_avg_pixels8_y2_8_mmi;
-    c->avg_pixels_tab[1][3] = ff_avg_pixels8_xy2_8_mmi;
-
-    c->avg_pixels_tab[2][0] = ff_avg_pixels4_8_mmi;
-    c->avg_pixels_tab[2][1] = ff_avg_pixels4_x2_8_mmi;
-    c->avg_pixels_tab[2][2] = ff_avg_pixels4_y2_8_mmi;
-    c->avg_pixels_tab[2][3] = ff_avg_pixels4_xy2_8_mmi;
-}
-#endif  // #if HAVE_MMI
-
 void ff_hpeldsp_init_mips(HpelDSPContext *c, int flags)
 {
-#if HAVE_MMI
-    ff_hpeldsp_init_mmi(c, flags);
-#endif  // #if HAVE_MMI
-#if HAVE_MSA
-    ff_hpeldsp_init_msa(c, flags);
-#endif  // #if HAVE_MSA
+    int cpu_flags = av_get_cpu_flags();
+
+    if (have_mmi(cpu_flags)) {
+        c->put_pixels_tab[0][0] = ff_put_pixels16_8_mmi;
+        c->put_pixels_tab[0][1] = ff_put_pixels16_x2_8_mmi;
+        c->put_pixels_tab[0][2] = ff_put_pixels16_y2_8_mmi;
+        c->put_pixels_tab[0][3] = ff_put_pixels16_xy2_8_mmi;
+
+        c->put_pixels_tab[1][0] = ff_put_pixels8_8_mmi;
+        c->put_pixels_tab[1][1] = ff_put_pixels8_x2_8_mmi;
+        c->put_pixels_tab[1][2] = ff_put_pixels8_y2_8_mmi;
+        c->put_pixels_tab[1][3] = ff_put_pixels8_xy2_8_mmi;
+
+        c->put_pixels_tab[2][0] = ff_put_pixels4_8_mmi;
+        c->put_pixels_tab[2][1] = ff_put_pixels4_x2_8_mmi;
+        c->put_pixels_tab[2][2] = ff_put_pixels4_y2_8_mmi;
+        c->put_pixels_tab[2][3] = ff_put_pixels4_xy2_8_mmi;
+
+        c->put_no_rnd_pixels_tab[0][0] = ff_put_pixels16_8_mmi;
+        c->put_no_rnd_pixels_tab[0][1] = ff_put_no_rnd_pixels16_x2_8_mmi;
+        c->put_no_rnd_pixels_tab[0][2] = ff_put_no_rnd_pixels16_y2_8_mmi;
+        c->put_no_rnd_pixels_tab[0][3] = ff_put_no_rnd_pixels16_xy2_8_mmi;
+
+        c->put_no_rnd_pixels_tab[1][0] = ff_put_pixels8_8_mmi;
+        c->put_no_rnd_pixels_tab[1][1] = ff_put_no_rnd_pixels8_x2_8_mmi;
+        c->put_no_rnd_pixels_tab[1][2] = ff_put_no_rnd_pixels8_y2_8_mmi;
+        c->put_no_rnd_pixels_tab[1][3] = ff_put_no_rnd_pixels8_xy2_8_mmi;
+
+        c->avg_pixels_tab[0][0] = ff_avg_pixels16_8_mmi;
+        c->avg_pixels_tab[0][1] = ff_avg_pixels16_x2_8_mmi;
+        c->avg_pixels_tab[0][2] = ff_avg_pixels16_y2_8_mmi;
+        c->avg_pixels_tab[0][3] = ff_avg_pixels16_xy2_8_mmi;
+
+        c->avg_pixels_tab[1][0] = ff_avg_pixels8_8_mmi;
+        c->avg_pixels_tab[1][1] = ff_avg_pixels8_x2_8_mmi;
+        c->avg_pixels_tab[1][2] = ff_avg_pixels8_y2_8_mmi;
+        c->avg_pixels_tab[1][3] = ff_avg_pixels8_xy2_8_mmi;
+
+        c->avg_pixels_tab[2][0] = ff_avg_pixels4_8_mmi;
+        c->avg_pixels_tab[2][1] = ff_avg_pixels4_x2_8_mmi;
+        c->avg_pixels_tab[2][2] = ff_avg_pixels4_y2_8_mmi;
+        c->avg_pixels_tab[2][3] = ff_avg_pixels4_xy2_8_mmi;
+    }
+
+    if (have_msa(cpu_flags)) {
+        c->put_pixels_tab[0][0] = ff_put_pixels16_msa;
+        c->put_pixels_tab[0][1] = ff_put_pixels16_x2_msa;
+        c->put_pixels_tab[0][2] = ff_put_pixels16_y2_msa;
+        c->put_pixels_tab[0][3] = ff_put_pixels16_xy2_msa;
+
+        c->put_pixels_tab[1][0] = ff_put_pixels8_msa;
+        c->put_pixels_tab[1][1] = ff_put_pixels8_x2_msa;
+        c->put_pixels_tab[1][2] = ff_put_pixels8_y2_msa;
+        c->put_pixels_tab[1][3] = ff_put_pixels8_xy2_msa;
+
+        c->put_pixels_tab[2][1] = ff_put_pixels4_x2_msa;
+        c->put_pixels_tab[2][2] = ff_put_pixels4_y2_msa;
+        c->put_pixels_tab[2][3] = ff_put_pixels4_xy2_msa;
+
+        c->put_no_rnd_pixels_tab[0][0] = ff_put_pixels16_msa;
+        c->put_no_rnd_pixels_tab[0][1] = ff_put_no_rnd_pixels16_x2_msa;
+        c->put_no_rnd_pixels_tab[0][2] = ff_put_no_rnd_pixels16_y2_msa;
+        c->put_no_rnd_pixels_tab[0][3] = ff_put_no_rnd_pixels16_xy2_msa;
+
+        c->put_no_rnd_pixels_tab[1][0] = ff_put_pixels8_msa;
+        c->put_no_rnd_pixels_tab[1][1] = ff_put_no_rnd_pixels8_x2_msa;
+        c->put_no_rnd_pixels_tab[1][2] = ff_put_no_rnd_pixels8_y2_msa;
+        c->put_no_rnd_pixels_tab[1][3] = ff_put_no_rnd_pixels8_xy2_msa;
+
+        c->avg_pixels_tab[0][0] = ff_avg_pixels16_msa;
+        c->avg_pixels_tab[0][1] = ff_avg_pixels16_x2_msa;
+        c->avg_pixels_tab[0][2] = ff_avg_pixels16_y2_msa;
+        c->avg_pixels_tab[0][3] = ff_avg_pixels16_xy2_msa;
+
+        c->avg_pixels_tab[1][0] = ff_avg_pixels8_msa;
+        c->avg_pixels_tab[1][1] = ff_avg_pixels8_x2_msa;
+        c->avg_pixels_tab[1][2] = ff_avg_pixels8_y2_msa;
+        c->avg_pixels_tab[1][3] = ff_avg_pixels8_xy2_msa;
+
+        c->avg_pixels_tab[2][0] = ff_avg_pixels4_msa;
+        c->avg_pixels_tab[2][1] = ff_avg_pixels4_x2_msa;
+        c->avg_pixels_tab[2][2] = ff_avg_pixels4_y2_msa;
+        c->avg_pixels_tab[2][3] = ff_avg_pixels4_xy2_msa;
+    }
 }
diff --git a/libavcodec/mips/idctdsp_init_mips.c b/libavcodec/mips/idctdsp_init_mips.c
index 85b76ca478..23efd9ed58 100644
--- a/libavcodec/mips/idctdsp_init_mips.c
+++ b/libavcodec/mips/idctdsp_init_mips.c
@@ -19,56 +19,44 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/mips/cpu.h"
 #include "idctdsp_mips.h"
 #include "xvididct_mips.h"
 
-#if HAVE_MSA
-static av_cold void idctdsp_init_msa(IDCTDSPContext *c, AVCodecContext *avctx,
-                                     unsigned high_bit_depth)
+av_cold void ff_idctdsp_init_mips(IDCTDSPContext *c, AVCodecContext *avctx,
+                          unsigned high_bit_depth)
 {
-    if ((avctx->lowres != 1) && (avctx->lowres != 2) && (avctx->lowres != 3) &&
-        (avctx->bits_per_raw_sample != 10) &&
-        (avctx->bits_per_raw_sample != 12) &&
-        (avctx->idct_algo == FF_IDCT_AUTO)) {
-                c->idct_put = ff_simple_idct_put_msa;
-                c->idct_add = ff_simple_idct_add_msa;
-                c->idct = ff_simple_idct_msa;
-                c->perm_type = FF_IDCT_PERM_NONE;
-    }
+    int cpu_flags = av_get_cpu_flags();
 
-    c->put_pixels_clamped = ff_put_pixels_clamped_msa;
-    c->put_signed_pixels_clamped = ff_put_signed_pixels_clamped_msa;
-    c->add_pixels_clamped = ff_add_pixels_clamped_msa;
-}
-#endif  // #if HAVE_MSA
+    if (have_mmi(cpu_flags)) {
+        if ((avctx->lowres != 1) && (avctx->lowres != 2) && (avctx->lowres != 3) &&
+            (avctx->bits_per_raw_sample != 10) &&
+            (avctx->bits_per_raw_sample != 12) &&
+            ((avctx->idct_algo == FF_IDCT_AUTO) || (avctx->idct_algo == FF_IDCT_SIMPLE))) {
+                    c->idct_put = ff_simple_idct_put_8_mmi;
+                    c->idct_add = ff_simple_idct_add_8_mmi;
+                    c->idct = ff_simple_idct_8_mmi;
+                    c->perm_type = FF_IDCT_PERM_NONE;
+        }
 
-#if HAVE_MMI
-static av_cold void idctdsp_init_mmi(IDCTDSPContext *c, AVCodecContext *avctx,
-        unsigned high_bit_depth)
-{
-    if ((avctx->lowres != 1) && (avctx->lowres != 2) && (avctx->lowres != 3) &&
-        (avctx->bits_per_raw_sample != 10) &&
-        (avctx->bits_per_raw_sample != 12) &&
-        ((avctx->idct_algo == FF_IDCT_AUTO) || (avctx->idct_algo == FF_IDCT_SIMPLE))) {
-                c->idct_put = ff_simple_idct_put_8_mmi;
-                c->idct_add = ff_simple_idct_add_8_mmi;
-                c->idct = ff_simple_idct_8_mmi;
-                c->perm_type = FF_IDCT_PERM_NONE;
+        c->put_pixels_clamped = ff_put_pixels_clamped_mmi;
+        c->add_pixels_clamped = ff_add_pixels_clamped_mmi;
+        c->put_signed_pixels_clamped = ff_put_signed_pixels_clamped_mmi;
     }
 
-    c->put_pixels_clamped = ff_put_pixels_clamped_mmi;
-    c->add_pixels_clamped = ff_add_pixels_clamped_mmi;
-    c->put_signed_pixels_clamped = ff_put_signed_pixels_clamped_mmi;
-}
-#endif /* HAVE_MMI */
+    if (have_msa(cpu_flags)) {
+        if ((avctx->lowres != 1) && (avctx->lowres != 2) && (avctx->lowres != 3) &&
+            (avctx->bits_per_raw_sample != 10) &&
+            (avctx->bits_per_raw_sample != 12) &&
+            (avctx->idct_algo == FF_IDCT_AUTO)) {
+                    c->idct_put = ff_simple_idct_put_msa;
+                    c->idct_add = ff_simple_idct_add_msa;
+                    c->idct = ff_simple_idct_msa;
+                    c->perm_type = FF_IDCT_PERM_NONE;
+        }
 
-av_cold void ff_idctdsp_init_mips(IDCTDSPContext *c, AVCodecContext *avctx,
-                          unsigned high_bit_depth)
-{
-#if HAVE_MMI
-    idctdsp_init_mmi(c, avctx, high_bit_depth);
-#endif /* HAVE_MMI */
-#if HAVE_MSA
-    idctdsp_init_msa(c, avctx, high_bit_depth);
-#endif  // #if HAVE_MSA
+        c->put_pixels_clamped = ff_put_pixels_clamped_msa;
+        c->put_signed_pixels_clamped = ff_put_signed_pixels_clamped_msa;
+        c->add_pixels_clamped = ff_add_pixels_clamped_msa;
+    }
 }
diff --git a/libavcodec/mips/me_cmp_init_mips.c b/libavcodec/mips/me_cmp_init_mips.c
index 219a0dc00c..e3e33b8e5e 100644
--- a/libavcodec/mips/me_cmp_init_mips.c
+++ b/libavcodec/mips/me_cmp_init_mips.c
@@ -18,39 +18,35 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/mips/cpu.h"
 #include "me_cmp_mips.h"
 
-#if HAVE_MSA
-static av_cold void me_cmp_msa(MECmpContext *c, AVCodecContext *avctx)
+av_cold void ff_me_cmp_init_mips(MECmpContext *c, AVCodecContext *avctx)
 {
+    int cpu_flags = av_get_cpu_flags();
+
+    if (have_msa(cpu_flags)) {
 #if BIT_DEPTH == 8
-    c->pix_abs[0][0] = ff_pix_abs16_msa;
-    c->pix_abs[0][1] = ff_pix_abs16_x2_msa;
-    c->pix_abs[0][2] = ff_pix_abs16_y2_msa;
-    c->pix_abs[0][3] = ff_pix_abs16_xy2_msa;
-    c->pix_abs[1][0] = ff_pix_abs8_msa;
-    c->pix_abs[1][1] = ff_pix_abs8_x2_msa;
-    c->pix_abs[1][2] = ff_pix_abs8_y2_msa;
-    c->pix_abs[1][3] = ff_pix_abs8_xy2_msa;
+        c->pix_abs[0][0] = ff_pix_abs16_msa;
+        c->pix_abs[0][1] = ff_pix_abs16_x2_msa;
+        c->pix_abs[0][2] = ff_pix_abs16_y2_msa;
+        c->pix_abs[0][3] = ff_pix_abs16_xy2_msa;
+        c->pix_abs[1][0] = ff_pix_abs8_msa;
+        c->pix_abs[1][1] = ff_pix_abs8_x2_msa;
+        c->pix_abs[1][2] = ff_pix_abs8_y2_msa;
+        c->pix_abs[1][3] = ff_pix_abs8_xy2_msa;
 
-    c->hadamard8_diff[0] = ff_hadamard8_diff16_msa;
-    c->hadamard8_diff[1] = ff_hadamard8_diff8x8_msa;
+        c->hadamard8_diff[0] = ff_hadamard8_diff16_msa;
+        c->hadamard8_diff[1] = ff_hadamard8_diff8x8_msa;
 
-    c->hadamard8_diff[4] = ff_hadamard8_intra16_msa;
-    c->hadamard8_diff[5] = ff_hadamard8_intra8x8_msa;
+        c->hadamard8_diff[4] = ff_hadamard8_intra16_msa;
+        c->hadamard8_diff[5] = ff_hadamard8_intra8x8_msa;
 
-    c->sad[0] = ff_pix_abs16_msa;
-    c->sad[1] = ff_pix_abs8_msa;
-    c->sse[0] = ff_sse16_msa;
-    c->sse[1] = ff_sse8_msa;
-    c->sse[2] = ff_sse4_msa;
+        c->sad[0] = ff_pix_abs16_msa;
+        c->sad[1] = ff_pix_abs8_msa;
+        c->sse[0] = ff_sse16_msa;
+        c->sse[1] = ff_sse8_msa;
+        c->sse[2] = ff_sse4_msa;
 #endif
-}
-#endif  // #if HAVE_MSA
-
-av_cold void ff_me_cmp_init_mips(MECmpContext *c, AVCodecContext *avctx)
-{
-#if HAVE_MSA
-    me_cmp_msa(c, avctx);
-#endif  // #if HAVE_MSA
+    }
 }
diff --git a/libavcodec/mips/mpegvideo_init_mips.c b/libavcodec/mips/mpegvideo_init_mips.c
index be77308140..bfda90bbcc 100644
--- a/libavcodec/mips/mpegvideo_init_mips.c
+++ b/libavcodec/mips/mpegvideo_init_mips.c
@@ -18,41 +18,31 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/mips/cpu.h"
 #include "h263dsp_mips.h"
 #include "mpegvideo_mips.h"
 
-#if HAVE_MSA
-static av_cold void dct_unquantize_init_msa(MpegEncContext *s)
+av_cold void ff_mpv_common_init_mips(MpegEncContext *s)
 {
-    s->dct_unquantize_h263_intra = ff_dct_unquantize_h263_intra_msa;
-    s->dct_unquantize_h263_inter = ff_dct_unquantize_h263_inter_msa;
-    if (!s->q_scale_type)
-        s->dct_unquantize_mpeg2_inter = ff_dct_unquantize_mpeg2_inter_msa;
-}
-#endif  // #if HAVE_MSA
+    int cpu_flags = av_get_cpu_flags();
 
-#if HAVE_MMI
-static av_cold void dct_unquantize_init_mmi(MpegEncContext *s)
-{
-    s->dct_unquantize_h263_intra = ff_dct_unquantize_h263_intra_mmi;
-    s->dct_unquantize_h263_inter = ff_dct_unquantize_h263_inter_mmi;
-    s->dct_unquantize_mpeg1_intra = ff_dct_unquantize_mpeg1_intra_mmi;
-    s->dct_unquantize_mpeg1_inter = ff_dct_unquantize_mpeg1_inter_mmi;
+    if (have_mmi(cpu_flags)) {
+        s->dct_unquantize_h263_intra = ff_dct_unquantize_h263_intra_mmi;
+        s->dct_unquantize_h263_inter = ff_dct_unquantize_h263_inter_mmi;
+        s->dct_unquantize_mpeg1_intra = ff_dct_unquantize_mpeg1_intra_mmi;
+        s->dct_unquantize_mpeg1_inter = ff_dct_unquantize_mpeg1_inter_mmi;
 
-    if (!(s->avctx->flags & AV_CODEC_FLAG_BITEXACT))
-        if (!s->q_scale_type)
-            s->dct_unquantize_mpeg2_intra = ff_dct_unquantize_mpeg2_intra_mmi;
+        if (!(s->avctx->flags & AV_CODEC_FLAG_BITEXACT))
+            if (!s->q_scale_type)
+                s->dct_unquantize_mpeg2_intra = ff_dct_unquantize_mpeg2_intra_mmi;
 
-    s->denoise_dct= ff_denoise_dct_mmi;
-}
-#endif /* HAVE_MMI */
+        s->denoise_dct= ff_denoise_dct_mmi;
+    }
 
-av_cold void ff_mpv_common_init_mips(MpegEncContext *s)
-{
-#if HAVE_MMI
-    dct_unquantize_init_mmi(s);
-#endif /* HAVE_MMI */
-#if HAVE_MSA
-    dct_unquantize_init_msa(s);
-#endif  // #if HAVE_MSA
+    if (have_msa(cpu_flags)) {
+        s->dct_unquantize_h263_intra = ff_dct_unquantize_h263_intra_msa;
+        s->dct_unquantize_h263_inter = ff_dct_unquantize_h263_inter_msa;
+        if (!s->q_scale_type)
+            s->dct_unquantize_mpeg2_inter = ff_dct_unquantize_mpeg2_inter_msa;
+    }
 }
diff --git a/libavcodec/mips/mpegvideoencdsp_init_mips.c b/libavcodec/mips/mpegvideoencdsp_init_mips.c
index 9bfe94e4cd..71831a61ac 100644
--- a/libavcodec/mips/mpegvideoencdsp_init_mips.c
+++ b/libavcodec/mips/mpegvideoencdsp_init_mips.c
@@ -18,23 +18,18 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/mips/cpu.h"
 #include "libavcodec/bit_depth_template.c"
 #include "h263dsp_mips.h"
 
-#if HAVE_MSA
-static av_cold void mpegvideoencdsp_init_msa(MpegvideoEncDSPContext *c,
-                                             AVCodecContext *avctx)
-{
-#if BIT_DEPTH == 8
-    c->pix_sum = ff_pix_sum_msa;
-#endif
-}
-#endif  // #if HAVE_MSA
-
 av_cold void ff_mpegvideoencdsp_init_mips(MpegvideoEncDSPContext *c,
                                           AVCodecContext *avctx)
 {
-#if HAVE_MSA
-    mpegvideoencdsp_init_msa(c, avctx);
-#endif  // #if HAVE_MSA
+    int cpu_flags = av_get_cpu_flags();
+
+    if (have_msa(cpu_flags)) {
+#if BIT_DEPTH == 8
+        c->pix_sum = ff_pix_sum_msa;
+#endif
+    }
 }
diff --git a/libavcodec/mips/pixblockdsp_init_mips.c b/libavcodec/mips/pixblockdsp_init_mips.c
index fd0238d79b..2e2d70953b 100644
--- a/libavcodec/mips/pixblockdsp_init_mips.c
+++ b/libavcodec/mips/pixblockdsp_init_mips.c
@@ -19,51 +19,38 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/mips/cpu.h"
 #include "pixblockdsp_mips.h"
 
-#if HAVE_MSA
-static av_cold void pixblockdsp_init_msa(PixblockDSPContext *c,
-                                         AVCodecContext *avctx,
-                                         unsigned high_bit_depth)
+void ff_pixblockdsp_init_mips(PixblockDSPContext *c, AVCodecContext *avctx,
+                              unsigned high_bit_depth)
 {
-    c->diff_pixels = ff_diff_pixels_msa;
+    int cpu_flags = av_get_cpu_flags();
+
+    if (have_mmi(cpu_flags)) {
+        c->diff_pixels = ff_diff_pixels_mmi;
 
-    switch (avctx->bits_per_raw_sample) {
-    case 9:
-    case 10:
-    case 12:
-    case 14:
-        c->get_pixels = ff_get_pixels_16_msa;
-        break;
-    default:
-        if (avctx->bits_per_raw_sample <= 8 || avctx->codec_type !=
-            AVMEDIA_TYPE_VIDEO) {
-            c->get_pixels = ff_get_pixels_8_msa;
+        if (!high_bit_depth || avctx->codec_type != AVMEDIA_TYPE_VIDEO) {
+            c->get_pixels = ff_get_pixels_8_mmi;
         }
-        break;
     }
-}
-#endif  // #if HAVE_MSA
 
-#if HAVE_MMI
-static av_cold void pixblockdsp_init_mmi(PixblockDSPContext *c,
-        AVCodecContext *avctx, unsigned high_bit_depth)
-{
-    c->diff_pixels = ff_diff_pixels_mmi;
+    if (have_msa(cpu_flags)) {
+        c->diff_pixels = ff_diff_pixels_msa;
 
-    if (!high_bit_depth || avctx->codec_type != AVMEDIA_TYPE_VIDEO) {
-        c->get_pixels = ff_get_pixels_8_mmi;
+        switch (avctx->bits_per_raw_sample) {
+        case 9:
+        case 10:
+        case 12:
+        case 14:
+            c->get_pixels = ff_get_pixels_16_msa;
+            break;
+        default:
+            if (avctx->bits_per_raw_sample <= 8 || avctx->codec_type !=
+                AVMEDIA_TYPE_VIDEO) {
+                c->get_pixels = ff_get_pixels_8_msa;
+            }
+            break;
+        }
     }
 }
-#endif /* HAVE_MMI */
-
-void ff_pixblockdsp_init_mips(PixblockDSPContext *c, AVCodecContext *avctx,
-                              unsigned high_bit_depth)
-{
-#if HAVE_MMI
-    pixblockdsp_init_mmi(c, avctx, high_bit_depth);
-#endif /* HAVE_MMI */
-#if HAVE_MSA
-    pixblockdsp_init_msa(c, avctx, high_bit_depth);
-#endif  // #if HAVE_MSA
-}
diff --git a/libavcodec/mips/qpeldsp_init_mips.c b/libavcodec/mips/qpeldsp_init_mips.c
index 140e8f89c9..cccf9d4429 100644
--- a/libavcodec/mips/qpeldsp_init_mips.c
+++ b/libavcodec/mips/qpeldsp_init_mips.c
@@ -18,150 +18,146 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/mips/cpu.h"
 #include "qpeldsp_mips.h"
 
-#if HAVE_MSA
-static av_cold void qpeldsp_init_msa(QpelDSPContext *c)
+void ff_qpeldsp_init_mips(QpelDSPContext *c)
 {
-    c->put_qpel_pixels_tab[0][0] = ff_copy_16x16_msa;
-    c->put_qpel_pixels_tab[0][1] = ff_horiz_mc_qpel_aver_src0_16width_msa;
-    c->put_qpel_pixels_tab[0][2] = ff_horiz_mc_qpel_16width_msa;
-    c->put_qpel_pixels_tab[0][3] = ff_horiz_mc_qpel_aver_src1_16width_msa;
-    c->put_qpel_pixels_tab[0][4] = ff_vert_mc_qpel_aver_src0_16x16_msa;
-    c->put_qpel_pixels_tab[0][5] = ff_hv_mc_qpel_aver_hv_src00_16x16_msa;
-    c->put_qpel_pixels_tab[0][6] = ff_hv_mc_qpel_aver_v_src0_16x16_msa;
-    c->put_qpel_pixels_tab[0][7] = ff_hv_mc_qpel_aver_hv_src10_16x16_msa;
-    c->put_qpel_pixels_tab[0][8] = ff_vert_mc_qpel_16x16_msa;
-    c->put_qpel_pixels_tab[0][9] = ff_hv_mc_qpel_aver_h_src0_16x16_msa;
-    c->put_qpel_pixels_tab[0][10] = ff_hv_mc_qpel_16x16_msa;
-    c->put_qpel_pixels_tab[0][11] = ff_hv_mc_qpel_aver_h_src1_16x16_msa;
-    c->put_qpel_pixels_tab[0][12] = ff_vert_mc_qpel_aver_src1_16x16_msa;
-    c->put_qpel_pixels_tab[0][13] = ff_hv_mc_qpel_aver_hv_src01_16x16_msa;
-    c->put_qpel_pixels_tab[0][14] = ff_hv_mc_qpel_aver_v_src1_16x16_msa;
-    c->put_qpel_pixels_tab[0][15] = ff_hv_mc_qpel_aver_hv_src11_16x16_msa;
+    int cpu_flags = av_get_cpu_flags();
 
-    c->put_qpel_pixels_tab[1][0] = ff_copy_8x8_msa;
-    c->put_qpel_pixels_tab[1][1] = ff_horiz_mc_qpel_aver_src0_8width_msa;
-    c->put_qpel_pixels_tab[1][2] = ff_horiz_mc_qpel_8width_msa;
-    c->put_qpel_pixels_tab[1][3] = ff_horiz_mc_qpel_aver_src1_8width_msa;
-    c->put_qpel_pixels_tab[1][4] = ff_vert_mc_qpel_aver_src0_8x8_msa;
-    c->put_qpel_pixels_tab[1][5] = ff_hv_mc_qpel_aver_hv_src00_8x8_msa;
-    c->put_qpel_pixels_tab[1][6] = ff_hv_mc_qpel_aver_v_src0_8x8_msa;
-    c->put_qpel_pixels_tab[1][7] = ff_hv_mc_qpel_aver_hv_src10_8x8_msa;
-    c->put_qpel_pixels_tab[1][8] = ff_vert_mc_qpel_8x8_msa;
-    c->put_qpel_pixels_tab[1][9] = ff_hv_mc_qpel_aver_h_src0_8x8_msa;
-    c->put_qpel_pixels_tab[1][10] = ff_hv_mc_qpel_8x8_msa;
-    c->put_qpel_pixels_tab[1][11] = ff_hv_mc_qpel_aver_h_src1_8x8_msa;
-    c->put_qpel_pixels_tab[1][12] = ff_vert_mc_qpel_aver_src1_8x8_msa;
-    c->put_qpel_pixels_tab[1][13] = ff_hv_mc_qpel_aver_hv_src01_8x8_msa;
-    c->put_qpel_pixels_tab[1][14] = ff_hv_mc_qpel_aver_v_src1_8x8_msa;
-    c->put_qpel_pixels_tab[1][15] = ff_hv_mc_qpel_aver_hv_src11_8x8_msa;
+    if (have_msa(cpu_flags)) {
+        c->put_qpel_pixels_tab[0][0] = ff_copy_16x16_msa;
+        c->put_qpel_pixels_tab[0][1] = ff_horiz_mc_qpel_aver_src0_16width_msa;
+        c->put_qpel_pixels_tab[0][2] = ff_horiz_mc_qpel_16width_msa;
+        c->put_qpel_pixels_tab[0][3] = ff_horiz_mc_qpel_aver_src1_16width_msa;
+        c->put_qpel_pixels_tab[0][4] = ff_vert_mc_qpel_aver_src0_16x16_msa;
+        c->put_qpel_pixels_tab[0][5] = ff_hv_mc_qpel_aver_hv_src00_16x16_msa;
+        c->put_qpel_pixels_tab[0][6] = ff_hv_mc_qpel_aver_v_src0_16x16_msa;
+        c->put_qpel_pixels_tab[0][7] = ff_hv_mc_qpel_aver_hv_src10_16x16_msa;
+        c->put_qpel_pixels_tab[0][8] = ff_vert_mc_qpel_16x16_msa;
+        c->put_qpel_pixels_tab[0][9] = ff_hv_mc_qpel_aver_h_src0_16x16_msa;
+        c->put_qpel_pixels_tab[0][10] = ff_hv_mc_qpel_16x16_msa;
+        c->put_qpel_pixels_tab[0][11] = ff_hv_mc_qpel_aver_h_src1_16x16_msa;
+        c->put_qpel_pixels_tab[0][12] = ff_vert_mc_qpel_aver_src1_16x16_msa;
+        c->put_qpel_pixels_tab[0][13] = ff_hv_mc_qpel_aver_hv_src01_16x16_msa;
+        c->put_qpel_pixels_tab[0][14] = ff_hv_mc_qpel_aver_v_src1_16x16_msa;
+        c->put_qpel_pixels_tab[0][15] = ff_hv_mc_qpel_aver_hv_src11_16x16_msa;
 
-    c->put_no_rnd_qpel_pixels_tab[0][0] = ff_copy_16x16_msa;
-    c->put_no_rnd_qpel_pixels_tab[0][1] =
-        ff_horiz_mc_qpel_no_rnd_aver_src0_16width_msa;
-    c->put_no_rnd_qpel_pixels_tab[0][2] = ff_horiz_mc_qpel_no_rnd_16width_msa;
-    c->put_no_rnd_qpel_pixels_tab[0][3] =
-        ff_horiz_mc_qpel_no_rnd_aver_src1_16width_msa;
-    c->put_no_rnd_qpel_pixels_tab[0][4] =
-        ff_vert_mc_qpel_no_rnd_aver_src0_16x16_msa;
-    c->put_no_rnd_qpel_pixels_tab[0][5] =
-        ff_hv_mc_qpel_no_rnd_aver_hv_src00_16x16_msa;
-    c->put_no_rnd_qpel_pixels_tab[0][6] =
-        ff_hv_mc_qpel_no_rnd_aver_v_src0_16x16_msa;
-    c->put_no_rnd_qpel_pixels_tab[0][7] =
-        ff_hv_mc_qpel_no_rnd_aver_hv_src10_16x16_msa;
-    c->put_no_rnd_qpel_pixels_tab[0][8] = ff_vert_mc_qpel_no_rnd_16x16_msa;
-    c->put_no_rnd_qpel_pixels_tab[0][9] =
-        ff_hv_mc_qpel_no_rnd_aver_h_src0_16x16_msa;
-    c->put_no_rnd_qpel_pixels_tab[0][10] = ff_hv_mc_qpel_no_rnd_16x16_msa;
-    c->put_no_rnd_qpel_pixels_tab[0][11] =
-        ff_hv_mc_qpel_no_rnd_aver_h_src1_16x16_msa;
-    c->put_no_rnd_qpel_pixels_tab[0][12] =
-        ff_vert_mc_qpel_no_rnd_aver_src1_16x16_msa;
-    c->put_no_rnd_qpel_pixels_tab[0][13] =
-        ff_hv_mc_qpel_no_rnd_aver_hv_src01_16x16_msa;
-    c->put_no_rnd_qpel_pixels_tab[0][14] =
-        ff_hv_mc_qpel_no_rnd_aver_v_src1_16x16_msa;
-    c->put_no_rnd_qpel_pixels_tab[0][15] =
-        ff_hv_mc_qpel_no_rnd_aver_hv_src11_16x16_msa;
+        c->put_qpel_pixels_tab[1][0] = ff_copy_8x8_msa;
+        c->put_qpel_pixels_tab[1][1] = ff_horiz_mc_qpel_aver_src0_8width_msa;
+        c->put_qpel_pixels_tab[1][2] = ff_horiz_mc_qpel_8width_msa;
+        c->put_qpel_pixels_tab[1][3] = ff_horiz_mc_qpel_aver_src1_8width_msa;
+        c->put_qpel_pixels_tab[1][4] = ff_vert_mc_qpel_aver_src0_8x8_msa;
+        c->put_qpel_pixels_tab[1][5] = ff_hv_mc_qpel_aver_hv_src00_8x8_msa;
+        c->put_qpel_pixels_tab[1][6] = ff_hv_mc_qpel_aver_v_src0_8x8_msa;
+        c->put_qpel_pixels_tab[1][7] = ff_hv_mc_qpel_aver_hv_src10_8x8_msa;
+        c->put_qpel_pixels_tab[1][8] = ff_vert_mc_qpel_8x8_msa;
+        c->put_qpel_pixels_tab[1][9] = ff_hv_mc_qpel_aver_h_src0_8x8_msa;
+        c->put_qpel_pixels_tab[1][10] = ff_hv_mc_qpel_8x8_msa;
+        c->put_qpel_pixels_tab[1][11] = ff_hv_mc_qpel_aver_h_src1_8x8_msa;
+        c->put_qpel_pixels_tab[1][12] = ff_vert_mc_qpel_aver_src1_8x8_msa;
+        c->put_qpel_pixels_tab[1][13] = ff_hv_mc_qpel_aver_hv_src01_8x8_msa;
+        c->put_qpel_pixels_tab[1][14] = ff_hv_mc_qpel_aver_v_src1_8x8_msa;
+        c->put_qpel_pixels_tab[1][15] = ff_hv_mc_qpel_aver_hv_src11_8x8_msa;
 
-    c->put_no_rnd_qpel_pixels_tab[1][0] = ff_copy_8x8_msa;
-    c->put_no_rnd_qpel_pixels_tab[1][1] =
-        ff_horiz_mc_qpel_no_rnd_aver_src0_8width_msa;
-    c->put_no_rnd_qpel_pixels_tab[1][2] = ff_horiz_mc_qpel_no_rnd_8width_msa;
-    c->put_no_rnd_qpel_pixels_tab[1][3] =
-        ff_horiz_mc_qpel_no_rnd_aver_src1_8width_msa;
-    c->put_no_rnd_qpel_pixels_tab[1][4] =
-        ff_vert_mc_qpel_no_rnd_aver_src0_8x8_msa;
-    c->put_no_rnd_qpel_pixels_tab[1][5] =
-        ff_hv_mc_qpel_no_rnd_aver_hv_src00_8x8_msa;
-    c->put_no_rnd_qpel_pixels_tab[1][6] =
-        ff_hv_mc_qpel_no_rnd_aver_v_src0_8x8_msa;
-    c->put_no_rnd_qpel_pixels_tab[1][7] =
-        ff_hv_mc_qpel_no_rnd_aver_hv_src10_8x8_msa;
-    c->put_no_rnd_qpel_pixels_tab[1][8] = ff_vert_mc_qpel_no_rnd_8x8_msa;
-    c->put_no_rnd_qpel_pixels_tab[1][9] =
-        ff_hv_mc_qpel_no_rnd_aver_h_src0_8x8_msa;
-    c->put_no_rnd_qpel_pixels_tab[1][10] = ff_hv_mc_qpel_no_rnd_8x8_msa;
-    c->put_no_rnd_qpel_pixels_tab[1][11] =
-        ff_hv_mc_qpel_no_rnd_aver_h_src1_8x8_msa;
-    c->put_no_rnd_qpel_pixels_tab[1][12] =
-        ff_vert_mc_qpel_no_rnd_aver_src1_8x8_msa;
-    c->put_no_rnd_qpel_pixels_tab[1][13] =
-        ff_hv_mc_qpel_no_rnd_aver_hv_src01_8x8_msa;
-    c->put_no_rnd_qpel_pixels_tab[1][14] =
-        ff_hv_mc_qpel_no_rnd_aver_v_src1_8x8_msa;
-    c->put_no_rnd_qpel_pixels_tab[1][15] =
-        ff_hv_mc_qpel_no_rnd_aver_hv_src11_8x8_msa;
+        c->put_no_rnd_qpel_pixels_tab[0][0] = ff_copy_16x16_msa;
+        c->put_no_rnd_qpel_pixels_tab[0][1] =
+            ff_horiz_mc_qpel_no_rnd_aver_src0_16width_msa;
+        c->put_no_rnd_qpel_pixels_tab[0][2] = ff_horiz_mc_qpel_no_rnd_16width_msa;
+        c->put_no_rnd_qpel_pixels_tab[0][3] =
+            ff_horiz_mc_qpel_no_rnd_aver_src1_16width_msa;
+        c->put_no_rnd_qpel_pixels_tab[0][4] =
+            ff_vert_mc_qpel_no_rnd_aver_src0_16x16_msa;
+        c->put_no_rnd_qpel_pixels_tab[0][5] =
+            ff_hv_mc_qpel_no_rnd_aver_hv_src00_16x16_msa;
+        c->put_no_rnd_qpel_pixels_tab[0][6] =
+            ff_hv_mc_qpel_no_rnd_aver_v_src0_16x16_msa;
+        c->put_no_rnd_qpel_pixels_tab[0][7] =
+            ff_hv_mc_qpel_no_rnd_aver_hv_src10_16x16_msa;
+        c->put_no_rnd_qpel_pixels_tab[0][8] = ff_vert_mc_qpel_no_rnd_16x16_msa;
+        c->put_no_rnd_qpel_pixels_tab[0][9] =
+            ff_hv_mc_qpel_no_rnd_aver_h_src0_16x16_msa;
+        c->put_no_rnd_qpel_pixels_tab[0][10] = ff_hv_mc_qpel_no_rnd_16x16_msa;
+        c->put_no_rnd_qpel_pixels_tab[0][11] =
+            ff_hv_mc_qpel_no_rnd_aver_h_src1_16x16_msa;
+        c->put_no_rnd_qpel_pixels_tab[0][12] =
+            ff_vert_mc_qpel_no_rnd_aver_src1_16x16_msa;
+        c->put_no_rnd_qpel_pixels_tab[0][13] =
+            ff_hv_mc_qpel_no_rnd_aver_hv_src01_16x16_msa;
+        c->put_no_rnd_qpel_pixels_tab[0][14] =
+            ff_hv_mc_qpel_no_rnd_aver_v_src1_16x16_msa;
+        c->put_no_rnd_qpel_pixels_tab[0][15] =
+            ff_hv_mc_qpel_no_rnd_aver_hv_src11_16x16_msa;
 
-    c->avg_qpel_pixels_tab[0][0] = ff_avg_width16_msa;
-    c->avg_qpel_pixels_tab[0][1] =
-        ff_horiz_mc_qpel_avg_dst_aver_src0_16width_msa;
-    c->avg_qpel_pixels_tab[0][2] = ff_horiz_mc_qpel_avg_dst_16width_msa;
-    c->avg_qpel_pixels_tab[0][3] =
-        ff_horiz_mc_qpel_avg_dst_aver_src1_16width_msa;
-    c->avg_qpel_pixels_tab[0][4] = ff_vert_mc_qpel_avg_dst_aver_src0_16x16_msa;
-    c->avg_qpel_pixels_tab[0][5] =
-        ff_hv_mc_qpel_avg_dst_aver_hv_src00_16x16_msa;
-    c->avg_qpel_pixels_tab[0][6] = ff_hv_mc_qpel_avg_dst_aver_v_src0_16x16_msa;
-    c->avg_qpel_pixels_tab[0][7] =
-        ff_hv_mc_qpel_avg_dst_aver_hv_src10_16x16_msa;
-    c->avg_qpel_pixels_tab[0][8] = ff_vert_mc_qpel_avg_dst_16x16_msa;
-    c->avg_qpel_pixels_tab[0][9] = ff_hv_mc_qpel_avg_dst_aver_h_src0_16x16_msa;
-    c->avg_qpel_pixels_tab[0][10] = ff_hv_mc_qpel_avg_dst_16x16_msa;
-    c->avg_qpel_pixels_tab[0][11] = ff_hv_mc_qpel_avg_dst_aver_h_src1_16x16_msa;
-    c->avg_qpel_pixels_tab[0][12] = ff_vert_mc_qpel_avg_dst_aver_src1_16x16_msa;
-    c->avg_qpel_pixels_tab[0][13] =
-        ff_hv_mc_qpel_avg_dst_aver_hv_src01_16x16_msa;
-    c->avg_qpel_pixels_tab[0][14] = ff_hv_mc_qpel_avg_dst_aver_v_src1_16x16_msa;
-    c->avg_qpel_pixels_tab[0][15] =
-        ff_hv_mc_qpel_avg_dst_aver_hv_src11_16x16_msa;
+        c->put_no_rnd_qpel_pixels_tab[1][0] = ff_copy_8x8_msa;
+        c->put_no_rnd_qpel_pixels_tab[1][1] =
+            ff_horiz_mc_qpel_no_rnd_aver_src0_8width_msa;
+        c->put_no_rnd_qpel_pixels_tab[1][2] = ff_horiz_mc_qpel_no_rnd_8width_msa;
+        c->put_no_rnd_qpel_pixels_tab[1][3] =
+            ff_horiz_mc_qpel_no_rnd_aver_src1_8width_msa;
+        c->put_no_rnd_qpel_pixels_tab[1][4] =
+            ff_vert_mc_qpel_no_rnd_aver_src0_8x8_msa;
+        c->put_no_rnd_qpel_pixels_tab[1][5] =
+            ff_hv_mc_qpel_no_rnd_aver_hv_src00_8x8_msa;
+        c->put_no_rnd_qpel_pixels_tab[1][6] =
+            ff_hv_mc_qpel_no_rnd_aver_v_src0_8x8_msa;
+        c->put_no_rnd_qpel_pixels_tab[1][7] =
+            ff_hv_mc_qpel_no_rnd_aver_hv_src10_8x8_msa;
+        c->put_no_rnd_qpel_pixels_tab[1][8] = ff_vert_mc_qpel_no_rnd_8x8_msa;
+        c->put_no_rnd_qpel_pixels_tab[1][9] =
+            ff_hv_mc_qpel_no_rnd_aver_h_src0_8x8_msa;
+        c->put_no_rnd_qpel_pixels_tab[1][10] = ff_hv_mc_qpel_no_rnd_8x8_msa;
+        c->put_no_rnd_qpel_pixels_tab[1][11] =
+            ff_hv_mc_qpel_no_rnd_aver_h_src1_8x8_msa;
+        c->put_no_rnd_qpel_pixels_tab[1][12] =
+            ff_vert_mc_qpel_no_rnd_aver_src1_8x8_msa;
+        c->put_no_rnd_qpel_pixels_tab[1][13] =
+            ff_hv_mc_qpel_no_rnd_aver_hv_src01_8x8_msa;
+        c->put_no_rnd_qpel_pixels_tab[1][14] =
+            ff_hv_mc_qpel_no_rnd_aver_v_src1_8x8_msa;
+        c->put_no_rnd_qpel_pixels_tab[1][15] =
+            ff_hv_mc_qpel_no_rnd_aver_hv_src11_8x8_msa;
 
-    c->avg_qpel_pixels_tab[1][0] = ff_avg_width8_msa;
-    c->avg_qpel_pixels_tab[1][1] =
-        ff_horiz_mc_qpel_avg_dst_aver_src0_8width_msa;
-    c->avg_qpel_pixels_tab[1][2] = ff_horiz_mc_qpel_avg_dst_8width_msa;
-    c->avg_qpel_pixels_tab[1][3] =
-        ff_horiz_mc_qpel_avg_dst_aver_src1_8width_msa;
-    c->avg_qpel_pixels_tab[1][4] = ff_vert_mc_qpel_avg_dst_aver_src0_8x8_msa;
-    c->avg_qpel_pixels_tab[1][5] = ff_hv_mc_qpel_avg_dst_aver_hv_src00_8x8_msa;
-    c->avg_qpel_pixels_tab[1][6] = ff_hv_mc_qpel_avg_dst_aver_v_src0_8x8_msa;
-    c->avg_qpel_pixels_tab[1][7] = ff_hv_mc_qpel_avg_dst_aver_hv_src10_8x8_msa;
-    c->avg_qpel_pixels_tab[1][8] = ff_vert_mc_qpel_avg_dst_8x8_msa;
-    c->avg_qpel_pixels_tab[1][9] = ff_hv_mc_qpel_avg_dst_aver_h_src0_8x8_msa;
-    c->avg_qpel_pixels_tab[1][10] = ff_hv_mc_qpel_avg_dst_8x8_msa;
-    c->avg_qpel_pixels_tab[1][11] = ff_hv_mc_qpel_avg_dst_aver_h_src1_8x8_msa;
-    c->avg_qpel_pixels_tab[1][12] = ff_vert_mc_qpel_avg_dst_aver_src1_8x8_msa;
-    c->avg_qpel_pixels_tab[1][13] = ff_hv_mc_qpel_avg_dst_aver_hv_src01_8x8_msa;
-    c->avg_qpel_pixels_tab[1][14] = ff_hv_mc_qpel_avg_dst_aver_v_src1_8x8_msa;
-    c->avg_qpel_pixels_tab[1][15] = ff_hv_mc_qpel_avg_dst_aver_hv_src11_8x8_msa;
-}
-#endif  // #if HAVE_MSA
+        c->avg_qpel_pixels_tab[0][0] = ff_avg_width16_msa;
+        c->avg_qpel_pixels_tab[0][1] =
+            ff_horiz_mc_qpel_avg_dst_aver_src0_16width_msa;
+        c->avg_qpel_pixels_tab[0][2] = ff_horiz_mc_qpel_avg_dst_16width_msa;
+        c->avg_qpel_pixels_tab[0][3] =
+            ff_horiz_mc_qpel_avg_dst_aver_src1_16width_msa;
+        c->avg_qpel_pixels_tab[0][4] = ff_vert_mc_qpel_avg_dst_aver_src0_16x16_msa;
+        c->avg_qpel_pixels_tab[0][5] =
+            ff_hv_mc_qpel_avg_dst_aver_hv_src00_16x16_msa;
+        c->avg_qpel_pixels_tab[0][6] = ff_hv_mc_qpel_avg_dst_aver_v_src0_16x16_msa;
+        c->avg_qpel_pixels_tab[0][7] =
+            ff_hv_mc_qpel_avg_dst_aver_hv_src10_16x16_msa;
+        c->avg_qpel_pixels_tab[0][8] = ff_vert_mc_qpel_avg_dst_16x16_msa;
+        c->avg_qpel_pixels_tab[0][9] = ff_hv_mc_qpel_avg_dst_aver_h_src0_16x16_msa;
+        c->avg_qpel_pixels_tab[0][10] = ff_hv_mc_qpel_avg_dst_16x16_msa;
+        c->avg_qpel_pixels_tab[0][11] = ff_hv_mc_qpel_avg_dst_aver_h_src1_16x16_msa;
+        c->avg_qpel_pixels_tab[0][12] = ff_vert_mc_qpel_avg_dst_aver_src1_16x16_msa;
+        c->avg_qpel_pixels_tab[0][13] =
+            ff_hv_mc_qpel_avg_dst_aver_hv_src01_16x16_msa;
+        c->avg_qpel_pixels_tab[0][14] = ff_hv_mc_qpel_avg_dst_aver_v_src1_16x16_msa;
+        c->avg_qpel_pixels_tab[0][15] =
+            ff_hv_mc_qpel_avg_dst_aver_hv_src11_16x16_msa;
 
-void ff_qpeldsp_init_mips(QpelDSPContext *c)
-{
-#if HAVE_MSA
-    qpeldsp_init_msa(c);
-#endif  // #if HAVE_MSA
+        c->avg_qpel_pixels_tab[1][0] = ff_avg_width8_msa;
+        c->avg_qpel_pixels_tab[1][1] =
+            ff_horiz_mc_qpel_avg_dst_aver_src0_8width_msa;
+        c->avg_qpel_pixels_tab[1][2] = ff_horiz_mc_qpel_avg_dst_8width_msa;
+        c->avg_qpel_pixels_tab[1][3] =
+            ff_horiz_mc_qpel_avg_dst_aver_src1_8width_msa;
+        c->avg_qpel_pixels_tab[1][4] = ff_vert_mc_qpel_avg_dst_aver_src0_8x8_msa;
+        c->avg_qpel_pixels_tab[1][5] = ff_hv_mc_qpel_avg_dst_aver_hv_src00_8x8_msa;
+        c->avg_qpel_pixels_tab[1][6] = ff_hv_mc_qpel_avg_dst_aver_v_src0_8x8_msa;
+        c->avg_qpel_pixels_tab[1][7] = ff_hv_mc_qpel_avg_dst_aver_hv_src10_8x8_msa;
+        c->avg_qpel_pixels_tab[1][8] = ff_vert_mc_qpel_avg_dst_8x8_msa;
+        c->avg_qpel_pixels_tab[1][9] = ff_hv_mc_qpel_avg_dst_aver_h_src0_8x8_msa;
+        c->avg_qpel_pixels_tab[1][10] = ff_hv_mc_qpel_avg_dst_8x8_msa;
+        c->avg_qpel_pixels_tab[1][11] = ff_hv_mc_qpel_avg_dst_aver_h_src1_8x8_msa;
+        c->avg_qpel_pixels_tab[1][12] = ff_vert_mc_qpel_avg_dst_aver_src1_8x8_msa;
+        c->avg_qpel_pixels_tab[1][13] = ff_hv_mc_qpel_avg_dst_aver_hv_src01_8x8_msa;
+        c->avg_qpel_pixels_tab[1][14] = ff_hv_mc_qpel_avg_dst_aver_v_src1_8x8_msa;
+        c->avg_qpel_pixels_tab[1][15] = ff_hv_mc_qpel_avg_dst_aver_hv_src11_8x8_msa;
+    }
 }
diff --git a/libavcodec/mips/vc1dsp_init_mips.c b/libavcodec/mips/vc1dsp_init_mips.c
index c0007ff650..94126f3a9d 100644
--- a/libavcodec/mips/vc1dsp_init_mips.c
+++ b/libavcodec/mips/vc1dsp_init_mips.c
@@ -18,6 +18,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/mips/cpu.h"
 #include "libavutil/attributes.h"
 #include "libavcodec/vc1dsp.h"
 #include "vc1dsp_mips.h"
@@ -27,104 +28,93 @@
     dsp->OP##vc1_mspel_pixels_tab[1][X+4*Y] = ff_##OP##vc1_mspel_mc##X##Y##INSN; \
     dsp->OP##vc1_mspel_pixels_tab[0][X+4*Y] = ff_##OP##vc1_mspel_mc##X##Y##_16##INSN
 
-#if HAVE_MMI
-static av_cold void vc1dsp_init_mmi(VC1DSPContext *dsp)
-{
-#if _MIPS_SIM != _ABIO32
-    dsp->vc1_inv_trans_8x8    = ff_vc1_inv_trans_8x8_mmi;
-    dsp->vc1_inv_trans_4x8    = ff_vc1_inv_trans_4x8_mmi;
-    dsp->vc1_inv_trans_8x4    = ff_vc1_inv_trans_8x4_mmi;
-#endif
-    dsp->vc1_inv_trans_4x4    = ff_vc1_inv_trans_4x4_mmi;
-    dsp->vc1_inv_trans_8x8_dc = ff_vc1_inv_trans_8x8_dc_mmi;
-    dsp->vc1_inv_trans_4x8_dc = ff_vc1_inv_trans_4x8_dc_mmi;
-    dsp->vc1_inv_trans_8x4_dc = ff_vc1_inv_trans_8x4_dc_mmi;
-    dsp->vc1_inv_trans_4x4_dc = ff_vc1_inv_trans_4x4_dc_mmi;
-
-    dsp->vc1_h_overlap        = ff_vc1_h_overlap_mmi;
-    dsp->vc1_v_overlap        = ff_vc1_v_overlap_mmi;
-    dsp->vc1_h_s_overlap      = ff_vc1_h_s_overlap_mmi;
-    dsp->vc1_v_s_overlap      = ff_vc1_v_s_overlap_mmi;
-
-    dsp->vc1_v_loop_filter4  = ff_vc1_v_loop_filter4_mmi;
-    dsp->vc1_h_loop_filter4  = ff_vc1_h_loop_filter4_mmi;
-    dsp->vc1_v_loop_filter8  = ff_vc1_v_loop_filter8_mmi;
-    dsp->vc1_h_loop_filter8  = ff_vc1_h_loop_filter8_mmi;
-    dsp->vc1_v_loop_filter16 = ff_vc1_v_loop_filter16_mmi;
-    dsp->vc1_h_loop_filter16 = ff_vc1_h_loop_filter16_mmi;
-
-    FN_ASSIGN(put_, 0, 0, _mmi);
-    FN_ASSIGN(put_, 0, 1, _mmi);
-    FN_ASSIGN(put_, 0, 2, _mmi);
-    FN_ASSIGN(put_, 0, 3, _mmi);
-
-    FN_ASSIGN(put_, 1, 0, _mmi);
-    //FN_ASSIGN(put_, 1, 1, _mmi);//FIXME
-    //FN_ASSIGN(put_, 1, 2, _mmi);//FIXME
-    //FN_ASSIGN(put_, 1, 3, _mmi);//FIXME
-
-    FN_ASSIGN(put_, 2, 0, _mmi);
-    //FN_ASSIGN(put_, 2, 1, _mmi);//FIXME
-    //FN_ASSIGN(put_, 2, 2, _mmi);//FIXME
-    //FN_ASSIGN(put_, 2, 3, _mmi);//FIXME
-
-    FN_ASSIGN(put_, 3, 0, _mmi);
-    //FN_ASSIGN(put_, 3, 1, _mmi);//FIXME
-    //FN_ASSIGN(put_, 3, 2, _mmi);//FIXME
-    //FN_ASSIGN(put_, 3, 3, _mmi);//FIXME
-
-    FN_ASSIGN(avg_, 0, 0, _mmi);
-    FN_ASSIGN(avg_, 0, 1, _mmi);
-    FN_ASSIGN(avg_, 0, 2, _mmi);
-    FN_ASSIGN(avg_, 0, 3, _mmi);
-
-    FN_ASSIGN(avg_, 1, 0, _mmi);
-    //FN_ASSIGN(avg_, 1, 1, _mmi);//FIXME
-    //FN_ASSIGN(avg_, 1, 2, _mmi);//FIXME
-    //FN_ASSIGN(avg_, 1, 3, _mmi);//FIXME
-
-    FN_ASSIGN(avg_, 2, 0, _mmi);
-    //FN_ASSIGN(avg_, 2, 1, _mmi);//FIXME
-    //FN_ASSIGN(avg_, 2, 2, _mmi);//FIXME
-    //FN_ASSIGN(avg_, 2, 3, _mmi);//FIXME
-
-    FN_ASSIGN(avg_, 3, 0, _mmi);
-    //FN_ASSIGN(avg_, 3, 1, _mmi);//FIXME
-    //FN_ASSIGN(avg_, 3, 2, _mmi);//FIXME
-    //FN_ASSIGN(avg_, 3, 3, _mmi);//FIXME
-
-    dsp->put_no_rnd_vc1_chroma_pixels_tab[0] = ff_put_no_rnd_vc1_chroma_mc8_mmi;
-    dsp->avg_no_rnd_vc1_chroma_pixels_tab[0] = ff_avg_no_rnd_vc1_chroma_mc8_mmi;
-    dsp->put_no_rnd_vc1_chroma_pixels_tab[1] = ff_put_no_rnd_vc1_chroma_mc4_mmi;
-    dsp->avg_no_rnd_vc1_chroma_pixels_tab[1] = ff_avg_no_rnd_vc1_chroma_mc4_mmi;
-}
-#endif /* HAVE_MMI */
-
-#if HAVE_MSA
-static av_cold void vc1dsp_init_msa(VC1DSPContext *dsp)
-{
-    dsp->vc1_inv_trans_8x8 = ff_vc1_inv_trans_8x8_msa;
-    dsp->vc1_inv_trans_4x8 = ff_vc1_inv_trans_4x8_msa;
-    dsp->vc1_inv_trans_8x4 = ff_vc1_inv_trans_8x4_msa;
-
-    FN_ASSIGN(put_, 1, 1, _msa);
-    FN_ASSIGN(put_, 1, 2, _msa);
-    FN_ASSIGN(put_, 1, 3, _msa);
-    FN_ASSIGN(put_, 2, 1, _msa);
-    FN_ASSIGN(put_, 2, 2, _msa);
-    FN_ASSIGN(put_, 2, 3, _msa);
-    FN_ASSIGN(put_, 3, 1, _msa);
-    FN_ASSIGN(put_, 3, 2, _msa);
-    FN_ASSIGN(put_, 3, 3, _msa);
-}
-#endif /* HAVE_MSA */
-
 av_cold void ff_vc1dsp_init_mips(VC1DSPContext *dsp)
 {
-#if HAVE_MMI
-    vc1dsp_init_mmi(dsp);
-#endif /* HAVE_MMI */
-#if HAVE_MSA
-    vc1dsp_init_msa(dsp);
-#endif /* HAVE_MSA */
+    int cpu_flags = av_get_cpu_flags();
+
+    if (have_mmi(cpu_flags)) {
+ #if _MIPS_SIM != _ABIO32
+        dsp->vc1_inv_trans_8x8    = ff_vc1_inv_trans_8x8_mmi;
+        dsp->vc1_inv_trans_4x8    = ff_vc1_inv_trans_4x8_mmi;
+        dsp->vc1_inv_trans_8x4    = ff_vc1_inv_trans_8x4_mmi;
+#endif
+        dsp->vc1_inv_trans_4x4    = ff_vc1_inv_trans_4x4_mmi;
+        dsp->vc1_inv_trans_8x8_dc = ff_vc1_inv_trans_8x8_dc_mmi;
+        dsp->vc1_inv_trans_4x8_dc = ff_vc1_inv_trans_4x8_dc_mmi;
+        dsp->vc1_inv_trans_8x4_dc = ff_vc1_inv_trans_8x4_dc_mmi;
+        dsp->vc1_inv_trans_4x4_dc = ff_vc1_inv_trans_4x4_dc_mmi;
+
+        dsp->vc1_h_overlap        = ff_vc1_h_overlap_mmi;
+        dsp->vc1_v_overlap        = ff_vc1_v_overlap_mmi;
+        dsp->vc1_h_s_overlap      = ff_vc1_h_s_overlap_mmi;
+        dsp->vc1_v_s_overlap      = ff_vc1_v_s_overlap_mmi;
+
+        dsp->vc1_v_loop_filter4  = ff_vc1_v_loop_filter4_mmi;
+        dsp->vc1_h_loop_filter4  = ff_vc1_h_loop_filter4_mmi;
+        dsp->vc1_v_loop_filter8  = ff_vc1_v_loop_filter8_mmi;
+        dsp->vc1_h_loop_filter8  = ff_vc1_h_loop_filter8_mmi;
+        dsp->vc1_v_loop_filter16 = ff_vc1_v_loop_filter16_mmi;
+        dsp->vc1_h_loop_filter16 = ff_vc1_h_loop_filter16_mmi;
+
+        FN_ASSIGN(put_, 0, 0, _mmi);
+        FN_ASSIGN(put_, 0, 1, _mmi);
+        FN_ASSIGN(put_, 0, 2, _mmi);
+        FN_ASSIGN(put_, 0, 3, _mmi);
+
+        FN_ASSIGN(put_, 1, 0, _mmi);
+        //FN_ASSIGN(put_, 1, 1, _mmi);//FIXME
+        //FN_ASSIGN(put_, 1, 2, _mmi);//FIXME
+        //FN_ASSIGN(put_, 1, 3, _mmi);//FIXME
+
+        FN_ASSIGN(put_, 2, 0, _mmi);
+        //FN_ASSIGN(put_, 2, 1, _mmi);//FIXME
+        //FN_ASSIGN(put_, 2, 2, _mmi);//FIXME
+        //FN_ASSIGN(put_, 2, 3, _mmi);//FIXME
+
+        FN_ASSIGN(put_, 3, 0, _mmi);
+        //FN_ASSIGN(put_, 3, 1, _mmi);//FIXME
+        //FN_ASSIGN(put_, 3, 2, _mmi);//FIXME
+        //FN_ASSIGN(put_, 3, 3, _mmi);//FIXME
+
+        FN_ASSIGN(avg_, 0, 0, _mmi);
+        FN_ASSIGN(avg_, 0, 1, _mmi);
+        FN_ASSIGN(avg_, 0, 2, _mmi);
+        FN_ASSIGN(avg_, 0, 3, _mmi);
+
+        FN_ASSIGN(avg_, 1, 0, _mmi);
+        //FN_ASSIGN(avg_, 1, 1, _mmi);//FIXME
+        //FN_ASSIGN(avg_, 1, 2, _mmi);//FIXME
+        //FN_ASSIGN(avg_, 1, 3, _mmi);//FIXME
+
+        FN_ASSIGN(avg_, 2, 0, _mmi);
+        //FN_ASSIGN(avg_, 2, 1, _mmi);//FIXME
+        //FN_ASSIGN(avg_, 2, 2, _mmi);//FIXME
+        //FN_ASSIGN(avg_, 2, 3, _mmi);//FIXME
+
+        FN_ASSIGN(avg_, 3, 0, _mmi);
+        //FN_ASSIGN(avg_, 3, 1, _mmi);//FIXME
+        //FN_ASSIGN(avg_, 3, 2, _mmi);//FIXME
+        //FN_ASSIGN(avg_, 3, 3, _mmi);//FIXME
+
+        dsp->put_no_rnd_vc1_chroma_pixels_tab[0] = ff_put_no_rnd_vc1_chroma_mc8_mmi;
+        dsp->avg_no_rnd_vc1_chroma_pixels_tab[0] = ff_avg_no_rnd_vc1_chroma_mc8_mmi;
+        dsp->put_no_rnd_vc1_chroma_pixels_tab[1] = ff_put_no_rnd_vc1_chroma_mc4_mmi;
+        dsp->avg_no_rnd_vc1_chroma_pixels_tab[1] = ff_avg_no_rnd_vc1_chroma_mc4_mmi;
+    }
+
+    if (have_msa(cpu_flags)) {
+        dsp->vc1_inv_trans_8x8 = ff_vc1_inv_trans_8x8_msa;
+        dsp->vc1_inv_trans_4x8 = ff_vc1_inv_trans_4x8_msa;
+        dsp->vc1_inv_trans_8x4 = ff_vc1_inv_trans_8x4_msa;
+
+        FN_ASSIGN(put_, 1, 1, _msa);
+        FN_ASSIGN(put_, 1, 2, _msa);
+        FN_ASSIGN(put_, 1, 3, _msa);
+        FN_ASSIGN(put_, 2, 1, _msa);
+        FN_ASSIGN(put_, 2, 2, _msa);
+        FN_ASSIGN(put_, 2, 3, _msa);
+        FN_ASSIGN(put_, 3, 1, _msa);
+        FN_ASSIGN(put_, 3, 2, _msa);
+        FN_ASSIGN(put_, 3, 3, _msa);
+    }
 }
diff --git a/libavcodec/mips/videodsp_init.c b/libavcodec/mips/videodsp_init.c
index 817040420b..07c23bcf7e 100644
--- a/libavcodec/mips/videodsp_init.c
+++ b/libavcodec/mips/videodsp_init.c
@@ -18,12 +18,12 @@
  * 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 "libavutil/mips/asmdefs.h"
 #include "libavcodec/videodsp.h"
 
-#if HAVE_MSA
 static void prefetch_mips(uint8_t *mem, ptrdiff_t stride, int h)
 {
     register const uint8_t *p = mem;
@@ -41,11 +41,11 @@ static void prefetch_mips(uint8_t *mem, ptrdiff_t stride, int h)
         : [stride] "r" (stride)
     );
 }
-#endif  // #if HAVE_MSA
 
 av_cold void ff_videodsp_init_mips(VideoDSPContext *ctx, int bpc)
 {
-#if HAVE_MSA
-    ctx->prefetch = prefetch_mips;
-#endif  // #if HAVE_MSA
+    int cpu_flags = av_get_cpu_flags();
+
+    if (have_msa(cpu_flags))
+        ctx->prefetch = prefetch_mips;
 }
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;
+    }
 }
diff --git a/libavcodec/mips/vp8dsp_init_mips.c b/libavcodec/mips/vp8dsp_init_mips.c
index 7fd8fb0d32..92d8c792cb 100644
--- a/libavcodec/mips/vp8dsp_init_mips.c
+++ b/libavcodec/mips/vp8dsp_init_mips.c
@@ -24,6 +24,7 @@
  * VP8 compatible video decoder
  */
 
+#include "libavutil/mips/cpu.h"
 #include "config.h"
 #include "libavutil/attributes.h"
 #include "libavcodec/vp8dsp.h"
@@ -71,132 +72,123 @@
     dsp->put_vp8_bilinear_pixels_tab[IDX][0][0] =  \
         ff_put_vp8_pixels##SIZE##_msa;
 
-#if HAVE_MSA
-static av_cold void vp8dsp_init_msa(VP8DSPContext *dsp)
-{
-    dsp->vp8_luma_dc_wht = ff_vp8_luma_dc_wht_msa;
-    dsp->vp8_idct_add = ff_vp8_idct_add_msa;
-    dsp->vp8_idct_dc_add = ff_vp8_idct_dc_add_msa;
-    dsp->vp8_idct_dc_add4y = ff_vp8_idct_dc_add4y_msa;
-    dsp->vp8_idct_dc_add4uv = ff_vp8_idct_dc_add4uv_msa;
-
-    VP8_MC_MIPS_FUNC(0, 16);
-    VP8_MC_MIPS_FUNC(1, 8);
-    VP8_MC_MIPS_FUNC(2, 4);
-
-    VP8_BILINEAR_MC_MIPS_FUNC(0, 16);
-    VP8_BILINEAR_MC_MIPS_FUNC(1, 8);
-    VP8_BILINEAR_MC_MIPS_FUNC(2, 4);
-
-    VP8_MC_MIPS_COPY(0, 16);
-    VP8_MC_MIPS_COPY(1, 8);
-
-    dsp->vp8_v_loop_filter16y = ff_vp8_v_loop_filter16_msa;
-    dsp->vp8_h_loop_filter16y = ff_vp8_h_loop_filter16_msa;
-    dsp->vp8_v_loop_filter8uv = ff_vp8_v_loop_filter8uv_msa;
-    dsp->vp8_h_loop_filter8uv = ff_vp8_h_loop_filter8uv_msa;
-
-    dsp->vp8_v_loop_filter16y_inner = ff_vp8_v_loop_filter16_inner_msa;
-    dsp->vp8_h_loop_filter16y_inner = ff_vp8_h_loop_filter16_inner_msa;
-    dsp->vp8_v_loop_filter8uv_inner = ff_vp8_v_loop_filter8uv_inner_msa;
-    dsp->vp8_h_loop_filter8uv_inner = ff_vp8_h_loop_filter8uv_inner_msa;
-
-    dsp->vp8_v_loop_filter_simple = ff_vp8_v_loop_filter_simple_msa;
-    dsp->vp8_h_loop_filter_simple = ff_vp8_h_loop_filter_simple_msa;
-}
-#endif  // #if HAVE_MSA
 
-#if HAVE_MMI
-static av_cold void vp8dsp_init_mmi(VP8DSPContext *dsp)
-{
-    dsp->vp8_luma_dc_wht    = ff_vp8_luma_dc_wht_mmi;
-    dsp->vp8_luma_dc_wht_dc = ff_vp8_luma_dc_wht_dc_mmi;
-    dsp->vp8_idct_add       = ff_vp8_idct_add_mmi;
-    dsp->vp8_idct_dc_add    = ff_vp8_idct_dc_add_mmi;
-    dsp->vp8_idct_dc_add4y  = ff_vp8_idct_dc_add4y_mmi;
-    dsp->vp8_idct_dc_add4uv = ff_vp8_idct_dc_add4uv_mmi;
-
-    dsp->put_vp8_epel_pixels_tab[0][0][1] = ff_put_vp8_epel16_h4_mmi;
-    dsp->put_vp8_epel_pixels_tab[0][0][2] = ff_put_vp8_epel16_h6_mmi;
-    dsp->put_vp8_epel_pixels_tab[0][1][0] = ff_put_vp8_epel16_v4_mmi;
-    dsp->put_vp8_epel_pixels_tab[0][1][1] = ff_put_vp8_epel16_h4v4_mmi;
-    dsp->put_vp8_epel_pixels_tab[0][1][2] = ff_put_vp8_epel16_h6v4_mmi;
-    dsp->put_vp8_epel_pixels_tab[0][2][0] = ff_put_vp8_epel16_v6_mmi;
-    dsp->put_vp8_epel_pixels_tab[0][2][1] = ff_put_vp8_epel16_h4v6_mmi;
-    dsp->put_vp8_epel_pixels_tab[0][2][2] = ff_put_vp8_epel16_h6v6_mmi;
-
-    dsp->put_vp8_epel_pixels_tab[1][0][1] = ff_put_vp8_epel8_h4_mmi;
-    dsp->put_vp8_epel_pixels_tab[1][0][2] = ff_put_vp8_epel8_h6_mmi;
-    dsp->put_vp8_epel_pixels_tab[1][1][0] = ff_put_vp8_epel8_v4_mmi;
-    dsp->put_vp8_epel_pixels_tab[1][1][1] = ff_put_vp8_epel8_h4v4_mmi;
-    dsp->put_vp8_epel_pixels_tab[1][1][2] = ff_put_vp8_epel8_h6v4_mmi;
-    dsp->put_vp8_epel_pixels_tab[1][2][0] = ff_put_vp8_epel8_v6_mmi;
-    dsp->put_vp8_epel_pixels_tab[1][2][1] = ff_put_vp8_epel8_h4v6_mmi;
-    dsp->put_vp8_epel_pixels_tab[1][2][2] = ff_put_vp8_epel8_h6v6_mmi;
-
-    dsp->put_vp8_epel_pixels_tab[2][0][1] = ff_put_vp8_epel4_h4_mmi;
-    dsp->put_vp8_epel_pixels_tab[2][0][2] = ff_put_vp8_epel4_h6_mmi;
-    dsp->put_vp8_epel_pixels_tab[2][1][0] = ff_put_vp8_epel4_v4_mmi;
-    dsp->put_vp8_epel_pixels_tab[2][1][1] = ff_put_vp8_epel4_h4v4_mmi;
-    dsp->put_vp8_epel_pixels_tab[2][1][2] = ff_put_vp8_epel4_h6v4_mmi;
-    dsp->put_vp8_epel_pixels_tab[2][2][0] = ff_put_vp8_epel4_v6_mmi;
-    dsp->put_vp8_epel_pixels_tab[2][2][1] = ff_put_vp8_epel4_h4v6_mmi;
-    dsp->put_vp8_epel_pixels_tab[2][2][2] = ff_put_vp8_epel4_h6v6_mmi;
-
-    dsp->put_vp8_bilinear_pixels_tab[0][0][1] = ff_put_vp8_bilinear16_h_mmi;
-    dsp->put_vp8_bilinear_pixels_tab[0][0][2] = ff_put_vp8_bilinear16_h_mmi;
-    dsp->put_vp8_bilinear_pixels_tab[0][1][0] = ff_put_vp8_bilinear16_v_mmi;
-    dsp->put_vp8_bilinear_pixels_tab[0][1][1] = ff_put_vp8_bilinear16_hv_mmi;
-    dsp->put_vp8_bilinear_pixels_tab[0][1][2] = ff_put_vp8_bilinear16_hv_mmi;
-    dsp->put_vp8_bilinear_pixels_tab[0][2][0] = ff_put_vp8_bilinear16_v_mmi;
-    dsp->put_vp8_bilinear_pixels_tab[0][2][1] = ff_put_vp8_bilinear16_hv_mmi;
-    dsp->put_vp8_bilinear_pixels_tab[0][2][2] = ff_put_vp8_bilinear16_hv_mmi;
-
-    dsp->put_vp8_bilinear_pixels_tab[1][0][1] = ff_put_vp8_bilinear8_h_mmi;
-    dsp->put_vp8_bilinear_pixels_tab[1][0][2] = ff_put_vp8_bilinear8_h_mmi;
-    dsp->put_vp8_bilinear_pixels_tab[1][1][0] = ff_put_vp8_bilinear8_v_mmi;
-    dsp->put_vp8_bilinear_pixels_tab[1][1][1] = ff_put_vp8_bilinear8_hv_mmi;
-    dsp->put_vp8_bilinear_pixels_tab[1][1][2] = ff_put_vp8_bilinear8_hv_mmi;
-    dsp->put_vp8_bilinear_pixels_tab[1][2][0] = ff_put_vp8_bilinear8_v_mmi;
-    dsp->put_vp8_bilinear_pixels_tab[1][2][1] = ff_put_vp8_bilinear8_hv_mmi;
-    dsp->put_vp8_bilinear_pixels_tab[1][2][2] = ff_put_vp8_bilinear8_hv_mmi;
-
-    dsp->put_vp8_bilinear_pixels_tab[2][0][1] = ff_put_vp8_bilinear4_h_mmi;
-    dsp->put_vp8_bilinear_pixels_tab[2][0][2] = ff_put_vp8_bilinear4_h_mmi;
-    dsp->put_vp8_bilinear_pixels_tab[2][1][0] = ff_put_vp8_bilinear4_v_mmi;
-    dsp->put_vp8_bilinear_pixels_tab[2][1][1] = ff_put_vp8_bilinear4_hv_mmi;
-    dsp->put_vp8_bilinear_pixels_tab[2][1][2] = ff_put_vp8_bilinear4_hv_mmi;
-    dsp->put_vp8_bilinear_pixels_tab[2][2][0] = ff_put_vp8_bilinear4_v_mmi;
-    dsp->put_vp8_bilinear_pixels_tab[2][2][1] = ff_put_vp8_bilinear4_hv_mmi;
-    dsp->put_vp8_bilinear_pixels_tab[2][2][2] = ff_put_vp8_bilinear4_hv_mmi;
-
-    dsp->put_vp8_epel_pixels_tab[0][0][0]     = ff_put_vp8_pixels16_mmi;
-    dsp->put_vp8_bilinear_pixels_tab[0][0][0] = ff_put_vp8_pixels16_mmi;
-
-    dsp->put_vp8_epel_pixels_tab[1][0][0]     = ff_put_vp8_pixels8_mmi;
-    dsp->put_vp8_bilinear_pixels_tab[1][0][0] = ff_put_vp8_pixels8_mmi;
-
-    dsp->vp8_v_loop_filter16y = ff_vp8_v_loop_filter16_mmi;
-    dsp->vp8_h_loop_filter16y = ff_vp8_h_loop_filter16_mmi;
-    dsp->vp8_v_loop_filter8uv = ff_vp8_v_loop_filter8uv_mmi;
-    dsp->vp8_h_loop_filter8uv = ff_vp8_h_loop_filter8uv_mmi;
-
-    dsp->vp8_v_loop_filter16y_inner = ff_vp8_v_loop_filter16_inner_mmi;
-    dsp->vp8_h_loop_filter16y_inner = ff_vp8_h_loop_filter16_inner_mmi;
-    dsp->vp8_v_loop_filter8uv_inner = ff_vp8_v_loop_filter8uv_inner_mmi;
-    dsp->vp8_h_loop_filter8uv_inner = ff_vp8_h_loop_filter8uv_inner_mmi;
-
-    dsp->vp8_v_loop_filter_simple = ff_vp8_v_loop_filter_simple_mmi;
-    dsp->vp8_h_loop_filter_simple = ff_vp8_h_loop_filter_simple_mmi;
-}
-#endif /* HAVE_MMI */
 
 av_cold void ff_vp8dsp_init_mips(VP8DSPContext *dsp)
 {
-#if HAVE_MMI
-    vp8dsp_init_mmi(dsp);
-#endif /* HAVE_MMI */
-#if HAVE_MSA
-    vp8dsp_init_msa(dsp);
-#endif  // #if HAVE_MSA
+    int cpu_flags = av_get_cpu_flags();
+
+    if (have_mmi(cpu_flags)) {
+        dsp->vp8_luma_dc_wht    = ff_vp8_luma_dc_wht_mmi;
+        dsp->vp8_luma_dc_wht_dc = ff_vp8_luma_dc_wht_dc_mmi;
+        dsp->vp8_idct_add       = ff_vp8_idct_add_mmi;
+        dsp->vp8_idct_dc_add    = ff_vp8_idct_dc_add_mmi;
+        dsp->vp8_idct_dc_add4y  = ff_vp8_idct_dc_add4y_mmi;
+        dsp->vp8_idct_dc_add4uv = ff_vp8_idct_dc_add4uv_mmi;
+
+        dsp->put_vp8_epel_pixels_tab[0][0][1] = ff_put_vp8_epel16_h4_mmi;
+        dsp->put_vp8_epel_pixels_tab[0][0][2] = ff_put_vp8_epel16_h6_mmi;
+        dsp->put_vp8_epel_pixels_tab[0][1][0] = ff_put_vp8_epel16_v4_mmi;
+        dsp->put_vp8_epel_pixels_tab[0][1][1] = ff_put_vp8_epel16_h4v4_mmi;
+        dsp->put_vp8_epel_pixels_tab[0][1][2] = ff_put_vp8_epel16_h6v4_mmi;
+        dsp->put_vp8_epel_pixels_tab[0][2][0] = ff_put_vp8_epel16_v6_mmi;
+        dsp->put_vp8_epel_pixels_tab[0][2][1] = ff_put_vp8_epel16_h4v6_mmi;
+        dsp->put_vp8_epel_pixels_tab[0][2][2] = ff_put_vp8_epel16_h6v6_mmi;
+
+        dsp->put_vp8_epel_pixels_tab[1][0][1] = ff_put_vp8_epel8_h4_mmi;
+        dsp->put_vp8_epel_pixels_tab[1][0][2] = ff_put_vp8_epel8_h6_mmi;
+        dsp->put_vp8_epel_pixels_tab[1][1][0] = ff_put_vp8_epel8_v4_mmi;
+        dsp->put_vp8_epel_pixels_tab[1][1][1] = ff_put_vp8_epel8_h4v4_mmi;
+        dsp->put_vp8_epel_pixels_tab[1][1][2] = ff_put_vp8_epel8_h6v4_mmi;
+        dsp->put_vp8_epel_pixels_tab[1][2][0] = ff_put_vp8_epel8_v6_mmi;
+        dsp->put_vp8_epel_pixels_tab[1][2][1] = ff_put_vp8_epel8_h4v6_mmi;
+        dsp->put_vp8_epel_pixels_tab[1][2][2] = ff_put_vp8_epel8_h6v6_mmi;
+
+        dsp->put_vp8_epel_pixels_tab[2][0][1] = ff_put_vp8_epel4_h4_mmi;
+        dsp->put_vp8_epel_pixels_tab[2][0][2] = ff_put_vp8_epel4_h6_mmi;
+        dsp->put_vp8_epel_pixels_tab[2][1][0] = ff_put_vp8_epel4_v4_mmi;
+        dsp->put_vp8_epel_pixels_tab[2][1][1] = ff_put_vp8_epel4_h4v4_mmi;
+        dsp->put_vp8_epel_pixels_tab[2][1][2] = ff_put_vp8_epel4_h6v4_mmi;
+        dsp->put_vp8_epel_pixels_tab[2][2][0] = ff_put_vp8_epel4_v6_mmi;
+        dsp->put_vp8_epel_pixels_tab[2][2][1] = ff_put_vp8_epel4_h4v6_mmi;
+        dsp->put_vp8_epel_pixels_tab[2][2][2] = ff_put_vp8_epel4_h6v6_mmi;
+
+        dsp->put_vp8_bilinear_pixels_tab[0][0][1] = ff_put_vp8_bilinear16_h_mmi;
+        dsp->put_vp8_bilinear_pixels_tab[0][0][2] = ff_put_vp8_bilinear16_h_mmi;
+        dsp->put_vp8_bilinear_pixels_tab[0][1][0] = ff_put_vp8_bilinear16_v_mmi;
+        dsp->put_vp8_bilinear_pixels_tab[0][1][1] = ff_put_vp8_bilinear16_hv_mmi;
+        dsp->put_vp8_bilinear_pixels_tab[0][1][2] = ff_put_vp8_bilinear16_hv_mmi;
+        dsp->put_vp8_bilinear_pixels_tab[0][2][0] = ff_put_vp8_bilinear16_v_mmi;
+        dsp->put_vp8_bilinear_pixels_tab[0][2][1] = ff_put_vp8_bilinear16_hv_mmi;
+        dsp->put_vp8_bilinear_pixels_tab[0][2][2] = ff_put_vp8_bilinear16_hv_mmi;
+
+        dsp->put_vp8_bilinear_pixels_tab[1][0][1] = ff_put_vp8_bilinear8_h_mmi;
+        dsp->put_vp8_bilinear_pixels_tab[1][0][2] = ff_put_vp8_bilinear8_h_mmi;
+        dsp->put_vp8_bilinear_pixels_tab[1][1][0] = ff_put_vp8_bilinear8_v_mmi;
+        dsp->put_vp8_bilinear_pixels_tab[1][1][1] = ff_put_vp8_bilinear8_hv_mmi;
+        dsp->put_vp8_bilinear_pixels_tab[1][1][2] = ff_put_vp8_bilinear8_hv_mmi;
+        dsp->put_vp8_bilinear_pixels_tab[1][2][0] = ff_put_vp8_bilinear8_v_mmi;
+        dsp->put_vp8_bilinear_pixels_tab[1][2][1] = ff_put_vp8_bilinear8_hv_mmi;
+        dsp->put_vp8_bilinear_pixels_tab[1][2][2] = ff_put_vp8_bilinear8_hv_mmi;
+
+        dsp->put_vp8_bilinear_pixels_tab[2][0][1] = ff_put_vp8_bilinear4_h_mmi;
+        dsp->put_vp8_bilinear_pixels_tab[2][0][2] = ff_put_vp8_bilinear4_h_mmi;
+        dsp->put_vp8_bilinear_pixels_tab[2][1][0] = ff_put_vp8_bilinear4_v_mmi;
+        dsp->put_vp8_bilinear_pixels_tab[2][1][1] = ff_put_vp8_bilinear4_hv_mmi;
+        dsp->put_vp8_bilinear_pixels_tab[2][1][2] = ff_put_vp8_bilinear4_hv_mmi;
+        dsp->put_vp8_bilinear_pixels_tab[2][2][0] = ff_put_vp8_bilinear4_v_mmi;
+        dsp->put_vp8_bilinear_pixels_tab[2][2][1] = ff_put_vp8_bilinear4_hv_mmi;
+        dsp->put_vp8_bilinear_pixels_tab[2][2][2] = ff_put_vp8_bilinear4_hv_mmi;
+
+        dsp->put_vp8_epel_pixels_tab[0][0][0]     = ff_put_vp8_pixels16_mmi;
+        dsp->put_vp8_bilinear_pixels_tab[0][0][0] = ff_put_vp8_pixels16_mmi;
+
+        dsp->put_vp8_epel_pixels_tab[1][0][0]     = ff_put_vp8_pixels8_mmi;
+        dsp->put_vp8_bilinear_pixels_tab[1][0][0] = ff_put_vp8_pixels8_mmi;
+
+        dsp->vp8_v_loop_filter16y = ff_vp8_v_loop_filter16_mmi;
+        dsp->vp8_h_loop_filter16y = ff_vp8_h_loop_filter16_mmi;
+        dsp->vp8_v_loop_filter8uv = ff_vp8_v_loop_filter8uv_mmi;
+        dsp->vp8_h_loop_filter8uv = ff_vp8_h_loop_filter8uv_mmi;
+
+        dsp->vp8_v_loop_filter16y_inner = ff_vp8_v_loop_filter16_inner_mmi;
+        dsp->vp8_h_loop_filter16y_inner = ff_vp8_h_loop_filter16_inner_mmi;
+        dsp->vp8_v_loop_filter8uv_inner = ff_vp8_v_loop_filter8uv_inner_mmi;
+        dsp->vp8_h_loop_filter8uv_inner = ff_vp8_h_loop_filter8uv_inner_mmi;
+
+        dsp->vp8_v_loop_filter_simple = ff_vp8_v_loop_filter_simple_mmi;
+        dsp->vp8_h_loop_filter_simple = ff_vp8_h_loop_filter_simple_mmi;
+    }
+
+    if (have_msa(cpu_flags)) {
+        dsp->vp8_luma_dc_wht = ff_vp8_luma_dc_wht_msa;
+        dsp->vp8_idct_add = ff_vp8_idct_add_msa;
+        dsp->vp8_idct_dc_add = ff_vp8_idct_dc_add_msa;
+        dsp->vp8_idct_dc_add4y = ff_vp8_idct_dc_add4y_msa;
+        dsp->vp8_idct_dc_add4uv = ff_vp8_idct_dc_add4uv_msa;
+
+        VP8_MC_MIPS_FUNC(0, 16);
+        VP8_MC_MIPS_FUNC(1, 8);
+        VP8_MC_MIPS_FUNC(2, 4);
+
+        VP8_BILINEAR_MC_MIPS_FUNC(0, 16);
+        VP8_BILINEAR_MC_MIPS_FUNC(1, 8);
+        VP8_BILINEAR_MC_MIPS_FUNC(2, 4);
+
+        VP8_MC_MIPS_COPY(0, 16);
+        VP8_MC_MIPS_COPY(1, 8);
+
+        dsp->vp8_v_loop_filter16y = ff_vp8_v_loop_filter16_msa;
+        dsp->vp8_h_loop_filter16y = ff_vp8_h_loop_filter16_msa;
+        dsp->vp8_v_loop_filter8uv = ff_vp8_v_loop_filter8uv_msa;
+        dsp->vp8_h_loop_filter8uv = ff_vp8_h_loop_filter8uv_msa;
+
+        dsp->vp8_v_loop_filter16y_inner = ff_vp8_v_loop_filter16_inner_msa;
+        dsp->vp8_h_loop_filter16y_inner = ff_vp8_h_loop_filter16_inner_msa;
+        dsp->vp8_v_loop_filter8uv_inner = ff_vp8_v_loop_filter8uv_inner_msa;
+        dsp->vp8_h_loop_filter8uv_inner = ff_vp8_h_loop_filter8uv_inner_msa;
+
+        dsp->vp8_v_loop_filter_simple = ff_vp8_v_loop_filter_simple_msa;
+        dsp->vp8_h_loop_filter_simple = ff_vp8_h_loop_filter_simple_msa;
+    }
 }
diff --git a/libavcodec/mips/vp9dsp_init_mips.c b/libavcodec/mips/vp9dsp_init_mips.c
index 5990fa6952..5a8c599e7e 100644
--- a/libavcodec/mips/vp9dsp_init_mips.c
+++ b/libavcodec/mips/vp9dsp_init_mips.c
@@ -18,6 +18,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/mips/cpu.h"
 #include "config.h"
 #include "libavutil/common.h"
 #include "libavcodec/vp9dsp.h"
@@ -209,10 +210,17 @@ static av_cold void vp9dsp_init_mmi(VP9DSPContext *dsp, int bpp)
 
 av_cold void ff_vp9dsp_init_mips(VP9DSPContext *dsp, int bpp)
 {
+#if HAVE_MSA || HAVE_MMI
+    int cpu_flags = av_get_cpu_flags();
+#endif
+
 #if HAVE_MMI
-    vp9dsp_init_mmi(dsp, bpp);
-#endif  // #if HAVE_MMI
+    if (have_mmi(cpu_flags))
+        vp9dsp_init_mmi(dsp, bpp);
+#endif
+
 #if HAVE_MSA
-    vp9dsp_init_msa(dsp, bpp);
-#endif  // #if HAVE_MSA
+    if (have_msa(cpu_flags))
+        vp9dsp_init_msa(dsp, bpp);
+#endif
 }
diff --git a/libavcodec/mips/wmv2dsp_init_mips.c b/libavcodec/mips/wmv2dsp_init_mips.c
index 51dd2078d9..af1400731a 100644
--- a/libavcodec/mips/wmv2dsp_init_mips.c
+++ b/libavcodec/mips/wmv2dsp_init_mips.c
@@ -18,21 +18,17 @@
  * 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 "wmv2dsp_mips.h"
 
-#if HAVE_MMI
-static av_cold void wmv2dsp_init_mmi(WMV2DSPContext *c)
-{
-    c->idct_add  = ff_wmv2_idct_add_mmi;
-    c->idct_put  = ff_wmv2_idct_put_mmi;
-}
-#endif /* HAVE_MMI */
-
 av_cold void ff_wmv2dsp_init_mips(WMV2DSPContext *c)
 {
-#if HAVE_MMI
-    wmv2dsp_init_mmi(c);
-#endif /* HAVE_MMI */
+    int cpu_flags = av_get_cpu_flags();
+
+    if (have_mmi(cpu_flags)) {
+        c->idct_add  = ff_wmv2_idct_add_mmi;
+        c->idct_put  = ff_wmv2_idct_put_mmi;
+    }
 }
diff --git a/libavcodec/mips/wmv2dsp_mips.h b/libavcodec/mips/wmv2dsp_mips.h
index 22894c505d..f7313460fb 100644
--- a/libavcodec/mips/wmv2dsp_mips.h
+++ b/libavcodec/mips/wmv2dsp_mips.h
@@ -23,7 +23,7 @@
 
 #include "libavcodec/wmv2dsp.h"
 
-void ff_wmv2_idct_add_mmi(uint8_t *dest, int line_size, int16_t *block);
-void ff_wmv2_idct_put_mmi(uint8_t *dest, int line_size, int16_t *block);
+void ff_wmv2_idct_add_mmi(uint8_t *dest, long int line_size, int16_t *block);
+void ff_wmv2_idct_put_mmi(uint8_t *dest, long int line_size, int16_t *block);
 
 #endif /* AVCODEC_MIPS_WMV2DSP_MIPS_H */
diff --git a/libavcodec/mips/wmv2dsp_mmi.c b/libavcodec/mips/wmv2dsp_mmi.c
index 1f6ccb299b..8796ebe195 100644
--- a/libavcodec/mips/wmv2dsp_mmi.c
+++ b/libavcodec/mips/wmv2dsp_mmi.c
@@ -95,7 +95,7 @@ static void wmv2_idct_col_mmi(short * b)
     b[56] = (a0 + a2 - a1 - a5 + 8192) >> 14;
 }
 
-void ff_wmv2_idct_add_mmi(uint8_t *dest, int line_size, int16_t *block)
+void ff_wmv2_idct_add_mmi(uint8_t *dest, long int line_size, int16_t *block)
 {
     int i;
     double ftmp[11];
@@ -212,7 +212,7 @@ void ff_wmv2_idct_add_mmi(uint8_t *dest, int line_size, int16_t *block)
     );
 }
 
-void ff_wmv2_idct_put_mmi(uint8_t *dest, int line_size, int16_t *block)
+void ff_wmv2_idct_put_mmi(uint8_t *dest, long int line_size, int16_t *block)
 {
     int i;
     double ftmp[8];
diff --git a/libavcodec/mips/xvididct_init_mips.c b/libavcodec/mips/xvididct_init_mips.c
index c1d82cc30c..ed545cfe17 100644
--- a/libavcodec/mips/xvididct_init_mips.c
+++ b/libavcodec/mips/xvididct_init_mips.c
@@ -18,28 +18,23 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/mips/cpu.h"
 #include "xvididct_mips.h"
 
-#if HAVE_MMI
-static av_cold void xvid_idct_init_mmi(IDCTDSPContext *c, AVCodecContext *avctx,
+av_cold void ff_xvid_idct_init_mips(IDCTDSPContext *c, AVCodecContext *avctx,
         unsigned high_bit_depth)
 {
-    if (!high_bit_depth) {
-        if (avctx->idct_algo == FF_IDCT_AUTO ||
-                avctx->idct_algo == FF_IDCT_XVID) {
-            c->idct_put = ff_xvid_idct_put_mmi;
-            c->idct_add = ff_xvid_idct_add_mmi;
-            c->idct = ff_xvid_idct_mmi;
-            c->perm_type = FF_IDCT_PERM_NONE;
+    int cpu_flags = av_get_cpu_flags();
+
+    if (have_mmi(cpu_flags)) {
+        if (!high_bit_depth) {
+            if (avctx->idct_algo == FF_IDCT_AUTO ||
+                    avctx->idct_algo == FF_IDCT_XVID) {
+                c->idct_put = ff_xvid_idct_put_mmi;
+                c->idct_add = ff_xvid_idct_add_mmi;
+                c->idct = ff_xvid_idct_mmi;
+                c->perm_type = FF_IDCT_PERM_NONE;
+            }
         }
     }
 }
-#endif /* HAVE_MMI */
-
-av_cold void ff_xvid_idct_init_mips(IDCTDSPContext *c, AVCodecContext *avctx,
-        unsigned high_bit_depth)
-{
-#if HAVE_MMI
-    xvid_idct_init_mmi(c, avctx, high_bit_depth);
-#endif /* HAVE_MMI */
-}
