[vlc-devel] [PATCH] Mod:: Added Quality factor to sout ffmpeg for JPEG encoding

noxelia at gmail.com noxelia at gmail.com
Wed Aug 20 09:00:43 CEST 2008


From: basOS G <noxelia 4t gmail , com>

One feuture that is to be combined with the snapshot functionality is this new
 --sout-ffmpeg-qcompress value for tuning JPEG Quality factor. The default was 0.5..
Now you can play between 0~1 and see the artifacts..
I don't know if this parameter has side effects on video encoding (possibly yes)
but its main usage is to be combined with --snapshot-format jpg.
Note: There is another parameter (blur) that may have jpeq quality results but with
a quick test i didn't see much difference, so it is not exported.
---
 modules/codec/avcodec/avcodec.c |    4 +++-
 modules/codec/avcodec/avcodec.h |    3 +++
 modules/codec/avcodec/encoder.c |    9 ++++++++-
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/modules/codec/avcodec/avcodec.c b/modules/codec/avcodec/avcodec.c
index 3fa80a5..30dde7e 100644
--- a/modules/codec/avcodec/avcodec.c
+++ b/modules/codec/avcodec/avcodec.c
@@ -185,7 +185,9 @@ vlc_module_begin();
                  ENC_LUMA_ELIM_TEXT, ENC_LUMA_ELIM_LONGTEXT, true );
     add_integer( ENC_CFG_PREFIX "chroma-elim-threshold", 0, NULL,
                  ENC_CHROMA_ELIM_TEXT, ENC_CHROMA_ELIM_LONGTEXT, true );
-
+//MODA JPEG Q
+   add_float_with_range( ENC_CFG_PREFIX "qcompress", 0.5, 0.0, 1.0, NULL,
+                 ENC_QCOMPRESS_TEXT, NULL, true );
 #if LIBAVCODEC_VERSION_INT >= ((51<<16)+(40<<8)+4)
     /* Audio AAC encoder profile */
     add_string( ENC_CFG_PREFIX "aac-profile", "main", NULL,
diff --git a/modules/codec/avcodec/avcodec.h b/modules/codec/avcodec/avcodec.h
index 591d125..0c57840 100644
--- a/modules/codec/avcodec/avcodec.h
+++ b/modules/codec/avcodec/avcodec.h
@@ -224,6 +224,9 @@ void EndAudioDec( decoder_t *p_dec );
   "the PSNR isn't much changed (default: 0.0). The H264 specification " \
   "recommends 7." )
 
+//MODA JPEG Q
+#define ENC_QCOMPRESS_TEXT N_("Q Compress Value")
+
 #if LIBAVCODEC_VERSION_INT >= ((51<<16)+(40<<8)+4)
 #define ENC_PROFILE_TEXT N_( "Specify AAC audio profile to use" )
 #define ENC_PROFILE_LONGTEXT N_( "Specify the AAC audio profile to use " \
diff --git a/modules/codec/avcodec/encoder.c b/modules/codec/avcodec/encoder.c
index acd092f..e80293c 100644
--- a/modules/codec/avcodec/encoder.c
+++ b/modules/codec/avcodec/encoder.c
@@ -143,6 +143,7 @@ struct encoder_sys_t
     int        i_quality; /* for VBR */
     float      f_lumi_masking, f_dark_masking, f_p_masking, f_border_masking;
     int        i_luma_elim, i_chroma_elim;
+    float      f_qcompress ; /* MODA for JPEG QAULITY */
 #if LIBAVCODEC_VERSION_INT >= ((51<<16)+(40<<8)+4)
     int        i_aac_profile; /* AAC profile to use.*/
 #endif
@@ -161,6 +162,7 @@ static const char *const ppsz_enc_options[] = {
 #if LIBAVCODEC_VERSION_INT >= ((51<<16)+(40<<8)+4)
      "aac-profile",
 #endif
+/*MODA JPEG Q*/  "qcompress",
      NULL
 };
 
@@ -423,7 +425,12 @@ int OpenEncoder( vlc_object_t *p_this )
 
         /* Defaults from ffmpeg.c */
         p_context->qblur = 0.5;
-        p_context->qcompress = 0.5;
+        //MODA JPEG Q was 0.5
+        var_Get( p_enc, ENC_CFG_PREFIX "qcompress", &val );
+        if( val.f_float < 0.01 || val.f_float > 1.00 ) val.f_float = 0.5;
+        p_context->qcompress = val.f_float ;
+        msg_Dbg( p_enc, "Q Compress Value= %.2f", p_context->qcompress );
+
         p_context->b_quant_offset = 1.25;
         p_context->b_quant_factor = 1.25;
         p_context->i_quant_offset = 0.0;
-- 
1.5.4.3




More information about the vlc-devel mailing list