]> git.sesse.net Git - vlc/commitdiff
* modules/codec/ffmpeg/*:
authorGildas Bazin <gbazin@videolan.org>
Wed, 28 Jul 2004 10:37:24 +0000 (10:37 +0000)
committerGildas Bazin <gbazin@videolan.org>
Wed, 28 Jul 2004 10:37:24 +0000 (10:37 +0000)
  - added fourcc for SNOW and DTS.
  - added 'qscale' (fixed quantizer scale - VBR) and 'strict' (standard compliance) encoding options.

modules/codec/ffmpeg/encoder.c
modules/codec/ffmpeg/ffmpeg.c
modules/codec/ffmpeg/ffmpeg.h

index b304668ad132f168411e9062941aa4adecd00d88..aa74473af69ee075d0dd43ca7bbbc57d343a68e2 100644 (file)
@@ -134,13 +134,14 @@ struct encoder_sys_t
     int        i_noise_reduction;
     vlc_bool_t b_mpeg4_matrix;
     vlc_bool_t b_trellis;
+    int        i_quality; /* for VBR */
 };
 
 static const char *ppsz_enc_options[] = {
     "keyint", "bframes", "vt", "qmin", "qmax", "hq", "strict_rc",
     "rc-buffer-size", "rc-buffer-aggressivity", "pre-me", "hurry-up",
     "interlace", "i-quant-factor", "noise-reduction", "mpeg4-matrix",
-    "trellis", NULL
+    "trellis", "qscale", "strict", NULL
 };
 
 /*****************************************************************************
@@ -274,6 +275,10 @@ int E_(OpenEncoder)( vlc_object_t *p_this )
     var_Get( p_enc, ENC_CFG_PREFIX "mpeg4-matrix", &val );
     p_sys->b_mpeg4_matrix = val.b_bool;
 
+    var_Get( p_enc, ENC_CFG_PREFIX "qscale", &val );
+    if( val.f_float < 0.01 || val.f_float > 255.0 ) val.f_float = 0;
+    p_sys->i_quality = (int)(FF_QP2LAMBDA * val.f_float + 0.5);
+
     var_Get( p_enc, ENC_CFG_PREFIX "hq", &val );
     if( val.psz_string && *val.psz_string )
     {
@@ -295,6 +300,10 @@ int E_(OpenEncoder)( vlc_object_t *p_this )
     var_Get( p_enc, ENC_CFG_PREFIX "trellis", &val );
     p_sys->b_trellis = val.b_bool;
 
+    var_Get( p_enc, ENC_CFG_PREFIX "strict", &val );
+    if( val.i_int < - 1 || val.i_int > 1 ) val.i_int = 0;
+    p_context->strict_std_compliance = val.i_int;
+
     if( p_enc->fmt_in.i_cat == VIDEO_ES )
     {
         if( !p_enc->fmt_in.video.i_width || !p_enc->fmt_in.video.i_height )
@@ -327,10 +336,10 @@ int E_(OpenEncoder)( vlc_object_t *p_this )
 
 #if LIBAVCODEC_BUILD >= 4687
         av_reduce( &p_context->sample_aspect_ratio.num,
-                  &p_context->sample_aspect_ratio.den,
-                  p_enc->fmt_in.video.i_aspect *
-                  (int64_t)p_context->height / p_context->width,
-                  VOUT_ASPECT_FACTOR, 1 << 30 /* something big */ );
+                   &p_context->sample_aspect_ratio.den,
+                   p_enc->fmt_in.video.i_aspect *
+                   (int64_t)p_context->height / p_context->width,
+                   VOUT_ASPECT_FACTOR, 1 << 30 /* something big */ );
 #else
         p_context->aspect_ratio = ((float)p_enc->fmt_in.video.i_aspect) /
             VOUT_ASPECT_FACTOR;
@@ -392,6 +401,14 @@ int E_(OpenEncoder)( vlc_object_t *p_this )
         p_context->max_qdiff = 3;
 
         p_context->mb_decision = p_sys->i_hq;
