]> git.sesse.net Git - vlc/commitdiff
* modules/codec/ffmpeg/*: new --ffmpeg-lowres option to force video decoding at a...
authorGildas Bazin <gbazin@videolan.org>
Sun, 26 Sep 2004 13:39:00 +0000 (13:39 +0000)
committerGildas Bazin <gbazin@videolan.org>
Sun, 26 Sep 2004 13:39:00 +0000 (13:39 +0000)
modules/codec/ffmpeg/demux.c
modules/codec/ffmpeg/encoder.c
modules/codec/ffmpeg/ffmpeg.c
modules/codec/ffmpeg/ffmpeg.h
modules/codec/ffmpeg/video.c

index e2342fcf25396fc1e41f5386c457613d6a9b2165..7535f732454a8d291f6a5190f670c73b8be48745 100644 (file)
@@ -5,7 +5,7 @@
  * $Id$
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
- *          Gildas Bazin <gbazin@netcourrier.com>
+ *          Gildas Bazin <gbazin@videolan.org>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
index aa74473af69ee075d0dd43ca7bbbc57d343a68e2..9a526ab8a2567203e43d3ff0194b31e82b4b0a0c 100644 (file)
@@ -306,6 +306,8 @@ int E_(OpenEncoder)( vlc_object_t *p_this )
 
     if( p_enc->fmt_in.i_cat == VIDEO_ES )
     {
+        int i_aspect_num, i_aspect_den;
+
         if( !p_enc->fmt_in.video.i_width || !p_enc->fmt_in.video.i_height )
         {
             msg_Warn( p_enc, "invalid size %ix%i", p_enc->fmt_in.video.i_width,
@@ -335,11 +337,14 @@ int E_(OpenEncoder)( vlc_object_t *p_this )
         p_context->b_frame_strategy = 0;
 
 #if LIBAVCODEC_BUILD >= 4687
+        av_reduce( &i_aspect_num, &i_aspect_den,
+                   p_enc->fmt_in.video.i_aspect,
+                   VOUT_ASPECT_FACTOR, 1 << 30 /* something big */ );
         av_reduce( &p_context->sample_aspect_ratio.num,
                    &p_context->sample_aspect_ratio.den,
-                   p_enc->fmt_in.video.i_aspect *
+                   i_aspect_num *
                    (int64_t)p_context->height / p_context->width,
-                   VOUT_ASPECT_FACTOR, 1 << 30 /* something big */ );
+                   i_aspect_den, 1 << 30 /* something big */ );
 #else
         p_context->aspect_ratio = ((float)p_enc->fmt_in.video.i_aspect) /
             VOUT_ASPECT_FACTOR;
index 71f57ba1f40229e290704d10b70c50b6a8ebbcc1..bd36500243c2f2f1743378231c0b1ba93d772561 100644 (file)
@@ -98,6 +98,9 @@ vlc_module_begin();
         VLC_FALSE );
     add_integer ( "ffmpeg-vismv", 0, NULL, VISMV_TEXT, VISMV_LONGTEXT,
         VLC_TRUE );
+    add_integer ( "ffmpeg-lowres", 0, NULL, LOWRES_TEXT, LOWRES_LONGTEXT,
+        VLC_TRUE );
+        change_integer_range( 0, 2 );
 
 #ifdef LIBAVCODEC_PP
     add_integer( "ffmpeg-pp-q", 0, NULL, PP_Q_TEXT, PP_Q_LONGTEXT, VLC_FALSE );
@@ -270,16 +273,6 @@ static void CloseDecoder( vlc_object_t *p_this )
     decoder_t *p_dec = (decoder_t *)p_this;
     decoder_sys_t *p_sys = p_dec->p_sys;
 
-    if( p_sys->p_context )
-    {
-        if( p_sys->p_context->extradata )
-            free( p_sys->p_context->extradata );
-
-        avcodec_close( p_sys->p_context );
-        msg_Dbg( p_dec, "ffmpeg codec (%s) stopped", p_sys->psz_namecodec );
-        av_free( p_sys->p_context );
-    }
-
     switch( p_sys->i_cat )
     {
     case AUDIO_ES:
@@ -290,9 +283,19 @@ static void CloseDecoder( vlc_object_t *p_this )
         break;
     }
 
+    if( p_sys->p_context )
+    {
+        if( p_sys->p_context->extradata )
+            free( p_sys->p_context->extradata );
+
+        avcodec_close( p_sys->p_context );
+        msg_Dbg( p_dec, "ffmpeg codec (%s) stopped", p_sys->psz_namecodec );
+        av_free( p_sys->p_context );
+    }
+
     free( p_sys );
 }
-  
+
 /*****************************************************************************
  * local Functions
  *****************************************************************************/
index b3047fb557b16d21004b1d0b7909df52eb4d3046..349ace8558fd0b5f87f49936f16f8d75a4de215f 100644 (file)
@@ -124,6 +124,10 @@ void E_(ClosePostproc)( decoder_t *, void * );
     "2 - visualize forward predicted MVs of B frames\n" \
     "4 - visualize backward predicted MVs of B frames" )
 
+#define LOWRES_TEXT N_( "Low resolution decoding" )
+#define LOWRES_LONGTEXT N_( "Will only decode a low resolution version of " \
+    "the video." )
+
 #define LIBAVCODEC_PP_TEXT N_("ffmpeg post processing filter chains")
 /* FIXME (cut/past from ffmpeg */
 #define LIBAVCODEC_PP_LONGTEXT \
index 525af4254b6e273a9265cd1a04dff0975b2a8791..f8819e264b1a124a47246b57affa53aff3c646f0 100644 (file)
@@ -152,6 +152,11 @@ static inline picture_t *ffmpeg_NewPictBuf( decoder_t *p_dec,
         return NULL; /* invalid display size */
     }
 
+#if LIBAVCODEC_BUILD >= 4723
+    p_dec->fmt_out.video.i_width >>= p_context->lowres;
+    p_dec->fmt_out.video.i_height >>= p_context->lowres;
+#endif
+
     if( !p_dec->fmt_out.i_codec )
     {
         /* we make conversion if possible*/
@@ -245,6 +250,12 @@ int E_(InitVideoDec)( decoder_t *p_dec, AVCodecContext *p_context,
     if( val.i_int ) p_sys->p_context->debug_mv = val.i_int;
 #endif
 
+    var_Create( p_dec, "ffmpeg-lowres", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
+    var_Get( p_dec, "ffmpeg-lowres", &val );
+#if LIBAVCODEC_BUILD >= 4723
+    if( val.i_int > 0 && val.i_int <= 2 ) p_sys->p_context->lowres = val.i_int;
+#endif
+
     /* ***** ffmpeg frame skipping ***** */
     var_Create( p_dec, "ffmpeg-hurry-up", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
     var_Get( p_dec, "ffmpeg-hurry-up", &val );