]> git.sesse.net Git - vlc/commitdiff
Merge commit 'origin/1.0-bugfix'
authorJean-Baptiste Kempf <jb@videolan.org>
Mon, 25 May 2009 23:57:08 +0000 (01:57 +0200)
committerJean-Baptiste Kempf <jb@videolan.org>
Mon, 25 May 2009 23:57:08 +0000 (01:57 +0200)
1  2 
NEWS
modules/video_output/snapshot.c
src/video_output/video_output.c
src/video_output/vout_pictures.c

diff --combined NEWS
index 433a682930f145e312f1dd1b8898b376d391cf1e,06ff7e1ae3cffb81dd4ccf2aa650c18a39d2561d..ec2eae6496b07f9d646898e6f5098e242de5f95e
--- 1/NEWS
--- 2/NEWS
+++ b/NEWS
@@@ -1,18 -1,10 +1,18 @@@
- Changes between 0.9.9a and 1.0.0-rc1:
 +Changes between 1.0.0-rc1 and 1.1.0-git:
 +----------------------------------------
 +
 +Mac OS X Interface:
 + * Completely reworked user interface (based upon works from GSoC 2008)
 +
 +
+ Changes between 0.9.9a and 1.0.0-rc2:
  ------------------------------------
  
  Important notes:
  ----------------
   * Alsa and OSS audio capture has been removed from the v4l and v4l2 accesses.
     See 'Access:' for more info.
 + * Support for Mac OS X 10.4.x was dropped due to its technical limitations
  
  Playback:
   * Instantaneous pausing
@@@ -109,8 -101,8 +109,8 @@@ Windows CE Port
   EXPERIMENTAL work for the winCE port has been done.
  
  Mac OS X Port:
 - * Support for Mac OS X 10.4.x was dropped due to its technical limitations
   * Speed improvements by using llvm-gcc
 + * New Document icons by Dominic Spitaler
  
  Audio output:
   * Removed obsolete Esound and aRts plugins
index 5b6c4c330add7296b59898af02ab7ea4430109ed,2fc7c2af8f89885436fb48481c887723fef1b57a..411f1e56150ea038d79d906bc23c71ea39c16b2f
   * keep a cache of low-res snapshots.
   * The snapshot structure is defined in include/snapshot.h
   * In order to access the current snapshot cache, object variables are used:
-  *   snapshot-list-pointer : the pointer on the first element in the list
-  *   snapshot-datasize     : size of a snapshot
+  *   vout-snapshot-list-pointer : the pointer on the first element in the list
+  *   vout-snapshot-datasize     : size of a snapshot
   *                           (also available in snapshot_t->i_datasize)
-  *   snapshot-cache-size   : size of the cache list
+  *   vout-snapshot-cache-size   : size of the cache list
   *
   * It is used for the moment by the CORBA module and a specialized
   * python-vlc binding.
