]> git.sesse.net Git - vlc/blobdiff - modules/codec/ffmpeg/ffmpeg.c
* ALL: Introduction of a new api for decoders.
[vlc] / modules / codec / ffmpeg / ffmpeg.c
index c72db9297c8a1fccc1bd0e2a428b4a69778d6dab..db67bf8199edeba5dd6708221e5454bc04dacf05 100644 (file)
@@ -2,7 +2,7 @@
  * ffmpeg.c: video decoder using ffmpeg library
  *****************************************************************************
  * Copyright (C) 1999-2001 VideoLAN
- * $Id: ffmpeg.c,v 1.2 2002/08/04 18:39:41 sam Exp $
+ * $Id: ffmpeg.c,v 1.49 2003/09/02 20:19:25 gbazin Exp $
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *
@@ -10,7 +10,7 @@
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version.
- * 
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
 #include <vlc/vlc.h>
 #include <vlc/vout.h>
+#include <vlc/aout.h>
 #include <vlc/decoder.h>
 #include <vlc/input.h>
 
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>                                              /* getpid() */
-#endif
-
-#include <errno.h>
 #include <string.h>
 
 #ifdef HAVE_SYS_TIMES_H
 #   include <sys/times.h>
 #endif
 
-#include "avcodec.h"                                            /* ffmpeg */
+/* ffmpeg header */
+#ifdef HAVE_FFMPEG_AVCODEC_H
+#   include <ffmpeg/avcodec.h>
+#else
+#   include <avcodec.h>
+#endif
+
+#if LIBAVCODEC_BUILD < 4655
+#   error You must have a libavcodec >= 4655 (get CVS)
+#endif
+
+
 #include "ffmpeg.h"
 
+#ifdef LIBAVCODEC_PP
+#   ifdef HAVE_POSTPROC_POSTPROCESS_H
+#       include <postproc/postprocess.h>
+#   else
+#       include <libpostproc/postprocess.h>
+#   endif
+#endif
+
+#include "video.h" // video ffmpeg specific
+#include "audio.h" // audio ffmpeg specific
+
 /*
  * Local prototypes
  */
+int             E_(OpenChroma)  ( vlc_object_t * );
 static int      OpenDecoder     ( vlc_object_t * );
 static int      RunDecoder      ( decoder_fifo_t * );
-static int      InitThread      ( videodec_thread_t * );
-static void     EndThread       ( videodec_thread_t * );
-static void     DecodeThread    ( videodec_thread_t * );
+
+static int      InitThread      ( generic_thread_t * );
+static void     EndThread       ( generic_thread_t * );
 
 
 static int      b_ffmpeginit = 0;
 
+static int ffmpeg_GetFfmpegCodec( vlc_fourcc_t, int *, int *, char ** );
+
 /*****************************************************************************
  * Module descriptor
  *****************************************************************************/
+#define DR_TEXT N_("Direct rendering")
 
-#define ERROR_RESILIENCE_LONGTEXT \
-    "ffmpeg can make errors resiliences.          \n"\
-    "Nevertheless, with buggy encoder (like ISO MPEG-4 encoder from M$) " \
+#define ERROR_TEXT N_("Error resilience")
+#define ERROR_LONGTEXT N_( \
+    "ffmpeg can make errors resiliences.          \n" \
+    "Nevertheless, with a buggy encoder (like ISO MPEG-4 encoder from M$) " \
     "this will produce a lot of errors.\n" \
-    "Valid range is -1 to 99 (-1 disable all errors resiliences)."
-
-#define HURRY_UP_LONGTEXT \
+    "Valid range is -1 to 99 (-1 disables all errors resiliences).")
+
+#define BUGS_TEXT N_("Workaround bugs")
+#define BUGS_LONGTEXT N_( \
+    "Try to fix some bugs\n" \
+    "1  autodetect\n" \
+    "2  old msmpeg4\n" \
+    "4  xvid interlaced\n" \
+    "8  ump4 \n" \
+    "16 no padding\n" \
+    "32 ac vlc\n" \
+    "64 Qpel chroma")
+
+#define HURRYUP_TEXT N_("Hurry up")
+#define HURRYUP_LONGTEXT N_( \
     "Allow the decoder to partially decode or skip frame(s) " \
-    "when there not enough time.\n It's usefull with low CPU power " \
-    "but it could produce broken pictures."
-    
+    "when there is not enough time. It's useful with low CPU power " \
+    "but it can produce distorted pictures.")
+
+#define TRUNC_TEXT N_("Truncated stream")
+#define TRUNC_LONGTEXT N_("truncated stream -1:auto,0:disable,:1:enable")
+
+#define PP_Q_TEXT N_("Post processing quality")
+#define PP_Q_LONGTEXT N_( \
+    "Quality of post processing. Valid range is 0 to 6\n" \
+    "Higher levels require considerable more CPU power, but produce " \
+    "better looking pictures." )
+
+#define LIBAVCODEC_PP_TEXT N_("Ffmpeg postproc filter chains")
+/* FIXME (cut/past from ffmpeg */
+#define LIBAVCODEC_PP_LONGTEXT \
+"<filterName>[:<option>[:<option>...]][[,|/][-]<filterName>[:<option>...]]...\n" \
+"long form example:\n" \
+"vdeblock:autoq/hdeblock:autoq/linblenddeint    default,-vdeblock\n" \
+"short form example:\n" \
+"vb:a/hb:a/lb de,-vb\n" \
+"more examples:\n" \
+"tn:64:128:256\n" \
+"Filters                        Options\n" \
+"short  long name       short   long option     Description\n" \
+"*      *               a       autoq           cpu power dependant enabler\n" \
+"                       c       chrom           chrominance filtring enabled\n" \
+"                       y       nochrom         chrominance filtring disabled\n" \
+"hb     hdeblock        (2 Threshold)           horizontal deblocking filter\n" \
+"       1. difference factor: default=64, higher -> more deblocking\n" \
+"       2. flatness threshold: default=40, lower -> more deblocking\n" \
+"                       the h & v deblocking filters share these\n" \
+"                       so u cant set different thresholds for h / v\n" \
+"vb     vdeblock        (2 Threshold)           vertical deblocking filter\n" \
+"h1     x1hdeblock                              Experimental h deblock filter 1\n" \
+"v1     x1vdeblock                              Experimental v deblock filter 1\n" \
+"dr     dering                                  Deringing filter\n" \
+"al     autolevels                              automatic brightness / contrast\n" \
+"                       f       fullyrange      stretch luminance to (0..255)\n" \
+"lb     linblenddeint                           linear blend deinterlacer\n" \
+"li     linipoldeint                            linear interpolating deinterlace\n" \
+"ci     cubicipoldeint                          cubic interpolating deinterlacer\n" \
+"md     mediandeint                             median deinterlacer\n" \
+"fd     ffmpegdeint                             ffmpeg deinterlacer\n" \
+"de     default                                 hb:a,vb:a,dr:a,al\n" \
+"fa     fast                                    h1:a,v1:a,dr:a,al\n" \
+"tn     tmpnoise        (3 Thresholds)          Temporal Noise Reducer\n" \
+"                       1. <= 2. <= 3.          larger -> stronger filtering\n" \
+"fq     forceQuant      <quantizer>             Force quantizer\n"
+
 vlc_module_begin();
