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"
37 //FIXME use some macros to avoid duplicating get_cabac (cannot be done yet
38 //as that would make optimization work hard)
39 #if ARCH_X86 && HAVE_7REGS && !defined(BROKEN_RELOCATIONS)
40 static int decode_significance_x86(CABACContext *c, int max_coeff,
41 uint8_t *significant_coeff_ctx_base,
42 int *index, x86_reg last_off){
43 void *end= significant_coeff_ctx_base + max_coeff - 1;
44 int minusstart= -(intptr_t)significant_coeff_ctx_base;
45 int minusindex= 4-(intptr_t)index;
51 "movl %a11(%6), %5 \n\t"
52 "movl %a12(%6), %3 \n\t"
56 BRANCHLESS_GET_CABAC("%4", "%6", "(%1)", "%3",
57 "%w3", "%5", "%k0", "%b0", "%a13")
63 BRANCHLESS_GET_CABAC("%4", "%6", "(%1)", "%3",
64 "%w3", "%5", "%k0", "%b0", "%a13")
69 "add %1, %%"REG_c" \n\t"
70 "movl %%ecx, (%0) \n\t"
84 "add %1, %%"REG_c" \n\t"
85 "movl %%ecx, (%0) \n\t"
90 "movl %5, %a11(%6) \n\t"
91 "movl %3, %a12(%6) \n\t"
92 :"=&q"(coeff_count), "+r"(significant_coeff_ctx_base), "+m"(index),
93 "=&r"(low), "=&r"(bit), "=&r"(range)
94 :"r"(c), "m"(minusstart), "m"(end), "m"(minusindex), "m"(last_off),
95 "i"(offsetof(CABACContext, range)), "i"(offsetof(CABACContext, low)),
96 "i"(offsetof(CABACContext, bytestream))
102 static int decode_significance_8x8_x86(CABACContext *c,
103 uint8_t *significant_coeff_ctx_base,
104 int *index, x86_reg last_off, const uint8_t *sig_off){
105 int minusindex= 4-(intptr_t)index;
113 "movl %a12(%7), %5 \n\t"
114 "movl %a13(%7), %3 \n\t"
120 "movzbl (%0, %6), %k6 \n\t"
123 BRANCHLESS_GET_CABAC("%4", "%7", "(%6)", "%3",
124 "%w3", "%5", "%k0", "%b0", "%a14")
130 "movzbl "MANGLE(last_coeff_flag_offset_8x8)"(%k6), %k6\n\t"
134 BRANCHLESS_GET_CABAC("%4", "%7", "(%6)", "%3",
135 "%w3", "%5", "%k0", "%b0", "%a14")
139 "movl %k6, (%0) \n\t"
153 "movl %k6, (%0) \n\t"
158 "movl %5, %a12(%7) \n\t"
159 "movl %3, %a13(%7) \n\t"
160 :"=&q"(coeff_count),"+m"(last), "+m"(index), "=&r"(low), "=&r"(bit),
161 "=&r"(range), "=&r"(state)
162 :"r"(c), "m"(minusindex), "m"(significant_coeff_ctx_base), "m"(sig_off), "m"(last_off),
163 "i"(offsetof(CABACContext, range)), "i"(offsetof(CABACContext, low)),
164 "i"(offsetof(CABACContext, bytestream))
169 #endif /* ARCH_X86 && HAVE_7REGS && !defined(BROKEN_RELOCATIONS) */
171 #endif /* AVCODEC_X86_H264_I386_H */