This resolves circular header dependencies and fixes 'make checkheaders'. --- libavcodec/arm/vp56_arith.c | 89 +++++++++++++++++ libavcodec/arm/vp56_arith.h | 92 ------------------ libavcodec/vp5.c | 1 + libavcodec/vp56.c | 1 + libavcodec/vp56.h | 193 ------------------------------------- libavcodec/vp56rac.c | 1 + libavcodec/vp56rac.h | 224 +++++++++++++++++++++++++++++++++++++++++++ libavcodec/vp6.c | 1 + libavcodec/vp8.c | 1 + libavcodec/x86/vp56_arith.c | 53 ++++++++++ libavcodec/x86/vp56_arith.h | 54 ---------- 11 files changed, 371 insertions(+), 339 deletions(-) create mode 100644 libavcodec/arm/vp56_arith.c delete mode 100644 libavcodec/arm/vp56_arith.h create mode 100644 libavcodec/vp56rac.h create mode 100644 libavcodec/x86/vp56_arith.c delete mode 100644 libavcodec/x86/vp56_arith.h
diff --git a/libavcodec/arm/vp56_arith.c b/libavcodec/arm/vp56_arith.c new file mode 100644 index 0000000..078c4ed --- /dev/null +++ b/libavcodec/arm/vp56_arith.c @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2010 Mans Rullgard <[email protected]> + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "config.h" + +#if HAVE_ARMV6 && HAVE_INLINE_ASM + +#define vp56_rac_get_prob vp56_rac_get_prob_armv6 +static inline int vp56_rac_get_prob_armv6(VP56RangeCoder *c, int pr) +{ + unsigned shift = ff_vp56_norm_shift[c->high]; + unsigned code_word = c->code_word << shift; + unsigned high = c->high << shift; + unsigned bit; + + __asm__ volatile ("adds %3, %3, %0 \n" + "cmpcs %7, %4 \n" + "ldrcsh %2, [%4], #2 \n" + "rsb %0, %6, #256 \n" + "smlabb %0, %5, %6, %0 \n" + "rev16cs %2, %2 \n" + "orrcs %1, %1, %2, lsl %3 \n" + "subcs %3, %3, #16 \n" + "lsr %0, %0, #8 \n" + "cmp %1, %0, lsl #16 \n" + "subge %1, %1, %0, lsl #16 \n" + "subge %0, %5, %0 \n" + "movge %2, #1 \n" + "movlt %2, #0 \n" + : "=&r"(c->high), "=&r"(c->code_word), "=&r"(bit), + "+&r"(c->bits), "+&r"(c->buffer) + : "r"(high), "r"(pr), "r"(c->end - 1), + "0"(shift), "1"(code_word)); + + return bit; +} + +#define vp56_rac_get_prob_branchy vp56_rac_get_prob_branchy_armv6 +static inline int vp56_rac_get_prob_branchy_armv6(VP56RangeCoder *c, int pr) +{ + unsigned shift = ff_vp56_norm_shift[c->high]; + unsigned code_word = c->code_word << shift; + unsigned high = c->high << shift; + unsigned low; + unsigned tmp; + + __asm__ volatile ("adds %3, %3, %0 \n" + "cmpcs %7, %4 \n" + "ldrcsh %2, [%4], #2 \n" + "rsb %0, %6, #256 \n" + "smlabb %0, %5, %6, %0 \n" + "rev16cs %2, %2 \n" + "orrcs %1, %1, %2, lsl %3 \n" + "subcs %3, %3, #16 \n" + "lsr %0, %0, #8 \n" + "lsl %2, %0, #16 \n" + : "=&r"(low), "+&r"(code_word), "=&r"(tmp), + "+&r"(c->bits), "+&r"(c->buffer) + : "r"(high), "r"(pr), "r"(c->end - 1), "0"(shift)); + + if (code_word >= tmp) { + c->high = high - low; + c->code_word = code_word - tmp; + return 1; + } + + c->high = low; + c->code_word = code_word; + return 0; +} + +#endif diff --git a/libavcodec/arm/vp56_arith.h b/libavcodec/arm/vp56_arith.h deleted file mode 100644 index f5dbd1d..0000000 --- a/libavcodec/arm/vp56_arith.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (C) 2010 Mans Rullgard <[email protected]> - * - * This file is part of Libav. - * - * Libav is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * Libav is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with Libav; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef AVCODEC_ARM_VP56_ARITH_H -#define AVCODEC_ARM_VP56_ARITH_H - -#if HAVE_ARMV6 && HAVE_INLINE_ASM - -#define vp56_rac_get_prob vp56_rac_get_prob_armv6 -static inline int vp56_rac_get_prob_armv6(VP56RangeCoder *c, int pr) -{ - unsigned shift = ff_vp56_norm_shift[c->high]; - unsigned code_word = c->code_word << shift; - unsigned high = c->high << shift; - unsigned bit; - - __asm__ volatile ("adds %3, %3, %0 \n" - "cmpcs %7, %4 \n" - "ldrcsh %2, [%4], #2 \n" - "rsb %0, %6, #256 \n" - "smlabb %0, %5, %6, %0 \n" - "rev16cs %2, %2 \n" - "orrcs %1, %1, %2, lsl %3 \n" - "subcs %3, %3, #16 \n" - "lsr %0, %0, #8 \n" - "cmp %1, %0, lsl #16 \n" - "subge %1, %1, %0, lsl #16 \n" - "subge %0, %5, %0 \n" - "movge %2, #1 \n" - "movlt %2, #0 \n" - : "=&r"(c->high), "=&r"(c->code_word), "=&r"(bit), - "+&r"(c->bits), "+&r"(c->buffer) - : "r"(high), "r"(pr), "r"(c->end - 1), - "0"(shift), "1"(code_word)); - - return bit; -} - -#define vp56_rac_get_prob_branchy vp56_rac_get_prob_branchy_armv6 -static inline int vp56_rac_get_prob_branchy_armv6(VP56RangeCoder *c, int pr) -{ - unsigned shift = ff_vp56_norm_shift[c->high]; - unsigned code_word = c->code_word << shift; - unsigned high = c->high << shift; - unsigned low; - unsigned tmp; - - __asm__ volatile ("adds %3, %3, %0 \n" - "cmpcs %7, %4 \n" - "ldrcsh %2, [%4], #2 \n" - "rsb %0, %6, #256 \n" - "smlabb %0, %5, %6, %0 \n" - "rev16cs %2, %2 \n" - "orrcs %1, %1, %2, lsl %3 \n" - "subcs %3, %3, #16 \n" - "lsr %0, %0, #8 \n" - "lsl %2, %0, #16 \n" - : "=&r"(low), "+&r"(code_word), "=&r"(tmp), - "+&r"(c->bits), "+&r"(c->buffer) - : "r"(high), "r"(pr), "r"(c->end - 1), "0"(shift)); - - if (code_word >= tmp) { - c->high = high - low; - c->code_word = code_word - tmp; - return 1; - } - - c->high = low; - c->code_word = code_word; - return 0; -} - -#endif - -#endif diff --git a/libavcodec/vp5.c b/libavcodec/vp5.c index 807309f..f602f57 100644 --- a/libavcodec/vp5.c +++ b/libavcodec/vp5.c @@ -31,6 +31,7 @@ #include "vp56.h" #include "vp56data.h" #include "vp5data.h" +#include "vp56rac.h" static int vp5_parse_header(VP56Context *s, const uint8_t *buf, int buf_size, diff --git a/libavcodec/vp56.c b/libavcodec/vp56.c index a181978..3981b72 100644 --- a/libavcodec/vp56.c +++ b/libavcodec/vp56.c @@ -26,6 +26,7 @@ #include "vp56.h" #include "vp56data.h" +#include "vp56rac.h" void ff_vp56_init_dequant(VP56Context *s, int quantizer) diff --git a/libavcodec/vp56.h b/libavcodec/vp56.h index 5a55f7d..07334cf 100644 --- a/libavcodec/vp56.h +++ b/libavcodec/vp56.h @@ -176,197 +176,4 @@ void ff_vp56_init_dequant(VP56Context *s, int quantizer); int ff_vp56_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt); - -/** - * vp56 specific range coder implementation - */ - -extern const uint8_t ff_vp56_norm_shift[256]; -void ff_vp56_init_range_decoder(VP56RangeCoder *c, const uint8_t *buf, int buf_size); - -static av_always_inline unsigned int vp56_rac_renorm(VP56RangeCoder *c) -{ - int shift = ff_vp56_norm_shift[c->high]; - int bits = c->bits; - unsigned int code_word = c->code_word; - - c->high <<= shift; - code_word <<= shift; - bits += shift; - if(bits >= 0 && c->buffer < c->end) { - code_word |= bytestream_get_be16(&c->buffer) << bits; - bits -= 16; - } - c->bits = bits; - return code_word; -} - -#if ARCH_ARM -#include "arm/vp56_arith.h" -#elif ARCH_X86 -#include "x86/vp56_arith.h" -#endif - -#ifndef vp56_rac_get_prob -#define vp56_rac_get_prob vp56_rac_get_prob -static av_always_inline int vp56_rac_get_prob(VP56RangeCoder *c, uint8_t prob) -{ - unsigned int code_word = vp56_rac_renorm(c); - unsigned int low = 1 + (((c->high - 1) * prob) >> 8); - unsigned int low_shift = low << 16; - int bit = code_word >= low_shift; - - c->high = bit ? c->high - low : low; - c->code_word = bit ? code_word - low_shift : code_word; - - return bit; -} -#endif - -#ifndef vp56_rac_get_prob_branchy -// branchy variant, to be used where there's a branch based on the bit decoded -static av_always_inline int vp56_rac_get_prob_branchy(VP56RangeCoder *c, int prob) -{ - unsigned long code_word = vp56_rac_renorm(c); - unsigned low = 1 + (((c->high - 1) * prob) >> 8); - unsigned low_shift = low << 16; - - if (code_word >= low_shift) { - c->high -= low; - c->code_word = code_word - low_shift; - return 1; - } - - c->high = low; - c->code_word = code_word; - return 0; -} -#endif - -static av_always_inline int vp56_rac_get(VP56RangeCoder *c) -{ - unsigned int code_word = vp56_rac_renorm(c); - /* equiprobable */ - int low = (c->high + 1) >> 1; - unsigned int low_shift = low << 16; - int bit = code_word >= low_shift; - if (bit) { - c->high -= low; - code_word -= low_shift; - } else { - c->high = low; - } - - c->code_word = code_word; - return bit; -} - -// rounding is different than vp56_rac_get, is vp56_rac_get wrong? -static av_always_inline int vp8_rac_get(VP56RangeCoder *c) -{ - return vp56_rac_get_prob(c, 128); -} - -static av_unused int vp56_rac_gets(VP56RangeCoder *c, int bits) -{ - int value = 0; - - while (bits--) { - value = (value << 1) | vp56_rac_get(c); - } - - return value; -} - -static av_unused int vp8_rac_get_uint(VP56RangeCoder *c, int bits) -{ - int value = 0; - - while (bits--) { - value = (value << 1) | vp8_rac_get(c); - } - - return value; -} - -// fixme: add 1 bit to all the calls to this? -static av_unused int vp8_rac_get_sint(VP56RangeCoder *c, int bits) -{ - int v; - - if (!vp8_rac_get(c)) - return 0; - - v = vp8_rac_get_uint(c, bits); - - if (vp8_rac_get(c)) - v = -v; - - return v; -} - -// P(7) -static av_unused int vp56_rac_gets_nn(VP56RangeCoder *c, int bits) -{ - int v = vp56_rac_gets(c, 7) << 1; - return v + !v; -} - -static av_unused int vp8_rac_get_nn(VP56RangeCoder *c) -{ - int v = vp8_rac_get_uint(c, 7) << 1; - return v + !v; -} - -static av_always_inline -int vp56_rac_get_tree(VP56RangeCoder *c, - const VP56Tree *tree, - const uint8_t *probs) -{ - while (tree->val > 0) { - if (vp56_rac_get_prob(c, probs[tree->prob_idx])) - tree += tree->val; - else - tree++; - } - return -tree->val; -} - -/** - * This is identical to vp8_rac_get_tree except for the possibility of starting - * on a node other than the root node, needed for coeff decode where this is - * used to save a bit after a 0 token (by disallowing EOB to immediately follow.) - */ -static av_always_inline -int vp8_rac_get_tree_with_offset(VP56RangeCoder *c, const int8_t (*tree)[2], - const uint8_t *probs, int i) -{ - do { - i = tree[i][vp56_rac_get_prob(c, probs[i])]; - } while (i > 0); - - return -i; -} - -// how probabilities are associated with decisions is different I think -// well, the new scheme fits in the old but this way has one fewer branches per decision -static av_always_inline -int vp8_rac_get_tree(VP56RangeCoder *c, const int8_t (*tree)[2], - const uint8_t *probs) -{ - return vp8_rac_get_tree_with_offset(c, tree, probs, 0); -} - -// DCTextra -static av_always_inline int vp8_rac_get_coeff(VP56RangeCoder *c, const uint8_t *prob) -{ - int v = 0; - - do { - v = (v<<1) + vp56_rac_get_prob(c, *prob++); - } while (*prob); - - return v; -} - #endif /* AVCODEC_VP56_H */ diff --git a/libavcodec/vp56rac.c b/libavcodec/vp56rac.c index c009cad..fdcd53f 100644 --- a/libavcodec/vp56rac.c +++ b/libavcodec/vp56rac.c @@ -21,6 +21,7 @@ #include "libavutil/common.h" #include "vp56.h" +#include "vp56rac.h" const uint8_t ff_vp56_norm_shift[256]= { 8,7,6,6,5,5,5,5,4,4,4,4,4,4,4,4, diff --git a/libavcodec/vp56rac.h b/libavcodec/vp56rac.h new file mode 100644 index 0000000..97ba3f7 --- /dev/null +++ b/libavcodec/vp56rac.h @@ -0,0 +1,224 @@ +/** + * @file + * VP5 and VP6 compatible video decoder (range coder functions) + * + * Copyright (C) 2006 Aurelien Jacobs <[email protected]> + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_VP56RAC_H +#define AVCODEC_VP56RAC_H + +#include <stdint.h> + +#include "vp56.h" +#include "config.h" + +/** + * vp56 specific range coder implementation + */ + +extern const uint8_t ff_vp56_norm_shift[256]; +void ff_vp56_init_range_decoder(VP56RangeCoder *c, const uint8_t *buf, int buf_size); + +static av_always_inline unsigned int vp56_rac_renorm(VP56RangeCoder *c) +{ + int shift = ff_vp56_norm_shift[c->high]; + int bits = c->bits; + unsigned int code_word = c->code_word; + + c->high <<= shift; + code_word <<= shift; + bits += shift; + if(bits >= 0 && c->buffer < c->end) { + code_word |= bytestream_get_be16(&c->buffer) << bits; + bits -= 16; + } + c->bits = bits; + return code_word; +} + +#if ARCH_ARM +#include "arm/vp56_arith.c" +#elif ARCH_X86 +#include "x86/vp56_arith.c" +#endif + +#ifndef vp56_rac_get_prob +#define vp56_rac_get_prob vp56_rac_get_prob +static av_always_inline int vp56_rac_get_prob(VP56RangeCoder *c, uint8_t prob) +{ + unsigned int code_word = vp56_rac_renorm(c); + unsigned int low = 1 + (((c->high - 1) * prob) >> 8); + unsigned int low_shift = low << 16; + int bit = code_word >= low_shift; + + c->high = bit ? c->high - low : low; + c->code_word = bit ? code_word - low_shift : code_word; + + return bit; +} +#endif + +#ifndef vp56_rac_get_prob_branchy +// branchy variant, to be used where there's a branch based on the bit decoded +static av_always_inline int vp56_rac_get_prob_branchy(VP56RangeCoder *c, int prob) +{ + unsigned long code_word = vp56_rac_renorm(c); + unsigned low = 1 + (((c->high - 1) * prob) >> 8); + unsigned low_shift = low << 16; + + if (code_word >= low_shift) { + c->high -= low; + c->code_word = code_word - low_shift; + return 1; + } + + c->high = low; + c->code_word = code_word; + return 0; +} +#endif + +static av_always_inline int vp56_rac_get(VP56RangeCoder *c) +{ + unsigned int code_word = vp56_rac_renorm(c); + /* equiprobable */ + int low = (c->high + 1) >> 1; + unsigned int low_shift = low << 16; + int bit = code_word >= low_shift; + if (bit) { + c->high -= low; + code_word -= low_shift; + } else { + c->high = low; + } + + c->code_word = code_word; + return bit; +} + +// rounding is different than vp56_rac_get, is vp56_rac_get wrong? +static av_always_inline int vp8_rac_get(VP56RangeCoder *c) +{ + return vp56_rac_get_prob(c, 128); +} + +static av_unused int vp56_rac_gets(VP56RangeCoder *c, int bits) +{ + int value = 0; + + while (bits--) { + value = (value << 1) | vp56_rac_get(c); + } + + return value; +} + +static av_unused int vp8_rac_get_uint(VP56RangeCoder *c, int bits) +{ + int value = 0; + + while (bits--) { + value = (value << 1) | vp8_rac_get(c); + } + + return value; +} + +// fixme: add 1 bit to all the calls to this? +static av_unused int vp8_rac_get_sint(VP56RangeCoder *c, int bits) +{ + int v; + + if (!vp8_rac_get(c)) + return 0; + + v = vp8_rac_get_uint(c, bits); + + if (vp8_rac_get(c)) + v = -v; + + return v; +} + +// P(7) +static av_unused int vp56_rac_gets_nn(VP56RangeCoder *c, int bits) +{ + int v = vp56_rac_gets(c, 7) << 1; + return v + !v; +} + +static av_unused int vp8_rac_get_nn(VP56RangeCoder *c) +{ + int v = vp8_rac_get_uint(c, 7) << 1; + return v + !v; +} + +static av_always_inline +int vp56_rac_get_tree(VP56RangeCoder *c, + const VP56Tree *tree, + const uint8_t *probs) +{ + while (tree->val > 0) { + if (vp56_rac_get_prob(c, probs[tree->prob_idx])) + tree += tree->val; + else + tree++; + } + return -tree->val; +} + +/** + * This is identical to vp8_rac_get_tree except for the possibility of starting + * on a node other than the root node, needed for coeff decode where this is + * used to save a bit after a 0 token (by disallowing EOB to immediately follow.) + */ +static av_always_inline +int vp8_rac_get_tree_with_offset(VP56RangeCoder *c, const int8_t (*tree)[2], + const uint8_t *probs, int i) +{ + do { + i = tree[i][vp56_rac_get_prob(c, probs[i])]; + } while (i > 0); + + return -i; +} + +// how probabilities are associated with decisions is different I think +// well, the new scheme fits in the old but this way has one fewer branches per decision +static av_always_inline +int vp8_rac_get_tree(VP56RangeCoder *c, const int8_t (*tree)[2], + const uint8_t *probs) +{ + return vp8_rac_get_tree_with_offset(c, tree, probs, 0); +} + +// DCTextra +static av_always_inline int vp8_rac_get_coeff(VP56RangeCoder *c, const uint8_t *prob) +{ + int v = 0; + + do { + v = (v<<1) + vp56_rac_get_prob(c, *prob++); + } while (*prob); + + return v; +} + +#endif /* AVCODEC_VP56RAC_H */ diff --git a/libavcodec/vp6.c b/libavcodec/vp6.c index 4f3f402..00c4bfa 100644 --- a/libavcodec/vp6.c +++ b/libavcodec/vp6.c @@ -34,6 +34,7 @@ #include "vp56.h" #include "vp56data.h" +#include "vp56rac.h" #include "vp6data.h" #define VP6_MAX_HUFF_SIZE 12 diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c index 38f38b7..b7d2a3f 100644 --- a/libavcodec/vp8.c +++ b/libavcodec/vp8.c @@ -24,6 +24,7 @@ #include "libavutil/imgutils.h" #include "avcodec.h" +#include "vp56rac.h" #include "vp8.h" #include "vp8data.h" #include "rectangle.h" diff --git a/libavcodec/x86/vp56_arith.c b/libavcodec/x86/vp56_arith.c new file mode 100644 index 0000000..c1d0e2d --- /dev/null +++ b/libavcodec/x86/vp56_arith.c @@ -0,0 +1,53 @@ +/** + * VP5 and VP6 compatible video decoder (arith decoder) + * + * Copyright (C) 2006 Aurelien Jacobs <[email protected]> + * Copyright (C) 2010 Eli Friedman + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include <stdint.h> + +#include "config.h" + +#if HAVE_FAST_CMOV +#define vp56_rac_get_prob vp56_rac_get_prob +static av_always_inline int vp56_rac_get_prob(VP56RangeCoder *c, uint8_t prob) +{ + unsigned int code_word = vp56_rac_renorm(c); + unsigned int high = c->high; + unsigned int low = 1 + (((high - 1) * prob) >> 8); + unsigned int low_shift = low << 16; + int bit = 0; + + __asm__( + "subl %4, %1 \n\t" + "subl %3, %2 \n\t" + "leal (%2, %3), %3 \n\t" + "setae %b0 \n\t" + "cmovb %4, %1 \n\t" + "cmovb %3, %2 \n\t" + : "+q"(bit), "+r"(high), "+r"(code_word), "+r"(low_shift) + : "r"(low) + ); + + c->high = high; + c->code_word = code_word; + return bit; +} +#endif diff --git a/libavcodec/x86/vp56_arith.h b/libavcodec/x86/vp56_arith.h deleted file mode 100644 index be2dd30..0000000 --- a/libavcodec/x86/vp56_arith.h +++ /dev/null @@ -1,54 +0,0 @@ -/** - * VP5 and VP6 compatible video decoder (arith decoder) - * - * Copyright (C) 2006 Aurelien Jacobs <[email protected]> - * Copyright (C) 2010 Eli Friedman - * - * This file is part of Libav. - * - * Libav is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * Libav is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with Libav; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef AVCODEC_X86_VP56_ARITH_H -#define AVCODEC_X86_VP56_ARITH_H - -#if HAVE_FAST_CMOV -#define vp56_rac_get_prob vp56_rac_get_prob -static av_always_inline int vp56_rac_get_prob(VP56RangeCoder *c, uint8_t prob) -{ - unsigned int code_word = vp56_rac_renorm(c); - unsigned int high = c->high; - unsigned int low = 1 + (((high - 1) * prob) >> 8); - unsigned int low_shift = low << 16; - int bit = 0; - - __asm__( - "subl %4, %1 \n\t" - "subl %3, %2 \n\t" - "leal (%2, %3), %3 \n\t" - "setae %b0 \n\t" - "cmovb %4, %1 \n\t" - "cmovb %3, %2 \n\t" - : "+q"(bit), "+r"(high), "+r"(code_word), "+r"(low_shift) - : "r"(low) - ); - - c->high = high; - c->code_word = code_word; - return bit; -} -#endif - -#endif /* AVCODEC_X86_VP56_ARITH_H */ -- 1.7.1 _______________________________________________ libav-devel mailing list [email protected] https://lists.libav.org/mailman/listinfo/libav-devel
