diff options
author | XhmikosR <xhmikosr@users.sourceforge.net> | 2010-08-02 12:54:35 +0400 |
---|---|---|
committer | XhmikosR <xhmikosr@users.sourceforge.net> | 2010-08-02 12:54:35 +0400 |
commit | c5d184664fec4340b57082cd1cc31220d9f1220b (patch) | |
tree | 34c6103e95b6538a8e71d1ba87897536b7b51015 /src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/vp56.h | |
parent | aef6f86e8400fa5ee1e9d9ddc6190412ef09e519 (diff) |
updated ffmpeg (thanks to Aleksoid for finding the conflict in avcore\utils.c for Debug VS2010 builds)
git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@2180 10f7b99b-c216-0410-bff0-8a66a9350fd8
Diffstat (limited to 'src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/vp56.h')
-rw-r--r-- | src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/vp56.h | 84 |
1 files changed, 52 insertions, 32 deletions
diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/vp56.h b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/vp56.h index a4ef49ede..69518fa73 100644 --- a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/vp56.h +++ b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/vp56.h @@ -56,7 +56,7 @@ typedef struct { bits left) in order to eliminate a negate in cache refilling */ const uint8_t *buffer; const uint8_t *end; - unsigned long code_word; + unsigned int code_word; } VP56RangeCoder; typedef struct { @@ -170,10 +170,10 @@ struct vp56_context { }; -void vp56_init(AVCodecContext *avctx, int flip, int has_alpha); -int vp56_free(AVCodecContext *avctx); -void vp56_init_dequant(VP56Context *s, int quantizer); -int vp56_decode_frame(AVCodecContext *avctx, void *data, int *data_size, +void ff_vp56_init(AVCodecContext *avctx, int flip, int has_alpha); +int ff_vp56_free(AVCodecContext *avctx); +void ff_vp56_init_dequant(VP56Context *s, int quantizer); +int ff_vp56_decode_frame(AVCodecContext *avctx, void *data, int *data_size, const uint8_t *buf, int buf_size); @@ -191,25 +191,12 @@ static inline void vp56_init_range_decoder(VP56RangeCoder *c, c->code_word = bytestream_get_be16(&c->buffer); } -static inline int vp56_rac_get_prob(VP56RangeCoder *c, uint8_t prob) +static av_always_inline unsigned int vp56_rac_renorm(VP56RangeCoder *c) { - /* Don't put c->high in a local variable; if we do that, gcc gets - * the stupids and turns the code below into a branch again. */ + int shift = ff_h264_norm_shift[c->high] - 1; int bits = c->bits; - unsigned long code_word = c->code_word; - unsigned int low = 1 + (((c->high - 1) * prob) >> 8); - unsigned int low_shift = low << 8; - int bit = code_word >= low_shift; - int shift; + unsigned int code_word = c->code_word; - /* Incantation to convince GCC to turn these into conditional moves - * instead of branches -- faster, as this branch is basically - * unpredictable. */ - c->high = bit ? c->high - low : low; - code_word = bit ? code_word - low_shift : code_word; - - /* normalize */ - shift = ff_h264_norm_shift[c->high] - 1; c->high <<= shift; code_word <<= shift; bits += shift; @@ -218,29 +205,62 @@ static inline int vp56_rac_get_prob(VP56RangeCoder *c, uint8_t prob) bits -= 8; } c->bits = bits; - c->code_word = code_word; + return code_word; +} + +#if ARCH_X86 +#include "x86/vp56_arith.h" +#endif + +#ifndef vp56_rac_get_prob +#define vp56_rac_get_prob vp56_rac_get_prob +static 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 << 8; + 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 + +// 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 << 8; + + 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; +} static 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 << 8; - int bit = c->code_word >= low_shift; + int bit = code_word >= low_shift; if (bit) { - c->high = (c->high - low) << 1; - c->code_word -= low_shift; + c->high -= low; + code_word -= low_shift; } else { - c->high = low << 1; + c->high = low; } - /* normalize */ - c->code_word <<= 1; - if (++c->bits == 0 && c->buffer < c->end) { - c->bits = -8; - c->code_word |= *c->buffer++; - } + c->code_word = code_word; return bit; } |