-    add_category_hint( N_("Miscellaneous"), NULL );
-#if LIBAVCODEC_BUILD >= 4611
-    add_integer ( "ffmpeg-error-resilience", 0, NULL, 
-                  "error resilience", ERROR_RESILIENCE_LONGTEXT );
-    add_integer ( "ffmpeg-workaround-bugs", 0, NULL, 
-                  "workaround bugs", "0-99, seems to be for msmpeg v3\n"  );
-#endif
-    add_bool( "ffmpeg-hurry-up", 0, NULL, "hurry up", HURRY_UP_LONGTEXT );
-    set_description( _("ffmpeg video decoder((MS)MPEG4,SVQ1,H263)") );
+    add_category_hint( N_("ffmpeg"), NULL, VLC_FALSE );
     set_capability( "decoder", 70 );
     set_callbacks( OpenDecoder, NULL );
+    set_description( _("ffmpeg audio/video decoder((MS)MPEG4,SVQ1,H263,WMV,WMA)") );
+
+    add_bool( "ffmpeg-dr", 1, NULL, DR_TEXT, DR_TEXT, VLC_TRUE );
+    add_integer ( "ffmpeg-error-resilience", -1, NULL, ERROR_TEXT, ERROR_LONGTEXT, VLC_TRUE );
+    add_integer ( "ffmpeg-workaround-bugs", 1, NULL, BUGS_TEXT, BUGS_LONGTEXT, VLC_FALSE );
+    add_bool( "ffmpeg-hurry-up", 0, NULL, HURRYUP_TEXT, HURRYUP_LONGTEXT, VLC_FALSE );
+    add_integer( "ffmpeg-truncated", -1, NULL, TRUNC_TEXT, TRUNC_LONGTEXT, VLC_FALSE );
+
+    add_category_hint( N_("Post processing"), NULL, VLC_FALSE );
+
+    add_integer( "ffmpeg-pp-q", 0, NULL, PP_Q_TEXT, PP_Q_LONGTEXT, VLC_FALSE );
+#ifdef LIBAVCODEC_PP
+    add_string( "ffmpeg-pp-name", "default", NULL, LIBAVCODEC_PP_TEXT, LIBAVCODEC_PP_LONGTEXT, VLC_TRUE );
+#endif
+
+    /* chroma conversion submodule */
+    add_submodule();
+    set_capability( "chroma", 50 );
+    set_callbacks( E_(OpenChroma), NULL );
+    set_description( _("ffmpeg chroma conversion") );
+
+    var_Create( p_module->p_libvlc, "avcodec", VLC_VAR_MUTEX );
 vlc_module_end();
 
 /*****************************************************************************
  * OpenDecoder: probe the decoder and return score
  *****************************************************************************
- * Tries to launch a decoder and return score so that the interface is able 
+ * Tries to launch a decoder and return score so that the interface is able
  * to chose.
  *****************************************************************************/
 static int OpenDecoder( vlc_object_t *p_this )
 {
-    decoder_fifo_t *p_fifo = (decoder_fifo_t*) p_this;
+    decoder_t *p_dec = (decoder_t*) p_this;
 
-    if( ffmpeg_GetFfmpegCodec( p_fifo->i_fourcc, NULL, NULL ) )
+    if( !ffmpeg_GetFfmpegCodec( p_dec->p_fifo->i_fourcc, NULL, NULL, NULL ) )
     {
-        p_fifo->pf_run = RunDecoder;
-        return VLC_SUCCESS;
+        return VLC_EGENERIC;
     }
 
-    return VLC_EGENERIC;
+    p_dec->pf_run = RunDecoder;
+
+    return VLC_SUCCESS;
 }
 
+typedef union decoder_thread_u
+{
+    generic_thread_t gen;
+    adec_thread_t    audio;
+    vdec_thread_t    video;
+
+} decoder_thread_t;
+
 /*****************************************************************************
  * RunDecoder: this function is called just after the thread is created
  *****************************************************************************/
 static int RunDecoder( decoder_fifo_t *p_fifo )
 {
-    videodec_thread_t   *p_vdec;
+    generic_thread_t *p_decoder;
     int b_error;
 
-    if ( !(p_vdec = (videodec_thread_t*)malloc( sizeof(videodec_thread_t))) )
+    if ( !(p_decoder = malloc( sizeof( decoder_thread_t ) ) ) )
     {
         msg_Err( p_fifo, "out of memory" );
         DecoderError( p_fifo );
         return( -1 );
     }
-    memset( p_vdec, 0, sizeof( videodec_thread_t ) );
+    memset( p_decoder, 0, sizeof( decoder_thread_t ) );
 
-    p_vdec->p_fifo = p_fifo;
+    p_decoder->p_fifo = p_fifo;
 
-    if( InitThread( p_vdec ) != 0 )
+    if( InitThread( p_decoder ) != 0 )
     {
+        msg_Err( p_fifo, "initialization failed" );
         DecoderError( p_fifo );
         return( -1 );
     }
-     
-    while( (!p_vdec->p_fifo->b_die) && (!p_vdec->p_fifo->b_error) )
+
+    while( (!p_decoder->p_fifo->b_die) && (!p_decoder->p_fifo->b_error) )
     {
-        DecodeThread( p_vdec );
+        switch( p_decoder->i_cat )
+        {
+            case VIDEO_ES:
+                E_( DecodeThread_Video )( (vdec_thread_t*)p_decoder );
+                break;
+            case AUDIO_ES:
+                E_( DecodeThread_Audio )( (adec_thread_t*)p_decoder );
+                break;
+        }
     }
 
-    if( ( b_error = p_vdec->p_fifo->b_error ) )
+    if( ( b_error = p_decoder->p_fifo->b_error ) )
     {
-        DecoderError( p_vdec->p_fifo );
+        DecoderError( p_decoder->p_fifo );
     }
 
-    EndThread( p_vdec );
+    EndThread( p_decoder );
 
     if( b_error )
     {
         return( -1 );
     }
-   
-    return( 0 );
-} 
 
