Index: filters/adjust/filter_adjust.c
===================================================================
--- filters/adjust/filter_adjust.c	(revision 10781)
+++ filters/adjust/filter_adjust.c	(working copy)
@@ -34,12 +34,6 @@
 {
     VideoFilter vf;
 
-    int yend;
-    int cend;
-
-    int width;
-    int height;
-
 #ifdef MMX
     int yfilt;
     int cfilt;
@@ -141,62 +135,54 @@
 }
 #endif /* MMX */
 
-static void SetupSize(ThisFilter *filter, VideoFrameType inpixfmt,
-                      int *width, int *height)
-{
-    filter->width = *width;
-    filter->height = *height;
-
-    filter->yend = *width * *height;
-
-    switch (inpixfmt)
-    {
-        case FMT_YV12:
-            filter->cend = filter->yend + *width * *height / 2;
-            break;
-        case FMT_YUV422P:
-            filter->cend = filter->yend + *width * *height;
-            break;
-        default:
-            break;
-    }
-}
-
 int adjustFilter (VideoFilter *vf, VideoFrame *frame)
 {
     ThisFilter *filter = (ThisFilter *) vf;
     TF_VARS;
 
-    if (frame->width != filter->width || frame->height != filter->height)
-        SetupSize(filter, frame->codec, &frame->width, &frame->height);
-
     TF_START;
+    {
+        unsigned char *ybeg = frame->buf + frame->offsets[0];
+        unsigned char *yend = ybeg + (frame->pitches[0] * frame->height);
+        int cheight = (frame->codec == FMT_YV12) ?
+            (frame->height >> 1) : frame->height;
+        unsigned char *ubeg = frame->buf + frame->offsets[1];
+        unsigned char *uend = ubeg + (frame->pitches[1] * cheight);
+        unsigned char *vbeg = frame->buf + frame->offsets[2];
+        unsigned char *vend = ubeg + (frame->pitches[2] * cheight);
 
 #ifdef MMX
-    if (filter->yfilt)
-        adjustRegionMMX(frame->buf, frame->buf + filter->yend, filter->ytable,
-                        &(filter->yshift), &(filter->yscale), &(filter->ymin),
-                        mm_cpool + 1, mm_cpool + 2);
-    else
-        adjustRegion(frame->buf, frame->buf + filter->yend, filter->ytable);
+        if (filter->yfilt)
+            adjustRegionMMX(ybeg, yend, filter->ytable,
+                            &(filter->yshift), &(filter->yscale),
+                            &(filter->ymin), mm_cpool + 1, mm_cpool + 2);
+        else
+            adjustRegion(ybeg, yend, filter->ytable);
 
-    if (filter->cfilt)
-        adjustRegionMMX(frame->buf + filter->yend, frame->buf + filter->cend,
-                        filter->ctable, &(filter->cshift), &(filter->cscale),
-                        &(filter->cmin), mm_cpool + 3, mm_cpool + 4);
-    else
-        adjustRegion(frame->buf + filter->yend, frame->buf + filter->cend,
-                     filter->ctable);
+        if (filter->cfilt)
+        {
+            adjustRegionMMX(ubeg, uend, filter->ctable,
+                            &(filter->cshift), &(filter->cscale),
+                            &(filter->cmin), mm_cpool + 3, mm_cpool + 4);
+            adjustRegionMMX(vbeg, vend, filter->ctable,
+                            &(filter->cshift), &(filter->cscale),
+                            &(filter->cmin), mm_cpool + 3, mm_cpool + 4);
+        }
+        else
+        {
+            adjustRegion(ubeg, uend, filter->ctable);
+            adjustRegion(vbeg, vend, filter->ctable);
+        }
 
-    if (filter->yfilt || filter->cfilt)
-        emms();
+        if (filter->yfilt || filter->cfilt)
+            emms();
 
 #else /* MMX */
-    adjustRegion(frame->buf, frame->buf + filter->yend, filter->ytable);
-    adjustRegion(frame->buf + filter->yend, frame->buf + filter->cend,
-                 filter->ctable);
+        adjustRegion(ybeg, yend, filter->ytable);
+        adjustRegion(ubeg, uend, filter->ctable);
+        adjustRegion(vbeg, vend, filter->ctable);
 #endif /* MMX */
-
+    }
     TF_END(filter, "Adjust: ");
     return 0;
 }
