diff --git a/src/detection/camera/camera.h b/src/detection/camera/camera.h index d55573d31..83d07f312 100644 --- a/src/detection/camera/camera.h +++ b/src/detection/camera/camera.h @@ -7,6 +7,7 @@ typedef struct FFCameraResult FFstrbuf name; FFstrbuf vendor; FFstrbuf id; + FFstrbuf colorspace; uint32_t width; uint32_t height; } FFCameraResult; diff --git a/src/detection/camera/camera_linux.c b/src/detection/camera/camera_linux.c index 227028258..f4472d4e7 100644 --- a/src/detection/camera/camera_linux.c +++ b/src/detection/camera/camera_linux.c @@ -33,6 +33,22 @@ const char* ffDetectCamera(FFlist* result) ffStrbufInitS(&camera->name, (const char*) cap.card); ffStrbufInit(&camera->vendor); ffStrbufInitS(&camera->id, (const char*) cap.bus_info); + switch (fmt.fmt.pix.colorspace) + { + case V4L2_COLORSPACE_SMPTE170M: ffStrbufInitStatic(&camera->colorspace, "SMPTE 170M"); break; + case V4L2_COLORSPACE_SMPTE240M: ffStrbufInitStatic(&camera->colorspace, "SMPTE 240M"); break; + case V4L2_COLORSPACE_BT878: ffStrbufInitStatic(&camera->colorspace, "BT.808"); break; + case V4L2_COLORSPACE_470_SYSTEM_M: ffStrbufInitStatic(&camera->colorspace, "NTSC"); break; + case V4L2_COLORSPACE_470_SYSTEM_BG: ffStrbufInitStatic(&camera->colorspace, "EBU 3213"); break; + case V4L2_COLORSPACE_JPEG: ffStrbufInitStatic(&camera->colorspace, "JPEG"); break; + case V4L2_COLORSPACE_REC709: + case V4L2_COLORSPACE_SRGB: ffStrbufInitStatic(&camera->colorspace, "sRGB"); break; + case V4L2_COLORSPACE_OPRGB: ffStrbufInitStatic(&camera->colorspace, "Adobe RGB"); break; + case V4L2_COLORSPACE_BT2020: ffStrbufInitStatic(&camera->colorspace, "BT.2020"); break; + case V4L2_COLORSPACE_RAW: ffStrbufInitStatic(&camera->colorspace, "RAW"); break; + case V4L2_COLORSPACE_DCI_P3: ffStrbufInitStatic(&camera->colorspace, "DCI-P3"); break; + default: ffStrbufInit(&camera->colorspace); break; + } camera->width = fmt.fmt.pix.width; camera->height = fmt.fmt.pix.height; } diff --git a/src/modules/camera/camera.c b/src/modules/camera/camera.c index 35cc99180..4f3be100c 100644 --- a/src/modules/camera/camera.c +++ b/src/modules/camera/camera.c @@ -13,19 +13,27 @@ static void printDevice(FFCameraOptions* options, const FFCameraResult* device, { ffPrintLogoAndKey(FF_CAMERA_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT); + ffStrbufWriteTo(&device->name, stdout); + if (device->colorspace.length > 0) + { + fputs(" - ", stdout); + ffStrbufWriteTo(&device->colorspace, stdout); + } + if (device->width > 0 && device->height > 0) - printf("%s (%upx x %upx)\n", device->name.chars, (unsigned) device->width, (unsigned) device->height); + printf(" (%upx x %upx)\n", (unsigned) device->width, (unsigned) device->height); else - ffStrbufPutTo(&device->name, stdout); + putchar('\n'); } else { ffPrintFormat(FF_CAMERA_MODULE_NAME, index, &options->moduleArgs, FF_CAMERA_NUM_FORMAT_ARGS, (FFformatarg[]) { {FF_FORMAT_ARG_TYPE_STRBUF, &device->name}, {FF_FORMAT_ARG_TYPE_STRBUF, &device->vendor}, + {FF_FORMAT_ARG_TYPE_STRBUF, &device->colorspace}, {FF_FORMAT_ARG_TYPE_STRBUF, &device->id}, {FF_FORMAT_ARG_TYPE_UINT, &device->width}, - {FF_FORMAT_ARG_TYPE_UINT, &device->height} + {FF_FORMAT_ARG_TYPE_UINT, &device->height}, }); } } @@ -57,6 +65,7 @@ void ffPrintCamera(FFCameraOptions* options) { ffStrbufDestroy(&dev->name); ffStrbufDestroy(&dev->id); + ffStrbufDestroy(&dev->colorspace); } } @@ -113,6 +122,7 @@ void ffGenerateCameraJsonResult(FF_MAYBE_UNUSED FFCameraOptions* options, yyjson yyjson_mut_val* obj = yyjson_mut_arr_add_obj(doc, arr); yyjson_mut_obj_add_strbuf(doc, obj, "name", &dev->name); yyjson_mut_obj_add_strbuf(doc, obj, "vendor", &dev->vendor); + yyjson_mut_obj_add_strbuf(doc, obj, "colorSpace", &dev->colorspace); yyjson_mut_obj_add_strbuf(doc, obj, "id", &dev->id); yyjson_mut_obj_add_uint(doc, obj, "width", dev->width); yyjson_mut_obj_add_uint(doc, obj, "height", dev->height); @@ -122,6 +132,7 @@ void ffGenerateCameraJsonResult(FF_MAYBE_UNUSED FFCameraOptions* options, yyjson { ffStrbufDestroy(&dev->name); ffStrbufDestroy(&dev->id); + ffStrbufDestroy(&dev->colorspace); } } @@ -130,6 +141,7 @@ void ffPrintCameraHelpFormat(void) ffPrintModuleFormatHelp(FF_CAMERA_MODULE_NAME, "{1} ({4}px x {5}px)", FF_CAMERA_NUM_FORMAT_ARGS, (const char* []) { "Device name", "Vendor", + "Color space", "Identifier", "Width (in px)", "Height (in px)",