2 * Copyright (C) 2010 Mans Rullgard <mans@mansr.com>
4 * This file is part of Libav.
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.
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.
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
21 #ifndef AVCODEC_ARM_VP56_ARITH_H
22 #define AVCODEC_ARM_VP56_ARITH_H
32 #if CONFIG_THUMB || defined __clang__
42 #define vp56_rac_get_prob vp56_rac_get_prob_armv6
43 static inline int vp56_rac_get_prob_armv6(VP56RangeCoder *c, int pr)
45 unsigned shift = ff_vp56_norm_shift[c->high];
46 unsigned code_word = c->code_word << shift;
47 unsigned high = c->high << shift;
50 __asm__ ("adds %3, %3, %0 \n"
53 L("ldrcsh %2, [%4], #2 \n")
54 U("ldrhcs %2, [%4], #2 \n")
56 "smlabb %0, %5, %6, %0 \n"
59 T("lslcs %2, %2, %3 \n")
60 T("orrcs %1, %1, %2 \n")
61 A("orrcs %1, %1, %2, lsl %3 \n")
62 "subcs %3, %3, #16 \n"
64 "cmp %1, %0, lsl #16 \n"
66 "subge %1, %1, %0, lsl #16 \n"
70 : "=&r"(c->high), "=&r"(c->code_word), "=&r"(bit),
71 "+&r"(c->bits), "+&r"(c->buffer)
72 : "r"(high), "r"(pr), "r"(c->end - 1),
73 "0"(shift), "1"(code_word)
79 #define vp56_rac_get_prob_branchy vp56_rac_get_prob_branchy_armv6
80 static inline int vp56_rac_get_prob_branchy_armv6(VP56RangeCoder *c, int pr)
82 unsigned shift = ff_vp56_norm_shift[c->high];
83 unsigned code_word = c->code_word << shift;
84 unsigned high = c->high << shift;
88 __asm__ ("adds %3, %3, %0 \n"
91 L("ldrcsh %2, [%4], #2 \n")
92 U("ldrhcs %2, [%4], #2 \n")
94 "smlabb %0, %5, %6, %0 \n"
97 T("lslcs %2, %2, %3 \n")
98 T("orrcs %1, %1, %2 \n")
99 A("orrcs %1, %1, %2, lsl %3 \n")
100 "subcs %3, %3, #16 \n"
103 : "=&r"(low), "+&r"(code_word), "=&r"(tmp),
104 "+&r"(c->bits), "+&r"(c->buffer)
105 : "r"(high), "r"(pr), "r"(c->end - 1), "0"(shift)
108 if (code_word >= tmp) {
109 c->high = high - low;
110 c->code_word = code_word - tmp;
115 c->code_word = code_word;
121 #endif /* AVCODEC_ARM_VP56_ARITH_H */