+    return( 0 );
+}
 
 /*****************************************************************************
- * locales Functions
+ *
+ * Functions that initialize, decode and end the decoding process
+ *
  *****************************************************************************/
 
-#define GetWLE( p ) \
-    ( *(u8*)(p) + ( *((u8*)(p)+1) << 8 ) )
-
-#define GetDWLE( p ) \
-    (  *(u8*)(p) + ( *((u8*)(p)+1) << 8 ) + \
-      ( *((u8*)(p)+2) << 16 ) + ( *((u8*)(p)+3) << 24 ) )
+/*****************************************************************************
+ * InitThread: initialize vdec output thread
+ *****************************************************************************
+ * This function is called from decoder_Run and performs the second step
+ * of the initialization. It returns 0 on success. Note that the thread's
+ * flag are not modified inside this function.
+ *
+ * ffmpeg codec will be open, some memory allocated. But Vout is not yet
+ *   open (done after the first decoded frame)
+ *****************************************************************************/
 
-static void ffmpeg_ParseBitMapInfoHeader( bitmapinfoheader_t *p_bh, 
-                                          u8 *p_data )
+static int InitThread( generic_thread_t *p_decoder )
 {
-    p_bh->i_size          = GetDWLE( p_data );
-    p_bh->i_width         = GetDWLE( p_data + 4 );
-    p_bh->i_height        = GetDWLE( p_data + 8 );
-    p_bh->i_planes        = GetWLE( p_data + 12 );
-    p_bh->i_bitcount      = GetWLE( p_data + 14 );
-    p_bh->i_compression   = GetDWLE( p_data + 16 );
-    p_bh->i_sizeimage     = GetDWLE( p_data + 20 );
-    p_bh->i_xpelspermeter = GetDWLE( p_data + 24 );
-    p_bh->i_ypelspermeter = GetDWLE( p_data + 28 );
-    p_bh->i_clrused       = GetDWLE( p_data + 32 );
-    p_bh->i_clrimportant  = GetDWLE( p_data + 36 );
-
-    if( p_bh->i_size > 40 )
-    {
-        p_bh->i_data = p_bh->i_size - 40;
-        p_bh->p_data = malloc( p_bh->i_data ); 
-        memcpy( p_bh->p_data, p_data + 40, p_bh->i_data );
-    }
-    else
-    {
-        p_bh->i_data = 0;
-        p_bh->p_data = NULL;
-    } 
+    int i_result;
+    vlc_value_t lockval;
 
-}
-/* get the first pes from fifo */
-static pes_packet_t *__PES_GET( decoder_fifo_t *p_fifo )
-{
-    pes_packet_t *p_pes;
 
-    vlc_mutex_lock( &p_fifo->data_lock );
+    var_Get( p_decoder->p_fifo->p_libvlc, "avcodec", &lockval );
+    vlc_mutex_lock( lockval.p_address );
 
-    /* if fifo is emty wait */
-    while( !p_fifo->p_first )
-    {
-        if( p_fifo->b_die )
-        {
-            vlc_mutex_unlock( &p_fifo->data_lock );
-            return( NULL );
-        }
-        vlc_cond_wait( &p_fifo->data_wait, &p_fifo->data_lock );
-    }
-    p_pes = p_fifo->p_first;
-
-    vlc_mutex_unlock( &p_fifo->data_lock );
-
-    return( p_pes );
-}
-
-/* free the first pes and go to next */
-static void __PES_NEXT( decoder_fifo_t *p_fifo )
-{
-    pes_packet_t *p_next;
-
-    vlc_mutex_lock( &p_fifo->data_lock );
-    
-    p_next = p_fifo->p_first->p_next;
-    p_fifo->p_first->p_next = NULL;
-    input_DeletePES( p_fifo->p_packets_mgt, p_fifo->p_first );
-    p_fifo->p_first = p_next;
-    p_fifo->i_depth--;
-
-    if( !p_fifo->p_first )
+     /* *** init ffmpeg library (libavcodec) *** */
+    if( !b_ffmpeginit )
     {
-        /* No PES in the fifo */
-        /* pp_last no longer valid */
-        p_fifo->pp_last = &p_fifo->p_first;
-        while( !p_fifo->p_first )
-        {
-            vlc_cond_signal( &p_fifo->data_wait );
-            vlc_cond_wait( &p_fifo->data_wait, &p_fifo->data_lock );
-        }
-    }
-    vlc_mutex_unlock( &p_fifo->data_lock );
-}
-
-static inline void __GetFrame( videodec_thread_t *p_vdec )
-{
-    pes_packet_t  *p_pes;
-    data_packet_t *p_data;
-    byte_t        *p_buffer;
 
-    p_pes = __PES_GET( p_vdec->p_fifo );
-    p_vdec->i_pts = p_pes->i_pts;
+        avcodec_init();
+        avcodec_register_all();
+        b_ffmpeginit = 1;
 
-    while( ( !p_pes->i_nb_data )||( !p_pes->i_pes_size ) )
-    {
-        __PES_NEXT( p_vdec->p_fifo );
-        p_pes = __PES_GET( p_vdec->p_fifo );
+        msg_Dbg( p_decoder->p_fifo, "libavcodec initialized (interface "
+                                    LIBAVCODEC_BUILD_STR ")" );
     }
-    p_vdec->i_framesize = p_pes->i_pes_size;
-    if( p_pes->i_nb_data == 1 )
+    else
     {
-        p_vdec->p_framedata = p_pes->p_first->p_payload_start;
-        return;    
+        msg_Dbg( p_decoder->p_fifo, "libavcodec already initialized" );
     }
-    /* get a buffer and gather all data packet */
-    p_vdec->p_framedata = p_buffer = malloc( p_pes->i_pes_size );
-    p_data = p_pes->p_first;
-    do
-    {
-        p_vdec->p_fifo->p_vlc->pf_memcpy( p_buffer, p_data->p_payload_start, 
-                     p_data->p_payload_end - p_data->p_payload_start );
-        p_buffer += p_data->p_payload_end - p_data->p_payload_start;
-        p_data = p_data->p_next;
-    } while( p_data );
-}
+    vlc_mutex_unlock( lockval.p_address );
 
