Why is the v4l2 buffer size greater than the actual image size?

Hello,

I’m using the Genio 1200 EVK with the Sony IMX214 camera.
I found that with some resolutions and formats, the buffer size is greater than the actual image size.

For example, I use the below commands to fetch the camera image

  1. Get the Video node for recording video
    $ v4l2-ctl --list-devices
    ...
    mtk-v4l2-camera (platform:mtkcam0):
     /dev/video116 --> Preview
     /dev/video118 --> Video
     /dev/video119 --> Capture
     /dev/media4
    
  2. Run the following command to record the video stream from csi0 camera
    $ v4l2-ctl --set-fmt-video=width=2104,height=1560,pixelformat=NM12 --stream-mmap=1 --stream-count=10 --stream-to=~/v4l2-NM12-2104x1560.yuv -d /dev/video118
    

The width of the real image I got is 2112 instead of 2104. Why is that?

Thanks

The reason is that the ISP hardware requires width and height alignments causing the driver to adjust the buffer size accordingly.

For more details, please refer to Buffer Size Is Larger Than Image Size.