Skip to content
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

Misalignment in 4:2:0 YUV -> BGR conversion #89

Open
Qengineering opened this issue Sep 24, 2024 · 2 comments
Open

Misalignment in 4:2:0 YUV -> BGR conversion #89

Qengineering opened this issue Sep 24, 2024 · 2 comments

Comments

@Qengineering
Copy link

When converting 1920x1080 4:2:0 YUV (NV12) to BGR (8-bits) you get a misalignment in the green channel.
Tested on the Rock5C
Screenshot from 2024-09-24 10-16-16

Code:

    // Create RGA input buffer (NV12)
    rga_buffer_t src;
    memset(&src, 0, sizeof(rga_buffer_t));
    src.width = tmp_frame->width;
    src.height = tmp_frame->height;
    src.wstride = tmp_frame->linesize[0];
    src.hstride = tmp_frame->height;
    src.format = RK_FORMAT_YCbCr_420_SP; 
    src.vir_addr = tmp_frame->data[0];
    src.phy_addr = 0; 

    // Create RGA output buffer (BGR)
    rga_buffer_t dst;
    memset(&dst, 0, sizeof(rga_buffer_t));
    dst.width = TmpMat.cols;
    dst.height = TmpMat.rows;
    dst.wstride = TmpMat.cols;
    dst.hstride = TmpMat.rows;
    dst.format = RK_FORMAT_BGR_888;
    dst.vir_addr = TmpMat.data;
    dst.phy_addr = 0;

    // Perform color space conversion
    int ret = imcvtcolor(src, dst, src.format, dst.format);//, &opt);
    if (ret != IM_STATUS_SUCCESS) {
        std::cerr << "RGA color conversion failed: " << imStrError(ret) << std::endl;
    }
@Qengineering
Copy link
Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants