diff -Naur MPlayer-1.0rc4_r31930.orig/libfaad2/structs.h MPlayer-1.0rc4_r31930/libfaad2/structs.h
--- MPlayer-1.0rc4_r31930.orig/libfaad2/structs.h	2008-01-26 19:31:48.000000000 +0100
+++ MPlayer-1.0rc4_r31930/libfaad2/structs.h	2010-08-06 21:00:34.000000000 +0200
@@ -325,7 +325,7 @@
     /*uint8_t*/ unsigned char aacSpectralDataResilienceFlag;
     /*uint8_t*/ unsigned char epConfig;
 
-    /*uint8_t*/ char sbr_present_flag;
+    /*uint8_t*/ signed char sbr_present_flag;
     /*uint8_t*/ char forceUpSampling;
     /*uint8_t*/ char downSampledSBR;
 } mp4AudioSpecificConfig;
diff -Naur MPlayer-1.0rc4_r31930.orig/libfaad2/structs.h.orig MPlayer-1.0rc4_r31930/libfaad2/structs.h.orig
--- MPlayer-1.0rc4_r31930.orig/libfaad2/structs.h.orig	1970-01-01 01:00:00.000000000 +0100
+++ MPlayer-1.0rc4_r31930/libfaad2/structs.h.orig	2008-01-26 19:31:48.000000000 +0100
@@ -0,0 +1,492 @@
+/*
+** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+**
+** Any non-GPL usage of this software or parts of this software is strictly
+** forbidden.
+**
+** Commercial non-GPL licensing of this software is possible.
+** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
+**
+** $Id: structs.h,v 1.42 2004/09/08 09:43:11 gcp Exp $
+**/
+
+#ifndef __STRUCTS_H__
+#define __STRUCTS_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "cfft.h"
+#ifdef SBR_DEC
+#include "sbr_dec.h"
+#endif
+
+#define MAX_CHANNELS        64
+#define MAX_SYNTAX_ELEMENTS 48
+#define MAX_WINDOW_GROUPS    8
+#define MAX_SFB             51
+#define MAX_LTP_SFB         40
+#define MAX_LTP_SFB_S        8
+
+/* used to save the prediction state */
+typedef struct {
+    int16_t r[2];
+    int16_t COR[2];
+    int16_t VAR[2];
+} pred_state;
+
+typedef struct {
+    uint16_t N;
+    cfft_info *cfft;
+    complex_t *sincos;
+#ifdef PROFILE
+    int64_t cycles;
+    int64_t fft_cycles;
+#endif
+} mdct_info;
+
+typedef struct
+{
+    const real_t *long_window[2];
+    const real_t *short_window[2];
+#ifdef LD_DEC
+    const real_t *ld_window[2];
+#endif
+
+    mdct_info *mdct256;
+#ifdef LD_DEC
+    mdct_info *mdct1024;
+#endif
+    mdct_info *mdct2048;
+#ifdef PROFILE
+    int64_t cycles;
+#endif
+} fb_info;
+
+typedef struct
+{
+    uint8_t present;
+
+    uint8_t num_bands;
+    uint8_t pce_instance_tag;
+    uint8_t excluded_chns_present;
+    uint8_t band_top[17];
+    uint8_t prog_ref_level;
+    uint8_t dyn_rng_sgn[17];
+    uint8_t dyn_rng_ctl[17];
+    uint8_t exclude_mask[MAX_CHANNELS];
+    uint8_t additional_excluded_chns[MAX_CHANNELS];
+
+    real_t ctrl1;
+    real_t ctrl2;
+} drc_info;
+
+typedef struct
+{
+    uint8_t element_instance_tag;
+    uint8_t object_type;
+    uint8_t sf_index;
+    uint8_t num_front_channel_elements;
+    uint8_t num_side_channel_elements;
+    uint8_t num_back_channel_elements;
+    uint8_t num_lfe_channel_elements;
+    uint8_t num_assoc_data_elements;
+    uint8_t num_valid_cc_elements;
+    uint8_t mono_mixdown_present;
+    uint8_t mono_mixdown_element_number;
+    uint8_t stereo_mixdown_present;
+    uint8_t stereo_mixdown_element_number;
+    uint8_t matrix_mixdown_idx_present;
+    uint8_t pseudo_surround_enable;
+    uint8_t matrix_mixdown_idx;
+    uint8_t front_element_is_cpe[16];
+    uint8_t front_element_tag_select[16];
+    uint8_t side_element_is_cpe[16];
+    uint8_t side_element_tag_select[16];
+    uint8_t back_element_is_cpe[16];
+    uint8_t back_element_tag_select[16];
+    uint8_t lfe_element_tag_select[16];
+    uint8_t assoc_data_element_tag_select[16];
+    uint8_t cc_element_is_ind_sw[16];
+    uint8_t valid_cc_element_tag_select[16];
+
+    uint8_t channels;
+
+    uint8_t comment_field_bytes;
+    uint8_t comment_field_data[257];
+
+    /* extra added values */
+    uint8_t num_front_channels;
+    uint8_t num_side_channels;
+    uint8_t num_back_channels;
+    uint8_t num_lfe_channels;
+    uint8_t sce_channel[16];
+    uint8_t cpe_channel[16];
+} program_config;
+
+typedef struct
+{
+    uint16_t syncword;
+    uint8_t id;
+    uint8_t layer;
+    uint8_t protection_absent;
+    uint8_t profile;
+    uint8_t sf_index;
+    uint8_t private_bit;
+    uint8_t channel_configuration;
+    uint8_t original;
+    uint8_t home;
+    uint8_t emphasis;
+    uint8_t copyright_identification_bit;
+    uint8_t copyright_identification_start;
+    uint16_t aac_frame_length;
+    uint16_t adts_buffer_fullness;
+    uint8_t no_raw_data_blocks_in_frame;
+    uint16_t crc_check;
+
+    /* control param */
+    uint8_t old_format;
+} adts_header;
+
+typedef struct
+{
+    uint8_t copyright_id_present;
+    int8_t copyright_id[10];
+    uint8_t original_copy;
+    uint8_t home;
+    uint8_t bitstream_type;
+    uint32_t bitrate;
+    uint8_t num_program_config_elements;
+    uint32_t adif_buffer_fullness;
+
+    /* maximum of 16 PCEs */
+    program_config pce[16];
+} adif_header;
+
+#ifdef LTP_DEC
+typedef struct
+{
+    uint8_t last_band;
+    uint8_t data_present;
+    uint16_t lag;
+    uint8_t lag_update;
+    uint8_t coef;
+    uint8_t long_used[MAX_SFB];
+    uint8_t short_used[8];
+    uint8_t short_lag_present[8];
+    uint8_t short_lag[8];
+} ltp_info;
+#endif
+
+#ifdef MAIN_DEC
+typedef struct
+{
+    uint8_t limit;
+    uint8_t predictor_reset;
+    uint8_t predictor_reset_group_number;
+    uint8_t prediction_used[MAX_SFB];
+} pred_info;
+#endif
+
+typedef struct
+{
+    uint8_t number_pulse;
+    uint8_t pulse_start_sfb;
+    uint8_t pulse_offset[4];
+    uint8_t pulse_amp[4];
+} pulse_info;
+
+typedef struct
+{
+    uint8_t n_filt[8];
+    uint8_t coef_res[8];
+    uint8_t length[8][4];
+    uint8_t order[8][4];
+    uint8_t direction[8][4];
+    uint8_t coef_compress[8][4];
+    uint8_t coef[8][4][32];
+} tns_info;
+
+#ifdef SSR_DEC
+typedef struct
+{
+    uint8_t max_band;
+
+    uint8_t adjust_num[4][8];
+    uint8_t alevcode[4][8][8];
+    uint8_t aloccode[4][8][8];
+} ssr_info;
+#endif
+
+typedef struct
+{
+    uint8_t max_sfb;
+
+    uint8_t num_swb;
+    uint8_t num_window_groups;
+    uint8_t num_windows;
+    uint8_t window_sequence;
+    uint8_t window_group_length[8];
+    uint8_t window_shape;
+    uint8_t scale_factor_grouping;
+    uint16_t sect_sfb_offset[8][15*8];
+    uint16_t swb_offset[52];
+
+    uint8_t sect_cb[8][15*8];
+    uint16_t sect_start[8][15*8];
+    uint16_t sect_end[8][15*8];
+    uint8_t sfb_cb[8][8*15];
+    uint8_t num_sec[8]; /* number of sections in a group */
+
+    uint8_t global_gain;
+    int16_t scale_factors[8][51]; /* [0..255] */
+
+    uint8_t ms_mask_present;
+    uint8_t ms_used[MAX_WINDOW_GROUPS][MAX_SFB];
+
+    uint8_t noise_used;
+
+    uint8_t pulse_data_present;
+    uint8_t tns_data_present;
+    uint8_t gain_control_data_present;
+    uint8_t predictor_data_present;
+
+    pulse_info pul;
+    tns_info tns;
+#ifdef MAIN_DEC
+    pred_info pred;
+#endif
+#ifdef LTP_DEC
+    ltp_info ltp;
+    ltp_info ltp2;
+#endif
+#ifdef SSR_DEC
+    ssr_info ssr;
+#endif
+
+#ifdef ERROR_RESILIENCE
+    /* ER HCR data */
+    uint16_t length_of_reordered_spectral_data;
+    uint8_t length_of_longest_codeword;
+    /* ER RLVC data */
+    uint8_t sf_concealment;
+    uint8_t rev_global_gain;
+    uint16_t length_of_rvlc_sf;
+    uint16_t dpcm_noise_nrg;
+    uint8_t sf_escapes_present;
+    uint8_t length_of_rvlc_escapes;
+    uint16_t dpcm_noise_last_position;
+#endif
+} ic_stream; /* individual channel stream */
+
+typedef struct
+{
+    uint8_t channel;
+    int16_t paired_channel;
+
+    uint8_t element_instance_tag;
+    uint8_t common_window;
+
+    ic_stream ics1;
+    ic_stream ics2;
+} element; /* syntax element (SCE, CPE, LFE) */
+
+typedef struct mp4AudioSpecificConfig
+{
+    /* Audio Specific Info */
+    /*uint8_t*/ unsigned char objectTypeIndex;
+    /*uint8_t*/ unsigned char samplingFrequencyIndex;
+    /*uint32_t*/ unsigned long samplingFrequency;
+    /*uint8_t*/ unsigned char channelsConfiguration;
+
+    /* GA Specific Info */
+    /*uint8_t*/ unsigned char frameLengthFlag;
+    /*uint8_t*/ unsigned char dependsOnCoreCoder;
+    /*uint16_t*/ unsigned short coreCoderDelay;
+    /*uint8_t*/ unsigned char extensionFlag;
+    /*uint8_t*/ unsigned char aacSectionDataResilienceFlag;
+    /*uint8_t*/ unsigned char aacScalefactorDataResilienceFlag;
+    /*uint8_t*/ unsigned char aacSpectralDataResilienceFlag;
+    /*uint8_t*/ unsigned char epConfig;
+
+    /*uint8_t*/ char sbr_present_flag;
+    /*uint8_t*/ char forceUpSampling;
+    /*uint8_t*/ char downSampledSBR;
+} mp4AudioSpecificConfig;
+
+#define MAX_ASC_BYTES 64
+typedef struct {
+    int inited;
+    int version, versionA;
+    int framelen_type;
+    int useSameStreamMux;
+    int allStreamsSameTimeFraming;
+    int numSubFrames;
+    int numPrograms;
+    int numLayers;
+    int otherDataPresent;
+    uint32_t otherDataLenBits;
+    uint32_t frameLength;
+    uint8_t ASC[MAX_ASC_BYTES];
+    uint32_t ASCbits;
+} latm_header;
+
+typedef struct NeAACDecConfiguration
+{
+    /*uint8_t*/ unsigned char defObjectType;
+    /*uint32_t*/ unsigned long defSampleRate;
+    /*uint8_t*/ unsigned char outputFormat;
+    /*uint8_t*/ unsigned char downMatrix;
+    /*uint8_t*/ unsigned char useOldADTSFormat;
+    /*uint8_t*/ unsigned char dontUpSampleImplicitSBR;
+} NeAACDecConfiguration, *NeAACDecConfigurationPtr;
+
+typedef struct NeAACDecFrameInfo
+{
+    /*uint32_t*/ unsigned long bytesconsumed;
+    /*uint32_t*/ unsigned long samples;
+    /*uint8_t*/ unsigned char channels;
+    /*uint8_t*/ unsigned char error;
+    /*uint32_t*/ unsigned long samplerate;
+
+    /* SBR: 0: off, 1: on; normal, 2: on; downsampled */
+    /*uint8_t*/ unsigned char sbr;
+
+    /* MPEG-4 ObjectType */
+    /*uint8_t*/ unsigned char object_type;
+
+    /* AAC header type; MP4 will be signalled as RAW also */
+    /*uint8_t*/ unsigned char header_type;
+
+    /* multichannel configuration */
+    /*uint8_t*/ unsigned char num_front_channels;
+    /*uint8_t*/ unsigned char num_side_channels;
+    /*uint8_t*/ unsigned char num_back_channels;
+    /*uint8_t*/ unsigned char num_lfe_channels;
+    /*uint8_t*/ unsigned char channel_position[MAX_CHANNELS];
+
+    /* PS: 0: off, 1: on */
+    /*uint8_t*/ unsigned char ps;
+} NeAACDecFrameInfo;
+
+typedef struct
+{
+    uint8_t adts_header_present;
+    uint8_t adif_header_present;
+    uint8_t latm_header_present;
+    uint8_t sf_index;
+    uint8_t object_type;
+    uint8_t channelConfiguration;
+#ifdef ERROR_RESILIENCE
+    uint8_t aacSectionDataResilienceFlag;
+    uint8_t aacScalefactorDataResilienceFlag;
+    uint8_t aacSpectralDataResilienceFlag;
+#endif
+    uint16_t frameLength;
+    uint8_t postSeekResetFlag;
+
+    uint32_t frame;
+
+    uint8_t downMatrix;
+    uint8_t upMatrix;
+    uint8_t first_syn_ele;
+    uint8_t has_lfe;
+    /* number of channels in current frame */
+    uint8_t fr_channels;
+    /* number of elements in current frame */
+    uint8_t fr_ch_ele;
+
+    /* element_output_channels:
+       determines the number of channels the element will output
+    */
+    uint8_t element_output_channels[MAX_SYNTAX_ELEMENTS];
+    /* element_alloced:
+       determines whether the data needed for the element is allocated or not
+    */
+    uint8_t element_alloced[MAX_SYNTAX_ELEMENTS];
+    /* alloced_channels:
+       determines the number of channels where output data is allocated for
+    */
+    uint8_t alloced_channels;
+
+    /* output data buffer */
+    void *sample_buffer;
+
+    uint8_t window_shape_prev[MAX_CHANNELS];
+#ifdef LTP_DEC
+    uint16_t ltp_lag[MAX_CHANNELS];
+#endif
+    fb_info *fb;
+    drc_info *drc;
+
+    real_t *time_out[MAX_CHANNELS];
+    real_t *fb_intermed[MAX_CHANNELS];
+
+#ifdef SBR_DEC
+    int8_t sbr_present_flag;
+    int8_t forceUpSampling;
+    int8_t downSampledSBR;
+    /* determines whether SBR data is allocated for the gives element */
+    uint8_t sbr_alloced[MAX_SYNTAX_ELEMENTS];
+
+    sbr_info *sbr[MAX_SYNTAX_ELEMENTS];
+#endif
+#if (defined(PS_DEC) || defined(DRM_PS))
+    uint8_t ps_used[MAX_SYNTAX_ELEMENTS];
+    uint8_t ps_used_global;
+#endif
+
+#ifdef SSR_DEC
+    real_t *ssr_overlap[MAX_CHANNELS];
+    real_t *prev_fmd[MAX_CHANNELS];
+    real_t ipqf_buffer[MAX_CHANNELS][4][96/4];
+#endif
+
+#ifdef MAIN_DEC
+    pred_state *pred_stat[MAX_CHANNELS];
+#endif
+#ifdef LTP_DEC
+    int16_t *lt_pred_stat[MAX_CHANNELS];
+#endif
+
+    /* Program Config Element */
+    uint8_t pce_set;
+    program_config pce;
+    uint8_t element_id[MAX_CHANNELS];
+    uint8_t internal_channel[MAX_CHANNELS];
+
+    /* Configuration data */
+    NeAACDecConfiguration config;
+
+#ifdef PROFILE
+    int64_t cycles;
+    int64_t spectral_cycles;
+    int64_t output_cycles;
+    int64_t scalefac_cycles;
+    int64_t requant_cycles;
+#endif
+    latm_header latm_config;
+} NeAACDecStruct, *NeAACDecHandle;
+
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff -Naur MPlayer-1.0rc4_r31930.orig/libmpcodecs/vf_dint.c MPlayer-1.0rc4_r31930/libmpcodecs/vf_dint.c
--- MPlayer-1.0rc4_r31930.orig/libmpcodecs/vf_dint.c	2010-02-21 16:48:03.000000000 +0100
+++ MPlayer-1.0rc4_r31930/libmpcodecs/vf_dint.c	2010-08-06 21:00:34.000000000 +0200
@@ -32,7 +32,7 @@
   float sense; // first parameter
   float level; // second parameter
   unsigned int imgfmt;
