]> git.sesse.net Git - ffmpeg/commitdiff
15/16bit in C speedup
authorMichael Niedermayer <michaelni@gmx.at>
Wed, 31 Oct 2001 00:26:29 +0000 (00:26 +0000)
committerMichael Niedermayer <michaelni@gmx.at>
Wed, 31 Oct 2001 00:26:29 +0000 (00:26 +0000)
Originally committed as revision 2585 to svn://svn.mplayerhq.hu/mplayer/trunk/postproc

postproc/swscale.c
postproc/swscale_template.c

index 484f34998f07de6f5a3c34dd61426b4e82f36356..d703c65f92204f1f46c2f583faee7c8b97253138 100644 (file)
@@ -98,6 +98,13 @@ static uint16_t pix_buf_uv[2][2048*2];
 // clipping helper table for C implementations:
 static unsigned char clip_table[768];
 
+static unsigned short clip_table16b[768];
+static unsigned short clip_table16g[768];
+static unsigned short clip_table16r[768];
+static unsigned short clip_table15b[768];
+static unsigned short clip_table15g[768];
+static unsigned short clip_table15r[768];
+
 // yuv->rgb conversion tables:
 static    int yuvtab_2568[256];
 static    int yuvtab_3343[256];
@@ -702,9 +709,9 @@ FULL_YSCALEYUV2RGB
                                int V=((uvbuf0[i+2048]*uvalpha1+uvbuf1[i+2048]*uvalpha)>>19);
 
                                ((uint16_t*)dest)[i] =
-                                       (clip_table[(Y + yuvtab_40cf[U]) >>13]>>3) |
-                                       ((clip_table[(Y + yuvtab_1a1e[V] + yuvtab_0c92[U]) >>13]<<3)&0x07E0) |
-                                       ((clip_table[(Y + yuvtab_3343[V]) >>13]<<8)&0xF800);
+                                       clip_table16b[(Y + yuvtab_40cf[U]) >>13] |
+                                       clip_table16g[(Y + yuvtab_1a1e[V] + yuvtab_0c92[U]) >>13] |
+                                       clip_table16r[(Y + yuvtab_3343[V]) >>13];
                        }
                }
                else if(dstbpp==15)
@@ -716,9 +723,9 @@ FULL_YSCALEYUV2RGB
                                int V=((uvbuf0[i+2048]*uvalpha1+uvbuf1[i+2048]*uvalpha)>>19);
 
                                ((uint16_t*)dest)[i] =
-                                       (clip_table[(Y + yuvtab_40cf[U]) >>13]>>3) |
-                                       ((clip_table[(Y + yuvtab_1a1e[V] + yuvtab_0c92[U]) >>13]<<2)&0x03E0) |
-                                       ((clip_table[(Y + yuvtab_3343[V]) >>13]<<7)&0x7C00);
+                                       clip_table15b[(Y + yuvtab_40cf[U]) >>13] |
+                                       clip_table15g[(Y + yuvtab_1a1e[V] + yuvtab_0c92[U]) >>13] |
+                                       clip_table15r[(Y + yuvtab_3343[V]) >>13];
                        }
                }
 #endif
@@ -846,14 +853,14 @@ FULL_YSCALEYUV2RGB
                                int Cr= yuvtab_3343[V];
 
                                ((uint16_t*)dest)[i] =
-                                       (clip_table[(Y1 + Cb) >>13]>>3) |
-                                       ((clip_table[(Y1 + Cg) >>13]<<3)&0x07E0) |
-                                       ((clip_table[(Y1 + Cr) >>13]<<8)&0xF800);
+                                       clip_table16b[(Y1 + Cb) >>13] |
+                                       clip_table16g[(Y1 + Cg) >>13] |
+                                       clip_table16r[(Y1 + Cr) >>13];
 
                                ((uint16_t*)dest)[i+1] =
-                                       (clip_table[(Y2 + Cb) >>13]>>3) |
-                                       ((clip_table[(Y2 + Cg) >>13]<<3)&0x07E0) |
-                                       ((clip_table[(Y2 + Cr) >>13]<<8)&0xF800);
+                                       clip_table16b[(Y2 + Cb) >>13] |
+                                       clip_table16g[(Y2 + Cg) >>13] |
+                                       clip_table16r[(Y2 + Cr) >>13];
                        }
                }
                else if(dstbpp==15)
