• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • Examples
  • File List
  • Globals

libavcodec/x86/h264_i386.h

Go to the documentation of this file.
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 <stddef.h>
00033 
00034 #include "libavcodec/cabac.h"
00035 #include "cabac.h"
00036 
00037 //FIXME use some macros to avoid duplicating get_cabac (cannot be done yet
00038 //as that would make optimization work hard)
00039 #if 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     __asm__ volatile(
00049         "2:                                     \n\t"
00050 
00051         BRANCHLESS_GET_CABAC("%4", "(%1)", "%3",
00052                              "%w3", "%5", "%k0", "%b0", "%6")
00053 
00054         "test $1, %4                            \n\t"
00055         " jz 3f                                 \n\t"
00056         "add  %10, %1                           \n\t"
00057 
00058         BRANCHLESS_GET_CABAC("%4", "(%1)", "%3",
00059                              "%w3", "%5", "%k0", "%b0", "%6")
00060 
00061         "sub  %10, %1                           \n\t"
00062         "mov  %2, %0                            \n\t"
00063         "movl %7, %%ecx                         \n\t"
00064         "add  %1, %%"REG_c"                     \n\t"
00065         "movl %%ecx, (%0)                       \n\t"
00066 
00067         "test $1, %4                            \n\t"
00068         " jnz 4f                                \n\t"
00069 
00070         "add"OPSIZE"  $4, %2                    \n\t"
00071 
00072         "3:                                     \n\t"
00073         "add  $1, %1                            \n\t"
00074         "cmp  %8, %1                            \n\t"
00075         " jb 2b                                 \n\t"
00076         "mov  %2, %0                            \n\t"
00077         "movl %7, %%ecx                         \n\t"
00078         "add  %1, %%"REG_c"                     \n\t"
00079         "movl %%ecx, (%0)                       \n\t"
00080         "4:                                     \n\t"
00081         "add  %9, %k0                           \n\t"
00082         "shr $2, %k0                            \n\t"
00083         :"=&q"(coeff_count), "+r"(significant_coeff_ctx_base), "+m"(index),
00084          "+&r"(c->low), "=&r"(bit), "+&r"(c->range),
00085          "+m"(c->bytestream)
00086         :"m"(minusstart), "m"(end), "m"(minusindex), "m"(last_off)
00087         : "%"REG_c, "memory"
00088     );
00089     return coeff_count;
00090 }
00091 
00092 static int decode_significance_8x8_x86(CABACContext *c,
00093                                        uint8_t *significant_coeff_ctx_base,
00094                                        int *index, uint8_t *last_coeff_ctx_base, const uint8_t *sig_off){
00095     int minusindex= 4-(intptr_t)index;
00096     int bit;
00097     x86_reg coeff_count;
00098     x86_reg last=0;
00099     x86_reg state;
00100     __asm__ volatile(
00101         "mov %1, %6                             \n\t"
00102         "2:                                     \n\t"
00103 
00104         "mov %10, %0                            \n\t"
00105         "movzbl (%0, %6), %k6                   \n\t"
00106         "add %9, %6                             \n\t"
00107 
00108         BRANCHLESS_GET_CABAC("%4", "(%6)", "%3",
00109                              "%w3", "%5", "%k0", "%b0", "%7")
00110 
00111         "mov %1, %k6                            \n\t"
00112         "test $1, %4                            \n\t"
00113         " jz 3f                                 \n\t"
00114 
00115         "movzbl "MANGLE(last_coeff_flag_offset_8x8)"(%k6), %k6\n\t"
00116         "add %11, %6                            \n\t"
00117 
00118         BRANCHLESS_GET_CABAC("%4", "(%6)", "%3",
00119                              "%w3", "%5", "%k0", "%b0", "%7")
00120 
00121         "mov %2, %0                             \n\t"
00122         "mov %1, %k6                            \n\t"
00123         "movl %k6, (%0)                         \n\t"
00124 
00125         "test $1, %4                            \n\t"
00126         " jnz 4f                                \n\t"
00127 
00128         "add"OPSIZE"  $4, %2                    \n\t"
00129 
00130         "3:                                     \n\t"
00131         "addl $1, %k6                           \n\t"
00132         "mov %k6, %1                            \n\t"
00133         "cmpl $63, %k6                          \n\t"
00134         " jb 2b                                 \n\t"
00135         "mov %2, %0                             \n\t"
00136         "movl %k6, (%0)                         \n\t"
00137         "4:                                     \n\t"
00138         "addl %8, %k0                           \n\t"
00139         "shr $2, %k0                            \n\t"
00140         :"=&q"(coeff_count),"+m"(last), "+m"(index), "+&r"(c->low), "=&r"(bit),
00141          "+&r"(c->range), "=&r"(state), "+m"(c->bytestream)
00142         :"m"(minusindex), "m"(significant_coeff_ctx_base), "m"(sig_off), "m"(last_coeff_ctx_base)
00143         : "%"REG_c, "memory"
00144     );
00145     return coeff_count;
00146 }
00147 #endif /* HAVE_7REGS && !defined(BROKEN_RELOCATIONS) */
00148 
00149 #endif /* AVCODEC_X86_H264_I386_H */
Generated on Thu Jan 24 2013 17:08:54 for Libav by doxygen 1.7.1