@@@ -84,10 -84,12 +84,12 @@@ vlc_module_begin (
      set_subcategory( SUBCAT_VIDEO_VOUT )
      set_capability( "video output", 1 )
  
-     add_integer( "snapshot-width", 320, NULL, WIDTH_TEXT, WIDTH_LONGTEXT, false )
-     add_integer( "snapshot-height", 200, NULL, HEIGHT_TEXT, HEIGHT_LONGTEXT, false )
-     add_string( "snapshot-chroma", "RV32", NULL, CHROMA_TEXT, CHROMA_LONGTEXT, true )
-     add_integer( "snapshot-cache-size", 50, NULL, CACHE_TEXT, CACHE_LONGTEXT, true )
+     add_integer( "vout-snapshot-width", 320, NULL, WIDTH_TEXT, WIDTH_LONGTEXT, false )
+     add_integer( "vout-snapshot-height", 200, NULL, HEIGHT_TEXT, HEIGHT_LONGTEXT, false )
+     add_string( "vout-snapshot-chroma", "RV32", NULL, CHROMA_TEXT, CHROMA_LONGTEXT, true )
+         add_deprecated_alias( "snapshot-chroma" )
+     add_integer( "vout-snapshot-cache-size", 50, NULL, CACHE_TEXT, CACHE_LONGTEXT, true )
+         add_deprecated_alias( "snapshot-cache-size" )
  
      set_callbacks( Create, Destroy )
  vlc_module_end ()
@@@ -128,11 -130,11 +130,11 @@@ static int Create( vlc_object_t *p_thi
      if( ! p_vout->p_sys )
          return VLC_ENOMEM;
  
-     var_Create( p_vout, "snapshot-width", VLC_VAR_INTEGER );
-     var_Create( p_vout, "snapshot-height", VLC_VAR_INTEGER );
-     var_Create( p_vout, "snapshot-datasize", VLC_VAR_INTEGER );
-     var_Create( p_vout, "snapshot-cache-size", VLC_VAR_INTEGER );
-     var_Create( p_vout, "snapshot-list-pointer", VLC_VAR_ADDRESS );
+     var_Create( p_vout, "vout-snapshot-width", VLC_VAR_INTEGER );
+     var_Create( p_vout, "vout-snapshot-height", VLC_VAR_INTEGER );
+     var_Create( p_vout, "vout-snapshot-datasize", VLC_VAR_INTEGER );
+     var_Create( p_vout, "vout-snapshot-cache-size", VLC_VAR_INTEGER );
+     var_Create( p_vout, "vout-snapshot-list-pointer", VLC_VAR_ADDRESS );
  
      p_vout->pf_init = Init;
      p_vout->pf_end = End;
@@@ -152,27 -154,29 +154,33 @@@ static int Init( vout_thread_t *p_vout 
      picture_t *p_pic;
      vlc_value_t val;
      char* psz_chroma;
 -    int i_chroma;
 +    vlc_fourcc_t i_chroma;
      int i_width;
      int i_height;
      int i_datasize;
  
-     i_width  = config_GetInt( p_vout, "snapshot-width" );
-     i_height = config_GetInt( p_vout, "snapshot-height" );
+     i_width  = config_GetInt( p_vout, "vout-snapshot-width" );
+     i_height = config_GetInt( p_vout, "vout-snapshot-height" );
  
-     psz_chroma = config_GetPsz( p_vout, "snapshot-chroma" );
-     if( !psz_chroma )
+     psz_chroma = config_GetPsz( p_vout, "vout-snapshot-chroma" );
+     if( psz_chroma )
      {
-         msg_Err( p_vout, "Cannot find chroma information." );
-         return VLC_EGENERIC;
+         if( strlen( psz_chroma ) < 4 )
+         {
+             msg_Err( p_vout, "vout-snapshot-chroma should be 4 characters long" );
+             return VLC_EGENERIC;
+         }
+         i_chroma = VLC_FOURCC( psz_chroma[0], psz_chroma[1],
+                                psz_chroma[2], psz_chroma[3] );
+         free( psz_chroma );
      }
 -    else
 +
 +    i_chroma = vlc_fourcc_GetCodecFromString( VIDEO_ES, psz_chroma );
 +    free( psz_chroma );
 +
 +    if( !i_chroma )
      {
 -        msg_Err( p_vout, "Cannot find chroma information." );
 +        msg_Err( p_vout, "snapshot-chroma should be 4 characters long" );
          return VLC_EGENERIC;
      }
  
      /* Define the bitmasks */
      switch( i_chroma )
      {
 -      case VLC_FOURCC( 'R','V','1','5' ):
 +      case VLC_CODEC_RGB15:
          p_vout->output.i_rmask = 0x001f;
          p_vout->output.i_gmask = 0x03e0;
          p_vout->output.i_bmask = 0x7c00;
          break;
  
 -      case VLC_FOURCC( 'R','V','1','6' ):
 +      case VLC_CODEC_RGB16:
          p_vout->output.i_rmask = 0x001f;
          p_vout->output.i_gmask = 0x07e0;
          p_vout->output.i_bmask = 0xf800;
          break;
  
 -      case VLC_FOURCC( 'R','V','2','4' ):
 +      case VLC_CODEC_RGB24:
          p_vout->output.i_rmask = 0xff0000;
          p_vout->output.i_gmask = 0x00ff00;
          p_vout->output.i_bmask = 0x0000ff;
          break;
  
 -      case VLC_FOURCC( 'R','V','3','2' ):
 +      case VLC_CODEC_RGB32:
          p_vout->output.i_rmask = 0xff0000;
          p_vout->output.i_gmask = 0x00ff00;
          p_vout->output.i_bmask = 0x0000ff;
  
      p_vout->p_sys->i_datasize = i_datasize;
      p_vout->p_sys->i_index = 0;
-     p_vout->p_sys->i_size = config_GetInt( p_vout, "snapshot-cache-size" );
+     p_vout->p_sys->i_size = config_GetInt( p_vout, "vout-snapshot-cache-size" );
  
      if( p_vout->p_sys->i_size < 2 )
      {
-         msg_Err( p_vout, "snapshot-cache-size must be at least 1." );
+         msg_Err( p_vout, "vout-snapshot-cache-size must be at least 1." );
          return VLC_EGENERIC;
      }
  
      }
  
      val.i_int = i_width;
-     var_Set( p_vout, "snapshot-width", val );
+     var_Set( p_vout, "vout-snapshot-width", val );
      val.i_int = i_height;
-     var_Set( p_vout, "snapshot-height", val );
+     var_Set( p_vout, "vout-snapshot-height", val );
      val.i_int = i_datasize;
-     var_Set( p_vout, "snapshot-datasize", val );
+     var_Set( p_vout, "vout-snapshot-datasize", val );
  
      val.i_int = p_vout->p_sys->i_size;
-     var_Set( p_vout, "snapshot-cache-size", val );
+     var_Set( p_vout, "vout-snapshot-cache-size", val );
  
      val.p_address = p_vout->p_sys->p_list;
-     var_Set( p_vout, "snapshot-list-pointer", val );
+     var_Set( p_vout, "vout-snapshot-list-pointer", val );
  
      /* Get the p_input pointer (to access video times) */
      p_vout->p_sys->p_input = vlc_object_find( p_vout, VLC_OBJECT_INPUT,
      if( !p_vout->p_sys->p_input )
          return VLC_ENOOBJ;
  
-     if( var_Create( p_vout->p_sys->p_input, "snapshot-id", VLC_VAR_INTEGER ) )
+     if( var_Create( p_vout->p_sys->p_input, "vout-snapshot-id", VLC_VAR_INTEGER ) )
      {
-         msg_Err( p_vout, "Cannot create snapshot-id variable in p_input(%p).",
+         msg_Err( p_vout, "Cannot create vout-snapshot-id variable in p_input(%p).",
                   p_vout->p_sys->p_input );
          return VLC_EGENERIC;
      }
      /* Register the snapshot vout module at the input level */
      val.p_address = p_vout;
  
-     if( var_Set( p_vout->p_sys->p_input, "snapshot-id", val ) )
+     if( var_Set( p_vout->p_sys->p_input, "vout-snapshot-id", val ) )
      {
-         msg_Err( p_vout, "Cannot register snapshot-id in p_input(%p).",
+         msg_Err( p_vout, "Cannot register vout-snapshot-id in p_input(%p).",
                   p_vout->p_sys->p_input );
          return VLC_EGENERIC;
      }
@@@ -348,12 -352,12 +356,12 @@@ static void Destroy( vlc_object_t *p_th
      vout_thread_t *p_vout = ( vout_thread_t * )p_this;
      int i_index;
  
-     var_Destroy( p_vout->p_sys->p_input, "snapshot-id" );
+     var_Destroy( p_vout->p_sys->p_input, "vout-snapshot-id" );
  
      vlc_object_release( p_vout->p_sys->p_input );
-     var_Destroy( p_this, "snapshot-width" );
-     var_Destroy( p_this, "snapshot-height" );
-     var_Destroy( p_this, "snapshot-datasize" );
+     var_Destroy( p_this, "vout-snapshot-width" );
+     var_Destroy( p_this, "vout-snapshot-height" );
+     var_Destroy( p_this, "vout-snapshot-datasize" );
  
      for( i_index = 0 ; i_index < p_vout->p_sys->i_size ; i_index++ )
      {
index c090c111fc1394d24c50f11260946a24204890d4,825e1d6f25ac2e92877e12460fd713f1696b754c..7555d8345cc357dd4d17e1eac810f6edce61032a
@@@ -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;
  }
  
@@@ -1202,6 -1213,9 +1202,9 @@@ static void* RunThread( void *p_this 
  
                  picture_Copy( p_pic, p_directbuffer );
  
+                 p_pic->format.i_sar_num = p_vout->fmt_out.i_sar_num;
+                 p_pic->format.i_sar_den = p_vout->fmt_out.i_sar_den;
                  p_pic->p_next = p_vout->p->snapshot.p_picture;
                  p_vout->p->snapshot.p_picture = p_pic;
                  p_vout->p->snapshot.i_request--;
index 8033f38ec6b356c8adce906879b881cde8a5a252,0f408f864187ca89dcded5e2eada7a9134fd5c01..c61fe74691cd553d8cb60a5e52c9f6aa435226b0
@@@ -408,6 -408,8 +408,6 @@@ picture_t *vout_RenderPicture( vout_thr
                                    p_vout->fmt_out.i_aspect );
              p_tmp_pic->i_type = MEMORY_PICTURE;
              p_tmp_pic->i_status = RESERVED_PICTURE;
 -            /* some modules (such as blend)  needs to know the extra information in picture heap */
 -            p_tmp_pic->p_heap = &p_vout->output;
          }
  
          /* Convert image to the first direct buffer */
@@@ -558,8 -560,8 +558,8 @@@ int __vout_AllocatePicture( vlc_object_
      i_width_aligned = (i_width + 15) >> 4 << 4;
      i_height_aligned = (i_height + 15) >> 4 << 4;
  
 -    if( vout_InitPicture( p_this, p_pic, i_chroma,
 -                          i_width, i_height, i_aspect ) != VLC_SUCCESS )
 +    if( picture_Setup( p_pic, i_chroma,
 +                       i_width, i_height, i_aspect ) != VLC_SUCCESS )
      {
          p_pic->i_planes = 0;
          return VLC_EGENERIC;
      return VLC_SUCCESS;
  }
  
 -/**
 - * Initialise the video format fields given chroma/size.
 - *
 - * This function initializes all the video_frame_format_t fields given the
 - * static properties of a picture (chroma and size).
 - * \param p_format Pointer to the format structure to initialize
 - * \param i_chroma Chroma to set
 - * \param i_width Width to set
 - * \param i_height Height to set
 - * \param i_aspect Aspect ratio
 - */
 -void vout_InitFormat( video_frame_format_t *p_format, vlc_fourcc_t i_chroma,
 -                      int i_width, int i_height, int i_aspect )
 -{
 -    p_format->i_chroma   = i_chroma;
 -    p_format->i_width    = p_format->i_visible_width  = i_width;
 -    p_format->i_height   = p_format->i_visible_height = i_height;
 -    p_format->i_x_offset = p_format->i_y_offset = 0;
 -    p_format->i_aspect   = i_aspect;
 -
 -#if 0
 -    /* Assume we have square pixels */
 -    if( i_width && i_height )
 -        p_format->i_aspect = i_width * VOUT_ASPECT_FACTOR / i_height;
 -    else
 -        p_format->i_aspect = 0;
 -#endif
 -
 -    switch( i_chroma )
 -    {
 -        case FOURCC_YUVA:
 -            p_format->i_bits_per_pixel = 32;
 -            break;
 -        case FOURCC_I444:
 -        case FOURCC_J444:
 -            p_format->i_bits_per_pixel = 24;
 -            break;
 -        case FOURCC_I422:
 -        case FOURCC_YUY2:
 -        case FOURCC_UYVY:
 -        case FOURCC_J422:
 -            p_format->i_bits_per_pixel = 16;
 -            break;
 -        case FOURCC_I440:
 -        case FOURCC_J440:
 -            p_format->i_bits_per_pixel = 16;
 -            break;
 -        case FOURCC_I411:
 -        case FOURCC_YV12:
 -        case FOURCC_I420:
 -        case FOURCC_J420:
 -        case FOURCC_IYUV:
 -            p_format->i_bits_per_pixel = 12;
 -            break;
 -        case FOURCC_I410:
 -        case FOURCC_YVU9:
 -            p_format->i_bits_per_pixel = 9;
 -            break;
 -        case FOURCC_Y211:
 -            p_format->i_bits_per_pixel = 8;
 -            break;
 -        case FOURCC_YUVP:
 -            p_format->i_bits_per_pixel = 8;
 -            break;
 -
 -        case FOURCC_RV32:
 -        case FOURCC_RGBA:
 -            p_format->i_bits_per_pixel = 32;
 -            break;
 -        case FOURCC_RV24:
 -            p_format->i_bits_per_pixel = 24;
 -            break;
 -        case FOURCC_RV15:
 -        case FOURCC_RV16:
 -            p_format->i_bits_per_pixel = 16;
 -            break;
 -        case FOURCC_RGB2:
 -            p_format->i_bits_per_pixel = 8;
 -            break;
 -
 -        case FOURCC_GREY:
 -        case FOURCC_Y800:
 -        case FOURCC_Y8:
 -        case FOURCC_RGBP:
 -            p_format->i_bits_per_pixel = 8;
 -            break;
 -
 -        default:
 -            p_format->i_bits_per_pixel = 0;
 -            break;
 -    }
 -}
 -
 -/**
 - * Initialise the picture_t fields given chroma/size.
 - *
 - * This function initializes most of the picture_t fields given a chroma and
 - * size. It makes the assumption that stride == width.
 - * \param p_this The calling object
 - * \param p_pic Pointer to the picture to initialize
 - * \param i_chroma The chroma fourcc to set
 - * \param i_width The width of the picture
 - * \param i_height The height of the picture
 - * \param i_aspect The aspect ratio of the picture
 - */
 -int __vout_InitPicture( vlc_object_t *p_this, picture_t *p_pic,
 -                        vlc_fourcc_t i_chroma,
 -                        int i_width, int i_height, int i_aspect )
 -{
 -    int i_index, i_width_aligned, i_height_aligned;
 -
 -    /* Store default values */
 -    for( i_index = 0; i_index < VOUT_MAX_PLANES; i_index++ )
 -    {
 -        p_pic->p[i_index].p_pixels = NULL;
 -        p_pic->p[i_index].i_pixel_pitch = 1;
 -    }
 -
 -    p_pic->pf_release = NULL;
 -    p_pic->pf_lock = NULL;
 -    p_pic->pf_unlock = NULL;
 -    p_pic->i_refcount = 0;
 -
 -    p_pic->i_qtype = QTYPE_NONE;
 -    p_pic->i_qstride = 0;
 -    p_pic->p_q = NULL;
 -
 -    vout_InitFormat( &p_pic->format, i_chroma, i_width, i_height, i_aspect );
 -
 -    /* Make sure the real dimensions are a multiple of 16 */
 -    i_width_aligned = (i_width + 15) >> 4 << 4;
 -    i_height_aligned = (i_height + 15) >> 4 << 4;
 -
 -    /* Calculate coordinates */
 -    switch( i_chroma )
 -    {
 -        case FOURCC_I411:
 -            p_pic->p[ Y_PLANE ].i_lines = i_height_aligned;
 -            p_pic->p[ Y_PLANE ].i_visible_lines = i_height;
 -            p_pic->p[ Y_PLANE ].i_pitch = i_width_aligned;
 -            p_pic->p[ Y_PLANE ].i_visible_pitch = i_width;
 -            p_pic->p[ U_PLANE ].i_lines = i_height_aligned;
 -            p_pic->p[ U_PLANE ].i_visible_lines = i_height;
 -            p_pic->p[ U_PLANE ].i_pitch = i_width_aligned / 4;
 -            p_pic->p[ U_PLANE ].i_visible_pitch = i_width / 4;
 -            p_pic->p[ V_PLANE ].i_lines = i_height_aligned;
 -            p_pic->p[ V_PLANE ].i_visible_lines = i_height;
 -            p_pic->p[ V_PLANE ].i_pitch = i_width_aligned / 4;
 -            p_pic->p[ V_PLANE ].i_visible_pitch = i_width / 4;
 -            p_pic->i_planes = 3;
 -            break;
 -
 -        case FOURCC_I410:
 -        case FOURCC_YVU9:
 -            p_pic->p[ Y_PLANE ].i_lines = i_height_aligned;
 -            p_pic->p[ Y_PLANE ].i_visible_lines = i_height;
 -            p_pic->p[ Y_PLANE ].i_pitch = i_width_aligned;
 -            p_pic->p[ Y_PLANE ].i_visible_pitch = i_width;
 -            p_pic->p[ U_PLANE ].i_lines = i_height_aligned / 4;
 -            p_pic->p[ U_PLANE ].i_visible_lines = i_height / 4;
 -            p_pic->p[ U_PLANE ].i_pitch = i_width_aligned / 4;
 -            p_pic->p[ U_PLANE ].i_visible_pitch = i_width / 4;
 -            p_pic->p[ V_PLANE ].i_lines = i_height_aligned / 4;
 -            p_pic->p[ V_PLANE ].i_visible_lines = i_height / 4;
 -            p_pic->p[ V_PLANE ].i_pitch = i_width_aligned / 4;
 -            p_pic->p[ V_PLANE ].i_visible_pitch = i_width / 4;
 -            p_pic->i_planes = 3;
 -            break;
 -
 -        case FOURCC_YV12:
 -        case FOURCC_I420:
 -        case FOURCC_IYUV:
 -        case FOURCC_J420:
 -            p_pic->p[ Y_PLANE ].i_lines = i_height_aligned;
 -            p_pic->p[ Y_PLANE ].i_visible_lines = i_height;
 -            p_pic->p[ Y_PLANE ].i_pitch = i_width_aligned;
 -            p_pic->p[ Y_PLANE ].i_visible_pitch = i_width;
 -            p_pic->p[ U_PLANE ].i_lines = i_height_aligned / 2;
 -            p_pic->p[ U_PLANE ].i_visible_lines = i_height / 2;
 -            p_pic->p[ U_PLANE ].i_pitch = i_width_aligned / 2;
 -            p_pic->p[ U_PLANE ].i_visible_pitch = i_width / 2;
 -            p_pic->p[ V_PLANE ].i_lines = i_height_aligned / 2;
 -            p_pic->p[ V_PLANE ].i_visible_lines = i_height / 2;
 -            p_pic->p[ V_PLANE ].i_pitch = i_width_aligned / 2;
 -            p_pic->p[ V_PLANE ].i_visible_pitch = i_width / 2;
 -            p_pic->i_planes = 3;
 -            break;
 -
 -        case FOURCC_I422:
 -        case FOURCC_J422:
 -            p_pic->p[ Y_PLANE ].i_lines = i_height_aligned;
 -            p_pic->p[ Y_PLANE ].i_visible_lines = i_height;
 -            p_pic->p[ Y_PLANE ].i_pitch = i_width_aligned;
 -            p_pic->p[ Y_PLANE ].i_visible_pitch = i_width;
 -            p_pic->p[ U_PLANE ].i_lines = i_height_aligned;
 -            p_pic->p[ U_PLANE ].i_visible_lines = i_height;
 -            p_pic->p[ U_PLANE ].i_pitch = i_width_aligned / 2;
 -            p_pic->p[ U_PLANE ].i_visible_pitch = i_width / 2;
 -            p_pic->p[ V_PLANE ].i_lines = i_height_aligned;
 -            p_pic->p[ V_PLANE ].i_visible_lines = i_height;
 -            p_pic->p[ V_PLANE ].i_pitch = i_width_aligned / 2;
 -            p_pic->p[ V_PLANE ].i_visible_pitch = i_width / 2;
 -            p_pic->i_planes = 3;
 -            break;
 -
 -        case FOURCC_I440:
 -        case FOURCC_J440:
 -            p_pic->p[ Y_PLANE ].i_lines = i_height_aligned;
 -            p_pic->p[ Y_PLANE ].i_visible_lines = i_height;
 -            p_pic->p[ Y_PLANE ].i_pitch = i_width_aligned;
 -            p_pic->p[ Y_PLANE ].i_visible_pitch = i_width;
 -            p_pic->p[ U_PLANE ].i_lines = i_height_aligned / 2;
 -            p_pic->p[ U_PLANE ].i_visible_lines = i_height / 2;
 -            p_pic->p[ U_PLANE ].i_pitch = i_width_aligned;
 -            p_pic->p[ U_PLANE ].i_visible_pitch = i_width;
 -            p_pic->p[ V_PLANE ].i_lines = i_height_aligned / 2;
 -            p_pic->p[ V_PLANE ].i_visible_lines = i_height / 2;
 -            p_pic->p[ V_PLANE ].i_pitch = i_width_aligned;
 -            p_pic->p[ V_PLANE ].i_visible_pitch = i_width;
 -            p_pic->i_planes = 3;
 -            break;
 -
 -        case FOURCC_I444:
 -        case FOURCC_J444:
 -            p_pic->p[ Y_PLANE ].i_lines = i_height_aligned;
 -            p_pic->p[ Y_PLANE ].i_visible_lines = i_height;
 -            p_pic->p[ Y_PLANE ].i_pitch = i_width_aligned;
 -            p_pic->p[ Y_PLANE ].i_visible_pitch = i_width;
 -            p_pic->p[ U_PLANE ].i_lines = i_height_aligned;
 -            p_pic->p[ U_PLANE ].i_visible_lines = i_height;
 -            p_pic->p[ U_PLANE ].i_pitch = i_width_aligned;
 -            p_pic->p[ U_PLANE ].i_visible_pitch = i_width;
 -            p_pic->p[ V_PLANE ].i_lines = i_height_aligned;
 -            p_pic->p[ V_PLANE ].i_visible_lines = i_height;
 -            p_pic->p[ V_PLANE ].i_pitch = i_width_aligned;
 -            p_pic->p[ V_PLANE ].i_visible_pitch = i_width;
 -            p_pic->i_planes = 3;
 -            break;
 -
 -        case FOURCC_YUVA:
 -            p_pic->p[ Y_PLANE ].i_lines = i_height_aligned;
 -            p_pic->p[ Y_PLANE ].i_visible_lines = i_height;
 -            p_pic->p[ Y_PLANE ].i_pitch = i_width_aligned;
 -            p_pic->p[ Y_PLANE ].i_visible_pitch = i_width;
 -            p_pic->p[ U_PLANE ].i_lines = i_height_aligned;
 -            p_pic->p[ U_PLANE ].i_visible_lines = i_height;
 -            p_pic->p[ U_PLANE ].i_pitch = i_width_aligned;
 -            p_pic->p[ U_PLANE ].i_visible_pitch = i_width;
 -            p_pic->p[ V_PLANE ].i_lines = i_height_aligned;
 -            p_pic->p[ V_PLANE ].i_visible_lines = i_height;
 -            p_pic->p[ V_PLANE ].i_pitch = i_width_aligned;
 -            p_pic->p[ V_PLANE ].i_visible_pitch = i_width;
 -            p_pic->p[ A_PLANE ].i_lines = i_height_aligned;
 -            p_pic->p[ A_PLANE ].i_visible_lines = i_height;
 -            p_pic->p[ A_PLANE ].i_pitch = i_width_aligned;
 -            p_pic->p[ A_PLANE ].i_visible_pitch = i_width;
 -            p_pic->i_planes = 4;
 -            break;
 -
 -        case FOURCC_YUVP:
 -            p_pic->p->i_lines = i_height_aligned;
 -            p_pic->p->i_visible_lines = i_height;
 -            p_pic->p->i_pitch = i_width_aligned;
 -            p_pic->p->i_visible_pitch = i_width;
 -            p_pic->p->i_pixel_pitch = 8;
 -            p_pic->i_planes = 1;
 -            break;
 -
 -        case FOURCC_Y211:
 -            p_pic->p->i_lines = i_height_aligned;
 -            p_pic->p->i_visible_lines = i_height;
 -            p_pic->p->i_pitch = i_width_aligned;
 -            p_pic->p->i_visible_pitch = i_width;
 -            p_pic->p->i_pixel_pitch = 4;
 -            p_pic->i_planes = 1;
 -            break;
 -
 -        case FOURCC_UYVY:
 -        case FOURCC_YUY2:
 -            p_pic->p->i_lines = i_height_aligned;
 -            p_pic->p->i_visible_lines = i_height;
 -            p_pic->p->i_pitch = i_width_aligned * 2;
 -            p_pic->p->i_visible_pitch = i_width * 2;
 -            p_pic->p->i_pixel_pitch = 4;
 -            p_pic->i_planes = 1;
 -            break;
 -
 -        case FOURCC_RGB2:
 -            p_pic->p->i_lines = i_height_aligned;
 -            p_pic->p->i_visible_lines = i_height;
 -            p_pic->p->i_pitch = i_width_aligned;
 -            p_pic->p->i_visible_pitch = i_width;
 -            p_pic->p->i_pixel_pitch = 1;
 -            p_pic->i_planes = 1;
 -            break;
 -
 -        case FOURCC_RV15:
 -            p_pic->p->i_lines = i_height_aligned;
 -            p_pic->p->i_visible_lines = i_height;
 -            p_pic->p->i_pitch = i_width_aligned * 2;
 -            p_pic->p->i_visible_pitch = i_width * 2;
 -            p_pic->p->i_pixel_pitch = 2;
 -            p_pic->i_planes = 1;
 -            break;
 -
 -        case FOURCC_RV16:
 -            p_pic->p->i_lines = i_height_aligned;
 -            p_pic->p->i_visible_lines = i_height;
 -            p_pic->p->i_pitch = i_width_aligned * 2;
 -            p_pic->p->i_visible_pitch = i_width * 2;
 -            p_pic->p->i_pixel_pitch = 2;
 -            p_pic->i_planes = 1;
 -            break;
 -
 -        case FOURCC_RV24:
 -            p_pic->p->i_lines = i_height_aligned;
 -            p_pic->p->i_visible_lines = i_height;
 -            p_pic->p->i_pitch = i_width_aligned * 3;
 -            p_pic->p->i_visible_pitch = i_width * 3;
 -            p_pic->p->i_pixel_pitch = 3;
 -            p_pic->i_planes = 1;
 -            break;
 -
 -        case FOURCC_RV32:
 -        case FOURCC_RGBA:
 -            p_pic->p->i_lines = i_height_aligned;
 -            p_pic->p->i_visible_lines = i_height;
 -            p_pic->p->i_pitch = i_width_aligned * 4;
 -            p_pic->p->i_visible_pitch = i_width * 4;
 -            p_pic->p->i_pixel_pitch = 4;
 -            p_pic->i_planes = 1;
 -            break;
 -
 -        case FOURCC_GREY:
 -        case FOURCC_Y800:
 -        case FOURCC_Y8:
 -        case FOURCC_RGBP:
 -            p_pic->p->i_lines = i_height_aligned;
 -            p_pic->p->i_visible_lines = i_height;
 -            p_pic->p->i_pitch = i_width_aligned;
 -            p_pic->p->i_visible_pitch = i_width;
 -            p_pic->p->i_pixel_pitch = 1;
 -            p_pic->i_planes = 1;
 -            break;
 -
 -        default:
 -            if( p_this )
 -                msg_Err( p_this, "unknown chroma type 0x%.8x (%4.4s)",
 -                                 i_chroma, (char*)&i_chroma );
 -            p_pic->i_planes = 0;
 -            return VLC_EGENERIC;
 -    }
 -
 -    return VLC_SUCCESS;
 -}
 -
  /**
   * Compare two chroma values
   *
  int vout_ChromaCmp( vlc_fourcc_t i_chroma, vlc_fourcc_t i_amorhc )
  {
      static const vlc_fourcc_t p_I420[] = {
 -        FOURCC_I420, FOURCC_IYUV, FOURCC_YV12, FOURCC_J420, 0
 +        VLC_CODEC_I420, VLC_CODEC_YV12, VLC_CODEC_J420, 0
      };
      static const vlc_fourcc_t p_I422[] = {
 -        FOURCC_I422, FOURCC_J422, 0
 +        VLC_CODEC_I422, VLC_CODEC_J422, 0
      };
      static const vlc_fourcc_t p_I440[] = {
 -        FOURCC_I440, FOURCC_J440, 0
 +        VLC_CODEC_I440, VLC_CODEC_J440, 0
      };
      static const vlc_fourcc_t p_I444[] = {
 -        FOURCC_I444, FOURCC_J444, 0
 -    };
 -    static const vlc_fourcc_t p_UYVY[] = {
 -        FOURCC_UYVY, FOURCC_UYNV, FOURCC_Y422, 0
 -    };
 -    static const vlc_fourcc_t p_YUYV[] = {
 -        FOURCC_YUY2, FOURCC_YUNV, 0
 -    };
 -    static const vlc_fourcc_t p_GREY[] = {
 -        FOURCC_GREY, FOURCC_Y800, FOURCC_Y8, 0
 +        VLC_CODEC_I444, VLC_CODEC_J444, 0
      };
      static const vlc_fourcc_t *pp_fcc[] = {
 -        p_I420, p_I422, p_I440, p_I444, p_UYVY, p_YUYV, p_GREY, NULL
 +        p_I420, p_I422, p_I440, p_I444, NULL
      };
  
 +    /* */
 +    i_chroma = vlc_fourcc_GetCodec( VIDEO_ES, i_chroma );
 +    i_amorhc = vlc_fourcc_GetCodec( VIDEO_ES, i_amorhc );
 +
      /* If they are the same, they are the same ! */
      if( i_chroma == i_amorhc )
          return 1;
@@@ -648,255 -1011,6 +648,255 @@@ static void PictureReleaseCallback( pic
          return;
      picture_Delete( p_picture );
  }
 +
 +/*****************************************************************************
 + *
 + *****************************************************************************/
 +int picture_Setup( picture_t *p_picture, vlc_fourcc_t i_chroma, int i_width, int i_height, int i_aspect )
 +{
 +    int i_index, i_width_aligned, i_height_aligned;
 +
 +    /* Store default values */
 +    for( i_index = 0; i_index < VOUT_MAX_PLANES; i_index++ )
 +    {
 +        p_picture->p[i_index].p_pixels = NULL;
 +        p_picture->p[i_index].i_pixel_pitch = 1;
 +    }
 +
 +    p_picture->pf_release = NULL;
 +    p_picture->p_release_sys = NULL;
 +    p_picture->pf_lock = NULL;
 +    p_picture->pf_unlock = NULL;
 +    p_picture->i_refcount = 0;
 +
 +    p_picture->i_qtype = QTYPE_NONE;
 +    p_picture->i_qstride = 0;
 +    p_picture->p_q = NULL;
 +
 +    video_format_Setup( &p_picture->format, i_chroma, i_width, i_height, i_aspect );
 +
 +    /* Make sure the real dimensions are a multiple of 16 */
 +    i_width_aligned = (i_width + 15) >> 4 << 4;
 +    i_height_aligned = (i_height + 15) >> 4 << 4;
 +
 +    /* Calculate coordinates */
 +    switch( vlc_fourcc_GetCodec( VIDEO_ES, i_chroma ) )
 +    {
 +    case VLC_CODEC_I411:
 +        p_picture->p[ Y_PLANE ].i_lines = i_height_aligned;
 +        p_picture->p[ Y_PLANE ].i_visible_lines = i_height;
 +        p_picture->p[ Y_PLANE ].i_pitch = i_width_aligned;
 +        p_picture->p[ Y_PLANE ].i_visible_pitch = i_width;
 +        p_picture->p[ U_PLANE ].i_lines = i_height_aligned;
 +        p_picture->p[ U_PLANE ].i_visible_lines = i_height;
 +        p_picture->p[ U_PLANE ].i_pitch = i_width_aligned / 4;
 +        p_picture->p[ U_PLANE ].i_visible_pitch = i_width / 4;
 +        p_picture->p[ V_PLANE ].i_lines = i_height_aligned;
 +        p_picture->p[ V_PLANE ].i_visible_lines = i_height;
 +        p_picture->p[ V_PLANE ].i_pitch = i_width_aligned / 4;
 +        p_picture->p[ V_PLANE ].i_visible_pitch = i_width / 4;
 +        p_picture->i_planes = 3;
 +        break;
 +
 +    case VLC_CODEC_I410:
 +        p_picture->p[ Y_PLANE ].i_lines = i_height_aligned;
 +        p_picture->p[ Y_PLANE ].i_visible_lines = i_height;
 +        p_picture->p[ Y_PLANE ].i_pitch = i_width_aligned;
 +        p_picture->p[ Y_PLANE ].i_visible_pitch = i_width;
 +        p_picture->p[ U_PLANE ].i_lines = i_height_aligned / 4;
 +        p_picture->p[ U_PLANE ].i_visible_lines = i_height / 4;
 +        p_picture->p[ U_PLANE ].i_pitch = i_width_aligned / 4;
 +        p_picture->p[ U_PLANE ].i_visible_pitch = i_width / 4;
 +        p_picture->p[ V_PLANE ].i_lines = i_height_aligned / 4;
 +        p_picture->p[ V_PLANE ].i_visible_lines = i_height / 4;
 +        p_picture->p[ V_PLANE ].i_pitch = i_width_aligned / 4;
 +        p_picture->p[ V_PLANE ].i_visible_pitch = i_width / 4;
 +        p_picture->i_planes = 3;
 +        break;
 +
 +    case VLC_CODEC_YV12:
 +    case VLC_CODEC_I420:
 +    case VLC_CODEC_J420:
 +        p_picture->p[ Y_PLANE ].i_lines = i_height_aligned;
 +        p_picture->p[ Y_PLANE ].i_visible_lines = i_height;
 +        p_picture->p[ Y_PLANE ].i_pitch = i_width_aligned;
 +        p_picture->p[ Y_PLANE ].i_visible_pitch = i_width;
 +        p_picture->p[ U_PLANE ].i_lines = i_height_aligned / 2;
 +        p_picture->p[ U_PLANE ].i_visible_lines = i_height / 2;
 +        p_picture->p[ U_PLANE ].i_pitch = i_width_aligned / 2;
 +        p_picture->p[ U_PLANE ].i_visible_pitch = i_width / 2;
 +        p_picture->p[ V_PLANE ].i_lines = i_height_aligned / 2;
 +        p_picture->p[ V_PLANE ].i_visible_lines = i_height / 2;
 +        p_picture->p[ V_PLANE ].i_pitch = i_width_aligned / 2;
 +        p_picture->p[ V_PLANE ].i_visible_pitch = i_width / 2;
 +        p_picture->i_planes = 3;
 +        break;
 +
 +    case VLC_CODEC_I422:
 +    case VLC_CODEC_J422:
 +        p_picture->p[ Y_PLANE ].i_lines = i_height_aligned;
 +        p_picture->p[ Y_PLANE ].i_visible_lines = i_height;
 +        p_picture->p[ Y_PLANE ].i_pitch = i_width_aligned;
 +        p_picture->p[ Y_PLANE ].i_visible_pitch = i_width;
 +        p_picture->p[ U_PLANE ].i_lines = i_height_aligned;
 +        p_picture->p[ U_PLANE ].i_visible_lines = i_height;
 +        p_picture->p[ U_PLANE ].i_pitch = i_width_aligned / 2;
 +        p_picture->p[ U_PLANE ].i_visible_pitch = i_width / 2;
 +        p_picture->p[ V_PLANE ].i_lines = i_height_aligned;
 +        p_picture->p[ V_PLANE ].i_visible_lines = i_height;
 +        p_picture->p[ V_PLANE ].i_pitch = i_width_aligned / 2;
 +        p_picture->p[ V_PLANE ].i_visible_pitch = i_width / 2;
 +        p_picture->i_planes = 3;
 +        break;
 +
 +    case VLC_CODEC_I440:
 +    case VLC_CODEC_J440:
 +        p_picture->p[ Y_PLANE ].i_lines = i_height_aligned;
 +        p_picture->p[ Y_PLANE ].i_visible_lines = i_height;
 +        p_picture->p[ Y_PLANE ].i_pitch = i_width_aligned;
 +        p_picture->p[ Y_PLANE ].i_visible_pitch = i_width;
 +        p_picture->p[ U_PLANE ].i_lines = i_height_aligned / 2;
 +        p_picture->p[ U_PLANE ].i_visible_lines = i_height / 2;
 +        p_picture->p[ U_PLANE ].i_pitch = i_width_aligned;
 +        p_picture->p[ U_PLANE ].i_visible_pitch = i_width;
 +        p_picture->p[ V_PLANE ].i_lines = i_height_aligned / 2;
 +        p_picture->p[ V_PLANE ].i_visible_lines = i_height / 2;
 +        p_picture->p[ V_PLANE ].i_pitch = i_width_aligned;
 +        p_picture->p[ V_PLANE ].i_visible_pitch = i_width;
 +        p_picture->i_planes = 3;
 +        break;
 +
 +    case VLC_CODEC_I444:
 +    case VLC_CODEC_J444:
 +        p_picture->p[ Y_PLANE ].i_lines = i_height_aligned;
 +        p_picture->p[ Y_PLANE ].i_visible_lines = i_height;
 +        p_picture->p[ Y_PLANE ].i_pitch = i_width_aligned;
 +        p_picture->p[ Y_PLANE ].i_visible_pitch = i_width;
 +        p_picture->p[ U_PLANE ].i_lines = i_height_aligned;
 +        p_picture->p[ U_PLANE ].i_visible_lines = i_height;
 +        p_picture->p[ U_PLANE ].i_pitch = i_width_aligned;
 +        p_picture->p[ U_PLANE ].i_visible_pitch = i_width;
 +        p_picture->p[ V_PLANE ].i_lines = i_height_aligned;
 +        p_picture->p[ V_PLANE ].i_visible_lines = i_height;
 +        p_picture->p[ V_PLANE ].i_pitch = i_width_aligned;
 +        p_picture->p[ V_PLANE ].i_visible_pitch = i_width;
 +        p_picture->i_planes = 3;
 +        break;
 +
 +    case VLC_CODEC_YUVA:
 +        p_picture->p[ Y_PLANE ].i_lines = i_height_aligned;
 +        p_picture->p[ Y_PLANE ].i_visible_lines = i_height;
 +        p_picture->p[ Y_PLANE ].i_pitch = i_width_aligned;
 +        p_picture->p[ Y_PLANE ].i_visible_pitch = i_width;
 +        p_picture->p[ U_PLANE ].i_lines = i_height_aligned;
 +        p_picture->p[ U_PLANE ].i_visible_lines = i_height;
 +        p_picture->p[ U_PLANE ].i_pitch = i_width_aligned;
 +        p_picture->p[ U_PLANE ].i_visible_pitch = i_width;
 +        p_picture->p[ V_PLANE ].i_lines = i_height_aligned;
 +        p_picture->p[ V_PLANE ].i_visible_lines = i_height;
 +        p_picture->p[ V_PLANE ].i_pitch = i_width_aligned;
 +        p_picture->p[ V_PLANE ].i_visible_pitch = i_width;
 +        p_picture->p[ A_PLANE ].i_lines = i_height_aligned;
 +        p_picture->p[ A_PLANE ].i_visible_lines = i_height;
 +        p_picture->p[ A_PLANE ].i_pitch = i_width_aligned;
 +        p_picture->p[ A_PLANE ].i_visible_pitch = i_width;
 +        p_picture->i_planes = 4;
 +        break;
 +
 +    case VLC_CODEC_YUVP:
 +        p_picture->p->i_lines = i_height_aligned;
 +        p_picture->p->i_visible_lines = i_height;
 +        p_picture->p->i_pitch = i_width_aligned;
 +        p_picture->p->i_visible_pitch = i_width;
 +        p_picture->p->i_pixel_pitch = 8;
 +        p_picture->i_planes = 1;
 +        break;
 +
 +    case VLC_CODEC_Y211:
 +        p_picture->p->i_lines = i_height_aligned;
 +        p_picture->p->i_visible_lines = i_height;
 +        p_picture->p->i_pitch = i_width_aligned;
 +        p_picture->p->i_visible_pitch = i_width;
 +        p_picture->p->i_pixel_pitch = 4;
 +        p_picture->i_planes = 1;
 +        break;
 +
 +    case VLC_CODEC_UYVY:
 +    case VLC_CODEC_VYUY:
 +    case VLC_CODEC_YUYV:
 +    case VLC_CODEC_YVYU:
 +        p_picture->p->i_lines = i_height_aligned;
 +        p_picture->p->i_visible_lines = i_height;
 +        p_picture->p->i_pitch = i_width_aligned * 2;
 +        p_picture->p->i_visible_pitch = i_width * 2;
 +        p_picture->p->i_pixel_pitch = 4;
 +        p_picture->i_planes = 1;
 +        break;
 +
 +    case VLC_CODEC_RGB8:
 +        p_picture->p->i_lines = i_height_aligned;
 +        p_picture->p->i_visible_lines = i_height;
 +        p_picture->p->i_pitch = i_width_aligned;
 +        p_picture->p->i_visible_pitch = i_width;
 +        p_picture->p->i_pixel_pitch = 1;
 +        p_picture->i_planes = 1;
 +        break;
 +
 +    case VLC_CODEC_RGB15:
 +        p_picture->p->i_lines = i_height_aligned;
 +        p_picture->p->i_visible_lines = i_height;
 +        p_picture->p->i_pitch = i_width_aligned * 2;
 +        p_picture->p->i_visible_pitch = i_width * 2;
 +        p_picture->p->i_pixel_pitch = 2;
 +        p_picture->i_planes = 1;
 +        break;
 +
 +    case VLC_CODEC_RGB16:
 +        p_picture->p->i_lines = i_height_aligned;
 +        p_picture->p->i_visible_lines = i_height;
 +        p_picture->p->i_pitch = i_width_aligned * 2;
 +        p_picture->p->i_visible_pitch = i_width * 2;
 +        p_picture->p->i_pixel_pitch = 2;
 +        p_picture->i_planes = 1;
 +        break;
 +
 +    case VLC_CODEC_RGB24:
 +        p_picture->p->i_lines = i_height_aligned;
 +        p_picture->p->i_visible_lines = i_height;
 +        p_picture->p->i_pitch = i_width_aligned * 3;
 +        p_picture->p->i_visible_pitch = i_width * 3;
 +        p_picture->p->i_pixel_pitch = 3;
 +        p_picture->i_planes = 1;
 +        break;
 +
 +    case VLC_CODEC_RGB32:
 +    case VLC_CODEC_RGBA:
 +        p_picture->p->i_lines = i_height_aligned;
 +        p_picture->p->i_visible_lines = i_height;
 +        p_picture->p->i_pitch = i_width_aligned * 4;
 +        p_picture->p->i_visible_pitch = i_width * 4;
 +        p_picture->p->i_pixel_pitch = 4;
 +        p_picture->i_planes = 1;
 +        break;
 +
 +    case VLC_CODEC_GREY:
 +    case VLC_CODEC_RGBP:
 +        p_picture->p->i_lines = i_height_aligned;
 +        p_picture->p->i_visible_lines = i_height;
 +        p_picture->p->i_pitch = i_width_aligned;
 +        p_picture->p->i_visible_pitch = i_width;
 +        p_picture->p->i_pixel_pitch = 1;
 +        p_picture->i_planes = 1;
 +        break;
 +
 +    default:
 +        p_picture->i_planes = 0;
 +        return VLC_EGENERIC;
 +    }
 +
 +    return VLC_SUCCESS;
 +}
 +
  /*****************************************************************************
   *
   *****************************************************************************/
@@@ -926,7 -1040,6 +926,7 @@@ picture_t *picture_New( vlc_fourcc_t i_
  void picture_Delete( picture_t *p_picture )
  {
      assert( p_picture && p_picture->i_refcount == 0 );
 +    assert( p_picture->p_release_sys == NULL );
  
      free( p_picture->p_q );
      free( p_picture->p_data_orig );
@@@ -1001,30 -1114,37 +1001,37 @@@ int picture_Export( vlc_object_t *p_obj
      fmt_out.i_sar_num =
      fmt_out.i_sar_den = 1;
      fmt_out.i_chroma  = i_format;
-     fmt_out.i_width   = i_override_width;
-     fmt_out.i_height  = i_override_height;
  
-     if( fmt_out.i_height == 0 && fmt_out.i_width > 0 )
+     /* compute original width/height */
+     unsigned int i_original_width;
+     unsigned int i_original_height;
+     if( fmt_in.i_sar_num >= fmt_in.i_sar_den )
      {
-         fmt_out.i_height = fmt_in.i_height * fmt_out.i_width / fmt_in.i_width;
-         const int i_height = fmt_out.i_height * fmt_in.i_sar_den / fmt_in.i_sar_num;
-         if( i_height > 0 )
-             fmt_out.i_height = i_height;
+         i_original_width = fmt_in.i_width * fmt_in.i_sar_num / fmt_in.i_sar_den;
+         i_original_height = fmt_in.i_height;
      }
      else
      {
-         if( fmt_out.i_width == 0 && fmt_out.i_height > 0 )
-         {
-             fmt_out.i_width = fmt_in.i_width * fmt_out.i_height / fmt_in.i_height;
-         }
-         else
-         {
-             fmt_out.i_width = fmt_in.i_width;
-             fmt_out.i_height = fmt_in.i_height;
-         }
-         const int i_width = fmt_out.i_width * fmt_in.i_sar_num / fmt_in.i_sar_den;
-         if( i_width > 0 )
-             fmt_out.i_width = i_width;
+         i_original_width =  fmt_in.i_width;
+         i_original_height = fmt_in.i_height * fmt_in.i_sar_den / fmt_in.i_sar_num;
+     }
+     /* */
+     fmt_out.i_width  = ( i_override_width < 0 ) ?
+                        i_original_width : i_override_width;
+     fmt_out.i_height = ( i_override_height < 0 ) ?
+                        i_original_height : i_override_height;
+     /* scale if only one direction is provided */
+     if( fmt_out.i_height == 0 && fmt_out.i_width > 0 )
+     {
+         fmt_out.i_height = fmt_in.i_height * fmt_out.i_width
+                      * fmt_in.i_sar_den / fmt_in.i_width / fmt_in.i_sar_num;
+     }
+     else if( fmt_out.i_width == 0 && fmt_out.i_height > 0 )
+     {
+         fmt_out.i_width  = fmt_in.i_width * fmt_out.i_height
+                      * fmt_in.i_sar_num / fmt_in.i_height / fmt_in.i_sar_den;
      }
  
      image_handler_t *p_image = image_HandlerCreate( p_obj );
  /*****************************************************************************
   *
   *****************************************************************************/
 -