+
+        if( p_sys->i_quality )
+        {
+            p_context->flags |= CODEC_FLAG_QSCALE;
+#if LIBAVCODEC_BUILD >= 4668
+            p_context->global_quality = p_sys->i_quality;
+#endif
+        }
     }
     else if( p_enc->fmt_in.i_cat == AUDIO_ES )
     {
@@ -662,6 +679,8 @@ static block_t *EncodeVideo( encoder_t *p_enc, picture_t *p_pict )
         }
     }
 
+    frame.quality = p_sys->i_quality;
+
     i_out = avcodec_encode_video( p_sys->p_context, p_sys->p_buffer_out,
                                   AVCODEC_MAX_VIDEO_FRAME_SIZE, &frame );
 
index da2f052de147d0a66257bef410be6bd20e7a9f7f..ce499e4cd6d010cd987f0fb1df7758d4f2140202 100644 (file)
@@ -145,6 +145,10 @@ vlc_module_begin();
                  ENC_QMAX_TEXT, ENC_QMAX_LONGTEXT, VLC_TRUE );
     add_bool( ENC_CFG_PREFIX "trellis", 0, NULL,
               ENC_TRELLIS_TEXT, ENC_TRELLIS_LONGTEXT, VLC_TRUE );
+    add_float( ENC_CFG_PREFIX "qscale", 0, NULL,
+               ENC_QSCALE_TEXT, ENC_QSCALE_LONGTEXT, VLC_TRUE );
+    add_integer( ENC_CFG_PREFIX "strict", 0, NULL,
+                 ENC_STRICT_TEXT, ENC_STRICT_LONGTEXT, VLC_TRUE );
 
     /* demux submodule */
     add_submodule();
@@ -670,6 +674,12 @@ static struct
       VIDEO_ES, "Sierra VMD Video" },
 #endif
 
+#if LIBAVCODEC_BUILD >= 4718
+    /* FFMPEG's SNOW wavelet codec */
+    { VLC_FOURCC('S','N','O','W'), CODEC_ID_SNOW,
+      VIDEO_ES, "FFMpeg SNOW wavelet Video" },
+#endif
+
     /*
      *  Audio Codecs
      */
@@ -718,6 +728,12 @@ static struct
     { VLC_FOURCC('a','5','2','b'), CODEC_ID_AC3, /* VLC specific hack */
       AUDIO_ES, "A52 Audio (aka AC3)" },
 
+#if LIBAVCODEC_BUILD >= 4718
+    /* DTS Audio */
+    { VLC_FOURCC('d','t','s',' '), CODEC_ID_DTS,
+      AUDIO_ES, "DTS Audio" },
+#endif
+
     /* AAC audio */
     { VLC_FOURCC('m','p','4','a'), CODEC_ID_AAC,
       AUDIO_ES, "MPEG AAC Audio" },
index 61700ffbf3fd991748326bee108eadeda1595053..c0d54ae8213838e2f828260fe77fa807f50456a4 100644 (file)
@@ -230,3 +230,11 @@ void E_(ClosePostproc)( decoder_t *, void * );
 #define ENC_TRELLIS_TEXT N_( "Enable trellis quantization" )
 #define ENC_TRELLIS_LONGTEXT N_( "Allows you to enable trellis " \
   "quantization (rate distortion for block coefficients)." )
+
+#define ENC_QSCALE_TEXT N_( "Use fixed video quantizer scale" )
+#define ENC_QSCALE_LONGTEXT N_( "Allows you to specify a fixed video " \
+  "quantizer scale for VBR encoding (accepted values: 0.01 to 255.0)." )
+
+#define ENC_STRICT_TEXT N_( "Strict standard compliance" )
+#define ENC_STRICT_LONGTEXT N_( "Allows you to force a strict standard " \
+  "compliance when encoding (accepted values: -1, 0, 1)." )