@@ -249,11 +235,13 @@
 
 VideoFilter *
 newAdjustFilter (VideoFrameType inpixfmt, VideoFrameType outpixfmt, 
-                    int *width, int *height, char *options)
+                 int *width, int *height, char *options)
 {
     ThisFilter *filter;
     int numopts, ymin, ymax, cmin, cmax;
     float ygamma, cgamma;
+    (void) width;
+    (void) height;
 
     if (inpixfmt != outpixfmt ||
         (inpixfmt != FMT_YV12 && inpixfmt != FMT_YUV422P))
@@ -305,8 +293,6 @@
     fillTable (filter->ctable, cmin, cmax, 16, 240, cgamma);
 #endif
 
-    SetupSize(filter, inpixfmt, width, height);
-
     filter->vf.filter = &adjustFilter;
     filter->vf.cleanup = NULL;
     
Index: filters/kerneldeint/filter_kerneldeint.c
===================================================================
--- filters/kerneldeint/filter_kerneldeint.c	(revision 10781)
+++ filters/kerneldeint/filter_kerneldeint.c	(working copy)
@@ -16,6 +16,7 @@
 #include "config.h"
 #include "dsputil.h"
 
+#undef ABS
 #define ABS(A) ( (A) > 0 ? (A) : -(A) )
 #define CLAMP(A,L,U) ((A)>(U)?(U):((A)<(L)?(L):(A)))
 
@@ -35,20 +36,14 @@
 {
     VideoFilter vf;
 
-    int width;
-    int height;
-    int uoff;
-    int voff;
-    int cwidth;
-    int cheight;
     int threshold;
     int skipchroma;
     int mm_flags;
-    int size;
     void (*filtfunc)(uint8_t*, uint8_t*, int, int, int);
     mmx_t threshold_low;
     mmx_t threshold_high;
     uint8_t *line;
+    int linesize;
     TF_STRUCT;
 } ThisFilter;
 
@@ -249,44 +244,19 @@
 }
 #endif
 
-static void SetupSize(ThisFilter *filter, VideoFrameType inpixfmt,
-                      int *width, int *height)
-{
-    filter->width = *width;
-    filter->height = *height;
-    filter->cwidth = *width / 2;
-    filter->uoff = *width * *height;
-
-    switch (inpixfmt)
-    {
-        case FMT_YUV422P:
-            filter->voff = filter->uoff + *width * *height / 2;
-            filter->size = *width * *height * 2;
-            filter->cheight = *height;
-            break;
-        case FMT_YV12:
-            filter->voff = filter->uoff + *width * *height / 4;
-            filter->size = *width * *height * 3 / 2;
-            filter->cheight = *height / 2;
-            break;
-        default:
-            ;
-    }
-
-    if (filter->line)
-        free(filter->line);
-
-    filter->line = malloc(*width);
-}
-
 static int
 KernelDeint (VideoFilter * f, VideoFrame * frame)
 {
     ThisFilter *filter = (ThisFilter *) f;
     TF_VARS;
 
-    if (frame->width != filter->width || frame->height != filter->height)
-        SetupSize(filter, frame->codec, &frame->width, &frame->height);
+    if (frame->pitches[0] > filter->linesize)
+    {
+        if (filter->line)
+            free(filter->line);
+        filter->line = malloc(frame->pitches[0]);
+        filter->linesize = frame->pitches[0];
+    }
 
     if (!filter->line)
     {
@@ -295,19 +265,28 @@
     }
 
     TF_START;
-    (filter->filtfunc)(frame->buf, filter->line, filter->width,
-                           filter->height, filter->threshold);
-    if (!filter->skipchroma)
     {
-        (filter->filtfunc)(frame->buf + filter->uoff, filter->line,
-                           filter->cwidth, filter->cheight, filter->threshold);
-        (filter->filtfunc)(frame->buf + filter->voff, filter->line,
-                           filter->cwidth, filter->cheight, filter->threshold);
-    }
+        unsigned char *ybeg = frame->buf + frame->offsets[0];
+        unsigned char *ubeg = frame->buf + frame->offsets[1];
+        unsigned char *vbeg = frame->buf + frame->offsets[2];
+        int cheight = (frame->codec == FMT_YV12) ?
+            (frame->height >> 1) : frame->height;
+
+        (filter->filtfunc)(ybeg, filter->line, frame->pitches[0],
+                           frame->height, filter->threshold);
+
+        if (!filter->skipchroma)
+        {
+            (filter->filtfunc)(ubeg, filter->line, frame->pitches[1],
+                               cheight, filter->threshold);
+            (filter->filtfunc)(vbeg, filter->line, frame->pitches[2],
+                               cheight, filter->threshold);
+        }
 #ifdef MMX
-    if (filter->mm_flags)
-        emms();
+        if (filter->mm_flags)
+            emms();
 #endif
+    }
     TF_END(filter, "KernelDeint: ");
     return 0;
 }
