From f7813a5324be39d13ab536c245d15dfc602a7849 Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Sun, 29 Dec 2013 12:19:38 +0000 Subject: basic type mechanism working --- ffmpeg/libavcodec/cabac_functions.h | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) (limited to 'ffmpeg/libavcodec/cabac_functions.h') diff --git a/ffmpeg/libavcodec/cabac_functions.h b/ffmpeg/libavcodec/cabac_functions.h index ee70fcf..7e22064 100644 --- a/ffmpeg/libavcodec/cabac_functions.h +++ b/ffmpeg/libavcodec/cabac_functions.h @@ -49,7 +49,10 @@ static void refill(CABACContext *c){ c->low+= c->bytestream[0]<<1; #endif c->low -= CABAC_MASK; - c->bytestream += CABAC_BITS / 8; +#if !UNCHECKED_BITSTREAM_READER + if (c->bytestream < c->bytestream_end) +#endif + c->bytestream += CABAC_BITS / 8; } static inline void renorm_cabac_decoder_once(CABACContext *c){ @@ -76,7 +79,10 @@ static void refill2(CABACContext *c){ #endif c->low += x<bytestream += CABAC_BITS/8; +#if !UNCHECKED_BITSTREAM_READER + if (c->bytestream < c->bytestream_end) +#endif + c->bytestream += CABAC_BITS/8; } static av_always_inline int get_cabac_inline(CABACContext *c, uint8_t * const state){ @@ -111,6 +117,7 @@ static int av_unused get_cabac(CABACContext *c, uint8_t * const state){ return get_cabac_inline(c,state); } +#ifndef get_cabac_bypass static int av_unused get_cabac_bypass(CABACContext *c){ int range; c->low += c->low; @@ -126,7 +133,7 @@ static int av_unused get_cabac_bypass(CABACContext *c){ return 1; } } - +#endif #ifndef get_cabac_bypass_sign static av_always_inline int get_cabac_bypass_sign(CABACContext *c, int val){ @@ -159,4 +166,24 @@ static int av_unused get_cabac_terminate(CABACContext *c){ } } +/** + * Skip @p n bytes and reset the decoder. + * @return the address of the first skipped byte or NULL if there's less than @p n bytes left + */ +static av_unused const uint8_t* skip_bytes(CABACContext *c, int n) { + const uint8_t *ptr = c->bytestream; + + if (c->low & 0x1) + ptr--; +#if CABAC_BITS == 16 + if (c->low & 0x1FF) + ptr--; +#endif + if ((int) (c->bytestream_end - ptr) < n) + return NULL; + ff_init_cabac_decoder(c, ptr + n, c->bytestream_end - ptr - n); + + return ptr; +} + #endif /* AVCODEC_CABAC_FUNCTIONS_H */ -- cgit v1.2.3