]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/cabac.c
Add new yuv444 pixfmts to avcodec_align_dimensions2
[ffmpeg] / libavcodec / cabac.c
index 1e0d9e592a7bc6317d9a7d9683325c2bc3ea4df8..691beb0ae3d4e8b1d417dd6b177c2b613a3d1ec3 100644 (file)
@@ -2,32 +2,32 @@
  * H.26L/H.264/AVC/JVT/14496-10/... encoder/decoder
  * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at>
  *
- * This file is part of FFmpeg.
+ * This file is part of Libav.
  *
- * FFmpeg is free software; you can redistribute it and/or
+ * 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.
  *
- * FFmpeg is distributed in the hope that it will be useful,
+ * 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 FFmpeg; if not, write to the Free Software
+ * License along with Libav; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 /**
- * @file cabac.c
+ * @file
  * Context Adaptive Binary Arithmetic Coder.
  */
 
 #include <string.h>
 
-#include "common.h"
-#include "bitstream.h"
+#include "libavutil/common.h"
+#include "get_bits.h"
 #include "cabac.h"
 
 static const uint8_t lps_range[64][4]= {
@@ -161,28 +161,21 @@ void ff_init_cabac_states(CABACContext *c){
         ff_h264_mps_state[2*i+1]= 2*mps_state[i]+1;
 
         if( i ){
-#ifdef BRANCHLESS_CABAC_DECODER
             ff_h264_mlps_state[128-2*i-1]= 2*lps_state[i]+0;
             ff_h264_mlps_state[128-2*i-2]= 2*lps_state[i]+1;
         }else{
             ff_h264_mlps_state[128-2*i-1]= 1;
             ff_h264_mlps_state[128-2*i-2]= 0;
-#else
-            ff_h264_lps_state[2*i+0]= 2*lps_state[i]+0;
-            ff_h264_lps_state[2*i+1]= 2*lps_state[i]+1;
-        }else{
-            ff_h264_lps_state[2*i+0]= 1;
-            ff_h264_lps_state[2*i+1]= 0;
-#endif
         }
     }
 }
 
-#if 0 //selftest
-#undef random
+#ifdef TEST
 #define SIZE 10240
 
+#include "libavutil/lfg.h"
 #include "avcodec.h"
+#include "cabac.h"
 
 int main(void){
     CABACContext c;
@@ -190,12 +183,14 @@ int main(void){
     uint8_t r[9*SIZE];
     int i;
     uint8_t state[10]= {0};
+    AVLFG prng;
 
+    av_lfg_init(&prng, 1);
     ff_init_cabac_encoder(&c, b, SIZE);
-    ff_init_cabac_states(&c, ff_h264_lps_range, ff_h264_mps_state, ff_h264_lps_state, 64);
+    ff_init_cabac_states(&c);
 
     for(i=0; i<SIZE; i++){
-        r[i]= random()%7;
+        r[i] = av_lfg_get(&prng) % 7;
     }
 
     for(i=0; i<SIZE; i++){
@@ -262,4 +257,4 @@ STOP_TIMER("get_cabac_ueg")
     return 0;
 }
 
-#endif
+#endif /* TEST */