encoder: hevc: Fix the size over-flow for encoded buffer.
authorSreerenj Balachandran <sreerenj.balachandran@intel.com>
Thu, 28 May 2015 07:52:48 +0000 (10:52 +0300)
committerSreerenj Balachandran <sreerenj.balachandran@intel.com>
Thu, 28 May 2015 07:52:48 +0000 (10:52 +0300)
The approximation of 6 times compression ratio migh not
work in all cases. Especially when enabling I frames.
Provide large enough size for coded-buffer creation.

gst-libs/gst/vaapi/gstvaapiencoder_h265.c

index 7ba45a0..a9c09a7 100644 (file)
@@ -2274,9 +2274,9 @@ set_context_info (GstVaapiEncoder * base_encoder)
   base_encoder->num_ref_frames =
       ((encoder->num_bframes ? 2 : 1) + DEFAULT_SURFACES_COUNT);
 
-  /* Take an approximation of 6 times compression ratio */
-  base_encoder->codedbuf_size = ((GST_ROUND_UP_32 (vip->width) *
-          GST_ROUND_UP_32 (vip->height) * 12 / 6)) / 8;
+  /* Only YUV 4:2:0 formats are supported for now. */
+  base_encoder->codedbuf_size += GST_ROUND_UP_32 (vip->width) *
+          GST_ROUND_UP_32 (vip->height) * 3 / 2;
 
   return GST_VAAPI_ENCODER_STATUS_SUCCESS;
 }