• 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 FFmpeg.
00006  *
00007  * FFmpeg 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  * FFmpeg 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 FFmpeg; 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 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 /* ARCH_X86 && HAVE_7REGS && !defined(BROKEN_RELOCATIONS) */
00170 
00171 #endif /* AVCODEC_X86_H264_I386_H */

Generated on Wed Apr 11 2012 07:31:35 for FFmpeg by  doxygen 1.7.1