-static inline void __NextFrame( videodec_thread_t *p_vdec )
-{
-    pes_packet_t  *p_pes;
+    /* *** determine codec type *** */
+    ffmpeg_GetFfmpegCodec( p_decoder->p_fifo->i_fourcc,
+                           &p_decoder->i_cat,
+                           &p_decoder->i_codec_id,
+                           &p_decoder->psz_namecodec );
 
-    p_pes = __PES_GET( p_vdec->p_fifo );
-    if( p_pes->i_nb_data != 1 )
+    /* *** ask ffmpeg for a decoder *** */
+    if( !( p_decoder->p_codec =
+                avcodec_find_decoder( p_decoder->i_codec_id ) ) )
     {
-        free( p_vdec->p_framedata ); /* FIXME keep this buffer */
+        msg_Err( p_decoder->p_fifo,
+                 "codec not found (%s)",
+                 p_decoder->psz_namecodec );
+        return( -1 );
     }
-    __PES_NEXT( p_vdec->p_fifo );
-}
-
-/* FIXME FIXME some of them are wrong */
-static int i_ffmpeg_PixFmtToChroma[] = 
-{
-/* PIX_FMT_ANY = -1,PIX_FMT_YUV420P, PIX_FMT_YUV422,
-   PIX_FMT_RGB24, PIX_FMT_BGR24, PIX_FMT_YUV422P, 
-   PIX_FMT_YUV444P, PIX_FMT_YUV410P */
 
-    0, VLC_FOURCC('I','4','2','0'), VLC_FOURCC('I','4','2','0'), 
-    VLC_FOURCC('R','V','2','4'), 0, VLC_FOURCC('Y','4','2','2'), 
-    VLC_FOURCC('I','4','4','4'), 0 
-};
+     /* *** Get a p_context *** */
+    p_decoder->p_context = avcodec_alloc_context();
 
-static inline u32 ffmpeg_PixFmtToChroma( int i_ffmpegchroma )
-{
-    if( ++i_ffmpegchroma > 7 )
-    {
-        return( 0 );
-    }
-    else
+    switch( p_decoder->i_cat )
     {
-        return( i_ffmpeg_PixFmtToChroma[i_ffmpegchroma] );
-    }
-}
-
-static inline int ffmpeg_FfAspect( int i_width, int i_height, int i_ffaspect )
-{
-    switch( i_ffaspect )
-    {
-        case( FF_ASPECT_4_3_625 ):
-        case( FF_ASPECT_4_3_525 ):
-            return( VOUT_ASPECT_FACTOR * 4 / 3);
-        case( FF_ASPECT_16_9_625 ):
-        case( FF_ASPECT_16_9_525 ):
-            return( VOUT_ASPECT_FACTOR * 16 / 9 );
-        case( FF_ASPECT_SQUARE ):
+        case VIDEO_ES:
+            i_result = E_( InitThread_Video )( (vdec_thread_t*)p_decoder );
+            break;
+        case AUDIO_ES:
+            i_result = E_( InitThread_Audio )( (adec_thread_t*)p_decoder );
+            break;
         default:
-            return( VOUT_ASPECT_FACTOR * i_width / i_height );
+            i_result = -1;
     }
-}
 
-static int ffmpeg_CheckVout( vout_thread_t *p_vout,
-                             int i_width,
-                             int i_height,
-                             int i_aspect,
-                             int i_chroma )
-{
-    if( !p_vout )
-    {
-        return( 0 );
-    }
-    if( !i_chroma )
-    {
-        /* we will try to make conversion */
-        i_chroma = VLC_FOURCC('I','4','2','0');
-    } 
-    
-    if( ( p_vout->render.i_width != i_width )||
-        ( p_vout->render.i_height != i_height )||
-        ( p_vout->render.i_chroma != i_chroma )||
-        ( p_vout->render.i_aspect != 
-                ffmpeg_FfAspect( i_width, i_height, i_aspect ) ) )
-    {
-        return( 0 );
-    }
-    else
-    {
-        return( 1 );
-    }
-}
+    p_decoder->pts = 0;
+    p_decoder->p_buffer = NULL;
+    p_decoder->i_buffer = 0;
+    p_decoder->i_buffer_size = 0;
 
-/* Return a Vout */
+    return( i_result );
+}
 
-static vout_thread_t *ffmpeg_CreateVout( videodec_thread_t *p_vdec,
-                                         int i_width,
-                                         int i_height,
-                                         int i_aspect,
-                                         int i_chroma )
+/*****************************************************************************
+ * EndThread: thread destruction
+ *****************************************************************************
+ * This function is called when the thread ends after a sucessful
+ * initialization.
+ *****************************************************************************/
+static void EndThread( generic_thread_t *p_decoder )
 {
-    vout_thread_t *p_vout;
 
-    if( (!i_width)||(!i_height) )
+    if( !p_decoder )
     {
-        return( NULL ); /* Can't create a new vout without display size */
+        return;
     }
 
-    if( !i_chroma )
+    if( p_decoder->p_context != NULL)
     {
-        /* we make conversion if possible*/
-        i_chroma = VLC_FOURCC('I','4','2','0');
-        msg_Warn( p_vdec->p_fifo, "Internal chroma conversion (FIXME)");
-        /* It's mainly for I410 -> I420 conversion that I've made,
-           it's buggy and very slow */
-    } 
-
-    i_aspect = ffmpeg_FfAspect( i_width, i_height, i_aspect );
-    
-    /* Spawn a video output if there is none. First we look for our children,
-     * then we look for any other vout that might be available. */
-    p_vout = vlc_object_find( p_vdec->p_fifo, VLC_OBJECT_VOUT,
-                                              FIND_CHILD );
-    if( !p_vout )
-    {
-        p_vout = vlc_object_find( p_vdec->p_fifo, VLC_OBJECT_VOUT,
-                                                  FIND_ANYWHERE );
+        FREE( p_decoder->p_context->extradata );
+        avcodec_close( p_decoder->p_context );
+        msg_Dbg( p_decoder->p_fifo,
+                 "ffmpeg codec (%s) stopped",
+                 p_decoder->psz_namecodec );
+        free( p_decoder->p_context );
     }
 
-    if( p_vout )
-    {
-        if( !ffmpeg_CheckVout( p_vout, 
-                               i_width, i_height, i_aspect,i_chroma ) )
-        {
-            /* We are not interested in this format, close this vout */
-            vlc_object_detach_all( p_vout );
-            vlc_object_release( p_vout );
-            vout_DestroyThread( p_vout );
-            p_vout = NULL;
-        }
-        else
-        {
-            /* This video output is cool! Hijack it. */
-            vlc_object_detach_all( p_vout );
-            vlc_object_attach( p_vout, p_vdec->p_fifo );
-            vlc_object_release( p_vout );
-        }
-    }
+    FREE( p_decoder->p_buffer );
 
-    if( p_vout == NULL )
+    switch( p_decoder->i_cat )
     {
-        msg_Dbg( p_vdec->p_fifo, "no vout present, spawning one" );
-    
-        p_vout = vout_CreateThread( p_vdec->p_fifo,
-                                    i_width,
-                                    i_height,
-                                    i_chroma,
-                                    i_aspect );
+        case AUDIO_ES:
+            E_( EndThread_Audio )( (adec_thread_t*)p_decoder );
+            break;
+        case VIDEO_ES:
+            E_( EndThread_Video )( (vdec_thread_t*)p_decoder );
+            break;
     }
 
-    return( p_vout );
+    free( p_decoder );
 }
 
