c++ - Combining two YV12 image buffers into a single side-by-side image -
i have 2 image buffers in yv12 format need combine single side-by-side image.
(1920x1080) + (1920x1080) = (3840*1080)
yv12 split 3 seperate planes.
yyyyyyyy vv uu
the pixel format 12 bits-per-pixel.
i have created method memcpy
s 1 buffer (1920x1080) larger buffer (3840x1080), isn't working.
here c++.
byte* source = buffer; byte* destination = convertbuffer3d; // copy on y (int x = 0; x < height; x++) { memcpy(destination, source, width); destination += width * 2; source += width; } // copy on v (int x = 0; x < (height / 2); x++) { memcpy(destination, source, width / 2); destination += width; source += width / 2; } // copy on u (int x = 0; x < (height / 2); x++) { memcpy(destination, source, width / 2); destination += width; source += width / 2; }
i expected this:
instead, result:
what missing?
what wanted this:
y1 y1 y1 y1 y2 y2 y2 y2 y1 y1 y1 y1 y2 y2 y2 y2 y1 y1 y1 y1 y2 y2 y2 y2 y1 y1 y1 y1 y2 y2 y2 y2 u1 u1 u2 u2 v1 v1 v2 v2 u1 u1 u2 u2 v1 v1 v2 v2
but code doing this:
y1 y1 y1 y1 y2 y2 y2 y2 y1 y1 y1 y1 y2 y2 y2 y2 y1 y1 y1 y1 y2 y2 y2 y2 y1 y1 y1 y1 y2 y2 y2 y2 u1 u1 v1 v1 u2 u2 v2 v2 u1 u1 v1 v1 u2 u2 v2 v2
here's corrected code (untested)
byte* source = buffer; byte* destination = convertbuffer3d; // copy on y (int x = 0; x < height; x++) { memcpy(destination, source, width); destination += width * 2; source += width; } (int x = 0; x < (height / 2); x++) { // copy on v memcpy(destination, source, width / 2); destination += width; source += width / 2; // copy on u memcpy(destination, source, width / 2); destination += width; source += width / 2; }
Comments
Post a Comment