]> git.sesse.net Git - vlc/blobdiff - modules/codec/ffmpeg/ffmpeg.c
* include/configuration.h: added a new flag to the configuration stucture to
[vlc] / modules / codec / ffmpeg / ffmpeg.c
index 5ea47cbe50ac4a979b7e596a0bb2c25078ab7536..5e900769a2b5b7f386c4eaf392620bf3310a7c5f 100644 (file)
@@ -2,7 +2,7 @@
  * ffmpeg.c: video decoder using ffmpeg library
  *****************************************************************************
  * Copyright (C) 1999-2001 VideoLAN
- * $Id: ffmpeg.c,v 1.12 2002/10/28 06:26:11 fenrir Exp $
+ * $Id: ffmpeg.c,v 1.25 2003/02/20 01:52:46 sigmunau Exp $
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *
 #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
@@ -70,7 +65,7 @@ static int ffmpeg_GetFfmpegCodec( vlc_fourcc_t, int *, int *, char ** );
  *****************************************************************************/
 
 #define ERROR_RESILIENCE_LONGTEXT \
-    "ffmpeg can make errors resiliences.          \n"\
+    "ffmpeg can make errors resiliences.          \n" \
     "Nevertheless, with 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)."
@@ -83,14 +78,14 @@ static int ffmpeg_GetFfmpegCodec( vlc_fourcc_t, int *, int *, char ** );
 #define POSTPROCESSING_Q_LONGTEXT \
     "Quality of post processing\n"\
     "Valid range is 0 to 6\n" \
-    "( Overridden by others setting)"
+    "(Overridden by others setting)"
     
 #define POSTPROCESSING_AQ_LONGTEXT \
-    "Post processing quality is selected upon time left" \
+    "Post processing quality is selected upon time left " \
     "but no more than requested quality\n" \
     "Not yet implemented !"
 
-#define WORAROUND_BUG_LONGTEXT \
+#define WORKAROUND_BUGS_LONGTEXT \
     "Try to fix some bugs\n" \
     "1  autodetect\n" \
     "2  old msmpeg4\n" \
@@ -101,40 +96,45 @@ static int ffmpeg_GetFfmpegCodec( vlc_fourcc_t, int *, int *, char ** );
     "64 Qpel chroma"
 
 vlc_module_begin();
-    add_category_hint( N_("Ffmpeg"), NULL );
+    add_category_hint( N_("ffmpeg"), NULL, VLC_FALSE );
+#if LIBAVCODEC_BUILD >= 4615
+    add_bool( "ffmpeg-dr", 0, NULL,
+              "direct rendering", 
+              "direct rendering", VLC_TRUE );
+#endif
 #if LIBAVCODEC_BUILD >= 4611
     add_integer ( "ffmpeg-error-resilience", -1, NULL, 
-                  "error resilience", ERROR_RESILIENCE_LONGTEXT );
-    add_integer ( "ffmpeg-workaround-bugs", 0, NULL, 
-                  "workaround bugs", WORAROUND_BUG_LONGTEXT );
+                  "error resilience", ERROR_RESILIENCE_LONGTEXT, VLC_TRUE );
+    add_integer ( "ffmpeg-workaround-bugs", 1, NULL, 
+                  "workaround bugs", WORKAROUND_BUGS_LONGTEXT, VLC_FALSE );
 #endif
-    add_bool( "ffmpeg-hurry-up", 0, NULL, "hurry up", HURRY_UP_LONGTEXT );
+    add_bool( "ffmpeg-hurry-up", 0, NULL, "hurry up", HURRY_UP_LONGTEXT, VLC_FALSE );
     
-    add_category_hint( N_("Post processing"), NULL );
+    add_category_hint( N_("Post processing"), NULL, VLC_FALSE );
     add_module( "ffmpeg-pp", "postprocessing",NULL, NULL,
-                N_( "ffmpeg postprocessing module" ), NULL ); 
+                N_( "ffmpeg postprocessing module" ), NULL, VLC_FALSE ); 
     add_integer( "ffmpeg-pp-q", 0, NULL,
-                 "post processing quality", POSTPROCESSING_Q_LONGTEXT );
+                 "post processing quality", POSTPROCESSING_Q_LONGTEXT, VLC_FALSE );
     add_bool( "ffmpeg-pp-auto", 0, NULL,
-              "auto-level Post processing quality", POSTPROCESSING_AQ_LONGTEXT );
+              "auto-level Post processing quality", POSTPROCESSING_AQ_LONGTEXT, VLC_FALSE );
     add_bool( "ffmpeg-db-yv", 0, NULL, 
               "force vertical luminance deblocking", 
-              "force vertical luminance deblocking (override other settings)" );
+              "force vertical luminance deblocking (override other settings)", VLC_TRUE );
     add_bool( "ffmpeg-db-yh", 0, NULL, 
               "force horizontal luminance deblocking",
-              "force horizontal luminance deblocking (override other settings)" );
+              "force horizontal luminance deblocking (override other settings)", VLC_TRUE );
     add_bool( "ffmpeg-db-cv", 0, NULL, 
               "force vertical chrominance deblocking",
-              "force vertical chrominance deblocking (override other settings)" );
+              "force vertical chrominance deblocking (override other settings)", VLC_TRUE );
     add_bool( "ffmpeg-db-ch", 0, NULL, 
               "force horizontal chrominance deblocking",
-              "force horizontal chrominance deblocking (override other settings) " );
+              "force horizontal chrominance deblocking (override other settings) ", VLC_TRUE );
     add_bool( "ffmpeg-dr-y", 0, NULL,
               "force luminance deringing",
-              "force luminance deringing (override other settings)" );
+              "force luminance deringing (override other settings)", VLC_TRUE );
     add_bool( "ffmpeg-dr-c", 0, NULL,
               "force chrominance deringing",
-              "force chrominance deringing (override other settings)" );
+              "force chrominance deringing (override other settings)", VLC_TRUE );
       
     set_description( _("ffmpeg audio/video decoder((MS)MPEG4,SVQ1,H263,WMV,WMA)") );
     set_capability( "decoder", 70 );
