Try to optimize a bit the antialiasing thing
authorJérome Decoodt <djc@videolan.org>
Fri, 6 Jul 2007 07:33:15 +0000 (07:33 +0000)
committerJérome Decoodt <djc@videolan.org>
Fri, 6 Jul 2007 07:33:15 +0000 (07:33 +0000)
modules/video_filter/rotate.c

index 44aed33..5d85c18 100644 (file)
@@ -189,39 +189,42 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
             {
                 const int i_line_orig = (i_line_orig0>>12) + i_line_center;
                 const int i_col_orig  = (i_col_orig0>>12)  + i_col_center;
-                int i_line_percent = (i_line_orig0>>4) & 255;
-                int i_col_percent  = (i_col_orig0 >>4) & 255;
+                const uint8_t* p_orig_offset = p_in + i_line_orig * i_pitch
+                                                + i_col_orig;
+                const uint8_t i_line_percent = (i_line_orig0>>4) & 255;
+                const uint8_t i_col_percent  = (i_col_orig0 >>4) & 255;
 
                 if(    -1 <= i_line_orig && i_line_orig < i_visible_lines
                     && -1 <= i_col_orig  && i_col_orig  < i_visible_pitch )
                 {
-                    uint8_t i_curpix = black_pixel;
-                    uint8_t i_colpix = black_pixel;
-                    uint8_t i_linpix = black_pixel;
-                    uint8_t i_nexpix = black_pixel;
-                    if( ( 0 <= i_line_orig ) && ( 0 <= i_col_orig ) )
-                        i_curpix = p_in[i_line_orig*i_pitch+i_col_orig];
-                    if(  ( i_line_orig < i_visible_lines - 1)
-                      && ( i_col_orig >= 0 ) )
-                    {
-                        i_linpix=p_in[(i_line_orig+1)*i_pitch+i_col_orig];
-
-                    }
-                    if(  ( i_col_orig < i_visible_pitch - 1)
-                      && ( i_line_orig >= 0 ) )
-                    {
-                        i_colpix=p_in[i_line_orig*i_pitch+i_col_orig+1];
-                    }
-                    if( ( i_line_orig < i_visible_lines - 1)
-                     && ( i_col_orig  < i_visible_pitch - 1) )
-                        i_nexpix = p_in[(i_line_orig+1)*i_pitch+i_col_orig+1];
-
                 #define test 1
                 #undef test
                 #ifdef test
                     if( ( i_col_orig > i_visible_pitch/2 ) )
                 #endif
                     {
+                        uint8_t i_curpix = black_pixel;
+                        uint8_t i_colpix = black_pixel;
+                        uint8_t i_linpix = black_pixel;
+                        uint8_t i_nexpix = black_pixel;
+                        if( ( 0 <= i_line_orig ) && ( 0 <= i_col_orig ) )
+                            i_curpix = *p_orig_offset;
+                        p_orig_offset++;
+
+                        if(  ( i_col_orig < i_visible_pitch - 1)
+                             && ( i_line_orig >= 0 ) )
+                            i_colpix=*p_orig_offset;
+
+                        p_orig_offset+=i_pitch;
+                        if( ( i_line_orig < i_visible_lines - 1)
+                            && ( i_col_orig  < i_visible_pitch - 1) )
+                            i_nexpix=*p_orig_offset;
+
+                        p_orig_offset--;
+                        if(  ( i_line_orig < i_visible_lines - 1)
+                             && ( i_col_orig >= 0 ) )
+                            i_linpix=*p_orig_offset;
+
                         unsigned int temp = 0;
                         temp+= i_curpix *
                             (256 - i_line_percent) * ( 256 - i_col_percent );
@@ -238,7 +241,7 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
                     {   *p_out = black_pixel;
                     }
                     else
-                        *p_out = p_in[i_line_orig*i_pitch+i_col_orig];
+                        *p_out = *p_orig_offset;
                 #endif
                 #undef test
                 }