diff dsputil.c @ 764:d4726182dfd2 libavcodec

optimize block_permute() optimize dct_quantize_c() dont permute s->q_inter/intra_matrix
author michaelni
date Wed, 23 Oct 2002 15:11:07 +0000
parents 8e1f0939d15d
children eacc2dd8fd9d
line wrap: on
line diff
--- a/dsputil.c	Wed Oct 23 08:14:12 2002 +0000
+++ b/dsputil.c	Wed Oct 23 15:11:07 2002 +0000
@@ -1553,16 +1553,25 @@
     return s;
 }
 
-/* permute block according so that it corresponds to the MMX idct
-   order */
-void block_permute(INT16 *block, UINT8 *permutation)
+void ff_block_permute(INT16 *block, UINT8 *permutation, const UINT8 *scantable, int last)
 {
-	int i;
-	INT16 temp[64];
+    int i;
+    INT16 temp[64];
+    
+    if(last<=0) return;
+    if(permutation[1]==1) return; //FIXME its ok but not clean and might fail for some perms
 
-	for(i=0; i<64; i++) temp[ permutation[i] ] = block[i];
-
-	for(i=0; i<64; i++) block[i] = temp[i];
+    for(i=0; i<=last; i++){
+        const int j= scantable[i];
+        temp[j]= block[j];
+        block[j]=0;
+    }
+    
+    for(i=0; i<=last; i++){
+        const int j= scantable[i];
+        const int perm_j= permutation[j];
+        block[perm_j]= temp[j];
+    }
 }
 
 void clear_blocks_c(DCTELEM *blocks)