Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #57, incomplete/broken images when ISP Tuning Tool is paused and replayed #58

Merged
merged 3 commits into from
May 20, 2022
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions package/isp-tuningd/src/isp-tuningd.c
Original file line number Diff line number Diff line change
Expand Up @@ -520,16 +520,11 @@ void stdin_read(uv_stream_t *stream, ssize_t nread, const uv_buf_t* buf)
return;
}
static uint32_t ptr = 0;
if (flag_send_pic == 0) {
// do not send
ptr = 0;
goto clean;
}
uint8_t* pic_nv12_buffer = pic_write_buffer[pic_write_buffer_select] + 6;
size_t lack = PIC_YUV_SIZE - ptr;
if (nread >= lack) {
static time_t last_time = 0;
if (time(NULL) - last_time >= 1) {
if (flag_send_pic && time(NULL) - last_time >= 1) {
memcpy(pic_nv12_buffer + ptr, buf->base, lack);
// broadcast
broadcast(pic_write_buffer[pic_write_buffer_select], sizeof(pic_write_buffer[0]), 1);
Expand All @@ -538,13 +533,21 @@ void stdin_read(uv_stream_t *stream, ssize_t nread, const uv_buf_t* buf)
fflush(stdout);
last_time = time(NULL);
}
// reset
pic_write_buffer_select ^= 1;
ptr = 0;
pic_nv12_buffer = pic_write_buffer[pic_write_buffer_select] + 6;
// drop on too much data, align PIC_YUV_SIZE
ptr = (nread - lack) % PIC_YUV_SIZE;
if (flag_send_pic) {
memcpy(pic_nv12_buffer, buf->base + (nread - ptr), ptr);
}
} else {
memcpy(pic_nv12_buffer + ptr, buf->base, nread);
if (flag_send_pic) {
memcpy(pic_nv12_buffer + ptr, buf->base, nread);
}
ptr += nread;
}
clean:

if (buf->base) {
free(buf->base);
}
Expand Down