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