@@ -250,11 +250,12 @@ static int InitThread( generic_thread_t *p_decoder )
         avcodec_register_all();
         b_ffmpeginit = 1;
 
-        msg_Dbg( p_decoder->p_fifo, "library ffmpeg initialized" );
+        msg_Dbg( p_decoder->p_fifo, "libavcodec initialized (interface "
+                                    LIBAVCODEC_BUILD_STR ")" );
     }
     else
     {
-        msg_Dbg( p_decoder->p_fifo, "library ffmpeg already initialized" );
+        msg_Dbg( p_decoder->p_fifo, "libavcodec already initialized" );
     }
 
     /* *** determine codec type *** */
@@ -294,6 +295,10 @@ static int InitThread( generic_thread_t *p_decoder )
     }
     
     p_decoder->pts = 0;
+    p_decoder->p_buffer = NULL;
+    p_decoder->i_buffer = 0;
+    p_decoder->i_buffer_size = 0;
+
     return( i_result );
 }
 
@@ -313,7 +318,6 @@ static void EndThread( generic_thread_t *p_decoder )
     
     if( p_decoder->p_context != NULL)
     {
-        FREE( p_decoder->p_context->quant_store );
         FREE( p_decoder->p_context->extradata );
         avcodec_close( p_decoder->p_context );
         msg_Dbg( p_decoder->p_fifo, 
@@ -341,7 +345,7 @@ static void EndThread( generic_thread_t *p_decoder )
  * locales Functions
  *****************************************************************************/
 
-void E_( GetPESData )( u8 *p_buf, int i_max, pes_packet_t *p_pes )
+int E_( GetPESData )( u8 *p_buf, int i_max, pes_packet_t *p_pes )
 {   
     int i_copy; 
     int i_count;
@@ -372,6 +376,7 @@ void E_( GetPESData )( u8 *p_buf, int i_max, pes_packet_t *p_pes )
     {
         memset( p_buf, 0, i_max - i_count );
     }
+    return( i_count );
 }
 
 
@@ -386,6 +391,14 @@ static int ffmpeg_GetFfmpegCodec( vlc_fourcc_t i_fourcc,
 
     switch( i_fourcc )
     {
+#if 0
+        /* XXX don't use it */
+        case FOURCC_mpgv:
+            i_cat = VIDEO_ES;
+            i_codec = CODEC_ID_MPEG1VIDEO;
+            psz_name = "MPEG-1/2 Video";
+            break;
+#endif
 #if LIBAVCODEC_BUILD >= 4608 
         case FOURCC_DIV1:
         case FOURCC_div1:
@@ -479,6 +492,41 @@ static int ffmpeg_GetFfmpegCodec( vlc_fourcc_t i_fourcc,
             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;
+#if LIBAVCODEC_BUILD >= 4640
+        case FOURCC_mjpb:
+            i_cat = VIDEO_ES;
+            i_codec = CODEC_ID_MJPEGB;
+            psz_name = "Motion JPEG B";
+            break;
+#endif
+        case FOURCC_dvsl:
+        case FOURCC_dvsd:
+        case FOURCC_DVSD:
+        case FOURCC_dvhd:
+        case FOURCC_dvc:
+        case FOURCC_dvp:
+            i_cat = VIDEO_ES;
+            i_codec = CODEC_ID_DVVIDEO;
+            psz_name = "DV video";
+            break;
+
+#if LIBAVCODEC_BUILD >= 4655
+        case FOURCC_dvau:
+            i_cat = AUDIO_ES;
+            i_codec = CODEC_ID_DVAUDIO;
+            psz_name = "DV audio";
+            break;
+#endif
 
 #if LIBAVCODEC_BUILD >= 4632
         case FOURCC_WMA1:
@@ -493,15 +541,12 @@ static int ffmpeg_GetFfmpegCodec( vlc_fourcc_t i_fourcc,
             i_codec = CODEC_ID_WMAV2;
             psz_name ="Windows Media Audio 2";
             break;
-
-
+#endif
         default:
             i_cat = UNKNOWN_ES;
             i_codec = CODEC_ID_NONE;
             psz_name = NULL;
             break;
-#endif
-
     }
 
     if( i_codec != CODEC_ID_NONE )