[FFmpeg-cvslog] libxvid: Add SSIM displaying through a libxvidcore plugin

Timothy Gu git at videolan.org
Mon Apr 7 03:27:03 CEST 2014


ffmpeg | branch: master | Timothy Gu <timothygu99 at gmail.com> | Tue Jul 30 19:40:45 2013 -0700| [c389a804943095ebf078daec6b64690d2c97069c] | committer: Vittorio Giovara

libxvid: Add SSIM displaying through a libxvidcore plugin

Signed-off-by: Vittorio Giovara <vittorio.giovara at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c389a804943095ebf078daec6b64690d2c97069c
---

 doc/encoders.texi    |   37 +++++++++++++++++++++++++++++++++++++
 libavcodec/libxvid.c |   19 +++++++++++++++++++
 libavcodec/version.h |    2 +-
 3 files changed, 57 insertions(+), 1 deletion(-)

diff --git a/doc/encoders.texi b/doc/encoders.texi
index 5c0e489..21beb17 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -518,6 +518,43 @@ be better than any of the two specified individually. In other
 words, the resulting quality will be the worse one of the two
 effects.
 
+ at item ssim
+Set structural similarity (SSIM) displaying method. Possible values:
+
+ at table @samp
+ at item off
+Disable displaying of SSIM information.
+
+ at item avg
+Output average SSIM at the end of encoding to stdout. The format of
+showing the average SSIM is:
+
+ at example
+Average SSIM: %f
+ at end example
+
+For users who are not familiar with C, %f means a float number, or
+a decimal (e.g. 0.939232).
+
+ at item frame
+Output both per-frame SSIM data during encoding and average SSIM at
+the end of encoding to stdout. The format of per-frame information
+is:
+
+ at example
+       SSIM: avg: %1.3f min: %1.3f max: %1.3f
+ at end example
+
+For users who are not familiar with C, %1.3f means a float number
+rounded to 3 digits after the dot (e.g. 0.932).
+
+ at end table
+
+ at item ssim_acc
+Set SSIM accuracy. Valid options are integers within the range of
+0-4, while 0 gives the most accurate result and 4 computes the
+fastest.
+
 @end table
 
 @section libx264
diff --git a/libavcodec/libxvid.c b/libavcodec/libxvid.c
index 42614ea..9970d86 100644
--- a/libavcodec/libxvid.c
+++ b/libavcodec/libxvid.c
@@ -62,6 +62,8 @@ struct xvid_context {
     unsigned char *inter_matrix;   /**< I-Frame Quant Matrix */
     int lumi_aq;                   /**< Lumi masking as an aq method */
     int variance_aq;               /**< Variance adaptive quantization */
+    int ssim;                      /**< SSIM information display mode */
+    int ssim_acc;                  /**< SSIM accuracy. 0: accurate. 4: fast. */
 };
 
 /**
@@ -354,6 +356,7 @@ static av_cold int xvid_encode_init(AVCodecContext *avctx)  {
     xvid_plugin_2pass2_t rc2pass2     = { 0 };
     xvid_plugin_lumimasking_t masking_l = { 0 }; /* For lumi masking */
     xvid_plugin_lumimasking_t masking_v = { 0 }; /* For variance AQ */
+    xvid_plugin_ssim_t ssim           = { 0 };
     xvid_gbl_init_t xvid_gbl_init     = { 0 };
     xvid_enc_create_t xvid_enc_create = { 0 };
     xvid_enc_plugin_t plugins[7];
@@ -552,6 +555,17 @@ static av_cold int xvid_encode_init(AVCodecContext *avctx)  {
         xvid_enc_create.num_plugins++;
     }
 
+    /* SSIM */
+    if (x->ssim) {
+        plugins[xvid_enc_create.num_plugins].func = xvid_plugin_ssim;
+        ssim.b_printstat = x->ssim == 2;
+        ssim.acc         = x->ssim_acc;
+        ssim.cpu_flags   = xvid_gbl_init.cpu_flags;
+        ssim.b_visualize = 0;
+        plugins[xvid_enc_create.num_plugins].param = &ssim;
+        xvid_enc_create.num_plugins++;
+    }
+
     /* Frame Rate and Key Frames */
     xvid_correct_framerate(avctx);
     xvid_enc_create.fincr = avctx->time_base.num;
@@ -780,6 +794,11 @@ static av_cold int xvid_encode_close(AVCodecContext *avctx) {
 static const AVOption options[] = {
     { "lumi_aq",     "Luminance masking AQ", OFFSET(lumi_aq),     AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE },
     { "variance_aq", "Variance AQ",          OFFSET(variance_aq), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE },
+    { "ssim",        "Show SSIM information to stdout",       OFFSET(ssim),              AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 2, VE, "ssim" },
+        { "off",     NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, INT_MIN, INT_MAX, VE, "ssim" },
+        { "avg",     NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, INT_MIN, INT_MAX, VE, "ssim" },
+        { "frame",   NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 2 }, INT_MIN, INT_MAX, VE, "ssim" },
+    { "ssim_acc",    "SSIM accuracy",                         OFFSET(ssim_acc),          AV_OPT_TYPE_INT, { .i64 = 2 }, 0, 4, VE },
     { NULL },
 };
 
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 738b816..a92213e 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -30,7 +30,7 @@
 
 #define LIBAVCODEC_VERSION_MAJOR 55
 #define LIBAVCODEC_VERSION_MINOR 45
-#define LIBAVCODEC_VERSION_MICRO  1
+#define LIBAVCODEC_VERSION_MICRO  2
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
                                                LIBAVCODEC_VERSION_MINOR, \



More information about the ffmpeg-cvslog mailing list