1
by Reinhard Tartler
Import upstream version 0.6.2 |
1 |
/*
|
2 |
* H.26L/H.264/AVC/JVT/14496-10/... encoder/decoder
|
|
3 |
* Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at>
|
|
4 |
*
|
|
1.1.1
by Reinhard Tartler
Import upstream version 0.7~b1 |
5 |
* This file is part of Libav.
|
1
by Reinhard Tartler
Import upstream version 0.6.2 |
6 |
*
|
1.1.1
by Reinhard Tartler
Import upstream version 0.7~b1 |
7 |
* Libav is free software; you can redistribute it and/or
|
1
by Reinhard Tartler
Import upstream version 0.6.2 |
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 |
*
|
|
1.1.1
by Reinhard Tartler
Import upstream version 0.7~b1 |
12 |
* Libav is distributed in the hope that it will be useful,
|
1
by Reinhard Tartler
Import upstream version 0.6.2 |
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
|
|
1.1.1
by Reinhard Tartler
Import upstream version 0.7~b1 |
18 |
* License along with Libav; if not, write to the Free Software
|
1
by Reinhard Tartler
Import upstream version 0.6.2 |
19 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
20 |
*/
|
|
21 |
||
22 |
/**
|
|
23 |
* @file
|
|
24 |
* H.264 / AVC / MPEG4 part10 codec.
|
|
25 |
* non-MMX i386-specific optimizations for H.264
|
|
26 |
* @author Michael Niedermayer <michaelni@gmx.at>
|
|
27 |
*/
|
|
28 |
||
29 |
#ifndef AVCODEC_X86_H264_I386_H
|
|
30 |
#define AVCODEC_X86_H264_I386_H
|
|
31 |
||
1.2.1
by Reinhard Tartler
Import upstream version 0.8~beta1 |
32 |
#include <stddef.h> |
33 |
||
1
by Reinhard Tartler
Import upstream version 0.6.2 |
34 |
#include "libavcodec/cabac.h" |
1.2.1
by Reinhard Tartler
Import upstream version 0.8~beta1 |
35 |
#include "cabac.h" |
1
by Reinhard Tartler
Import upstream version 0.6.2 |
36 |
|
1.1.12
by Reinhard Tartler
Import upstream version 9~beta1 |
37 |
#if HAVE_INLINE_ASM
|
38 |
||
1
by Reinhard Tartler
Import upstream version 0.6.2 |
39 |
//FIXME use some macros to avoid duplicating get_cabac (cannot be done yet
|
40 |
//as that would make optimization work hard)
|
|
1.1.11
by Reinhard Tartler
Import upstream version 0.8.99-1537-gacb2c79 |
41 |
#if HAVE_7REGS
|
1.1.12
by Reinhard Tartler
Import upstream version 9~beta1 |
42 |
#define decode_significance decode_significance_x86
|
1
by Reinhard Tartler
Import upstream version 0.6.2 |
43 |
static int decode_significance_x86(CABACContext *c, int max_coeff, |
44 |
uint8_t *significant_coeff_ctx_base, |
|
1.1.3
by Reinhard Tartler
Import upstream version 0.7~rc1 |
45 |
int *index, x86_reg last_off){ |
1
by Reinhard Tartler
Import upstream version 0.6.2 |
46 |
void *end= significant_coeff_ctx_base + max_coeff - 1; |
1.2.1
by Reinhard Tartler
Import upstream version 0.8~beta1 |
47 |
int minusstart= -(intptr_t)significant_coeff_ctx_base; |
48 |
int minusindex= 4-(intptr_t)index; |
|
49 |
int bit; |
|
50 |
x86_reg coeff_count; |
|
1.1.11
by Reinhard Tartler
Import upstream version 0.8.99-1537-gacb2c79 |
51 |
|
52 |
#ifdef BROKEN_RELOCATIONS
|
|
53 |
void *tables; |
|
54 |
||
55 |
__asm__ volatile( |
|
56 |
"lea "MANGLE(ff_h264_cabac_tables)", %0 \n\t" |
|
57 |
: "=&r"(tables) |
|
58 |
);
|
|
59 |
#endif
|
|
60 |
||
61 |
__asm__ volatile( |
|
62 |
"3: \n\t" |
|
63 |
||
64 |
BRANCHLESS_GET_CABAC("%4", "%q4", "(%1)", "%3", "%w3", |
|
65 |
"%5", "%q5", "%k0", "%b0", |
|
1.1.12
by Reinhard Tartler
Import upstream version 9~beta1 |
66 |
"%c11(%6)", "%c12(%6)", |
67 |
AV_STRINGIFY(H264_NORM_SHIFT_OFFSET), |
|
68 |
AV_STRINGIFY(H264_LPS_RANGE_OFFSET), |
|
69 |
AV_STRINGIFY(H264_MLPS_STATE_OFFSET), |
|
70 |
"%13") |
|
1
by Reinhard Tartler
Import upstream version 0.6.2 |
71 |
|
1.2.1
by Reinhard Tartler
Import upstream version 0.8~beta1 |
72 |
"test $1, %4 \n\t" |
1.1.11
by Reinhard Tartler
Import upstream version 0.8.99-1537-gacb2c79 |
73 |
" jz 4f \n\t" |
1.2.1
by Reinhard Tartler
Import upstream version 0.8~beta1 |
74 |
"add %10, %1 \n\t" |
75 |
||
1.1.11
by Reinhard Tartler
Import upstream version 0.8.99-1537-gacb2c79 |
76 |
BRANCHLESS_GET_CABAC("%4", "%q4", "(%1)", "%3", "%w3", |
77 |
"%5", "%q5", "%k0", "%b0", |
|
1.1.12
by Reinhard Tartler
Import upstream version 9~beta1 |
78 |
"%c11(%6)", "%c12(%6)", |
79 |
AV_STRINGIFY(H264_NORM_SHIFT_OFFSET), |
|
80 |
AV_STRINGIFY(H264_LPS_RANGE_OFFSET), |
|
81 |
AV_STRINGIFY(H264_MLPS_STATE_OFFSET), |
|
82 |
"%13") |
|
1.2.1
by Reinhard Tartler
Import upstream version 0.8~beta1 |
83 |
|
84 |
"sub %10, %1 \n\t" |
|
85 |
"mov %2, %0 \n\t" |
|
86 |
"movl %7, %%ecx \n\t" |
|
1
by Reinhard Tartler
Import upstream version 0.6.2 |
87 |
"add %1, %%"REG_c" \n\t" |
1.2.1
by Reinhard Tartler
Import upstream version 0.8~beta1 |
88 |
"movl %%ecx, (%0) \n\t" |
1
by Reinhard Tartler
Import upstream version 0.6.2 |
89 |
|
1.2.1
by Reinhard Tartler
Import upstream version 0.8~beta1 |
90 |
"test $1, %4 \n\t" |
1.1.11
by Reinhard Tartler
Import upstream version 0.8.99-1537-gacb2c79 |
91 |
" jnz 5f \n\t" |
1
by Reinhard Tartler
Import upstream version 0.6.2 |
92 |
|
1.2.1
by Reinhard Tartler
Import upstream version 0.8~beta1 |
93 |
"add"OPSIZE" $4, %2 \n\t" |
1
by Reinhard Tartler
Import upstream version 0.6.2 |
94 |
|
1.1.11
by Reinhard Tartler
Import upstream version 0.8.99-1537-gacb2c79 |
95 |
"4: \n\t" |
1
by Reinhard Tartler
Import upstream version 0.6.2 |
96 |
"add $1, %1 \n\t" |
1.2.1
by Reinhard Tartler
Import upstream version 0.8~beta1 |
97 |
"cmp %8, %1 \n\t" |
1.1.11
by Reinhard Tartler
Import upstream version 0.8.99-1537-gacb2c79 |
98 |
" jb 3b \n\t" |
1.2.1
by Reinhard Tartler
Import upstream version 0.8~beta1 |
99 |
"mov %2, %0 \n\t" |
100 |
"movl %7, %%ecx \n\t" |
|
1
by Reinhard Tartler
Import upstream version 0.6.2 |
101 |
"add %1, %%"REG_c" \n\t" |
1.2.1
by Reinhard Tartler
Import upstream version 0.8~beta1 |
102 |
"movl %%ecx, (%0) \n\t" |
1.1.11
by Reinhard Tartler
Import upstream version 0.8.99-1537-gacb2c79 |
103 |
"5: \n\t" |
1.2.1
by Reinhard Tartler
Import upstream version 0.8~beta1 |
104 |
"add %9, %k0 \n\t" |
105 |
"shr $2, %k0 \n\t" |
|
1.1.11
by Reinhard Tartler
Import upstream version 0.8.99-1537-gacb2c79 |
106 |
: "=&q"(coeff_count), "+r"(significant_coeff_ctx_base), "+m"(index), |
107 |
"+&r"(c->low), "=&r"(bit), "+&r"(c->range) |
|
108 |
: "r"(c), "m"(minusstart), "m"(end), "m"(minusindex), "m"(last_off), |
|
109 |
"i"(offsetof(CABACContext, bytestream)), |
|
1.1.12
by Reinhard Tartler
Import upstream version 9~beta1 |
110 |
"i"(offsetof(CABACContext, bytestream_end)) |
111 |
TABLES_ARG
|
|
1.2.1
by Reinhard Tartler
Import upstream version 0.8~beta1 |
112 |
: "%"REG_c, "memory" |
1
by Reinhard Tartler
Import upstream version 0.6.2 |
113 |
);
|
114 |
return coeff_count; |
|
115 |
}
|
|
116 |
||
1.1.12
by Reinhard Tartler
Import upstream version 9~beta1 |
117 |
#define decode_significance_8x8 decode_significance_8x8_x86
|
1
by Reinhard Tartler
Import upstream version 0.6.2 |
118 |
static int decode_significance_8x8_x86(CABACContext *c, |
119 |
uint8_t *significant_coeff_ctx_base, |
|
1.2.1
by Reinhard Tartler
Import upstream version 0.8~beta1 |
120 |
int *index, uint8_t *last_coeff_ctx_base, const uint8_t *sig_off){ |
121 |
int minusindex= 4-(intptr_t)index; |
|
122 |
int bit; |
|
123 |
x86_reg coeff_count; |
|
1
by Reinhard Tartler
Import upstream version 0.6.2 |
124 |
x86_reg last=0; |
1.2.1
by Reinhard Tartler
Import upstream version 0.8~beta1 |
125 |
x86_reg state; |
1.1.11
by Reinhard Tartler
Import upstream version 0.8.99-1537-gacb2c79 |
126 |
|
127 |
#ifdef BROKEN_RELOCATIONS
|
|
128 |
void *tables; |
|
129 |
||
130 |
__asm__ volatile( |
|
131 |
"lea "MANGLE(ff_h264_cabac_tables)", %0 \n\t" |
|
132 |
: "=&r"(tables) |
|
133 |
);
|
|
134 |
#endif
|
|
135 |
||
1
by Reinhard Tartler
Import upstream version 0.6.2 |
136 |
__asm__ volatile( |
1.2.1
by Reinhard Tartler
Import upstream version 0.8~beta1 |
137 |
"mov %1, %6 \n\t" |
1.1.11
by Reinhard Tartler
Import upstream version 0.8.99-1537-gacb2c79 |
138 |
"3: \n\t" |
1
by Reinhard Tartler
Import upstream version 0.6.2 |
139 |
|
1.2.1
by Reinhard Tartler
Import upstream version 0.8~beta1 |
140 |
"mov %10, %0 \n\t" |
141 |
"movzbl (%0, %6), %k6 \n\t" |
|
142 |
"add %9, %6 \n\t" |
|
143 |
||
1.1.11
by Reinhard Tartler
Import upstream version 0.8.99-1537-gacb2c79 |
144 |
BRANCHLESS_GET_CABAC("%4", "%q4", "(%6)", "%3", "%w3", |
145 |
"%5", "%q5", "%k0", "%b0", |
|
1.1.12
by Reinhard Tartler
Import upstream version 9~beta1 |
146 |
"%c12(%7)", "%c13(%7)", |
147 |
AV_STRINGIFY(H264_NORM_SHIFT_OFFSET), |
|
148 |
AV_STRINGIFY(H264_LPS_RANGE_OFFSET), |
|
149 |
AV_STRINGIFY(H264_MLPS_STATE_OFFSET), |
|
150 |
"%15") |
|
1.2.1
by Reinhard Tartler
Import upstream version 0.8~beta1 |
151 |
|
152 |
"mov %1, %k6 \n\t" |
|
153 |
"test $1, %4 \n\t" |
|
1.1.11
by Reinhard Tartler
Import upstream version 0.8.99-1537-gacb2c79 |
154 |
" jz 4f \n\t" |
1
by Reinhard Tartler
Import upstream version 0.6.2 |
155 |
|
1.1.11
by Reinhard Tartler
Import upstream version 0.8.99-1537-gacb2c79 |
156 |
#ifdef BROKEN_RELOCATIONS
|
1.1.12
by Reinhard Tartler
Import upstream version 9~beta1 |
157 |
"movzbl %c14(%15, %q6), %k6\n\t" |
1.1.11
by Reinhard Tartler
Import upstream version 0.8.99-1537-gacb2c79 |
158 |
#else
|
1.1.12
by Reinhard Tartler
Import upstream version 9~beta1 |
159 |
"movzbl "MANGLE(ff_h264_cabac_tables)"+%c14(%k6), %k6\n\t" |
1.1.11
by Reinhard Tartler
Import upstream version 0.8.99-1537-gacb2c79 |
160 |
#endif
|
1.2.1
by Reinhard Tartler
Import upstream version 0.8~beta1 |
161 |
"add %11, %6 \n\t" |
162 |
||
1.1.11
by Reinhard Tartler
Import upstream version 0.8.99-1537-gacb2c79 |
163 |
BRANCHLESS_GET_CABAC("%4", "%q4", "(%6)", "%3", "%w3", |
164 |
"%5", "%q5", "%k0", "%b0", |
|
1.1.12
by Reinhard Tartler
Import upstream version 9~beta1 |
165 |
"%c12(%7)", "%c13(%7)", |
166 |
AV_STRINGIFY(H264_NORM_SHIFT_OFFSET), |
|
167 |
AV_STRINGIFY(H264_LPS_RANGE_OFFSET), |
|
168 |
AV_STRINGIFY(H264_MLPS_STATE_OFFSET), |
|
169 |
"%15") |
|
1.2.1
by Reinhard Tartler
Import upstream version 0.8~beta1 |
170 |
|
171 |
"mov %2, %0 \n\t" |
|
172 |
"mov %1, %k6 \n\t" |
|
173 |
"movl %k6, (%0) \n\t" |
|
174 |
||
175 |
"test $1, %4 \n\t" |
|
1.1.11
by Reinhard Tartler
Import upstream version 0.8.99-1537-gacb2c79 |
176 |
" jnz 5f \n\t" |
1
by Reinhard Tartler
Import upstream version 0.6.2 |
177 |
|
1.2.1
by Reinhard Tartler
Import upstream version 0.8~beta1 |
178 |
"add"OPSIZE" $4, %2 \n\t" |
1
by Reinhard Tartler
Import upstream version 0.6.2 |
179 |
|
1.1.11
by Reinhard Tartler
Import upstream version 0.8.99-1537-gacb2c79 |
180 |
"4: \n\t" |
1.2.1
by Reinhard Tartler
Import upstream version 0.8~beta1 |
181 |
"addl $1, %k6 \n\t" |
182 |
"mov %k6, %1 \n\t" |
|
183 |
"cmpl $63, %k6 \n\t" |
|
1.1.11
by Reinhard Tartler
Import upstream version 0.8.99-1537-gacb2c79 |
184 |
" jb 3b \n\t" |
1.2.1
by Reinhard Tartler
Import upstream version 0.8~beta1 |
185 |
"mov %2, %0 \n\t" |
186 |
"movl %k6, (%0) \n\t" |
|
1.1.11
by Reinhard Tartler
Import upstream version 0.8.99-1537-gacb2c79 |
187 |
"5: \n\t" |
1.2.1
by Reinhard Tartler
Import upstream version 0.8~beta1 |
188 |
"addl %8, %k0 \n\t" |
189 |
"shr $2, %k0 \n\t" |
|
1.1.11
by Reinhard Tartler
Import upstream version 0.8.99-1537-gacb2c79 |
190 |
: "=&q"(coeff_count), "+m"(last), "+m"(index), "+&r"(c->low), |
191 |
"=&r"(bit), "+&r"(c->range), "=&r"(state) |
|
192 |
: "r"(c), "m"(minusindex), "m"(significant_coeff_ctx_base), |
|
193 |
"m"(sig_off), "m"(last_coeff_ctx_base), |
|
194 |
"i"(offsetof(CABACContext, bytestream)), |
|
195 |
"i"(offsetof(CABACContext, bytestream_end)), |
|
196 |
"i"(H264_LAST_COEFF_FLAG_OFFSET_8x8_OFFSET) TABLES_ARG |
|
1.2.1
by Reinhard Tartler
Import upstream version 0.8~beta1 |
197 |
: "%"REG_c, "memory" |
1
by Reinhard Tartler
Import upstream version 0.6.2 |
198 |
);
|
199 |
return coeff_count; |
|
200 |
}
|
|
1.2.1
by Reinhard Tartler
Import upstream version 0.8~beta1 |
201 |
#endif /* HAVE_7REGS && !defined(BROKEN_RELOCATIONS) */ |
1
by Reinhard Tartler
Import upstream version 0.6.2 |
202 |
|
1.1.12
by Reinhard Tartler
Import upstream version 9~beta1 |
203 |
#endif /* HAVE_INLINE_ASM */ |
1
by Reinhard Tartler
Import upstream version 0.6.2 |
204 |
#endif /* AVCODEC_X86_H264_I386_H */ |