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 Libav.
7 * Libav 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 * Libav 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 Libav; 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"
36 //FIXME use some macros to avoid duplicating get_cabac (cannot be done yet
37 //as that would make optimization work hard)
38 #if ARCH_X86 && HAVE_7REGS && !defined(BROKEN_RELOCATIONS)
39 static int decode_significance_x86(CABACContext *c, int max_coeff,
40 uint8_t *significant_coeff_ctx_base,
41 int *index, x86_reg last_off){
42 void *end= significant_coeff_ctx_base + max_coeff - 1;
43 int minusstart= -(int)significant_coeff_ctx_base;
44 int minusindex= 4-(int)index;
49 "movl %a10(%5), %%esi \n\t"
50 "movl %a11(%5), %3 \n\t"
54 BRANCHLESS_GET_CABAC("%4", "%5", "(%1)", "%3",
55 "%w3", "%%esi", "%k0", "%b0", "%a12")
61 BRANCHLESS_GET_CABAC("%4", "%5", "(%1)", "%3",
62 "%w3", "%%esi", "%k0", "%b0", "%a12")
67 "add %1, %%"REG_c" \n\t"
68 "movl %%ecx, (%0) \n\t"
82 "add %1, %%"REG_c" \n\t"
83 "movl %%ecx, (%0) \n\t"
88 "movl %%esi, %a10(%5) \n\t"
89 "movl %3, %a11(%5) \n\t"
90 :"=&r"(coeff_count), "+r"(significant_coeff_ctx_base), "+m"(index),
91 "=&r"(low), "=&r"(bit)
92 :"r"(c), "m"(minusstart), "m"(end), "m"(minusindex), "m"(last_off),
93 "i"(offsetof(CABACContext, range)), "i"(offsetof(CABACContext, low)),
94 "i"(offsetof(CABACContext, bytestream))
95 : "%"REG_c, "%esi", "memory"
100 static int decode_significance_8x8_x86(CABACContext *c,
101 uint8_t *significant_coeff_ctx_base,
102 int *index, x86_reg last_off, const uint8_t *sig_off){
103 int minusindex= 4-(int)index;
109 "movl %a10(%5), %%esi \n\t"
110 "movl %a11(%5), %3 \n\t"
112 "mov %1, %%"REG_D" \n\t"
116 "movzbl (%0, %%"REG_D"), %%edi \n\t"
117 "add %7, %%"REG_D" \n\t"
119 BRANCHLESS_GET_CABAC("%4", "%5", "(%%"REG_D")", "%3",
120 "%w3", "%%esi", "%k0", "%b0", "%a12")
126 "movzbl "MANGLE(last_coeff_flag_offset_8x8)"(%%edi), %%edi\n\t"
127 "add %7, %%"REG_D" \n\t"
128 "add %9, %%"REG_D" \n\t"
130 BRANCHLESS_GET_CABAC("%4", "%5", "(%%"REG_D")", "%3",
131 "%w3", "%%esi", "%k0", "%b0", "%a12")
135 "movl %%edi, (%0) \n\t"
144 "addl $1, %%edi \n\t"
146 "cmpl $63, %%edi \n\t"
149 "movl %%edi, (%0) \n\t"
154 "movl %%esi, %a10(%5) \n\t"
155 "movl %3, %a11(%5) \n\t"
156 :"=&r"(coeff_count),"+m"(last), "+m"(index), "=&r"(low), "=&r"(bit)
157 :"r"(c), "m"(minusindex), "m"(significant_coeff_ctx_base), "m"(sig_off), "m"(last_off),
158 "i"(offsetof(CABACContext, range)), "i"(offsetof(CABACContext, low)),
159 "i"(offsetof(CABACContext, bytestream))
160 : "%"REG_c, "%esi", "%"REG_D, "memory"
164 #endif /* ARCH_X86 && HAVE_7REGS && !defined(BROKEN_RELOCATIONS) */
166 #endif /* AVCODEC_X86_H264_I386_H */