Skip to content

Commit b8ddbb8

Browse files
committed
supports PIXFMT_ARGB target
1 parent 856666c commit b8ddbb8

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/unicapture.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,12 @@ void* unicapture_run(void* data)
187187
// Convert frame to suitable video formats
188188
if (ui_frame.pixel_format != PIXFMT_INVALID) {
189189
converter_run(&ui_converter, &ui_frame, &ui_frame_converted,
190-
target_format == PIXFMT_RGB ? PIXFMT_ARGB : PIXFMT_YUV420_SEMI_PLANAR);
190+
(target_format == PIXFMT_RGB || target_format == PIXFMT_ARGB) ? PIXFMT_ARGB : PIXFMT_YUV420_SEMI_PLANAR);
191191
}
192192

193193
if (video_frame.pixel_format != PIXFMT_INVALID) {
194194
converter_run(&video_converter, &video_frame, &video_frame_converted,
195-
target_format == PIXFMT_RGB ? PIXFMT_ARGB : PIXFMT_YUV420_SEMI_PLANAR);
195+
(target_format == PIXFMT_RGB || target_format == PIXFMT_ARGB) ? PIXFMT_ARGB : PIXFMT_YUV420_SEMI_PLANAR);
196196
}
197197

198198
uint64_t frame_converted = getticks_us();
@@ -204,7 +204,7 @@ void* unicapture_run(void* data)
204204
const int width = video_frame_converted.width;
205205
const int height = video_frame_converted.height;
206206

207-
if (target_format == PIXFMT_RGB) {
207+
if (target_format == PIXFMT_RGB || target_format == PIXFMT_ARGB) {
208208
blended_frame.planes[0].buffer = realloc(blended_frame.planes[0].buffer, width * height * 4);
209209
blended_frame.planes[0].stride = width * 4;
210210
blended_frame.pixel_format = PIXFMT_ARGB;
@@ -266,6 +266,8 @@ void* unicapture_run(void* data)
266266
FILE* fd = fopen(filename, "wb");
267267
if (target_format == PIXFMT_RGB)
268268
fwrite(final_frame.planes[0].buffer, 3 * final_frame.width * final_frame.height, 1, fd);
269+
if (target_format == PIXFMT_ARGB)
270+
fwrite(final_frame.planes[0].buffer, 4 * final_frame.width * final_frame.height, 1, fd);
269271
if (target_format == PIXFMT_YUV420_SEMI_PLANAR) {
270272
fwrite(final_frame.planes[0].buffer, final_frame.width * final_frame.height, 1, fd);
271273
fwrite(final_frame.planes[1].buffer, final_frame.width * final_frame.height / 2, 1, fd);
@@ -274,7 +276,7 @@ void* unicapture_run(void* data)
274276
INFO("Buffer dumped to: %s", filename);
275277
}
276278

277-
if (this->callback != NULL && target_format == PIXFMT_RGB) {
279+
if (this->callback != NULL && (target_format == PIXFMT_RGB || target_format == PIXFMT_ARGB)) {
278280
this->callback(this->callback_data, final_frame.width, final_frame.height, final_frame.planes[0].buffer);
279281
}
280282

0 commit comments

Comments
 (0)