From ee75c40eff3ed516535e8b150e5a17206e73d81a Mon Sep 17 00:00:00 2001
From: Hugues Fruchet <hugues.fruchet@foss.st.com>
Date: Wed, 30 Aug 2023 10:48:22 +0200
Subject: [PATCH 1/3] v4l2codecs: fix support of unaligned videos

Current implementation fails on frame input mapping when
driver returns an aligned width & height.
Fix this by ignoring aligned width & height returned by S_FMT,
it is useless till buffer alignment is extrapolated later on
from bytesperline and sizeimage S_FMT values.

Signed-off-by: Hugues Fruchet <hugues.fruchet@foss.st.com>
---
 sys/v4l2codecs/gstv4l2encoder.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/sys/v4l2codecs/gstv4l2encoder.c b/sys/v4l2codecs/gstv4l2encoder.c
index e2ef423..eabb74a 100644
--- a/sys/v4l2codecs/gstv4l2encoder.c
+++ b/sys/v4l2codecs/gstv4l2encoder.c
@@ -415,6 +415,10 @@ gst_v4l2_encoder_select_sink_format (GstV4l2Encoder * self, GstVideoInfo * in,
     }
   }
 
+
+    fmt.fmt.pix_mp.width = width;
+    fmt.fmt.pix_mp.height = height;
+
   if (!gst_v4l2_format_to_video_info (&fmt, out)) {
     GST_ERROR_OBJECT (self, "Unsupported V4L2 pixelformat %" GST_FOURCC_FORMAT,
         GST_FOURCC_ARGS (fmt.fmt.pix_mp.pixelformat));
-- 
2.25.1

