1 /*
2 * Copyright (c) 2015 Manojkumar Bhosale (Manojkumar.Bhosale@imgtec.com)
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 #include "h263dsp_mips.h"
22 #include "libavutil/mips/generic_macros_msa.h"
23
sum_u8src_16width_msa(uint8_t * src,int32_t stride)24 static int32_t sum_u8src_16width_msa(uint8_t *src, int32_t stride)
25 {
26 uint32_t sum = 0;
27 v16u8 in0, in1, in2, in3, in4, in5, in6, in7;
28 v16u8 in8, in9, in10, in11, in12, in13, in14, in15;
29
30 LD_UB8(src, stride, in0, in1, in2, in3, in4, in5, in6, in7);
31 src += (8 * stride);
32 LD_UB8(src, stride, in8, in9, in10, in11, in12, in13, in14, in15);
33
34 HADD_UB4_UB(in0, in1, in2, in3, in0, in1, in2, in3);
35 HADD_UB4_UB(in4, in5, in6, in7, in4, in5, in6, in7);
36 HADD_UB4_UB(in8, in9, in10, in11, in8, in9, in10, in11);
37 HADD_UB4_UB(in12, in13, in14, in15, in12, in13, in14, in15);
38
39 sum = HADD_UH_U32(in0);
40 sum += HADD_UH_U32(in1);
41 sum += HADD_UH_U32(in2);
42 sum += HADD_UH_U32(in3);
43 sum += HADD_UH_U32(in4);
44 sum += HADD_UH_U32(in5);
45 sum += HADD_UH_U32(in6);
46 sum += HADD_UH_U32(in7);
47 sum += HADD_UH_U32(in8);
48 sum += HADD_UH_U32(in9);
49 sum += HADD_UH_U32(in10);
50 sum += HADD_UH_U32(in11);
51 sum += HADD_UH_U32(in12);
52 sum += HADD_UH_U32(in13);
53 sum += HADD_UH_U32(in14);
54 sum += HADD_UH_U32(in15);
55
56 return sum;
57 }
58
ff_pix_sum_msa(uint8_t * pix,int line_size)59 int ff_pix_sum_msa(uint8_t *pix, int line_size)
60 {
61 return sum_u8src_16width_msa(pix, line_size);
62 }
63