[svn] / branches / release-1_3-branch / xvidcore / src / image / image.c Repository:
ViewVC logotype

Diff of /branches/release-1_3-branch/xvidcore/src/image/image.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1664, Sat Dec 17 11:24:32 2005 UTC revision 1736, Fri Oct 13 11:26:18 2006 UTC
# Line 19  Line 19 
19   *  along with this program ; if not, write to the Free Software   *  along with this program ; if not, write to the Free Software
20   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
21   *   *
22   * $Id: image.c,v 1.33 2005-12-17 11:24:32 syskin Exp $   * $Id: image.c,v 1.38 2006-10-13 11:26:18 Skal Exp $
23   *   *
24   ****************************************************************************/   ****************************************************************************/
25    
# Line 34  Line 34 
34  #include "interpolate8x8.h"  #include "interpolate8x8.h"
35  #include "../utils/mem_align.h"  #include "../utils/mem_align.h"
36  #include "../motion/sad.h"  #include "../motion/sad.h"
37    #include "../utils/emms.h"
38    
39  #include "font.h"               /* XXX: remove later */  #include "font.h"               /* XXX: remove later */
40    
# Line 236  Line 237 
237          }          }
238  }  }
239    
 /* bframe encoding requires image-based u,v interpolation */  
240  void  void
241  image_interpolate(const IMAGE * refn,  image_interpolate(const uint8_t * refn,
242                                    IMAGE * refh,                                    uint8_t * refh,
243                                    IMAGE * refv,                                    uint8_t * refv,
244                                    IMAGE * refhv,                                    uint8_t * refhv,
245                                    uint32_t edged_width,                                    uint32_t edged_width,
246                                    uint32_t edged_height,                                    uint32_t edged_height,
247                                    uint32_t quarterpel,                                    uint32_t quarterpel,
# Line 250  Line 250 
250          const uint32_t offset = EDGE_SIZE2 * (edged_width + 1); /* we only interpolate half of the edge area */          const uint32_t offset = EDGE_SIZE2 * (edged_width + 1); /* we only interpolate half of the edge area */
251          const uint32_t stride_add = 7 * edged_width;          const uint32_t stride_add = 7 * edged_width;
252    
253          uint8_t *n_ptr, *h_ptr, *v_ptr, *hv_ptr;          uint8_t *n_ptr;
254            uint8_t *h_ptr, *v_ptr, *hv_ptr;
255          uint32_t x, y;          uint32_t x, y;
256    
257            n_ptr = (uint8_t*)refn;
258          n_ptr = refn->y;          h_ptr = refh;
259          h_ptr = refh->y;          v_ptr = refv;
         v_ptr = refv->y;  
260    
261          n_ptr -= offset;          n_ptr -= offset;
262          h_ptr -= offset;          h_ptr -= offset;
# Line 285  Line 285 
285                          n_ptr += stride_add;                          n_ptr += stride_add;
286                  }                  }
287    
288                  h_ptr = refh->y + (edged_height - EDGE_SIZE - EDGE_SIZE2)*edged_width - EDGE_SIZE2;                  h_ptr = refh + (edged_height - EDGE_SIZE - EDGE_SIZE2)*edged_width - EDGE_SIZE2;
289                  hv_ptr = refhv->y + (edged_height - EDGE_SIZE - EDGE_SIZE2)*edged_width - EDGE_SIZE2;                  hv_ptr = refhv + (edged_height - EDGE_SIZE - EDGE_SIZE2)*edged_width - EDGE_SIZE2;
290    
291                  for (y = 0; y < (edged_height - EDGE_SIZE); y = y + 8) {                  for (y = 0; y < (edged_height - EDGE_SIZE); y = y + 8) {
292                          hv_ptr -= stride_add;                          hv_ptr -= stride_add;
# Line 302  Line 302 
302                  }                  }
303          } else {          } else {
304    
305                  hv_ptr = refhv->y;                  hv_ptr = refhv;
306                  hv_ptr -= offset;                  hv_ptr -= offset;
307    
308                  for (y = 0; y < (edged_height - EDGE_SIZE); y += 8) {                  for (y = 0; y < (edged_height - EDGE_SIZE); y += 8) {
# Line 1015  Line 1015 
1015                  p += edged_width/2;                  p += edged_width/2;
1016          }          }
1017  }  }
1018    
1019    /****************************************************************************/
1020    
1021    static void (*deintl_core)(uint8_t *, int width, int height, const int stride) = 0;
1022    extern void xvid_deinterlace_sse(uint8_t *, int width, int height, const int stride);
1023    
1024    #define CLIP_255(x)   ( ((x)&~255) ? ((-(x)) >> (8*sizeof((x))-1))&0xff : (x) )
1025    
1026    static void deinterlace_c(uint8_t *pix, int width, int height, const int bps)
1027    {
1028      pix += bps;
1029      while(width-->0)
1030      {
1031        int p1 = pix[-bps];
1032        int p2 = pix[0];
1033        int p0 = p2;
1034        int j = (height>>1) - 1;
1035        int V;
1036        unsigned char *P = pix++;
1037        while(j-->0)
1038        {
1039          const int  p3 = P[  bps];
1040          const int  p4 = P[2*bps];
1041          V =  ((p1+p3+1)>>1) + ((p2 - ((p0+p4+1)>>1)) >> 2);
1042          P[0] = CLIP_255( V );
1043          p0 = p2;
1044          p1 = p3;
1045          p2 = p4;
1046          P += 2*bps;
1047        }
1048        V =  ((p1+p1+1)>>1) + ((p2 - ((p0+p2+1)>>1)) >> 2);
1049        P[0] = CLIP_255( V );
1050      }
1051    }
1052    #undef CLIP_255
1053    
1054    int xvid_image_deinterlace(xvid_image_t* img, int width, int height, int bottom_first)
1055    {
1056            if (height&1)
1057                    return 0;
1058            if (img->csp!=XVID_CSP_PLANAR && img->csp!=XVID_CSP_I420 && img->csp!=XVID_CSP_YV12)
1059                    return 0;       /* not yet supported */
1060            if (deintl_core==0) {
1061                    deintl_core = deinterlace_c;
1062    #ifdef ARCH_IS_IA32
1063                    {
1064                            int cpu_flags = check_cpu_features();
1065                            if (cpu_flags & XVID_CPU_MMX)
1066                                    deintl_core = xvid_deinterlace_sse;
1067                    }
1068    #endif
1069            }
1070            if (!bottom_first) {
1071                    deintl_core(img->plane[0], width,    height,    img->stride[0]);
1072                    deintl_core(img->plane[1], width>>1, height>>1, img->stride[1]);
1073                    deintl_core(img->plane[2], width>>1, height>>1, img->stride[2]);
1074            }
1075            else {
1076                    deintl_core((uint8_t *)img->plane[0] + ( height    -1)*img->stride[0], width,    height,    -img->stride[0]);
1077                    deintl_core((uint8_t *)img->plane[1] + ((height>>1)-1)*img->stride[1], width>>1, height>>1, -img->stride[1]);
1078                    deintl_core((uint8_t *)img->plane[2] + ((height>>1)-1)*img->stride[2], width>>1, height>>1, -img->stride[2]);
1079            }
1080            emms();
1081    
1082            return 1;
1083    }
1084    

Legend:
Removed from v.1664  
changed lines
  Added in v.1736

No admin address has been configured
ViewVC Help
Powered by ViewVC 1.0.4