-
Notifications
You must be signed in to change notification settings - Fork 219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
yuv420 alignment problem #42
Comments
The alignment should support only being a multiple of 2 in either direction, but there's an error in the firmware calculation of where the V plane sits and it is aligning it to an address that is a multiple of 32 (instead of 16). This only generates a different answer under a few odd conditions, which is why it hadn't been spotted before. I'm creating a firmware patch to resolve this. |
Having just written that, there's a complication which requires a bit more thought. Whilst the ISP will happily take a chroma stride that is only a multiple of 16, the start address for both chroma planes have to be on an address that is a multiple of 32. This causes this issue of the 2nd chroma plane start address being wrong when there are an odd number of lines in the 1st chroma plane, which equates to a luma height that is only a multiple of 2. Use of any of the 2 plane YUV formats, or YUV422 (no vertical chroma subsampling), avoids the restrictions, but are more of a pain to handle elsewhere. |
Hi 6by9, Thank you for your reply, Please correct me if I understand it wrong. This is 796x648 yuv data, if you need it. |
Active area != buffer size. I missed out the detail that the stride (number of bytes from the start of one line to the start of the next) of any buffer is rounded up to a multiple of 32. In V4L2 the stride of subsampled chroma planes is always the luma stride / subsample level. So your 796 pixel wide line will work on a stride (V4L2 In your original case of 800x650 That V start offset of 650000 (0x9eb10) is NOT 32byte aligned, so we get an issue in programming the ISP :-( |
I'll look to see if it is feasible to set the Y plane alignment to 64 bytes for YUV420. This will correctly set the U/V plane alignments to 32. Will need a simultaneous change to kernel + firmware. |
The simplest solution is to bump the alignment requirement for the luma bytesperline to 64 bytes, therefore the chroma planes will always be 32 byte aligned. It should be a simple case of changing the number at https://github.com/raspberrypi/linux/blob/rpi-5.10.y/drivers/staging/vc04_services/bcm2835-isp/bcm2835-isp-fmts.h#L51 |
Does the firmware isp component know about the kernel defined stride? I was expecting to have to change the alignment there as well. |
Once that's done, there's a similar alignment parameter in the firmware which is currently set as
on YUV420PackedPlanar to stop non-V4L2 users of that component hitting the same issue. |
It should get told it.
video.[width|height] is the buffer size. |
Great, I'll make the changes and give it a test. |
If looking at doing the firmware change too, output_min_alignment and lowres_min_alignment both need to be increased too as the output formaters have the same restriction as the input formater (chroma stride is 16bit aligned, but chroma base addresses are 32bit). |
Will do! |
This should now be fixed with the latest kernel change. @glddiv, please retest and close if it works for you. |
Hi 6by9 Hi all |
Hello everyone,
Recently I ran into a problem. When I previewed the 800x650 yuv420 image (or stored the yuv420 data), I found that the color was shifted.
The effect is as follows:
After reviewing the code, I aligned the yuv420 in the code to 4, temporarily solving the preview problem:
https://github.com/raspberrypi/libcamera-apps/blob/d50ec797589b6aa057eb20854c12e806d63f8965/libcamera_app.hpp#L211
Any ideas? Should yuv420 be aligned to 4?
The text was updated successfully, but these errors were encountered: