1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
| void nv212Yv12(char *nv21, char *yv12, int width, int height)
{
int frameSize = width * height;
memcpy(yv12, nv21, frameSize);
nv21 += frameSize;
yv12 += frameSize;
int halfWidth = width / 2;
int halfHeight = height / 2;
int quadFrame = halfWidth * halfHeight;
for (int i = 0; i < halfHeight; i++) {
for (int j = 0; j < halfWidth; j++) {
*(yv12 + i * halfWidth + j) = *nv21++;
*(yv12 + quadFrame + i * halfWidth + j) = *nv21++;
}
}
}
void yv122Nv21(char *yv12, char *nv21, int width, int height)
{
int frameSize = width * height;
memcpy(nv21, yv12, frameSize);
nv21 += frameSize;
yv12 += frameSize;
int halfWidth = width / 2;
int halfHeight = height / 2;
int quadFrame = halfWidth * halfHeight;
for (int i = 0; i < halfHeight; i++) {
for (int j = 0; j < halfWidth; j++) {
*nv21++ = *(yv12 + i * halfWidth + j);
*nv21++ = *(yv12 + quadFrame + i * halfWidth + j);
}
}
} |
void nv212Yv12(char *nv21, char *yv12, int width, int height)
{
int frameSize = width * height;
memcpy(yv12, nv21, frameSize);
nv21 += frameSize;
yv12 += frameSize;
int halfWidth = width / 2;
int halfHeight = height / 2;
int quadFrame = halfWidth * halfHeight;
for (int i = 0; i < halfHeight; i++) {
for (int j = 0; j < halfWidth; j++) {
*(yv12 + i * halfWidth + j) = *nv21++;
*(yv12 + quadFrame + i * halfWidth + j) = *nv21++;
}
}
}
void yv122Nv21(char *yv12, char *nv21, int width, int height)
{
int frameSize = width * height;
memcpy(nv21, yv12, frameSize);
nv21 += frameSize;
yv12 += frameSize;
int halfWidth = width / 2;
int halfHeight = height / 2;
int quadFrame = halfWidth * halfHeight;
for (int i = 0; i < halfHeight; i++) {
for (int j = 0; j < halfWidth; j++) {
*nv21++ = *(yv12 + i * halfWidth + j);
*nv21++ = *(yv12 + quadFrame + i * halfWidth + j);
}
}
}