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