Statistics
| Branch: | Revision:

ffmpeg / libavcodec / arm / vp56_arith.h @ 2912e87a

History | View | Annotate | Download (3.51 KB)

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

    
21
#ifndef AVCODEC_ARM_VP56_ARITH_H
22
#define AVCODEC_ARM_VP56_ARITH_H
23

    
24
#if HAVE_ARMV6 && HAVE_INLINE_ASM
25

    
26
#define vp56_rac_get_prob vp56_rac_get_prob_armv6
27
static inline int vp56_rac_get_prob_armv6(VP56RangeCoder *c, int pr)
28
{
29
    unsigned shift     = ff_vp56_norm_shift[c->high];
30
    unsigned code_word = c->code_word << shift;
31
    unsigned high      = c->high << shift;
32
    unsigned bit;
33

    
34
    __asm__ volatile ("adds    %3,  %3,  %0           \n"
35
                      "cmpcs   %7,  %4                \n"
36
                      "ldrcsh  %2,  [%4], #2          \n"
37
                      "rsb     %0,  %6,  #256         \n"
38
                      "smlabb  %0,  %5,  %6,  %0      \n"
39
                      "rev16cs %2,  %2                \n"
40
                      "orrcs   %1,  %1,  %2,  lsl %3  \n"
41
                      "subcs   %3,  %3,  #16          \n"
42
                      "lsr     %0,  %0,  #8           \n"
43
                      "cmp     %1,  %0,  lsl #16      \n"
44
                      "subge   %1,  %1,  %0,  lsl #16 \n"
45
                      "subge   %0,  %5,  %0           \n"
46
                      "movge   %2,  #1                \n"
47
                      "movlt   %2,  #0                \n"
48
                      : "=&r"(c->high), "=&r"(c->code_word), "=&r"(bit),
49
                        "+&r"(c->bits), "+&r"(c->buffer)
50
                      : "r"(high), "r"(pr), "r"(c->end - 1),
51
                        "0"(shift), "1"(code_word));
52

    
53
    return bit;
54
}
55

    
56
#define vp56_rac_get_prob_branchy vp56_rac_get_prob_branchy_armv6
57
static inline int vp56_rac_get_prob_branchy_armv6(VP56RangeCoder *c, int pr)
58
{
59
    unsigned shift     = ff_vp56_norm_shift[c->high];
60
    unsigned code_word = c->code_word << shift;
61
    unsigned high      = c->high << shift;
62
    unsigned low;
63
    unsigned tmp;
64

    
65
    __asm__ volatile ("adds    %3,  %3,  %0           \n"
66
                      "cmpcs   %7,  %4                \n"
67
                      "ldrcsh  %2,  [%4], #2          \n"
68
                      "rsb     %0,  %6,  #256         \n"
69
                      "smlabb  %0,  %5,  %6,  %0      \n"
70
                      "rev16cs %2,  %2                \n"
71
                      "orrcs   %1,  %1,  %2,  lsl %3  \n"
72
                      "subcs   %3,  %3,  #16          \n"
73
                      "lsr     %0,  %0,  #8           \n"
74
                      "lsl     %2,  %0,  #16          \n"
75
                      : "=&r"(low), "+&r"(code_word), "=&r"(tmp),
76
                        "+&r"(c->bits), "+&r"(c->buffer)
77
                      : "r"(high), "r"(pr), "r"(c->end - 1), "0"(shift));
78

    
79
    if (code_word >= tmp) {
80
        c->high      = high - low;
81
        c->code_word = code_word - tmp;
82
        return 1;
83
    }
84

    
85
    c->high      = low;
86
    c->code_word = code_word;
87
    return 0;
88
}
89

    
90
#endif
91

    
92
#endif