直接上代码
void CodeReaderHelper::Yuv422_toRGB(unsigned char *yuv, unsigned char *rgb, int source_width, int source_height, int target_width, int target_height)
{
float scale_x;
float scale_y;
if (target_width >= source_width) //不能放大,只能缩小
{
scale_x = 1;
}
else
{
scale_x = (float)source_width / target_width;
}
if (target_height >= source_height) //不能放大,只能缩小
{
scale_y = 1;
}
else
{
scale_y = (float)source_height / target_height;
}
float y_t = 0, x_t = 0; //目标行列是否取样判断
int y_t_count = 0; //目标行
int x_t_count = 0; //目标列
int r, g, b;
int y0, y1, u, v;
int p, p_t; //指针
int p0, p_t0; //每一行开始的指针
scale_x = scale_x * 4; //一次处理2个点,4个数据
for (int h = 0; h < source_height; h++)
{
if (h >= y_t) //取样条件满足
{