@@ -315,7 +294,8 @@
 void
 CleanupKernelDeintFilter (VideoFilter * filter)
 {
-    free (((ThisFilter *)filter)->line);
+    if (((ThisFilter *)filter)->line)
+        free (((ThisFilter *)filter)->line);
 }
 
 VideoFilter *
@@ -324,6 +304,7 @@
 {
     ThisFilter *filter;
     int numopts;
+    (void) height;
 
     if ( inpixfmt != outpixfmt ||
         (inpixfmt != FMT_YV12 && inpixfmt != FMT_YUV422P) )
@@ -356,8 +337,8 @@
 #endif
         filter->filtfunc = &KDP;
 
-    filter->line = NULL;
-    SetupSize(filter, inpixfmt, width, height);
+    filter->line = malloc(*width);
+    filter->linesize = *width;
 
     if (filter->line == NULL)
     {
Index: filters/ivtc/filter_ivtc.c
===================================================================
--- filters/ivtc/filter_ivtc.c	(revision 10781)
+++ filters/ivtc/filter_ivtc.c	(working copy)
@@ -22,8 +22,6 @@
     VideoFilter vf;
 
     struct pullup_context *context;
-    int uoff;
-    int voff;
     int height;
     int width;
     int progressive_frame_seen;
@@ -31,6 +29,8 @@
     int apply_filter;
 } ThisFilter;
 
+static void SetupFilter(ThisFilter *vf, int width, int height, int *pitches);
+
 static inline void * memcpy_pic(void * dst, const void * src, int height, int dstStride, int srcStride)
 {
     void *retval=dst;
@@ -71,25 +71,20 @@
     if (!filter->apply_filter)
         return 1;
     
+    SetupFilter(filter, frame->width, frame->height, (int*)frame->pitches);
+
     struct pullup_buffer *b;
     struct pullup_frame *f;
-    int height  = frame->height;
-    int width   = frame->width;
-    int cwidth  = width / 2;
-    int cheight = height / 2;
+    int ypitch  = filter->context->stride[0];
+    int height  = filter->height;
+    int cpitch  = filter->context->stride[1];
+    int cheight = filter->height >> 1;
     int p = frame->top_field_first ^ 1;
 
     struct pullup_context *c = filter->context;
     if (c->bpp[0] == 0)
         c->bpp[0] = c->bpp[1] = c->bpp[2] = frame->bpp;
     
-    if ((frame->width != filter->width) ||
-        (frame->height != filter->height))
-    {
-        return 0;
-    }
-
-
     b = pullup_get_buffer(c,2);
     if (!b)
     {
@@ -98,9 +93,12 @@
         return 0;   
     }
         
-    memcpy_pic(b->planes[0], frame->buf, height, width, width);
-    memcpy_pic(b->planes[1], frame->buf + filter->uoff, cheight, cwidth, cwidth);
-    memcpy_pic(b->planes[2], frame->buf + filter->voff, cheight, cwidth, cwidth);
+    memcpy_pic(b->planes[0], frame->buf + frame->offsets[0],
+               height,  ypitch, ypitch);
+    memcpy_pic(b->planes[1], frame->buf + frame->offsets[1],
+               cheight, cpitch, cpitch);
+    memcpy_pic(b->planes[2], frame->buf + frame->offsets[2],
+               cheight, cpitch, cpitch);
 
     pullup_submit_field(c, b, p);
     pullup_submit_field(c, b, p^1);
@@ -142,11 +140,15 @@
         pullup_pack_frame(c, f);
     }
 
-    memcpy_pic(frame->buf, f->buffer->planes[0], height, width, width);
-    memcpy_pic(frame->buf + filter->uoff, f->buffer->planes[1], cheight, cwidth, cwidth);
-    memcpy_pic(frame->buf + filter->voff, f->buffer->planes[2], cheight, cwidth, cwidth);
+    memcpy_pic(frame->buf + frame->offsets[0], f->buffer->planes[0],
+               height,  ypitch, ypitch);
+    memcpy_pic(frame->buf + frame->offsets[1], f->buffer->planes[1],
+               cheight, cpitch, cpitch);
+    memcpy_pic(frame->buf + frame->offsets[2], f->buffer->planes[2],
+               cheight, cpitch, cpitch);
                             
     pullup_release_frame(f);
+
     return 1;
 }
 