@@ -870,13 +877,14 @@ FULL_YSCALEYUV2RGB
                                int Cr= yuvtab_3343[V];
 
                                ((uint16_t*)dest)[i] =
-                                       (clip_table[(Y1 + Cb) >>13]>>3) |
-                                       ((clip_table[(Y1 + Cg) >>13]<<2)&0x03E0) |
-                                       ((clip_table[(Y1 + Cr) >>13]<<7)&0x7C00);
+                                       clip_table15b[(Y1 + Cb) >>13] |
+                                       clip_table15g[(Y1 + Cg) >>13] |
+                                       clip_table15r[(Y1 + Cr) >>13];
+
                                ((uint16_t*)dest)[i+1] =
-                                       (clip_table[(Y2 + Cb) >>13]>>3) |
-                                       ((clip_table[(Y2 + Cg) >>13]<<2)&0x03E0) |
-                                       ((clip_table[(Y2 + Cr) >>13]<<7)&0x7C00);
+                                       clip_table15b[(Y2 + Cb) >>13] |
+                                       clip_table15g[(Y2 + Cg) >>13] |
+                                       clip_table15r[(Y2 + Cr) >>13];
                        }
                }
 #endif
@@ -1075,14 +1083,14 @@ static inline void yuv2rgb1(uint16_t *buf0, uint16_t *buf1, uint16_t *uvbuf0, ui
                        int Cr= yuvtab_3343[V];
 
                        ((uint16_t*)dest)[i] =
-                               (clip_table[(Y1 + Cb) >>13]>>3) |
-                               ((clip_table[(Y1 + Cg) >>13]<<3)&0x07E0) |
-                               ((clip_table[(Y1 + Cr) >>13]<<8)&0xF800);
+                               clip_table16b[(Y1 + Cb) >>13] |
+                               clip_table16g[(Y1 + Cg) >>13] |
+                               clip_table16r[(Y1 + Cr) >>13];
 
                        ((uint16_t*)dest)[i+1] =
-                               (clip_table[(Y2 + Cb) >>13]>>3) |
-                               ((clip_table[(Y2 + Cg) >>13]<<3)&0x07E0) |
-                               ((clip_table[(Y2 + Cr) >>13]<<8)&0xF800);
+                               clip_table16b[(Y2 + Cb) >>13] |
+                               clip_table16g[(Y2 + Cg) >>13] |
+                               clip_table16r[(Y2 + Cr) >>13];
                }
        }
        else if(dstbpp==15)
@@ -1099,13 +1107,14 @@ static inline void yuv2rgb1(uint16_t *buf0, uint16_t *buf1, uint16_t *uvbuf0, ui
                        int Cr= yuvtab_3343[V];
 
                        ((uint16_t*)dest)[i] =
-                               (clip_table[(Y1 + Cb) >>13]>>3) |
-                               ((clip_table[(Y1 + Cg) >>13]<<2)&0x03E0) |
-                               ((clip_table[(Y1 + Cr) >>13]<<7)&0x7C00);
+                               clip_table15b[(Y1 + Cb) >>13] |
+                               clip_table15g[(Y1 + Cg) >>13] |
+                               clip_table15r[(Y1 + Cr) >>13];
+
                        ((uint16_t*)dest)[i+1] =
-                               (clip_table[(Y2 + Cb) >>13]>>3) |
-                               ((clip_table[(Y2 + Cg) >>13]<<2)&0x03E0) |
-                               ((clip_table[(Y2 + Cr) >>13]<<7)&0x7C00);
+                               clip_table15b[(Y2 + Cb) >>13] |
+                               clip_table15g[(Y2 + Cg) >>13] |
+                               clip_table15r[(Y2 + Cr) >>13];
                }
        }
 #endif
@@ -1666,4 +1675,15 @@ void SwScale_Init(){
        yuvtab_40cf[i]=0x40cf*(i-128);
     }
 
