[Pkg-gstreamer-commits] [gstreamer-vaapi] 120/176: encoder: h264: improve automatic bitrate calculation.

Vincent Cheng vcheng at moszumanska.debian.org
Tue Jun 3 08:09:33 UTC 2014


This is an automated email from the git hooks/post-receive script.

vcheng pushed a commit to branch upstream
in repository gstreamer-vaapi.

commit c7a2095b78f9b543b9e97b8556d1d67f2e23487b
Author: Gwenole Beauchesne <gwenole.beauchesne at intel.com>
Date:   Mon Jan 13 11:49:14 2014 +0100

    encoder: h264: improve automatic bitrate calculation.
    
    For non "Constant-QP" modes, we could provide more reasonable heuristics
    for the target bitrate. In general, 48 bits per macroblock with all the
    useful coding tools enable looks safe enough. Then, this rate is raised
    by +10% to +15% for each coding tool that is disabled.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=719699
---
 gst-libs/gst/vaapi/gstvaapiencoder_h264.c | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/gst-libs/gst/vaapi/gstvaapiencoder_h264.c b/gst-libs/gst/vaapi/gstvaapiencoder_h264.c
index 0362f84..4d98c55 100644
--- a/gst-libs/gst/vaapi/gstvaapiencoder_h264.c
+++ b/gst-libs/gst/vaapi/gstvaapiencoder_h264.c
@@ -1360,16 +1360,28 @@ ensure_bitrate (GstVaapiEncoderH264 * encoder)
 {
   GstVaapiEncoder *const base_encoder = GST_VAAPI_ENCODER_CAST (encoder);
 
-  /* Default compression: 64 bits per macroblock */
+  /* Default compression: 48 bits per macroblock in "high-compression" mode */
   switch (GST_VAAPI_ENCODER_RATE_CONTROL (encoder)) {
     case GST_VAAPI_RATECONTROL_CBR:
     case GST_VAAPI_RATECONTROL_VBR:
     case GST_VAAPI_RATECONTROL_VBR_CONSTRAINED:
-      if (!base_encoder->bitrate)
-        base_encoder->bitrate = GST_VAAPI_ENCODER_WIDTH (encoder) *
-            GST_VAAPI_ENCODER_HEIGHT (encoder) *
+      if (!base_encoder->bitrate) {
+        /* According to the literature and testing, CABAC entropy coding
+           mode could provide for +10% to +18% improvement in general,
+           thus estimating +15% here ; and using adaptive 8x8 transforms
+           in I-frames could bring up to +10% improvement. */
+        guint bits_per_mb = 48;
+        if (!encoder->use_cabac)
+          bits_per_mb += (bits_per_mb * 15) / 100;
+        if (!encoder->use_dct8x8)
+          bits_per_mb += (bits_per_mb * 10) / 100;
+
+        base_encoder->bitrate =
+            encoder->mb_width * encoder->mb_height * bits_per_mb *
             GST_VAAPI_ENCODER_FPS_N (encoder) /
-            GST_VAAPI_ENCODER_FPS_D (encoder) / 4 / 1000;
+            GST_VAAPI_ENCODER_FPS_D (encoder) / 1000;
+        GST_INFO ("target bitrate computed to %u kbps", base_encoder->bitrate);
+      }
       break;
     default:
       base_encoder->bitrate = 0;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gstreamer/gstreamer-vaapi.git



More information about the Pkg-gstreamer-commits mailing list