2 * H.26L/H.264/AVC/JVT/14496-10/... encoder/decoder
3 * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at>
5 * This file is part of FFmpeg.
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.
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.
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
24 * H.264 / AVC / MPEG4 part10 codec.
25 * non-MMX i386-specific optimizations for H.264
26 * @author Michael Niedermayer <michaelni@gmx.at>
29 #ifndef AVCODEC_X86_H264_I386_H
30 #define AVCODEC_X86_H264_I386_H
34 #include "libavcodec/cabac.h"
39 //FIXME use some macros to avoid duplicating get_cabac (cannot be done yet
40 //as that would make optimization work hard)
42 #define decode_significance decode_significance_x86
43 static int decode_significance_x86(CABACContext *c, int max_coeff,
44 uint8_t *significant_coeff_ctx_base,
45 int *index, x86_reg last_off){
46 void *end= significant_coeff_ctx_base + max_coeff - 1;
47 int minusstart= -(intptr_t)significant_coeff_ctx_base;
48 int minusindex= 4-(intptr_t)index;
52 #ifdef BROKEN_RELOCATIONS
56 "lea "MANGLE(ff_h264_cabac_tables)", %0 \n\t"
64 BRANCHLESS_GET_CABAC("%4", "%q4", "(%1)", "%3", "%w3",
65 "%5", "%q5", "%k0", "%b0",
66 "%a11(%6)", "%a12(%6)", "%a13", "%a14", "%a15", "%16")
72 BRANCHLESS_GET_CABAC("%4", "%q4", "(%1)", "%3", "%w3",
73 "%5", "%q5", "%k0", "%b0",
74 "%a11(%6)", "%a12(%6)", "%a13", "%a14", "%a15", "%16")
79 "add %1, %%"REG_c" \n\t"
80 "movl %%ecx, (%0) \n\t"
85 "add"OPSIZE" $4, %2 \n\t"
93 "add %1, %%"REG_c" \n\t"
94 "movl %%ecx, (%0) \n\t"
98 : "=&q"(coeff_count), "+r"(significant_coeff_ctx_base), "+m"(index),
99 "+&r"(c->low), "=&r"(bit), "+&r"(c->range)
100 : "r"(c), "m"(minusstart), "m"(end), "m"(minusindex), "m"(last_off),
101 "i"(offsetof(CABACContext, bytestream)),
102 "i"(offsetof(CABACContext, bytestream_end)),
103 "i"(H264_NORM_SHIFT_OFFSET),
104 "i"(H264_LPS_RANGE_OFFSET),
105 "i"(H264_MLPS_STATE_OFFSET) TABLES_ARG
111 #define decode_significance_8x8 decode_significance_8x8_x86
112 static int decode_significance_8x8_x86(CABACContext *c,
113 uint8_t *significant_coeff_ctx_base,
114 int *index, uint8_t *last_coeff_ctx_base, const uint8_t *sig_off){
115 int minusindex= 4-(intptr_t)index;
121 #ifdef BROKEN_RELOCATIONS
125 "lea "MANGLE(ff_h264_cabac_tables)", %0 \n\t"
135 "movzbl (%0, %6), %k6 \n\t"
138 BRANCHLESS_GET_CABAC("%4", "%q4", "(%6)", "%3", "%w3",
139 "%5", "%q5", "%k0", "%b0",
140 "%a12(%7)", "%a13(%7)", "%a14", "%a15", "%a16", "%18")
146 #ifdef BROKEN_RELOCATIONS
147 "movzbl %a17(%18, %q6), %k6\n\t"
149 "movzbl "MANGLE(ff_h264_cabac_tables)"+%a17(%k6), %k6\n\t"
153 BRANCHLESS_GET_CABAC("%4", "%q4", "(%6)", "%3", "%w3",
154 "%5", "%q5", "%k0", "%b0",
155 "%a12(%7)", "%a13(%7)", "%a14", "%a15", "%a16", "%18")
159 "movl %k6, (%0) \n\t"
164 "add"OPSIZE" $4, %2 \n\t"
172 "movl %k6, (%0) \n\t"
176 : "=&q"(coeff_count), "+m"(last), "+m"(index), "+&r"(c->low),
177 "=&r"(bit), "+&r"(c->range), "=&r"(state)
178 : "r"(c), "m"(minusindex), "m"(significant_coeff_ctx_base),
179 "m"(sig_off), "m"(last_coeff_ctx_base),
180 "i"(offsetof(CABACContext, bytestream)),
181 "i"(offsetof(CABACContext, bytestream_end)),
182 "i"(H264_NORM_SHIFT_OFFSET),
183 "i"(H264_LPS_RANGE_OFFSET),
184 "i"(H264_MLPS_STATE_OFFSET),
185 "i"(H264_LAST_COEFF_FLAG_OFFSET_8x8_OFFSET) TABLES_ARG
190 #endif /* HAVE_7REGS && !defined(BROKEN_RELOCATIONS) */
192 #endif /* HAVE_INLINE_ASM */
193 #endif /* AVCODEC_X86_H264_I386_H */