]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/cabac_functions.h
mpeg12dec: move setting first_field to mpeg_field_start()
[ffmpeg] / libavcodec / cabac_functions.h
index 484ba85db679b8fe99f5278fd99459a49bb3e297..beb5016396ce09d3ee09eb36662f552966f58669 100644 (file)
 #include "cabac.h"
 #include "config.h"
 
+#if ARCH_AARCH64
+#   include "aarch64/cabac.h"
+#endif
+#if ARCH_ARM
+#   include "arm/cabac.h"
+#endif
 #if ARCH_X86
 #   include "x86/cabac.h"
 #endif
 
-extern uint8_t ff_h264_cabac_tables[512 + 4*2*64 + 4*64 + 63];
-static uint8_t * const ff_h264_norm_shift = ff_h264_cabac_tables + H264_NORM_SHIFT_OFFSET;
-static uint8_t * const ff_h264_lps_range = ff_h264_cabac_tables + H264_LPS_RANGE_OFFSET;
-static uint8_t * const ff_h264_mlps_state = ff_h264_cabac_tables + H264_MLPS_STATE_OFFSET;
-static uint8_t * const ff_h264_last_coeff_flag_offset_8x8 = ff_h264_cabac_tables + H264_LAST_COEFF_FLAG_OFFSET_8x8_OFFSET;
+static const uint8_t * const ff_h264_norm_shift = ff_h264_cabac_tables + H264_NORM_SHIFT_OFFSET;
+static const uint8_t * const ff_h264_lps_range = ff_h264_cabac_tables + H264_LPS_RANGE_OFFSET;
+static const uint8_t * const ff_h264_mlps_state = ff_h264_cabac_tables + H264_MLPS_STATE_OFFSET;
+static const uint8_t * const ff_h264_last_coeff_flag_offset_8x8 = ff_h264_cabac_tables + H264_LAST_COEFF_FLAG_OFFSET_8x8_OFFSET;
 
 static void refill(CABACContext *c){
 #if CABAC_BITS == 16
@@ -113,6 +118,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;
@@ -128,7 +134,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){
@@ -148,7 +154,6 @@ static av_always_inline int get_cabac_bypass_sign(CABACContext *c, int val){
 #endif
 
 /**
- *
  * @return the number of bytes read or 0 if no end
  */
 static int av_unused get_cabac_terminate(CABACContext *c){
@@ -161,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 */