2016-07-15 3 views
0

두 개의 이미지 버퍼가 YV12 형식으로되어있어 하나의 병존 이미지로 결합해야합니다.두 개의 YV12 이미지 버퍼를 하나의 병렬 이미지로 결합

(1920 × 1080) + (1920 × 1080) = (1080 * 3840)

YV12 3 개 별도의 평면으로 분할된다.

YYYYYYYY VV UU 

픽셀 형식은 픽셀 당 12 비트입니다.

큰 버퍼 (3840x1080)에 memcpy 개의 버퍼 (1920x1080)가 있지만 작동하지 않는 방법을 만들었습니다.

내 C++입니다.

Incorrect image

내가 실종 무엇 : 나는이 결과를 얻을 대신

Correct image

:

BYTE* source = buffer; 
BYTE* destination = convertBuffer3D; 

// copy over the Y 
for (int x = 0; x < height; x++) 
{ 
    memcpy(destination, source, width); 
    destination += width * 2; 
    source += width; 
} 

// copy over the V 
for (int x = 0; x < (height/2); x++) 
{ 
    memcpy(destination, source, width/2); 
    destination += width; 
    source += width/2; 
} 

// copy over the U 
for (int x = 0; x < (height/2); x++) 
{ 
    memcpy(destination, source, width/2); 
    destination += width; 
    source += width/2; 
} 

나는이 예상? 당신이 원하는 무엇

+0

이 코드를 잘 대해 보이는 (안된) 수정 된 코드입니다 . 당신은 아마도 다른 것을 놓치고있을 것입니다. (두 이미지 중 하나가 보폭이 확장 되었습니까?). –

+0

우리의 패딩이 확장되지 않습니다. 내 1920x1080 이미지의 총 버퍼 크기는 3110400 (1920x1080x1.5)이므로 추가 데이터가 없습니다. –

+0

또한 YV12보다는 NV12 인 경우에도 비슷한 효과가 있다고 가정합니다. 그런 다음 루프가 끝나면 소스와 대상을 간단히 확인해야합니다. 그것들이 정확하다면 문제는 루프가 아니라 예상 한 것과 다른 이미지 구조를가집니다. –

답변

1

은 이것이다 :

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 

을하지만 코드는 실제로이 일을한다 :

여기
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 

BYTE* source = buffer; 
BYTE* destination = convertBuffer3D; 

// copy over the Y 
for (int x = 0; x < height; x++) 
{ 
    memcpy(destination, source, width); 
    destination += width * 2; 
    source += width; 
} 

for (int x = 0; x < (height/2); x++) 
{ 
    // copy over the V 
    memcpy(destination, source, width/2); 
    destination += width; 
    source += width/2; 

    // copy over the U 
    memcpy(destination, source, width/2); 
    destination += width; 
    source += width/2; 
}