00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00029 #ifndef AVCODEC_X86_H264_I386_H
00030 #define AVCODEC_X86_H264_I386_H
00031
00032 #include <stddef.h>
00033
00034 #include "libavcodec/cabac.h"
00035 #include "cabac.h"
00036
00037
00038
00039 #if ARCH_X86 && HAVE_7REGS && !defined(BROKEN_RELOCATIONS)
00040 static int decode_significance_x86(CABACContext *c, int max_coeff,
00041 uint8_t *significant_coeff_ctx_base,
00042 int *index, x86_reg last_off){
00043 void *end= significant_coeff_ctx_base + max_coeff - 1;
00044 int minusstart= -(intptr_t)significant_coeff_ctx_base;
00045 int minusindex= 4-(intptr_t)index;
00046 int bit;
00047 x86_reg coeff_count;
00048 int low;
00049 int range;
00050 __asm__ volatile(
00051 "movl %a11(%6), %5 \n\t"
00052 "movl %a12(%6), %3 \n\t"
00053
00054 "2: \n\t"
00055
00056 BRANCHLESS_GET_CABAC("%4", "%6", "(%1)", "%3",
00057 "%w3", "%5", "%k0", "%b0", "%a13")
00058
00059 "test $1, %4 \n\t"
00060 " jz 3f \n\t"
00061 "add %10, %1 \n\t"
00062
00063 BRANCHLESS_GET_CABAC("%4", "%6", "(%1)", "%3",
00064 "%w3", "%5", "%k0", "%b0", "%a13")
00065
00066 "sub %10, %1 \n\t"
00067 "mov %2, %0 \n\t"
00068 "movl %7, %%ecx \n\t"
00069 "add %1, %%"REG_c" \n\t"
00070 "movl %%ecx, (%0) \n\t"
00071
00072 "test $1, %4 \n\t"
00073 " jnz 4f \n\t"
00074
00075 "add $4, %0 \n\t"
00076 "mov %0, %2 \n\t"
00077
00078 "3: \n\t"
00079 "add $1, %1 \n\t"
00080 "cmp %8, %1 \n\t"
00081 " jb 2b \n\t"
00082 "mov %2, %0 \n\t"
00083 "movl %7, %%ecx \n\t"
00084 "add %1, %%"REG_c" \n\t"
00085 "movl %%ecx, (%0) \n\t"
00086 "4: \n\t"
00087 "add %9, %k0 \n\t"
00088 "shr $2, %k0 \n\t"
00089
00090 "movl %5, %a11(%6) \n\t"
00091 "movl %3, %a12(%6) \n\t"
00092 :"=&q"(coeff_count), "+r"(significant_coeff_ctx_base), "+m"(index),
00093 "=&r"(low), "=&r"(bit), "=&r"(range)
00094 :"r"(c), "m"(minusstart), "m"(end), "m"(minusindex), "m"(last_off),
00095 "i"(offsetof(CABACContext, range)), "i"(offsetof(CABACContext, low)),
00096 "i"(offsetof(CABACContext, bytestream))
00097 : "%"REG_c, "memory"
00098 );
00099 return coeff_count;
00100 }
00101
00102 static int decode_significance_8x8_x86(CABACContext *c,
00103 uint8_t *significant_coeff_ctx_base,
00104 int *index, x86_reg last_off, const uint8_t *sig_off){
00105 int minusindex= 4-(intptr_t)index;
00106 int bit;
00107 x86_reg coeff_count;
00108 int low;
00109 int range;
00110 x86_reg last=0;
00111 x86_reg state;
00112 __asm__ volatile(
00113 "movl %a12(%7), %5 \n\t"
00114 "movl %a13(%7), %3 \n\t"
00115
00116 "mov %1, %6 \n\t"
00117 "2: \n\t"
00118
00119 "mov %10, %0 \n\t"
00120 "movzbl (%0, %6), %k6 \n\t"
00121 "add %9, %6 \n\t"
00122
00123 BRANCHLESS_GET_CABAC("%4", "%7", "(%6)", "%3",
00124 "%w3", "%5", "%k0", "%b0", "%a14")
00125
00126 "mov %1, %k6 \n\t"
00127 "test $1, %4 \n\t"
00128 " jz 3f \n\t"
00129
00130 "movzbl "MANGLE(last_coeff_flag_offset_8x8)"(%k6), %k6\n\t"
00131 "add %9, %6 \n\t"
00132 "add %11, %6 \n\t"
00133
00134 BRANCHLESS_GET_CABAC("%4", "%7", "(%6)", "%3",
00135 "%w3", "%5", "%k0", "%b0", "%a14")
00136
00137 "mov %2, %0 \n\t"
00138 "mov %1, %k6 \n\t"
00139 "movl %k6, (%0) \n\t"
00140
00141 "test $1, %4 \n\t"
00142 " jnz 4f \n\t"
00143
00144 "add $4, %0 \n\t"
00145 "mov %0, %2 \n\t"
00146
00147 "3: \n\t"
00148 "addl $1, %k6 \n\t"
00149 "mov %k6, %1 \n\t"
00150 "cmpl $63, %k6 \n\t"
00151 " jb 2b \n\t"
00152 "mov %2, %0 \n\t"
00153 "movl %k6, (%0) \n\t"
00154 "4: \n\t"
00155 "addl %8, %k0 \n\t"
00156 "shr $2, %k0 \n\t"
00157
00158 "movl %5, %a12(%7) \n\t"
00159 "movl %3, %a13(%7) \n\t"
00160 :"=&q"(coeff_count),"+m"(last), "+m"(index), "=&r"(low), "=&r"(bit),
00161 "=&r"(range), "=&r"(state)
00162 :"r"(c), "m"(minusindex), "m"(significant_coeff_ctx_base), "m"(sig_off), "m"(last_off),
00163 "i"(offsetof(CABACContext, range)), "i"(offsetof(CABACContext, low)),
00164 "i"(offsetof(CABACContext, bytestream))
00165 : "%"REG_c, "memory"
00166 );
00167 return coeff_count;
00168 }
00169 #endif
00170
00171 #endif