// yuvconvert.c.cpp : Defines the entry point for the console
application.
//
#include "stdafx.h"
void convert_yuv422_to_yuv420(char *InBuff, char *OutBuff, int width,
int height)
{
int i = 0, j = 0, k = 0;
int UOffset = width * height;
int VOffset = (width * height) * 5/4;
int UVSize = (width * height) / 4;
int line1 = 0, line2 = 0;
int m = 0, n = 0;
int y = 0, u = 0, v = 0;
u = UOffset;
v = VOffset;
for (i = 0, j = 1; i < height; i += 2, j += 2)
{
/* Input Buffer Pointer Indexes */
line1 = i * width * 2;
line2 = j * width * 2;
/* Output Buffer Pointer Indexes */
m = width * y;
y = y + 1;
n = width * y;
y = y + 1;
/* Scan two lines at a time */
for (k = 0; k < width*2; k += 4)
{
unsigned char Y1, Y2, U, V;
unsigned char Y3, Y4, U2, V2;
/* Read Input Buffer */
Y1 = InBuff[line1++];
U = InBuff[line1++];
Y2 = InBuff[line1++];
V = InBuff[line1++];
Y3 = InBuff[line2++];
U2 = InBuff[line2++];
Y4 = InBuff[line2++];
V2 = InBuff[line2++];
/* Write Output Buffer */
OutBuff[m++] = Y1;
OutBuff[m++] = Y2;
OutBuff[n++] = Y3;
OutBuff[n++] = Y4;
OutBuff[u++] = (U + U2)/2;
OutBuff[v++] = (V + V2)/2;
}
}
}
int _tmain(int argc, _TCHAR* argv[])
{
//char InBuff[] = {'1', '2', '3', '4','1', '2', '3', '4','1', '2',
'3', '4','1', '2', '3', '4','1', '2', '3', '4','1', '2', '3', '4','1',
'2', '3', '4','1', '2', '3', '4'};
char InBuff[] = {'y', 'u', 'y', 'v','y', 'u', 'y', 'v','y', 'u',
'y', 'v','y', 'u', 'y', 'v','y', 'u', 'y', 'v','y', 'u', 'y', 'v','y',
'u', 'y', 'v','y', 'u', 'y', 'v','y', 'u', 'y', 'v','y', 'u', 'y',
'v','y', 'u', 'y', 'v','y', 'u', 'y', 'v','y', 'u', 'y', 'v','y', 'u',
'y', 'v','y', 'u', 'y', 'v','y', 'u', 'y', 'v'};
char OutBuff[64]= {0};
convert_yuv422_to_yuv420(InBuff, OutBuff, 8, 4);
return 0;
}
Developed by:
Sachin Nikam
Software Engineer,
PUNE.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en