[Pkg-gstreamer-commits] [gstreamer-vaapi] 44/176: encoder: fix computation of max coded buffer size (again).

Vincent Cheng vcheng at moszumanska.debian.org
Tue Jun 3 08:09:26 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 2940a74ea45956edb8ec3e94bb983e255fcf0dc1
Author: Gwenole Beauchesne <gwenole.beauchesne at intel.com>
Date:   Thu Dec 5 18:13:54 2013 +0100

    encoder: fix computation of max coded buffer size (again).
    
    The previous fix was only valid to express the maximum size of the
    macroblock layer, i.e. without any headers. Now, also account for
    the slice headers and top picture header, but also any other header
    we might stuff into the VA coded buffer, e.g. sequence headers.
---
 gst-libs/gst/vaapi/gstvaapiencoder_h264.c  | 22 ++++++++++++++++++++++
 gst-libs/gst/vaapi/gstvaapiencoder_mpeg2.c | 22 ++++++++++++++++++++++
 2 files changed, 44 insertions(+)

diff --git a/gst-libs/gst/vaapi/gstvaapiencoder_h264.c b/gst-libs/gst/vaapi/gstvaapiencoder_h264.c
index a9a9b13..cc5dbcc 100644
--- a/gst-libs/gst/vaapi/gstvaapiencoder_h264.c
+++ b/gst-libs/gst/vaapi/gstvaapiencoder_h264.c
@@ -1592,6 +1592,15 @@ gst_vaapi_encoder_h264_set_context_info (GstVaapiEncoder * base_encoder)
   GstVaapiContextInfo *const cip = &base_encoder->context_info;
   const guint DEFAULT_SURFACES_COUNT = 3;
 
+  /* Maximum sizes for common headers (in bits) */
+  enum {
+    MAX_SPS_HDR_SIZE = 16473,
+    MAX_VUI_PARAMS_SIZE = 210,
+    MAX_HRD_PARAMS_SIZE = 4103,
+    MAX_PPS_HDR_SIZE = 101,
+    MAX_SLICE_HDR_SIZE = 397 + 2572 + 6670 + 2402,
+  };
+
   cip->profile = encoder->profile;
   cip->ref_frames = (encoder->b_frame_num ? 2 : 1) + DEFAULT_SURFACES_COUNT;
 
@@ -1600,6 +1609,19 @@ gst_vaapi_encoder_h264_set_context_info (GstVaapiEncoder * base_encoder)
   /* XXX: check profile and compute RawMbBits */
   base_encoder->codedbuf_size = (GST_ROUND_UP_16 (cip->width) *
       GST_ROUND_UP_16 (cip->height) / 256) * 400;
+
+  /* Account for SPS header */
+  /* XXX: exclude scaling lists, MVC/SVC extensions */
+  base_encoder->codedbuf_size += 4 + GST_ROUND_UP_8 (MAX_SPS_HDR_SIZE +
+      MAX_VUI_PARAMS_SIZE + 2 * MAX_HRD_PARAMS_SIZE) / 8;
+
+  /* Account for PPS header */
+  /* XXX: exclude slice groups, scaling lists, MVC/SVC extensions */
+  base_encoder->codedbuf_size += 4 + GST_ROUND_UP_8 (MAX_PPS_HDR_SIZE) / 8;
+
+  /* Account for slice header. At most 200 slices are supported */
+  base_encoder->codedbuf_size += 200 * (4 +
+      GST_ROUND_UP_8 (MAX_SLICE_HDR_SIZE) / 8);
 }
 
 static GstCaps *
diff --git a/gst-libs/gst/vaapi/gstvaapiencoder_mpeg2.c b/gst-libs/gst/vaapi/gstvaapiencoder_mpeg2.c
index 90a6e23..62d98ef 100644
--- a/gst-libs/gst/vaapi/gstvaapiencoder_mpeg2.c
+++ b/gst-libs/gst/vaapi/gstvaapiencoder_mpeg2.c
@@ -633,6 +633,16 @@ gst_vaapi_encoder_mpeg2_set_context_info (GstVaapiEncoder * base_encoder)
   GstVaapiEncoderMpeg2 *const encoder = GST_VAAPI_ENCODER_MPEG2 (base_encoder);
   GstVaapiContextInfo *const cip = &base_encoder->context_info;
 
+  /* Maximum sizes for common headers (in bytes) */
+  enum {
+    MAX_SEQ_HDR_SIZE = 140,
+    MAX_SEQ_EXT_SIZE = 10,
+    MAX_GOP_SIZE = 8,
+    MAX_PIC_HDR_SIZE = 10,
+    MAX_PIC_EXT_SIZE = 11,
+    MAX_SLICE_HDR_SIZE = 8,
+  };
+
   cip->profile = to_vaapi_profile (encoder->profile);
   cip->ref_frames = 2;
 
@@ -640,6 +650,18 @@ gst_vaapi_encoder_mpeg2_set_context_info (GstVaapiEncoder * base_encoder)
      have a limit of 4608 bits per macroblock. */
   base_encoder->codedbuf_size = (GST_ROUND_UP_16 (cip->width) *
       GST_ROUND_UP_16 (cip->height) / 256) * 576;
+
+  /* Account for Sequence, GOP, and Picture headers */
+  /* XXX: exclude unused Sequence Display Extension, Sequence Scalable
+     Extension, Quantization Matrix Extension, Picture Display Extension,
+     Picture Temporal Scalable Extension, Picture Spatial Scalable
+     Extension */
+  base_encoder->codedbuf_size += MAX_SEQ_HDR_SIZE + MAX_SEQ_EXT_SIZE +
+      MAX_GOP_SIZE + MAX_PIC_HDR_SIZE + MAX_PIC_EXT_SIZE;
+
+  /* Account for Slice headers. We use one slice per line of macroblock */
+  base_encoder->codedbuf_size += (GST_ROUND_UP_16 (cip->height) / 16) *
+      MAX_SLICE_HDR_SIZE;
 }
 
 static gboolean

-- 
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