diff options
author | Gwenole Beauchesne <gwenole.beauchesne@intel.com> | 2013-12-05 18:13:54 +0100 |
---|---|---|
committer | Gwenole Beauchesne <gwenole.beauchesne@intel.com> | 2013-12-05 18:13:54 +0100 |
commit | 2940a74ea45956edb8ec3e94bb983e255fcf0dc1 (patch) | |
tree | 91d0a0b25c8c85922b08fb96700fab12332d4430 /gst-libs/gst/vaapi/gstvaapiencoder_mpeg2.c | |
parent | b864d1f71acc47bd41b8e7171c4ad4d6628849f4 (diff) |
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.
Diffstat (limited to 'gst-libs/gst/vaapi/gstvaapiencoder_mpeg2.c')
-rw-r--r-- | gst-libs/gst/vaapi/gstvaapiencoder_mpeg2.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/gst-libs/gst/vaapi/gstvaapiencoder_mpeg2.c b/gst-libs/gst/vaapi/gstvaapiencoder_mpeg2.c index 90a6e23d..62d98eff 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 |