@@ -156,6 +158,34 @@
     pullup_free_context((((ThisFilter *)filter)->context));    
 }
 
+static void SetupFilter(ThisFilter *vf, int width, int height, int *pitches)
+{
+    if (vf->width  == width  &&
+        vf->height == height &&
+        vf->context->stride[0] == pitches[0] && 
+        vf->context->stride[1] == pitches[1] &&
+        vf->context->stride[2] == pitches[2])
+    {
+        return;
+    }
+    
+    vf->width         = width;
+    vf->height        = height;
+
+    vf->context->w[0] = width;
+    vf->context->w[1] = width >> 1;
+    vf->context->w[2] = width >> 1;
+    vf->context->w[3] = 0;
+    vf->context->h[0] = height;
+    vf->context->h[1] = height >> 1;
+    vf->context->h[2] = height >> 1;
+    vf->context->h[3] = 0;
+    vf->context->stride[0] = pitches[0];
+    vf->context->stride[1] = pitches[1];
+    vf->context->stride[2] = pitches[2];
+    vf->context->stride[3] = 0;
+}
+
 VideoFilter *
 NewIvtcFilter (VideoFrameType inpixfmt, VideoFrameType outpixfmt,
                         int *width, int *height, char *options)
@@ -176,13 +206,10 @@
         return NULL;
     }
 
+    bzero (filter, sizeof (ThisFilter));
     filter->progressive_frame_seen = 0;
     filter->interlaced_frame_seen = 0;
     filter->apply_filter = 0;
-    filter->height = *height;
-    filter->width  = *width;
-    filter->uoff = *width * *height;
-    filter->voff = *width * *height  * 5 /  4;
     filter->context = pullup_alloc_context();
     struct pullup_context *c = filter->context;
     c->metric_plane = 0;
@@ -194,17 +221,11 @@
     c->nplanes = 4;
     pullup_preinit_context(c);
     c->bpp[0] = c->bpp[1] = c->bpp[2] = 0;
-    c->w[0] = *width;
-    c->h[0] = *height;
-    c->w[1] = c->w[2] = (*width >> 1);
-    c->h[1] = c->h[2] = (*height >> 1);
-    c->w[3] = 0;
-    c->h[3] = 0;
-    c->stride[0] = *width;
-    c->stride[1] = c->stride[2] = (*width >> 1);
-    c->stride[3] = c->w[3];
     c->background[1] = c->background[2]  = 128;
 
+    int pitches[3] = { *width, *width >> 1, *width >> 1 };
+    SetupFilter(filter, *width, *height, pitches);
+
 #ifdef HAVE_MMX
     c->cpu      |= PULLUP_CPU_MMX;
 #endif