-/* FIXME FIXME FIXME this is a big shit
-   does someone want to rewrite this function ? 
-   or said to me how write a better thing
-   FIXME FIXME FIXME
-*/
+/*****************************************************************************
+ * locales Functions
+ *****************************************************************************/
 
-static void ffmpeg_ConvertPictureI410toI420( picture_t *p_pic,
-                                             AVPicture *p_avpicture,
-                                             videodec_thread_t   *p_vdec )
+int E_( GetPESData )( u8 *p_buf, int i_max, pes_packet_t *p_pes )
 {
-    u8 *p_src, *p_dst;
-    u8 *p_plane[3];
-    int i_plane;
-    
-    int i_stride, i_lines;
-    int i_height, i_width;
-    int i_y, i_x;
-    
-    i_height = p_vdec->p_context->height;
-    i_width  = p_vdec->p_context->width;
-    
-    p_dst = p_pic->p[0].p_pixels;
-    p_src  = p_avpicture->data[0];
-
-    /* copy first plane */
-    for( i_y = 0; i_y < i_height; i_y++ )
-    {
-        p_vdec->p_fifo->p_vlc->pf_memcpy( p_dst, p_src, i_width);
-        p_dst += p_pic->p[0].i_pitch;
-        p_src += p_avpicture->linesize[0];
-    }
-    
-    /* process each plane in a temporary buffer */
-    for( i_plane = 1; i_plane < 3; i_plane++ )
-    {
-        i_stride = p_avpicture->linesize[i_plane];
-        i_lines = i_height / 4;
+    int i_copy;
+    int i_count;
 
-        p_dst = p_plane[i_plane] = malloc( i_lines * i_stride * 2 * 2 );
-        p_src  = p_avpicture->data[i_plane];
+    data_packet_t   *p_data;
 
-        /* for each source line */
-        for( i_y = 0; i_y < i_lines; i_y++ )
-        {
-            for( i_x = 0; i_x < i_stride - 1; i_x++ )
-            {
-                p_dst[2 * i_x    ] = p_src[i_x];
-                p_dst[2 * i_x + 1] = ( p_src[i_x] + p_src[i_x + 1]) / 2;
-
-            }
-            p_dst[2 * i_stride - 2] = p_src[i_x];
-            p_dst[2 * i_stride - 1] = p_src[i_x];
-                           
-            p_dst += 4 * i_stride; /* process the next even lines */
-            p_src += i_stride;
-        }
-
-
-    }
-
-    for( i_plane = 1; i_plane < 3; i_plane++ )
-    {
-        i_stride = p_avpicture->linesize[i_plane];
-        i_lines = i_height / 4;
-
-        p_dst = p_plane[i_plane] + 2*i_stride;
-        p_src  = p_plane[i_plane];
-
-        for( i_y = 0; i_y < i_lines - 1; i_y++ )
-        {
-            for( i_x = 0; i_x <  2 * i_stride ; i_x++ )
-            {
-                p_dst[i_x] = ( p_src[i_x] + p_src[i_x + 4*i_stride])/2;
-            }
-                           
-            p_dst += 4 * i_stride; /* process the next odd lines */
-            p_src += 4 * i_stride;
-        }
-        /* last line */
-        p_vdec->p_fifo->p_vlc->pf_memcpy( p_dst, p_src, 2*i_stride );
-    }
-    /* copy to p_pic, by block
-       if I do pixel per pixel it segfault. It's why I use 
-       temporaries buffers */
-    for( i_plane = 1; i_plane < 3; i_plane++ )
+    i_count = 0;
+    p_data = p_pes->p_first;
+    while( p_data != NULL && i_count < i_max )
     {
 
-        int i_size; 
-        p_src  = p_plane[i_plane];
-        p_dst = p_pic->p[i_plane].p_pixels;
+        i_copy = __MIN( p_data->p_payload_end - p_data->p_payload_start,
+                        i_max - i_count );
 
-        i_size = __MIN( 2*i_stride, p_pic->p[i_plane].i_pitch);
-        for( i_y = 0; i_y < __MIN(p_pic->p[i_plane].i_lines, 2 * i_lines); i_y++ )
+        if( i_copy > 0 )
         {
-            p_vdec->p_fifo->p_vlc->pf_memcpy( p_dst, p_src, i_size );
-            p_src += 2 * i_stride;
-            p_dst += p_pic->p[i_plane].i_pitch;
+            memcpy( p_buf,
+                    p_data->p_payload_start,
+                    i_copy );
         }
-        free( p_plane[i_plane] );
-    }
 
-}
-
-static void ffmpeg_ConvertPicture( picture_t *p_pic,
-                                   AVPicture *p_avpicture,
-                                   videodec_thread_t   *p_vdec )
-{
-    int i_plane; 
-    int i_size;
-    int i_line;
-
-    u8  *p_dst;
-    u8  *p_src;
-    int i_src_stride;
-    int i_dst_stride;
-    
-    if( ffmpeg_PixFmtToChroma( p_vdec->p_context->pix_fmt ) )
-    {
-        /* convert ffmpeg picture to our format */
-        for( i_plane = 0; i_plane < p_pic->i_planes; i_plane++ )
-        {
-            p_src  = p_avpicture->data[i_plane];
-            p_dst = p_pic->p[i_plane].p_pixels;
-            i_src_stride = p_avpicture->linesize[i_plane];
-            i_dst_stride = p_pic->p[i_plane].i_pitch;
-            
-            i_size = __MIN( i_src_stride, i_dst_stride );
-            for( i_line = 0; i_line < p_pic->p[i_plane].i_lines; i_line++ )
-            {
-                p_vdec->p_fifo->p_vlc->pf_memcpy( p_dst, p_src, i_size );
-                p_src += i_src_stride;
-                p_dst += i_dst_stride;
-            }
-        }
-        return;
+        p_data = p_data->p_next;
+        i_count += i_copy;
+        p_buf   += i_copy;
     }
 
-    /* we need to convert to I420 */
-    switch( p_vdec->p_context->pix_fmt )
+    if( i_count < i_max )
     {
-#if LIBAVCODEC_BUILD >= 4615
-        case( PIX_FMT_YUV410P ):
-            ffmpeg_ConvertPictureI410toI420( p_pic, p_avpicture, p_vdec );
-            break;
-#endif            
-        default:
-            p_vdec->p_fifo->b_error =1;
-            break;
+        memset( p_buf, 0, i_max - i_count );
     }
+    return( i_count );
 }
 
 