+    for(i=0; i<768; i++)
+    {
+       int v= clip_table[i];
+       clip_table16b[i]= v>>3;
+       clip_table16g[i]= (v<<3)&0x07E0;
+       clip_table16r[i]= (v<<8)&0xF800;
+       clip_table15b[i]= v>>3;
+       clip_table15g[i]= (v<<2)&0x03E0;
+       clip_table15r[i]= (v<<7)&0x7C00;
+    }
+
 }
index 484f34998f07de6f5a3c34dd61426b4e82f36356..d703c65f92204f1f46c2f583faee7c8b97253138 100644 (file)
@@ -98,6 +98,13 @@ static uint16_t pix_buf_uv[2][2048*2];
 // clipping helper table for C implementations:
 static unsigned char clip_table[768];
 
+static unsigned short clip_table16b[768];
+static unsigned short clip_table16g[768];
+static unsigned short clip_table16r[768];
+static unsigned short clip_table15b[768];
+static unsigned short clip_table15g[768];
+static unsigned short clip_table15r[768];
+
 // yuv->rgb conversion tables:
 static    int yuvtab_2568[256];
 static    int yuvtab_3343[256];
@@ -702,9 +709,9 @@ FULL_YSCALEYUV2RGB
                                int V=((uvbuf0[i+2048]*uvalpha1+uvbuf1[i+2048]*uvalpha)>>19);
 
                                ((uint16_t*)dest)[i] =
-                                       (clip_table[(Y + yuvtab_40cf[U]) >>13]>>3) |
-                                       ((clip_table[(Y + yuvtab_1a1e[V] + yuvtab_0c92[U]) >>13]<<3)&0x07E0) |
-                                       ((clip_table[(Y + yuvtab_3343[V]) >>13]<<8)&0xF800);
+                                       clip_table16b[(Y + yuvtab_40cf[U]) >>13] |
+                                       clip_table16g[(Y + yuvtab_1a1e[V] + yuvtab_0c92[U]) >>13] |
+                                       clip_table16r[(Y + yuvtab_3343[V]) >>13];
                        }
                }
                else if(dstbpp==15)
@@ -716,9 +723,9 @@ FULL_YSCALEYUV2RGB
                                int V=((uvbuf0[i+2048]*uvalpha1+uvbuf1[i+2048]*uvalpha)>>19);
 
                                ((uint16_t*)dest)[i] =
-                                       (clip_table[(Y + yuvtab_40cf[U]) >>13]>>3) |
-                                       ((clip_table[(Y + yuvtab_1a1e[V] + yuvtab_0c92[U]) >>13]<<2)&0x03E0) |
-                                       ((clip_table[(Y + yuvtab_3343[V]) >>13]<<7)&0x7C00);
+                                       clip_table15b[(Y + yuvtab_40cf[U]) >>13] |
+                                       clip_table15g[(Y + yuvtab_1a1e[V] + yuvtab_0c92[U]) >>13] |
+                                       clip_table15r[(Y + yuvtab_3343[V]) >>13];
                        }
                }
 #endif
@@ -846,14 +853,14 @@ FULL_YSCALEYUV2RGB
                                int Cr= yuvtab_3343[V];
 
                                ((uint16_t*)dest)[i] =
-                                       (clip_table[(Y1 + Cb) >>13]>>3) |
-                                       ((clip_table[(Y1 + Cg) >>13]<<3)&0x07E0) |
-                                       ((clip_table[(Y1 + Cr) >>13]<<8)&0xF800);
+                                       clip_table16b[(Y1 + Cb) >>13] |
+                                       clip_table16g[(Y1 + Cg) >>13] |
+                                       clip_table16r[(Y1 + Cr) >>13];
 
                                ((uint16_t*)dest)[i+1] =
-                                       (clip_table[(Y2 + Cb) >>13]>>3) |
-                                       ((clip_table[(Y2 + Cg) >>13]<<3)&0x07E0) |
-                                       ((clip_table[(Y2 + Cr) >>13]<<8)&0xF800);
+                                       clip_table16b[(Y2 + Cb) >>13] |
+                                       clip_table16g[(Y2 + Cg) >>13] |
+                                       clip_table16r[(Y2 + Cr) >>13];
                        }
                }
                else if(dstbpp==15)
@@ -870,13 +877,14 @@ FULL_YSCALEYUV2RGB
                                int Cr= yuvtab_3343[V];
 
                                ((uint16_t*)dest)[i] =
