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
23 * @file libavcodec/x86/h264_i386.h
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
32 #include "libavcodec/cabac.h"
34 //FIXME use some macros to avoid duplicating get_cabac (cannot be done yet
35 //as that would make optimization work hard)
36 #if ARCH_X86 && HAVE_7REGS && HAVE_EBX_AVAILABLE && !defined(BROKEN_RELOCATIONS)
37 static int decode_significance_x86(CABACContext
*c
, int max_coeff
,
38 uint8_t *significant_coeff_ctx_base
,
40 void *end
= significant_coeff_ctx_base
+ max_coeff
- 1;
41 int minusstart
= -(int)significant_coeff_ctx_base
;
42 int minusindex
= 4-(int)index
;
45 "movl "RANGE
"(%3), %%esi \n\t"
46 "movl "LOW
"(%3), %%ebx \n\t"
50 BRANCHLESS_GET_CABAC("%%edx", "%3", "(%1)", "%%ebx",
51 "%%bx", "%%esi", "%%eax", "%%al")
56 BRANCHLESS_GET_CABAC("%%edx", "%3", "61(%1)", "%%ebx",
57 "%%bx", "%%esi", "%%eax", "%%al")
59 "mov %2, %%"REG_a
" \n\t"
61 "add %1, %%"REG_c
" \n\t"
62 "movl %%ecx, (%%"REG_a
") \n\t"
67 "add $4, %%"REG_a
" \n\t"
68 "mov %%"REG_a
", %2 \n\t"
74 "mov %2, %%"REG_a
" \n\t"
76 "add %1, %%"REG_c
" \n\t"
77 "movl %%ecx, (%%"REG_a
") \n\t"
82 "movl %%esi, "RANGE
"(%3) \n\t"
83 "movl %%ebx, "LOW
"(%3) \n\t"
84 :"=&a"(coeff_count
), "+r"(significant_coeff_ctx_base
), "+m"(index
)
85 :"r"(c
), "m"(minusstart
), "m"(end
), "m"(minusindex
)
86 : "%"REG_c
, "%ebx", "%edx", "%esi", "memory"
91 static int decode_significance_8x8_x86(CABACContext
*c
,
92 uint8_t *significant_coeff_ctx_base
,
93 int *index
, const uint8_t *sig_off
){
94 int minusindex
= 4-(int)index
;
98 "movl "RANGE
"(%3), %%esi \n\t"
99 "movl "LOW
"(%3), %%ebx \n\t"
101 "mov %1, %%"REG_D
" \n\t"
104 "mov %6, %%"REG_a
" \n\t"
105 "movzbl (%%"REG_a
", %%"REG_D
"), %%edi \n\t"
106 "add %5, %%"REG_D
" \n\t"
108 BRANCHLESS_GET_CABAC("%%edx", "%3", "(%%"REG_D
")", "%%ebx",
109 "%%bx", "%%esi", "%%eax", "%%al")
112 "test $1, %%edx \n\t"
115 "movzbl "MANGLE(last_coeff_flag_offset_8x8
)"(%%edi), %%edi\n\t"
116 "add %5, %%"REG_D
" \n\t"
118 BRANCHLESS_GET_CABAC("%%edx", "%3", "15(%%"REG_D
")", "%%ebx",
119 "%%bx", "%%esi", "%%eax", "%%al")
121 "mov %2, %%"REG_a
" \n\t"
123 "movl %%edi, (%%"REG_a
") \n\t"
125 "test $1, %%edx \n\t"
128 "add $4, %%"REG_a
" \n\t"
129 "mov %%"REG_a
", %2 \n\t"
132 "addl $1, %%edi \n\t"
134 "cmpl $63, %%edi \n\t"
136 "mov %2, %%"REG_a
" \n\t"
137 "movl %%edi, (%%"REG_a
") \n\t"
139 "addl %4, %%eax \n\t"
142 "movl %%esi, "RANGE
"(%3) \n\t"
143 "movl %%ebx, "LOW
"(%3) \n\t"
144 :"=&a"(coeff_count
),"+m"(last
), "+m"(index
)
145 :"r"(c
), "m"(minusindex
), "m"(significant_coeff_ctx_base
), "m"(sig_off
)
146 : "%"REG_c
, "%ebx", "%edx", "%esi", "%"REG_D
, "memory"
150 #endif /* ARCH_X86 && HAVE_7REGS && HAVE_EBX_AVAILABLE */
151 /* !defined(BROKEN_RELOCATIONS) */
153 #endif /* AVCODEC_X86_H264_I386_H */