-  char diff;
+  signed char diff;
   uint32_t max;
 //  int dfr;
 //  int rdfr;
@@ -81,10 +81,10 @@
 
 static int put_image (struct vf_instance *vf, mp_image_t *mpi, double pts)
 {
-    char rrow0[MAXROWSIZE];
-    char rrow1[MAXROWSIZE];
-    char rrow2[MAXROWSIZE];
-    char *row0 = rrow0, *row1 = rrow1, *row2 = rrow2/*, *row3 = rrow3*/;
+    signed char rrow0[MAXROWSIZE];
+    signed char rrow1[MAXROWSIZE];
+    signed char rrow2[MAXROWSIZE];
+    signed char *row0 = rrow0, *row1 = rrow1, *row2 = rrow2/*, *row3 = rrow3*/;
     int rowsize = mpi->width;
     uint32_t nok = 0, max = vf->priv->max;
     int diff = vf->priv->diff;
diff -Naur MPlayer-1.0rc4_r31930.orig/libmpcodecs/vf_dint.c.orig MPlayer-1.0rc4_r31930/libmpcodecs/vf_dint.c.orig
--- MPlayer-1.0rc4_r31930.orig/libmpcodecs/vf_dint.c.orig	1970-01-01 01:00:00.000000000 +0100
+++ MPlayer-1.0rc4_r31930/libmpcodecs/vf_dint.c.orig	2010-02-21 16:48:03.000000000 +0100
@@ -0,0 +1,214 @@
+/*
+ * This file is part of MPlayer.
+ *
+ * MPlayer is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * MPlayer is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with MPlayer; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <inttypes.h>
+
+#include "config.h"
+#include "mp_msg.h"
+
+#include "mp_image.h"
+#include "img_format.h"
+#include "vf.h"
+
+struct vf_priv_s {
+  float sense; // first parameter
+  float level; // second parameter
+  unsigned int imgfmt;
+  char diff;
+  uint32_t max;
+//  int dfr;
+//  int rdfr;
+  int was_dint;
+  mp_image_t *pmpi; // previous mpi
+};
+
+#define MAXROWSIZE 1200
+
+static int config (struct vf_instance *vf,
+        int width, int height, int d_width, int d_height,
+	unsigned int flags, unsigned int outfmt)
+{
+    int rowsize;
+
+    vf->priv->pmpi = vf_get_image (vf->next, outfmt, MP_IMGTYPE_TEMP,
+				   0, width, height);
+    if (!(vf->priv->pmpi->flags & MP_IMGFLAG_PLANAR) &&
+	outfmt != IMGFMT_RGB32 && outfmt != IMGFMT_BGR32 &&
+	outfmt != IMGFMT_RGB24 && outfmt != IMGFMT_BGR24 &&
+	outfmt != IMGFMT_RGB16 && outfmt != IMGFMT_BGR16)
+    {
+      mp_msg (MSGT_VFILTER, MSGL_WARN, "Drop-interlaced filter doesn't support this outfmt :(\n");
+      return 0;
+    }
+    vf->priv->imgfmt = outfmt;
+    // recalculate internal values
+    rowsize = vf->priv->pmpi->width;
+    if (rowsize > MAXROWSIZE) rowsize = MAXROWSIZE;
+    vf->priv->max = vf->priv->level * vf->priv->pmpi->height * rowsize / 2;
+    if (vf->priv->pmpi->flags & MP_IMGFLAG_PLANAR) // planar YUV
+      vf->priv->diff = vf->priv->sense * 256;
+    else
+      vf->priv->diff = vf->priv->sense * (1 << (vf->priv->pmpi->bpp/3));
+    if (vf->priv->diff < 0) vf->priv->diff = 0;
+    if (!(vf->priv->pmpi->flags & MP_IMGFLAG_PLANAR) &&
+	vf->priv->pmpi->bpp < 24 && vf->priv->diff > 31)
+      vf->priv->diff = 31;
+    mp_msg (MSGT_VFILTER, MSGL_INFO, "Drop-interlaced: %dx%d diff %d / level %u\n",
+	   vf->priv->pmpi->width, vf->priv->pmpi->height,
+	   (int)vf->priv->diff, (unsigned int)vf->priv->max);
+//    vf->priv->rdfr = vf->priv->dfr = 0;
+    vf->priv->was_dint = 0;
+    return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt);
+}
+
+static int put_image (struct vf_instance *vf, mp_image_t *mpi, double pts)
+{
+    char rrow0[MAXROWSIZE];
+    char rrow1[MAXROWSIZE];
+    char rrow2[MAXROWSIZE];
+    char *row0 = rrow0, *row1 = rrow1, *row2 = rrow2/*, *row3 = rrow3*/;
+    int rowsize = mpi->width;
+    uint32_t nok = 0, max = vf->priv->max;
+    int diff = vf->priv->diff;
+    int i, j;
+    register int n1, n2;
+    unsigned char *cur0, *prv0;
+    register unsigned char *cur, *prv;
+
+    if (rowsize > MAXROWSIZE) rowsize = MAXROWSIZE;
+    // check if nothing to do
+    if (mpi->imgfmt == vf->priv->imgfmt)
+    {
+      cur0 = mpi->planes[0] + mpi->stride[0];
+      prv0 = mpi->planes[0];
+      for (j = 1; j < mpi->height && nok <= max; j++)
+      {
+	cur = cur0;
+	prv = prv0;
+	// analyse row (row0)
+	if (mpi->flags & MP_IMGFLAG_PLANAR) // planar YUV - check luminance
+	  for (i = 0; i < rowsize; i++)
+	  {
+	    if (cur[0] - prv[0] > diff)
+	      row0[i] = 1;
+	    else if (cur[0] - prv[0] < -diff)
+	      row0[i] = -1;
+	    else
+	      row0[i] = 0;
+	    cur++;
+	    prv++;
+	    // check if row0 is 1 but row1 is 0, and row2 is 1 or row2 is 0
+	    // but row3 is 1 so it's interlaced ptr (nok++)
+	    if (j > 2 && row0[i] > 0 && (row1[i] < 0 || (!row1[i] && row2[i] < 0)) &&
+		(++nok) > max)
+	      break;
+	  }
+	else if (mpi->bpp < 24) // RGB/BGR 16 - check all colors
+	  for (i = 0; i < rowsize; i++)
+	  {
+	    n1 = cur[0] + (cur[1]<<8);
+	    n2 = prv[0] + (prv[1]<<8);
+	    if ((n1&0x1f) - (n2&0x1f) > diff ||
+		((n1>>5)&0x3f) - ((n2>>5)&0x3f) > diff ||
+		((n1>>11)&0x1f) - ((n2>>11)&0x1f) > diff)
+	      row0[i] = 1;
+	    else if ((n1&0x1f) - (n2&0x1f) < -diff ||
+		     ((n1>>5)&0x3f) - ((n2>>5)&0x3f) < -diff ||
+		     ((n1>>11)&0x1f) - ((n2>>11)&0x1f) < -diff)
+	      row0[i] = -1;
+	    else
+	      row0[i] = 0;
+	    cur += 2;
+	    prv += 2;
+	    // check if row0 is 1 but row1 is 0, and row2 is 1 or row2 is 0
+	    // but row3 is 1 so it's interlaced ptr (nok++)
+	    if (j > 2 && row0[i] > 0 && (row1[i] < 0 || (!row1[i] && row2[i] < 0)) &&
+		(++nok) > max)
+	      break;
+	  }
+	else // RGB/BGR 24/32
+	  for (i = 0; i < rowsize; i++)
+	  {
+	    if (cur[0] - prv[0] > diff ||
+		cur[1] - prv[1] > diff ||
+		cur[2] - prv[2] > diff)
+	      row0[i] = 1;
+	    else if (prv[0] - cur[0] > diff ||
+		     prv[1] - cur[1] > diff ||
+		     prv[2] - cur[2] > diff)
+	      row0[i] = -1;
+	    else
+	      row0[i] = 0;
+	    cur += mpi->bpp/8;
+	    prv += mpi->bpp/8;
+	    // check if row0 is 1 but row1 is 0, and row2 is 1 or row2 is 0
+	    // but row3 is 1 so it's interlaced ptr (nok++)
+	    if (j > 2 && row0[i] > 0 && (row1[i] < 0 || (!row1[i] && row2[i] < 0)) &&
+		(++nok) > max)
+	      break;
+	  }
+	cur0 += mpi->stride[0];
+	prv0 += mpi->stride[0];
+	// rotate rows
+	cur = row2;
+	row2 = row1;
+	row1 = row0;
+	row0 = cur;
+      }
+    }
+    // check if number of interlaced is above of max
+    if (nok > max)
+    {
+//      vf->priv->dfr++;
+      if (vf->priv->was_dint < 1) // can skip at most one frame!
+      {
+	vf->priv->was_dint++;
+//	vf->priv->rdfr++;
+//	mp_msg (MSGT_VFILTER, MSGL_INFO, "DI:%d/%d ", vf->priv->rdfr, vf->priv->dfr);
+	return 0;
+      }
+    }
+    vf->priv->was_dint = 0;
+//    mp_msg (MSGT_VFILTER, MSGL_INFO, "DI:%d/%d ", vf->priv->rdfr, vf->priv->dfr);
+    return vf_next_put_image (vf, mpi, pts);
+}
+
+static int vf_open(vf_instance_t *vf, char *args){
+    vf->config = config;
+    vf->put_image = put_image;
+//    vf->default_reqs=VFCAP_ACCEPT_STRIDE;
+    vf->priv = malloc (sizeof(struct vf_priv_s));
+    vf->priv->sense = 0.1;
+    vf->priv->level = 0.15;
+    vf->priv->pmpi = NULL;
+    if (args)
+      sscanf (args, "%f:%f", &vf->priv->sense, &vf->priv->level);
+    return 1;
+}
+
+const vf_info_t vf_info_dint = {
+    "drop interlaced frames",
+    "dint",
+    "A.G.",
+    "",
+    vf_open,
+    NULL
+};
diff -Naur MPlayer-1.0rc4_r31930.orig/libmpcodecs/vf_divtc.c MPlayer-1.0rc4_r31930/libmpcodecs/vf_divtc.c
--- MPlayer-1.0rc4_r31930.orig/libmpcodecs/vf_divtc.c	2010-02-21 16:48:03.000000000 +0100
+++ MPlayer-1.0rc4_r31930/libmpcodecs/vf_divtc.c	2010-08-06 21:00:34.000000000 +0200
@@ -384,7 +384,7 @@
    {
    int *buf=0, *bp, bufsize=0, n, b, f, i, j, m, s;
    unsigned int *cbuf=0, *cp;
-   char *pbuf;
+   signed char *pbuf;
    char lbuf[256];
    int sum[5];
    double d;
diff -Naur MPlayer-1.0rc4_r31930.orig/libmpcodecs/vf_divtc.c.orig MPlayer-1.0rc4_r31930/libmpcodecs/vf_divtc.c.orig
--- MPlayer-1.0rc4_r31930.orig/libmpcodecs/vf_divtc.c.orig	1970-01-01 01:00:00.000000000 +0100
+++ MPlayer-1.0rc4_r31930/libmpcodecs/vf_divtc.c.orig	2010-02-21 16:48:03.000000000 +0100
@@ -0,0 +1,720 @@
+/*
+ * This file is part of MPlayer.
+ *
+ * MPlayer is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * MPlayer is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with MPlayer; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <limits.h>
+#include <math.h>
+
+#include "config.h"
+#include "mp_msg.h"
+#include "cpudetect.h"
+#include "libavutil/common.h"
+#include "mpbswap.h"
+
+#include "img_format.h"
+#include "mp_image.h"
+#include "vf.h"
+
+#include "libvo/fastmemcpy.h"
+
+const vf_info_t vf_info_divtc;
+
+struct vf_priv_s
+   {
+   int deghost, pass, phase, window, fcount, bcount, frameno, misscount,
+      ocount, sum[5];
+   double threshold;
+   FILE *file;
+   char *bdata;
+   unsigned int *csdata;
+   int *history;
+   };
+
+/*
+ * diff_MMX and diff_C stolen from vf_decimate.c
+ */
+
+#if HAVE_MMX && HAVE_EBX_AVAILABLE
+static int diff_MMX(unsigned char *old, unsigned char *new, int os, int ns)
+   {
+   volatile short out[4];
+   __asm__ (
+	"movl $8, %%ecx \n\t"
+	"pxor %%mm4, %%mm4 \n\t"
+	"pxor %%mm7, %%mm7 \n\t"
+
+	ASMALIGN(4)
+	"1: \n\t"
+
+	"movq (%%"REG_S"), %%mm0 \n\t"
+	"movq (%%"REG_S"), %%mm2 \n\t"
+	"add %%"REG_a", %%"REG_S" \n\t"
+	"movq (%%"REG_D"), %%mm1 \n\t"
+	"add %%"REG_b", %%"REG_D" \n\t"
+	"psubusb %%mm1, %%mm2 \n\t"
+	"psubusb %%mm0, %%mm1 \n\t"
+	"movq %%mm2, %%mm0 \n\t"
+	"movq %%mm1, %%mm3 \n\t"
+	"punpcklbw %%mm7, %%mm0 \n\t"
+	"punpcklbw %%mm7, %%mm1 \n\t"
+	"punpckhbw %%mm7, %%mm2 \n\t"
+	"punpckhbw %%mm7, %%mm3 \n\t"
+	"paddw %%mm0, %%mm4 \n\t"
+	"paddw %%mm1, %%mm4 \n\t"
+	"paddw %%mm2, %%mm4 \n\t"
+	"paddw %%mm3, %%mm4 \n\t"
+
+	"decl %%ecx \n\t"
+	"jnz 1b \n\t"
+	"movq %%mm4, (%%"REG_d") \n\t"
+	"emms \n\t"
+	:
+	: "S" (old), "D" (new), "a" ((long)os), "b" ((long)ns), "d" (out)
+	: "%ecx", "memory"
+	);
+   return out[0]+out[1]+out[2]+out[3];
+   }
+#endif
+
+static int diff_C(unsigned char *old, unsigned char *new, int os, int ns)
+   {
+   int x, y, d=0;
+
+   for(y=8; y; y--, new+=ns, old+=os)
+      for(x=8; x; x--)
+	 d+=abs(new[x]-old[x]);
+
+   return d;
+   }
+
+static int (*diff)(unsigned char *, unsigned char *, int, int);
+
+static int diff_plane(unsigned char *old, unsigned char *new,
+		      int w, int h, int os, int ns, int arg)
+   {
+   int x, y, d, max=0, sum=0, n=0;
+
+   for(y=0; y<h-7; y+=8)
+      {
+      for(x=0; x<w-7; x+=8)
+	 {
+	 d=diff(old+x+y*os, new+x+y*ns, os, ns);
+	 if(d>max) max=d;
+	 sum+=d;
+	 n++;
+	 }
+      }
+
+   return (sum+n*max)/2;
+   }
+
+/*
+static unsigned int checksum_plane(unsigned char *p, unsigned char *z,
+				   int w, int h, int s, int zs, int arg)
+   {
+   unsigned int shift, sum;
+   unsigned char *e;
+
+   for(sum=0; h; h--, p+=s-w)
+      for(e=p+w, shift=32; p<e;)
+	 sum^=(*p++)<<(shift=(shift-8)&31);
+
+   return sum;
+   }
+*/
+
+static unsigned int checksum_plane(unsigned char *p, unsigned char *z,
+				   int w, int h, int s, int zs, int arg)
+   {
+   unsigned int shift;
+   uint32_t sum, t;
+   unsigned char *e, *e2;
+#if HAVE_FAST_64BIT
+   typedef uint64_t wsum_t;
+#else
+   typedef uint32_t wsum_t;
+#endif
+   wsum_t wsum;
+
+   for(sum=0; h; h--, p+=s-w)
+      {
+      for(shift=0, e=p+w; (int)p&(sizeof(wsum_t)-1) && p<e;)
+	 sum^=*p++<<(shift=(shift-8)&31);
+
+      for(wsum=0, e2=e-sizeof(wsum_t)+1; p<e2; p+=sizeof(wsum_t))
+	 wsum^=*(wsum_t *)p;
+
+#if HAVE_FAST_64BIT
+      t=be2me_32((uint32_t)(wsum>>32^wsum));
+#else
+      t=be2me_32(wsum);
+#endif
+
+      for(sum^=(t<<shift|t>>(32-shift)); p<e;)
+	 sum^=*p++<<(shift=(shift-8)&31);
+      }
+
+   return sum;
+   }
+
+static int deghost_plane(unsigned char *d, unsigned char *s,
+			 int w, int h, int ds, int ss, int threshold)
+   {
+   int t;
+   unsigned char *e;
+
+   for(; h; h--, s+=ss-w, d+=ds-w)
+      for(e=d+w; d<e; d++, s++)
+	 if(abs(*d-*s)>=threshold)
+	    *d=(t=(*d<<1)-*s)<0?0:t>255?255:t;
+
+   return 0;
+   }
+
+static int copyop(unsigned char *d, unsigned char *s, int bpl, int h, int dstride, int sstride, int dummy) {
+  memcpy_pic(d, s, bpl, h, dstride, sstride);
+  return 0;
+}
+
+static int imgop(int(*planeop)(unsigned char *, unsigned char *,
+			       int, int, int, int, int),
+		 mp_image_t *dst, mp_image_t *src, int arg)
+   {
+   if(dst->flags&MP_IMGFLAG_PLANAR)
+      return planeop(dst->planes[0], src?src->planes[0]:0,
+		     dst->w, dst->h,
+		     dst->stride[0], src?src->stride[0]:0, arg)+
+	     planeop(dst->planes[1], src?src->planes[1]:0,
+		     dst->chroma_width, dst->chroma_height,
+		     dst->stride[1], src?src->stride[1]:0, arg)+
+	     planeop(dst->planes[2], src?src->planes[2]:0,
+		     dst->chroma_width, dst->chroma_height,
+		     dst->stride[2], src?src->stride[2]:0, arg);
+
+   return planeop(dst->planes[0], src?src->planes[0]:0,
+		  dst->w*(dst->bpp/8), dst->h,
+		  dst->stride[0], src?src->stride[0]:0, arg);
+   }
+
+/*
+ * Find the phase in which the telecine pattern fits best to the
+ * given 5 frame slice of frame difference measurements.
+ *
+ * If phase1 and phase2 are not negative, only the two specified
+ * phases are tested.
+ */
+
+static int match(struct vf_priv_s *p, int *diffs,
+		 int phase1, int phase2, double *strength)
+   {
+   static const int pattern1[]={ -4,  1, 1, 1, 1 },
+      pattern2[]={ -2, -3, 4, 4, -3 }, *pattern;
+   int f, m, n, t[5];
+
+   pattern=p->deghost>0?pattern2:pattern1;
+
+   for(f=0; f<5; f++)
+      {
+      if(phase1<0 || phase2<0 || f==phase1 || f==phase2)
+	 {
+	 for(n=t[f]=0; n<5; n++)
+	    t[f]+=diffs[n]*pattern[(n-f+5)%5];
+	 }
+      else
+	 t[f]=INT_MIN;
+      }
+
+   /* find the best match */
+   for(m=0, n=1; n<5; n++)
+      if(t[n]>t[m]) m=n;
+
+   if(strength)
+      {
+      /* the second best match */
+      for(f=m?0:1, n=f+1; n<5; n++)
+	 if(n!=m && t[n]>t[f]) f=n;
+
+      *strength=(t[m]>0?(double)(t[m]-t[f])/t[m]:0.0);
+      }
+
+   return m;
+   }
+
+static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts)
+   {
+   mp_image_t *dmpi, *tmpi=0;
+   int n, m, f, newphase;
+   struct vf_priv_s *p=vf->priv;
+   unsigned int checksum;
+   double d;
+
+   dmpi=vf_get_image(vf->next, mpi->imgfmt,
+		     MP_IMGTYPE_STATIC, MP_IMGFLAG_ACCEPT_STRIDE |
+		     MP_IMGFLAG_PRESERVE | MP_IMGFLAG_READABLE,
+		     mpi->width, mpi->height);
+   vf_clone_mpi_attributes(dmpi, mpi);
+
+   newphase=p->phase;
+
+   switch(p->pass)
+      {
+      case 1:
+	 fprintf(p->file, "%08x %d\n",
+		 (unsigned int)imgop((void *)checksum_plane, mpi, 0, 0),
+		 p->frameno?imgop(diff_plane, dmpi, mpi, 0):0);
+	 break;
+
+      case 2:
+	 if(p->frameno/5>p->bcount)
+	    {
+	    mp_msg(MSGT_VFILTER, MSGL_ERR,
+		   "\n%s: Log file ends prematurely! "
+		   "Switching to one pass mode.\n", vf->info->name);
+	    p->pass=0;
+	    break;
+	    }
+
+	 checksum=(unsigned int)imgop((void *)checksum_plane, mpi, 0, 0);
+
+	 if(checksum!=p->csdata[p->frameno])
+	    {
+	    for(f=0; f<100; f++)
+	       if(p->frameno+f<p->fcount && p->csdata[p->frameno+f]==checksum)
+		  break;
+	       else if(p->frameno-f>=0 && p->csdata[p->frameno-f]==checksum)
+		  {
+		  f=-f;
+		  break;
+		  }
+
+	    if(f<100)
+	       {
+	       mp_msg(MSGT_VFILTER, MSGL_INFO,
+		      "\n%s: Mismatch with pass-1: %+d frame(s).\n",
+		      vf->info->name, f);
+
+	       p->frameno+=f;
+	       p->misscount=0;
+	       }
+	    else if(p->misscount++>=30)
+	       {
+	       mp_msg(MSGT_VFILTER, MSGL_ERR,
+		      "\n%s: Sync with pass-1 lost! "
+		      "Switching to one pass mode.\n", vf->info->name);
+	       p->pass=0;
+	       break;
+	       }
+	    }
+
+	 n=(p->frameno)/5;
+	 if(n>=p->bcount) n=p->bcount-1;
+
+	 newphase=p->bdata[n];
+	 break;
+
+      default:
+	 if(p->frameno)
+	    {
+	    int *sump=p->sum+p->frameno%5,
+	       *histp=p->history+p->frameno%p->window;
+
+	    *sump-=*histp;
+	    *sump+=(*histp=imgop(diff_plane, dmpi, mpi, 0));
+	    }
+
+	 m=match(p, p->sum, -1, -1, &d);
+
+	 if(d>=p->threshold)
+	    newphase=m;
+      }
+
+   n=p->ocount++%5;
+
+   if(newphase!=p->phase && ((p->phase+4)%5<n)==((newphase+4)%5<n))
+      {
+      p->phase=newphase;
+      mp_msg(MSGT_VFILTER, MSGL_STATUS,
+	     "\n%s: Telecine phase %d.\n", vf->info->name, p->phase);
+      }
+
+   switch((p->frameno++-p->phase+10)%5)
+      {
+      case 0:
+	 imgop(copyop, dmpi, mpi, 0);
+	 return 0;
+
+      case 4:
+	 if(p->deghost>0)
+	    {
+	    tmpi=vf_get_image(vf->next, mpi->imgfmt,
+			      MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE |
+			      MP_IMGFLAG_READABLE,
+			      mpi->width, mpi->height);
+	    vf_clone_mpi_attributes(tmpi, mpi);
+
+	    imgop(copyop, tmpi, mpi, 0);
+	    imgop(deghost_plane, tmpi, dmpi, p->deghost);
+	    imgop(copyop, dmpi, mpi, 0);
+	    return vf_next_put_image(vf, tmpi, MP_NOPTS_VALUE);
+	    }
+      }
+
+   imgop(copyop, dmpi, mpi, 0);
+   return vf_next_put_image(vf, dmpi, MP_NOPTS_VALUE);
+   }
+
+static int analyze(struct vf_priv_s *p)
+   {
+   int *buf=0, *bp, bufsize=0, n, b, f, i, j, m, s;
+   unsigned int *cbuf=0, *cp;
+   char *pbuf;
+   char lbuf[256];
+   int sum[5];
+   double d;
+
+   /* read the file */
+
+   n=15;
+   while(fgets(lbuf, 256, p->file))
+      {
+      if(n>=bufsize-19)
+	 {
+	 bufsize=bufsize?bufsize*2:30000;
+	 if((bp=realloc(buf, bufsize*sizeof *buf))) buf=bp;
+	 if((cp=realloc(cbuf, bufsize*sizeof *cbuf))) cbuf=cp;
+
+	 if(!bp || !cp)
+	    {
+	    mp_msg(MSGT_VFILTER, MSGL_FATAL, "%s: Not enough memory.\n",
+		   vf_info_divtc.name);
+	    free(buf);
+	    free(cbuf);
+	    return 0;
+	    }
+	 }
+      sscanf(lbuf, "%x %d", cbuf+n, buf+n);
+      n++;
+      }
+
+   if(!n)
+      {
+      mp_msg(MSGT_VFILTER, MSGL_FATAL, "%s: Empty 2-pass log file.\n",
+	     vf_info_divtc.name);
+      free(buf);
+      free(cbuf);
+      return 0;
+      }
+
+   /* generate some dummy data past the beginning and end of the array */
+
+   buf+=15, cbuf+=15;
+   n-=15;
+
+   memcpy(buf-15, buf, 15*sizeof *buf);
+   memset(cbuf-15, 0, 15*sizeof *cbuf);
+
+   while(n%5)
+      buf[n]=buf[n-5], cbuf[n]=0, n++;
+
+   memcpy(buf+n, buf+n-15, 15*sizeof *buf);
+   memset(cbuf+n, 0, 15*sizeof *cbuf);
+
+   p->csdata=cbuf;
+   p->fcount=n;
+
+   /* array with one slot for each slice of 5 frames */
+
+   p->bdata=pbuf=malloc(p->bcount=b=(n/5));
+   memset(pbuf, 255, b);
+
+   /* resolve the automatic mode */
+
+   if(p->deghost<0)
+      {
+      int deghost=-p->deghost;
+      double s0=0.0, s1=0.0;
+
+      for(f=0; f<n; f+=5)
+	 {
+	 p->deghost=0; match(p, buf+f, -1, -1, &d); s0+=d;
+	 p->deghost=1; match(p, buf+f, -1, -1, &d); s1+=d;
+	 }
+
+      p->deghost=s1>s0?deghost:0;
+
+      mp_msg(MSGT_VFILTER, MSGL_INFO,
+	     "%s: Deghosting %-3s (relative pattern strength %+.2fdB).\n",
+	     vf_info_divtc.name,
+	     p->deghost?"ON":"OFF",
+	     10.0*log10(s1/s0));
+      }
+
+   /* analyze the data */
+
+   for(f=0; f<5; f++)
+      for(sum[f]=0, n=-15; n<20; n+=5)
+	 sum[f]+=buf[n+f];
+
+   for(f=0; f<b; f++)
+      {
+      m=match(p, sum, -1, -1, &d);
+
+      if(d>=p->threshold)
+	 pbuf[f]=m;
+
+      if(f<b-1)
+	 for(n=0; n<5; n++)
+	    sum[n]=sum[n]-buf[5*(f-3)+n]+buf[5*(f+4)+n];
+      }
+
+   /* fill in the gaps */
+
+   /* the beginning */
+   for(f=0; f<b && pbuf[f]==-1; f++);
+
+   if(f==b)
+      {
+      free(buf-15);
+      mp_msg(MSGT_VFILTER, MSGL_FATAL, "%s: No telecine pattern found!\n",
+	     vf_info_divtc.name);
+      return 0;
+      }
+
+   for(n=0; n<f; pbuf[n++]=pbuf[f]);
+
+   /* the end */
+   for(f=b-1; pbuf[f]==-1; f--);
+   for(n=f+1; n<b; pbuf[n++]=pbuf[f]);
+
+   /* the rest */
+   for(f=0;;)
+      {
+      while(f<b && pbuf[f]!=-1) f++;
+      if(f==b) break;
+      for(n=f; pbuf[n]==-1; n++);
+
+      if(pbuf[f-1]==pbuf[n])
+	 {
+	 /* just a gap */
+	 while(f<n) pbuf[f++]=pbuf[n];
+	 }
+      else
+	 {
+	 /* phase change, reanalyze the original data in the gap with zero
+	    threshold for only the two phases that appear at the ends */
+
+	 for(i=0; i<5; i++)
+	    for(sum[i]=0, j=5*f-15; j<5*f; j+=5)
+	       sum[i]+=buf[i+j];
+
+	 for(i=f; i<n; i++)
+	    {
+	    pbuf[i]=match(p, sum, pbuf[f-1], pbuf[n], 0);
+
+	    for(j=0; j<5; j++)
+	       sum[j]=sum[j]-buf[5*(i-3)+j]+buf[5*(i+4)+j];
+	    }
+
+	 /* estimate the transition point by dividing the gap
+	    in the same proportion as the number of matches of each kind */
+
+	 for(i=f, m=f; i<n; i++)
+	    if(pbuf[i]==pbuf[f-1]) m++;
+
+	 /* find the transition of the right direction nearest to the
+	    estimated point */
+
+	 if(m>f && m<n)
+	    {
+	    for(j=m; j>f; j--)
+	       if(pbuf[j-1]==pbuf[f-1] && pbuf[j]==pbuf[n]) break;
+	    for(s=m; s<n; s++)
+	       if(pbuf[s-1]==pbuf[f-1] && pbuf[s]==pbuf[n]) break;
+
+	    m=(s-m<m-j)?s:j;
+	    }
+
+	 /* and rewrite the data to allow only this one transition */
+
+	 for(i=f; i<m; i++)
+	    pbuf[i]=pbuf[f-1];
+
+	 for(; i<n; i++)
+	    pbuf[i]=pbuf[n];
+
+	 f=n;
+	 }
+      }
+
+   free(buf-15);
+
+   return 1;
+   }
+
+static int query_format(struct vf_instance *vf, unsigned int fmt)
+   {
+   switch(fmt)
+      {
+      case IMGFMT_444P: case IMGFMT_IYUV: case IMGFMT_RGB24:
+      case IMGFMT_422P: case IMGFMT_UYVY: case IMGFMT_BGR24:
+      case IMGFMT_411P: case IMGFMT_YUY2: case IMGFMT_IF09:
+      case IMGFMT_YV12: case IMGFMT_I420: case IMGFMT_YVU9:
+      case IMGFMT_IUYV: case IMGFMT_Y800: case IMGFMT_Y8:
+	 return vf_next_query_format(vf,fmt);
+      }
+
+   return 0;
+   }
+
+static void uninit(struct vf_instance *vf)
+   {
+   if(vf->priv)
+      {
+      if(vf->priv->file) fclose(vf->priv->file);
+      if(vf->priv->csdata) free(vf->priv->csdata-15);
+      free(vf->priv->bdata);
+      free(vf->priv->history);
+      free(vf->priv);
+      }
+   }
+
+static int vf_open(vf_instance_t *vf, char *args)
+   {
+   struct vf_priv_s *p;
+   char *filename="framediff.log", *ap, *q, *a;
+
+   if(args && !(args=strdup(args)))
+      {
+   nomem:
+      mp_msg(MSGT_VFILTER, MSGL_FATAL,
+	     "%s: Not enough memory.\n", vf->info->name);
+   fail:
+      uninit(vf);
+      free(args);
+      return 0;
+      }
+
+   vf->put_image=put_image;
+   vf->uninit=uninit;
+   vf->query_format=query_format;
+   vf->default_reqs=VFCAP_ACCEPT_STRIDE;
+   if(!(vf->priv=p=calloc(1, sizeof(struct vf_priv_s))))
+      goto nomem;
+
+   p->phase=5;
+   p->threshold=0.5;
+   p->window=30;
+
+   if((ap=args))
+      while(*ap)
+	 {
+	 q=ap;
+	 if((ap=strchr(q, ':'))) *ap++=0; else ap=q+strlen(q);
+	 if((a=strchr(q, '='))) *a++=0; else a=q+strlen(q);
+
+	 switch(*q)
+	    {
+	    case 0:                              break;
+	    case 'f': filename=a;                break;
+	    case 't': p->threshold=atof(a);      break;
+	    case 'w': p->window=5*(atoi(a)+4)/5; break;
+	    case 'd': p->deghost=atoi(a);        break;
+	    case 'p':
+	       if(q[1]=='h') p->phase=atoi(a);
+	       else p->pass=atoi(a);
+	       break;
+
+	    case 'h':
+	       mp_msg(MSGT_VFILTER, MSGL_INFO,
+		      "\n%s options:\n\n"
+		      "pass=1|2         - Use 2-pass mode.\n"
+		      "file=filename    - Set the 2-pass log file name "
+		      "(default %s).\n"
+		      "threshold=value  - Set the pattern recognition "
+		      "sensitivity (default %g).\n"
+		      "deghost=value    - Select deghosting threshold "
+		      "(default %d).\n"
+		      "window=numframes - Set the statistics window "
+		      "for 1-pass mode (default %d).\n"
+		      "phase=0|1|2|3|4  - Set the initial phase "
+		      "for 1-pass mode (default %d).\n\n"
+		      "The option names can be abbreviated to the shortest "
+		      "unique prefix.\n\n",
+		      vf->info->name, filename, p->threshold, p->deghost,
+		      p->window, p->phase%5);
+	       break;
+
+	    default:
+	       mp_msg(MSGT_VFILTER, MSGL_FATAL,
+		      "%s: Unknown argument %s.\n", vf->info->name, q);
+	       goto fail;
+	    }
+	 }
+
+   switch(p->pass)
+      {
+      case 1:
+	 if(!(p->file=fopen(filename, "w")))
+	    {
+	    mp_msg(MSGT_VFILTER, MSGL_FATAL,
+		   "%s: Can't create file %s.\n", vf->info->name, filename);
+	    goto fail;
+	    }
+
+	 break;
+
+      case 2:
+	 if(!(p->file=fopen(filename, "r")))
+	    {
+	    mp_msg(MSGT_VFILTER, MSGL_FATAL,
+		   "%s: Can't open file %s.\n", vf->info->name, filename);
+	    goto fail;
+	    }
+
+	 if(!analyze(p))
+	    goto fail;
+
+	 fclose(p->file);
+	 p->file=0;
+	 break;
+      }
+
+   if(p->window<5) p->window=5;
+   if(!(p->history=calloc(sizeof *p->history, p->window)))
+      goto nomem;
+
+   diff = diff_C;
+#if HAVE_MMX && HAVE_EBX_AVAILABLE
+   if(gCpuCaps.hasMMX) diff = diff_MMX;
+#endif
+
+   free(args);
+   return 1;
+   }
+
+const vf_info_t vf_info_divtc =
+   {
+   "inverse telecine for deinterlaced video",
+   "divtc",
+   "Ville Saari",
+   "",
+   vf_open,
+   NULL
+   };
