OSDN Git Service

Merge remote-tracking branch 'qatar/master'
[coroid/ffmpeg_saccubus.git] / libavcodec / arm / mpegvideo_armv5te_s.S
1 /*
2  * Optimization of some functions from mpegvideo.c for armv5te
3  * Copyright (c) 2007 Siarhei Siamashka <ssvb@users.sourceforge.net>
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 "asm.S"
24
25 /*
26  * Special optimized version of dct_unquantize_h263_helper_c, it
27  * requires the block to be at least 8 bytes aligned, and may process
28  * more elements than requested.  But it is guaranteed to never
29  * process more than 64 elements provided that count argument is <= 64,
30  * so it is safe. This function is optimized for a common distribution
31  * of values for nCoeffs (they are mostly multiple of 8 plus one or
32  * two extra elements). So this function processes data as 8 elements
33  * per loop iteration and contains optional 2 elements processing in
34  * the end.
35  *
36  * Inner loop should take 6 cycles per element on arm926ej-s (Nokia 770)
37  */
38
39 .macro  dequant_t       dst, src, mul, add, tmp
40         rsbs            \tmp, ip, \src, asr #16
41         addgt           \tmp, \add, #0
42         rsblt           \tmp, \add, #0
43         smlatbne        \dst, \src, \mul, \tmp
44 .endm
45
46 .macro  dequant_b       dst, src, mul, add, tmp
47         rsbs            \tmp, ip, \src, lsl #16
48         addgt           \tmp, \add, #0
49         rsblt           \tmp, \add, #0
50         smlabbne        \dst, \src, \mul, \tmp
51 .endm
52
53 function ff_dct_unquantize_h263_armv5te, export=1
54         push            {r4-r9,lr}
55         mov             ip, #0
56         subs            r3, r3, #2
57         ble             2f
58         ldrd            r4, [r0, #0]
59 1:
60         ldrd            r6, [r0, #8]
61
62         dequant_t       r9, r4, r1, r2, r9
63         dequant_t       lr, r5, r1, r2, lr
64         dequant_b       r4, r4, r1, r2, r8
65         dequant_b       r5, r5, r1, r2, r8
66
67         strh            r4, [r0], #2
68         strh            r9, [r0], #2
69         strh            r5, [r0], #2
70         strh            lr, [r0], #2
71
72         dequant_t       r9, r6, r1, r2, r9
73         dequant_t       lr, r7, r1, r2, lr
74         dequant_b       r6, r6, r1, r2, r8
75         dequant_b       r7, r7, r1, r2, r8
76
77         strh            r6, [r0], #2
78         strh            r9, [r0], #2
79         strh            r7, [r0], #2
80         strh            lr, [r0], #2
81
82         subs            r3, r3, #8
83         ldrdgt          r4, [r0, #0] /* load data early to avoid load/use pipeline stall */
84         bgt             1b
85
86         adds            r3, r3, #2
87         pople           {r4-r9,pc}
88 2:
89         ldrsh           r9, [r0, #0]
90         ldrsh           lr, [r0, #2]
91         mov             r8, r2
92         cmp             r9, #0
93         rsblt           r8, r2, #0
94         smlabbne        r9, r9, r1, r8
95         mov             r8, r2
96         cmp             lr, #0
97         rsblt           r8, r2, #0
98         smlabbne        lr, lr, r1, r8
99         strh            r9, [r0], #2
100         strh            lr, [r0], #2
101         pop             {r4-r9,pc}
102 endfunc