Statistics
| Branch: | Revision:

ffmpeg / libavcodec / i386 / h264_i386.h @ 40d0e665

History | View | Annotate | Download (6.17 KB)

1
/*
2
 * H.26L/H.264/AVC/JVT/14496-10/... encoder/decoder
3
 * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at>
4
 *
5
 * This file is part of FFmpeg.
6
 *
7
 * FFmpeg is free software; you can redistribute it and/or
8
 * modify it under the terms of the GNU Lesser General Public
9
 * License as published by the Free Software Foundation; either
10
 * version 2.1 of the License, or (at your option) any later version.
11
 *
12
 * FFmpeg is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
 * Lesser General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU Lesser General Public
18
 * License along with FFmpeg; if not, write to the Free Software
19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
 */
21

    
22
/**
23
 * @file h264_i386.h
24
 * H.264 / AVC / MPEG4 part10 codec.
25
 * non-MMX i386-specific optimizations for H.264
26
 * @author Michael Niedermayer <michaelni@gmx.at>
27
 */
28

    
29
#ifndef FFMPEG_H264_I386_H
30
#define FFMPEG_H264_I386_H
31

    
32

    
33
#include "cabac.h"
34

    
35
//FIXME use some macros to avoid duplicating get_cabac (cannot be done yet
36
//as that would make optimization work hard)
37
#if defined(ARCH_X86) && defined(HAVE_7REGS)     && \
38
    defined(HAVE_EBX_AVAILABLE)                  && \
39
    !defined(BROKEN_RELOCATIONS)
40
static int decode_significance_x86(CABACContext *c, int max_coeff,
41
                                   uint8_t *significant_coeff_ctx_base,
42
                                   int *index){
43
    void *end= significant_coeff_ctx_base + max_coeff - 1;
44
    int minusstart= -(int)significant_coeff_ctx_base;
45
    int minusindex= 4-(int)index;
46
    int coeff_count;
47
    asm volatile(
48
        "movl "RANGE    "(%3), %%esi            \n\t"
49
        "movl "LOW      "(%3), %%ebx            \n\t"
50

    
51
        "2:                                     \n\t"
52

    
53
        BRANCHLESS_GET_CABAC("%%edx", "%3", "(%1)", "%%ebx",
54
                             "%%bx", "%%esi", "%%eax", "%%al")
55

    
56
        "test $1, %%edx                         \n\t"
57
        " jz 3f                                 \n\t"
58

    
59
        BRANCHLESS_GET_CABAC("%%edx", "%3", "61(%1)", "%%ebx",
60
                             "%%bx", "%%esi", "%%eax", "%%al")
61

    
62
        "mov  %2, %%"REG_a"                     \n\t"
63
        "movl %4, %%ecx                         \n\t"
64
        "add  %1, %%"REG_c"                     \n\t"
65
        "movl %%ecx, (%%"REG_a")                \n\t"
66

    
67
        "test $1, %%edx                         \n\t"
68
        " jnz 4f                                \n\t"
69

    
70
        "add  $4, %%"REG_a"                     \n\t"
71
        "mov  %%"REG_a", %2                     \n\t"
72

    
73
        "3:                                     \n\t"
74
        "add  $1, %1                            \n\t"
75
        "cmp  %5, %1                            \n\t"
76
        " jb 2b                                 \n\t"
77
        "mov  %2, %%"REG_a"                     \n\t"
78
        "movl %4, %%ecx                         \n\t"
79
        "add  %1, %%"REG_c"                     \n\t"
80
        "movl %%ecx, (%%"REG_a")                \n\t"
81
        "4:                                     \n\t"
82
        "add  %6, %%eax                         \n\t"
83
        "shr $2, %%eax                          \n\t"
84

    
85
        "movl %%esi, "RANGE    "(%3)            \n\t"
86
        "movl %%ebx, "LOW      "(%3)            \n\t"
87
        :"=&a"(coeff_count), "+r"(significant_coeff_ctx_base), "+m"(index)
88
        :"r"(c), "m"(minusstart), "m"(end), "m"(minusindex)
89
        : "%"REG_c, "%ebx", "%edx", "%esi", "memory"
90
    );
91
    return coeff_count;
92
}
93

    
94
static int decode_significance_8x8_x86(CABACContext *c,
95
                                       uint8_t *significant_coeff_ctx_base,
96
                                       int *index, const uint8_t *sig_off){
97
    int minusindex= 4-(int)index;
98
    int coeff_count;
99
    x86_reg last=0;
100
    asm volatile(
101
        "movl "RANGE    "(%3), %%esi            \n\t"
102
        "movl "LOW      "(%3), %%ebx            \n\t"
103

    
104
        "mov %1, %%"REG_D"                      \n\t"
105
        "2:                                     \n\t"
106

    
107
        "mov %6, %%"REG_a"                      \n\t"
108
        "movzbl (%%"REG_a", %%"REG_D"), %%edi   \n\t"
109
        "add %5, %%"REG_D"                      \n\t"
110

    
111
        BRANCHLESS_GET_CABAC("%%edx", "%3", "(%%"REG_D")", "%%ebx",
112
                             "%%bx", "%%esi", "%%eax", "%%al")
113

    
114
        "mov %1, %%edi                          \n\t"
115
        "test $1, %%edx                         \n\t"
116
        " jz 3f                                 \n\t"
117

    
118
        "movzbl "MANGLE(last_coeff_flag_offset_8x8)"(%%edi), %%edi\n\t"
119
        "add %5, %%"REG_D"                      \n\t"
120

    
121
        BRANCHLESS_GET_CABAC("%%edx", "%3", "15(%%"REG_D")", "%%ebx",
122
                             "%%bx", "%%esi", "%%eax", "%%al")
123

    
124
        "mov %2, %%"REG_a"                      \n\t"
125
        "mov %1, %%edi                          \n\t"
126
        "movl %%edi, (%%"REG_a")                \n\t"
127

    
128
        "test $1, %%edx                         \n\t"
129
        " jnz 4f                                \n\t"
130

    
131
        "add $4, %%"REG_a"                      \n\t"
132
        "mov %%"REG_a", %2                      \n\t"
133

    
134
        "3:                                     \n\t"
135
        "addl $1, %%edi                         \n\t"
136
        "mov %%edi, %1                          \n\t"
137
        "cmpl $63, %%edi                        \n\t"
138
        " jb 2b                                 \n\t"
139
        "mov %2, %%"REG_a"                      \n\t"
140
        "movl %%edi, (%%"REG_a")                \n\t"
141
        "4:                                     \n\t"
142
        "addl %4, %%eax                         \n\t"
143
        "shr $2, %%eax                          \n\t"
144

    
145
        "movl %%esi, "RANGE    "(%3)            \n\t"
146
        "movl %%ebx, "LOW      "(%3)            \n\t"
147
        :"=&a"(coeff_count),"+m"(last), "+m"(index)
148
        :"r"(c), "m"(minusindex), "m"(significant_coeff_ctx_base), "m"(sig_off)
149
        : "%"REG_c, "%ebx", "%edx", "%esi", "%"REG_D, "memory"
150
    );
151
    return coeff_count;
152
}
153
#endif /* defined(ARCH_X86) && defined(HAVE_7REGS) &&                 */
154
       /* defined(HAVE_EBX_AVAILABLE) && !defined(BROKEN_RELOCATIONS) */
155

    
156
#endif /* FFMPEG_H264_I386_H */