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 #if HAVE_INLINE_ASM
00038
00039
00040
00041 #if HAVE_7REGS
00042 #define decode_significance decode_significance_x86
00043 static int decode_significance_x86(CABACContext *c, int max_coeff,
00044 uint8_t *significant_coeff_ctx_base,
00045 int *index, x86_reg last_off){
00046 void *end= significant_coeff_ctx_base + max_coeff - 1;
00047 int minusstart= -(intptr_t)significant_coeff_ctx_base;
00048 int minusindex= 4-(intptr_t)index;
00049 int bit;
00050 x86_reg coeff_count;
00051
00052 #ifdef BROKEN_RELOCATIONS
00053 void *tables;
00054
00055 __asm__ volatile(
00056 "lea "MANGLE(ff_h264_cabac_tables)", %0 \n\t"
00057 : "=&r"(tables)
00058 );
00059 #endif
00060
00061 __asm__ volatile(
00062 "3: \n\t"
00063
00064 BRANCHLESS_GET_CABAC("%4", "%q4", "(%1)", "%3", "%w3",
00065 "%5", "%q5", "%k0", "%b0",
00066 "%c11(%6)", "%c12(%6)",
00067 AV_STRINGIFY(H264_NORM_SHIFT_OFFSET),
00068 AV_STRINGIFY(H264_LPS_RANGE_OFFSET),
00069 AV_STRINGIFY(H264_MLPS_STATE_OFFSET),
00070 "%13")
00071
00072 "test $1, %4 \n\t"
00073 " jz 4f \n\t"
00074 "add %10, %1 \n\t"
00075
00076 BRANCHLESS_GET_CABAC("%4", "%q4", "(%1)", "%3", "%w3",
00077 "%5", "%q5", "%k0", "%b0",
00078 "%c11(%6)", "%c12(%6)",
00079 AV_STRINGIFY(H264_NORM_SHIFT_OFFSET),
00080 AV_STRINGIFY(H264_LPS_RANGE_OFFSET),
00081 AV_STRINGIFY(H264_MLPS_STATE_OFFSET),
00082 "%13")
00083
00084 "sub %10, %1 \n\t"
00085 "mov %2, %0 \n\t"
00086 "movl %7, %%ecx \n\t"
00087 "add %1, %%"REG_c" \n\t"
00088 "movl %%ecx, (%0) \n\t"
00089
00090 "test $1, %4 \n\t"
00091 " jnz 5f \n\t"
00092
00093 "add"OPSIZE" $4, %2 \n\t"
00094
00095 "4: \n\t"
00096 "add $1, %1 \n\t"
00097 "cmp %8, %1 \n\t"
00098 " jb 3b \n\t"
00099 "mov %2, %0 \n\t"
00100 "movl %7, %%ecx \n\t"
00101 "add %1, %%"REG_c" \n\t"
00102 "movl %%ecx, (%0) \n\t"
00103 "5: \n\t"
00104 "add %9, %k0 \n\t"
00105 "shr $2, %k0 \n\t"
00106 : "=&q"(coeff_count), "+r"(significant_coeff_ctx_base), "+m"(index),
00107 "+&r"(c->low), "=&r"(bit), "+&r"(c->range)
00108 : "r"(c), "m"(minusstart), "m"(end), "m"(minusindex), "m"(last_off),
00109 "i"(offsetof(CABACContext, bytestream)),
00110 "i"(offsetof(CABACContext, bytestream_end))
00111 TABLES_ARG
00112 : "%"REG_c, "memory"
00113 );
00114 return coeff_count;
00115 }
00116
00117 #define decode_significance_8x8 decode_significance_8x8_x86
00118 static int decode_significance_8x8_x86(CABACContext *c,
00119 uint8_t *significant_coeff_ctx_base,
00120 int *index, uint8_t *last_coeff_ctx_base, const uint8_t *sig_off){
00121 int minusindex= 4-(intptr_t)index;
00122 int bit;
00123 x86_reg coeff_count;
00124 x86_reg last=0;
00125 x86_reg state;
00126
00127 #ifdef BROKEN_RELOCATIONS
00128 void *tables;
00129
00130 __asm__ volatile(
00131 "lea "MANGLE(ff_h264_cabac_tables)", %0 \n\t"
00132 : "=&r"(tables)
00133 );
00134 #endif
00135
00136 __asm__ volatile(
00137 "mov %1, %6 \n\t"
00138 "3: \n\t"
00139
00140 "mov %10, %0 \n\t"
00141 "movzbl (%0, %6), %k6 \n\t"
00142 "add %9, %6 \n\t"
00143
00144 BRANCHLESS_GET_CABAC("%4", "%q4", "(%6)", "%3", "%w3",
00145 "%5", "%q5", "%k0", "%b0",
00146 "%c12(%7)", "%c13(%7)",
00147 AV_STRINGIFY(H264_NORM_SHIFT_OFFSET),
00148 AV_STRINGIFY(H264_LPS_RANGE_OFFSET),
00149 AV_STRINGIFY(H264_MLPS_STATE_OFFSET),
00150 "%15")
00151
00152 "mov %1, %k6 \n\t"
00153 "test $1, %4 \n\t"
00154 " jz 4f \n\t"
00155
00156 #ifdef BROKEN_RELOCATIONS
00157 "movzbl %c14(%15, %q6), %k6\n\t"
00158 #else
00159 "movzbl "MANGLE(ff_h264_cabac_tables)"+%c14(%k6), %k6\n\t"
00160 #endif
00161 "add %11, %6 \n\t"
00162
00163 BRANCHLESS_GET_CABAC("%4", "%q4", "(%6)", "%3", "%w3",
00164 "%5", "%q5", "%k0", "%b0",
00165 "%c12(%7)", "%c13(%7)",
00166 AV_STRINGIFY(H264_NORM_SHIFT_OFFSET),
00167 AV_STRINGIFY(H264_LPS_RANGE_OFFSET),
00168 AV_STRINGIFY(H264_MLPS_STATE_OFFSET),
00169 "%15")
00170
00171 "mov %2, %0 \n\t"
00172 "mov %1, %k6 \n\t"
00173 "movl %k6, (%0) \n\t"
00174
00175 "test $1, %4 \n\t"
00176 " jnz 5f \n\t"
00177
00178 "add"OPSIZE" $4, %2 \n\t"
00179
00180 "4: \n\t"
00181 "addl $1, %k6 \n\t"
00182 "mov %k6, %1 \n\t"
00183 "cmpl $63, %k6 \n\t"
00184 " jb 3b \n\t"
00185 "mov %2, %0 \n\t"
00186 "movl %k6, (%0) \n\t"
00187 "5: \n\t"
00188 "addl %8, %k0 \n\t"
00189 "shr $2, %k0 \n\t"
00190 : "=&q"(coeff_count), "+m"(last), "+m"(index), "+&r"(c->low),
00191 "=&r"(bit), "+&r"(c->range), "=&r"(state)
00192 : "r"(c), "m"(minusindex), "m"(significant_coeff_ctx_base),
00193 "m"(sig_off), "m"(last_coeff_ctx_base),
00194 "i"(offsetof(CABACContext, bytestream)),
00195 "i"(offsetof(CABACContext, bytestream_end)),
00196 "i"(H264_LAST_COEFF_FLAG_OFFSET_8x8_OFFSET) TABLES_ARG
00197 : "%"REG_c, "memory"
00198 );
00199 return coeff_count;
00200 }
00201 #endif
00202
00203 #endif
00204 #endif