]> granicus.if.org Git - libx264/commitdiff
move quant_mf[] from x264_t to the heap, and merge duplicate entries
authorLoren Merritt <pengvado@videolan.org>
Sun, 30 Jul 2006 02:39:05 +0000 (02:39 +0000)
committerLoren Merritt <pengvado@videolan.org>
Sun, 30 Jul 2006 02:39:05 +0000 (02:39 +0000)
git-svn-id: svn://svn.videolan.org/x264/trunk@540 df754926-b1dd-0310-bc7b-ec298dee348c

common/common.h
common/set.c
common/set.h
encoder/encoder.c

index 799d19542f7411c904344a148301252cf83f2c47..322327e1e425e93a156969de836e251fe9dd08a3 100644 (file)
@@ -295,12 +295,12 @@ struct x264_t
     x264_pps_t      *pps;
     int             i_idr_pic_id;
 
-    int             dequant4_mf[4][6][4][4];
-    int             dequant8_mf[2][6][8][8];
-    int             quant4_mf[4][6][4][4];
-    int             quant8_mf[2][6][8][8];
-    int             unquant4_mf[4][52][16];
-    int             unquant8_mf[2][52][64];
+    int             (*dequant4_mf[4])[4][4]; /* [4][6][4][4] */
+    int             (*dequant8_mf[2])[8][8]; /* [2][6][8][8] */
+    int             (*quant4_mf[4])[4][4];   /* [4][6][4][4] */
+    int             (*quant8_mf[2])[8][8];   /* [2][6][8][8] */
+    int             (*unquant4_mf[4])[16];   /* [4][52][16] */
+    int             (*unquant8_mf[2])[64];   /* [2][52][64] */
 
     uint32_t        nr_residual_sum[2][64];
     uint32_t        nr_offset[2][64];
index d72763ff1328426f0dc9e248d69a1287e6c40d57..f6dc7c3d8284bfe58b04de8d0bdac82712f33d2e 100644 (file)
@@ -72,7 +72,27 @@ void x264_cqm_init( x264_t *h )
     int def_quant8[6][64];
     int def_dequant4[6][16];
     int def_dequant8[6][64];
-    int q, i, i_list;
+    int q, i, j, i_list;
+
+    for( i = 0; i < 6; i++ )
+    {
+        int size = i<4 ? 16 : 64;
+        for( j = (i<4 ? 0 : 4); j < i; j++ )
+            if( !memcmp( h->pps->scaling_list[i], h->pps->scaling_list[j], size*sizeof(uint8_t) ) )
+                break;
+        if( j < i )
+        {
+            h->  quant4_mf[i] = h->  quant4_mf[j];
+            h->dequant4_mf[i] = h->dequant4_mf[j];
+            h->unquant4_mf[i] = h->unquant4_mf[j];
+        }
+        else
+        {
+            h->  quant4_mf[i] = x264_malloc( 6*size*sizeof(int) );
+            h->dequant4_mf[i] = x264_malloc( 6*size*sizeof(int) );
+            h->unquant4_mf[i] = x264_malloc(52*size*sizeof(int) );
+        }
+    }
 
     for( q = 0; q < 6; q++ )
     {
@@ -116,6 +136,23 @@ void x264_cqm_init( x264_t *h )
     }
 }
 
+void x264_cqm_delete( x264_t *h )
+{
+    int i, j;
+    for( i = 0; i < 6; i++ )
+    {
+        for( j = 0; j < i; j++ )
+            if( h->quant4_mf[i] == h->quant4_mf[j] )
+                break;
+        if( j == i )
+        {
+            x264_free( h->  quant4_mf[i] );
+            x264_free( h->dequant4_mf[i] );
+            x264_free( h->unquant4_mf[i] );
+        }
+    }
+}
+
 int x264_cqm_parse_jmlist( x264_t *h, const char *buf, const char *name,
                            uint8_t *cqm, const uint8_t *jvt, int length )
 {
index 74fa64f2f92cb32946f5a63be7f050c750222952..86de444a814813dbf7c3622e977c422b15426b21 100644 (file)
@@ -219,6 +219,7 @@ static const uint8_t * const x264_cqm_jvt[6] =
 };
 
 void x264_cqm_init( x264_t *h );
+void x264_cqm_delete( x264_t *h );
 int  x264_cqm_parse_file( x264_t *h, const char *filename );
 
 #endif
index 51af962af2add8fc20d4857499f30c1aa9ee6253..c9b464c60221117247d9a7b8561fe5b0e0107d33 100644 (file)
@@ -1818,6 +1818,7 @@ void    x264_encoder_close  ( x264_t *h )
     if( h->param.rc.psz_rc_eq )
         free( h->param.rc.psz_rc_eq );
 
+    x264_cqm_delete( h );
     x264_macroblock_cache_end( h );
     x264_free( h->out.p_bitstream );
     for( i = 1; i < h->param.i_threads; i++ )