*** imgconvert.c.orig	Mon May 26 09:43:31 2008
--- imgconvert.c	Mon May 26 09:51:39 2008
***************
*** 1,3 ****
--- 1,5 ----
+ #define EJO_INTERLACED
+ #define EJO_INTERPOLATE
  /*
   * Misc image conversion routines
   * Copyright (c) 2001, 2002, 2003 Fabrice Bellard.
***************
*** 2353,2358 ****
--- 2355,2434 ----
      }
  }
  
+ #ifdef EJO_INTERLACED
+ /* 1x2 -> 2x1 */
+ 
+ /* Most 411 material comes from MiniDV camcorders.  This material
+    is almost always interlaced.  Scale 411 to 420 interlaced so
+    chroma chanel retains the correct information from both the odd
+    field and the even field.  */
+ 
+ # ifdef EJO_INTERPOLATE
+ static void conv411(uint8_t *dst, int dst_wrap,
+                     const uint8_t *src, int src_wrap,
+                     int width, int height)
+ {
+ 	static int eflag=0;
+     int i;
+     uint8_t *d;
+ 
+     width>>=1; width--;
+ 
+ 	if(!eflag) {
+ 		av_log(NULL,AV_LOG_DEBUG, "Using interlaced 75/25 conv411!\n");
+ 		eflag++;
+ 	}
+ 
+     for(i=0;i<height;i++){
+ 		const uint8_t *s1, *s2;
+ 		int j;
+ 		int k=(((i+1)>>1)<<2)-(i&1);
+         s1 = &src[k*src_wrap];
+ 		s2 = &src[(k+2-((i&1)<<2))*src_wrap];
+         d = &dst[i*dst_wrap];
+         for(j=0;j<width;j++){
+             d[0] = (3*s1[0]+s2[0]) >> 2;
+             d[1] = (3*(s1[0]+s1[1])+(s2[0]+s2[1])) >> 3;
+             s1++;
+             s2++;
+             d += 2;
+         }
+ 		d[0] = d[1] = (3*s1[0]+s2[0]) >> 2;
+     }
+ }
+ # else
+ static void conv411(uint8_t *dst, int dst_wrap,
+                     const uint8_t *src, int src_wrap,
+                     int width, int height)
+ {
+ 	static int eflag=0;
+     int i;
+     uint8_t *d;
+ 
+     width>>=1; width--;
+ 
+ 	if(!eflag) {
+ 		av_log(NULL,AV_LOG_DEBUG, "Using interlaced conv411!\n");
+ 		eflag++;
+ 	}
+ 
+     for(i=0;i<height;i++){
+ 		const uint8_t *s1;
+ 		int j;
+ 		int k=(((i+1)>>1)<<2)-(i&1);
+         s1 = &src[k*src_wrap];
+         d = &dst[i*dst_wrap];
+         for(j=0;j<width;j++){
+             d[0] = s1[0];
+             d[1] = (s1[0] + s1[1]) >> 1;
+             s1++;
+             d += 2;
+         }
+ 		d[0] = d[1] = s1[0];
+     }
+ }
+ # endif
+ #else
  /* 1x2 -> 2x1 */
  static void conv411(uint8_t *dst, int dst_wrap,
                      const uint8_t *src, int src_wrap,
***************
*** 2380,2385 ****
--- 2456,2462 ----
          dst += dst_wrap;
      }
  }
+ #endif
  
  /* XXX: always use linesize. Return -1 if not supported */
  int img_convert(AVPicture *dst, int dst_pix_fmt,
