<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">On 2013/4/23 15:47, José Fonseca wrote:<br>
</div>
<blockquote
cite="mid:CAH_+9jnecAp8+f4QDSdnUKwdCaUUrLbZJA6Yz8eFi=_k_Byuog@mail.gmail.com"
type="cite">
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<div dir="ltr">
<div style=""><span
style="font-family:arial,sans-serif;font-size:13px">Just a
few requests:</span><br>
</div>
<div style=""><span
style="font-family:arial,sans-serif;font-size:13px">- </span><span
style="font-family:arial,sans-serif;font-size:13px">Please
make snapshotFormat global an enum, and do the string
compare when parsing the options.</span></div>
<div style=""><font face="arial, sans-serif">- Please add an
example to the README.markdown, just after "Recording a
video with FFmpeg" section.</font></div>
</div>
</blockquote>
<br>
<font face="arial, sans-serif">Totally agree<br>
<br>
</font>
<blockquote
cite="mid:CAH_+9jnecAp8+f4QDSdnUKwdCaUUrLbZJA6Yz8eFi=_k_Byuog@mail.gmail.com"
type="cite">
<div dir="ltr">
<div><br>
</div>
<div style="">Otherwise looks greast.</div>
<div>
<br>
</div>
<div><font face="arial, sans-serif">Given that raw does not
encode the frame buffer size, and framebuffer sizes are
variable/fickle, I think a nice future improvement would be
to allow forcing the size on command line, to prevent video
to go bust. For example:</font></div>
<div><font face="arial, sans-serif"><br>
</font></div>
<div><font face="arial, sans-serif"> </font><span
style="font-family:arial,sans-serif;font-size:13px">glretrace
--snapshot-format=RGB:1920x</span><span
style="font-family:arial,sans-serif;font-size:13px">1080 ...</span><font
face="arial, sans-serif"><br>
</font></div>
</div>
</blockquote>
<br>
Yes, I think that's why you're using PNM or BITMAP, forcing size
seems a good idea for it to work<br>
<br>
Thanks<br>
--Shuang<br>
<br>
<blockquote
cite="mid:CAH_+9jnecAp8+f4QDSdnUKwdCaUUrLbZJA6Yz8eFi=_k_Byuog@mail.gmail.com"
type="cite">
<div dir="ltr">
<div><font face="arial, sans-serif">
</font>
<div><span style="font-family:arial,sans-serif;font-size:13px"><br>
</span></div>
<div style=""><span
style="font-family:arial,sans-serif;font-size:13px">Jose</span></div>
</div>
</div>
<div class="gmail_extra"><br>
<br>
<div class="gmail_quote">
On Fri, Apr 19, 2013 at 3:23 AM, Shuang He <span dir="ltr"><<a
moz-do-not-send="true" href="mailto:shuang.he@intel.com"
target="_blank">shuang.he@intel.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
This allows to create h264 video with gstreamer-vaapi very
fast, and save much more disk space.<br>
Using PNM format couldn't reach same performance, since PNM
decoding seems inefficient in gstreamer.<br>
Following are some experiment data with smokinguns demo
1920x1080 resolution on Ivybridge:<br>
1. With png saving, it runs at around 4.5 FPS, which has
compression rate 5.15x against raw RGB data<br>
Reference command:<br>
glretrace -s snapshot/ smokinguns.trace<br>
<br>
2. Using PNM with gstreamer-vaapi, which could run at around
9 FPS, which has compression rate<br>
485x (QP dependent) against raw RGB data.<br>
Reference command:<br>
glretrace -s - smokinguns.trace | gst-launch-0.10
fdsrc blocksize=409600 ! queue \<br>
! pnmdec ! videoparse format=rgb width=1920
height=1080 ! ffmpegcolorspace ! queue \<br>
! vaapiupload direct-rendering=0 ! queue !
vaapiencodeh264 ! filesink location=xxx.264<br>
<br>
3. With following command that directly write raw RGB stream
and encoded into H264 video, it<br>
runs at around 18.5 FPS, which has compression rate 485x
(QP dependent) against raw RGB data,<br>
Reference command:<br>
glretrace --snapshot-format=RGB -s -
smokinguns.trace | gst-launch-0.10 fdsrc blocksize=409600 !
queue \<br>
! videoparse format=rgb width=1920 height=1080 !
queue ! ffmpegcolorspace ! queue \<br>
! vaapiupload direct-rendering=0 ! queue !
vaapiencodeh264 ! filesink location=xxx.264<br>
<br>
v2: Use --snapshot-format= option to specify which format is
used to write to stdout output<br>
---<br>
image/CMakeLists.txt | 1 +<br>
image/image.hpp | 13 +++++++++++++<br>
image/image_raw.cpp | 47
++++++++++++++++++++++++++++++++++++++++++++++<br>
retrace/retrace_main.cpp | 12 +++++++++++-<br>
4 files changed, 72 insertions(+), 1 deletion(-)<br>
create mode 100644 image/image_raw.cpp<br>
<br>
diff --git a/image/CMakeLists.txt b/image/CMakeLists.txt<br>
index ee4d98f..37203f8 100644<br>
--- a/image/CMakeLists.txt<br>
+++ b/image/CMakeLists.txt<br>
@@ -7,6 +7,7 @@ add_library (image STATIC<br>
image_bmp.cpp<br>
image_png.cpp<br>
image_pnm.cpp<br>
+ image_raw.cpp<br>
)<br>
<br>
target_link_libraries (image<br>
diff --git a/image/image.hpp b/image/image.hpp<br>
index 7dd18c1..11bfc63 100644<br>
--- a/image/image.hpp<br>
+++ b/image/image.hpp<br>
@@ -106,6 +106,19 @@ public:<br>
return writePNG(os);<br>
}<br>
<br>
+ void<br>
+ writeRAW(std::ostream &os) const;<br>
+<br>
+ inline bool<br>
+ writeRAW(const char *filename) const {<br>
+ std::ofstream os(filename, std::ofstream::binary);<br>
+ if (!os) {<br>
+ return false;<br>
+ }<br>
+ writeRAW(os);<br>
+ return true;<br>
+ }<br>
+<br>
double compare(Image &ref);<br>
};<br>
<br>
diff --git a/image/image_raw.cpp b/image/image_raw.cpp<br>
new file mode 100644<br>
index 0000000..dd45d10<br>
--- /dev/null<br>
+++ b/image/image_raw.cpp<br>
@@ -0,0 +1,47 @@<br>
+/**************************************************************************<br>
+ *<br>
+ * Copyright (C) 2013 Intel Corporation. All rights
reversed.<br>
+ * Author: Shuang He <<a moz-do-not-send="true"
href="mailto:shuang.he@intel.com">shuang.he@intel.com</a>><br>
+ * All Rights Reserved.<br>
+ *<br>
+ * Permission is hereby granted, free of charge, to any
person obtaining a copy<br>
+ * of this software and associated documentation files (the
"Software"), to deal<br>
+ * in the Software without restriction, including without
limitation the rights<br>
+ * to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell<br>
+ * copies of the Software, and to permit persons to whom
the Software is<br>
+ * furnished to do so, subject to the following conditions:<br>
+ *<br>
+ * The above copyright notice and this permission notice
shall be included in<br>
+ * all copies or substantial portions of the Software.<br>
+ *<br>
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR<br>
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY,<br>
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
NO EVENT SHALL THE<br>
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER<br>
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM,<br>
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN<br>
+ * THE SOFTWARE.<br>
+ *<br>
+
**************************************************************************/<br>
+<br>
+<br>
+#include <assert.h><br>
+#include <string.h><br>
+#include <stdint.h><br>
+#include <stdio.h><br>
+<br>
+#include "image.hpp"<br>
+<br>
+<br>
+namespace image {<br>
+<br>
+void<br>
+Image::writeRAW(std::ostream &os) const {<br>
+ const unsigned char *row;<br>
+<br>
+ for (row = start(); row != end(); row += stride()) {<br>
+ os.write((const char *)row, width*channels);<br>
+ }<br>
+}<br>
+<br>
+} /* namespace image */<br>
diff --git a/retrace/retrace_main.cpp
b/retrace/retrace_main.cpp<br>
index 2d3311f..dbe34f8 100644<br>
--- a/retrace/retrace_main.cpp<br>
+++ b/retrace/retrace_main.cpp<br>
@@ -46,6 +46,7 @@ static bool loopOnFinish = false;<br>
<br>
static const char *comparePrefix = NULL;<br>
static const char *snapshotPrefix = NULL;<br>
+static const char *snapshotFormat = NULL;<br>
static trace::CallSet snapshotFrequency;<br>
static trace::CallSet compareFrequency;<br>
static trace::ParseBookmark lastFrameStart;<br>
@@ -128,7 +129,10 @@ takeSnapshot(unsigned call_no) {<br>
char comment[21];<br>
snprintf(comment, sizeof comment, "%u",<br>
useCallNos ? call_no : snapshot_no);<br>
- src->writePNM(std::cout, comment);<br>
+ if (snapshotFormat != NULL &&
strcmp(snapshotFormat, "RGB") == 0)<br>
+ src->writeRAW(std::cout);<br>
+ else<br>
+ src->writePNM(std::cout, comment);<br>
} else {<br>
os::String filename =
os::String::format("%s%010u.png",<br>
snapshotPrefix,<br>
@@ -567,6 +571,7 @@ usage(const char *argv0) {<br>
" --driver=DRIVER force driver type (`hw`,
`sw`, `ref`, `null`, or driver module name)\n"<br>
" --sb use a single buffer
visual\n"<br>
" -s, --snapshot-prefix=PREFIX take snapshots;
`-` for PNM stdout output\n"<br>
+ " --snapshot-format=FMT use (PNM or RGB;
default is PNM) when writing to stdout output\n"<br>
" -S, --snapshot=CALLSET calls to snapshot
(default is every frame)\n"<br>
" -v, --verbose increase output
verbosity\n"<br>
" -D, --dump-state=CALL dump state at specific
call no\n"<br>
@@ -585,6 +590,7 @@ enum {<br>
PPD_OPT,<br>
PMEM_OPT,<br>
SB_OPT,<br>
+ SNAPSHOT_FORMAT_OPT,<br>
LOOP_OPT,<br>
SINGLETHREAD_OPT<br>
};<br>
@@ -609,6 +615,7 @@ longOptions[] = {<br>
{"pmem", no_argument, 0, PMEM_OPT},<br>
{"sb", no_argument, 0, SB_OPT},<br>
{"snapshot-prefix", required_argument, 0, 's'},<br>
+ {"snapshot-format", required_argument, 0,
SNAPSHOT_FORMAT_OPT},<br>
{"snapshot", required_argument, 0, 'S'},<br>
{"verbose", no_argument, 0, 'v'},<br>
{"wait", no_argument, 0, 'w'},<br>
@@ -699,6 +706,9 @@ int main(int argc, char **argv)<br>
retrace::verbosity = -2;<br>
}<br>
break;<br>
+ case SNAPSHOT_FORMAT_OPT:<br>
+ snapshotFormat = optarg;<br>
+ break;<br>
case 'S':<br>
snapshotFrequency = trace::CallSet(optarg);<br>
if (snapshotPrefix == NULL) {<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.7.10.1<br>
<br>
_______________________________________________<br>
apitrace mailing list<br>
<a moz-do-not-send="true"
href="mailto:apitrace@lists.freedesktop.org">apitrace@lists.freedesktop.org</a><br>
<a moz-do-not-send="true"
href="http://lists.freedesktop.org/mailman/listinfo/apitrace"
target="_blank">http://lists.freedesktop.org/mailman/listinfo/apitrace</a><br>
</font></span></blockquote>
</div>
<br>
</div>
</blockquote>
<br>
</body>
</html>