FFmpeg
mpegvideoenc_mmi.c
Go to the documentation of this file.
1 /*
2  * Loongson SIMD optimized mpegvideo
3  *
4  * Copyright (c) 2015 Loongson Technology Corporation Limited
5  * Copyright (c) 2015 Zhou Xiaoyong <zhouxiaoyong@loongson.cn>
6  * Zhang Shuangshuang <zhangshuangshuang@ict.ac.cn>
7  *
8  * This file is part of FFmpeg.
9  *
10  * FFmpeg is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 2.1 of the License, or (at your option) any later version.
14  *
15  * FFmpeg is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with FFmpeg; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23  */
24 
25 #include "mpegvideo_mips.h"
27 
29 {
30  const int intra = s->mb_intra;
31  int *sum = s->dct_error_sum[intra];
32  uint16_t *offset = s->dct_offset[intra];
33  double ftmp[8];
34  mips_reg addr[1];
36 
37  s->dct_count[intra]++;
38 
39  __asm__ volatile(
40  "pxor %[ftmp0], %[ftmp0], %[ftmp0] \n\t"
41  "1: \n\t"
42  MMI_LDC1(%[ftmp1], %[block], 0x00)
43  "pxor %[ftmp2], %[ftmp2], %[ftmp2] \n\t"
44  MMI_LDC1(%[ftmp3], %[block], 0x08)
45  "pxor %[ftmp4], %[ftmp4], %[ftmp4] \n\t"
46  "pcmpgth %[ftmp2], %[ftmp2], %[ftmp1] \n\t"
47  "pcmpgth %[ftmp4], %[ftmp4], %[ftmp3] \n\t"
48  "pxor %[ftmp1], %[ftmp1], %[ftmp2] \n\t"
49  "pxor %[ftmp3], %[ftmp3], %[ftmp4] \n\t"
50  "psubh %[ftmp1], %[ftmp1], %[ftmp2] \n\t"
51  "psubh %[ftmp3], %[ftmp3], %[ftmp4] \n\t"
52  MMI_LDC1(%[ftmp6], %[offset], 0x00)
53  "mov.d %[ftmp5], %[ftmp1] \n\t"
54  "psubush %[ftmp1], %[ftmp1], %[ftmp6] \n\t"
55  MMI_LDC1(%[ftmp6], %[offset], 0x08)
56  "mov.d %[ftmp7], %[ftmp3] \n\t"
57  "psubush %[ftmp3], %[ftmp3], %[ftmp6] \n\t"
58  "pxor %[ftmp1], %[ftmp1], %[ftmp2] \n\t"
59  "pxor %[ftmp3], %[ftmp3], %[ftmp4] \n\t"
60  "psubh %[ftmp1], %[ftmp1], %[ftmp2] \n\t"
61  "psubh %[ftmp3], %[ftmp3], %[ftmp4] \n\t"
62  MMI_SDC1(%[ftmp1], %[block], 0x00)
63  MMI_SDC1(%[ftmp3], %[block], 0x08)
64  "mov.d %[ftmp1], %[ftmp5] \n\t"
65  "mov.d %[ftmp3], %[ftmp7] \n\t"
66  "punpcklhw %[ftmp5], %[ftmp5], %[ftmp0] \n\t"
67  "punpckhhw %[ftmp1], %[ftmp1], %[ftmp0] \n\t"
68  "punpcklhw %[ftmp7], %[ftmp7], %[ftmp0] \n\t"
69  "punpckhhw %[ftmp3], %[ftmp3], %[ftmp0] \n\t"
70  MMI_LDC1(%[ftmp2], %[sum], 0x00)
71  "paddw %[ftmp5], %[ftmp5], %[ftmp2] \n\t"
72  MMI_LDC1(%[ftmp2], %[sum], 0x08)
73  "paddw %[ftmp1], %[ftmp1], %[ftmp2] \n\t"
74  MMI_LDC1(%[ftmp2], %[sum], 0x10)
75  "paddw %[ftmp7], %[ftmp7], %[ftmp2] \n\t"
76  MMI_LDC1(%[ftmp2], %[sum], 0x18)
77  "paddw %[ftmp3], %[ftmp3], %[ftmp2] \n\t"
78  MMI_SDC1(%[ftmp5], %[sum], 0x00)
79  MMI_SDC1(%[ftmp1], %[sum], 0x08)
80  MMI_SDC1(%[ftmp7], %[sum], 0x10)
81  MMI_SDC1(%[ftmp3], %[sum], 0x18)
82  PTR_ADDIU "%[block], %[block], 0x10 \n\t"
83  PTR_ADDIU "%[sum], %[sum], 0x20 \n\t"
84  PTR_SUBU "%[addr0], %[block1], %[block] \n\t"
85  PTR_ADDIU "%[offset], %[offset], 0x10 \n\t"
86  "bgtz %[addr0], 1b \n\t"
87  : [ftmp0]"=&f"(ftmp[0]), [ftmp1]"=&f"(ftmp[1]),
88  [ftmp2]"=&f"(ftmp[2]), [ftmp3]"=&f"(ftmp[3]),
89  [ftmp4]"=&f"(ftmp[4]), [ftmp5]"=&f"(ftmp[5]),
90  [ftmp6]"=&f"(ftmp[6]), [ftmp7]"=&f"(ftmp[7]),
92  [addr0]"=&r"(addr[0]),
93  [block]"+&r"(block), [sum]"+&r"(sum),
94  [offset]"+&r"(offset)
95  : [block1]"r"(block+64)
96  : "memory"
97  );
98 }
ff_denoise_dct_mmi
void ff_denoise_dct_mmi(MpegEncContext *s, int16_t *block)
Definition: mpegvideoenc_mmi.c:28
mips_reg
#define mips_reg
Definition: asmdefs.h:46
mmiutils.h
s
#define s(width, name)
Definition: cbs_vp9.c:198
block1
static int16_t block1[64]
Definition: dct.c:120
PTR_SUBU
#define PTR_SUBU
Definition: asmdefs.h:52
DECLARE_VAR_ALL64
#define DECLARE_VAR_ALL64
Definition: mmiutils.h:39
offset
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
Definition: writing_filters.txt:86
mpegvideo_mips.h
__asm__
__asm__(".macro parse_r var r\n\t" "\\var = -1\n\t" _IFC_REG(0) _IFC_REG(1) _IFC_REG(2) _IFC_REG(3) _IFC_REG(4) _IFC_REG(5) _IFC_REG(6) _IFC_REG(7) _IFC_REG(8) _IFC_REG(9) _IFC_REG(10) _IFC_REG(11) _IFC_REG(12) _IFC_REG(13) _IFC_REG(14) _IFC_REG(15) _IFC_REG(16) _IFC_REG(17) _IFC_REG(18) _IFC_REG(19) _IFC_REG(20) _IFC_REG(21) _IFC_REG(22) _IFC_REG(23) _IFC_REG(24) _IFC_REG(25) _IFC_REG(26) _IFC_REG(27) _IFC_REG(28) _IFC_REG(29) _IFC_REG(30) _IFC_REG(31) ".iflt \\var\n\t" ".error \"Unable to parse register name \\r\"\n\t" ".endif\n\t" ".endm")
PTR_ADDIU
#define PTR_ADDIU
Definition: asmdefs.h:50
block
The exact code depends on how similar the blocks are and how related they are to the block
Definition: filter_design.txt:207
RESTRICT_ASM_ALL64
#define RESTRICT_ASM_ALL64
Definition: mmiutils.h:40
MpegEncContext
MpegEncContext.
Definition: mpegvideo.h:73