-/*****************************************************************************
- *
- * Functions that initialize, decode and end the decoding process
- *
- *****************************************************************************/
-
-/*****************************************************************************
- * InitThread: initialize vdec output thread
- *****************************************************************************
- * This function is called from RunDecoderoder and performs the second step 
- * of the initialization. It returns 0 on success. Note that the thread's 
- * flag are not modified inside this function.
- *****************************************************************************/
-
-static int InitThread( videodec_thread_t *p_vdec )
+static int ffmpeg_GetFfmpegCodec( vlc_fourcc_t i_fourcc,
+                                  int *pi_cat,
+                                  int *pi_ffmpeg_codec,
+                                  char **ppsz_name )
 {
-    int i_ffmpeg_codec; 
-    int i_tmp;
-    
-    if( p_vdec->p_fifo->p_demux_data )
-    {
-        ffmpeg_ParseBitMapInfoHeader( &p_vdec->format, 
-                                      (u8*)p_vdec->p_fifo->p_demux_data );
-    }
-    else
-    {
-        msg_Warn( p_vdec->p_fifo, "display informations missing" );
-    }
+    int i_cat;
+    int i_codec;
+    char *psz_name;
 
-    /*init ffmpeg */
-    if( !b_ffmpeginit )
+    switch( i_fourcc )
     {
-        avcodec_init();
-        avcodec_register_all();
-        b_ffmpeginit = 1;
-        msg_Dbg( p_vdec->p_fifo, "library ffmpeg initialized" );
-    }
-    else
-    {
-        msg_Dbg( p_vdec->p_fifo, "library ffmpeg already initialized" );
-    }
-    ffmpeg_GetFfmpegCodec( p_vdec->p_fifo->i_fourcc,
-                           &i_ffmpeg_codec,
-                           &p_vdec->psz_namecodec );
-    p_vdec->p_codec = 
-        avcodec_find_decoder( i_ffmpeg_codec );
-    
-    if( !p_vdec->p_codec )
-    {
-        msg_Err( p_vdec->p_fifo, "codec not found (%s)",
-                                 p_vdec->psz_namecodec );
-        return( -1 );
-    }
+        case FOURCC_mpgv:
+            i_cat = VIDEO_ES;
+            i_codec = CODEC_ID_MPEG1VIDEO;
+            psz_name = "MPEG-1/2 Video";
+            break;
 
-    p_vdec->p_context = &p_vdec->context;
-    memset( p_vdec->p_context, 0, sizeof( AVCodecContext ) );
-
-    p_vdec->p_context->width  = p_vdec->format.i_width;
-    p_vdec->p_context->height = p_vdec->format.i_height;
-    
-/*  XXX
-    p_vdec->p_context->workaround_bugs 
-      --> seems to be for msmpeg 3 but can't know what is supposed to do
-
-    p_vdec->p_context->strict_std_compliance
-      --> strictly follow mpeg4 standard for decoder or encoder ??
-      
-    p_vdec->p_context->error_resilience
-      --> don't make error resilience, because of some ms encoder witch 
-      use some wrong VLC code.
-*/
-
-#if LIBAVCODEC_BUILD >= 4611
-    i_tmp = config_GetInt( p_vdec->p_fifo, "ffmpeg-workaround-bugs" );
-    p_vdec->p_context->workaround_bugs  = __MAX( __MIN( i_tmp, 99 ), 0 );
-
-    i_tmp = config_GetInt( p_vdec->p_fifo, "ffmpeg-error-resilience" );
-    p_vdec->p_context->error_resilience = __MAX( __MIN( i_tmp, 99 ), -1 );
-#endif
-#if LIBAVCODEC_BUILD >= 4614
-    if( config_GetInt( p_vdec->p_fifo, "grayscale" ) )
-    {
-        p_vdec->p_context->flags|= CODEC_FLAG_GRAY;
-    }
-#endif
-    
-    if (avcodec_open(p_vdec->p_context, p_vdec->p_codec) < 0)
-    {
-        msg_Err( p_vdec->p_fifo, "cannot open codec (%s)",
-                                 p_vdec->psz_namecodec );
-        return( -1 );
-    }
-    else
-    {
-        msg_Dbg( p_vdec->p_fifo, "ffmpeg codec (%s) started",
-                                 p_vdec->psz_namecodec );
-    }
-    
-    /* first give init data */
-    if( p_vdec->format.i_data )
-    {
-        AVPicture avpicture;
-        int b_gotpicture;
-        
-        switch( i_ffmpeg_codec )
-        {
-            case( CODEC_ID_MPEG4 ):
-                avcodec_decode_video( p_vdec->p_context, &avpicture, 
-                                      &b_gotpicture,
-                                      p_vdec->format.p_data,
-                                      p_vdec->format.i_data );
-                break;
-            default:
-                break;
-        }
-    }
-    
-    /* This will be created after the first decoded frame */
-    p_vdec->p_vout = NULL;
-    
-    return( 0 );
-}
+        case FOURCC_DIV1:
+        case FOURCC_div1:
+        case FOURCC_MPG4:
+        case FOURCC_mpg4:
+            i_cat = VIDEO_ES;
+            i_codec = CODEC_ID_MSMPEG4V1;
+            psz_name = "MS MPEG-4 v1";
+            break;
 
