00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef AVCODEC_ARM_VP56_ARITH_H
00022 #define AVCODEC_ARM_VP56_ARITH_H
00023
00024 #if CONFIG_THUMB
00025 # define A(x)
00026 # define T(x) x
00027 #else
00028 # define A(x) x
00029 # define T(x)
00030 #endif
00031
00032 #if CONFIG_THUMB || defined __clang__
00033 # define L(x)
00034 # define U(x) x
00035 #else
00036 # define L(x) x
00037 # define U(x)
00038 #endif
00039
00040 #if HAVE_ARMV6 && HAVE_INLINE_ASM
00041
00042 #define vp56_rac_get_prob vp56_rac_get_prob_armv6
00043 static inline int vp56_rac_get_prob_armv6(VP56RangeCoder *c, int pr)
00044 {
00045 unsigned shift = ff_vp56_norm_shift[c->high];
00046 unsigned code_word = c->code_word << shift;
00047 unsigned high = c->high << shift;
00048 unsigned bit;
00049
00050 __asm__ ("adds %3, %3, %0 \n"
00051 "itt cs \n"
00052 "cmpcs %7, %4 \n"
00053 L("ldrcsh %2, [%4], #2 \n")
00054 U("ldrhcs %2, [%4], #2 \n")
00055 "rsb %0, %6, #256 \n"
00056 "smlabb %0, %5, %6, %0 \n"
00057 T("itttt cs \n")
00058 "rev16cs %2, %2 \n"
00059 T("lslcs %2, %2, %3 \n")
00060 T("orrcs %1, %1, %2 \n")
00061 A("orrcs %1, %1, %2, lsl %3 \n")
00062 "subcs %3, %3, #16 \n"
00063 "lsr %0, %0, #8 \n"
00064 "cmp %1, %0, lsl #16 \n"
00065 "ittte ge \n"
00066 "subge %1, %1, %0, lsl #16 \n"
00067 "subge %0, %5, %0 \n"
00068 "movge %2, #1 \n"
00069 "movlt %2, #0 \n"
00070 : "=&r"(c->high), "=&r"(c->code_word), "=&r"(bit),
00071 "+&r"(c->bits), "+&r"(c->buffer)
00072 : "r"(high), "r"(pr), "r"(c->end - 1),
00073 "0"(shift), "1"(code_word)
00074 : "cc");
00075
00076 return bit;
00077 }
00078
00079 #define vp56_rac_get_prob_branchy vp56_rac_get_prob_branchy_armv6
00080 static inline int vp56_rac_get_prob_branchy_armv6(VP56RangeCoder *c, int pr)
00081 {
00082 unsigned shift = ff_vp56_norm_shift[c->high];
00083 unsigned code_word = c->code_word << shift;
00084 unsigned high = c->high << shift;
00085 unsigned low;
00086 unsigned tmp;
00087
00088 __asm__ ("adds %3, %3, %0 \n"
00089 "itt cs \n"
00090 "cmpcs %7, %4 \n"
00091 L("ldrcsh %2, [%4], #2 \n")
00092 U("ldrhcs %2, [%4], #2 \n")
00093 "rsb %0, %6, #256 \n"
00094 "smlabb %0, %5, %6, %0 \n"
00095 T("itttt cs \n")
00096 "rev16cs %2, %2 \n"
00097 T("lslcs %2, %2, %3 \n")
00098 T("orrcs %1, %1, %2 \n")
00099 A("orrcs %1, %1, %2, lsl %3 \n")
00100 "subcs %3, %3, #16 \n"
00101 "lsr %0, %0, #8 \n"
00102 "lsl %2, %0, #16 \n"
00103 : "=&r"(low), "+&r"(code_word), "=&r"(tmp),
00104 "+&r"(c->bits), "+&r"(c->buffer)
00105 : "r"(high), "r"(pr), "r"(c->end - 1), "0"(shift)
00106 : "cc");
00107
00108 if (code_word >= tmp) {
00109 c->high = high - low;
00110 c->code_word = code_word - tmp;
00111 return 1;
00112 }
00113
00114 c->high = low;
00115 c->code_word = code_word;
00116 return 0;
00117 }
00118
00119 #endif
00120
00121 #endif