Firstly, thank you so much for your seemingly endless patience...!
Secondly, I think I get it. Since I really only care about the intensity channel, I'll phrase it like this:
- The length of the rows in the Y plane is the width rounded up to the next multiple of 64.
- The length of the columns in the Y plane is the height rounded up to the next multiple of 2.
- The size of one single frame (Y, u, and v planes together) is 1.5 the size of the Y plane alone.
I tested this with a bunch of different even widths and even heights, odd widths and even heights, and it all worked perfectly. However -- and I'm only asking to make sure I didn't miss something mysterious here -- it failed when I tested this with a bunch of different even and/or odd widths and
odd heights. The failure was evident in three manners:
- when reading all of the bytes from the pipe, the number of bytes was not divisible by the calculated size of the YUV frame (as explained above).
- Saving a bunch of Y frames showed a visible dark bar on the right (to be clear, as always I not only reshaped the frame following the above, but also cropped out the intended size, as I always do).
- Saving all of the frames from the pipe showed how the imaged scene shifted to the left with each subsequent frame (and the artifact bar grew in width)
I'd like to add that, for example, the following
Code: Select all
libcamera-vid -n --framerate 10 --width 1640 --height 921 -t 2000 --codec yuv420 -o -
produced exactly 29895424 bytes. This number should be divisible by the number of frames, and the result of that division times two should be divisible by 3 (one frame is composed of one Y plane and two UV planes that are each a quarter of the size of the Y plane, so if we have two of these frames then dividing that by 3 will give the size of the Y plane). It is not. So something fishy is going on here when the height is odd.
Maybe the height should simply never be odd? Maybe there should be a warning/error about that?