annotate armv4l/float_arm_vfp.c @ 7599:3c07ce8ac9f7 libavcodec

fix and simplify frame size check and reencoding in verbatim mode
author jbr
date Sun, 17 Aug 2008 16:10:46 +0000
parents 9e5b6bf87f76
children eebc7209c47f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7060
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
1 /*
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
2 * Copyright (c) 2008 Siarhei Siamashka <ssvb@users.sourceforge.net>
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
3 *
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
4 * This file is part of FFmpeg.
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
5 *
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
6 * FFmpeg is free software; you can redistribute it and/or
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
7 * modify it under the terms of the GNU Lesser General Public
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
8 * License as published by the Free Software Foundation; either
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
9 * version 2.1 of the License, or (at your option) any later version.
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
10 *
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
11 * FFmpeg is distributed in the hope that it will be useful,
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
14 * Lesser General Public License for more details.
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
15 *
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
16 * You should have received a copy of the GNU Lesser General Public
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
17 * License along with FFmpeg; if not, write to the Free Software
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
19 */
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
20
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
21 #include "libavcodec/dsputil.h"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
22
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
23 /*
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
24 * VFP is a floating point coprocessor used in some ARM cores. VFP11 has 1 cycle
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
25 * throughput for almost all the instructions (except for double precision
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
26 * arithmetics), but rather high latency. Latency is 4 cycles for loads and 8 cycles
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
27 * for arithmetic operations. Scheduling code to avoid pipeline stalls is very
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
28 * important for performance. One more interesting feature is that VFP has
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
29 * independent load/store and arithmetics pipelines, so it is possible to make
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
30 * them work simultaneously and get more than 1 operation per cycle. Load/store
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
31 * pipeline can process 2 single precision floating point values per cycle and
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
32 * supports bulk loads and stores for large sets of registers. Arithmetic operations
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
33 * can be done on vectors, which allows to keep the arithmetics pipeline busy,
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
34 * while the processor may issue and execute other instructions. Detailed
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
35 * optimization manuals can be found at http://www.arm.com
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
36 */
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
37
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
38 /**
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
39 * ARM VFP optimized implementation of 'vector_fmul_c' function.
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
40 * Assume that len is a positive number and is multiple of 8
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
41 */
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
42 static void vector_fmul_vfp(float *dst, const float *src, int len)
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
43 {
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
44 int tmp;
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
45 asm volatile(
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
46 "fmrx %[tmp], fpscr\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
47 "orr %[tmp], %[tmp], #(3 << 16)\n\t" /* set vector size to 4 */
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
48 "fmxr fpscr, %[tmp]\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
49
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
50 "fldmias %[dst_r]!, {s0-s3}\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
51 "fldmias %[src]!, {s8-s11}\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
52 "fldmias %[dst_r]!, {s4-s7}\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
53 "fldmias %[src]!, {s12-s15}\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
54 "fmuls s8, s0, s8\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
55 "1:\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
56 "subs %[len], %[len], #16\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
57 "fmuls s12, s4, s12\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
58 "fldmiasge %[dst_r]!, {s16-s19}\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
59 "fldmiasge %[src]!, {s24-s27}\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
60 "fldmiasge %[dst_r]!, {s20-s23}\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
61 "fldmiasge %[src]!, {s28-s31}\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
62 "fmulsge s24, s16, s24\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
63 "fstmias %[dst_w]!, {s8-s11}\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
64 "fstmias %[dst_w]!, {s12-s15}\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
65 "fmulsge s28, s20, s28\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
66 "fldmiasgt %[dst_r]!, {s0-s3}\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
67 "fldmiasgt %[src]!, {s8-s11}\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
68 "fldmiasgt %[dst_r]!, {s4-s7}\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
69 "fldmiasgt %[src]!, {s12-s15}\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
70 "fmulsge s8, s0, s8\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
71 "fstmiasge %[dst_w]!, {s24-s27}\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
72 "fstmiasge %[dst_w]!, {s28-s31}\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
73 "bgt 1b\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
74
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
75 "bic %[tmp], %[tmp], #(7 << 16)\n\t" /* set vector size back to 1 */
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
76 "fmxr fpscr, %[tmp]\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
77 : [dst_w] "+&r" (dst), [dst_r] "+&r" (dst), [src] "+&r" (src), [len] "+&r" (len), [tmp] "=&r" (tmp)
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
78 :
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
79 : "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7",
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
80 "s8", "s9", "s10", "s11", "s12", "s13", "s14", "s15",
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
81 "s16", "s17", "s18", "s19", "s20", "s21", "s22", "s23",
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
82 "s24", "s25", "s26", "s27", "s28", "s29", "s30", "s31",
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
83 "cc", "memory");
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
84 }
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
85
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
86 /**
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
87 * ARM VFP optimized implementation of 'vector_fmul_reverse_c' function.
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
88 * Assume that len is a positive number and is multiple of 8
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
89 */
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
90 static void vector_fmul_reverse_vfp(float *dst, const float *src0, const float *src1, int len)
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
91 {
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
92 src1 += len;
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
93 asm volatile(
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
94 "fldmdbs %[src1]!, {s0-s3}\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
95 "fldmias %[src0]!, {s8-s11}\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
96 "fldmdbs %[src1]!, {s4-s7}\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
97 "fldmias %[src0]!, {s12-s15}\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
98 "fmuls s8, s3, s8\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
99 "fmuls s9, s2, s9\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
100 "fmuls s10, s1, s10\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
101 "fmuls s11, s0, s11\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
102 "1:\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
103 "subs %[len], %[len], #16\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
104 "fldmdbsge %[src1]!, {s16-s19}\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
105 "fmuls s12, s7, s12\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
106 "fldmiasge %[src0]!, {s24-s27}\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
107 "fmuls s13, s6, s13\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
108 "fldmdbsge %[src1]!, {s20-s23}\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
109 "fmuls s14, s5, s14\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
110 "fldmiasge %[src0]!, {s28-s31}\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
111 "fmuls s15, s4, s15\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
112 "fmulsge s24, s19, s24\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
113 "fldmdbsgt %[src1]!, {s0-s3}\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
114 "fmulsge s25, s18, s25\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
115 "fstmias %[dst]!, {s8-s13}\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
116 "fmulsge s26, s17, s26\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
117 "fldmiasgt %[src0]!, {s8-s11}\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
118 "fmulsge s27, s16, s27\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
119 "fmulsge s28, s23, s28\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
120 "fldmdbsgt %[src1]!, {s4-s7}\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
121 "fmulsge s29, s22, s29\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
122 "fstmias %[dst]!, {s14-s15}\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
123 "fmulsge s30, s21, s30\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
124 "fmulsge s31, s20, s31\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
125 "fmulsge s8, s3, s8\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
126 "fldmiasgt %[src0]!, {s12-s15}\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
127 "fmulsge s9, s2, s9\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
128 "fmulsge s10, s1, s10\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
129 "fstmiasge %[dst]!, {s24-s27}\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
130 "fmulsge s11, s0, s11\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
131 "fstmiasge %[dst]!, {s28-s31}\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
132 "bgt 1b\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
133
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
134 : [dst] "+&r" (dst), [src0] "+&r" (src0), [src1] "+&r" (src1), [len] "+&r" (len)
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
135 :
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
136 : "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7",
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
137 "s8", "s9", "s10", "s11", "s12", "s13", "s14", "s15",
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
138 "s16", "s17", "s18", "s19", "s20", "s21", "s22", "s23",
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
139 "s24", "s25", "s26", "s27", "s28", "s29", "s30", "s31",
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
140 "cc", "memory");
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
141 }
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
142
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
143 #ifdef HAVE_ARMV6
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
144 /**
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
145 * ARM VFP optimized float to int16 conversion.
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
146 * Assume that len is a positive number and is multiple of 8, destination
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
147 * buffer is at least 4 bytes aligned (8 bytes alignment is better for
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
148 * performance), little endian byte sex
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
149 */
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
150 void float_to_int16_vfp(int16_t *dst, const float *src, int len)
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
151 {
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
152 asm volatile(
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
153 "fldmias %[src]!, {s16-s23}\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
154 "ftosis s0, s16\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
155 "ftosis s1, s17\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
156 "ftosis s2, s18\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
157 "ftosis s3, s19\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
158 "ftosis s4, s20\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
159 "ftosis s5, s21\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
160 "ftosis s6, s22\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
161 "ftosis s7, s23\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
162 "1:\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
163 "subs %[len], %[len], #8\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
164 "fmrrs r3, r4, {s0, s1}\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
165 "fmrrs r5, r6, {s2, s3}\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
166 "fmrrs r7, r8, {s4, s5}\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
167 "fmrrs ip, lr, {s6, s7}\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
168 "fldmiasgt %[src]!, {s16-s23}\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
169 "ssat r4, #16, r4\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
170 "ssat r3, #16, r3\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
171 "ssat r6, #16, r6\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
172 "ssat r5, #16, r5\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
173 "pkhbt r3, r3, r4, lsl #16\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
174 "pkhbt r4, r5, r6, lsl #16\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
175 "ftosisgt s0, s16\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
176 "ftosisgt s1, s17\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
177 "ftosisgt s2, s18\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
178 "ftosisgt s3, s19\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
179 "ftosisgt s4, s20\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
180 "ftosisgt s5, s21\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
181 "ftosisgt s6, s22\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
182 "ftosisgt s7, s23\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
183 "ssat r8, #16, r8\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
184 "ssat r7, #16, r7\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
185 "ssat lr, #16, lr\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
186 "ssat ip, #16, ip\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
187 "pkhbt r5, r7, r8, lsl #16\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
188 "pkhbt r6, ip, lr, lsl #16\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
189 "stmia %[dst]!, {r3-r6}\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
190 "bgt 1b\n\t"
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
191
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
192 : [dst] "+&r" (dst), [src] "+&r" (src), [len] "+&r" (len)
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
193 :
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
194 : "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7",
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
195 "s16", "s17", "s18", "s19", "s20", "s21", "s22", "s23",
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
196 "r3", "r4", "r5", "r6", "r7", "r8", "ip", "lr",
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
197 "cc", "memory");
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
198 }
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
199 #endif
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
200
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
201 void ff_float_init_arm_vfp(DSPContext* c, AVCodecContext *avctx)
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
202 {
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
203 c->vector_fmul = vector_fmul_vfp;
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
204 c->vector_fmul_reverse = vector_fmul_reverse_vfp;
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
205 #ifdef HAVE_ARMV6
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
206 c->float_to_int16 = float_to_int16_vfp;
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
207 #endif
9e5b6bf87f76 convert DOS-style carriage return to Unix-style
gpoirier
parents: 6786
diff changeset
208 }