~siretart/libav/merge.raring.libav-0.8.6

« back to all changes in this revision

Viewing changes to libavcodec/x86/h264_i386.h

  • Committer: Package Import Robot
  • Author(s): Reinhard Tartler
  • Date: 2012-01-12 22:30:00 UTC
  • mfrom: (1.4.1)
  • mto: (1.3.11 sid) (26.1.1 quantal-security)
  • mto: This revision was merged to the branch mainline in revision 15.
  • Revision ID: package-import@ubuntu.com-20120112223000-s1reiy1e28hnix42
Tags: upstream-0.8~beta2
ImportĀ upstreamĀ versionĀ 0.8~beta2

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
#ifndef AVCODEC_X86_H264_I386_H
30
30
#define AVCODEC_X86_H264_I386_H
31
31
 
 
32
#include <stddef.h>
 
33
 
32
34
#include "libavcodec/cabac.h"
 
35
#include "cabac.h"
33
36
 
34
37
//FIXME use some macros to avoid duplicating get_cabac (cannot be done yet
35
38
//as that would make optimization work hard)
36
 
#if ARCH_X86 && HAVE_7REGS && HAVE_EBX_AVAILABLE && !defined(BROKEN_RELOCATIONS)
 
39
#if HAVE_7REGS && !defined(BROKEN_RELOCATIONS)
37
40
static int decode_significance_x86(CABACContext *c, int max_coeff,
38
41
                                   uint8_t *significant_coeff_ctx_base,
39
42
                                   int *index, x86_reg last_off){
40
43
    void *end= significant_coeff_ctx_base + max_coeff - 1;
41
 
    int minusstart= -(int)significant_coeff_ctx_base;
42
 
    int minusindex= 4-(int)index;
43
 
    int coeff_count;
 
44
    int minusstart= -(intptr_t)significant_coeff_ctx_base;
 
45
    int minusindex= 4-(intptr_t)index;
 
46
    int bit;
 
47
    x86_reg coeff_count;
44
48
    __asm__ volatile(
45
 
        "movl "RANGE    "(%3), %%esi            \n\t"
46
 
        "movl "LOW      "(%3), %%ebx            \n\t"
47
 
 
48
49
        "2:                                     \n\t"
49
50
 
50
 
        BRANCHLESS_GET_CABAC("%%edx", "%3", "(%1)", "%%ebx",
51
 
                             "%%bx", "%%esi", "%%eax", "%%al")
 
51
        BRANCHLESS_GET_CABAC("%4", "(%1)", "%3",
 
52
                             "%w3", "%5", "%k0", "%b0", "%6")
52
53
 
53
 
        "test $1, %%edx                         \n\t"
 
54
        "test $1, %4                            \n\t"
54
55
        " jz 3f                                 \n\t"
55
 
        "add  %7, %1                            \n\t"
56
 
 
57
 
        BRANCHLESS_GET_CABAC("%%edx", "%3", "(%1)", "%%ebx",
58
 
                             "%%bx", "%%esi", "%%eax", "%%al")
59
 
 
60
 
        "sub  %7, %1                            \n\t"
61
 
        "mov  %2, %%"REG_a"                     \n\t"
62
 
        "movl %4, %%ecx                         \n\t"
 
56
        "add  %10, %1                           \n\t"
 
57
 
 
58
        BRANCHLESS_GET_CABAC("%4", "(%1)", "%3",
 
59
                             "%w3", "%5", "%k0", "%b0", "%6")
 
60
 
 
61
        "sub  %10, %1                           \n\t"
 
62
        "mov  %2, %0                            \n\t"
 
63
        "movl %7, %%ecx                         \n\t"
63
64
        "add  %1, %%"REG_c"                     \n\t"
64
 
        "movl %%ecx, (%%"REG_a")                \n\t"
 
65
        "movl %%ecx, (%0)                       \n\t"
65
66
 
66
 
        "test $1, %%edx                         \n\t"
 
67
        "test $1, %4                            \n\t"
67
68
        " jnz 4f                                \n\t"
68
69
 
69
 
        "add  $4, %%"REG_a"                     \n\t"
70
 
        "mov  %%"REG_a", %2                     \n\t"
 
70
        "add"OPSIZE"  $4, %2                    \n\t"
71
71
 
72
72
        "3:                                     \n\t"
73
73
        "add  $1, %1                            \n\t"
74
 
        "cmp  %5, %1                            \n\t"
 
74
        "cmp  %8, %1                            \n\t"
75
75
        " jb 2b                                 \n\t"
76
 
        "mov  %2, %%"REG_a"                     \n\t"
77
 
        "movl %4, %%ecx                         \n\t"
 
76
        "mov  %2, %0                            \n\t"
 
77
        "movl %7, %%ecx                         \n\t"
78
78
        "add  %1, %%"REG_c"                     \n\t"
79
 
        "movl %%ecx, (%%"REG_a")                \n\t"
 
79
        "movl %%ecx, (%0)                       \n\t"
80
80
        "4:                                     \n\t"
81
 
        "add  %6, %%eax                         \n\t"
82
 
        "shr $2, %%eax                          \n\t"
83
 
 
84
 
        "movl %%esi, "RANGE    "(%3)            \n\t"
85
 
        "movl %%ebx, "LOW      "(%3)            \n\t"
86
 
        :"=&a"(coeff_count), "+r"(significant_coeff_ctx_base), "+m"(index)
87
 
        :"r"(c), "m"(minusstart), "m"(end), "m"(minusindex), "m"(last_off)
88
 
        : "%"REG_c, "%ebx", "%edx", "%esi", "memory"
 
81
        "add  %9, %k0                           \n\t"
 
82
        "shr $2, %k0                            \n\t"
 
83
        :"=&q"(coeff_count), "+r"(significant_coeff_ctx_base), "+m"(index),
 
84
         "+&r"(c->low), "=&r"(bit), "+&r"(c->range),
 
85
         "+m"(c->bytestream)
 
86
        :"m"(minusstart), "m"(end), "m"(minusindex), "m"(last_off)
 
87
        : "%"REG_c, "memory"
89
88
    );
90
89
    return coeff_count;
91
90
}
92
91
 
