omxvideoenc: Add stride check for input buffer extraction
authorShinya Saito <ssaito@igel.co.jp>
Tue, 10 Dec 2019 09:34:25 +0000 (18:34 +0900)
committerShinya Saito <ssaito@igel.co.jp>
Wed, 11 Dec 2019 06:53:29 +0000 (15:53 +0900)
Stride of input buffer may be different from
that of omx input port even if both sizes are the same.

omx/gstomxvideoenc.c

index 15f55f9..3f31d23 100644 (file)
@@ -2497,6 +2497,8 @@ gst_omx_video_enc_fill_buffer (GstOMXVideoEnc * self, GstBuffer * inbuf,
   OMX_PARAM_PORTDEFINITIONTYPE *port_def = &self->enc_in_port->port_def;
   gboolean ret = FALSE;
   GstVideoFrame frame;
+  GstVideoMeta *meta = gst_buffer_get_video_meta (inbuf);
+  gint stride = meta ? meta->stride[0] : info->stride[0];
 
   if (info->width != port_def->format.video.nFrameWidth ||
       info->height != port_def->format.video.nFrameHeight) {
@@ -2546,8 +2548,9 @@ gst_omx_video_enc_fill_buffer (GstOMXVideoEnc * self, GstBuffer * inbuf,
   }
 
   /* Same strides and everything */
-  if (gst_buffer_get_size (inbuf) ==
-      outbuf->omx_buf->nAllocLen - outbuf->omx_buf->nOffset) {
+  if ((gst_buffer_get_size (inbuf) ==
+          outbuf->omx_buf->nAllocLen - outbuf->omx_buf->nOffset) &&
+      (stride == port_def->format.video.nStride)) {
     outbuf->omx_buf->nFilledLen = gst_buffer_get_size (inbuf);
 
     GST_LOG_OBJECT (self, "Matched strides - direct copy %u bytes",