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 HAVE_ARMV6 && HAVE_INLINE_ASM
00033
00034 #define vp56_rac_get_prob vp56_rac_get_prob_armv6
00035 static inline int vp56_rac_get_prob_armv6(VP56RangeCoder *c, int pr)
00036 {
00037 unsigned shift = ff_vp56_norm_shift[c->high];
00038 unsigned code_word = c->code_word << shift;
00039 unsigned high = c->high << shift;
00040 unsigned bit;
00041
00042 __asm__ ("adds %3, %3, %0 \n"
00043 "itt cs \n"
00044 "cmpcs %7, %4 \n"
00045 A("ldrcsh %2, [%4], #2 \n")
00046 T("ldrhcs %2, [%4], #2 \n")
00047 "rsb %0, %6, #256 \n"
00048 "smlabb %0, %5, %6, %0 \n"
00049 T("itttt cs \n")
00050 "rev16cs %2, %2 \n"
00051 T("lslcs %2, %2, %3 \n")
00052 T("orrcs %1, %1, %2 \n")
00053 A("orrcs %1, %1, %2, lsl %3 \n")
00054 "subcs %3, %3, #16 \n"
00055 "lsr %0, %0, #8 \n"
00056 "cmp %1, %0, lsl #16 \n"
00057 "ittte ge \n"
00058 "subge %1, %1, %0, lsl #16 \n"
00059 "subge %0, %5, %0 \n"
00060 "movge %2, #1 \n"
00061 "movlt %2, #0 \n"
00062 : "=&r"(c->high), "=&r"(c->code_word), "=&r"(bit),
00063 "+&r"(c->bits), "+&r"(c->buffer)
00064 : "r"(high), "r"(pr), "r"(c->end - 1),
00065 "0"(shift), "1"(code_word)
00066 : "cc");
00067
00068 return bit;
00069 }
00070
00071 #define vp56_rac_get_prob_branchy vp56_rac_get_prob_branchy_armv6
00072 static inline int vp56_rac_get_prob_branchy_armv6(VP56RangeCoder *c, int pr)
00073 {
00074 unsigned shift = ff_vp56_norm_shift[c->high];
00075 unsigned code_word = c->code_word << shift;
00076 unsigned high = c->high << shift;
00077 unsigned low;
00078 unsigned tmp;
00079
00080 __asm__ ("adds %3, %3, %0 \n"
00081 "itt cs \n"
00082 "cmpcs %7, %4 \n"
00083 A("ldrcsh %2, [%4], #2 \n")
00084 T("ldrhcs %2, [%4], #2 \n")
00085 "rsb %0, %6, #256 \n"
00086 "smlabb %0, %5, %6, %0 \n"
00087 T("itttt cs \n")
00088 "rev16cs %2, %2 \n"
00089 T("lslcs %2, %2, %3 \n")
00090 T("orrcs %1, %1, %2 \n")
00091 A("orrcs %1, %1, %2, lsl %3 \n")
00092 "subcs %3, %3, #16 \n"
00093 "lsr %0, %0, #8 \n"
00094 "lsl %2, %0, #16 \n"
00095 : "=&r"(low), "+&r"(code_word), "=&r"(tmp),
00096 "+&r"(c->bits), "+&r"(c->buffer)
00097 : "r"(high), "r"(pr), "r"(c->end - 1), "0"(shift)
00098 : "cc");
00099
00100 if (code_word >= tmp) {
00101 c->high = high - low;
00102 c->code_word = code_word - tmp;
00103 return 1;
00104 }
00105
00106 c->high = low;
00107 c->code_word = code_word;
00108 return 0;
00109 }
00110
00111 #endif
00112
00113 #endif