]> git.sesse.net Git - vlc/commitdiff
Merge branch 1.0-bugfix
authorRémi Denis-Courmont <remi@remlab.net>
Wed, 20 May 2009 16:46:41 +0000 (19:46 +0300)
committerRémi Denis-Courmont <remi@remlab.net>
Wed, 20 May 2009 16:46:41 +0000 (19:46 +0300)
Conflicts:
modules/video_filter/extract.c
modules/video_filter/marq.c
projects/mozilla/control/npolibvlc.cpp
src/control/video.c

36 files changed:
1  2 
NEWS
modules/access/v4l2.c
modules/audio_filter/spatializer/spatializer.cpp
modules/codec/subtitles/subsdec.c
modules/demux/rawaud.c
modules/demux/ts.c
modules/gui/qt4/main_interface.cpp
modules/gui/qt4/main_interface.hpp
modules/gui/qt4/qt4.cpp
modules/misc/rtsp.c
modules/stream_out/transcode.c
modules/video_filter/adjust.c
modules/video_filter/alphamask.c
modules/video_filter/bluescreen.c
modules/video_filter/crop.c
modules/video_filter/erase.c
modules/video_filter/extract.c
modules/video_filter/gradient.c
modules/video_filter/logo.c
modules/video_filter/marq.c
modules/video_filter/mosaic.c
modules/video_filter/motionblur.c
modules/video_filter/osdmenu.c
modules/video_filter/postproc.c
modules/video_filter/rotate.c
modules/video_filter/sharpen.c
modules/video_output/msw/direct3d.c
modules/video_output/x11/xcommon.c
projects/mozilla/control/npolibvlc.cpp
projects/mozilla/test.html
projects/mozilla/vlcplugin.cpp
src/control/media_player.c
src/control/video.c
src/playlist/playlist_internal.h
src/playlist/services_discovery.c
src/video_output/video_output.c

diff --combined NEWS
index 382489dead1b6241bb54d139651e6011a2dfe616,9aac2686b0c54a8a02672283ebc76f9f07c70e49..d06b69006adb91569bc0fc209b02f5acf8c8f07d
--- 1/NEWS
--- 2/NEWS
+++ b/NEWS
@@@ -1,7 -1,3 +1,7 @@@
 +Changes between 1.0.0-rc1 and 1.1.0-git:
 +----------------------------------------
 +
 +
  Changes between 0.9.9a and 1.0.0-rc1:
  ------------------------------------
  
@@@ -53,7 -49,7 +53,7 @@@ Access
     OSS or Alsa audio input. Use --input-slave alsa:// or oss:// if needed.
   * DVB scanning on linux
   * EXPERIMENTAL Blu-Ray Disc and AVCHD Folders support