93
92
static int decode_significance_8x8_x86(CABACContext *c,
94
93
                                       uint8_t *significant_coeff_ctx_base,
95
 
                                       int *index, x86_reg last_off, const uint8_t *sig_off){
96
 
    int minusindex= 4-(int)index;
97
 
    int coeff_count;
 
94
                                       int *index, uint8_t *last_coeff_ctx_base, const uint8_t *sig_off){
 
95
    int minusindex= 4-(intptr_t)index;
 
96
    int bit;
 
97
    x86_reg coeff_count;
98
98
    x86_reg last=0;
 
99
    x86_reg state;
99
100
    __asm__ volatile(
100
 
        "movl "RANGE    "(%3), %%esi            \n\t"
101
 
        "movl "LOW      "(%3), %%ebx            \n\t"
102
 
 
103
 
        "mov %1, %%"REG_D"                      \n\t"
 
101
        "mov %1, %6                             \n\t"
104
102
        "2:                                     \n\t"
105
103
 
106
 
        "mov %6, %%"REG_a"                      \n\t"
107
 
        "movzbl (%%"REG_a", %%"REG_D"), %%edi   \n\t"
108
 
        "add %5, %%"REG_D"                      \n\t"
109
 
 
110
 
        BRANCHLESS_GET_CABAC("%%edx", "%3", "(%%"REG_D")", "%%ebx",
111
 
                             "%%bx", "%%esi", "%%eax", "%%al")
112
 
 
113
 
        "mov %1, %%edi                          \n\t"
114
 
        "test $1, %%edx                         \n\t"
 
104
        "mov %10, %0                            \n\t"
 
105
        "movzbl (%0, %6), %k6                   \n\t"
 
106
        "add %9, %6                             \n\t"
 
107
 
 
108
        BRANCHLESS_GET_CABAC("%4", "(%6)", "%3",
 
109
                             "%w3", "%5", "%k0", "%b0", "%7")
 
110
 
 
111
        "mov %1, %k6                            \n\t"
 
112
        "test $1, %4                            \n\t"
115
113
        " jz 3f                                 \n\t"
116
114
 
117
 
        "movzbl "MANGLE(last_coeff_flag_offset_8x8)"(%%edi), %%edi\n\t"
118
 
        "add %5, %%"REG_D"                      \n\t"
119
 
        "add %7, %%"REG_D"                      \n\t"
120
 
 
121
 
        BRANCHLESS_GET_CABAC("%%edx", "%3", "(%%"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"
 
115
        "movzbl "MANGLE(last_coeff_flag_offset_8x8)"(%k6), %k6\n\t"
 
116
        "add %11, %6                            \n\t"
 
117
 
 
118
        BRANCHLESS_GET_CABAC("%4", "(%6)", "%3",
 
119
                             "%w3", "%5", "%k0", "%b0", "%7")
 
120
 
 
121
        "mov %2, %0                             \n\t"
 
122
        "mov %1, %k6                            \n\t"
 
123
        "movl %k6, (%0)                         \n\t"
 
124
 
 
125
        "test $1, %4                            \n\t"
129
126
        " jnz 4f                                \n\t"
130
127
 
131
 
        "add $4, %%"REG_a"                      \n\t"
132
 
        "mov %%"REG_a", %2                      \n\t"
 
128
        "add"OPSIZE"  $4, %2                    \n\t"
133
129
 
134
130
        "3:                                     \n\t"
135
 
        "addl $1, %%edi                         \n\t"
136
 
        "mov %%edi, %1                          \n\t"
137
 
        "cmpl $63, %%edi                        \n\t"
 
131
        "addl $1, %k6                           \n\t"
 
132
        "mov %k6, %1                            \n\t"
 
133
        "cmpl $63, %k6                          \n\t"
138
134
        " jb 2b                                 \n\t"
139
 
        "mov %2, %%"REG_a"                      \n\t"
140
 
        "movl %%edi, (%%"REG_a")                \n\t"
 
135
        "mov %2, %0                             \n\t"
 
136
        "movl %k6, (%0)                         \n\t"
141
137
        "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), "m"(last_off)
149
 
        : "%"REG_c, "%ebx", "%edx", "%esi", "%"REG_D, "memory"
 
138
        "addl %8, %k0                           \n\t"
 
139
        "shr $2, %k0                            \n\t"
 
140
        :"=&q"(coeff_count),"+m"(last), "+m"(index), "+&r"(c->low), "=&r"(bit),
 
141
         "+&r"(c->range), "=&r"(state), "+m"(c->bytestream)
 
142
        :"m"(minusindex), "m"(significant_coeff_ctx_base), "m"(sig_off), "m"(last_coeff_ctx_base)
 
143
        : "%"REG_c, "memory"
150
144
    );
151
145
    return coeff_count;
152
146
}
153
 
#endif /* ARCH_X86 && HAVE_7REGS && HAVE_EBX_AVAILABLE */
154
 
       /* !defined(BROKEN_RELOCATIONS) */
 
147
#endif /* HAVE_7REGS && !defined(BROKEN_RELOCATIONS) */
155
148
 
156
149
#endif /* AVCODEC_X86_H264_I386_H */