Browse Source

Prepare for supporting multiple YUV formats.

Pavel Machek 10 months ago
parent
commit
99eab6ee54
1 changed files with 12 additions and 2 deletions
  1. 12 2
      src/process_pipeline.c

+ 12 - 2
src/process_pipeline.c

@@ -759,11 +759,21 @@ save_grw(const uint8_t *image, char *fname)
         }
         int width = state_proc.mode->width;
         int height = state_proc.mode->height;
-	int size = width*height*2;
+	int size = width * height * 2;
+	char *format;
+	switch (state_proc.mode->v4l_pixfmt) {
+	case V4L2_PIX_FMT_YUYV:
+		format = "YUY2";
+		break;
+	default:
+		printf("Please fill appropriate translation for YUV.\n");
+	}
 	fwrite(image, size, 1, outfile);
 	char buf[1024];
 	buf[0] = 0;
-	int header = sprintf(buf+1, "Caps: video/x-raw,format=YUY2,width=%d,height=%d\nSize: %d\nGRW", width, height, size);
+	int header = sprintf(buf+1,
+			     "Caps: video/x-raw,format=%s,width=%d,height=%d\nSize: %d\nGRW",
+			     format, width, height, size);
 	fwrite(buf, header+1, 1, outfile);
         fclose(outfile);
 }