-  * On-the-fly zip file decompression and browsing (MRL of the form zip://file.zip|file.avi to specify the file)
+  * On-the-fly zip file decompression and browsing (MRL of the form zip://file.zip!/file.avi to specify the file - the development form of zip://file.zip|file.avi is not supported anymore)
   * Opening of any file descriptor using 'fd://'
   * MTP device access on Unix
   * CD-Text support on the cdda module (CD-Audio)
diff --combined modules/access/v4l2.c
index aa511ee06d95dd6862e6828c0f5215ffe1bdf4b7,31dae6643f3445a6549b225e2e42f9e133a91ca5..27c139fe7d33cc82337830c8e8f2296ab68e7b3f
@@@ -393,41 -393,42 +393,41 @@@ static int AccessControlResetCallback( 
  static const struct
  {
      unsigned int i_v4l2;
 -    int i_fourcc;
 +    vlc_fourcc_t i_fourcc;
      int i_rmask;
      int i_gmask;
      int i_bmask;
  } v4l2chroma_to_fourcc[] =
  {
      /* Raw data types */
 -    { V4L2_PIX_FMT_GREY,    VLC_FOURCC('G','R','E','Y'), 0, 0, 0 },
 +    { V4L2_PIX_FMT_GREY,    VLC_CODEC_GREY, 0, 0, 0 },
      { V4L2_PIX_FMT_HI240,   VLC_FOURCC('I','2','4','0'), 0, 0, 0 },
 -    { V4L2_PIX_FMT_RGB555,  VLC_FOURCC('R','V','1','5'), 0x001f,0x03e0,0x7c00 },
 -    { V4L2_PIX_FMT_RGB565,  VLC_FOURCC('R','V','1','6'), 0x001f,0x07e0,0xf800 },
 +    { V4L2_PIX_FMT_RGB555,  VLC_CODEC_RGB15, 0x001f,0x03e0,0x7c00 },
 +    { V4L2_PIX_FMT_RGB565,  VLC_CODEC_RGB16, 0x001f,0x07e0,0xf800 },
      /* Won't work since we don't know how to handle such gmask values
       * correctly
 -    { V4L2_PIX_FMT_RGB555X, VLC_FOURCC('R','V','1','5'), 0x007c,0xe003,0x1f00 },
 -    { V4L2_PIX_FMT_RGB565X, VLC_FOURCC('R','V','1','6'), 0x00f8,0xe007,0x1f00 },
 +    { V4L2_PIX_FMT_RGB555X, VLC_CODEC_RGB15, 0x007c,0xe003,0x1f00 },
 +    { V4L2_PIX_FMT_RGB565X, VLC_CODEC_RGB16, 0x00f8,0xe007,0x1f00 },
      */
 -    { V4L2_PIX_FMT_BGR24,   VLC_FOURCC('R','V','2','4'), 0xff0000,0xff00,0xff },
 -    { V4L2_PIX_FMT_RGB24,   VLC_FOURCC('R','V','2','4'), 0xff,0xff00,0xff0000 },
 -    { V4L2_PIX_FMT_BGR32,   VLC_FOURCC('R','V','3','2'), 0xff0000,0xff00,0xff },
 -    { V4L2_PIX_FMT_RGB32,   VLC_FOURCC('R','V','3','2'), 0xff,0xff00,0xff0000 },
 -    { V4L2_PIX_FMT_YUYV,    VLC_FOURCC('Y','U','Y','2'), 0, 0, 0 },
 -    { V4L2_PIX_FMT_YUYV,    VLC_FOURCC('Y','U','Y','V'), 0, 0, 0 },
 -    { V4L2_PIX_FMT_UYVY,    VLC_FOURCC('U','Y','V','Y'), 0, 0, 0 },
 +    { V4L2_PIX_FMT_BGR24,   VLC_CODEC_RGB24, 0xff0000,0xff00,0xff },
 +    { V4L2_PIX_FMT_RGB24,   VLC_CODEC_RGB24, 0xff,0xff00,0xff0000 },
 +    { V4L2_PIX_FMT_BGR32,   VLC_CODEC_RGB32, 0xff0000,0xff00,0xff },
 +    { V4L2_PIX_FMT_RGB32,   VLC_CODEC_RGB32, 0xff,0xff00,0xff0000 },
 +    { V4L2_PIX_FMT_YUYV,    VLC_CODEC_YUYV, 0, 0, 0 },
 +    { V4L2_PIX_FMT_UYVY,    VLC_CODEC_UYVY, 0, 0, 0 },
      { V4L2_PIX_FMT_Y41P,    VLC_FOURCC('I','4','1','N'), 0, 0, 0 },
 -    { V4L2_PIX_FMT_YUV422P, VLC_FOURCC('I','4','2','2'), 0, 0, 0 },
 -    { V4L2_PIX_FMT_YVU420,  VLC_FOURCC('Y','V','1','2'), 0, 0, 0 },
 -    { V4L2_PIX_FMT_YUV411P, VLC_FOURCC('I','4','1','1'), 0, 0, 0 },
 -    { V4L2_PIX_FMT_YUV410,  VLC_FOURCC('I','4','1','0'), 0, 0, 0 },
 +    { V4L2_PIX_FMT_YUV422P, VLC_CODEC_I422, 0, 0, 0 },
 +    { V4L2_PIX_FMT_YVU420,  VLC_CODEC_YV12, 0, 0, 0 },
 +    { V4L2_PIX_FMT_YUV411P, VLC_CODEC_I411, 0, 0, 0 },
 +    { V4L2_PIX_FMT_YUV410,  VLC_CODEC_I410, 0, 0, 0 },
  
      /* Raw data types, not in V4L2 spec but still in videodev2.h and supported
       * by VLC */
 -    { V4L2_PIX_FMT_YUV420,  VLC_FOURCC('I','4','2','0'), 0, 0, 0 },
 -    /* FIXME { V4L2_PIX_FMT_RGB444,  VLC_FOURCC('R','V','3','2') }, */
 +    { V4L2_PIX_FMT_YUV420,  VLC_CODEC_I420, 0, 0, 0 },
 +    /* FIXME { V4L2_PIX_FMT_RGB444,  VLC_CODEC_RGB32 }, */
  
      /* Compressed data types */
 -    { V4L2_PIX_FMT_MJPEG,   VLC_FOURCC('M','J','P','G'), 0, 0, 0 },
 +    { V4L2_PIX_FMT_MJPEG,   VLC_CODEC_MJPG, 0, 0, 0 },
  #if 0
      { V4L2_PIX_FMT_JPEG,    VLC_FOURCC('J','P','E','G') },
      { V4L2_PIX_FMT_DV,      VLC_FOURCC('?','?','?','?') },
@@@ -1945,18 -1946,21 +1945,18 @@@ static int OpenVideoDev( vlc_object_t *
  
      /* Test and set Chroma */
      fmt.fmt.pix.pixelformat = 0;
 -    if( p_sys->psz_requested_chroma && strlen( p_sys->psz_requested_chroma ) > 0 )
 +    if( p_sys->psz_requested_chroma && *p_sys->psz_requested_chroma )
      {
          /* User specified chroma */
 -        if( strlen( p_sys->psz_requested_chroma ) >= 4 )
 +        const vlc_fourcc_t i_requested_fourcc =
 +            vlc_fourcc_GetCodecFromString( VIDEO_ES, p_sys->psz_requested_chroma );
 +
 +        for( int i = 0; v4l2chroma_to_fourcc[i].i_v4l2 != 0; i++ )
          {
 -            int i_requested_fourcc = VLC_FOURCC(
 -                p_sys->psz_requested_chroma[0], p_sys->psz_requested_chroma[1],
 -                p_sys->psz_requested_chroma[2], p_sys->psz_requested_chroma[3] );
 -            for( int i = 0; v4l2chroma_to_fourcc[i].i_v4l2 != 0; i++ )
 +            if( v4l2chroma_to_fourcc[i].i_fourcc == i_requested_fourcc )
              {
 -                if( v4l2chroma_to_fourcc[i].i_fourcc == i_requested_fourcc )
 -                {
 -                    fmt.fmt.pix.pixelformat = v4l2chroma_to_fourcc[i].i_v4l2;
 -                    break;
 -                }
 +                fmt.fmt.pix.pixelformat = v4l2chroma_to_fourcc[i].i_v4l2;
 +                break;
              }
          }
          /* Try and set user chroma */
@@@ -2909,6 -2913,7 +2909,7 @@@ static void SetAvailControlsByString( v
                  Control( p_obj, p_sys, i_fd, psz_name, i_cid,
                           strtol( ++psz_assign, &psz_parser, 0) );
              }
+             free( name.psz_string );
          }
  
          if( psz_parser < psz_assign )
              psz_parser = ( *psz_delim ) ? ( psz_delim + 1 ) : psz_delim;
          }
      }
+     var_Change( p_obj, "allcontrols", VLC_VAR_FREELIST, &val, &text );
  }
  
  /*****************************************************************************
@@@ -2954,7 -2960,8 +2956,8 @@@ static int ControlReset( vlc_object_t *
                      if( controls[i].i_cid == queryctrl.id ) break;
                  name2var( queryctrl.name );
                  Control( p_obj, p_sys, i_fd,
-                          controls[i].psz_name ? : (const char *)queryctrl.name,
+                          controls[i].psz_name ? controls[i].psz_name
+                           : (const char *)queryctrl.name,
                           queryctrl.id, queryctrl.default_value );
              }
              queryctrl.id |= V4L2_CTRL_FLAG_NEXT_CTRL;
                          if( controls[i].i_cid == queryctrl.id ) break;
                      name2var( queryctrl.name );
                      Control( p_obj, p_sys, i_fd,
-                              controls[i].psz_name ? : (const char *)queryctrl.name,
+                              controls[i].psz_name ? controls[i].psz_name
+                               : (const char *)queryctrl.name,
                               queryctrl.id, queryctrl.default_value );
                  }
              }
index 34a6c45438d8c03ac90cec2715179cab2b15c0a5,2fbecc931444073a375ef2d5d3398bdb24f03b89..1e843c2256ea3c5597a8eac434099935275bf65a
@@@ -103,7 -103,8 +103,8 @@@ private
  
  static const char *psz_control_names[] =
  {
-     "Roomsize", "Width" , "Wet", "Dry", "Damp"
+     "spatializer-roomsize", "spatializer-width" ,
+     "spatializer-wet", "spatializer-dry", "spatializer-damp"
  };
  static void DoWork( aout_instance_t *, aout_filter_t *,
                      aout_buffer_t *, aout_buffer_t * );
@@@ -133,12 -134,12 +134,12 @@@ static int Open( vlc_object_t *p_this 
      bool         b_fit = true;
      msg_Dbg(p_this, "Opening filter spatializer %s %s %d", __FILE__,__func__,__LINE__);
  
 -    if( p_filter->input.i_format != VLC_FOURCC('f','l','3','2' ) ||
 -        p_filter->output.i_format != VLC_FOURCC('f','l','3','2') )
 +    if( p_filter->input.i_format != VLC_CODEC_FL32 ||
 +        p_filter->output.i_format != VLC_CODEC_FL32 )
      {
          b_fit = false;
 -        p_filter->input.i_format = VLC_FOURCC('f','l','3','2');
 -        p_filter->output.i_format = VLC_FOURCC('f','l','3','2');
 +        p_filter->input.i_format = VLC_CODEC_FL32;
 +        p_filter->output.i_format = VLC_CODEC_FL32;
          msg_Warn( p_filter, "bad input or output format" );
      }
      if ( !AOUT_FMTS_SIMILAR( &p_filter->input, &p_filter->output ) )
index 8a7cf3521e4b706e8468d8b4b0d4e1ae1d8695e9,aa5ca570d66a0dcc1690dd4ec60ba2f80e658ce8..f217f0b77e244effe9cd8e718a68939c6f68a15d
@@@ -232,9 -232,9 +232,9 @@@ static int OpenDecoder( vlc_object_t *p
  
      switch( p_dec->fmt_in.i_codec )
      {
 -        case VLC_FOURCC('s','u','b','t'):
 -        case VLC_FOURCC('s','s','a',' '):
 -        case VLC_FOURCC('t','1','4','0'):
 +        case VLC_CODEC_SUBT:
 +        case VLC_CODEC_SSA:
 +        case VLC_CODEC_ITU_T140:
              break;
          default:
              return VLC_EGENERIC;
      char *psz_charset = NULL;
  
      /* First try demux-specified encoding */
 -    if( p_dec->fmt_in.i_codec == VLC_FOURCC('t','1','4','0') )
 +    if( p_dec->fmt_in.i_codec == VLC_CODEC_ITU_T140 )
          psz_charset = strdup( "UTF-8" ); /* IUT T.140 is always using UTF-8 */
      else
      if( p_dec->fmt_in.subs.psz_encoding && *p_dec->fmt_in.subs.psz_encoding )
      {
          psz_charset = strdup (p_dec->fmt_in.subs.psz_encoding);
          msg_Dbg (p_dec, "trying demuxer-specified character encoding: %s",
-                  p_dec->fmt_in.subs.psz_encoding ?: "not specified");
+                  p_dec->fmt_in.subs.psz_encoding ?
+                  p_dec->fmt_in.subs.psz_encoding : "not specified");
      }
  
      /* Second, try configured encoding */
      {
          psz_charset = var_CreateGetNonEmptyString (p_dec, "subsdec-encoding");
          msg_Dbg (p_dec, "trying configured character encoding: %s",
-                  psz_charset ?: "not specified");
+                  psz_charset ? psz_charset : "not specified");
      }
  
      /* Third, try "local" encoding with optional UTF-8 autodetection */
      {
          psz_charset = strdup (GetFallbackEncoding ());
          msg_Dbg (p_dec, "trying default character encoding: %s",
-                  psz_charset ?: "not specified");
+                  psz_charset ? psz_charset : "not specified");
  
          if (var_CreateGetBool (p_dec, "subsdec-autodetect-utf8"))
          {
      var_Get( p_dec, "subsdec-align", &val );
      p_sys->i_align = val.i_int;
  
 -    if( p_dec->fmt_in.i_codec == VLC_FOURCC('s','s','a',' ')
 +    if( p_dec->fmt_in.i_codec == VLC_CODEC_SSA
       && var_CreateGetBool( p_dec, "subsdec-formatted" ) )
      {
          if( p_dec->fmt_in.i_extra > 0 )
@@@ -492,7 -493,7 +493,7 @@@ static subpicture_t *ParseText( decoder
  
      /* Create a new subpicture region */
      memset( &fmt, 0, sizeof(video_format_t) );
 -    fmt.i_chroma = VLC_FOURCC('T','E','X','T');
 +    fmt.i_chroma = VLC_CODEC_TEXT;
      fmt.i_aspect = 0;
      fmt.i_width = fmt.i_height = 0;
      fmt.i_x_offset = fmt.i_y_offset = 0;
      }
  
      /* Decode and format the subpicture unit */
 -    if( p_dec->fmt_in.i_codec != VLC_FOURCC('s','s','a',' ') )
 +    if( p_dec->fmt_in.i_codec != VLC_CODEC_SSA )
      {
          /* Normal text subs, easy markup */
          p_spu->p_region->i_align = SUBPICTURE_ALIGN_BOTTOM | p_sys->i_align;
diff --combined modules/demux/rawaud.c
index a9473a0606d41ee561fbef9a76684f94b901f20c,c3ff27bc71c987865535e745f0b05e81afe36f91..2f2bb11c889214e30e1f7921c94b9547c9afcbfe
@@@ -48,11 -48,17 +48,17 @@@ static void Close( vlc_object_t * )
  
  #define FOURCC_TEXT N_("FOURCC code of raw input format")
  #define FOURCC_LONGTEXT N_( \
-     "FOURCC code of the raw input format. This is a four character string. Default is s16l." )
+     "FOURCC code of the raw input format. This is a four character string." )
  
  #define LANG_TEXT N_("Forces the audio language.")
  #define LANG_LONGTEXT N_("Forces the audio language for the output mux. Three letter ISO639 code. Default is 'eng'. ")
  
+ #ifdef WORDS_BIGENDIAN
+ # define FOURCC_DEFAULT "s16b"
+ #else
+ # define FOURCC_DEFAULT "s16l"
+ #endif
  vlc_module_begin();
      set_shortname( "Raw Audio" );
      set_description( N_("Raw audio demuxer") );
@@@ -63,7 -69,8 +69,8 @@@
      add_shortcut( "rawaud" );
      add_integer( "rawaud-channels", 2, 0, CHANNELS_TEXT, CHANNELS_LONGTEXT, false );
      add_integer( "rawaud-samplerate", 48000, 0, SAMPLERATE_TEXT, SAMPLERATE_LONGTEXT, false );
-     add_string( "rawaud-fourcc", "s16l", NULL, FOURCC_TEXT, FOURCC_LONGTEXT, false );
+     add_string( "rawaud-fourcc", FOURCC_DEFAULT, NULL,
+                 FOURCC_TEXT, FOURCC_LONGTEXT, false );
      add_string( "rawaud-lang", "eng", NULL, LANG_TEXT, LANG_LONGTEXT, false);
  vlc_module_end();
  
@@@ -106,43 -113,49 +113,43 @@@ static int Open( vlc_object_t * p_this 
      es_format_Init( &p_sys->fmt, AUDIO_ES, 0 );
  
      char *psz_fourcc = var_CreateGetString( p_demux, "rawaud-fourcc" );
 +    p_sys->fmt.i_codec = vlc_fourcc_GetCodecFromString( AUDIO_ES, psz_fourcc );
 +    free( psz_fourcc );
  
 -    if( ( psz_fourcc == NULL ?  0 : strlen( psz_fourcc ) ) != 4  )
 +    if( !p_sys->fmt.i_codec )
      {
          msg_Err( p_demux, "rawaud-fourcc must be a 4 character string");
 -        free( psz_fourcc );
          es_format_Clean( &p_sys->fmt );
          free( p_sys );
          return VLC_EGENERIC;
      }
  
 -    p_sys->fmt.i_codec = VLC_FOURCC( psz_fourcc[0], psz_fourcc[1],
 -                                     psz_fourcc[2], psz_fourcc[3] );
 -
 -    free( psz_fourcc );
      // get the bits per sample ratio based on codec
      switch( p_sys->fmt.i_codec )
      {
  
 -        case VLC_FOURCC( 'f', 'l', '6', '4' ):
 +        case VLC_CODEC_FL64:
              p_sys->fmt.audio.i_bitspersample = 64;
              break;
  
 -        case VLC_FOURCC( 'f', 'l', '3', '2' ):
 -        case VLC_FOURCC( 's', '3', '2', 'l' ):
 -        case VLC_FOURCC( 's', '3', '2', 'b' ):
 -        case VLC_FOURCC( 'i', 'n', '3', '2' ):
 +        case VLC_CODEC_FL32:
 +        case VLC_CODEC_S32L:
 +        case VLC_CODEC_S32B:
              p_sys->fmt.audio.i_bitspersample = 32;
              break;
  
 -        case VLC_FOURCC( 's', '2', '4', 'l' ):
 -        case VLC_FOURCC( 's', '2', '4', 'b' ):
 -        case VLC_FOURCC( 'i', 'n', '2', '4' ):
 -        case VLC_FOURCC( '4', '2', 'n', 'i' ):
 +        case VLC_CODEC_S24L:
 +        case VLC_CODEC_S24B:
              p_sys->fmt.audio.i_bitspersample = 24;
              break;
  
 -        case VLC_FOURCC( 's', '1', '6', 'l' ):
 -        case VLC_FOURCC( 's', '1', '6', 'b' ):
 +        case VLC_CODEC_S16L:
 +        case VLC_CODEC_S16B:
              p_sys->fmt.audio.i_bitspersample = 16;
              break;
  
 -        case VLC_FOURCC( 's', '8', ' ', ' ' ):
 -        case VLC_FOURCC( 'u', '8', ' ', ' ' ):
 +        case VLC_CODEC_S8:
 +        case VLC_CODEC_U8:
              p_sys->fmt.audio.i_bitspersample = 8;
              break;
  
diff --combined modules/demux/ts.c
index be3cd884a980007dc30b15fc8253f5d96ce5ff4d,b80031b68a845ba780f01a18b70ee466c353d7b5..180507ad5deb3dabfd3b091a168e22cdbcb94c63
@@@ -1737,7 -1737,7 +1737,7 @@@ static void ParsePES( demux_t *p_demux
      {
          i_skip += 1;
      }
 -    else if( pid->es->fmt.i_codec == VLC_FOURCC( 's', 'u', 'b', 't' ) &&
 +    else if( pid->es->fmt.i_codec == VLC_CODEC_SUBT &&
               pid->es->p_mpeg4desc )
      {
          decoder_config_descriptor_t *dcd = &pid->es->p_mpeg4desc->dec_descr;
          i_skip += 2;
      }
  #ifdef ZVBI_COMPILED
 -    else if( pid->es->fmt.i_codec == VLC_FOURCC( 't', 'e', 'l', 'x' ) )
 +    else if( pid->es->fmt.i_codec == VLC_CODEC_TELETEXT )
          i_skip = 0; /*hack for zvbi support */
  #endif
      /* skip header */
          p_pes->i_length = i_length * 100 / 9;
  
          p_block = block_ChainGather( p_pes );
 -        if( pid->es->fmt.i_codec == VLC_FOURCC( 's', 'u', 'b', 't' ) )
 +        if( pid->es->fmt.i_codec == VLC_CODEC_SUBT )
          {
              if( i_pes_size > 0 && p_block->i_buffer > i_pes_size )
              {
@@@ -2048,38 -2048,38 +2048,38 @@@ static int PIDFillFormat( ts_pid_t *pid
      case 0x01:  /* MPEG-1 video */
      case 0x02:  /* MPEG-2 video */
      case 0x80:  /* MPEG-2 MOTO video */
 -        es_format_Init( fmt, VIDEO_ES, VLC_FOURCC( 'm', 'p', 'g', 'v' ) );
 +        es_format_Init( fmt, VIDEO_ES, VLC_CODEC_MPGV );
          break;
      case 0x03:  /* MPEG-1 audio */
      case 0x04:  /* MPEG-2 audio */
 -        es_format_Init( fmt, AUDIO_ES, VLC_FOURCC( 'm', 'p', 'g', 'a' ) );
 +        es_format_Init( fmt, AUDIO_ES, VLC_CODEC_MPGA );
          break;
      case 0x11:  /* MPEG4 (audio) */
      case 0x0f:  /* ISO/IEC 13818-7 Audio with ADTS transport syntax */
 -        es_format_Init( fmt, AUDIO_ES, VLC_FOURCC( 'm', 'p', '4', 'a' ) );
 +        es_format_Init( fmt, AUDIO_ES, VLC_CODEC_MP4A );
          break;
      case 0x10:  /* MPEG4 (video) */
 -        es_format_Init( fmt, VIDEO_ES, VLC_FOURCC( 'm', 'p', '4', 'v' ) );
 +        es_format_Init( fmt, VIDEO_ES, VLC_CODEC_MP4V );
          pid->es->b_gather = true;
          break;
      case 0x1B:  /* H264 <- check transport syntax/needed descriptor */
 -        es_format_Init( fmt, VIDEO_ES, VLC_FOURCC( 'h', '2', '6', '4' ) );
 +        es_format_Init( fmt, VIDEO_ES, VLC_CODEC_H264 );
          break;
  
      case 0x81:  /* A52 (audio) */
 -        es_format_Init( fmt, AUDIO_ES, VLC_FOURCC( 'a', '5', '2', ' ' ) );
 +        es_format_Init( fmt, AUDIO_ES, VLC_CODEC_A52 );
          break;
      case 0x82:  /* DVD_SPU (sub) */
 -        es_format_Init( fmt, SPU_ES, VLC_FOURCC( 's', 'p', 'u', ' ' ) );
 +        es_format_Init( fmt, SPU_ES, VLC_CODEC_SPU );
          break;
      case 0x83:  /* LPCM (audio) */
 -        es_format_Init( fmt, AUDIO_ES, VLC_FOURCC( 'l', 'p', 'c', 'm' ) );
 +        es_format_Init( fmt, AUDIO_ES, VLC_CODEC_DVD_LPCM );
          break;
      case 0x84:  /* SDDS (audio) */
 -        es_format_Init( fmt, AUDIO_ES, VLC_FOURCC( 's', 'd', 'd', 's' ) );
 +        es_format_Init( fmt, AUDIO_ES, VLC_CODEC_SDDS );
          break;
      case 0x85:  /* DTS (audio) */
 -        es_format_Init( fmt, AUDIO_ES, VLC_FOURCC( 'd', 't', 's', ' ' ) );
 +        es_format_Init( fmt, AUDIO_ES, VLC_CODEC_DTS );
          break;
  
      case 0x91:  /* A52 vls (audio) */
@@@ -3103,14 -3103,14 +3103,14 @@@ static void PMTSetupEsISO14496( demux_
          {
          case 0x0B: /* mpeg4 sub */
              p_fmt->i_cat = SPU_ES;
 -            p_fmt->i_codec = VLC_FOURCC('s','u','b','t');
 +            p_fmt->i_codec = VLC_CODEC_SUBT;
              break;
  
          case 0x20: /* mpeg4 */
 -            p_fmt->i_codec = VLC_FOURCC('m','p','4','v');
 +            p_fmt->i_codec = VLC_CODEC_MP4V;
              break;
          case 0x21: /* h264 */
 -            p_fmt->i_codec = VLC_FOURCC('h','2','6','4');
 +            p_fmt->i_codec = VLC_CODEC_H264;
              break;
          case 0x60:
          case 0x61:
          case 0x63:
          case 0x64:
          case 0x65: /* mpeg2 */
 -            p_fmt->i_codec = VLC_FOURCC( 'm','p','g','v' );
 +            p_fmt->i_codec = VLC_CODEC_MPGV;
              break;
          case 0x6a: /* mpeg1 */
 -            p_fmt->i_codec = VLC_FOURCC( 'm','p','g','v' );
 +            p_fmt->i_codec = VLC_CODEC_MPGV;
              break;
          case 0x6c: /* mpeg1 */
 -            p_fmt->i_codec = VLC_FOURCC( 'j','p','e','g' );
 +            p_fmt->i_codec = VLC_CODEC_JPEG;
              break;
          default:
              p_fmt->i_cat = UNKNOWN_ES;
          switch( dcd->i_objectTypeIndication )
          {
          case 0x40: /* mpeg4 */
 -            p_fmt->i_codec = VLC_FOURCC('m','p','4','a');
 +            p_fmt->i_codec = VLC_CODEC_MP4A;
              break;
          case 0x66:
          case 0x67:
          case 0x68: /* mpeg2 aac */
 -            p_fmt->i_codec = VLC_FOURCC('m','p','4','a');
 +            p_fmt->i_codec = VLC_CODEC_MP4A;
              break;
          case 0x69: /* mpeg2 */
 -            p_fmt->i_codec = VLC_FOURCC('m','p','g','a');
 +            p_fmt->i_codec = VLC_CODEC_MPGA;
              break;
          case 0x6b: /* mpeg1 */
 -            p_fmt->i_codec = VLC_FOURCC('m','p','g','a');
 +            p_fmt->i_codec = VLC_CODEC_MPGA;
              break;
          default:
              p_fmt->i_cat = UNKNOWN_ES;
@@@ -3217,7 -3217,8 +3217,8 @@@ static void PMTSetupEsTeletext( demux_
              ts_teletext_page_t *p_dst = &p_page[i_page++];
  
              p_dst->i_type = p_src->i_teletext_type;
-             p_dst->i_magazine = p_src->i_teletext_magazine_number ? : 8;
+             p_dst->i_magazine = p_src->i_teletext_magazine_number
+                 ? p_src->i_teletext_magazine_number : 8;
              p_dst->i_page = p_src->i_teletext_page_number;
              memcpy( p_dst->p_iso639, p_src->i_iso6392_language_code, 3 );
          }
                  break;
              }
              /* FIXME check if it is the right split */
-             p_dst->i_magazine = (p_src->i_composition_page_id >> 8) ? : 8;
+             p_dst->i_magazine = (p_src->i_composition_page_id >> 8)
+                 ? (p_src->i_composition_page_id >> 8) : 8;
              p_dst->i_page = p_src->i_composition_page_id & 0xff;
              memcpy( p_dst->p_iso639, p_src->i_iso6392_language_code, 3 );
          }
  #endif
  
      /* */
 -    es_format_Init( p_fmt, SPU_ES, VLC_FOURCC( 't', 'e', 'l', 'x' ) );
 +    es_format_Init( p_fmt, SPU_ES, VLC_CODEC_TELETEXT );
  
      /* In stream output mode, do not separate the stream by page */
      if( p_demux->out->b_sout || i_page <= 0 )
@@@ -3337,7 -3339,7 +3339,7 @@@ static void PMTSetupEsDvbSubtitle( demu
  {
      es_format_t *p_fmt = &pid->es->fmt;
  
 -    es_format_Init( p_fmt, SPU_ES, VLC_FOURCC( 'd', 'v', 'b', 's' ) );
 +    es_format_Init( p_fmt, SPU_ES, VLC_CODEC_DVBS );
  
      dvbpsi_descriptor_t *p_dr = PMTEsFindDescriptor( p_es, 0x59 );
      int i_page = 0;
@@@ -3442,13 -3444,13 +3444,13 @@@ static void PMTSetupEs0x06( demux_t *p_
          PMTEsFindDescriptor( p_es, 0x81 ) )
      {
          p_fmt->i_cat = AUDIO_ES;
 -        p_fmt->i_codec = VLC_FOURCC('a','5','2',' ');
 +        p_fmt->i_codec = VLC_CODEC_A52;
      }
      else if( PMTEsFindDescriptor( p_es, 0x7a ) )
      {
          /* DVB with stream_type 0x06 (ETS EN 300 468) */
          p_fmt->i_cat = AUDIO_ES;
 -        p_fmt->i_codec = VLC_FOURCC( 'e', 'a', 'c', '3' );
 +        p_fmt->i_codec = VLC_CODEC_EAC3;
      }
      else if( PMTEsHasRegistration( p_demux, p_es, "DTS1" ) ||
               PMTEsHasRegistration( p_demux, p_es, "DTS2" ) ||
      {
          /*registration descriptor(ETSI TS 101 154 Annex F)*/
          p_fmt->i_cat = AUDIO_ES;
 -        p_fmt->i_codec = VLC_FOURCC('d','t','s',' ');
 +        p_fmt->i_codec = VLC_CODEC_DTS;
      }
      else if( PMTEsHasRegistration( p_demux, p_es, "BSSD" ) )
      {
          p_fmt->i_cat = AUDIO_ES;
          p_fmt->b_packetized = true;
 -        p_fmt->i_codec = VLC_FOURCC('a','e','s','3');
 +        p_fmt->i_codec = VLC_CODEC_302M;
      }
      else
      {
@@@ -3542,7 -3544,7 +3544,7 @@@ static void PMTSetupEs0xEA( demux_t *p_
  
      /* registration descriptor for VC-1 (SMPTE rp227) */
      p_fmt->i_cat = VIDEO_ES;
 -    p_fmt->i_codec = VLC_FOURCC('W','V','C','1');
 +    p_fmt->i_codec = VLC_CODEC_VC1;
  
      /* XXX With Simple and Main profile the SEQUENCE
       * header is modified: video width and height are
@@@ -3565,7 -3567,7 +3567,7 @@@ static void PMTSetupEs0xD1( demux_t *p_
      /* registration descriptor for Dirac
       * (backwards compatable with VC-2 (SMPTE Sxxxx:2008)) */
      p_fmt->i_cat = VIDEO_ES;
 -    p_fmt->i_codec = VLC_FOURCC('d','r','a','c');
 +    p_fmt->i_codec = VLC_CODEC_DIRAC;
  }
  
  static void PMTSetupEs0xA0( demux_t *p_demux, ts_pid_t *pid,
@@@ -3613,26 -3615,26 +3615,26 @@@ static void PMTSetupEsHDMV( demux_t *p_
      {
      case 0x80:
          p_fmt->i_cat = AUDIO_ES;
 -        p_fmt->i_codec = VLC_FOURCC( 'b', 'p', 'c', 'm' );
 +        p_fmt->i_codec = VLC_CODEC_BD_LPCM;
          break;
      case 0x82:
      case 0x85: /* DTS-HD High resolution audio */
      case 0x86: /* DTS-HD Master audio */
      case 0xA2: /* Secondary DTS audio */
          p_fmt->i_cat = AUDIO_ES;
 -        p_fmt->i_codec = VLC_FOURCC( 'd', 't', 's', ' ' );
 +        p_fmt->i_codec = VLC_CODEC_DTS;
          break;
  
      case 0x83: /* TrueHD AC3 */
          p_fmt->i_cat = AUDIO_ES;
 -        p_fmt->i_codec = VLC_FOURCC( 'm', 'l', 'p', ' ' );
 +        p_fmt->i_codec = VLC_CODEC_MLP;
          break;
  
      case 0x84: /* E-AC3 */
      case 0x87: /* E-AC3 */
      case 0xA1: /* Secondary E-AC3 */
          p_fmt->i_cat = AUDIO_ES;
 -        p_fmt->i_codec = VLC_FOURCC( 'e', 'a', 'c', '3' );
 +        p_fmt->i_codec = VLC_CODEC_EAC3;
          break;
      case 0x90: /* Presentation graphics */
      case 0x91: /* Interactive graphics */
@@@ -3934,8 -3936,8 +3936,8 @@@ static void PMTCallBack( demux_t *p_dem
  
          if( pid->es->fmt.i_cat == AUDIO_ES ||
              ( pid->es->fmt.i_cat == SPU_ES &&
 -              pid->es->fmt.i_codec != VLC_FOURCC('d','v','b','s') &&
 -              pid->es->fmt.i_codec != VLC_FOURCC('t','e','l','x') ) )
 +              pid->es->fmt.i_codec != VLC_CODEC_DVBS &&
 +              pid->es->fmt.i_codec != VLC_CODEC_TELETEXT ) )
          {
              PMTParseEsIso639( p_demux, pid, p_es );
          }
index 7bb39c12796abaad08b199e28a414935e4f6f5b8,0bde8ff48183de77858407a11509becbe32228ca..33cbba1f663abfbf0199a21388206aa9b488d7da
@@@ -84,6 -84,7 +84,7 @@@ MainInterface::MainInterface( intf_thre
      cryptedLabel         = NULL;
      controls             = NULL;
      inputC               = NULL;
+     b_shouldHide         = false;
  
      bgWasVisible         = false;
      i_bg_height          = 0;
      /* Final sizing and showing */
      setMinimumWidth( __MAX( controls->sizeHint().width(),
                              menuBar()->sizeHint().width() ) );
-     show();
+     setVisible( !b_shouldHide );
  
      /* And switch to minimal view if needed
         Must be called after the show() */
@@@ -462,7 -463,7 +463,7 @@@ inline void MainInterface::initSystray(
          if( b_systrayAvailable )
          {
              b_systrayWanted = true;
-             hide();
+             b_shouldHide = true;
          }
          else
              msg_Err( p_intf, "cannot start minimized without system tray bar" );
@@@ -760,7 -761,7 +761,7 @@@ void MainInterface::releaseVideoSlot( v
      videoIsActive = false;
  
      /* Try to resize, except when you are in Fullscreen mode */
 -    if( !isFullScreen() ) doComponentsUpdate();
 +    doComponentsUpdate();
  }
  
  /* Call from WindowControl function */
index 515f79f367f2f576fbc9c3f9c3b4bbb952a7d999,d522a8b7ae7719e85745307e42e66c9a31cf7fce..1d39a81685cf09830bf050aea9d09187742a3312
@@@ -144,6 -144,7 +144,7 @@@ private
      pl_dock_e            i_pl_dock;
      bool                 isDocked() { return ( i_pl_dock != PL_UNDOCKED ); }
      int                  i_bg_height;         ///< Save height of bgWidget
+     bool                 b_shouldHide;
  
      /* Status Bar */
      QLabel              *nameLabel;
@@@ -182,6 -183,7 +183,6 @@@ signals
      void askReleaseVideo( );
      void askVideoToResize( unsigned int, unsigned int );
      void askVideoToShow( unsigned int, unsigned int );
 -    void askVideoToToggle();
      void askBgWidgetToToggle();
      void askUpdate();
      void minimalViewToggled( bool );
diff --combined modules/gui/qt4/qt4.cpp
index 61c12760d130f0f629582a7f4404a6f262f1b17c,ec2efbe96c6fc0e27393c56d10dff48d6570cab1..e3507754cc7266bd9ba034d0578c5ba0bd59c50b
@@@ -223,7 -223,7 +223,7 @@@ vlc_module_begin (
                   UPDATER_DAYS_TEXT, false )
  #endif
      add_string( "qt-slider-colours",
-                 "255;255;255;20;226;20;255;176;15;235;30;20",
+                 "255;255;255;20;210;20;255;199;15;245;39;29",
                  NULL, SLIDERCOL_TEXT, SLIDERCOL_LONGTEXT, false )
  
      add_bool( "qt-privacy-ask", true, NULL, PRIVACY_TEXT, PRIVACY_TEXT,
@@@ -350,6 -350,17 +350,6 @@@ static void *Thread( void *obj 
  
      Q_INIT_RESOURCE( vlc );
  
 -#if !defined(WIN32) && !defined(__APPLE__)
 -    /* KLUDGE:
 -     * disables icon theme use because that makes Cleanlooks style bug
 -     * because it asks gconf for some settings that timeout because of threads
 -     * see commits 21610 21622 21654 for reference */
 -
 -    /* If you don't have a gconftool-2 binary, you should comment this line */
 -    if( strcmp( qVersion(), "4.4.0" ) < 0 ) /* fixed in Qt 4.4.0 */
 -        QApplication::setDesktopSettingsAware( false );
 -#endif
 -
      /* Start the QApplication here */
  #ifdef Q_WS_X11
      char *display = var_CreateGetNonEmptyString( p_intf, "x11-display" );
diff --combined modules/misc/rtsp.c
index f1a04676849687e501503c0d9f2dac4402f81cb2,ee23ed54d3002efdfeee40b7a89bedde3587febb..a87dc3fcf6393acfbde725b6069739be7297c02b
@@@ -221,6 -221,17 +221,17 @@@ typedef enu
      RTSP_CMD_TYPE_FORWARD,
  } rtsp_cmd_type_t;
  
+ /* */
+ typedef struct
+ {
+     int i_type;
+     int i_media_id;
+     //vod_media_t *p_media;
+     char *psz_session;
+     char *psz_arg;
+     double f_arg;
+ } rtsp_cmd_t;
  static vod_media_t *MediaNew( vod_t *, const char *, input_item_t * );
  static void         MediaDel( vod_t *, vod_media_t * );
  static int          MediaAddES( vod_t *, vod_media_t *, es_format_t * );
@@@ -337,12 -348,22 +348,22 @@@ static void Close( vlc_object_t * p_thi
  {
      vod_t *p_vod = (vod_t *)p_this;
      vod_sys_t *p_sys = p_vod->p_sys;
+     block_t *p_block_cmd;
+     rtsp_cmd_t cmd;
  
      /* Stop command thread */
      vlc_object_kill( p_vod );
      CommandPush( p_vod, RTSP_CMD_TYPE_NONE, NULL, NULL, 0.0, NULL );
      vlc_thread_join( p_vod );
  
+     while( block_FifoCount( p_sys->p_fifo_cmd ) > 0 )
+     {
+          p_block_cmd = block_FifoGet( p_sys->p_fifo_cmd );
+          memcpy( &cmd, p_block_cmd->p_buffer, sizeof(cmd) );
+          block_Release( p_block_cmd );
+          free( cmd.psz_session );
+          free( cmd.psz_arg );
+     }
      block_FifoRelease( p_sys->p_fifo_cmd );
  
      httpd_HostDelete( p_sys->p_rtsp_host );
@@@ -517,7 -538,7 +538,7 @@@ static int MediaAddES( vod_t *p_vod, vo
  
      switch( p_fmt->i_codec )
      {
 -        case VLC_FOURCC( 's', '1', '6', 'b' ):
 +        case VLC_CODEC_S16B:
              if( p_fmt->audio.i_channels == 1 && p_fmt->audio.i_rate == 44100 )
              {
                  p_es->i_payload_type = 11;
                            p_fmt->audio.i_channels ) == -1 )
                  p_es->psz_rtpmap = NULL;
              break;
 -        case VLC_FOURCC( 'u', '8', ' ', ' ' ):
 +        case VLC_CODEC_U8:
              p_es->i_payload_type = p_media->i_payload_type++;
              if( asprintf( &p_es->psz_rtpmap, "L8/%d/%d", p_fmt->audio.i_rate,
                            p_fmt->audio.i_channels ) == -1 )
                  p_es->psz_rtpmap = NULL;
              break;
 -        case VLC_FOURCC( 'm', 'p', 'g', 'a' ):
 -        case VLC_FOURCC( 'm', 'p', '3', ' ' ):
 +        case VLC_CODEC_MPGA:
              p_es->i_payload_type = 14;
              p_es->psz_rtpmap = strdup( "MPA/90000" );
              break;
 -        case VLC_FOURCC( 'm', 'p', 'g', 'v' ):
 +        case VLC_CODEC_MPGV:
              p_es->i_payload_type = 32;
              p_es->psz_rtpmap = strdup( "MPV/90000" );
              break;
 -        case VLC_FOURCC( 'a', '5', '2', ' ' ):
 +        case VLC_CODEC_A52:
              p_es->i_payload_type = p_media->i_payload_type++;
              if( asprintf( &p_es->psz_rtpmap, "ac3/%d", p_fmt->audio.i_rate ) == -1 )
                  p_es->psz_rtpmap = NULL;
              break;
 -        case VLC_FOURCC( 'H', '2', '6', '3' ):
 +        case VLC_CODEC_H263:
              p_es->i_payload_type = p_media->i_payload_type++;
              p_es->psz_rtpmap = strdup( "H263-1998/90000" );
              break;
 -        case VLC_FOURCC( 'h', '2', '6', '4' ):
 +        case VLC_CODEC_H264:
              p_es->i_payload_type = p_media->i_payload_type++;
              p_es->psz_rtpmap = strdup( "H264/90000" );
              p_es->psz_fmtp = NULL;
              if( !p_es->psz_fmtp )
                  p_es->psz_fmtp = strdup( "packetization-mode=1" );
              break;
 -        case VLC_FOURCC( 'm', 'p', '4', 'v' ):
 +        case VLC_CODEC_MP4V:
              p_es->i_payload_type = p_media->i_payload_type++;
              p_es->psz_rtpmap = strdup( "MP4V-ES/90000" );
              if( p_fmt->i_extra > 0 )
                  free( p_hexa );
              }
              break;
 -        case VLC_FOURCC( 'm', 'p', '4', 'a' ):
 +        case VLC_CODEC_MP4A:
              p_es->i_payload_type = p_media->i_payload_type++;
              if( asprintf( &p_es->psz_rtpmap, "mpeg4-generic/%d", p_fmt->audio.i_rate ) == -1 )
                  p_es->psz_rtpmap = NULL;
              p_es->i_payload_type = p_media->i_payload_type++;
              p_es->psz_rtpmap = strdup( "MP2P/90000" );
              break;
 -        case VLC_FOURCC( 's', 'a', 'm', 'r' ):
 +        case VLC_CODEC_AMR_NB:
              p_es->i_payload_type = p_media->i_payload_type++;
              p_es->psz_rtpmap = strdup( p_fmt->audio.i_channels == 2 ?
                                      "AMR/8000/2" : "AMR/8000" );
              p_es->psz_fmtp = strdup( "octet-align=1" );
              break;
 -        case VLC_FOURCC( 's', 'a', 'w', 'b' ):
 +        case VLC_CODEC_AMR_WB:
              p_es->i_payload_type = p_media->i_payload_type++;
              p_es->psz_rtpmap = strdup( p_fmt->audio.i_channels == 2 ?
                                      "AMR-WB/16000/2" : "AMR-WB/16000" );
@@@ -779,17 -801,6 +800,6 @@@ static void MediaDelES( vod_t *p_vod, v
      free( p_es );
  }
  
- /* */
- typedef struct
- {
-     int i_type;
-     int i_media_id;
-     //vod_media_t *p_media;
-     char *psz_session;
-     char *psz_arg;
-     double f_arg;
- } rtsp_cmd_t;
  static void CommandPush( vod_t *p_vod, rtsp_cmd_type_t i_type, vod_media_t *p_media, const char *psz_session,
                           double f_arg, const char *psz_arg )
  {
index 9d7b042d4c6dee384b16fe315834f605c19cb4bd,b4bf89136ab1126212cc4a0286783aac5d89a22c..d8eb8cad0cba5d38de97e14f99dffd6e9ccee7ba
@@@ -268,10 -268,13 +268,10 @@@ static int  transcode_video_encoder_ope
  static int  transcode_video_process( sout_stream_t *, sout_stream_id_t *,
                                       block_t *, block_t ** );
  
 -static void video_del_buffer( vlc_object_t *, picture_t * );
  static picture_t *video_new_buffer_decoder( decoder_t * );
  static void video_del_buffer_decoder( decoder_t *, picture_t * );
  static void video_link_picture_decoder( decoder_t *, picture_t * );
  static void video_unlink_picture_decoder( decoder_t *, picture_t * );
 -static picture_t *video_new_buffer_filter( filter_t * );
 -static void video_del_buffer_filter( filter_t *, picture_t * );
  
  static int  transcode_spu_new    ( sout_stream_t *, sout_stream_id_t * );
  static void transcode_spu_close  ( sout_stream_id_t * );
@@@ -362,6 -365,12 +362,6 @@@ struct sout_stream_sys_
  
  struct decoder_owner_sys_t
  {
 -    picture_t *pp_pics[PICTURE_RING_SIZE];
 -    sout_stream_sys_t *p_sys;
 -};
 -struct filter_owner_sys_t
 -{
 -    picture_t *pp_pics[PICTURE_RING_SIZE];
      sout_stream_sys_t *p_sys;
  };
  
@@@ -424,8 -433,8 +424,8 @@@ static int Open( vlc_object_t *p_this 
  
      if( p_sys->i_acodec )
      {
 -        if( p_sys->i_acodec == VLC_FOURCC('m','p','3',0) &&
 -            p_sys->i_channels > 2 )
 +        if( ( p_sys->i_acodec == VLC_CODEC_MP3 ||
 +              p_sys->i_acodec == VLC_CODEC_MPGA ) && p_sys->i_channels > 2 )
          {
              msg_Warn( p_stream, "%d channels invalid for mp3, forcing to 2",
                        p_sys->i_channels );
                                     &p_sys->p_osd_cfg, strdup( "dvbsub") );
          free( psz_next );
  
 -        p_sys->i_osdcodec = VLC_FOURCC('Y','U','V','P' );
 +        p_sys->i_osdcodec = VLC_CODEC_YUVP;
  
          msg_Dbg( p_stream, "codec osd=%4.4s", (char *)&p_sys->i_osdcodec );
  
@@@ -1073,11 -1082,11 +1073,11 @@@ static int transcode_audio_filter_chain
           p_dst->audio.i_rate );
  
      /* If any filter is needed, convert to fl32 */
 -    if( current.i_codec != VLC_FOURCC('f','l','3','2') )
 +    if( current.i_codec != VLC_CODEC_FL32 )
      {
          /* First step, convert to fl32 */
          current.i_codec =
 -        current.audio.i_format = VLC_FOURCC('f','l','3','2');
 +        current.audio.i_format = VLC_CODEC_FL32;
  
          if( !filter_chain_AppendFilter( p_chain, NULL, NULL, NULL, &current ) )
          {
@@@ -1173,7 -1182,7 +1173,7 @@@ static int transcode_audio_new( sout_st
          aout_BitsPerSample( id->p_decoder->fmt_out.i_codec );
      fmt_last = id->p_decoder->fmt_out;
      /* Fix AAC SBR changing number of channels and sampling rate */
 -    if( !(id->p_decoder->fmt_in.i_codec == VLC_FOURCC('m','p','4','a') &&
 +    if( !(id->p_decoder->fmt_in.i_codec == VLC_CODEC_MP4A &&
          fmt_last.audio.i_rate != id->p_encoder->fmt_in.audio.i_rate &&
          fmt_last.audio.i_channels != id->p_encoder->fmt_in.audio.i_channels) )
          fmt_last.audio.i_rate = id->p_decoder->fmt_in.audio.i_rate;
      {
          es_format_t fmt_fl32 = fmt_last;
          fmt_fl32.i_codec =
 -        fmt_fl32.audio.i_format = VLC_FOURCC('f','l','3','2');
 +        fmt_fl32.audio.i_format = VLC_CODEC_FL32;
          if( transcode_audio_filter_chain_build( p_stream, id->p_uf_chain,
                                                  &fmt_fl32, &fmt_last ) )
          {
      }
      fmt_last = id->p_encoder->fmt_in;
  
 -    /* FIXME: Hack for mp3 transcoding support */
 -    if( id->p_encoder->fmt_out.i_codec == VLC_FOURCC( 'm','p','3',' ' ) )
 -        id->p_encoder->fmt_out.i_codec = VLC_FOURCC( 'm','p','g','a' );
 +    /* */
 +    id->p_encoder->fmt_out.i_codec =
 +        vlc_fourcc_GetCodec( AUDIO_ES, id->p_encoder->fmt_out.i_codec );
  
      return VLC_SUCCESS;
  }
@@@ -1397,35 -1406,44 +1397,35 @@@ static void audio_del_buffer( decoder_
   * video
   */
  
 +static picture_t *transcode_video_filter_buffer_new( filter_t *p_filter )
 +{
 +    p_filter->fmt_out.video.i_chroma = p_filter->fmt_out.i_codec;
 +    return picture_New( p_filter->fmt_out.video.i_chroma,
 +                        p_filter->fmt_out.video.i_width,
 +                        p_filter->fmt_out.video.i_height,
 +                        p_filter->fmt_out.video.i_aspect );
 +}
 +static void transcode_video_filter_buffer_del( filter_t *p_filter, picture_t *p_pic )
 +{
 +    VLC_UNUSED(p_filter);
 +    picture_Release( p_pic );
 +}
 +
  static int transcode_video_filter_allocation_init( filter_t *p_filter,
                                                     void *p_data )
  {
 -    sout_stream_sys_t *p_sys = (sout_stream_sys_t*)p_data;
 -    int i;
 -
 -    p_filter->pf_vout_buffer_new = video_new_buffer_filter;
 -    p_filter->pf_vout_buffer_del = video_del_buffer_filter;
 -
 -    p_filter->p_owner = malloc( sizeof(filter_owner_sys_t) );
 -    if( !p_filter->p_owner )
 -        return VLC_EGENERIC;
 -
 -    for( i = 0; i < PICTURE_RING_SIZE; i++ )
 -        p_filter->p_owner->pp_pics[i] = 0;
 -    p_filter->p_owner->p_sys = p_sys;
 -
 +    p_filter->pf_vout_buffer_new = transcode_video_filter_buffer_new;
 +    p_filter->pf_vout_buffer_del = transcode_video_filter_buffer_del;
      return VLC_SUCCESS;
  }
  
  static void transcode_video_filter_allocation_clear( filter_t *p_filter )
  {
 -    int j;
 -
 -    /* Clean-up pictures ring buffer */
 -    for( j = 0; j < PICTURE_RING_SIZE; j++ )
 -    {
 -        if( p_filter->p_owner->pp_pics[j] )
 -            video_del_buffer( VLC_OBJECT(p_filter),
 -                              p_filter->p_owner->pp_pics[j] );
 -    }
 -    free( p_filter->p_owner );
  }
  
  static int transcode_video_new( sout_stream_t *p_stream, sout_stream_id_t *id )
  {
      sout_stream_sys_t *p_sys = p_stream->p_sys;
 -    int i;
  
      /* Open decoder
       * Initialization of decoder structures
      if( !id->p_decoder->p_owner )
          return VLC_EGENERIC;
  
 -    for( i = 0; i < PICTURE_RING_SIZE; i++ )
 -        id->p_decoder->p_owner->pp_pics[i] = 0;
      id->p_decoder->p_owner->p_sys = p_sys;
      /* id->p_decoder->p_cfg = p_sys->p_video_cfg; */
  
      /* The dimensions will be set properly later on.
       * Just put sensible values so we can test an encoder is available. */
      id->p_encoder->fmt_in.video.i_width =
-         id->p_encoder->fmt_out.video.i_width ?:
-         id->p_decoder->fmt_in.video.i_width ?: 16;
+         id->p_encoder->fmt_out.video.i_width
+           ? id->p_encoder->fmt_out.video.i_width
+           : id->p_decoder->fmt_in.video.i_width
+             ? id->p_decoder->fmt_in.video.i_width : 16;
      id->p_encoder->fmt_in.video.i_height =
-         id->p_encoder->fmt_out.video.i_height ?:
-         id->p_decoder->fmt_in.video.i_height ?: 16;
+         id->p_encoder->fmt_out.video.i_height
+           ? id->p_encoder->fmt_out.video.i_height
+           : id->p_decoder->fmt_in.video.i_height
+             ? id->p_decoder->fmt_in.video.i_height : 16;
      id->p_encoder->fmt_in.video.i_frame_rate = ENC_FRAMERATE;
      id->p_encoder->fmt_in.video.i_frame_rate_base = ENC_FRAMERATE_BASE;
  
@@@ -1715,9 -1739,12 +1719,9 @@@ static int transcode_video_encoder_open
  
      id->p_encoder->fmt_in.video.i_chroma = id->p_encoder->fmt_in.i_codec;
  
 -    /* Hack for mp2v/mp1v transcoding support */
 -    if( id->p_encoder->fmt_out.i_codec == VLC_FOURCC('m','p','1','v') ||
 -        id->p_encoder->fmt_out.i_codec == VLC_FOURCC('m','p','2','v') )
 -    {
 -        id->p_encoder->fmt_out.i_codec = VLC_FOURCC('m','p','g','v');
 -    }
 +    /*  */
 +    id->p_encoder->fmt_out.i_codec =
 +        vlc_fourcc_GetCodec( VIDEO_ES, id->p_encoder->fmt_out.i_codec );
  
      id->id = sout_StreamIdAdd( p_stream->p_sys->p_out,
                                 &id->p_encoder->fmt_out );
  static void transcode_video_close( sout_stream_t *p_stream,
                                     sout_stream_id_t *id )
  {
 -    int i;
 -
      if( p_stream->p_sys->i_threads >= 1 )
      {
          vlc_mutex_lock( &p_stream->p_sys->lock_out );
      if( id->p_decoder->p_description )
          vlc_meta_Delete( id->p_decoder->p_description );
  
 -    if( id->p_decoder->p_owner )
 -    {
 -        /* Clean-up pictures ring buffer */
 -        for( i = 0; i < PICTURE_RING_SIZE; i++ )
 -        {
 -            if( id->p_decoder->p_owner->pp_pics[i] )
 -                video_del_buffer( VLC_OBJECT(id->p_decoder),
 -                                  id->p_decoder->p_owner->pp_pics[i] );
 -        }
 -        free( id->p_decoder->p_owner );
 -    }
 +    free( id->p_decoder->p_owner );
  
      /* Close encoder */
      if( id->p_encoder->p_module )
@@@ -1787,7 -1826,7 +1791,7 @@@ static int transcode_video_process( sou
              {
                  msg_Dbg( p_stream, "late picture skipped (%"PRId64")",
                           current_date + 50000 - p_pic->date );
 -                p_pic->pf_release( p_pic );
 +                picture_Release( p_pic );
                  continue;
              }
          }
                  msg_Dbg( p_stream, "dropping frame (%i)",
                           (int)(i_video_drift - i_master_drift) );
  #endif
 -                p_pic->pf_release( p_pic );
 +                picture_Release( p_pic );
                  continue;
              }
              else if( i_video_drift > (i_master_drift + 50000) )
  
              if( transcode_video_encoder_open( p_stream, id ) != VLC_SUCCESS )
              {
 -                p_pic->pf_release( p_pic );
 +                picture_Release( p_pic );
                  transcode_video_close( p_stream, id );
                  id->b_transcode = false;
                  return VLC_EGENERIC;
          {
              video_format_t fmt;
  
 -            if( p_pic->i_refcount && !filter_chain_GetLength( id->p_f_chain ) )
 +            if( picture_IsReferenced( p_pic ) && !filter_chain_GetLength( id->p_f_chain ) )
              {
                  /* We can't modify the picture, we need to duplicate it */
                  picture_t *p_tmp = video_new_buffer_decoder( id->p_decoder );
                  if( p_tmp )
                  {
                      picture_Copy( p_tmp, p_pic );
 -                    p_pic->pf_release( p_pic );
 +                    picture_Release( p_pic );
                      p_pic = p_tmp;
                  }
              }
  
          if( p_sys->i_threads == 0 )
          {
 -            p_pic->pf_release( p_pic );
 +            picture_Release( p_pic );
          }
          else
          {
@@@ -2061,14 -2100,14 +2065,14 @@@ static void* EncoderThread( vlc_object_
          block_ChainAppend( &p_sys->p_buffers, p_block );
  
          vlc_mutex_unlock( &p_sys->lock_out );
 -        p_pic->pf_release( p_pic );
 +        picture_Release( p_pic );
      }
  
      while( p_sys->i_last_pic != p_sys->i_first_pic )
      {
          p_pic = p_sys->pp_pics[p_sys->i_first_pic++];
          p_sys->i_first_pic %= PICTURE_RING_SIZE;
 -        p_pic->pf_release( p_pic );
 +        picture_Release( p_pic );
      }
      block_ChainRelease( p_sys->p_buffers );
  
      return NULL;
  }
  
 -struct picture_sys_t
 -{
 -    vlc_object_t *p_owner;
 -};
 -
 -static void video_release_buffer( picture_t *p_pic )
 +static picture_t *video_new_buffer_decoder( decoder_t *p_dec )
  {
 -    if( p_pic && !p_pic->i_refcount && p_pic->pf_release && p_pic->p_sys )
 +    sout_stream_sys_t *p_ssys = p_dec->p_owner->p_sys;
 +    if( p_ssys->i_threads >= 1 )
      {
 -        video_del_buffer_decoder( (decoder_t *)p_pic->p_sys->p_owner, p_pic );
 -    }
 -    else if( p_pic && p_pic->i_refcount > 0 ) p_pic->i_refcount--;
 -}
 -
 -static picture_t *video_new_buffer( vlc_object_t *p_this, picture_t **pp_ring,
 -                                    sout_stream_sys_t *p_sys )
 -{
 -    decoder_t *p_dec = (decoder_t *)p_this;
 -    picture_t *p_pic;
 -    int i;
 +        int i_first_pic = p_ssys->i_first_pic;
  
 -    /* Find an empty space in the picture ring buffer */
 -    for( i = 0; i < PICTURE_RING_SIZE; i++ )
 -    {
 -        if( pp_ring[i] != NULL && pp_ring[i]->i_status == DESTROYED_PICTURE )
 -        {
 -            pp_ring[i]->i_status = RESERVED_PICTURE;
 -            return pp_ring[i];
 -        }
 -    }
 -    for( i = 0; i < PICTURE_RING_SIZE; i++ )
 -    {
 -        if( pp_ring[i] == NULL ) break;
 -    }
 -
 -    if( i == PICTURE_RING_SIZE && p_sys->i_threads >= 1 )
 -    {
 -        int i_first_pic = p_sys->i_first_pic;
 -
 -        if( p_sys->i_first_pic != p_sys->i_last_pic )
 +        if( p_ssys->i_first_pic != p_ssys->i_last_pic )
          {
              /* Encoder still has stuff to encode, wait to clear-up the list */
 -            while( p_sys->i_first_pic == i_first_pic )
 +            while( p_ssys->i_first_pic == i_first_pic )
                  msleep( 100000 );
          }
 -
 -        /* Find an empty space in the picture ring buffer */
 -        for( i = 0; i < PICTURE_RING_SIZE; i++ )
 -        {
 -            if( pp_ring[i] != NULL && pp_ring[i]->i_status == DESTROYED_PICTURE )
 -            {
 -                pp_ring[i]->i_status = RESERVED_PICTURE;
 -                return pp_ring[i];
 -            }
 -        }
 -        for( i = 0; i < PICTURE_RING_SIZE; i++ )
 -        {
 -            if( pp_ring[i] == NULL ) break;
 -        }
 -    }
 -
 -    if( i == PICTURE_RING_SIZE )
 -    {
 -        msg_Err( p_this, "decoder/filter is leaking pictures, "
 -                 "resetting its ring buffer" );
 -
 -        for( i = 0; i < PICTURE_RING_SIZE; i++ )
 -        {
 -            pp_ring[i]->pf_release( pp_ring[i] );
 -        }
 -
 -        i = 0;
      }
  
      p_dec->fmt_out.video.i_chroma = p_dec->fmt_out.i_codec;
 -    p_pic = picture_New( p_dec->fmt_out.video.i_chroma,
 -                         p_dec->fmt_out.video.i_width,
 -                         p_dec->fmt_out.video.i_height,
 -                         p_dec->fmt_out.video.i_aspect );
 -    if( !p_pic ) return NULL;
 -    p_pic->p_sys = calloc( 1, sizeof(picture_sys_t) );
 -    if( !p_pic->p_sys )
 -    {
 -        picture_Release( p_pic );
 -        return NULL;
 -    }
 -    p_pic->pf_release = video_release_buffer;
 -    p_pic->i_refcount = 0;
 -
 -    pp_ring[i] = p_pic;
 -    return p_pic;
 -}
 -
 -static picture_t *video_new_buffer_decoder( decoder_t *p_dec )
 -{
 -    return video_new_buffer( VLC_OBJECT(p_dec),
 -                             p_dec->p_owner->pp_pics, p_dec->p_owner->p_sys );
 -}
 -
 -static picture_t *video_new_buffer_filter( filter_t *p_filter )
 -{
 -    return video_new_buffer( VLC_OBJECT(p_filter),
 -                             p_filter->p_owner->pp_pics,
 -                             p_filter->p_owner->p_sys );
 -}
 -
 -static void video_del_buffer( vlc_object_t *p_this, picture_t *p_pic )
 -{
 -    VLC_UNUSED(p_this);
 -    if( p_pic )
 -    {
 -        free( p_pic->p_q );
 -        free( p_pic->p_data_orig );
 -        free( p_pic->p_sys );
 -        free( p_pic );
 -    }
 +    return picture_New( p_dec->fmt_out.video.i_chroma,
 +                        p_dec->fmt_out.video.i_width,
 +                        p_dec->fmt_out.video.i_height,
 +                        p_dec->fmt_out.video.i_aspect );
  }
  
  static void video_del_buffer_decoder( decoder_t *p_decoder, picture_t *p_pic )
  {
      VLC_UNUSED(p_decoder);
 -    p_pic->i_refcount = 0;
 -    p_pic->i_status = DESTROYED_PICTURE;
 -    picture_CleanupQuant( p_pic );
 -}
 -
 -static void video_del_buffer_filter( filter_t *p_filter, picture_t *p_pic )
 -{
 -    VLC_UNUSED(p_filter);
 -    p_pic->i_refcount = 0;
 -    p_pic->i_status = DESTROYED_PICTURE;
 -    picture_CleanupQuant( p_pic );
 +    picture_Release( p_pic );
  }
  
  static void video_link_picture_decoder( decoder_t *p_dec, picture_t *p_pic )
  {
      VLC_UNUSED(p_dec);
 -    p_pic->i_refcount++;
 +    picture_Hold( p_pic );
  }
  
  static void video_unlink_picture_decoder( decoder_t *p_dec, picture_t *p_pic )
  {
      VLC_UNUSED(p_dec);
 -    video_release_buffer( p_pic );
 +    picture_Release( p_pic );
  }
  
  /*
@@@ -2261,7 -2406,7 +2265,7 @@@ static int transcode_osd_new( sout_stre
  
          /* Open encoder */
          es_format_Init( &id->p_encoder->fmt_in, id->p_decoder->fmt_in.i_cat,
 -                        VLC_FOURCC('Y','U','V','A') );
 +                        VLC_CODEC_YUVA );
          id->p_encoder->fmt_in.psz_language = strdup( "osd" );
  
          id->p_encoder->p_cfg = p_sys->p_osd_cfg;
index 7d0da3cff2cf42ab7cd3510df8d6c4a941fd72f8,fa671dc2127d58b5e3f26fd91cee72961f1af140..c8dfecf48b1bae95daab08e6fa54570989f894e3
@@@ -36,6 -36,7 +36,6 @@@
  #include <vlc_common.h>
  #include <vlc_plugin.h>
  #include <vlc_sout.h>
 -#include <vlc_vout.h>
  
  #include "vlc_filter.h"
  #include "filter_picture.h"
@@@ -112,6 -113,7 +112,7 @@@ static const char *const ppsz_filter_op
   *****************************************************************************/
  struct filter_sys_t
  {
+     vlc_mutex_t lock;
      double     f_contrast;
      double     f_brightness;
      int        i_hue;
@@@ -171,6 -173,7 +172,7 @@@ static int Create( vlc_object_t *p_thi
      p_sys->b_brightness_threshold =
          var_CreateGetBoolCommand( p_filter, "brightness-threshold" );
  
+     vlc_mutex_init( &p_sys->lock );
      var_AddCallback( p_filter, "contrast",   AdjustCallback, p_sys );
      var_AddCallback( p_filter, "brightness", AdjustCallback, p_sys );
      var_AddCallback( p_filter, "hue",        AdjustCallback, p_sys );
@@@ -198,6 -201,7 +200,7 @@@ static void Destroy( vlc_object_t *p_th
      var_DelCallback( p_filter, "brightness-threshold",
                                               AdjustCallback, p_sys );
  
+     vlc_mutex_destroy( &p_sys->lock );
      free( p_sys );
  }
  
@@@ -231,13 -235,15 +234,15 @@@ static picture_t *FilterPlanar( filter_
          return NULL;
      }
  
-     /* Getvariables */
+     /* Get variables */
+     vlc_mutex_lock( &p_sys->lock );
      i_cont = (int)( p_sys->f_contrast * 255 );
      i_lum = (int)( (p_sys->f_brightness - 1.0)*255 );
      f_hue = (float)( p_sys->i_hue * M_PI / 180 );
      i_sat = (int)( p_sys->f_saturation * 256 );
      f_gamma = 1.0 / p_sys->f_gamma;
      b_thres = p_sys->b_brightness_threshold;
+     vlc_mutex_unlock( &p_sys->lock );
  
      /*
       * Threshold mode drops out everything about luma, contrast and gamma.
@@@ -459,7 -465,7 +464,7 @@@ static picture_t *FilterPacked( filter_
          return NULL;
      }
  
 -    p_outpic = p_filter->pf_vout_buffer_new( p_filter );
 +    p_outpic = filter_NewPicture( p_filter );
      if( !p_outpic )
      {
          msg_Warn( p_filter, "can't get output picture" );
          return NULL;
      }
  
-     /* Getvariables */
+     /* Get variables */
+     vlc_mutex_lock( &p_sys->lock );
      i_cont = (int)( p_sys->f_contrast * 255 );
      i_lum = (int)( (p_sys->f_brightness - 1.0)*255 );
      f_hue = (float)( p_sys->i_hue * M_PI / 180 );
      i_sat = (int)( p_sys->f_saturation * 256 );
      f_gamma = 1.0 / p_sys->f_gamma;
      b_thres = p_sys->b_brightness_threshold;
+     vlc_mutex_unlock( &p_sys->lock );
  
      /*
       * Threshold mode drops out everything about luma, contrast and gamma.
@@@ -658,6 -666,7 +665,7 @@@ static int AdjustCallback( vlc_object_
      VLC_UNUSED(p_this); VLC_UNUSED(oldval);
      filter_sys_t *p_sys = (filter_sys_t *)p_data;
  
+     vlc_mutex_lock( &p_sys->lock );
      if( !strcmp( psz_var, "contrast" ) )
          p_sys->f_contrast = newval.f_float;
      else if( !strcmp( psz_var, "brightness" ) )
          p_sys->f_gamma = newval.f_float;
      else if( !strcmp( psz_var, "brightness-threshold" ) )
          p_sys->b_brightness_threshold = newval.b_bool;
-     else
-         return VLC_EGENERIC;
+     vlc_mutex_unlock( &p_sys->lock );
      return VLC_SUCCESS;
  }
index 1b219447723446709aacad7528160f29de23ffaf,af46bd7a641092976a64084cd039544c6958dd5e..b9ddcd9445fe63b5dd012e7bd71485effab168ec
@@@ -31,6 -31,7 +31,6 @@@
  
  #include <vlc_common.h>
  #include <vlc_plugin.h>
 -#include <vlc_vout.h>
  
  #include <vlc_image.h>
  #include <vlc_filter.h>
@@@ -89,7 -90,7 +89,7 @@@ static int Create( vlc_object_t *p_thi
      filter_sys_t *p_sys;
      char *psz_string;
  
 -    if( p_filter->fmt_in.video.i_chroma != VLC_FOURCC('Y','U','V','A') )
 +    if( p_filter->fmt_in.video.i_chroma != VLC_CODEC_YUVA )
      {
          msg_Err( p_filter,
                   "Unsupported input chroma \"%4s\". "
      config_ChainParse( p_filter, CFG_PREFIX, ppsz_filter_options,
                         p_filter->p_cfg );
  
-     vlc_mutex_init( &p_sys->mask_lock );
-     psz_string =
-         var_CreateGetStringCommand( p_filter, CFG_PREFIX "mask" );
-     var_AddCallback( p_filter, CFG_PREFIX "mask", MaskCallback,
-                      p_filter );
      p_sys->p_mask = NULL;
      if( psz_string && *psz_string )
      {
      }
      free( psz_string );
  
+     vlc_mutex_init( &p_sys->mask_lock );
+     psz_string =
+         var_CreateGetStringCommand( p_filter, CFG_PREFIX "mask" );
+     var_AddCallback( p_filter, CFG_PREFIX "mask", MaskCallback,
+                      p_filter );
      p_filter->pf_video_filter = Filter;
  
      return VLC_SUCCESS;
@@@ -177,7 -178,7 +177,7 @@@ static void LoadMask( filter_t *p_filte
      video_format_t fmt_in, fmt_out;
      memset( &fmt_in, 0, sizeof( video_format_t ) );
      memset( &fmt_out, 0, sizeof( video_format_t ) );
 -    fmt_out.i_chroma = VLC_FOURCC('Y','U','V','A');
 +    fmt_out.i_chroma = VLC_CODEC_YUVA;
      if( p_filter->p_sys->p_mask )
          picture_Release( p_filter->p_sys->p_mask );
      p_image = image_HandlerCreate( p_filter );
index 40272c57c2b15b2593f229277de69b6a503f6b41,90396c81cc447b473d6fddf74300c1a4acc1aa35..41707d1813a02e64a7c1930838aaab5181121051
@@@ -31,6 -31,7 +31,6 @@@
  
  #include <vlc_common.h>
  #include <vlc_plugin.h>
 -#include <vlc_vout.h>
  
  #include "vlc_filter.h"
  
@@@ -102,6 -103,7 +102,7 @@@ static const char *const ppsz_filter_op
  
  struct filter_sys_t
  {
+     vlc_mutex_t lock;
      int i_u, i_v, i_ut, i_vt;
      uint8_t *p_at;
  };
@@@ -111,7 -113,7 +112,7 @@@ static int Create( vlc_object_t *p_thi
      filter_t *p_filter = (filter_t *)p_this;
      filter_sys_t *p_sys;
  
 -    if( p_filter->fmt_in.video.i_chroma != VLC_FOURCC('Y','U','V','A') )
 +    if( p_filter->fmt_in.video.i_chroma != VLC_CODEC_YUVA )
      {
          msg_Err( p_filter,
                   "Unsupported input chroma \"%4s\". "
      config_ChainParse( p_filter, CFG_PREFIX, ppsz_filter_options,
                         p_filter->p_cfg );
  
+     int val;
+     vlc_mutex_init( &p_sys->lock );
  #define GET_VAR( name, min, max )                                           \
-     p_sys->i_##name = __MIN( max, __MAX( min,                               \
-         var_CreateGetIntegerCommand( p_filter, CFG_PREFIX #name ) ) );      \
+     val = var_CreateGetIntegerCommand( p_filter, CFG_PREFIX #name );        \
+     p_sys->i_##name = __MIN( max, __MAX( min, val ) );                      \
      var_AddCallback( p_filter, CFG_PREFIX #name, BluescreenCallback, p_sys );
  
      GET_VAR( u, 0x00, 0xff );
@@@ -157,6 -161,7 +160,7 @@@ static void Destroy( vlc_object_t *p_th
      var_DelCallback( p_filter, CFG_PREFIX "vt", BluescreenCallback, p_sys );
  
      free( p_sys->p_at );
+     vlc_mutex_destroy( &p_sys->lock );
      free( p_sys );
  }
  
@@@ -173,7 -178,7 +177,7 @@@ static picture_t *Filter( filter_t *p_f
      uint8_t *p_v = p_pic->p[ V_PLANE ].p_pixels;
      uint8_t umin, umax, vmin, vmax;
  
 -    if( p_pic->format.i_chroma != VLC_FOURCC('Y','U','V','A') )
 +    if( p_pic->format.i_chroma != VLC_CODEC_YUVA )
      {
          msg_Err( p_filter,
                   "Unsupported input chroma \"%4s\". "
      p_sys->p_at = realloc( p_sys->p_at, i_lines * i_pitch * sizeof( uint8_t ) );
      p_at = p_sys->p_at;
  
+     vlc_mutex_lock( &p_sys->lock );
      umin = p_sys->i_u - p_sys->i_ut >= 0x00 ? p_sys->i_u - p_sys->i_ut : 0x00;
      umax = p_sys->i_u + p_sys->i_ut <= 0xff ? p_sys->i_u + p_sys->i_ut : 0xff;
      vmin = p_sys->i_v - p_sys->i_vt >= 0x00 ? p_sys->i_v - p_sys->i_vt : 0x00;
      vmax = p_sys->i_v + p_sys->i_vt <= 0xff ? p_sys->i_v + p_sys->i_vt : 0xff;
+     vlc_mutex_unlock( &p_sys->lock );
  
      for( i = 0; i < i_lines*i_pitch; i++ )
      {
@@@ -258,23 -265,17 +264,17 @@@ static int BluescreenCallback( vlc_obje
      VLC_UNUSED(p_this); VLC_UNUSED(oldval);
      filter_sys_t *p_sys = (filter_sys_t *) p_data;
  
+     vlc_mutex_lock( &p_sys->lock );
  #define VAR_IS( a ) !strcmp( psz_var, CFG_PREFIX a )
      if( VAR_IS( "u" ) )
-     {
          p_sys->i_u = __MAX( 0, __MIN( 255, newval.i_int ) );
-     }
      else if( VAR_IS( "v" ) )
-     {
          p_sys->i_v = __MAX( 0, __MIN( 255, newval.i_int ) );
-     }
      else if( VAR_IS( "ut" ) )
-     {
          p_sys->i_ut = __MAX( 0, __MIN( 255, newval.i_int ) );
-     }
      else if( VAR_IS( "vt" ) )
-     {
          p_sys->i_vt = __MAX( 0, __MIN( 255, newval.i_int ) );
-     }
+     vlc_mutex_unlock( &p_sys->lock );
  
      return VLC_SUCCESS;
  }
index e27a77121a288a4ccff52d7152abd1c5c4834e2b,b7a63ad4ea7851980b761ca021fe07f9f7eef177..286ce642c80ea03a7d3d1d72fc5c0f232d1847db
@@@ -145,6 -145,7 +145,7 @@@ vlc_module_end (
   *****************************************************************************/
  struct vout_sys_t
  {
+     vlc_mutex_t lock;
      vout_thread_t *p_vout;
  
      unsigned int i_x, i_y;
@@@ -228,10 -229,7 +229,7 @@@ static int Init( vout_thread_t *p_vout 
                      config_GetInt( p_vout, "autocrop-non-black-pixels" );
      p_vout->p_sys->i_diff = config_GetInt( p_vout, "autocrop-diff" );
      p_vout->p_sys->i_time = config_GetInt( p_vout, "autocrop-time" );
-     vlc_value_t val={0};
-     var_Get( p_vout, "ratio-crop", &val );
-     val.psz_string = "0";
-     var_SetString( p_vout, "ratio-crop", val.psz_string);
+     var_SetString( p_vout, "ratio-crop", "0" );
  
      if (p_vout->p_sys->b_autocrop)
          p_vout->p_sys->i_ratio = 0;
      }
  
  #ifdef BEST_AUTOCROP
+     vlc_mutex_init( &p_vout->p_sys->lock );
      var_AddCallback( p_vout, "ratio-crop", FilterCallback, NULL );
  #endif
  
@@@ -403,6 -402,8 +402,8 @@@ static void End( vout_thread_t *p_vout 
      }
  
      vout_filter_ReleaseDirectBuffers( p_vout );
+     var_DelCallback( p_vout, "ratio-crop", FilterCallback, NULL );
+     vlc_mutex_destroy( &p_sys->lock );
  }
  
  /*****************************************************************************
@@@ -435,6 -436,7 +436,7 @@@ static int Manage( vout_thread_t *p_vou
      memset( &fmt, 0, sizeof(video_format_t) );
  
  #ifdef BEST_AUTOCROP
+     /* XXX: not thread-safe with FilterCallback */
      msg_Dbg( p_vout, "cropping at %ix%i+%i+%i, %sautocropping",
                       p_vout->p_sys->i_width, p_vout->p_sys->i_height,
                       p_vout->p_sys->i_x, p_vout->p_sys->i_y,
      vout_filter_AddChild( p_vout, p_vout->p_sys->p_vout, MouseEvent );
  
      p_vout->p_sys->b_changed = false;
+     vlc_mutex_lock( &p_vout->p_sys->lock );
      p_vout->p_sys->i_lastchange = 0;
+     vlc_mutex_unlock( &p_vout->p_sys->lock );
  
      return VLC_SUCCESS;
  }
@@@ -535,10 -539,10 +539,10 @@@ static void Render( vout_thread_t *p_vo
      vout_DisplayPicture( p_vout->p_sys->p_vout, p_outpic );
  
      /* The source image may still be in the cache ... parse it! */
+     vlc_mutex_lock( &p_vout->p_sys->lock );
      if( p_vout->p_sys->b_autocrop )
-     {
          UpdateStats( p_vout, p_pic );
-     }
+     vlc_mutex_unlock( &p_vout->p_sys->lock );
  }
  
  #ifdef BEST_AUTOCROP
@@@ -554,13 -558,15 +558,13 @@@ static bool NonBlackLine(uint8_t *p_in
      switch(i_chroma)
      {
      // planar YUV
 -        case VLC_FOURCC('I','4','4','4'):
 -        case VLC_FOURCC('I','4','2','2'):
 -        case VLC_FOURCC('I','4','2','0'):
 -        case VLC_FOURCC('Y','V','1','2'):
 -        case VLC_FOURCC('I','Y','U','V'):
 -        case VLC_FOURCC('I','4','1','1'):
 -        case VLC_FOURCC('I','4','1','0'):
 -        case VLC_FOURCC('Y','V','U','9'):
 -        case VLC_FOURCC('Y','U','V','A'):
 +        case VLC_CODEC_I444:
 +        case VLC_CODEC_I422:
 +        case VLC_CODEC_I420:
 +        case VLC_CODEC_YV12:
 +        case VLC_CODEC_I411:
 +        case VLC_CODEC_I410:
 +        case VLC_CODEC_YUVA:
              i_skipCount = (i_pitch * i_skipCountPercent) / 100;
              for (i_index = i_col/2 + i_skipCount/2;
                   i_index <= i_visible_pitch/2 + i_col/2 - i_skipCount/2;
              }
              break;
      // packed RGB
 -        case VLC_FOURCC('R','G','B','2'):    // packed by 1
 +        case VLC_CODEC_RGB8:    // packed by 1
              i_skipCount = (i_pitch * i_skipCountPercent) / 100;
              for (i_index = i_col/2 + i_skipCount/2;
                   i_index <= i_visible_pitch/2 + i_col/2 - i_skipCount/2;
              if (i_count > i_nonBlackPixel) break;
              }
              break;
 -        case VLC_FOURCC('R','V','1','5'):    // packed by 2
 -        case VLC_FOURCC('R','V','1','6'):    // packed by 2
 +        case VLC_CODEC_RGB15:    // packed by 2
 +        case VLC_CODEC_RGB16:    // packed by 2
              i_skipCount = (i_pitch * i_skipCountPercent) / 100;
              for (i_index = i_col/2 + i_skipCount/2 -
                                  (i_col/2 + i_skipCount/2) % 2;
              if (i_count > i_nonBlackPixel) break;
              }
              break;
 -        case VLC_FOURCC('R','V','2','4'):    // packed by 3
 +        case VLC_CODEC_RGB24:    // packed by 3
              i_skipCount = (i_pitch * i_skipCountPercent) / 100;
              for (i_index = i_col/2 + i_skipCount/2 - (i_col/2 + i_skipCount/2) % 3; i_index <= i_visible_pitch/2 + i_col/2 - i_skipCount/2; i_index+=3)
              {
              if (i_count > i_nonBlackPixel) break;
              }
              break;
 -        case VLC_FOURCC('R','V','3','2'):    // packed by 4
 +        case VLC_CODEC_RGB32:    // packed by 4
              i_skipCount = (i_pitch * i_skipCountPercent) / 100;
              for (i_index = i_col/2 + i_skipCount/2 - (i_col/2 + i_skipCount/2) % 4; i_index <= i_visible_pitch/2 + i_col/2 - i_skipCount/2; i_index+=4)
              {
              }
              break;
      // packed YUV
 -        case VLC_FOURCC('Y','U','Y','2'):    // packed by 2
 -        case VLC_FOURCC('Y','U','N','V'):    // packed by 2
 -        case VLC_FOURCC('U','Y','V','Y'):    // packed by 2
 -        case VLC_FOURCC('U','Y','N','V'):    // packed by 2
 -        case VLC_FOURCC('Y','4','2','2'):    // packed by 2
 +        case VLC_CODEC_YUYV:    // packed by 2
 +        case VLC_CODEC_UYVY:    // packed by 2
              i_skipCount = (i_pitch * i_skipCountPercent) / 100;
              for (i_index = (i_col/2 + i_skipCount/2) -
                             (i_col/2 + i_skipCount/2) % 2;
@@@ -731,7 -740,7 +735,7 @@@ static void UpdateStats( vout_thread_t 
      /* Determine where black borders are */
      switch( p_vout->output.i_chroma )
      {
 -    case VLC_FOURCC('I','4','2','0'):
 +    case VLC_CODEC_I420:
          /* XXX: Do not laugh ! I know this is very naive. But it's just a
           *      proof of concept code snippet... */
          for( i = i_lines ; i-- ; )
@@@ -846,6 -855,7 +850,7 @@@ static int FilterCallback( vlc_object_
  
      if( !strcmp( psz_var, "ratio-crop" ) )
      {
+         vlc_mutex_lock( &p_vout->p_sys->lock );
          if ( !strcmp( newval.psz_string, "Auto" ) )
              p_vout->p_sys->i_ratio = 0;
          else
              if (p_vout->p_sys->i_ratio < p_vout->output.i_aspect / 432)
                  p_vout->p_sys->i_ratio = p_vout->output.i_aspect / 432;
          }
+         vlc_mutex_unlock( &p_vout->p_sys->lock );
       }
      return VLC_SUCCESS;
  }
index c43483ad37c979f8a2a75d12ae1ce03f85e649ac,b501c869fbd46e424f1b3004158f6157af6550af..2305009f93868deca2f9e50b72cec12b808c328a
@@@ -32,6 -32,7 +32,6 @@@
  #include <vlc_common.h>
  #include <vlc_plugin.h>
  #include <vlc_sout.h>
 -#include <vlc_vout.h>
  #include "vlc_image.h"
  
  #include "vlc_filter.h"
@@@ -99,7 -100,7 +99,7 @@@ static void LoadMask( filter_t *p_filte
      picture_t *p_old_mask = p_filter->p_sys->p_mask;
      memset( &fmt_in, 0, sizeof( video_format_t ) );
      memset( &fmt_out, 0, sizeof( video_format_t ) );
 -    fmt_out.i_chroma = VLC_FOURCC('Y','U','V','A');
 +    fmt_out.i_chroma = VLC_CODEC_YUVA;
      p_image = image_HandlerCreate( p_filter );
      p_filter->p_sys->p_mask =
          image_ReadUrl( p_image, psz_filename, &fmt_in, &fmt_out );
@@@ -127,12 -128,13 +127,12 @@@ static int Create( vlc_object_t *p_thi
  
      switch( p_filter->fmt_in.video.i_chroma )
      {
 -        case VLC_FOURCC('I','4','2','0'):
 -        case VLC_FOURCC('I','Y','U','V'):
 -        case VLC_FOURCC('J','4','2','0'):
 -        case VLC_FOURCC('Y','V','1','2'):
 +        case VLC_CODEC_I420:
 +        case VLC_CODEC_J420:
 +        case VLC_CODEC_YV12:
  
 -        case VLC_FOURCC('I','4','2','2'):
 -        case VLC_FOURCC('J','4','2','2'):
 +        case VLC_CODEC_I422:
 +        case VLC_CODEC_J422:
              break;
  
          default:
      p_sys->i_x = var_CreateGetIntegerCommand( p_filter, CFG_PREFIX "x" );
      p_sys->i_y = var_CreateGetIntegerCommand( p_filter, CFG_PREFIX "y" );
  
+     vlc_mutex_init( &p_sys->lock );
      var_AddCallback( p_filter, CFG_PREFIX "x", EraseCallback, p_sys );
      var_AddCallback( p_filter, CFG_PREFIX "y", EraseCallback, p_sys );
      var_AddCallback( p_filter, CFG_PREFIX "mask", EraseCallback, p_sys );
  
-     vlc_mutex_init( &p_sys->lock );
      return VLC_SUCCESS;
  }
  
@@@ -186,6 -187,9 +185,9 @@@ static void Destroy( vlc_object_t *p_th
      if( p_sys->p_mask )
          picture_Release( p_sys->p_mask );
  
+     var_DelCallback( p_filter, CFG_PREFIX "x", EraseCallback, p_sys );
+     var_DelCallback( p_filter, CFG_PREFIX "y", EraseCallback, p_sys );
+     var_DelCallback( p_filter, CFG_PREFIX "mask", EraseCallback, p_sys );
      vlc_mutex_destroy( &p_sys->lock );
  
      free( p_filter->p_sys );
@@@ -221,13 -225,12 +223,12 @@@ static void FilterErase( filter_t *p_fi
  {
      filter_sys_t *p_sys = p_filter->p_sys;
  
-     int i_plane;
+     vlc_mutex_lock( &p_sys->lock );
      const int i_mask_pitch = p_sys->p_mask->A_PITCH;
      const int i_mask_visible_pitch = p_sys->p_mask->p[A_PLANE].i_visible_pitch;
      const int i_mask_visible_lines = p_sys->p_mask->p[A_PLANE].i_visible_lines;
  
-     for( i_plane = 0; i_plane < p_inpic->i_planes; i_plane++ )
+     for( int i_plane = 0; i_plane < p_inpic->i_planes; i_plane++ )
      {
          const int i_pitch = p_inpic->p[i_plane].i_pitch;
          const int i_2pitch = i_pitch<<1;
          uint8_t *p_inpix = p_inpic->p[i_plane].p_pixels;
          uint8_t *p_outpix = p_outpic->p[i_plane].p_pixels;
          uint8_t *p_mask = p_sys->p_mask->A_PIXELS;
+         int i_x = p_sys->i_x, i_y = p_sys->i_y;
  
-         int i_x = p_sys->i_x,
-             i_y = p_sys->i_y;
          int x, y;
          int i_height = i_mask_visible_lines;
          int i_width  = i_mask_visible_pitch;
  
          const bool b_line_factor = ( i_plane /* U_PLANE or V_PLANE */ &&
 -            !( p_inpic->format.i_chroma == VLC_FOURCC('I','4','2','2')
 -            || p_inpic->format.i_chroma == VLC_FOURCC('J','4','2','2') ) );
 +            !( p_inpic->format.i_chroma == VLC_CODEC_I422
 +            || p_inpic->format.i_chroma == VLC_CODEC_J422 ) );
  
          if( i_plane ) /* U_PLANE or V_PLANE */
          {
              }
          }
      }
+     vlc_mutex_unlock( &p_sys->lock );
  }
  
  static int EraseCallback( vlc_object_t *p_this, char const *psz_var,
index 3364d4dc82ff1d144ad0d4bde61cc36075bf9652,c061884ac2cf26ad6ec8934c408492e04fe0e0c0..11551f7a82efac4d46a4e71cbb8f774ca9fc389b
@@@ -31,6 -31,7 +31,6 @@@
  
  #include <vlc_common.h>
  #include <vlc_plugin.h>
 -#include <vlc_vout.h>
  
  #include "vlc_filter.h"
  #include "filter_picture.h"
@@@ -92,8 -93,9 +92,9 @@@ static const char *const ppsz_filter_op
  enum { RED=0xFF0000, GREEN=0x00FF00, BLUE=0x0000FF };
  struct filter_sys_t
  {
-     int i_color;
+     vlc_mutex_t lock;
      int *projection_matrix;
+     uint32_t i_color;
  };
  
  /*****************************************************************************
@@@ -105,12 -107,13 +106,12 @@@ static int Create( vlc_object_t *p_thi
  
      switch( p_filter->fmt_in.video.i_chroma )
      {
 -        case VLC_FOURCC('I','4','2','0'):
 -        case VLC_FOURCC('I','Y','U','V'):
 -        case VLC_FOURCC('J','4','2','0'):
 -        case VLC_FOURCC('Y','V','1','2'):
 +        case VLC_CODEC_I420:
 +        case VLC_CODEC_J420:
 +        case VLC_CODEC_YV12:
  
 -        case VLC_FOURCC('I','4','2','2'):
 -        case VLC_FOURCC('J','4','2','2'):
 +        case VLC_CODEC_I422:
 +        case VLC_CODEC_J422:
  
          CASE_PACKED_YUV_422
              break;
  
      p_filter->p_sys->i_color = var_CreateGetIntegerCommand( p_filter,
                                                 FILTER_PREFIX "component" );
-     var_AddCallback( p_filter, FILTER_PREFIX "component",
-                      ExtractCallback, p_filter->p_sys );
      /* Matrix won't be used for RED, GREEN or BLUE in planar formats */
      make_projection_matrix( p_filter, p_filter->p_sys->i_color,
                              p_filter->p_sys->projection_matrix );
+     vlc_mutex_init( &p_filter->p_sys->lock );
+     var_AddCallback( p_filter, FILTER_PREFIX "component",
+                      ExtractCallback, p_filter->p_sys );
  
      p_filter->pf_video_filter = Filter;
  
  static void Destroy( vlc_object_t *p_this )
  {
      filter_t *p_filter = (filter_t *)p_this;
+     filter_sys_t *p_sys = p_filter->p_sys;
  
-     free( p_filter->p_sys->projection_matrix );
-     free( p_filter->p_sys );
+     var_DelCallback( p_filter, FILTER_PREFIX "component", ExtractCallback,
+                      p_sys );
+     vlc_mutex_destroy( &p_sys->lock );
+     free( p_sys->projection_matrix );
+     free( p_sys );
  }
  
  /*****************************************************************************
  static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
  {
      picture_t *p_outpic;
+     filter_sys_t *p_sys = p_filter->p_sys;
  
      if( !p_pic ) return NULL;
  
          return NULL;
      }
  
+     vlc_mutex_lock( &p_sys->lock );
      switch( p_pic->format.i_chroma )
      {
 -        case VLC_FOURCC('I','4','2','0'):
 -        case VLC_FOURCC('I','Y','U','V'):
 -        case VLC_FOURCC('J','4','2','0'):
 -        case VLC_FOURCC('Y','V','1','2'):
 +        case VLC_CODEC_I420:
 +        case VLC_CODEC_J420:
 +        case VLC_CODEC_YV12:
-             switch( p_filter->p_sys->i_color )
+             switch( p_sys->i_color )
              {
                  case RED:
                      get_red_from_yuv420( p_pic, p_outpic,
                  default:
                      get_custom_from_yuv420( p_pic, p_outpic,
                                              Y_PLANE, U_PLANE, V_PLANE,
-                                             p_filter->p_sys->projection_matrix);
+                                             p_sys->projection_matrix);
                      break;
              }
              break;
  
 -        case VLC_FOURCC('I','4','2','2'):
 -        case VLC_FOURCC('J','4','2','2'):
 +        case VLC_CODEC_I422:
 +        case VLC_CODEC_J422:
              switch( p_filter->p_sys->i_color )
              {
                  case RED:
                  default:
                      get_custom_from_yuv422( p_pic, p_outpic,
                                              Y_PLANE, U_PLANE, V_PLANE,
-                                             p_filter->p_sys->projection_matrix);
+                                             p_sys->projection_matrix);
                      break;
              }
              break;
  
          CASE_PACKED_YUV_422
              get_custom_from_packedyuv422( p_pic, p_outpic,
-                                           p_filter->p_sys->projection_matrix );
+                                           p_sys->projection_matrix );
              break;
  
          default:
+             vlc_mutex_unlock( &p_sys->lock );
              msg_Warn( p_filter, "Unsupported input chroma (%4s)",
                        (char*)&(p_pic->format.i_chroma) );
              picture_Release( p_pic );
              return NULL;
      }
+     vlc_mutex_unlock( &p_sys->lock );
  
      return CopyInfoAndRelease( p_outpic, p_pic );
  }
@@@ -757,6 -769,7 +766,7 @@@ static int ExtractCallback( vlc_object_
      VLC_UNUSED(oldval);
      filter_sys_t *p_sys = (filter_sys_t *)p_data;
  
+     vlc_mutex_lock( &p_sys->lock );
      if( !strcmp( psz_var, FILTER_PREFIX "component" ) )
      {
          p_sys->i_color = newval.i_int;
      {
          msg_Warn( p_this, "Unknown callback command." );
      }
+     vlc_mutex_unlock( &p_sys->lock );
      return VLC_SUCCESS;
  }
index a42d0b897917c7f0fdbe27d1214e4e9cbdcb1ced,948cb4a04d318256b720203ed6ea0e8b54698f02..fd3baa0551a1d22e23f12d2d13212e983fc1ff86
@@@ -35,6 -35,7 +35,6 @@@
  #include <vlc_common.h>
  #include <vlc_plugin.h>
  #include <vlc_sout.h>
 -#include <vlc_vout.h>
  
  #include "vlc_filter.h"
  #include "filter_picture.h"
@@@ -107,6 -108,7 +107,7 @@@ static const char *const ppsz_filter_op
   *****************************************************************************/
  struct filter_sys_t
  {
+     vlc_mutex_t lock;
      int i_mode;
  
      /* For the gradient mode */
@@@ -188,6 -190,7 +189,7 @@@ static int Create( vlc_object_t *p_thi
      p_filter->p_sys->b_cartoon =
          var_CreateGetBoolCommand( p_filter, FILTER_PREFIX "cartoon" );
  
+     vlc_mutex_init( &p_filter->p_sys->lock );
      var_AddCallback( p_filter, FILTER_PREFIX "mode",
                       GradientCallback, p_filter->p_sys );
      var_AddCallback( p_filter, FILTER_PREFIX "type",
  static void Destroy( vlc_object_t *p_this )
  {
      filter_t *p_filter = (filter_t *)p_this;
-     free( p_filter->p_sys->p_buf32 );
-     free( p_filter->p_sys->p_buf32_bis );
-     free( p_filter->p_sys->p_buf8 );
-     free( p_filter->p_sys->p_pre_hough );
-     free( p_filter->p_sys );
+     filter_sys_t *p_sys = p_filter->p_sys;
+     var_DelCallback( p_filter, FILTER_PREFIX "mode",
+                      GradientCallback, p_sys );
+     var_DelCallback( p_filter, FILTER_PREFIX "type",
+                      GradientCallback, p_sys );
+     var_DelCallback( p_filter, FILTER_PREFIX "cartoon",
+                      GradientCallback, p_sys );
+     vlc_mutex_destroy( &p_sys->lock );
+     free( p_sys->p_buf32 );
+     free( p_sys->p_buf32_bis );
+     free( p_sys->p_buf8 );
+     free( p_sys->p_pre_hough );
+     free( p_sys );
  }
  
  /*****************************************************************************
@@@ -239,6 -251,7 +250,7 @@@ static picture_t *Filter( filter_t *p_f
          return NULL;
      }
  
+     vlc_mutex_lock( &p_filter->p_sys->lock );
      switch( p_filter->p_sys->i_mode )
      {
          case EDGE:
          default:
              break;
      }
+     vlc_mutex_unlock( &p_filter->p_sys->lock );
  
      return CopyInfoAndRelease( p_outpic, p_pic );
  }
@@@ -756,6 -770,8 +769,8 @@@ static int GradientCallback( vlc_object
  {
      VLC_UNUSED(oldval);
      filter_sys_t *p_sys = (filter_sys_t *)p_data;
+     vlc_mutex_lock( &p_sys->lock );
      if( !strcmp( psz_var, FILTER_PREFIX "mode" ) )
      {
          if( !strcmp( newval.psz_string, "gradient" ) )
      {
          p_sys->b_cartoon = newval.b_bool;
      }
+     vlc_mutex_unlock( &p_sys->lock );
      return VLC_SUCCESS;
  }
index 5613a9bc023783f78c3a1a322c16ba3b9a4a012f,bdc988d3b8f96adbf92ee45cdbf49f56994d5838..f57056b5f6e788a5d748fe3287fa28fc57bc9251
@@@ -179,7 -179,7 +179,7 @@@ static picture_t *LoadImage( vlc_object
      memset( &fmt_in, 0, sizeof(video_format_t) );
      memset( &fmt_out, 0, sizeof(video_format_t) );
  
 -    fmt_out.i_chroma = VLC_FOURCC('Y','U','V','A');
 +    fmt_out.i_chroma = VLC_CODEC_YUVA;
      p_image = image_HandlerCreate( p_this );
      p_pic = image_ReadUrl( p_image, psz_filename, &fmt_in, &fmt_out );
      image_HandlerDelete( p_image );
@@@ -346,11 -346,12 +346,12 @@@ static int Create( vlc_object_t *p_thi
      p_sys->pos = var_CreateGetIntegerCommand( p_vout, "logo-position" );
      p_sys->posx = var_CreateGetIntegerCommand( p_vout, "logo-x" );
      p_sys->posy = var_CreateGetIntegerCommand( p_vout, "logo-y" );
-     p_logo_list->i_delay = __MAX( __MIN(
-         var_CreateGetIntegerCommand( p_vout, "logo-delay" ) , 60000 ), 0 );
+     p_logo_list->i_delay = var_CreateGetIntegerCommand( p_vout, "logo-delay" );
+     p_logo_list->i_delay = __MAX( __MIN( p_logo_list->i_delay, 60000 ), 0 );
      p_logo_list->i_repeat = var_CreateGetIntegerCommand( p_vout, "logo-repeat");
-     p_logo_list->i_alpha = __MAX( __MIN(
-         var_CreateGetIntegerCommand( p_vout, "logo-transparency" ), 255 ), 0 );
+     p_logo_list->i_alpha = var_CreateGetIntegerCommand( p_vout,
+                                                         "logo-transparency" );
+     p_logo_list->i_alpha = __MAX( __MIN( p_logo_list->i_alpha, 255 ), 0 );
  
      LoadLogoList( p_vout, p_logo_list );
  
@@@ -392,7 -393,7 +393,7 @@@ static int Init( vout_thread_t *p_vout 
          p_sys->p_blend->fmt_in.video.i_y_offset = 0;
      p_sys->p_blend->fmt_out.video.i_aspect = p_vout->render.i_aspect;
      p_sys->p_blend->fmt_out.video.i_chroma = p_vout->output.i_chroma;
 -    p_sys->p_blend->fmt_in.video.i_chroma = VLC_FOURCC('Y','U','V','A');
 +    p_sys->p_blend->fmt_in.video.i_chroma = VLC_CODEC_YUVA;
      p_sys->p_blend->fmt_in.video.i_aspect = VOUT_ASPECT_FACTOR;
      p_sys->i_width =
          p_sys->p_blend->fmt_in.video.i_width =
@@@ -695,13 -696,17 +696,17 @@@ static int CreateFilter( vlc_object_t *
      p_sys->posx = var_CreateGetIntegerCommand( p_filter, "logo-x" );
      p_sys->posy = var_CreateGetIntegerCommand( p_filter, "logo-y" );
      p_sys->pos = var_CreateGetIntegerCommand( p_filter, "logo-position" );
-     p_logo_list->i_alpha = __MAX( __MIN( var_CreateGetIntegerCommand(
-                            p_filter, "logo-transparency"), 255 ), 0 );
+     p_logo_list->i_alpha = var_CreateGetIntegerCommand( p_filter,
+                                                         "logo-transparency");
+     p_logo_list->i_alpha = __MAX( __MIN( p_logo_list->i_alpha, 255 ), 0 );
      p_logo_list->i_delay =
          var_CreateGetIntegerCommand( p_filter, "logo-delay" );
      p_logo_list->i_repeat =
          var_CreateGetIntegerCommand( p_filter, "logo-repeat" );
  
+     vlc_mutex_init( &p_logo_list->lock );
+     LoadLogoList( p_this, p_logo_list );
      var_AddCallback( p_filter, "logo-file", LogoCallback, p_sys );
      var_AddCallback( p_filter, "logo-x", LogoCallback, p_sys );
      var_AddCallback( p_filter, "logo-y", LogoCallback, p_sys );
      var_AddCallback( p_filter, "logo-transparency", LogoCallback, p_sys );
      var_AddCallback( p_filter, "logo-repeat", LogoCallback, p_sys );
  
-     vlc_mutex_init( &p_logo_list->lock );
-     vlc_mutex_lock( &p_logo_list->lock );
-     LoadLogoList( p_this, p_logo_list );
-     vlc_mutex_unlock( &p_logo_list->lock );
      /* Misc init */
      p_filter->pf_sub_filter = Filter;
      p_sys->b_need_update = true;
@@@ -821,7 -819,7 +819,7 @@@ static subpicture_t *Filter( filter_t *
  
      /* Create new SPU region */
      memset( &fmt, 0, sizeof(video_format_t) );
 -    fmt.i_chroma = VLC_FOURCC('Y','U','V','A');
 +    fmt.i_chroma = VLC_CODEC_YUVA;
      fmt.i_aspect = VOUT_ASPECT_FACTOR;
      fmt.i_sar_num = fmt.i_sar_den = 1;
      fmt.i_width = fmt.i_visible_width = p_pic->p[Y_PLANE].i_visible_pitch;
index 56299b785e61b2d1538dc6b7f2c83819e88d1869,ce627d124410fad85571c6e84cc2e97097ad3173..f993907d4d1445ea9ee7847d10ac268484ec449f
@@@ -33,6 -33,7 +33,6 @@@
  
  #include <vlc_common.h>
  #include <vlc_plugin.h>
 -#include <vlc_vout.h>
  
  #include "vlc_filter.h"
  #include "vlc_block.h"
@@@ -203,32 -204,36 +203,35 @@@ static int CreateFilter( vlc_object_t *
          return VLC_ENOMEM;
  
      vlc_mutex_init( &p_sys->lock );
 -    p_sys->p_style = malloc( sizeof( text_style_t ) );
 -    memcpy( p_sys->p_style, &default_text_style, sizeof( text_style_t ) );
 +    p_sys->p_style = text_style_New();
  
      config_ChainParse( p_filter, CFG_PREFIX, ppsz_filter_options,
                         p_filter->p_cfg );
  
  #define CREATE_VAR( stor, type, var ) \
      p_sys->stor = var_CreateGet##type##Command( p_filter, var ); \
      var_AddCallback( p_filter, var, MarqueeCallback, p_sys );
  
+     p_sys->b_need_update = true;
      CREATE_VAR( i_xoff, Integer, "marq-x" );
      CREATE_VAR( i_yoff, Integer, "marq-y" );
      CREATE_VAR( i_timeout,Integer, "marq-timeout" );
-     CREATE_VAR( i_refresh,Integer, "marq-refresh" );
-     p_sys->i_refresh *= 1000;
+     p_sys->i_refresh = 1000 * var_CreateGetIntegerCommand( p_filter,
+                                                            "marq-refresh" );
+     var_AddCallback( p_filter, "marq-refresh", MarqueeCallback, p_sys );
      CREATE_VAR( i_pos, Integer, "marq-position" );
      CREATE_VAR( psz_marquee, String, "marq-marquee" );
      CREATE_VAR( p_style->i_font_alpha, Integer, "marq-opacity" );
+     p_sys->p_style->i_font_alpha =
+          255 - var_CreateGetIntegerCommand( p_filter, "marq-opacity" );
+     var_AddCallback( p_filter, "marq-opacity", MarqueeCallback, p_sys );
      CREATE_VAR( p_style->i_font_color, Integer, "marq-color" );
      CREATE_VAR( p_style->i_font_size, Integer, "marq-size" );
  
-     p_sys->p_style->i_font_alpha = 255 - p_sys->p_style->i_font_alpha ;
      /* Misc init */
      p_filter->pf_sub_filter = Filter;
      p_sys->last_time = 0;
-     p_sys->b_need_update = true;
  
      return VLC_SUCCESS;
  }
@@@ -240,9 -245,6 +243,6 @@@ static void DestroyFilter( vlc_object_
      filter_t *p_filter = (filter_t *)p_this;
      filter_sys_t *p_sys = p_filter->p_sys;
  
-     text_style_Delete( p_sys->p_style );
-     free( p_sys->psz_marquee );
      /* Delete the marquee variables */
  #define DEL_VAR(var) \
      var_DelCallback( p_filter, var, MarqueeCallback, p_sys ); \
      DEL_VAR( "marq-size" );
  
      vlc_mutex_destroy( &p_sys->lock );
 -    free( p_sys->p_style );
++    text_style_Delete( p_sys->p_style );
+     free( p_sys->psz_marquee );
      free( p_sys );
  }
  
@@@ -282,7 -286,7 +284,7 @@@ static subpicture_t *Filter( filter_t *
          goto out;
  
      memset( &fmt, 0, sizeof(video_format_t) );
 -    fmt.i_chroma = VLC_FOURCC('T','E','X','T');
 +    fmt.i_chroma = VLC_CODEC_TEXT;
      fmt.i_aspect = 0;
      fmt.i_width = fmt.i_height = 0;
      fmt.i_x_offset = 0;
      p_spu->p_region->i_x = p_sys->i_xoff;
      p_spu->p_region->i_y = p_sys->i_yoff;
  
 -    p_spu->p_region->p_style = p_sys->p_style;
 +    p_spu->p_region->p_style = text_style_Duplicate( p_sys->p_style );
  
  out:
      vlc_mutex_unlock( &p_sys->lock );
index 5f7d97bccc161c8b05964a3fc8e51cac1e2282a7,a8d60f0c5a13191c08b96cd2d6b9ebf44d5df7a0..d9488f9807ce4c16e09f9e681151a57793fcc3bf
@@@ -31,6 -31,7 +31,6 @@@
  
  #include <vlc_common.h>
  #include <vlc_plugin.h>
 -#include <vlc_vout.h>
  
  #include <math.h>
  #include <limits.h> /* INT_MAX */
@@@ -321,7 -322,7 +321,7 @@@ static int CreateFilter( vlc_object_t *
  
      GET_VAR( align, 0, 10 );
      if( p_sys->i_align == 3 || p_sys->i_align == 7 )
-         p_sys->i_align = 5;
+         p_sys->i_align = 5; /* FIXME: NOT THREAD SAFE w.r.t. callback */
  
      GET_VAR( borderw, 0, INT_MAX );
      GET_VAR( borderh, 0, INT_MAX );
      GET_VAR( position, 0, 2 );
      GET_VAR( delay, 100, INT_MAX );
  #undef GET_VAR
-     p_sys->i_delay *= 1000;
+     p_sys->i_delay *= 1000; /* FIXME: NOT THREAD SAFE w.r.t. callback */
  
      p_sys->b_ar = var_CreateGetBoolCommand( p_filter,
                                              CFG_PREFIX "keep-aspect-ratio" );
@@@ -391,9 -392,8 +391,8 @@@ static void DestroyFilter( vlc_object_
  {
      filter_t *p_filter = (filter_t*)p_this;
      filter_sys_t *p_sys = p_filter->p_sys;
-     int i_index;
  
-     vlc_mutex_lock( &p_sys->lock );
+     /* FIXME: destroy callbacks first! */
  
      if( !p_sys->b_keep )
      {
  
      if( p_sys->i_order_length )
      {
-         for( i_index = 0; i_index < p_sys->i_order_length; i_index++ )
+         for( int i_index = 0; i_index < p_sys->i_order_length; i_index++ )
          {
              free( p_sys->ppsz_order[i_index] );
          }
          p_sys->i_offsets_length = 0;
      }
  
-     vlc_mutex_unlock( &p_sys->lock );
      vlc_mutex_destroy( &p_sys->lock );
      free( p_sys );
  }
@@@ -597,11 -596,11 +595,11 @@@ static subpicture_t *Filter( filter_t *
              fmt_in.i_height = p_es->p_picture->format.i_height;
              fmt_in.i_width = p_es->p_picture->format.i_width;
  
 -            if( fmt_in.i_chroma == VLC_FOURCC('Y','U','V','A') ||
 -                fmt_in.i_chroma == VLC_FOURCC('R','G','B','A') )
 -                fmt_out.i_chroma = VLC_FOURCC('Y','U','V','A');
 +            if( fmt_in.i_chroma == VLC_CODEC_YUVA ||
 +                fmt_in.i_chroma == VLC_CODEC_RGBA )
 +                fmt_out.i_chroma = VLC_CODEC_YUVA;
              else
 -                fmt_out.i_chroma = VLC_FOURCC('I','4','2','0');
 +                fmt_out.i_chroma = VLC_CODEC_I420;
              fmt_out.i_width = col_inner_width;
              fmt_out.i_height = row_inner_height;
  
index b17238d26bc7eea4c89daaca6d843a0b68a554d7,e975efcfb581cc97b13c72cddc872b27a72cbe1c..f5e43403136146a938f2e63507ff084cb9b3dc26
@@@ -33,6 -33,7 +33,6 @@@
  #include <vlc_common.h>
  #include <vlc_plugin.h>
  #include <vlc_sout.h>
 -#include <vlc_vout.h>
  #include <vlc_filter.h>
  #include "filter_picture.h"
  
@@@ -79,6 -80,7 +79,7 @@@ static const char *const ppsz_filter_op
   *****************************************************************************/
  struct filter_sys_t
  {
+     vlc_spinlock_t lock;
      int        i_factor;
  
      uint8_t  **pp_planes;
@@@ -104,6 -106,7 +105,7 @@@ static int Create( vlc_object_t *p_thi
  
      p_filter->p_sys->i_factor =
          var_CreateGetIntegerCommand( p_filter, FILTER_PREFIX "factor" );
+     vlc_spin_init( &p_filter->p_sys->lock );
      var_AddCallback( p_filter, FILTER_PREFIX "factor",
                       MotionBlurCallback, p_filter->p_sys );
  
@@@ -120,6 -123,10 +122,10 @@@ static void Destroy( vlc_object_t *p_th
  {
      filter_t *p_filter = (filter_t *)p_this;
  
+     var_DelCallback( p_filter, FILTER_PREFIX "factor",
+                      MotionBlurCallback, p_filter->p_sys );
+     vlc_spin_destroy( &p_filter->p_sys->lock );
      while( p_filter->p_sys->i_planes-- )
          free( p_filter->p_sys->pp_planes[p_filter->p_sys->i_planes] );
      free( p_filter->p_sys->pp_planes );
@@@ -219,7 -226,12 +225,12 @@@ static int MotionBlurCallback( vlc_obje
  {
      VLC_UNUSED(p_this); VLC_UNUSED(oldval);
      filter_sys_t *p_sys = (filter_sys_t *)p_data;
      if( !strcmp( psz_var, FILTER_PREFIX "factor" ) )
+     {
+         vlc_spin_lock( &p_sys->lock );
          p_sys->i_factor = __MIN( 127, __MAX( 1, newval.i_int ) );
+         vlc_spin_unlock( &p_sys->lock );
+     }
      return VLC_SUCCESS;
  }
index 25e5f3b8e725fed64285e2e5808e51d31c2595f4,d7f23a4eaa854292ea4ead6ebd23ee4e09eabdfd..e287f392cd6de721b3b2abfc2d6f2370bdfc9427
@@@ -218,6 -218,7 +218,7 @@@ static int CreateFilter ( vlc_object_t 
      if( p_sys->p_menu == NULL )
          goto error;
  
+     /* FIXME: this plugin is not at all thread-safe w.r.t. callbacks */
      p_sys->p_menu->i_position = p_sys->i_position;
  
      /* Check if menu position was overridden */
                          MouseEvent, p_sys );
      }
  
 -    es_format_Init( &p_filter->fmt_out, SPU_ES, VLC_FOURCC( 's','p','u',' ' ) );
 +    es_format_Init( &p_filter->fmt_out, SPU_ES, VLC_CODEC_SPU );
      p_filter->fmt_out.i_priority = 0;
  
      return VLC_SUCCESS;
@@@ -289,7 -290,7 +290,7 @@@ static void DestroyFilter( vlc_object_
      var_DelCallback( p_filter, OSD_CFG "update", OSDMenuCallback, p_sys );
      var_DelCallback( p_filter, OSD_CFG "alpha", OSDMenuCallback, p_sys );
  
-     if( p_sys )
+     if( p_sys ) /* FIXME: <-- WTF??? what about the 4 ones above? */
      {
          var_DelCallback( p_sys->p_menu, "osd-menu-update",
                           OSDMenuUpdateEvent, p_filter );
@@@ -369,7 -370,7 +370,7 @@@ static subpicture_region_t *create_text
  
      /* Create new SPU region */
      memset( &fmt, 0, sizeof(video_format_t) );
 -    fmt.i_chroma = VLC_FOURCC( 'T','E','X','T' );
 +    fmt.i_chroma = VLC_CODEC_TEXT;
      fmt.i_aspect = VOUT_ASPECT_FACTOR;
      fmt.i_sar_num = fmt.i_sar_den = 1;
      fmt.i_width = fmt.i_visible_width = i_width;
@@@ -407,13 -408,13 +408,13 @@@ static subpicture_region_t *create_pict
  
      /* Create new SPU region */
      memset( &fmt, 0, sizeof(video_format_t) );
 -    fmt.i_chroma = (p_pic == NULL) ? VLC_FOURCC('Y','U','V','P') : VLC_FOURCC('Y','U','V','A');
 +    fmt.i_chroma = (p_pic == NULL) ? VLC_CODEC_YUVP : VLC_CODEC_YUVA;
      fmt.i_aspect = VOUT_ASPECT_FACTOR;
      fmt.i_sar_num = fmt.i_sar_den = 1;
      fmt.i_width = fmt.i_visible_width = i_width;
      fmt.i_height = fmt.i_visible_height = i_height;
      fmt.i_x_offset = fmt.i_y_offset = 0;
 -    if( fmt.i_chroma == VLC_FOURCC('Y','U','V','P') )
 +    if( fmt.i_chroma == VLC_CODEC_YUVP )
      {
          fmt.p_palette = &palette;
          fmt.p_palette->i_entries = 0;
index d80a42a79df6da3e5e12792edd106388634f62c1,9d1dc57b4989ca37a7e1e5e7fdcd7a38a0c9c0b2..ee7499f6cd9252e96629d52781ee9d204ef69f2a
@@@ -29,7 -29,7 +29,7 @@@
  
  #include <vlc_common.h>
  #include <vlc_plugin.h>
 -#include <vlc_vout.h>
 +#include <vlc_filter.h>
  
  #include "filter_picture.h"
  
@@@ -140,21 -140,22 +140,21 @@@ static int OpenPostproc( vlc_object_t *
  
      switch( p_filter->fmt_in.video.i_chroma )
      {
 -        case VLC_FOURCC('I','4','4','4'):
 -        case VLC_FOURCC('J','4','4','4'):
 -        /* case VLC_FOURCC('Y','U','V','A'): FIXME Should work but alpha plane needs to be copied manually and I'm kind of feeling too lazy to write the code to do that ATM (i_pitch vs i_visible_pitch...). */
 +        case VLC_CODEC_I444:
 +        case VLC_CODEC_J444:
 +        /* case VLC_CODEC_YUVA: FIXME Should work but alpha plane needs to be copied manually and I'm kind of feeling too lazy to write the code to do that ATM (i_pitch vs i_visible_pitch...). */
              i_flags |= PP_FORMAT_444;
              break;
 -        case VLC_FOURCC('I','4','2','2'):
 -        case VLC_FOURCC('J','4','2','2'):
 +        case VLC_CODEC_I422:
 +        case VLC_CODEC_J422:
              i_flags |= PP_FORMAT_422;
              break;
 -        case VLC_FOURCC('I','4','1','1'):
 +        case VLC_CODEC_I411:
              i_flags |= PP_FORMAT_411;
              break;
 -        case VLC_FOURCC('I','4','2','0'):
 -        case VLC_FOURCC('I','Y','U','V'):
 -        case VLC_FOURCC('J','4','2','0'):
 -        case VLC_FOURCC('Y','V','1','2'):
 +        case VLC_CODEC_I420:
 +        case VLC_CODEC_J420:
 +        case VLC_CODEC_YV12:
              i_flags |= PP_FORMAT_420;
              break;
          default:
      var_AddCallback( p_filter, FILTER_PREFIX "name", PPNameCallback, NULL );
      if( val_orig.i_int )
      {
-         p_sys->pp_mode = pp_get_mode_by_name_and_quality( val.psz_string?:
+         p_sys->pp_mode = pp_get_mode_by_name_and_quality( val.psz_string ?
+                                                           val.psz_string :
                                                            "default",
                                                            val_orig.i_int );
  
                      &val, text.psz_string?&text:NULL );
      }
  
-     vlc_mutex_init( &p_sys->lock );
+     vlc_mutex_init( &p_sys->lock ); /* FIXME: too late w.r.t. callback */
  
      p_filter->pf_video_filter = PostprocPict;
      p_sys->b_had_matrix = true;
@@@ -252,6 -254,8 +253,8 @@@ static void ClosePostproc( vlc_object_
  {
      filter_t *p_filter = (filter_t *)p_this;
      filter_sys_t *p_sys = p_filter->p_sys;
+     /* FIXME: delete callbacks before mutex */
      vlc_mutex_destroy( &p_sys->lock );
      pp_free_context( p_sys->pp_context );
      if( p_sys->pp_mode ) pp_free_mode( p_sys->pp_mode );
@@@ -327,7 -331,8 +330,8 @@@ static void PPChangeMode( filter_t *p_f
      vlc_mutex_lock( &p_sys->lock );
      if( i_quality > 0 )
      {
-         pp_mode_t *pp_mode = pp_get_mode_by_name_and_quality( psz_name?:
+         pp_mode_t *pp_mode = pp_get_mode_by_name_and_quality( psz_name ?
+                                                               psz_name :
                                                                "default",
                                                                i_quality );
          if( pp_mode )
index ff058eb72b89c5826ec26fc7822605e72fae65f4,d41ea992d24206c30a487cb9f1416357b6fe003e..8a1d4342aacaea22845550781a48ee3e03c04c63
@@@ -33,6 -33,7 +33,6 @@@
  
  #include <vlc_common.h>
  #include <vlc_plugin.h>
 -#include <vlc_vout.h>
  
  #include "vlc_filter.h"
  #include "filter_picture.h"
@@@ -85,9 -86,9 +85,9 @@@ static const char *const ppsz_filter_op
   *****************************************************************************/
  struct filter_sys_t
  {
-     int     i_angle;
-     int     i_cos;
-     int     i_sin;
+     vlc_spinlock_t lock;
+     int            i_cos;
+     int            i_sin;
  };
  
  static inline void cache_trigo( int i_angle, int *i_sin, int *i_cos )
@@@ -136,15 -137,16 +136,16 @@@ static int Create( vlc_object_t *p_thi
      config_ChainParse( p_filter, FILTER_PREFIX, ppsz_filter_options,
                         p_filter->p_cfg );
  
-     p_sys->i_angle = var_CreateGetIntegerCommand( p_filter,
-                                                   FILTER_PREFIX "angle" ) * 10;
+     int i_angle = var_CreateGetIntegerCommand( p_filter,
+                                                FILTER_PREFIX "angle" ) * 10;
+     cache_trigo( i_angle, &p_sys->i_sin, &p_sys->i_cos );
      var_Create( p_filter, FILTER_PREFIX "deciangle",
                  VLC_VAR_INTEGER|VLC_VAR_ISCOMMAND );
+     vlc_spin_init( &p_sys->lock );
      var_AddCallback( p_filter, FILTER_PREFIX "angle", RotateCallback, p_sys );
      var_AddCallback( p_filter, FILTER_PREFIX "deciangle",
                       PreciseRotateCallback, p_sys );
  
-     cache_trigo( p_sys->i_angle, &p_sys->i_sin, &p_sys->i_cos );
  
      return VLC_SUCCESS;
  }
@@@ -159,7 -161,7 +160,7 @@@ static void Destroy( vlc_object_t *p_th
      var_DelCallback( p_filter, FILTER_PREFIX "angle", RotateCallback, p_filter->p_sys );
      var_DelCallback( p_filter, FILTER_PREFIX "deciangle",
                       PreciseRotateCallback, p_filter->p_sys );
+     vlc_spin_destroy( &p_filter->p_sys->lock );
      free( p_filter->p_sys );
  }
  
@@@ -170,8 -172,7 +171,7 @@@ static picture_t *Filter( filter_t *p_f
  {
      picture_t *p_outpic;
      filter_sys_t *p_sys = p_filter->p_sys;
-     int i_plane;
-     const int i_sin = p_sys->i_sin, i_cos = p_sys->i_cos;
+     int i_sin, i_cos;
  
      if( !p_pic ) return NULL;
  
          return NULL;
      }
  
-     for( i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
+     vlc_spin_lock( &p_sys->lock );
+     i_sin = p_sys->i_sin;
+     i_cos = p_sys->i_cos;
+     vlc_spin_unlock( &p_sys->lock );
+     for( int i_plane = 0 ; i_plane < p_pic->i_planes ; i_plane++ )
      {
          const int i_visible_lines = p_pic->p[i_plane].i_visible_lines;
          const int i_visible_pitch = p_pic->p[i_plane].i_visible_pitch;
@@@ -390,11 -396,9 +395,9 @@@ static int RotateCallback( vlc_object_
                             vlc_value_t oldval, vlc_value_t newval,
                             void *p_data )
  {
-     VLC_UNUSED(p_this); VLC_UNUSED(psz_var); VLC_UNUSED(oldval);
-     filter_sys_t *p_sys = (filter_sys_t *)p_data;
-     p_sys->i_angle = newval.i_int*10;
-     cache_trigo( p_sys->i_angle, &p_sys->i_sin, &p_sys->i_cos );
-     return VLC_SUCCESS;
+     oldval.i_int *= 10;
+     newval.i_int *= 10;
+     return PreciseRotateCallback( p_this, psz_var, oldval, newval, p_data );
  }
  
  static int PreciseRotateCallback( vlc_object_t *p_this, char const *psz_var,
  {
      VLC_UNUSED(p_this); VLC_UNUSED(psz_var); VLC_UNUSED(oldval);
      filter_sys_t *p_sys = (filter_sys_t *)p_data;
-     p_sys->i_angle = newval.i_int;
-     cache_trigo( p_sys->i_angle, &p_sys->i_sin, &p_sys->i_cos );
+     int i_sin, i_cos;
+     cache_trigo( newval.i_int, &i_sin, &i_cos );
+     vlc_spin_lock( &p_sys->lock );
+     p_sys->i_sin = i_sin;
+     p_sys->i_cos = i_cos;
+     vlc_spin_unlock( &p_sys->lock );
      return VLC_SUCCESS;
  }
index 1fbaea3e0f43d68e51b5762b8fc33a0b926e2e32,135f21b49ceff5558de68c10a849d636c5f49dac..d7724b4730042d0307f6bd00ac90b91f34ee4345
@@@ -39,6 -39,7 +39,6 @@@
  
  #include <vlc_common.h>
  #include <vlc_plugin.h>
 -#include <vlc_vout.h>
  
  #include "vlc_filter.h"
  #include "filter_picture.h"
@@@ -86,7 -87,7 +86,7 @@@ static const char *const ppsz_filter_op
  
  struct filter_sys_t
  {
-     float f_sigma;
+     vlc_mutex_t lock;
      int tab_precalc[512];
  };
  
@@@ -98,10 -99,8 +98,8 @@@ inline static int32_t clip( int32_t a 
      return (a > 255) ? 255 : (a < 0) ? 0 : a;
  }
  
- static void init_precalc_table(filter_sys_t *p_filter)
+ static void init_precalc_table(filter_sys_t *p_filter, float sigma)
  {
-     float sigma = p_filter->f_sigma;
      for(int i = 0; i < 512; ++i)
      {
          p_filter->tab_precalc[i] = (i - 256) * sigma;
@@@ -127,13 -126,13 +125,13 @@@ static int Create( vlc_object_t *p_thi
      config_ChainParse( p_filter, FILTER_PREFIX, ppsz_filter_options,
                     p_filter->p_cfg );
  
-     p_filter->p_sys->f_sigma =
-         var_CreateGetFloatCommand( p_filter, FILTER_PREFIX "sigma" );
+     float sigma = var_CreateGetFloatCommand( p_filter, FILTER_PREFIX "sigma" );
+     init_precalc_table(p_filter->p_sys, sigma);
+     vlc_mutex_init( &p_filter->p_sys->lock );
      var_AddCallback( p_filter, FILTER_PREFIX "sigma",
                       SharpenCallback, p_filter->p_sys );
  
-     init_precalc_table(p_filter->p_sys);
      return VLC_SUCCESS;
  }
  
  static void Destroy( vlc_object_t *p_this )
  {
      filter_t *p_filter = (filter_t *)p_this;
-     var_DelCallback( p_filter, FILTER_PREFIX "sigma",
-                      SharpenCallback, p_filter->p_sys );
-     free( p_filter->p_sys );
+     filter_sys_t *p_sys = p_filter->p_sys;
+     var_DelCallback( p_filter, FILTER_PREFIX "sigma", SharpenCallback, p_sys );
+     vlc_mutex_destroy( &p_sys->lock );
+     free( p_sys );
  }
  
  /*****************************************************************************
@@@ -184,6 -185,7 +184,7 @@@ static picture_t *Filter( filter_t *p_f
      i_src_pitch = p_pic->p[Y_PLANE].i_visible_pitch;
  
      /* perform convolution only on Y plane. Avoid border line. */
+     vlc_mutex_lock( &p_filter->p_sys->lock );
      for( i = 0; i < p_pic->p[Y_PLANE].i_visible_lines; i++ )
      {
          if( (i == 0) || (i == p_pic->p[Y_PLANE].i_visible_lines - 1) )
                    (p_src[(i + 1) * i_src_pitch + j    ] * v1) +
                    (p_src[(i + 1) * i_src_pitch + j + 1] * v1);
  
-         pix = pix >= 0 ? clip(pix) : -clip(pix * -1);
-         p_out[i * i_src_pitch + j] = clip( p_src[i * i_src_pitch + j] +
-             p_filter->p_sys->tab_precalc[pix + 256] );
+            pix = pix >= 0 ? clip(pix) : -clip(pix * -1);
+            p_out[i * i_src_pitch + j] = clip( p_src[i * i_src_pitch + j] +
+                p_filter->p_sys->tab_precalc[pix + 256] );
          }
      }
+     vlc_mutex_unlock( &p_filter->p_sys->lock );
  
      vlc_memcpy( p_outpic->p[U_PLANE].p_pixels, p_pic->p[U_PLANE].p_pixels,
                  p_outpic->p[U_PLANE].i_lines * p_outpic->p[U_PLANE].i_pitch );
@@@ -231,10 -233,11 +232,11 @@@ static int SharpenCallback( vlc_object_
                              vlc_value_t oldval, vlc_value_t newval,
                              void *p_data )
  {
-     VLC_UNUSED(p_this); VLC_UNUSED(oldval);
+     VLC_UNUSED(p_this); VLC_UNUSED(oldval); VLC_UNUSED(psz_var);
      filter_sys_t *p_sys = (filter_sys_t *)p_data;
-     if( !strcmp( psz_var, FILTER_PREFIX "sigma" ) )
-         p_sys->f_sigma = __MIN( 2., __MAX( 0., newval.f_float ) );
-     init_precalc_table(p_sys);
+     vlc_mutex_lock( &p_sys->lock );
+     init_precalc_table(p_sys,  __MIN( 2., __MAX( 0., newval.f_float ) ));
+     vlc_mutex_unlock( &p_sys->lock );
      return VLC_SUCCESS;
  }
index 4503e27165146c8c799d6fbdc9aa5291d39dbf39,6435154de92ad388439666af3a9666aa4794bc28..7d385468c2b4c0b8540f180f3e649e2d31a71794
@@@ -883,15 -883,17 +883,15 @@@ static D3DFORMAT Direct3DVoutFindFormat
      /* it sounds like vista does not support YUV surfaces at all */
          switch( i_chroma )
          {
 -            case VLC_FOURCC('U','Y','V','Y'):
 -            case VLC_FOURCC('U','Y','N','V'):
 -            case VLC_FOURCC('Y','4','2','2'):
 +            case VLC_CODEC_UYVY:
              {
                  static const D3DFORMAT formats[] =
                      { D3DFMT_UYVY, D3DFMT_YUY2, D3DFMT_X8R8G8B8, D3DFMT_A8R8G8B8, D3DFMT_R5G6B5, D3DFMT_X1R5G5B5 };
                  return Direct3DVoutSelectFormat(p_vout, target, formats, sizeof(formats)/sizeof(D3DFORMAT));
              }
 -            case VLC_FOURCC('I','4','2','0'):
 -            case VLC_FOURCC('I','4','2','2'):
 -            case VLC_FOURCC('Y','V','1','2'):
 +            case VLC_CODEC_I420:
 +            case VLC_CODEC_I422:
 +            case VLC_CODEC_YV12:
              {
                  /* typically 3D textures don't support planar format
                  ** fallback to packed version and use CPU for the conversion
                      { D3DFMT_YUY2, D3DFMT_UYVY, D3DFMT_X8R8G8B8, D3DFMT_A8R8G8B8, D3DFMT_R5G6B5, D3DFMT_X1R5G5B5 };
                  return Direct3DVoutSelectFormat(p_vout, target, formats, sizeof(formats)/sizeof(D3DFORMAT));
              }
 -            case VLC_FOURCC('Y','U','Y','2'):
 -            case VLC_FOURCC('Y','U','N','V'):
 +            case VLC_CODEC_YUYV:
              {
                  static const D3DFORMAT formats[] =
                      { D3DFMT_YUY2, D3DFMT_UYVY, D3DFMT_X8R8G8B8, D3DFMT_A8R8G8B8, D3DFMT_R5G6B5, D3DFMT_X1R5G5B5 };
  
      switch( i_chroma )
      {
 -        case VLC_FOURCC('R', 'V', '1', '5'):
 +        case VLC_CODEC_RGB15:
          {
              static const D3DFORMAT formats[] =
                  { D3DFMT_X1R5G5B5 };
              return Direct3DVoutSelectFormat(p_vout, target, formats, sizeof(formats)/sizeof(D3DFORMAT));
          }
 -        case VLC_FOURCC('R', 'V', '1', '6'):
 +        case VLC_CODEC_RGB16:
          {
              static const D3DFORMAT formats[] =
                  { D3DFMT_R5G6B5 };
              return Direct3DVoutSelectFormat(p_vout, target, formats, sizeof(formats)/sizeof(D3DFORMAT));
          }
 -        case VLC_FOURCC('R', 'V', '2', '4'):
 +        case VLC_CODEC_RGB24:
          {
              static const D3DFORMAT formats[] =
                  { D3DFMT_R8G8B8, D3DFMT_X8R8G8B8, D3DFMT_A8R8G8B8 };
              return Direct3DVoutSelectFormat(p_vout, target, formats, sizeof(formats)/sizeof(D3DFORMAT));
          }
 -        case VLC_FOURCC('R', 'V', '3', '2'):
 +        case VLC_CODEC_RGB32:
          {
              static const D3DFORMAT formats[] =
                  { D3DFMT_A8R8G8B8, D3DFMT_X8R8G8B8 };
@@@ -977,32 -980,32 +977,32 @@@ static int Direct3DVoutSetOutputFormat(
      switch( format )
      {
          case D3DFMT_YUY2:
 -            p_vout->output.i_chroma = VLC_FOURCC('Y', 'U', 'Y', '2');
 +            p_vout->output.i_chroma = VLC_CODEC_YUYV;
              break;
          case D3DFMT_UYVY:
 -            p_vout->output.i_chroma = VLC_FOURCC('U', 'Y', 'V', 'Y');
 +            p_vout->output.i_chroma = VLC_CODEC_UYVY;
              break;
          case D3DFMT_R8G8B8:
 -            p_vout->output.i_chroma = VLC_FOURCC('R', 'V', '2', '4');
 +            p_vout->output.i_chroma = VLC_CODEC_RGB24;
              p_vout->output.i_rmask = 0xff0000;
              p_vout->output.i_gmask = 0x00ff00;
              p_vout->output.i_bmask = 0x0000ff;
              break;
          case D3DFMT_X8R8G8B8:
          case D3DFMT_A8R8G8B8:
 -            p_vout->output.i_chroma = VLC_FOURCC('R', 'V', '3', '2');
 +            p_vout->output.i_chroma = VLC_CODEC_RGB32;
              p_vout->output.i_rmask = 0x00ff0000;
              p_vout->output.i_gmask = 0x0000ff00;
              p_vout->output.i_bmask = 0x000000ff;
              break;
          case D3DFMT_R5G6B5:
 -            p_vout->output.i_chroma = VLC_FOURCC('R', 'V', '1', '6');
 +            p_vout->output.i_chroma = VLC_CODEC_RGB16;
              p_vout->output.i_rmask = (0x1fL)<<11;
              p_vout->output.i_gmask = (0x3fL)<<5;
              p_vout->output.i_bmask = (0x1fL)<<0;
              break;
          case D3DFMT_X1R5G5B5:
 -            p_vout->output.i_chroma = VLC_FOURCC('R', 'V', '1', '5');
 +            p_vout->output.i_chroma = VLC_CODEC_RGB15;
              p_vout->output.i_rmask = (0x1fL)<<10;
              p_vout->output.i_gmask = (0x1fL)<<5;
              p_vout->output.i_bmask = (0x1fL)<<0;
@@@ -1028,7 -1031,8 +1028,8 @@@ static int Direct3DVoutCreatePictures( 
      HRESULT hr;
      size_t c;
      // if vout is already running, use current chroma, otherwise choose from upstream
-     int i_chroma = p_vout->output.i_chroma ? : p_vout->render.i_chroma;
+     int i_chroma = p_vout->output.i_chroma ? p_vout->output.i_chroma
+                                            : p_vout->render.i_chroma;
  
      I_OUTPUTPICTURES = 0;
  
           * picture_t structures */
          switch( p_vout->output.i_chroma )
          {
 -            case VLC_FOURCC('R','G','B','2'):
 +            case VLC_CODEC_RGB8:
                  p_pic->p->i_lines = p_vout->output.i_height;
                  p_pic->p->i_visible_lines = p_vout->output.i_height;
                  p_pic->p->i_pixel_pitch = 1;
                      p_pic->p->i_pixel_pitch;
                  p_pic->i_planes = 1;
              break;
 -            case VLC_FOURCC('R','V','1','5'):
 -            case VLC_FOURCC('R','V','1','6'):
 +            case VLC_CODEC_RGB15:
 +            case VLC_CODEC_RGB16:
                  p_pic->p->i_lines = p_vout->output.i_height;
                  p_pic->p->i_visible_lines = p_vout->output.i_height;
                  p_pic->p->i_pixel_pitch = 2;
                      p_pic->p->i_pixel_pitch;
                  p_pic->i_planes = 1;
              break;
 -            case VLC_FOURCC('R','V','2','4'):
 +            case VLC_CODEC_RGB24:
                  p_pic->p->i_lines = p_vout->output.i_height;
                  p_pic->p->i_visible_lines = p_vout->output.i_height;
                  p_pic->p->i_pixel_pitch = 3;
                      p_pic->p->i_pixel_pitch;
                  p_pic->i_planes = 1;
              break;
 -            case VLC_FOURCC('R','V','3','2'):
 +            case VLC_CODEC_RGB32:
                  p_pic->p->i_lines = p_vout->output.i_height;
                  p_pic->p->i_visible_lines = p_vout->output.i_height;
                  p_pic->p->i_pixel_pitch = 4;
                      p_pic->p->i_pixel_pitch;
                  p_pic->i_planes = 1;
                  break;
 -            case VLC_FOURCC('U','Y','V','Y'):
 -            case VLC_FOURCC('Y','U','Y','2'):
 +            case VLC_CODEC_UYVY:
 +            case VLC_CODEC_YUYV:
                  p_pic->p->i_lines = p_vout->output.i_height;
                  p_pic->p->i_visible_lines = p_vout->output.i_height;
                  p_pic->p->i_pixel_pitch = 2;
index ffe6de9fecd1faf62292b6a358d757e5f426ad68,9cd132c91c71b4c8178b8ea1b02ee602c42928f0..939ab8734d5cce99b777303d940f2a4b9d66ae52
@@@ -286,7 -286,7 +286,7 @@@ int Activate ( vlc_object_t *p_this 
              }
          }
      }
 -    p_vout->output.i_chroma = X112VLC_FOURCC(p_vout->output.i_chroma);
 +    p_vout->output.i_chroma = vlc_fourcc_GetCodec( VIDEO_ES, X112VLC_FOURCC(p_vout->output.i_chroma) );
  #elif defined(MODULE_NAME_IS_glx)
      {
          int i_opcode, i_evt, i_err = 0;
@@@ -812,7 -812,7 +812,7 @@@ static int InitVideo( vout_thread_t *p_
  #if XvVersion < 2 || ( XvVersion == 2 && XvRevision < 2 )
      switch( p_vout->output.i_chroma )
      {
 -        case VLC_FOURCC('R','V','1','6'):
 +        case VLC_CODEC_RGB16:
  #if defined( WORDS_BIGENDIAN )
              p_vout->output.i_rmask = 0xf800;
              p_vout->output.i_gmask = 0x07e0;
              p_vout->output.i_bmask = 0xf800;
  #endif
              break;
 -        case VLC_FOURCC('R','V','1','5'):
 +        case VLC_CODEC_RGB15:
  #if defined( WORDS_BIGENDIAN )
              p_vout->output.i_rmask = 0x7c00;
              p_vout->output.i_gmask = 0x03e0;
      switch( p_vout->p_sys->i_screen_depth )
      {
          case 8: /* FIXME: set the palette */
 -            p_vout->output.i_chroma = VLC_FOURCC('R','G','B','2'); break;
 +            p_vout->output.i_chroma = VLC_CODEC_RGB8; break;
          case 15:
 -            p_vout->output.i_chroma = VLC_FOURCC('R','V','1','5'); break;
 +            p_vout->output.i_chroma = VLC_CODEC_RGB15; break;
          case 16:
 -            p_vout->output.i_chroma = VLC_FOURCC('R','V','1','6'); break;
 +            p_vout->output.i_chroma = VLC_CODEC_RGB16; break;
          case 24:
          case 32:
 -            p_vout->output.i_chroma = VLC_FOURCC('R','V','3','2'); break;
 +            p_vout->output.i_chroma = VLC_CODEC_RGB32; break;
          default:
              msg_Err( p_vout, "unknown screen depth %i",
                       p_vout->p_sys->i_screen_depth );
          I_OUTPUTPICTURES++;
      }
  
 -    if( p_vout->output.i_chroma == VLC_FOURCC('Y','V','1','2') )
 +    if( p_vout->output.i_chroma == VLC_CODEC_YV12 )
      {
          /* U and V inverted compared to I420
           * Fixme: this should be handled by the vout core */
 -        p_vout->output.i_chroma = VLC_FOURCC('I','4','2','0');
 -        p_vout->fmt_out.i_chroma = VLC_FOURCC('I','4','2','0');
 +        p_vout->output.i_chroma = VLC_CODEC_I420;
 +        p_vout->fmt_out.i_chroma = VLC_CODEC_I420;
      }
  
      return VLC_SUCCESS;
@@@ -1232,6 -1232,8 +1232,8 @@@ static int ManageVideo( vout_thread_t *
                      val.i_int |= 1;
                      var_Set( p_vout, "mouse-button-down", val );
  
+                     var_SetBool( p_vout->p_libvlc, "intf-popupmenu", false );
                      /* detect double-clicks */
                      if( ( ((XButtonEvent *)&xevent)->time -
                            p_vout->p_sys->i_time_button_last_pressed ) < 300 )
                      var_Get( p_vout, "mouse-button-down", &val );
                      val.i_int |= 4;
                      var_Set( p_vout, "mouse-button-down", val );
+                     var_SetBool( p_vout->p_libvlc, "intf-popupmenu", true );
                      break;
  
                  case Button4:
                          var_Set( p_vout, "mouse-button-down", val );
  
                          var_SetBool( p_vout, "mouse-clicked", true );
-                         var_SetBool( p_vout->p_libvlc, "intf-popupmenu", false );
                      }
                      break;
  
                          val.i_int &= ~4;
                          var_Set( p_vout, "mouse-button-down", val );
  
-                         var_SetBool( p_vout->p_libvlc, "intf-popupmenu", true );
                      }
                      break;
  
@@@ -1611,8 -1612,6 +1612,8 @@@ static int CreateWindow( vout_thread_t 
      {
          p_win->owner_window = vout_RequestXWindow( p_vout, &p_win->i_x,
                                &p_win->i_y, &p_win->i_width, &p_win->i_height );
 +        if( !p_win->owner_window )
 +            return VLC_EGENERIC;
          xsize_hints.base_width  = xsize_hints.width = p_win->i_width;
          xsize_hints.base_height = xsize_hints.height = p_win->i_height;
          xsize_hints.flags       = PSize | PMinSize;
              xsize_hints.y = p_win->i_y;
              xsize_hints.flags |= PPosition;
          }
 +
 +        /* Select events we are interested in. */
 +        XSelectInput( p_vout->p_sys->p_display,
 +                      p_win->owner_window->handle.xid, StructureNotifyMask );
 +
 +        /* Get the parent window's geometry information */
 +        XGetGeometry( p_vout->p_sys->p_display,
 +                      p_win->owner_window->handle.xid,
 +                      &(Window){ 0 }, &(int){ 0 }, &(int){ 0 },
 +                      &p_win->i_width,
 +                      &p_win->i_height,
 +                      &(unsigned){ 0 }, &(unsigned){ 0 } );
 +
 +        /* From man XSelectInput: only one client at a time can select a
 +         * ButtonPress event, so we need to open a new window anyway. */
 +        p_win->base_window =
 +            XCreateWindow( p_vout->p_sys->p_display,
 +                           p_win->owner_window->handle.xid,
 +                           0, 0,
 +                           p_win->i_width, p_win->i_height,
 +                           0,
 +                           0, CopyFromParent, 0,
 +                           CWBackingStore | CWBackPixel | CWEventMask,
 +                           &xwindow_attributes );
      }
      else
      {
              DisplayWidth( p_vout->p_sys->p_display, p_vout->p_sys->i_screen );
          p_win->i_height =
              DisplayHeight( p_vout->p_sys->p_display, p_vout->p_sys->i_screen );
 -    }
  
 -    if( !p_win->owner_window )
 -    {
          /* Create the window and set hints - the window must receive
           * ConfigureNotify events, and until it is displayed, Expose and
           * MapNotify events. */
                          p_win->base_window, val.psz_string );
          }
          free( val.psz_string );
 -
 -        if( !p_vout->b_fullscreen )
 -        {
 -            const char *argv[] = { "vlc", NULL };
 -
 -            /* Set window manager hints and properties: size hints, command,
 -             * window's name, and accepted protocols */
 -            XSetWMNormalHints( p_vout->p_sys->p_display,
 -                               p_win->base_window, &xsize_hints );
 -            XSetCommand( p_vout->p_sys->p_display, p_win->base_window,
 -                         (char**)argv, 1 );
 -
 -            if( !var_GetBool( p_vout, "video-deco") )
 -            {
 -                Atom prop;
 -                mwmhints_t mwmhints;
 -
 -                mwmhints.flags = MWM_HINTS_DECORATIONS;
 -                mwmhints.decorations = False;
 -
 -                prop = XInternAtom( p_vout->p_sys->p_display, "_MOTIF_WM_HINTS",
 -                                    False );
 -
 -                XChangeProperty( p_vout->p_sys->p_display,
 -                                 p_win->base_window,
 -                                 prop, prop, 32, PropModeReplace,
 -                                 (unsigned char *)&mwmhints,
 -                                 PROP_MWM_HINTS_ELEMENTS );
 -            }
 -        }
 -    }
 -    else
 -    {
 -        Window dummy1;
 -        int dummy2, dummy3;
 -        unsigned int dummy4, dummy5;
 -
 -        /* Select events we are interested in. */
 -        XSelectInput( p_vout->p_sys->p_display,
 -                      p_win->owner_window->handle.xid, StructureNotifyMask );
 -
 -        /* Get the parent window's geometry information */
 -        XGetGeometry( p_vout->p_sys->p_display,
 -                      p_win->owner_window->handle.xid,
 -                      &dummy1, &dummy2, &dummy3,
 -                      &p_win->i_width,
 -                      &p_win->i_height,
 -                      &dummy4, &dummy5 );
 -
 -        /* From man XSelectInput: only one client at a time can select a
 -         * ButtonPress event, so we need to open a new window anyway. */
 -        p_win->base_window =
 -            XCreateWindow( p_vout->p_sys->p_display,
 -                           p_win->owner_window->handle.xid,
 -                           0, 0,
 -                           p_win->i_width, p_win->i_height,
 -                           0,
 -                           0, CopyFromParent, 0,
 -                           CWBackingStore | CWBackPixel | CWEventMask,
 -                           &xwindow_attributes );
      }
  
      if( (p_win->wm_protocols == None)        /* use WM_DELETE_WINDOW */
@@@ -1865,10 -1903,9 +1866,10 @@@ static int NewPicture( vout_thread_t *p
  #endif
  
      /* Fill in picture_t fields */
 -    vout_InitPicture( VLC_OBJECT(p_vout), p_pic, p_vout->output.i_chroma,
 -                      p_vout->output.i_width, p_vout->output.i_height,
 -                      p_vout->output.i_aspect );
 +    if( picture_Setup( p_pic, p_vout->output.i_chroma,
 +                       p_vout->output.i_width, p_vout->output.i_height,
 +                       p_vout->output.i_aspect ) )
 +        return -1;
  
  #ifdef HAVE_SYS_SHM_H
      if( p_vout->p_sys->i_shm_opcode )
      switch( p_vout->output.i_chroma )
      {
  #if defined(MODULE_NAME_IS_xvideo) || defined(MODULE_NAME_IS_xvmc)
 -        case VLC_FOURCC('I','4','2','0'):
 -        case VLC_FOURCC('Y','V','1','2'):
 -        case VLC_FOURCC('Y','2','1','1'):
 -        case VLC_FOURCC('Y','U','Y','2'):
 -        case VLC_FOURCC('U','Y','V','Y'):
 -        case VLC_FOURCC('R','V','1','5'):
 -        case VLC_FOURCC('R','V','1','6'):
 -        case VLC_FOURCC('R','V','2','4'): /* Fixme: pixel pitch == 4 ? */
 -        case VLC_FOURCC('R','V','3','2'):
 +        case VLC_CODEC_I420:
 +        case VLC_CODEC_YV12:
 +        case VLC_CODEC_Y211:
 +        case VLC_CODEC_YUYV:
 +        case VLC_CODEC_UYVY:
 +        case VLC_CODEC_RGB15:
 +        case VLC_CODEC_RGB16:
 +        case VLC_CODEC_RGB24: /* Fixme: pixel pitch == 4 ? */
 +        case VLC_CODEC_RGB32:
  
              for( i_plane = 0; i_plane < p_pic->p_sys->p_image->num_planes;
                   i_plane++ )
                  p_pic->p[i_plane].i_pitch =
                      p_pic->p_sys->p_image->pitches[i_plane];
              }
 -            if( p_vout->output.i_chroma == VLC_FOURCC('Y','V','1','2') )
 +            if( p_vout->output.i_chroma == VLC_CODEC_YV12 )
              {
                  /* U and V inverted compared to I420
                   * Fixme: this should be handled by the vout core */
              break;
  
  #else
 -        case VLC_FOURCC('R','G','B','2'):
 -        case VLC_FOURCC('R','V','1','6'):
 -        case VLC_FOURCC('R','V','1','5'):
 -        case VLC_FOURCC('R','V','2','4'):
 -        case VLC_FOURCC('R','V','3','2'):
 +        case VLC_CODEC_RGB8:
 +        case VLC_CODEC_RGB16:
 +        case VLC_CODEC_RGB15:
 +        case VLC_CODEC_RGB24:
 +        case VLC_CODEC_RGB32:
  
              p_pic->p->i_lines = p_pic->p_sys->p_image->height;
              p_pic->p->i_visible_lines = p_pic->p_sys->p_image->height;
              p_pic->p->i_pitch = p_pic->p_sys->p_image->bytes_per_line;
  
              /* p_pic->p->i_pixel_pitch = 4 for RV24 but this should be set
 -             * properly by vout_InitPicture() */
 +             * properly by picture_Setup() */
              p_pic->p->i_visible_pitch = p_pic->p->i_pixel_pitch
                                           * p_pic->p_sys->p_image->width;
              break;
index f7b8702e540e988910dc11db7dc6f85a8c366a41,f428187e21857ca5d1801a9cfe1e95f0236b9181..850fcbe79a9c157e8333318b53a814ada599beff
@@@ -4,7 -4,7 +4,7 @@@
   * Copyright (C) 2002-2009 the VideoLAN team
   *
   * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
 - *          Jan Paul Dinger <jpd@m2x.nl>
 + *          JP Dinger <jpd@m2x.nl>
   *
   * 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
@@@ -65,7 -65,6 +65,6 @@@ LibvlcRootNPObject::~LibvlcRootNPObject
      {
          if( audioObj    ) NPN_ReleaseObject(audioObj);
          if( inputObj    ) NPN_ReleaseObject(inputObj);
-         if( logObj      ) NPN_ReleaseObject(logObj);
          if( playlistObj ) NPN_ReleaseObject(playlistObj);
          if( videoObj    ) NPN_ReleaseObject(videoObj);
      }
@@@ -75,7 -74,6 +74,6 @@@ const NPUTF8 * const LibvlcRootNPObject
  {
      "audio",
      "input",
-     "log",
      "playlist",
      "video",
      "VersionInfo",
@@@ -86,7 -84,6 +84,6 @@@ enum LibvlcRootNPObjectPropertyId
  {
      ID_root_audio = 0,
      ID_root_input,
-     ID_root_log,
      ID_root_playlist,
      ID_root_video,
      ID_root_VersionInfo,
@@@ -116,14 -113,6 +113,6 @@@ LibvlcRootNPObject::getProperty(int ind
                               RuntimeNPClass<LibvlcInputNPObject>::getClass());
                  OBJECT_TO_NPVARIANT(NPN_RetainObject(inputObj), result);
                  return INVOKERESULT_NO_ERROR;
-             case ID_root_log:
-                 // create child object in lazyman fashion to avoid
-                 // ownership problem with firefox
-                 if( ! logObj )
-                     logObj = NPN_CreateObject(_instance,
-                                RuntimeNPClass<LibvlcLogNPObject>::getClass());
-                 OBJECT_TO_NPVARIANT(NPN_RetainObject(logObj), result);
-                 return INVOKERESULT_NO_ERROR;
              case ID_root_playlist:
                  // create child object in lazyman fashion to avoid
                  // ownership problem with firefox
                  OBJECT_TO_NPVARIANT(NPN_RetainObject(videoObj), result);
                  return INVOKERESULT_NO_ERROR;
              case ID_root_VersionInfo:
 -            {
 -                const char *s = libvlc_get_version();
 -                int len = strlen(s);
 -                NPUTF8 *retval =(NPUTF8*)NPN_MemAlloc(len);
 -                if( !retval )
 -                    return INVOKERESULT_OUT_OF_MEMORY;
 -
 -                memcpy(retval, s, len);
 -                STRINGN_TO_NPVARIANT(retval, len, result);
 -                return INVOKERESULT_NO_ERROR;
 -            }
 +                return invokeResultString(libvlc_get_version(),result);
              default:
                  ;
          }
@@@ -172,9 -171,18 +161,9 @@@ RuntimeNPObject::InvokeResult LibvlcRoo
          switch( index )
          {
              case ID_root_versionInfo:
 -                if( argCount == 0 )
 -                {
 -                    const char *s = libvlc_get_version();
 -                    int len = strlen(s);
 -                    NPUTF8 *retval =(NPUTF8*)NPN_MemAlloc(len);
 -                    if( !retval )
 -                        return INVOKERESULT_OUT_OF_MEMORY;
 -                    memcpy(retval, s, len);
 -                    STRINGN_TO_NPVARIANT(retval, len, result);
 -                    return INVOKERESULT_NO_ERROR;
 -                }
 -                return INVOKERESULT_NO_SUCH_METHOD;
 +                if( 0 != argCount )
 +                    return INVOKERESULT_NO_SUCH_METHOD;
 +                return invokeResultString(libvlc_get_version(),result);
              default:
                  ;
          }
@@@ -534,425 -542,6 +523,6 @@@ const NPUTF8 * const LibvlcInputNPObjec
  
  COUNTNAMES(LibvlcInputNPObject,methodCount,methodNames);
  
- /*
- ** implementation of libvlc message object
- */
- const NPUTF8 * const LibvlcMessageNPObject::propertyNames[] =
- {
-     "severity",
-     "type",
-     "name",
-     "header",
-     "message",
- };
- COUNTNAMES(LibvlcMessageNPObject,propertyCount,propertyNames);
- enum LibvlcMessageNPObjectPropertyIds
- {
-     ID_message_severity,
-     ID_message_type,
-     ID_message_name,
-     ID_message_header,
-     ID_message_message,
- };
- RuntimeNPObject::InvokeResult
- LibvlcMessageNPObject::getProperty(int index, NPVariant &result)
- {
-     /* is plugin still running */
-     if( isPluginRunning() )
-     {
-         switch( index )
-         {
-             case ID_message_severity:
-             {
-                 INT32_TO_NPVARIANT(_msg.i_severity, result);
-                 return INVOKERESULT_NO_ERROR;
-             }
-             case ID_message_type:
-                 return invokeResultString(_msg.psz_type,result);
-             case ID_message_name:
-                 return invokeResultString(_msg.psz_name,result);
-             case ID_message_header:
-                 return invokeResultString(_msg.psz_header,result);
-             case ID_message_message:
-                 return invokeResultString(_msg.psz_message,result);
-             default:
-                 ;
-         }
-     }
-     return INVOKERESULT_GENERIC_ERROR;
- }
- const NPUTF8 * const LibvlcMessageNPObject::methodNames[] =
- {
-     /* no methods */
- };
- COUNTNAMES(LibvlcMessageNPObject,methodCount,methodNames);
- /*
- ** implementation of libvlc message iterator object
- */
- LibvlcMessageIteratorNPObject::LibvlcMessageIteratorNPObject(NPP instance,
-                                                       const NPClass *aClass) :
-     RuntimeNPObject(instance, aClass),
-     _p_iter(NULL)
- {
-     // XXX FIXME use _instance or instance in this method?
-     /* is plugin still running */
-     if( instance->pdata )
-     {
-         VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(instance->pdata);
-         libvlc_log_t *p_log = p_plugin->getLog();
-         if( p_log )
-         {
-             _p_iter = libvlc_log_get_iterator(p_log, NULL);
-         }
-     }
- };
- LibvlcMessageIteratorNPObject::~LibvlcMessageIteratorNPObject()
- {
-     if( _p_iter )
-         libvlc_log_iterator_free(_p_iter, NULL);
- }
- const NPUTF8 * const LibvlcMessageIteratorNPObject::propertyNames[] =
- {
-     "hasNext",
- };
- COUNTNAMES(LibvlcMessageIteratorNPObject,propertyCount,propertyNames);
- enum LibvlcMessageIteratorNPObjectPropertyIds
- {
-     ID_messageiterator_hasNext,
- };
- RuntimeNPObject::InvokeResult
- LibvlcMessageIteratorNPObject::getProperty(int index, NPVariant &result)
- {
-     /* is plugin still running */
-     if( isPluginRunning() )
-     {
-         VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
-         switch( index )
-         {
-             case ID_messageiterator_hasNext:
-             {
-                 if( _p_iter && p_plugin->getLog() )
-                 {
-                     libvlc_exception_t ex;
-                     libvlc_exception_init(&ex);
-                     BOOLEAN_TO_NPVARIANT(
-                          libvlc_log_iterator_has_next(_p_iter, &ex), result );
-                     RETURN_ON_EXCEPTION(this,ex);
-                 }
-                 else
-                 {
-                     BOOLEAN_TO_NPVARIANT(0, result);
-                 }
-                 return INVOKERESULT_NO_ERROR;
-             }
-             default:
-                 ;
-         }
-     }
-     return INVOKERESULT_GENERIC_ERROR;
- }
- const NPUTF8 * const LibvlcMessageIteratorNPObject::methodNames[] =
- {
-     "next",
- };
- COUNTNAMES(LibvlcMessageIteratorNPObject,methodCount,methodNames);
- enum LibvlcMessageIteratorNPObjectMethodIds
- {
-     ID_messageiterator_next,
- };
- RuntimeNPObject::InvokeResult
- LibvlcMessageIteratorNPObject::invoke(int index, const NPVariant *args,
-                                       uint32_t argCount, NPVariant &result)
- {
-     /* is plugin still running */
-     if( isPluginRunning() )
-     {
-         VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
-         libvlc_exception_t ex;
-         libvlc_exception_init(&ex);
-         switch( index )
-         {
-             case ID_messageiterator_next:
-                 if( argCount == 0 )
-                 {
-                     if( _p_iter && p_plugin->getLog() )
-                     {
-                         struct libvlc_log_message_t buffer;
-                         buffer.sizeof_msg = sizeof(buffer);
-                         libvlc_log_iterator_next(_p_iter, &buffer, &ex);
-                         RETURN_ON_EXCEPTION(this,ex);
-                         LibvlcMessageNPObject* message =
-                             static_cast<LibvlcMessageNPObject*>(
-                             NPN_CreateObject(_instance, RuntimeNPClass<
-                             LibvlcMessageNPObject>::getClass()));
-                         if( message )
-                         {
-                             message->setMessage(buffer);
-                             OBJECT_TO_NPVARIANT(message, result);
-                             return INVOKERESULT_NO_ERROR;
-                         }
-                         return INVOKERESULT_OUT_OF_MEMORY;
-                     }
-                     return INVOKERESULT_GENERIC_ERROR;
-                 }
-                 return INVOKERESULT_NO_SUCH_METHOD;
-             default:
-                 ;
-         }
-     }
-     return INVOKERESULT_GENERIC_ERROR;
- }
-  
- /*
- ** implementation of libvlc message object
- */
- const NPUTF8 * const LibvlcMessagesNPObject::propertyNames[] =
- {
-     "count",
- };
- COUNTNAMES(LibvlcMessagesNPObject,propertyCount,propertyNames);
- enum LibvlcMessagesNPObjectPropertyIds
- {
-     ID_messages_count,
- };
- RuntimeNPObject::InvokeResult
- LibvlcMessagesNPObject::getProperty(int index, NPVariant &result)
- {
-     /* is plugin still running */
-     if( isPluginRunning() )
-     {
-         VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
-         switch( index )
-         {
-             case ID_messages_count:
-             {
-                 libvlc_log_t *p_log = p_plugin->getLog();
-                 if( p_log )
-                 {
-                     libvlc_exception_t ex;
-                     libvlc_exception_init(&ex);
-                     INT32_TO_NPVARIANT(libvlc_log_count(p_log, &ex), result);
-                     RETURN_ON_EXCEPTION(this,ex);
-                 }
-                 else
-                 {
-                     INT32_TO_NPVARIANT(0, result);
-                 }
-                 return INVOKERESULT_NO_ERROR;
-             }
-             default:
-                 ;
-         }
-     }
-     return INVOKERESULT_GENERIC_ERROR;
- }
- const NPUTF8 * const LibvlcMessagesNPObject::methodNames[] =
- {
-     "clear",
-     "iterator",
- };
- COUNTNAMES(LibvlcMessagesNPObject,methodCount,methodNames);
- enum LibvlcMessagesNPObjectMethodIds
- {
-     ID_messages_clear,
-     ID_messages_iterator,
- };
- RuntimeNPObject::InvokeResult
- LibvlcMessagesNPObject::invoke(int index, const NPVariant *args,
-                                uint32_t argCount, NPVariant &result)
- {
-     /* is plugin still running */
-     if( isPluginRunning() )
-     {
-         VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
-         libvlc_exception_t ex;
-         libvlc_exception_init(&ex);
-         switch( index )
-         {
-             case ID_messages_clear:
-                 if( argCount == 0 )
-                 {
-                     libvlc_log_t *p_log = p_plugin->getLog();
-                     if( p_log )
-                     {
-                         libvlc_log_clear(p_log, &ex);
-                         RETURN_ON_EXCEPTION(this,ex);
-                     }
-                     return INVOKERESULT_NO_ERROR;
-                 }
-                 return INVOKERESULT_NO_SUCH_METHOD;
-             case ID_messages_iterator:
-                 if( argCount == 0 )
-                 {
-                     LibvlcMessageIteratorNPObject* iter =
-                         static_cast<LibvlcMessageIteratorNPObject*>(
-                         NPN_CreateObject(_instance, RuntimeNPClass<
-                         LibvlcMessageIteratorNPObject>::getClass()));
-                     if( iter )
-                     {
-                         OBJECT_TO_NPVARIANT(iter, result);
-                         return INVOKERESULT_NO_ERROR;
-                     }
-                     return INVOKERESULT_OUT_OF_MEMORY;
-                 }
-                 return INVOKERESULT_NO_SUCH_METHOD;
-             default:
-                 ;
-         }
-     }
-     return INVOKERESULT_GENERIC_ERROR;
- }
- /*
- ** implementation of libvlc message object
- */
- LibvlcLogNPObject::~LibvlcLogNPObject()
- {
-     if( isValid() )
-     {
-         if( messagesObj ) NPN_ReleaseObject(messagesObj);
-     }
- };
- const NPUTF8 * const LibvlcLogNPObject::propertyNames[] =
- {
-     "messages",
-     "verbosity",
- };
- COUNTNAMES(LibvlcLogNPObject,propertyCount,propertyNames);
- enum LibvlcLogNPObjectPropertyIds
- {
-     ID_log_messages,
-     ID_log_verbosity,
- };
- RuntimeNPObject::InvokeResult
- LibvlcLogNPObject::getProperty(int index, NPVariant &result)
- {
-     /* is plugin still running */
-     if( isPluginRunning() )
-     {
-         VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
-         libvlc_exception_t ex;
-         libvlc_exception_init(&ex);
-         switch( index )
-         {
-             case ID_log_messages:
-             {
-                 // create child object in lazyman fashion to avoid
-                 // ownership problem with firefox
-                 if( ! messagesObj )
-                     messagesObj = NPN_CreateObject(_instance,
-                           RuntimeNPClass<LibvlcMessagesNPObject>::getClass());
-                 OBJECT_TO_NPVARIANT(NPN_RetainObject(messagesObj), result);
-                 return INVOKERESULT_NO_ERROR;
-             }
-             case ID_log_verbosity:
-             {
-                 if( p_plugin->getLog() )
-                 {
-                     INT32_TO_NPVARIANT( libvlc_get_log_verbosity(
-                                         p_plugin->getVLC(), &ex), result);
-                     RETURN_ON_EXCEPTION(this,ex);
-                 }
-                 else
-                 {
-                     /* log is not enabled, return -1 */
-                     DOUBLE_TO_NPVARIANT(-1.0, result);
-                 }
-                 return INVOKERESULT_NO_ERROR;
-             }
-             default:
-                 ;
-         }
-     }
-     return INVOKERESULT_GENERIC_ERROR;
- }
- RuntimeNPObject::InvokeResult
- LibvlcLogNPObject::setProperty(int index, const NPVariant &value)
- {
-     /* is plugin still running */
-     if( isPluginRunning() )
-     {
-         VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
-         libvlc_exception_t ex;
-         libvlc_exception_init(&ex);
-         switch( index )
-         {
-             case ID_log_verbosity:
-                 if( isNumberValue(value) )
-                 {
-                     libvlc_instance_t* p_libvlc = p_plugin->getVLC();
-                     libvlc_log_t *p_log = p_plugin->getLog();
-                     int verbosity = numberValue(value);
-                     if( verbosity >= 0 )
-                     {
-                         if( !p_log )
-                         {
-                             p_log = libvlc_log_open(p_libvlc, &ex);
-                             RETURN_ON_EXCEPTION(this,ex);
-                             p_plugin->setLog(p_log);
-                         }
-                         libvlc_set_log_verbosity(p_libvlc, (unsigned)verbosity, &ex);
-                         RETURN_ON_EXCEPTION(this,ex);
-                     }
-                     else if( p_log )
-                     {
-                         /* close log  when verbosity is set to -1 */
-                         p_plugin->setLog(NULL);
-                         libvlc_log_close(p_log, &ex);
-                         RETURN_ON_EXCEPTION(this,ex);
-                     }
-                     return INVOKERESULT_NO_ERROR;
-                 }
-                 return INVOKERESULT_INVALID_VALUE;
-             default:
-                 ;
-         }
-     }
-     return INVOKERESULT_GENERIC_ERROR;
- }
- const NPUTF8 * const LibvlcLogNPObject::methodNames[] =
- {
-     /* no methods */
- };
- COUNTNAMES(LibvlcLogNPObject,methodCount,methodNames);
  /*
  ** implementation of libvlc playlist items object
  */
@@@ -1051,9 -640,10 +621,9 @@@ LibvlcPlaylistItemsNPObject::invoke(in
  
  LibvlcPlaylistNPObject::~LibvlcPlaylistNPObject()
  {
 -    if( isValid() )
 -    {
 -        if( playlistItemsObj ) NPN_ReleaseObject(playlistItemsObj);
 -    }
 +    // Why the isValid()?
 +    if( isValid() && playlistItemsObj )
 +        NPN_ReleaseObject(playlistItemsObj);
  };
  
  const NPUTF8 * const LibvlcPlaylistNPObject::propertyNames[] =
@@@ -1231,8 -821,8 +801,8 @@@ LibvlcPlaylistNPObject::invoke(int inde
                      }
                  }
  
 -                int item = p_plugin->playlist_add_extended_untrusted(url, name, i_options,
 -                               const_cast<const char **>(ppsz_options), &ex);
 +                int item = p_plugin->playlist_add_extended_untrusted(url, name,
 +                      i_options, const_cast<const char **>(ppsz_options), &ex);
                  free(url);
                  free(name);
                  for( int i=0; i< i_options; ++i )
index 5c26ced69e0051d3b249c1503ed5e43a6df247e3,b9085f3d586892fb00e032f07c2ad5a1c4b2079c..e73ffecdd6c1a48be0350d166161dda7977b4208
@@@ -168,17 -168,6 +168,6 @@@ Insert Slider widge
  <INPUT size=4 value="" id="removeid"><INPUT type=submit value="Delete" onClick="doRemoveItem(document.getElementById('removeid').value);">\r
  </TD>\r
  </TR>\r
- <TR><TD>Messages:\r
- <INPUT type=button value="Messages" onClick='doMessages();'>\r
- Verbosity:\r
- <INPUT size=2 value="1" id="verbosity" onClick="doVerbosity(document.getElementById('verbosity').value);">\r
- <INPUT type=button value=" + " onClick='doVerbosity(1);'>\r
- <INPUT type=button value=" - " onClick='doVerbosity(-1);'>\r
- </TD>\r
- <TD>\r
- <DIV id="message" style="text-align:center">no message</DIV>\r
- </TD>\r
- </TR>\r
  <TR><TD>Audio Channel:\r
    <SELECT readonly onClick='doAudioChannel(this.value);'>\r
      <OPTION value=1>Stereo</OPTION>\r
@@@ -253,16 -242,6 +242,6 @@@ function doReverse(rate
          vlc.input.rate = -1.0 * vlc.input.rate;\r
  }\r
  \r
- function doVerbosity(value)\r
- {\r
-     var vlc = getVLC("vlc");\r
-     if( vlc )\r
-     {\r
-         vlc.log.verbosity = vlc.log.verbosity + value;\r
-         document.getElementById("verbosity").value = vlc.log.verbosity;\r
-     }\r
- }\r
\r
  function doAudioChannel(value)\r
  {\r
      var vlc = getVLC("vlc");\r
@@@ -355,30 -334,6 +334,6 @@@ function doPlaylistClearAll(
      }\r
  }\r
  \r
- function doMessages()\r
- {\r
-     var vlc = getVLC("vlc");\r
\r
-     if( vlc )\r
-     {\r
-         if( vlc.log.messages.count > 0 )\r
-         {\r
-             // there is one or more messages in the log\r
-             var iter = vlc.log.messages.iterator();\r
-             while( iter.hasNext )\r
-             {\r
-                 var msg = iter.next();\r
-                 if( msg.severity <= 1 )\r
-                 {\r
-                     document.getElementById("message").innerHTML = msg.message;\r
-                 }\r
-             }\r
-             // clear the log once finished to avoid clogging\r
-             vlc.log.messages.clear();\r
-         }\r
-     }\r
- }\r
\r
  function updateVolume(deltaVol)\r
  {\r
      var vlc = getVLC("vlc");\r
@@@ -467,23 -422,6 +422,6 @@@ function monitor(
      if( vlc )\r
      {\r
          newState = vlc.input.state;\r
\r
-         if( vlc.log.messages.count > 0 )\r
-         {\r
-             // there is one or more messages in the log\r
-             var iter = vlc.log.messages.iterator();\r
-             while( iter.hasNext )\r
-             {\r
-                 var msg = iter.next();\r
-                 if( msg.severity == 1 )\r
-                 {\r
-                     alert( msg.message );\r
-                 }\r
-                 document.getElementById("message").innerHTML = msg.message;\r
-             }\r
-             // clear the log once finished to avoid clogging\r
-             vlc.log.messages.clear();\r
-         }\r
      }\r
  \r
      if( prevState != newState )\r
@@@ -559,9 -497,6 +497,6 @@@ function doGo(targetURL
          var itemId = vlc.playlist.add(targetURL,"",options);\r
          if( itemId != -1 )\r
          {\r
-             // clear the message log and enable error logging\r
-             vlc.log.verbosity = 1;\r
-             vlc.log.messages.clear();\r
              // play MRL\r
              vlc.playlist.playItem(itemId);\r
              if( monitorTimerId == 0 )\r
          }\r
          else\r
          {\r
-             // disable log\r
-             vlc.log.verbosity = -1;\r
              alert("cannot play at the moment !");\r
          }\r
          doItemCount();\r
@@@ -602,16 -535,11 +535,11 @@@ function doPlayOrPause(
          }\r
          else if( vlc.playlist.items.count > 0 )\r
          {\r
-             // clear the message log and enable error logging\r
-             vlc.log.verbosity = 1;\r
-             vlc.log.messages.clear();\r
              vlc.playlist.play();\r
              monitor();\r
          }\r
          else\r
          {\r
-             // disable log\r
-             vlc.log.verbosity = -1;\r
              alert('nothing to play !');\r
          }\r
      }\r
@@@ -670,7 -598,6 +598,7 @@@ function onPlay(
  function onEnd()\r
  {\r
      document.getElementById("state").innerHTML = "End...";\r
 +    doStop();\r
  }\r
  \r
  var liveFeedText = new Array("Live", "((Live))", "(( Live ))", "((  Live  ))");\r
@@@ -728,10 -655,7 +656,7 @@@ function onPause(
  \r
  function onStop()\r
  {\r
-     // disable logging\r
      var vlc = getVLC("vlc");\r
-     if( vlc )\r
-         vlc.log.verbosity = -1;\r
  \r
      if( inputTracker )\r
      {\r
@@@ -752,25 -676,6 +677,6 @@@ function onError(
      var vlc = getVLC("vlc");\r
  \r
      document.getElementById("state").innerHTML = "Error...";\r
-     if( vlc )\r
-     {\r
-         if( vlc.log.messages.count > 0 )\r
-         {\r
-             // there is one or more messages in the log\r
-             var iter = vlc.log.messages.iterator();\r
-             while( iter.hasNext )\r
-             {\r
-                 var msg = iter.next();\r
-                 if( msg.severity <= 1 )\r
-                 {\r
-                     alert( msg.message );\r
-                 }\r
-                 document.getElementById("message").innerHTML = msg.message;\r
-             }\r
-             // clear the log once finished to avoid clogging\r
-             vlc.log.messages.clear();\r
-         }\r
-     }\r
  }\r
  \r
  function onInputTrackerScrollStart()\r
index 55c15ec1b0cfc110df2c0a4bbd4d99cfefb6637a,8f3ebe5e1cdbb4128eb7b85339a61dacc2ceb48b..552d6fdad43fb9a780a511f1e6f5e19b90094110
@@@ -50,7 -50,6 +50,6 @@@ VlcPlugin::VlcPlugin( NPP instance, uin
      libvlc_instance(NULL),
      libvlc_media_list(NULL),
      libvlc_media_player(NULL),
-     libvlc_log(NULL),
      p_scriptClass(NULL),
      p_browser(instance),
      psz_baseURL(NULL)
@@@ -136,7 -135,7 +135,7 @@@ NPError VlcPlugin::init(int argc, char
      /* parse plugin arguments */
      for( int i = 0; i < argc ; i++ )
      {
 -        fprintf(stderr, "argn=%s, argv=%s\n", argn[i], argv[i]);
 +       /* fprintf(stderr, "argn=%s, argv=%s\n", argn[i], argv[i]); */
  
          if( !strcmp( argn[i], "target" )
           || !strcmp( argn[i], "mrl")
          }
          else if( !strcmp( argn[i], "toolbar" ) )
          {
 -/* FIXME: Remove this when toolbar functionality has been implemented on\
 +/* FIXME: Remove this when toolbar functionality has been implemented on
   * MacOS X and Win32 for Firefox/Mozilla/Safari. */
  #ifdef XP_UNIX
              b_toolbar = boolValue(argv[i]);
      libvlc_exception_init(&ex);
  
      libvlc_instance = libvlc_new(ppsz_argc, ppsz_argv, &ex);
 -
      if( libvlc_exception_raised(&ex) )
      {
          libvlc_exception_clear(&ex);
@@@ -267,8 -267,6 +266,6 @@@ VlcPlugin::~VlcPlugin(
  {
      free(psz_baseURL);
      free(psz_target);
-     if( libvlc_log )
-         libvlc_log_close(libvlc_log, NULL);
      if( libvlc_media_player )
          libvlc_media_player_release( libvlc_media_player );
      if( libvlc_media_list )
@@@ -476,7 -474,7 +473,7 @@@ relativeurl
              if( href )
              {
                  /* prepend base URL */
 -                strcpy(href, psz_baseURL);
 +                memcpy(href, psz_baseURL, baseLen+1);
  
                  /*
                  ** relative url could be empty,
  
                  /* skip over protocol part  */
                  char *pathstart = strchr(href, ':');
 -                char *pathend;
 +                char *pathend = href+baseLen;
                  if( pathstart )
                  {
                      if( '/' == *(++pathstart) )
                      }
                      /* skip over host part */
                      pathstart = strchr(pathstart, '/');
 -                    pathend = href+baseLen;
                      if( ! pathstart )
                      {
                          // no path, add a / past end of url (over '\0')
                          return NULL;
                      }
                      pathstart = href;
 -                    pathend = href+baseLen;
                  }
  
                  /* relative URL made of an absolute path ? */
index 0ef1e65c0d516165b3542a49f0d093151b45c45c,fe80925d68e084b445578c7f75409183766cc905..389fce92aa460cadf8721adfb7b65947e50e8582
@@@ -78,20 -78,24 +78,20 @@@ static void release_input_thread( libvl
  
      p_input_thread = p_mi->p_input_thread;
  
 -    /* No one is tracking this input_thread apart from us. Destroy it. */
 -    if( p_mi->b_own_its_input_thread )
 -    {
 -        var_DelCallback( p_input_thread, "can-seek",
 -                         input_seekable_changed, p_mi );
 -        var_DelCallback( p_input_thread, "can-pause",
 -                         input_pausable_changed, p_mi );
 -        var_DelCallback( p_input_thread, "intf-event",
 -                         input_event_changed, p_mi );
 -
 -        /* We owned this one */
 -        input_Stop( p_input_thread, b_input_abort );
 -        vlc_thread_join( p_input_thread );
 -
 -        var_Destroy( p_input_thread, "drawable-hwnd" );
 -        var_Destroy( p_input_thread, "drawable-xid" );
 -        var_Destroy( p_input_thread, "drawable-agl" );
 -    }
 +    var_DelCallback( p_input_thread, "can-seek",
 +                     input_seekable_changed, p_mi );
 +    var_DelCallback( p_input_thread, "can-pause",
 +                    input_pausable_changed, p_mi );
 +    var_DelCallback( p_input_thread, "intf-event",
 +                     input_event_changed, p_mi );
 +
 +    /* We owned this one */
 +    input_Stop( p_input_thread, b_input_abort );
 +    vlc_thread_join( p_input_thread );
 +
 +    var_Destroy( p_input_thread, "drawable-hwnd" );
 +    var_Destroy( p_input_thread, "drawable-xid" );
 +    var_Destroy( p_input_thread, "drawable-agl" );
  
      vlc_object_release( p_input_thread );
  
@@@ -215,7 -219,7 +215,7 @@@ input_event_changed( vlc_object_t * p_t
          libvlc_media_set_state( p_mi->p_md, libvlc_state, NULL );
          libvlc_event_send( p_mi->p_event_manager, &event );
      }
 -    else if( newval.i_int == INPUT_EVENT_TIMES )
 +    else if( newval.i_int == INPUT_EVENT_POSITION )
      {
          if( var_GetInteger( p_input, "state" ) != PLAYING_S )
              return VLC_SUCCESS; /* Don't send the position while stopped */
                                                 var_GetTime( p_input, "time" );
          libvlc_event_send( p_mi->p_event_manager, &event );
      }
 +    else if( newval.i_int == INPUT_EVENT_LENGTH )
 +    {
 +        event.type = libvlc_MediaPlayerLengthChanged;
 +        event.u.media_player_length_changed.new_length =
 +                                               var_GetTime( p_input, "length" );
 +        libvlc_event_send( p_mi->p_event_manager, &event );
 +    }
  
      return VLC_SUCCESS;
  
  }
  
 +static void libvlc_media_player_destroy( libvlc_media_player_t * );
 +
  /**************************************************************************
   * Create a Media Instance object.
   *
@@@ -285,6 -280,7 +285,6 @@@ libvlc_media_player_new( libvlc_instanc
      p_mi->p_libvlc_instance = p_libvlc_instance;
      p_mi->p_input_thread = NULL;
      p_mi->i_refcount = 1;
 -    p_mi->b_own_its_input_thread = true;
      vlc_mutex_init( &p_mi->object_lock );
      p_mi->p_event_manager = libvlc_event_manager_new( p_mi,
              p_libvlc_instance, p_e );
              libvlc_MediaPlayerPositionChanged, p_e );
      libvlc_event_manager_register_event_type( p_mi->p_event_manager,
              libvlc_MediaPlayerTimeChanged, p_e );
 +    libvlc_event_manager_register_event_type( p_mi->p_event_manager,
 +            libvlc_MediaPlayerLengthChanged, p_e );
      libvlc_event_manager_register_event_type( p_mi->p_event_manager,
              libvlc_MediaPlayerTitleChanged, p_e );
      libvlc_event_manager_register_event_type( p_mi->p_event_manager,
      /* Snapshot initialization */
      libvlc_event_manager_register_event_type( p_mi->p_event_manager,
             libvlc_MediaPlayerSnapshotTaken, p_e );
 +
      /* Attach a var callback to the global object to provide the glue between
          vout_thread that generates the event and media_player that re-emits it
          with its own event manager
@@@ -354,8 -347,8 +354,8 @@@ libvlc_media_player_new_from_media
                                      libvlc_exception_t *p_e )
  {
      libvlc_media_player_t * p_mi;
 -    p_mi = libvlc_media_player_new( p_md->p_libvlc_instance, p_e );
  
 +    p_mi = libvlc_media_player_new( p_md->p_libvlc_instance, p_e );
      if( !p_mi )
          return NULL;
  
      return p_mi;
  }
  
 -/**************************************************************************
 - * Create a new media instance object from an input_thread (Libvlc Internal).
 - **************************************************************************/
 -libvlc_media_player_t * libvlc_media_player_new_from_input_thread(
 -                                   struct libvlc_instance_t *p_libvlc_instance,
 -                                   input_thread_t *p_input,
 -                                   libvlc_exception_t *p_e )
 -{
 -    libvlc_media_player_t * p_mi;
 -
 -    if( !p_input )
 -    {
 -        libvlc_exception_raise( p_e, "invalid input thread" );
 -        return NULL;
 -    }
 -
 -    p_mi = libvlc_media_player_new( p_libvlc_instance, p_e );
 -
 -    if( !p_mi )
 -        return NULL;
 -
 -    p_mi->p_md = libvlc_media_new_from_input_item(
 -                    p_libvlc_instance,
 -                    input_GetItem( p_input ), p_e );
 -
 -    if( !p_mi->p_md )
 -    {
 -        libvlc_media_player_destroy( p_mi );
 -        return NULL;
 -    }
 -
 -    /* will be released in media_player_release() */
 -    vlc_object_hold( p_input );
 -
 -    p_mi->p_input_thread = p_input;
 -    p_mi->b_own_its_input_thread = false;
 -
 -    return p_mi;
 -}
 -
  /**************************************************************************
   * Destroy a Media Instance object (libvlc internal)
   *
   * Warning: No lock held here, but hey, this is internal. Caller must lock.
   **************************************************************************/
 -void libvlc_media_player_destroy( libvlc_media_player_t *p_mi )
 +static void libvlc_media_player_destroy( libvlc_media_player_t *p_mi )
  {
      input_thread_t *p_input_thread;
      libvlc_exception_t p_e;
  
 -    libvlc_exception_init( &p_e );
 -
 -    if( !p_mi )
 -        return;
 +    assert( p_mi );
  
 -      /* Detach Callback from the main libvlc object */
 +    /* Detach Callback from the main libvlc object */
      var_DelCallback( p_mi->p_libvlc_instance->p_libvlc_int,
                       "vout-snapshottaken", SnapshotTakenCallback, p_mi );
  
 +    libvlc_exception_init( &p_e );
      p_input_thread = libvlc_get_input_thread( p_mi, &p_e );
  
      if( libvlc_exception_raised( &p_e ) )
 -    {
 -        libvlc_event_manager_release( p_mi->p_event_manager );
 +        /* no need to worry about no input thread */
          libvlc_exception_clear( &p_e );
 -        free( p_mi );
 -        return; /* no need to worry about no input thread */
 -    }
 -    vlc_mutex_destroy( &p_mi->object_lock );
 -
 -    vlc_object_release( p_input_thread );
 -
 -    libvlc_media_release( p_mi->p_md );
 +    else
 +        release_input_thread( p_mi, true );
  
 +    libvlc_event_manager_release( p_mi->p_event_manager );
 +    if( p_mi->p_md )
 +        libvlc_media_release( p_mi->p_md );
 +    vlc_mutex_destroy( &p_mi->object_lock );
      free( p_mi );
  }
  
   **************************************************************************/
  void libvlc_media_player_release( libvlc_media_player_t *p_mi )
  {
 -    if( !p_mi )
 -        return;
 +    bool destroy;
  
 +    assert( p_mi );
      vlc_mutex_lock( &p_mi->object_lock );
 -
 -    p_mi->i_refcount--;
 -
 -    if( p_mi->i_refcount > 0 )
 -    {
 -        vlc_mutex_unlock( &p_mi->object_lock );
 -        return;
 -    }
 +    destroy = !--p_mi->i_refcount;
      vlc_mutex_unlock( &p_mi->object_lock );
 -    vlc_mutex_destroy( &p_mi->object_lock );
 -
 -    release_input_thread( p_mi, true );
  
 -    libvlc_event_manager_release( p_mi->p_event_manager );
 -
 -    libvlc_media_release( p_mi->p_md );
 -
 -    free( p_mi );
 +    if( destroy )
 +        libvlc_media_player_destroy( p_mi );
  }
  
  /**************************************************************************
@@@ -660,17 -711,31 +660,17 @@@ void libvlc_media_player_stop( libvlc_m
          libvlc_event_send( p_mi->p_event_manager, &event );
      }
  
 -    if( p_mi->b_own_its_input_thread )
 -    {
 -        vlc_mutex_lock( &p_mi->object_lock );
 -        release_input_thread( p_mi, true ); /* This will stop the input thread */
 -        vlc_mutex_unlock( &p_mi->object_lock );
 -    }
 -    else
 -    {
 -        input_thread_t * p_input_thread = libvlc_get_input_thread( p_mi, p_e );
 -
 -        if( !p_input_thread )
 -            return;
 -
 -        input_Stop( p_input_thread, true );
 -        vlc_object_release( p_input_thread );
 -        p_mi->p_input_thread = NULL;
 -    }
 +    vlc_mutex_lock( &p_mi->object_lock );
 +    release_input_thread( p_mi, true ); /* This will stop the input thread */
 +    vlc_mutex_unlock( &p_mi->object_lock );
  }
  
  /**************************************************************************
   * set_nsobject
   **************************************************************************/
  void libvlc_media_player_set_nsobject( libvlc_media_player_t *p_mi,
 -                                                               void * drawable,
 -                                                               libvlc_exception_t *p_e )
 +                                        void * drawable,
 +                                        libvlc_exception_t *p_e )
  {
      (void) p_e;
      p_mi->drawable.nsobject = drawable;
@@@ -1176,7 -1241,10 +1176,10 @@@ libvlc_track_description_t 
      var_Change( p_input, psz_variable, VLC_VAR_GETLIST, &val_list, &text_list);
  
      if( val_list.p_list->i_count <= 0 ) /* no tracks */
+     {
+         var_Change( p_input, psz_variable, VLC_VAR_FREELIST, &val_list, &text_list);
          return NULL;
+     }
  
      libvlc_track_description_t *p_track_description, *p_actual, *p_previous;
      p_track_description = ( libvlc_track_description_t * )
diff --combined src/control/video.c
index fd62e005a72deb7e165116d887fa2994e2d7b3f9,939ed5941783135e87d7189cc77e598edf4c2c09..f43a81556d1a0f3e71404b1695f70e6736508ce0
@@@ -107,28 -107,28 +107,28 @@@ voi
  libvlc_video_take_snapshot( libvlc_media_player_t *p_mi, const char *psz_filepath,
          unsigned int i_width, unsigned int i_height, libvlc_exception_t *p_e )
  {
-     vout_thread_t *p_vout = GetVout( p_mi, p_e );
-     input_thread_t *p_input_thread;
-     /* GetVout will raise the exception for us */
-     if( !p_vout ) return;
+     vout_thread_t *p_vout;
  
+     /* The filepath must be not NULL */
      if( !psz_filepath )
      {
          libvlc_exception_raise( p_e, "filepath is null" );
          return;
      }
-     var_SetInteger( p_vout, "snapshot-width", i_width );
-     var_SetInteger( p_vout, "snapshot-height", i_height );
-     p_input_thread = p_mi->p_input_thread;
+     /* We must have an input */
      if( !p_mi->p_input_thread )
      {
          libvlc_exception_raise( p_e, "Input does not exist" );
          return;
      }
  
+     /* GetVout will raise the exception for us */
+     p_vout = GetVout( p_mi, p_e );
+     if( !p_vout ) return;
+     var_SetInteger( p_vout, "snapshot-width", i_width );
+     var_SetInteger( p_vout, "snapshot-height", i_height );
      var_SetString( p_vout, "snapshot-path", psz_filepath );
      var_SetString( p_vout, "snapshot-format", "png" );
  
@@@ -187,6 -187,157 +187,6 @@@ int libvlc_media_player_has_vout( libvl
      return has_vout;
  }
  
 -int libvlc_video_reparent( libvlc_media_player_t *p_mi, libvlc_drawable_t d,
 -                           libvlc_exception_t *p_e )
 -{
 -    (void) p_mi; (void) d;
 -    libvlc_exception_raise(p_e, "Reparenting not supported");
 -    return -1;
 -}
 -
 -void libvlc_video_resize( libvlc_media_player_t *p_mi, int width, int height, libvlc_exception_t *p_e )
 -{
 -    vout_thread_t *p_vout = GetVout( p_mi, p_e );
 -    if( p_vout )
 -    {
 -        vout_Control( p_vout, VOUT_SET_SIZE, width, height );
 -        vlc_object_release( p_vout );
 -    }
 -}
 -
 -void libvlc_video_redraw_rectangle( libvlc_media_player_t *p_mi,
 -                           const libvlc_rectangle_t *area,
 -                           libvlc_exception_t *p_e )
 -{
 -#ifdef __APPLE__
 -    if( (NULL != area)
 -     && ((area->bottom - area->top) > 0)
 -     && ((area->right - area->left) > 0) )
 -    {
 -        vout_thread_t *p_vout = GetVout( p_mi, p_e );
 -        if( p_vout )
 -        {
 -            /* tell running vout to redraw area */
 -            vout_Control( p_vout , VOUT_REDRAW_RECT,
 -                               area->top, area->left, area->bottom, area->right );
 -            vlc_object_release( p_vout );
 -        }
 -    }
 -#else
 -    (void) p_mi; (void) area; (void) p_e;
 -#endif
 -}
 -
 -/* global video settings */
 -
 -/* Deprecated use libvlc_media_player_set_drawable() */
 -void libvlc_video_set_parent( libvlc_instance_t *p_instance, libvlc_drawable_t d,
 -                              libvlc_exception_t *p_e )
 -{
 -    /* set as default for future vout instances */
 -#ifdef WIN32
 -    vlc_value_t val;
 -
 -    if( sizeof(HWND) > sizeof(libvlc_drawable_t) )
 -        return; /* BOOM! we told you not to use this function! */
 -    val.p_address = (void *)(uintptr_t)d;
 -    var_Set( p_instance->p_libvlc_int, "drawable-hwnd", val );
 -#elif defined(__APPLE__)
 -    var_SetInteger( p_instance->p_libvlc_int, "drawable-agl", d );
 -#else
 -    var_SetInteger( p_instance->p_libvlc_int, "drawable-xid", d );
 -#endif
 -
 -    libvlc_media_player_t *p_mi = libvlc_playlist_get_media_player(p_instance, p_e);
 -    if( p_mi )
 -    {
 -        libvlc_media_player_set_drawable( p_mi, d, p_e );
 -        libvlc_media_player_release(p_mi);
 -    }
 -}
 -
 -/* Deprecated use libvlc_media_player_get_drawable() */
 -libvlc_drawable_t libvlc_video_get_parent( libvlc_instance_t *p_instance, libvlc_exception_t *p_e )
 -{
 -    VLC_UNUSED(p_e);
 -
 -#ifdef WIN32
 -    vlc_value_t val;
 -
 -    if( sizeof(HWND) > sizeof(libvlc_drawable_t) )
 -        return 0;
 -    var_Get( p_instance->p_libvlc_int, "drawable-hwnd", &val );
 -    return (uintptr_t)val.p_address;
 -#elif defined(__APPLE__)
 -    return var_GetInteger( p_instance->p_libvlc_int, "drawable-agl" );
 -#else
 -    return var_GetInteger( p_instance->p_libvlc_int, "drawable-xid" );
 -#endif
 -}
 -
 -void libvlc_video_set_size( libvlc_instance_t *p_instance, int width, int height,
 -                           libvlc_exception_t *p_e )
 -{
 -    /* set as default for future vout instances */
 -    config_PutInt(p_instance->p_libvlc_int, "width", width);
 -    config_PutInt(p_instance->p_libvlc_int, "height", height);
 -
 -    libvlc_media_player_t *p_mi = libvlc_playlist_get_media_player(p_instance, p_e);
 -    if( p_mi )
 -    {
 -        vout_thread_t *p_vout = GetVout( p_mi, p_e );
 -        if( p_vout )
 -        {
 -            /* tell running vout to re-size */
 -            vout_Control( p_vout , VOUT_SET_SIZE, width, height);
 -            vlc_object_release( p_vout );
 -        }
 -        libvlc_media_player_release(p_mi);
 -    }
 -}
 -
 -void libvlc_video_set_viewport( libvlc_instance_t *p_instance, libvlc_media_player_t *p_mi,
 -                            const libvlc_rectangle_t *view, const libvlc_rectangle_t *clip,
 -                           libvlc_exception_t *p_e )
 -{
 -#ifdef __APPLE__
 -    if( !view )
 -    {
 -        libvlc_exception_raise( p_e, "viewport is NULL" );
 -        return;
 -    }
 -
 -    /* if clip is NULL, then use view rectangle as clip */
 -    if( !clip )
 -        clip = view;
 -
 -    /* set as default for future vout instances */
 -    var_SetInteger( p_instance->p_libvlc_int, "drawable-view-top", view->top );
 -    var_SetInteger( p_instance->p_libvlc_int, "drawable-view-left", view->left );
 -    var_SetInteger( p_instance->p_libvlc_int, "drawable-view-bottom", view->bottom );
 -    var_SetInteger( p_instance->p_libvlc_int, "drawable-view-right", view->right );
 -    var_SetInteger( p_instance->p_libvlc_int, "drawable-clip-top", clip->top );
 -    var_SetInteger( p_instance->p_libvlc_int, "drawable-clip-left", clip->left );
 -    var_SetInteger( p_instance->p_libvlc_int, "drawable-clip-bottom", clip->bottom );
 -    var_SetInteger( p_instance->p_libvlc_int, "drawable-clip-right", clip->right );
 -
 -    if( p_mi )
 -    {
 -        vout_thread_t *p_vout = GetVout( p_mi, p_e );
 -        if( p_vout )
 -        {
 -            /* change viewport for running vout */
 -            vout_Control( p_vout, VOUT_SET_VIEWPORT,
 -                               view->top, view->left, view->bottom, view->right,
 -                               clip->top, clip->left, clip->bottom, clip->right );
 -            vlc_object_release( p_vout );
 -        }
 -    }
 -#else
 -    (void) p_instance; (void) p_mi; (void) view; (void) clip; (void) p_e;
 -#endif
 -}
 -
  float libvlc_video_get_scale( libvlc_media_player_t *p_mp,
                                libvlc_exception_t *p_e )
  {
@@@ -266,13 -417,13 +266,13 @@@ int libvlc_video_get_spu( libvlc_media_
      var_Change( p_input_thread, "spu-es", VLC_VAR_GETCHOICES, &val_list, NULL );
      for( i = 0; i < val_list.p_list->i_count; i++ )
      {
-         vlc_value_t spu_val = val_list.p_list->p_values[i];
-         if( val.i_int == spu_val.i_int )
+         if( val.i_int == val_list.p_list->p_values[i].i_int )
          {
              i_spu = i;
              break;
          }
      }
+     var_Change( p_input_thread, "spu-es", VLC_VAR_FREELIST, &val_list, NULL );
      vlc_object_release( p_input_thread );
      return i_spu;
  }
@@@ -282,13 -433,17 +282,17 @@@ int libvlc_video_get_spu_count( libvlc_
  {
      input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi, p_e );
      vlc_value_t val_list;
+     int i_spu_count;
  
      if( !p_input_thread )
          return -1;
  
      var_Change( p_input_thread, "spu-es", VLC_VAR_GETCHOICES, &val_list, NULL );
+     i_spu_count = val_list.p_list->i_count;
+     var_Change( p_input_thread, "spu-es", VLC_VAR_FREELIST, &val_list, NULL );
      vlc_object_release( p_input_thread );
-     return val_list.p_list->i_count;
+     return i_spu_count;
  }
  
  libvlc_track_description_t *
@@@ -313,15 -468,13 +317,13 @@@ void libvlc_video_set_spu( libvlc_media
      if( val_list.p_list->i_count == 0 )
      {
          libvlc_exception_raise( p_e, "Subtitle value out of range" );
-         vlc_object_release( p_input_thread );
-         return;
+         goto end;
      }
  
      if( (i_spu < 0) && (i_spu > val_list.p_list->i_count) )
      {
          libvlc_exception_raise( p_e, "Subtitle value out of range" );
-         vlc_object_release( p_input_thread );
-         return;
+         goto end;
      }
  
      newval = val_list.p_list->p_values[i_spu];
      {
          libvlc_exception_raise( p_e, "Setting subtitle value failed" );
      }
+ end:
+     var_Change( p_input_thread, "spu-es", VLC_VAR_FREELIST, &val_list, NULL );
      vlc_object_release( p_input_thread );
  }
  
@@@ -502,13 -658,17 +507,17 @@@ int libvlc_video_get_track_count( libvl
  {
      input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi, p_e );
      vlc_value_t val_list;
+     int i_track_count;
  
      if( !p_input_thread )
          return -1;
  
      var_Change( p_input_thread, "video-es", VLC_VAR_GETCHOICES, &val_list, NULL );
+     i_track_count = val_list.p_list->i_count;
+     var_Change( p_input_thread, "video-es", VLC_VAR_FREELIST, &val_list, NULL );
      vlc_object_release( p_input_thread );
-     return val_list.p_list->i_count;
+     return i_track_count;
  }
  
  libvlc_track_description_t *
@@@ -542,13 -702,13 +551,13 @@@ int libvlc_video_get_track( libvlc_medi
      var_Change( p_input_thread, "video-es", VLC_VAR_GETCHOICES, &val_list, NULL );
      for( i = 0; i < val_list.p_list->i_count; i++ )
      {
-         vlc_value_t track_val = val_list.p_list->p_values[i];
-         if( track_val.i_int == val.i_int )
+         if( val_list.p_list->p_values[i].i_int == val.i_int )
          {
              i_track = i;
              break;
-        }
+         }
      }
+     var_Change( p_input_thread, "video-es", VLC_VAR_FREELIST, &val_list, NULL );
      vlc_object_release( p_input_thread );
      return i_track;
  }
@@@ -573,10 -733,23 +582,12 @@@ void libvlc_video_set_track( libvlc_med
              i_ret = var_Set( p_input_thread, "audio-es", val );
              if( i_ret < 0 )
                  libvlc_exception_raise( p_e, "Setting video track failed" );
-             vlc_object_release( p_input_thread );
-             return;
+             goto end;
          }
      }
      libvlc_exception_raise( p_e, "Video track out of range" );
+ end:
+     var_Change( p_input_thread, "video-es", VLC_VAR_FREELIST, &val_list, NULL );
      vlc_object_release( p_input_thread );
  }
 -
 -int libvlc_video_destroy( libvlc_media_player_t *p_mi,
 -                          libvlc_exception_t *p_e )
 -{
 -    vout_thread_t *p_vout = GetVout( p_mi, p_e );
 -    vlc_object_detach( p_vout );
 -    vlc_object_release( p_vout );
 -    vlc_object_release( p_vout );
 -
 -    return 0;
 -}
index f7fd544ef90c07c8a7da882c47e08edd59be7e78,cae5b040959b483053dd7d63128fa612209370ac..6afec4a26cd504a792a4a00c0d49eee9b8d3be1f
  #include "fetcher.h"
  #include "preparser.h"
  
+ typedef struct playlist_services_discovery_support_t {
+     /* the playlist items for category and onelevel */
+     playlist_item_t      *p_cat;
+     playlist_item_t      *p_one;
+     services_discovery_t *p_sd; /**< Loaded service discovery modules */
+     char                 *psz_name;
+ } vlc_sd_internal_t;
  typedef struct playlist_private_t
  {
      playlist_t           public_data;
      playlist_item_array_t items_to_delete; /**< Array of items and nodes to
              delete... At the very end. This sucks. */
  
-     struct playlist_services_discovery_support_t {
-         /* the playlist items for category and onelevel */
-         playlist_item_t*    p_cat;
-         playlist_item_t*    p_one;
-         services_discovery_t * p_sd; /**< Loaded service discovery modules */
-     } ** pp_sds;
+     vlc_sd_internal_t   **pp_sds;
      int                   i_sds;   /**< Number of service discovery modules */
      input_thread_t *      p_input;  /**< the input thread associated
                                       * with the current item */
@@@ -135,11 -139,10 +139,11 @@@ playlist_item_t * playlist_NodeAddInput
  
  /* Tree walking */
  playlist_item_t *playlist_ItemFindFromInputAndRoot( playlist_t *p_playlist,
 -                                   int i_input_id, playlist_item_t *p_root,
 -                                   bool );
 +                                input_item_t *p_input, playlist_item_t *p_root,
 +                                bool );
  
 -int playlist_DeleteFromInputInParent( playlist_t *, int, playlist_item_t *, bool );
 +int playlist_DeleteFromInputInParent( playlist_t *, input_item_t *,
 +                                      playlist_item_t *, bool );
  int playlist_DeleteFromItemId( playlist_t*, int );
  int playlist_ItemRelease( playlist_item_t * );
  
index 2baa5453f8743b025cbb4eec8b6c007af431bde8,03c9f0de91d07a7558ce652a49effbe8d57d8591..aaa46688b63709a1d3848a2f412248f80a49858d
@@@ -213,13 -213,13 +213,13 @@@ static void playlist_sd_item_removed( c
       * XXX: Why don't we have a function to ensure that in the playlist code ? */
      playlist_Lock( p_parent->p_playlist );
      p_pl_item = playlist_ItemFindFromInputAndRoot( p_parent->p_playlist,
 -            p_input->i_id, p_parent, false );
 +            p_input, p_parent, false );
  
      if( p_pl_item && p_pl_item->i_children > -1 )
          playlist_NodeDelete( p_parent->p_playlist, p_pl_item, true, false );
      else
          /* Delete the non-node item normally */
 -        playlist_DeleteFromInputInParent( p_parent->p_playlist, p_input->i_id,
 +        playlist_DeleteFromInputInParent( p_parent->p_playlist, p_input,
                                            p_parent, pl_Locked );
  
      playlist_Unlock( p_parent->p_playlist );
@@@ -289,6 -289,7 +289,7 @@@ int playlist_ServicesDiscoveryAdd( play
      p_sds->p_sd = p_sd;
      p_sds->p_one = p_one;
      p_sds->p_cat = p_cat;
+     p_sds->psz_name = strdup( psz_module );
  
      PL_LOCK;
      TAB_APPEND( pl_priv(p_playlist)->i_sds, pl_priv(p_playlist)->pp_sds, p_sds );
  }
  
  int playlist_ServicesDiscoveryRemove( playlist_t * p_playlist,
-                                       const char *psz_module )
+                                       const char *psz_name )
  {
+     playlist_private_t *priv = pl_priv( p_playlist );
      struct playlist_services_discovery_support_t * p_sds = NULL;
-     int i;
  
      PL_LOCK;
-     for( i = 0 ; i< pl_priv(p_playlist)->i_sds ; i ++ )
+     for( int i = 0; i < priv->i_sds; i++ )
      {
-         if( !strcmp( psz_module, module_get_object( pl_priv(p_playlist)->pp_sds[i]->p_sd->p_module ) ) )
+         if( !strcmp( psz_name, priv->pp_sds[i]->psz_name ) )
          {
-             p_sds = pl_priv(p_playlist)->pp_sds[i];
-             REMOVE_ELEM( pl_priv(p_playlist)->pp_sds, pl_priv(p_playlist)->i_sds, i );
+             p_sds = priv->pp_sds[i];
+             REMOVE_ELEM( priv->pp_sds, priv->i_sds, i );
              break;
          }
      }
  
      if( !p_sds )
      {
-         msg_Warn( p_playlist, "module %s is not loaded", psz_module );
+         msg_Warn( p_playlist, "discovery %s is not loaded", psz_name );
          return VLC_EGENERIC;
      }
  
      PL_UNLOCK;
  
      vlc_sd_Destroy( p_sd );
+     free( p_sds->psz_name );
      free( p_sds );
  
      return VLC_SUCCESS;
  }
  
  bool playlist_IsServicesDiscoveryLoaded( playlist_t * p_playlist,
-                                               const char *psz_module )
+                                          const char *psz_name )
  {
-     int i;
+     playlist_private_t *priv = pl_priv( p_playlist );
+     bool found = false;
      PL_LOCK;
  
-     for( i = 0 ; i< pl_priv(p_playlist)->i_sds ; i ++ )
+     for( int i = 0; i < priv->i_sds; i++ )
      {
-         if( !strcmp( psz_module, module_get_object( pl_priv(p_playlist)->pp_sds[i]->p_sd->p_module ) ) )
+         vlc_sd_internal_t *sd = priv->pp_sds[i];
+         if( sd->psz_name && !strcmp( psz_name, sd->psz_name ) )
          {
-             PL_UNLOCK;
-             return true;
+             found = true;
+             break;
          }
      }
      PL_UNLOCK;
-     return false;
+     return found;
  }
  
  void playlist_ServicesDiscoveryKillAll( playlist_t *p_playlist )
  {
-     while( pl_priv(p_playlist)->i_sds > 0 )
+     playlist_private_t *priv = pl_priv( p_playlist );
+     while( priv->i_sds > 0 )
          playlist_ServicesDiscoveryRemove( p_playlist,
-                                           module_get_object( pl_priv(p_playlist)->pp_sds[0]->p_sd->p_module ) );
+                                           priv->pp_sds[0]->psz_name );
  }
index f01fd264f8773875d828718e3add462fa5b04ae4,3c932f69856ca7315c1a3db263b412f0b4a616e0..c090c111fc1394d24c50f11260946a24204890d4
@@@ -208,7 -208,7 +208,7 @@@ vout_thread_t *__vout_Request( vlc_obje
              free( psz_filter_chain );
          }
  
 -        if( p_vout->fmt_render.i_chroma != p_fmt->i_chroma ||
 +        if( p_vout->fmt_render.i_chroma != vlc_fourcc_GetCodec( VIDEO_ES, p_fmt->i_chroma ) ||
              p_vout->fmt_render.i_width != p_fmt->i_width ||
              p_vout->fmt_render.i_height != p_fmt->i_height ||
              p_vout->p->b_filter_change )
@@@ -303,7 -303,7 +303,7 @@@ vout_thread_t * __vout_Create( vlc_obje
  
      unsigned int i_width = p_fmt->i_width;
      unsigned int i_height = p_fmt->i_height;
 -    vlc_fourcc_t i_chroma = p_fmt->i_chroma;
 +    vlc_fourcc_t i_chroma = vlc_fourcc_GetCodec( VIDEO_ES, p_fmt->i_chroma );
      unsigned int i_aspect = p_fmt->i_aspect;
  
      config_chain_t *p_cfg;
@@@ -816,10 -816,10 +816,10 @@@ static bool ChromaIsEqual( const pictur
       if( !vout_ChromaCmp( p_output->i_chroma, p_render->i_chroma ) )
           return false;
  
 -     if( p_output->i_chroma != FOURCC_RV15 &&
 -         p_output->i_chroma != FOURCC_RV16 &&
 -         p_output->i_chroma != FOURCC_RV24 &&
 -         p_output->i_chroma != FOURCC_RV32 )
 +     if( p_output->i_chroma != VLC_CODEC_RGB15 &&
 +         p_output->i_chroma != VLC_CODEC_RGB16 &&
 +         p_output->i_chroma != VLC_CODEC_RGB24 &&
 +         p_output->i_chroma != VLC_CODEC_RGB32 )
           return true;
  
       return p_output->i_rmask == p_render->i_rmask &&
@@@ -983,6 -983,17 +983,6 @@@ static int InitThread( vout_thread_t *p
          }
      }
  
 -    /* Link pictures back to their heap */
 -    for( i = 0 ; i < I_RENDERPICTURES ; i++ )
 -    {
 -        PP_RENDERPICTURE[ i ]->p_heap = &p_vout->render;
 -    }
 -
 -    for( i = 0 ; i < I_OUTPUTPICTURES ; i++ )
 -    {
 -        PP_OUTPUTPICTURE[ i ]->p_heap = &p_vout->output;
 -    }
 -
      return VLC_SUCCESS;
  }
  
@@@ -1916,7 -1927,8 +1916,8 @@@ static int DeinterlaceCallback( vlc_obj
      const deinterlace_mode_t *p_mode;
      for( p_mode = &p_deinterlace_mode[0]; p_mode->psz_mode; p_mode++ )
      {
-         if( !strcmp( p_mode->psz_mode, newval.psz_string ?: "" ) )
+         if( !strcmp( p_mode->psz_mode,
+                      newval.psz_string ? newval.psz_string : "" ) )
              break;
      }
      if( !p_mode->psz_mode )
@@@ -2012,7 -2024,7 +2013,7 @@@ static void DeinterlaceEnable( vout_thr
          else if( DeinterlaceIsPresent( p_vout, false ) )
              psz_mode = var_CreateGetNonEmptyString( p_vout, "sout-deinterlace-mode" );
      }
-     var_SetString( p_vout, "deinterlace", psz_mode ?: "" );
+     var_SetString( p_vout, "deinterlace", psz_mode ? psz_mode : "" );
      free( psz_mode );
  }