summaryrefslogtreecommitdiff
path: root/ffmpeg/libavcodec/cabac_functions.h
diff options
context:
space:
mode:
authorTim Redfern <tim@eclectronics.org>2013-12-29 12:19:38 +0000
committerTim Redfern <tim@eclectronics.org>2013-12-29 12:19:38 +0000
commitf7813a5324be39d13ab536c245d15dfc602a7849 (patch)
treefad99148b88823d34a5df2f0a25881a002eb291b /ffmpeg/libavcodec/cabac_functions.h
parentb7a5a477b8ff4d4e3028b9dfb9a9df0a41463f92 (diff)
basic type mechanism working
Diffstat (limited to 'ffmpeg/libavcodec/cabac_functions.h')
-rw-r--r--ffmpeg/libavcodec/cabac_functions.h33
1 files changed, 30 insertions, 3 deletions
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<<i;
- c->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 */