]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/intrax8.c
Make sure the EC code does not attempt to use inter based concealment if there
[ffmpeg] / libavcodec / intrax8.c
index 0436deb4ce865ac008b37b9705a1eab7eddb5e69..70e3bff7530c136e96d6661cdbcbbc6c35ed8349 100644 (file)
  */
 
 /**
- * @file intrax8.c
+ * @file libavcodec/intrax8.c
  * @brief IntraX8 (J-Frame) subdecoder, used by WMV2 and VC-1
  */
 
 #include "avcodec.h"
-#include "bitstream.h"
+#include "get_bits.h"
 #include "mpegvideo.h"
 #include "msmpeg4data.h"
 #include "intrax8huf.h"
@@ -42,15 +42,32 @@ static VLC j_ac_vlc[2][2][8];  //[quant<13],[intra/inter],[select]
 static VLC j_dc_vlc[2][8];     //[quant], [select]
 static VLC j_orient_vlc[2][4]; //[quant], [select]
 
-static void x8_vlc_init(){
+static av_cold void x8_vlc_init(void){
     int i;
+    int offset = 0;
+    int sizeidx = 0;
+    static const uint16_t sizes[8*4 + 8*2 + 2 + 4] = {
+        576, 548, 582, 618, 546, 616, 560, 642,
+        584, 582, 704, 664, 512, 544, 656, 640,
+        512, 648, 582, 566, 532, 614, 596, 648,
+        586, 552, 584, 590, 544, 578, 584, 624,
+
+        528, 528, 526, 528, 536, 528, 526, 544,
+        544, 512, 512, 528, 528, 544, 512, 544,
+
+        128, 128, 128, 128, 128, 128};
+
+    static VLC_TYPE table[28150][2];
 
 #define  init_ac_vlc(dst,src) \
+    dst.table = &table[offset]; \
+    dst.table_allocated = sizes[sizeidx]; \
+    offset += sizes[sizeidx++]; \
        init_vlc(&dst, \
               AC_VLC_BITS,77, \
               &src[1],4,2, \
               &src[0],4,2, \
-              1)
+              INIT_VLC_USE_NEW_STATIC)
 //set ac tables
     for(i=0;i<8;i++){
         init_ac_vlc( j_ac_vlc[0][0][i], x8_ac0_highquant_table[i][0] );
@@ -62,11 +79,14 @@ static void x8_vlc_init(){
 
 //set dc tables
 #define init_dc_vlc(dst,src) \
+    dst.table = &table[offset]; \
+    dst.table_allocated = sizes[sizeidx]; \
+    offset += sizes[sizeidx++]; \
         init_vlc(&dst, \
         DC_VLC_BITS,34, \
         &src[1],4,2, \
         &src[0],4,2, \
-        1);
+        INIT_VLC_USE_NEW_STATIC);
     for(i=0;i<8;i++){
         init_dc_vlc( j_dc_vlc[0][i], x8_dc_highquant_table[i][0]);
         init_dc_vlc( j_dc_vlc[1][i], x8_dc_lowquant_table [i][0]);
@@ -75,17 +95,22 @@ static void x8_vlc_init(){
 
 //set orient tables
 #define init_or_vlc(dst,src) \
+    dst.table = &table[offset]; \
+    dst.table_allocated = sizes[sizeidx]; \
+    offset += sizes[sizeidx++]; \
     init_vlc(&dst, \
     OR_VLC_BITS,12, \
     &src[1],4,2, \
     &src[0],4,2, \
-    1);
+    INIT_VLC_USE_NEW_STATIC);
     for(i=0;i<2;i++){
         init_or_vlc( j_orient_vlc[0][i], x8_orient_highquant_table[i][0]);
     }
     for(i=0;i<4;i++){
         init_or_vlc( j_orient_vlc[1][i], x8_orient_lowquant_table [i][0])
     }
+    if (offset != sizeof(table)/sizeof(VLC_TYPE)/2)
+        av_log(NULL, AV_LOG_ERROR, "table size %i does not match needed %i\n", (int)(sizeof(table)/sizeof(VLC_TYPE)/2), offset);
 }
 #undef init_or_vlc
 
@@ -511,7 +536,7 @@ static int x8_decode_intra_mb(IntraX8Context* const w, const int chroma){
     int sign;
 
     assert(w->orient<12);
-    memset(s->block[0],0x00,64*sizeof(DCTELEM));
+    s->dsp.clear_block(s->block[0]);
 
     if(chroma){
         dc_mode=2;
@@ -664,7 +689,7 @@ static void x8_init_block_index(MpegEncContext *s){ //FIXME maybe merge with ff_
  * @param w pointer to IntraX8Context
  * @param s pointer to MpegEncContext of the parent codec
  */
-void ff_intrax8_common_init(IntraX8Context * w, MpegEncContext * const s){
+av_cold void ff_intrax8_common_init(IntraX8Context * w, MpegEncContext * const s){
 
     w->s=s;
     x8_vlc_init();
@@ -680,7 +705,7 @@ void ff_intrax8_common_init(IntraX8Context * w, MpegEncContext * const s){
  * Destroy IntraX8 frame structure.
  * @param w pointer to IntraX8Context
  */
-void ff_intrax8_common_end(IntraX8Context * w)
+av_cold void ff_intrax8_common_end(IntraX8Context * w)
 {
     av_freep(&w->prediction_table);
 }