-/*****************************************************************************
- * DecodeThread: Called for decode one frame
- *****************************************************************************/
-static void  DecodeThread( videodec_thread_t *p_vdec )
-{
-    int     i_status;
-    int     b_drawpicture;
-    int     b_gotpicture;
-    AVPicture avpicture;  /* ffmpeg picture */
-    picture_t *p_pic; /* videolan picture */
-    /* we have to get a frame stored in a pes 
-       give it to ffmpeg decoder 
-       and send the image to the output */ 
-
-    /* TODO implement it in a better way */
-
-    if( ( config_GetInt(p_vdec->p_fifo, "ffmpeg-hurry-up") )&&
-        ( p_vdec->i_frame_late > 4 ) )
-    {
-#if LIBAVCODEC_BUILD > 4603
-        b_drawpicture = 0;
-        if( p_vdec->i_frame_late < 8 )
-        {
-            p_vdec->p_context->hurry_up = 2;
-        }
-        else
-        {
-            /* too much late picture, won't decode 
-               but break picture until a new I, and for mpeg4 ...*/
-            p_vdec->i_frame_late--; /* needed else it will never be decrease */
-            __PES_NEXT( p_vdec->p_fifo );
-            return;
-        }
-#else
-        if( p_vdec->i_frame_late < 8 )
-        {
-            b_drawpicture = 0; /* not really good but .. */
-        }
-        else
-        {
-            /* too much late picture, won't decode 
-               but break picture until a new I, and for mpeg4 ...*/
-            p_vdec->i_frame_late--; /* needed else it will never be decrease */
-            __PES_NEXT( p_vdec->p_fifo );
-            return;
-        }
-#endif
-    }
-    else
-    {
-        b_drawpicture = 1;
-#if LIBAVCODEC_BUILD > 4603
-        p_vdec->p_context->hurry_up = 0;
-#endif
-    }
+        case FOURCC_DIV2:
+        case FOURCC_div2:
+        case FOURCC_MP42:
+        case FOURCC_mp42:
+            i_cat = VIDEO_ES;
+            i_codec = CODEC_ID_MSMPEG4V2;
+            psz_name = "MS MPEG-4 v2";
+            break;
 
-    __GetFrame( p_vdec );
+        case FOURCC_MPG3:
+        case FOURCC_mpg3:
+        case FOURCC_div3:
+        case FOURCC_MP43:
+        case FOURCC_mp43:
+        case FOURCC_DIV3:
+        case FOURCC_DIV4:
+        case FOURCC_div4:
+        case FOURCC_DIV5:
+        case FOURCC_div5:
+        case FOURCC_DIV6:
+        case FOURCC_div6:
+        case FOURCC_AP41:
+        case FOURCC_3VID:
+        case FOURCC_3vid:
+        case FOURCC_3IVD:
+        case FOURCC_3ivd:
+            i_cat = VIDEO_ES;
+            i_codec = CODEC_ID_MSMPEG4V3;
+            psz_name = "MS MPEG-4 v3";
+            break;
 
-    i_status = avcodec_decode_video( p_vdec->p_context,
-                                     &avpicture,
-                                     &b_gotpicture,
-                                     p_vdec->p_framedata,
-                                     p_vdec->i_framesize);
+        case FOURCC_SVQ1:
+            i_cat = VIDEO_ES;
+            i_codec = CODEC_ID_SVQ1;
+            psz_name = "SVQ-1 (Sorenson Video v1)";
+            break;
+#if LIBAVCODEC_BUILD >= 4666
+        case FOURCC_SVQ3:
+            i_cat = VIDEO_ES;
+            i_codec = CODEC_ID_SVQ3;
+            psz_name = "SVQ-3 (Sorenson Video v3)";
+            break;
+#endif
 
-    __NextFrame( p_vdec );
+        case FOURCC_DIVX:
+        case FOURCC_divx:
+        case FOURCC_MP4S:
+        case FOURCC_mp4s:
+        case FOURCC_M4S2:
+        case FOURCC_m4s2:
+        case FOURCC_xvid:
+        case FOURCC_XVID:
+        case FOURCC_XviD:
+        case FOURCC_DX50:
+        case FOURCC_mp4v:
+        case FOURCC_4:
+        case FOURCC_m4cc:
+        case FOURCC_M4CC:
+        /* 3iv1 is unsupported by ffmpeg
+           putting it here gives extreme distorted images
+        case FOURCC_3IV1:
+        case FOURCC_3iv1:
+        */
+        case FOURCC_3IV2:
+        case FOURCC_3iv2:
+            i_cat = VIDEO_ES;
+            i_codec = CODEC_ID_MPEG4;
+            psz_name = "MPEG-4";
+            break;
+/* FIXME FOURCC_H263P exist but what fourcc ? */
+        case FOURCC_H263:
+        case FOURCC_h263:
+        case FOURCC_U263:
+            i_cat = VIDEO_ES;
+            i_codec = CODEC_ID_H263;
+            psz_name = "H263";
+            break;
 
-    if( i_status < 0 )
-    {
-        msg_Warn( p_vdec->p_fifo, "cannot decode one frame (%d bytes)",
-                                  p_vdec->i_framesize );
-        p_vdec->i_frame_error++;
-        return;
-    }
-    /* Update frame late count*/
-    /* I don't make statistic on decoding time */
-    if( p_vdec->i_pts <= mdate()) 
-    {
-        p_vdec->i_frame_late++;
-    }
-    else
-    {
-        p_vdec->i_frame_late = 0;
-    }
+        case FOURCC_I263:
+        case FOURCC_i263:
+            i_cat = VIDEO_ES;
+            i_codec = CODEC_ID_H263I;
+            psz_name = "I263.I";
+            break;
+        case FOURCC_WMV1:
+            i_cat = VIDEO_ES;
+            i_codec = CODEC_ID_WMV1;
+            psz_name ="Windows Media Video 1";
+            break;
+        case FOURCC_WMV2:
+        case FOURCC_MSS1:
+            i_cat = VIDEO_ES;
+            i_codec = CODEC_ID_WMV2;
+            psz_name ="Windows Media Video 2";
+            break;
+        case FOURCC_MJPG:
+        case FOURCC_mjpg:
+        case FOURCC_mjpa:
+        case FOURCC_jpeg:
+        case FOURCC_JPEG:
+        case FOURCC_JFIF:
+            i_cat = VIDEO_ES;
+            i_codec = CODEC_ID_MJPEG;
+            psz_name = "Motion JPEG";
+            break;
+        case FOURCC_mjpb:
+            i_cat = VIDEO_ES;
+            i_codec = CODEC_ID_MJPEGB;
+            psz_name = "Motion JPEG B";
+            break;
+        case FOURCC_dvsl:
+        case FOURCC_dvsd:
+        case FOURCC_DVSD:
+        case FOURCC_dvhd:
+        case FOURCC_dvc:
+        case FOURCC_dvp:
+        case FOURCC_CDVC:
+            i_cat = VIDEO_ES;
+            i_codec = CODEC_ID_DVVIDEO;
+            psz_name = "DV video";
+            break;
 
-    if( !b_gotpicture || avpicture.linesize[0] == 0 || !b_drawpicture)
-    {
-        return;
-    }
-    
-    /* Check our vout */
-    if( !ffmpeg_CheckVout( p_vdec->p_vout,
-                           p_vdec->p_context->width,
-                           p_vdec->p_context->height,
-                           p_vdec->p_context->aspect_ratio_info,
-                           ffmpeg_PixFmtToChroma(p_vdec->p_context->pix_fmt)) )
-    {
-        p_vdec->p_vout = 
-          ffmpeg_CreateVout( p_vdec,
-                             p_vdec->p_context->width,
-                             p_vdec->p_context->height,
-                             p_vdec->p_context->aspect_ratio_info,
-                             ffmpeg_PixFmtToChroma(p_vdec->p_context->pix_fmt));
-        if( !p_vdec->p_vout )
-        {
-            msg_Err( p_vdec->p_fifo, "cannot create vout" );
-            p_vdec->p_fifo->b_error = 1; /* abort */
-            return;
-        }
-    }
+        case FOURCC_MAC3:
+            i_cat = AUDIO_ES;
+            i_codec = CODEC_ID_MACE3;
+            psz_name = "MACE-3 audio";
+            break;
+        case FOURCC_MAC6:
+            i_cat = AUDIO_ES;
+            i_codec = CODEC_ID_MACE6;
+            psz_name = "MACE-6 audio";
+            break;
+        case FOURCC_dvau:
+            i_cat = AUDIO_ES;
+            i_codec = CODEC_ID_DVAUDIO;
+            psz_name = "DV audio";
+            break;
 
-    /* Send decoded frame to vout */
-    while( !(p_pic = vout_CreatePicture( p_vdec->p_vout, 0, 0, 0 ) ) )
-    {
-        if( p_vdec->p_fifo->b_die || p_vdec->p_fifo->b_error )
-        {
-            return;
-        }
-        msleep( VOUT_OUTMEM_SLEEP );
-    }
-    
-    ffmpeg_ConvertPicture( p_pic, 
-                           &avpicture, 
-                           p_vdec );
-    
-
-    /* FIXME correct avi and use i_dts */
-    vout_DatePicture( p_vdec->p_vout, p_pic, p_vdec->i_pts);
-    vout_DisplayPicture( p_vdec->p_vout, p_pic );
-    
-    return;
-}
+        case FOURCC_WMA1:
+        case FOURCC_wma1:
+            i_cat = AUDIO_ES;
+            i_codec = CODEC_ID_WMAV1;
+            psz_name ="Windows Media Audio 1";
+            break;
+        case FOURCC_WMA2:
+        case FOURCC_wma2:
+            i_cat = AUDIO_ES;
+            i_codec = CODEC_ID_WMAV2;
+            psz_name ="Windows Media Audio 2";
+            break;
 
