mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
ports: Add yuv shift to match bayer shift.
This commit is contained in:
parent
87d2da4640
commit
c1eeaefd6a
@ -1141,6 +1141,7 @@ void imlib_debayer_line(int x_start, int x_end, int y_row, void *dst_row_ptr, pi
|
||||
void imlib_debayer_image(image_t *dst, image_t *src);
|
||||
|
||||
// YUV Image Processing
|
||||
pixformat_t imlib_yuv_shift(pixformat_t pixfmt, int x);
|
||||
void imlib_deyuv_line(int x_start, int x_end, int y_row, void *dst_row_ptr, pixformat_t pixfmt, image_t *src);
|
||||
void imlib_deyuv_image(image_t *dst, image_t *src);
|
||||
|
||||
|
||||
@ -10,6 +10,14 @@
|
||||
*/
|
||||
#include "imlib.h"
|
||||
|
||||
pixformat_t imlib_yuv_shift(pixformat_t pixfmt, int x) {
|
||||
if (x % 2) {
|
||||
return (pixfmt == PIXFORMAT_YUV422) ? PIXFORMAT_YVU422 : PIXFORMAT_YUV422;
|
||||
}
|
||||
|
||||
return pixfmt;
|
||||
}
|
||||
|
||||
void imlib_deyuv_line(int x_start, int x_end, int y_row, void *dst_row_ptr, pixformat_t pixfmt, image_t *src) {
|
||||
int shift = (src->pixfmt == PIXFORMAT_YUV422) ? 16 : 0;
|
||||
int src_w = src->w, w_limit = src_w - 1;
|
||||
|
||||
@ -1117,9 +1117,7 @@ static mp_obj_t py_image_to(pixformat_t pixfmt, const uint16_t *default_color_pa
|
||||
(alpha_palette != NULL)) {
|
||||
mp_raise_msg(&mp_type_ValueError, MP_ERROR_TEXT("Only YUV422 copying/cropping is supported!"));
|
||||
} else {
|
||||
if (arg_roi.x % 2) {
|
||||
dst_img.pixfmt = (dst_img.pixfmt == PIXFORMAT_YUV422) ? PIXFORMAT_YVU422 : PIXFORMAT_YUV422;
|
||||
}
|
||||
dst_img.pixfmt = imlib_yuv_shift(dst_img.pixfmt, arg_roi.x);
|
||||
hint &= ~(IMAGE_HINT_AREA |
|
||||
IMAGE_HINT_BICUBIC |
|
||||
IMAGE_HINT_BILINEAR |
|
||||
|
||||
@ -378,10 +378,9 @@ int sensor_snapshot(sensor_t *sensor, image_t *image, uint32_t flags) {
|
||||
MAIN_FB()->subfmt_id = sensor->hw_flags.bayer;
|
||||
break;
|
||||
case PIXFORMAT_YUV422: {
|
||||
bool yuv_order = sensor->hw_flags.yuv_order == SENSOR_HW_FLAGS_YUV422;
|
||||
int even = yuv_order ? PIXFORMAT_YUV422 : PIXFORMAT_YVU422;
|
||||
int odd = yuv_order ? PIXFORMAT_YVU422 : PIXFORMAT_YUV422;
|
||||
MAIN_FB()->pixfmt = (MAIN_FB()->x % 2) ? odd : even;
|
||||
MAIN_FB()->pixfmt = PIXFORMAT_YUV;
|
||||
MAIN_FB()->subfmt_id = sensor->hw_flags.yuv_order;
|
||||
MAIN_FB()->pixfmt = imlib_yuv_shift(MAIN_FB()->pixfmt, MAIN_FB()->x);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
||||
@ -579,6 +579,7 @@ UVC_OBJ += $(addprefix $(BUILD)/$(OMV_DIR)/imlib/,\
|
||||
fmath.o \
|
||||
imlib.o \
|
||||
framebuffer.o \
|
||||
yuv.o \
|
||||
)
|
||||
|
||||
UVC_OBJ += $(addprefix $(BUILD)/$(OMV_DIR)/ports/stm32/,\
|
||||
|
||||
@ -978,10 +978,9 @@ int sensor_snapshot(sensor_t *sensor, image_t *image, uint32_t flags) {
|
||||
MAIN_FB()->subfmt_id = sensor->hw_flags.bayer;
|
||||
break;
|
||||
case PIXFORMAT_YUV422: {
|
||||
bool yuv_order = sensor->hw_flags.yuv_order == SENSOR_HW_FLAGS_YUV422;
|
||||
int even = yuv_order ? PIXFORMAT_YUV422 : PIXFORMAT_YVU422;
|
||||
int odd = yuv_order ? PIXFORMAT_YVU422 : PIXFORMAT_YUV422;
|
||||
MAIN_FB()->pixfmt = (MAIN_FB()->x % 2) ? odd : even;
|
||||
MAIN_FB()->pixfmt = PIXFORMAT_YUV;
|
||||
MAIN_FB()->subfmt_id = sensor->hw_flags.yuv_order;
|
||||
MAIN_FB()->pixfmt = imlib_yuv_shift(MAIN_FB()->pixfmt, MAIN_FB()->x);
|
||||
break;
|
||||
}
|
||||
case PIXFORMAT_JPEG: {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user