Skip to content

Commit

Permalink
Merge pull request #115 from sundermann/vtcapture-colors
Browse files Browse the repository at this point in the history
Fix pixel byte order / color correctness for vtcapture
  • Loading branch information
sundermann authored Apr 13, 2024
2 parents 10b638f + f3cc9e4 commit e26fb52
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/backends/libgm.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ int capture_acquire_frame(void* state, frame_info_t* frame)
return ret;
}

frame->pixel_format = PIXFMT_ABGR;
frame->pixel_format = PIXFMT_ARGB;
frame->width = width;
frame->height = height;
frame->planes[0].buffer = this->surface_info.framebuffer;
Expand Down
2 changes: 1 addition & 1 deletion src/backends/libhalgal.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ int capture_acquire_frame(void* state, frame_info_t* frame)
return ret;
}

frame->pixel_format = PIXFMT_ABGR;
frame->pixel_format = PIXFMT_ARGB;
frame->width = this->width;
frame->height = this->height;
frame->planes[0].buffer = this->mem_addr;
Expand Down
7 changes: 5 additions & 2 deletions src/converter.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ int converter_run(converter_t* this, frame_info_t* input, frame_info_t* output,
output->planes[0].stride = output->width * 4;

if (input->pixel_format == PIXFMT_RGB) {
RGB24ToARGB(
RAWToARGB(
input->planes[0].buffer,
input->planes[0].stride,
output->planes[0].buffer,
Expand All @@ -52,7 +52,7 @@ int converter_run(converter_t* this, frame_info_t* input, frame_info_t* output,
output->width,
output->height);
} else if (input->pixel_format == PIXFMT_YUV420_SEMI_PLANAR) {
NV21ToARGB(
NV12ToARGB(
input->planes[0].buffer,
input->planes[0].stride,
input->planes[1].buffer,
Expand Down Expand Up @@ -84,6 +84,9 @@ int converter_run(converter_t* this, frame_info_t* input, frame_info_t* output,
output->planes[0].stride,
output->width,
output->height);
} else if (input->pixel_format == PIXFMT_ARGB) {
output->planes[0].buffer = input->planes[0].buffer;
output->planes[0].stride = input->planes[0].stride;
} else {
return -2;
}
Expand Down
3 changes: 2 additions & 1 deletion src/json_rpc_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,14 @@ int send_rpc_message(char* host, ushort rpc_port, jvalue_ref post_body_jval, jva
JSchemaInfo schema;

char* url = (char*)calloc(1, PATH_MAX);
char* response = (char*)calloc(1, MAX_RESPONSE_BUF_SZ);

if (url == NULL) {
ERR("send_rpc_message: alloc failed -> url");
ret = -1;
goto exit;
}

char* response = (char*)calloc(1, MAX_RESPONSE_BUF_SZ);
if (response == NULL) {
ERR("send_rpc_message: alloc failed -> response");
ret = -2;
Expand Down
6 changes: 3 additions & 3 deletions src/unicapture.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ void* unicapture_run(void* data)
4 * width,
width,
height);
ARGBToRGB24(
ARGBToRAW(
blended_frame,
4 * width,
final_frame,
Expand All @@ -227,7 +227,7 @@ void* unicapture_run(void* data)

final_frame = realloc(final_frame, width * height * 3);

ARGBToRGB24(
ARGBToRAW(
ui_frame_converted.planes[0].buffer,
ui_frame_converted.planes[0].stride,
final_frame,
Expand All @@ -240,7 +240,7 @@ void* unicapture_run(void* data)

final_frame = realloc(final_frame, width * height * 3);

ARGBToRGB24(
ARGBToRAW(
video_frame_converted.planes[0].buffer,
video_frame_converted.planes[0].stride,
final_frame,
Expand Down

0 comments on commit e26fb52

Please sign in to comment.