+#if( ( LIBAVCODEC_BUILD >= 4663 ) && ( !defined( WORDS_BIGENDIAN ) ) )
+        /* Quality of this decoder on ppc is not good */
+       case FOURCC_IV31:
+        case FOURCC_iv31:
+        case FOURCC_IV32:
+        case FOURCC_iv32:
+            i_cat    = VIDEO_ES;
+            i_codec  = CODEC_ID_INDEO3;
+            psz_name = "Indeo v3";
+            break;
+#endif
 
-/*****************************************************************************
- * EndThread: thread destruction
- *****************************************************************************
- * This function is called when the thread ends after a sucessful
- * initialization.
- *****************************************************************************/
-static void EndThread( videodec_thread_t *p_vdec )
-{
-    if( !p_vdec )
-    {
-        return;
-    }
+#if LIBAVCODEC_BUILD >= 4668
+       /* Not yet finished 
+        case FOURCC_vp31:
+       case FOURCC_VP31:
+           i_cat    = VIDEO_ES;
+           i_codec  = CODEC_ID_VP3;
+           psz_name = "On2's VP3 Video";
+           break;
+
+        case FOURCC_asv1:
+        case FOURCC_ASV1:
+            i_cat    = VIDEO_ES;
+            i_codec  = CODEC_ID_ASV1;
+            psz_name = "Asus V1";
+            break; */
+#endif
 
-    if( p_vdec->p_context != NULL)
-    {
-        avcodec_close( p_vdec->p_context );
-        msg_Dbg( p_vdec->p_fifo, "ffmpeg codec (%s) stopped",
-                                 p_vdec->psz_namecodec );
+        default:
+            i_cat = UNKNOWN_ES;
+            i_codec = CODEC_ID_NONE;
+            psz_name = NULL;
+            break;
     }
 
-    if( p_vdec->p_vout != NULL )
+    if( i_codec != CODEC_ID_NONE )
     {
-        /* We are about to die. Reattach video output to p_vlc. */
-        vlc_object_detach( p_vdec->p_vout, p_vdec->p_fifo );
-        vlc_object_attach( p_vdec->p_vout, p_vdec->p_fifo->p_vlc );
+        if( pi_cat ) *pi_cat = i_cat;
+        if( pi_ffmpeg_codec ) *pi_ffmpeg_codec = i_codec;
+        if( ppsz_name ) *ppsz_name = psz_name;
+        return( VLC_TRUE );
     }
 
-    if( p_vdec->format.p_data != NULL)
-    {
-        free( p_vdec->format.p_data );
-    }
-    
-    free( p_vdec );
+    return( VLC_FALSE );
 }