-                                       (clip_table[(Y1 + Cb) >>13]>>3) |
-                                       ((clip_table[(Y1 + Cg) >>13]<<2)&0x03E0) |
-                                       ((clip_table[(Y1 + Cr) >>13]<<7)&0x7C00);
+                                       clip_table15b[(Y1 + Cb) >>13] |
+                                       clip_table15g[(Y1 + Cg) >>13] |
+                                       clip_table15r[(Y1 + Cr) >>13];
+
                                ((uint16_t*)dest)[i+1] =
-                                       (clip_table[(Y2 + Cb) >>13]>>3) |
-                                       ((clip_table[(Y2 + Cg) >>13]<<2)&0x03E0) |
-                                       ((clip_table[(Y2 + Cr) >>13]<<7)&0x7C00);
+                                       clip_table15b[(Y2 + Cb) >>13] |
+                                       clip_table15g[(Y2 + Cg) >>13] |
+                                       clip_table15r[(Y2 + Cr) >>13];
                        }
                }
 #endif
@@ -1075,14 +1083,14 @@ static inline void yuv2rgb1(uint16_t *buf0, uint16_t *buf1, uint16_t *uvbuf0, ui
                        int Cr= yuvtab_3343[V];
 
                        ((uint16_t*)dest)[i] =
-                               (clip_table[(Y1 + Cb) >>13]>>3) |
-                               ((clip_table[(Y1 + Cg) >>13]<<3)&0x07E0) |
-                               ((clip_table[(Y1 + Cr) >>13]<<8)&0xF800);
+                               clip_table16b[(Y1 + Cb) >>13] |
+                               clip_table16g[(Y1 + Cg) >>13] |
+                               clip_table16r[(Y1 + Cr) >>13];
 
                        ((uint16_t*)dest)[i+1] =
-                               (clip_table[(Y2 + Cb) >>13]>>3) |
-                               ((clip_table[(Y2 + Cg) >>13]<<3)&0x07E0) |
-                               ((clip_table[(Y2 + Cr) >>13]<<8)&0xF800);
+                               clip_table16b[(Y2 + Cb) >>13] |
+                               clip_table16g[(Y2 + Cg) >>13] |
+                               clip_table16r[(Y2 + Cr) >>13];
                }
        }
        else if(dstbpp==15)
@@ -1099,13 +1107,14 @@ static inline void yuv2rgb1(uint16_t *buf0, uint16_t *buf1, uint16_t *uvbuf0, ui
                        int Cr= yuvtab_3343[V];
 
                        ((uint16_t*)dest)[i] =
-                               (clip_table[(Y1 + Cb) >>13]>>3) |
-                               ((clip_table[(Y1 + Cg) >>13]<<2)&0x03E0) |
-                               ((clip_table[(Y1 + Cr) >>13]<<7)&0x7C00);
+                               clip_table15b[(Y1 + Cb) >>13] |
+                               clip_table15g[(Y1 + Cg) >>13] |
+                               clip_table15r[(Y1 + Cr) >>13];
+
                        ((uint16_t*)dest)[i+1] =
-                               (clip_table[(Y2 + Cb) >>13]>>3) |
-                               ((clip_table[(Y2 + Cg) >>13]<<2)&0x03E0) |
-                               ((clip_table[(Y2 + Cr) >>13]<<7)&0x7C00);
+                               clip_table15b[(Y2 + Cb) >>13] |
+                               clip_table15g[(Y2 + Cg) >>13] |
+                               clip_table15r[(Y2 + Cr) >>13];
                }
        }
 #endif
@@ -1666,4 +1675,15 @@ void SwScale_Init(){
        yuvtab_40cf[i]=0x40cf*(i-128);
     }
 
+    for(i=0; i<768; i++)
+    {
+       int v= clip_table[i];
+       clip_table16b[i]= v>>3;
+       clip_table16g[i]= (v<<3)&0x07E0;
+       clip_table16r[i]= (v<<8)&0xF800;
+       clip_table15b[i]= v>>3;
+       clip_table15g[i]= (v<<2)&0x03E0;
+       clip_table15r[i]= (v<<7)&0x7C00;
+    }
+
 }