mipi raw10转换成 raw10的C代码和raw10转raw8的代码
时间: 2023-08-09 08:06:12 浏览: 189
下面是 mipi raw10 转换成 raw10 的 C 代码:
```c
#include <stdio.h>
void mipi_raw10_to_raw10(unsigned char *input, unsigned char *output, int width, int height) {
int i, j;
int index = 0;
int output_index = 0;
unsigned short pixel;
for (i = 0; i < height; i++) {
for (j = 0; j < width; j += 4) {
pixel = input[index++] << 2;
pixel |= input[index] >> 6;
output[output_index++] = pixel & 0xff;
output[output_index++] = (pixel >> 8) & 0xff;
pixel = (input[index++] & 0x3f) << 4;
pixel |= input[index] >> 4;
output[output_index++] = pixel & 0xff;
output[output_index++] = (pixel >> 8) & 0xff;
pixel = (input[index++] & 0x0f) << 6;
pixel |= input[index] >> 2;
output[output_index++] = pixel & 0xff;
output[output_index++] = (pixel >> 8) & 0xff;
pixel = (input[index++] & 0x03) << 8;
pixel |= input[index++];
output[output_index++] = pixel & 0xff;
output[output_index++] = (pixel >> 8) & 0xff;
}
}
}
```
下面是 raw10 转换成 raw8 的 C 代码:
```c
#include <stdio.h>
void raw10_to_raw8(unsigned char *input, unsigned char *output, int width, int height) {
int i, j;
int index = 0;
int output_index = 0;
unsigned short pixel;
for (i = 0; i < height; i++) {
for (j = 0; j < width; j += 4) {
pixel = input[index++] << 2;
pixel |= input[index] >> 6;
output[output_index++] = pixel >> 2;
pixel = (input[index++] & 0x3f) << 4;
pixel |= input[index] >> 4;
output[output_index++] = pixel >> 2;
pixel = (input[index++] & 0x0f) << 6;
pixel |= input[index] >> 2;
output[output_index++] = pixel >> 2;
pixel = (input[index++] & 0x03) << 8;
pixel |= input[index++];
output[output_index++] = pixel >> 2;
}
}
}
```
以上代码仅供参考,具体实现需要根据具体的需求进行修改。
阅读全文