[PATCH] Add option '-s @' to write raw RGB directly to stdout

Jordan Justen jljusten at gmail.com
Wed Apr 17 23:06:08 PDT 2013


--snapshot-prefix=- and --snapshot-prefix=@ seem strange to me.

At least --snapshot-prefix=- sort of makes sense based on the - stdout
convention.

How about adding
--snapshot-format=FMT (PNM or RGB; default is PNM)
instead?

-Jordan

On Wed, Apr 17, 2013 at 8:39 PM, Shuang He <shuang.he at intel.com> wrote:
> This allows to create h264 video with gstreamer-vaapi very fast, and save much more disk space.
> Using PNM format couldn't reach same performance, since PNM decoding seems inefficient in gstreamer.
> Following are some experiment data with smokinguns demo 1920x1080 resolution on Ivybridge:
> 1. With png saving, it runs at around 4.5 FPS, which has compression rate 5.15x against raw RGB data
>    Reference command:
>         glretrace -s snapshot/ smokinguns.trace
>
> 2. Using PNM with gstreamer-vaapi, which could run at around 9 FPS, which has compression rate
>    485x (QP dependent) against raw RGB data.
>    Reference command:
>         glretrace -s - smokinguns.trace | gst-launch-0.10 fdsrc blocksize=409600 ! queue \
>         ! pnmdec ! videoparse format=rgb width=1920 height=1080 ! ffmpegcolorspace ! queue \
>         ! vaapiupload direct-rendering=0 ! queue ! vaapiencodeh264 ! filesink location=xxx.264
>
> 3. With following command that directly write raw RGB stream and encoded into H264 video, it
>    runs at around 18.5 FPS, which has compression rate 485x (QP dependent) against raw RGB data,
>    Reference command:
>         glretrace -s @ smokinguns.trace | gst-launch-0.10 fdsrc blocksize=409600 ! queue \
>         ! videoparse format=rgb width=1920 height=1080 ! queue ! ffmpegcolorspace ! queue \
>         ! vaapiupload direct-rendering=0 ! queue ! vaapiencodeh264 ! filesink location=xxx.264
> ---
>  image/CMakeLists.txt     |    1 +
>  image/image.hpp          |   13 +++++++++++++
>  image/image_raw.cpp      |   47 ++++++++++++++++++++++++++++++++++++++++++++++
>  retrace/retrace_main.cpp |    4 +++-
>  4 files changed, 64 insertions(+), 1 deletion(-)
>  create mode 100644 image/image_raw.cpp
>
> diff --git a/image/CMakeLists.txt b/image/CMakeLists.txt
> index ee4d98f..37203f8 100644
> --- a/image/CMakeLists.txt
> +++ b/image/CMakeLists.txt
> @@ -7,6 +7,7 @@ add_library (image STATIC
>      image_bmp.cpp
>      image_png.cpp
>      image_pnm.cpp
> +    image_raw.cpp
>  )
>
>  target_link_libraries (image
> diff --git a/image/image.hpp b/image/image.hpp
> index 7dd18c1..11bfc63 100644
> --- a/image/image.hpp
> +++ b/image/image.hpp
> @@ -106,6 +106,19 @@ public:
>          return writePNG(os);
>      }
>
> +    void
> +    writeRAW(std::ostream &os) const;
> +
> +    inline bool
> +    writeRAW(const char *filename) const {
> +       std::ofstream os(filename, std::ofstream::binary);
> +       if (!os) {
> +           return false;
> +       }
> +       writeRAW(os);
> +       return true;
> +    }
> +
>      double compare(Image &ref);
>  };
>
> diff --git a/image/image_raw.cpp b/image/image_raw.cpp
> new file mode 100644
> index 0000000..dd45d10
> --- /dev/null
> +++ b/image/image_raw.cpp
> @@ -0,0 +1,47 @@
> +/**************************************************************************
> + *
> + * Copyright (C) 2013 Intel Corporation. All rights reversed.
> + * Author: Shuang He <shuang.he at intel.com>
> + * All Rights Reserved.
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a copy
> + * of this software and associated documentation files (the "Software"), to deal
> + * in the Software without restriction, including without limitation the rights
> + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> + * copies of the Software, and to permit persons to whom the Software is
> + * furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice shall be included in
> + * all copies or substantial portions of the Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
> + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
> + * THE SOFTWARE.
> + *
> + **************************************************************************/
> +
> +
> +#include <assert.h>
> +#include <string.h>
> +#include <stdint.h>
> +#include <stdio.h>
> +
> +#include "image.hpp"
> +
> +
> +namespace image {
> +
> +void
> +Image::writeRAW(std::ostream &os) const {
> +    const unsigned char *row;
> +
> +    for (row = start(); row != end(); row += stride()) {
> +        os.write((const char *)row, width*channels);
> +    }
> +}
> +
> +} /* namespace image */
> diff --git a/retrace/retrace_main.cpp b/retrace/retrace_main.cpp
> index 2d3311f..a0dc47b 100644
> --- a/retrace/retrace_main.cpp
> +++ b/retrace/retrace_main.cpp
> @@ -129,6 +129,8 @@ takeSnapshot(unsigned call_no) {
>              snprintf(comment, sizeof comment, "%u",
>                       useCallNos ? call_no : snapshot_no);
>              src->writePNM(std::cout, comment);
> +        } else if (snapshotPrefix[0] == '@' && snapshotPrefix[1] == 0) {
> +            src->writeRAW(std::cout);
>          } else {
>              os::String filename = os::String::format("%s%010u.png",
>                                                       snapshotPrefix,
> @@ -566,7 +568,7 @@ usage(const char *argv0) {
>          "      --db                use a double buffer visual (default)\n"
>          "      --driver=DRIVER     force driver type (`hw`, `sw`, `ref`, `null`, or driver module name)\n"
>          "      --sb                use a single buffer visual\n"
> -        "  -s, --snapshot-prefix=PREFIX    take snapshots; `-` for PNM stdout output\n"
> +        "  -s, --snapshot-prefix=PREFIX    take snapshots; `-` for PNM stdout output; `@` for raw RGB stdout output\n"
>          "  -S, --snapshot=CALLSET  calls to snapshot (default is every frame)\n"
>          "  -v, --verbose           increase output verbosity\n"
>          "  -D, --dump-state=CALL   dump state at specific call no\n"
> --
> 1.7.10.1
>
> _______________________________________________
> apitrace mailing list
> apitrace at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/apitrace


More information about the apitrace mailing list