Improve ISP compatibility (fractional resizing)

This commit is contained in:
Kamil Trzcinski
2022-04-05 11:26:06 +02:00
parent cdcac155f6
commit 863acbbde5
7 changed files with 30 additions and 21 deletions

View File

@ -76,11 +76,12 @@ int buffer_list_set_format(buffer_list_t *buf_list, unsigned width, unsigned hei
retry:
// JPEG is in 16x16 blocks (shrink image to fit)
if (strstr(buf_list->name, "JPEG")) {
width = width / 16 * 16;
height = height / 16 * 16;
printf("JPEG: %dx%d vs %dx%d\n", orig_width, orig_height, width, height);
// JPEG is in 16x16 blocks (shrink image to fit) (but adapt to 32x32)
// And ISP output
if (strstr(buf_list->name, "JPEG") || strstr(buf_list->name, "H264") || buf_list->do_capture && strstr(buf_list->name, "ISP")) {
width = shrink_to_block(width, 32);
height = shrink_to_block(height, 32);
E_LOG_INFO(buf_list, "Adapting size to 32x32 block: %dx%d vs %dx%d", orig_width, orig_height, width, height);
}
if (buf_list->do_mplanes) {

View File

@ -75,6 +75,11 @@ unsigned fourcc_to_stride(unsigned width, unsigned format)
}
}
int shrink_to_block(int size, int block)
{
return size / block * block;
}
uint64_t get_monotonic_time_us(struct timespec *ts, struct timeval *tv)
{
struct timespec now;

View File

@ -41,6 +41,7 @@ fourcc_string fourcc_to_string(unsigned format);
unsigned fourcc_to_stride(unsigned width, unsigned format);
int xioctl(const char *name, int fd, int request, void *arg);
uint64_t get_monotonic_time_us(struct timespec *ts, struct timeval *tv);
int shrink_to_block(int size, int block);
#define E_XIOCTL(dev, _fd, _request, _value, _msg, ...) do { \
int ret; \