Libav 0.7.1
|
00001 /* 00002 * H.26L/H.264/AVC/JVT/14496-10/... encoder/decoder 00003 * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at> 00004 * 00005 * This file is part of Libav. 00006 * 00007 * Libav is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public 00009 * License as published by the Free Software Foundation; either 00010 * version 2.1 of the License, or (at your option) any later version. 00011 * 00012 * Libav is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public 00018 * License along with Libav; if not, write to the Free Software 00019 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00020 */ 00021 00029 #ifndef AVCODEC_X86_H264_I386_H 00030 #define AVCODEC_X86_H264_I386_H 00031 00032 #include "libavcodec/cabac.h" 00033 00034 //FIXME use some macros to avoid duplicating get_cabac (cannot be done yet 00035 //as that would make optimization work hard) 00036 #if ARCH_X86 && HAVE_7REGS && HAVE_EBX_AVAILABLE && !defined(BROKEN_RELOCATIONS) 00037 static int decode_significance_x86(CABACContext *c, int max_coeff, 00038 uint8_t *significant_coeff_ctx_base, 00039 int *index, x86_reg last_off){ 00040 void *end= significant_coeff_ctx_base + max_coeff - 1; 00041 int minusstart= -(int)significant_coeff_ctx_base; 00042 int minusindex= 4-(int)index; 00043 int coeff_count; 00044 __asm__ volatile( 00045 "movl "RANGE "(%3), %%esi \n\t" 00046 "movl "LOW "(%3), %%ebx \n\t" 00047 00048 "2: \n\t" 00049 00050 BRANCHLESS_GET_CABAC("%%edx", "%3", "(%1)", "%%ebx", 00051 "%%bx", "%%esi", "%%eax", "%%al") 00052 00053 "test $1, %%edx \n\t" 00054 " jz 3f \n\t" 00055 "add %7, %1 \n\t" 00056 00057 BRANCHLESS_GET_CABAC("%%edx", "%3", "(%1)", "%%ebx", 00058 "%%bx", "%%esi", "%%eax", "%%al") 00059 00060 "sub %7, %1 \n\t" 00061 "mov %2, %%"REG_a" \n\t" 00062 "movl %4, %%ecx \n\t" 00063 "add %1, %%"REG_c" \n\t" 00064 "movl %%ecx, (%%"REG_a") \n\t" 00065 00066 "test $1, %%edx \n\t" 00067 " jnz 4f \n\t" 00068 00069 "add $4, %%"REG_a" \n\t" 00070 "mov %%"REG_a", %2 \n\t" 00071 00072 "3: \n\t" 00073 "add $1, %1 \n\t" 00074 "cmp %5, %1 \n\t" 00075 " jb 2b \n\t" 00076 "mov %2, %%"REG_a" \n\t" 00077 "movl %4, %%ecx \n\t" 00078 "add %1, %%"REG_c" \n\t" 00079 "movl %%ecx, (%%"REG_a") \n\t" 00080 "4: \n\t" 00081 "add %6, %%eax \n\t" 00082 "shr $2, %%eax \n\t" 00083 00084 "movl %%esi, "RANGE "(%3) \n\t" 00085 "movl %%ebx, "LOW "(%3) \n\t" 00086 :"=&a"(coeff_count), "+r"(significant_coeff_ctx_base), "+m"(index) 00087 :"r"(c), "m"(minusstart), "m"(end), "m"(minusindex), "m"(last_off) 00088 : "%"REG_c, "%ebx", "%edx", "%esi", "memory" 00089 ); 00090 return coeff_count; 00091 } 00092 00093 static int decode_significance_8x8_x86(CABACContext *c, 00094 uint8_t *significant_coeff_ctx_base, 00095 int *index, x86_reg last_off, const uint8_t *sig_off){ 00096 int minusindex= 4-(int)index; 00097 int coeff_count; 00098 x86_reg last=0; 00099 __asm__ volatile( 00100 "movl "RANGE "(%3), %%esi \n\t" 00101 "movl "LOW "(%3), %%ebx \n\t" 00102 00103 "mov %1, %%"REG_D" \n\t" 00104 "2: \n\t" 00105 00106 "mov %6, %%"REG_a" \n\t" 00107 "movzbl (%%"REG_a", %%"REG_D"), %%edi \n\t" 00108 "add %5, %%"REG_D" \n\t" 00109 00110 BRANCHLESS_GET_CABAC("%%edx", "%3", "(%%"REG_D")", "%%ebx", 00111 "%%bx", "%%esi", "%%eax", "%%al") 00112 00113 "mov %1, %%edi \n\t" 00114 "test $1, %%edx \n\t" 00115 " jz 3f \n\t" 00116 00117 "movzbl "MANGLE(last_coeff_flag_offset_8x8)"(%%edi), %%edi\n\t" 00118 "add %5, %%"REG_D" \n\t" 00119 "add %7, %%"REG_D" \n\t" 00120 00121 BRANCHLESS_GET_CABAC("%%edx", "%3", "(%%"REG_D")", "%%ebx", 00122 "%%bx", "%%esi", "%%eax", "%%al") 00123 00124 "mov %2, %%"REG_a" \n\t" 00125 "mov %1, %%edi \n\t" 00126 "movl %%edi, (%%"REG_a") \n\t" 00127 00128 "test $1, %%edx \n\t" 00129 " jnz 4f \n\t" 00130 00131 "add $4, %%"REG_a" \n\t" 00132 "mov %%"REG_a", %2 \n\t" 00133 00134 "3: \n\t" 00135 "addl $1, %%edi \n\t" 00136 "mov %%edi, %1 \n\t" 00137 "cmpl $63, %%edi \n\t" 00138 " jb 2b \n\t" 00139 "mov %2, %%"REG_a" \n\t" 00140 "movl %%edi, (%%"REG_a") \n\t" 00141 "4: \n\t" 00142 "addl %4, %%eax \n\t" 00143 "shr $2, %%eax \n\t" 00144 00145 "movl %%esi, "RANGE "(%3) \n\t" 00146 "movl %%ebx, "LOW "(%3) \n\t" 00147 :"=&a"(coeff_count),"+m"(last), "+m"(index) 00148 :"r"(c), "m"(minusindex), "m"(significant_coeff_ctx_base), "m"(sig_off), "m"(last_off) 00149 : "%"REG_c, "%ebx", "%edx", "%esi", "%"REG_D, "memory" 00150 ); 00151 return coeff_count; 00152 } 00153 #endif /* ARCH_X86 && HAVE_7REGS && HAVE_EBX_AVAILABLE */ 00154 /* !defined(BROKEN_RELOCATIONS) */ 00155 00156 #endif /* AVCODEC_X86_H264_I386_H */