summaryrefslogtreecommitdiff
path: root/src/base/vnc
diff options
context:
space:
mode:
authorGiacomo Travaglini <giacomo.travaglini@arm.com>2017-09-28 13:01:08 +0100
committerGiacomo Travaglini <giacomo.travaglini@arm.com>2017-10-31 11:17:29 +0000
commit12fb1ca0b5f4ba139889e6005a4aed6d03467864 (patch)
tree455740b7e0cc3cf8e088a2473ef1c7f9b9814d30 /src/base/vnc
parent1025ef1598b8b7c3d00b82d30458e375697b8eff (diff)
downloadgem5-12fb1ca0b5f4ba139889e6005a4aed6d03467864.tar.xz
base: Introducing utility for writing raw data in png format
Originally it was possible to use a Bitmap writer class for dumping a framebuffer snapshot in a .bmp file. This patch enables you to choose another format. In particular it implements the writing of PNG Images using libpng library. The latter has to be already installed in your machine, otherwise gem5 will default to the Bitmap format. This configurable writer has been introduced in the VNC frame dumping mechanism, which is storing changed frame buffers from the VNC server Change-Id: Id7e5763c82235f1ce90381c8486b85a7cce734ce Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com> Reviewed-on: https://gem5-review.googlesource.com/5181 Reviewed-by: Jason Lowe-Power <jason@lowepower.com> Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>
Diffstat (limited to 'src/base/vnc')
-rw-r--r--src/base/vnc/Vnc.py5
-rw-r--r--src/base/vnc/vncinput.cc23
-rw-r--r--src/base/vnc/vncinput.hh9
-rw-r--r--src/base/vnc/vncserver.cc1
-rw-r--r--src/base/vnc/vncserver.hh1
5 files changed, 25 insertions, 14 deletions
diff --git a/src/base/vnc/Vnc.py b/src/base/vnc/Vnc.py
index a7faefb41..0aed0dc84 100644
--- a/src/base/vnc/Vnc.py
+++ b/src/base/vnc/Vnc.py
@@ -37,11 +37,16 @@
from m5.SimObject import SimObject
from m5.params import *
+from Graphics import *
+
class VncInput(SimObject):
type = 'VncInput'
cxx_header = "base/vnc/vncinput.hh"
frame_capture = Param.Bool(False, "capture changed frames to files")
+ img_format = Param.ImageFormat(
+ "Bitmap", "Format of the dumped Framebuffer"
+ )
class VncServer(VncInput):
type = 'VncServer'
diff --git a/src/base/vnc/vncinput.cc b/src/base/vnc/vncinput.cc
index 541b77143..b9d1d2546 100644
--- a/src/base/vnc/vncinput.cc
+++ b/src/base/vnc/vncinput.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2015 ARM Limited
+ * Copyright (c) 2010, 2015, 2017 ARM Limited
* All rights reserved
*
* The license below extends only to copyright in the software and shall
@@ -48,6 +48,7 @@
#include "base/misc.hh"
#include "base/output.hh"
+
#include "base/trace.hh"
#include "debug/VNC.hh"
@@ -58,7 +59,8 @@ VncInput::VncInput(const Params *p)
fb(&FrameBuffer::dummy),
_videoWidth(fb->width()), _videoHeight(fb->height()),
captureEnabled(p->frame_capture),
- captureCurrentFrame(0), captureLastHash(0)
+ captureCurrentFrame(0), captureLastHash(0),
+ imgFormat(p->img_format)
{
if (captureEnabled) {
// remove existing frame output directory if it exists, then create a
@@ -78,9 +80,11 @@ VncInput::setFrameBuffer(const FrameBuffer *rfb)
fb = rfb;
- // create bitmap of the frame with new attributes
- if (captureEnabled)
- captureBitmap.reset(new Bitmap(rfb));
+ // Create the Image Writer object in charge of dumping
+ // the frame buffer raw data into a file in a specific format.
+ if (captureEnabled) {
+ captureImage = createImgWriter(imgFormat, rfb);
+ }
// Setting a new frame buffer means that we need to send an update
// to the client. Mark the internal buffers as dirty to do so.
@@ -110,7 +114,7 @@ VncInput::setDirty()
void
VncInput::captureFrameBuffer()
{
- assert(captureBitmap);
+ assert(captureImage);
// skip identical frames
uint64_t new_hash = fb->getHash();
@@ -120,13 +124,14 @@ VncInput::captureFrameBuffer()
// get the filename for the current frame
char frameFilenameBuffer[64];
- snprintf(frameFilenameBuffer, 64, "fb.%06d.%lld.bmp.gz",
- captureCurrentFrame, static_cast<long long int>(curTick()));
+ snprintf(frameFilenameBuffer, 64, "fb.%06d.%lld.%s.gz",
+ captureCurrentFrame, static_cast<long long int>(curTick()),
+ captureImage->getImgExtension());
const string frameFilename(frameFilenameBuffer);
// create the compressed framebuffer file
OutputStream *fb_out(captureOutputDirectory->create(frameFilename, true));
- captureBitmap->write(*fb_out->stream());
+ captureImage->write(*fb_out->stream());
captureOutputDirectory->close(fb_out);
++captureCurrentFrame;
diff --git a/src/base/vnc/vncinput.hh b/src/base/vnc/vncinput.hh
index 15ddc5c58..38f42459f 100644
--- a/src/base/vnc/vncinput.hh
+++ b/src/base/vnc/vncinput.hh
@@ -48,7 +48,7 @@
#include <iostream>
#include <memory>
-#include "base/bitmap.hh"
+#include "base/imgwriter.hh"
#include "params/VncInput.hh"
#include "sim/sim_object.hh"
@@ -226,8 +226,11 @@ class VncInput : public SimObject
/** Computed hash of the last captured frame */
uint64_t captureLastHash;
- /** Cached bitmap object for writing out frame buffers to file */
- std::unique_ptr<Bitmap> captureBitmap;
+ /** Cached ImgWriter object for writing out frame buffers to file */
+ std::unique_ptr<ImgWriter> captureImage;
+
+ /** image format */
+ Enums::ImageFormat imgFormat;
/** Captures the current frame buffer to a file */
void captureFrameBuffer();
diff --git a/src/base/vnc/vncserver.cc b/src/base/vnc/vncserver.cc
index 9cf38dc2d..00ff5602f 100644
--- a/src/base/vnc/vncserver.cc
+++ b/src/base/vnc/vncserver.cc
@@ -64,7 +64,6 @@
#include <cstdio>
#include "base/atomicio.hh"
-#include "base/bitmap.hh"
#include "base/misc.hh"
#include "base/output.hh"
#include "base/socket.hh"
diff --git a/src/base/vnc/vncserver.hh b/src/base/vnc/vncserver.hh
index 99f4b5fe1..f64ccd7cd 100644
--- a/src/base/vnc/vncserver.hh
+++ b/src/base/vnc/vncserver.hh
@@ -48,7 +48,6 @@
#include <iostream>
#include "base/vnc/vncinput.hh"
-#include "base/bitmap.hh"
#include "base/circlebuf.hh"
#include "base/pollevent.hh"
#include "base/socket.hh"