Giter Site home page Giter Site logo

framesconv's Introduction

framesconv

This is a case study of GPU-accelerated RGB-to-NV12 colorspace conversion by means of OpenGL ES 3.1 compute shader. Optional codepath implementing this conversion by means of OpenGL ES 2.0 fragment shader is also provided. It also showcases following topics:

  • GBM buffers allocation, reading and writing,
  • Surfaceless EGL platform (EGL_MESA_platform_surfaceless),
  • Surfaceless EGL context (EGL_KHR_surfaceless_context),
  • Configless EGL context (EGL_KHR_no_config_context),
  • Creating EGL image from dma_buf (EGL_EXT_image_dma_buf_import),
  • Creating GL textures from EGL image (GL_OES_EGL_image).

The implementation allocates source and destination GBM buffers. Source GBM buffer is filled with raw RGBX data from a provided file. Compute shader converts RGB to NV12 writing output to the destination GBM buffer. In the end, output GBM buffer is drained to a provided file.

Building on Linux

framesconv depends on gbm, egl and glesv2. Once you have it installed, just

make

Building anywhere else

I don't care about any other platforms except Linux, so you are on your own. It's unlikely it would work at all, because EGL_EXT_image_dma_buf_import is Linux-specific extension.

Running

The commandline is

framesconv [-i input] -w width -h height [-o output] [-r render_node] [-es implementation]

where

  • input is either a) path to a source image, or b) - to read the data from standard input. In any case it's your responsibility to provide appropriate amount of input data. Source image is expected in raw 4-bytes RGBX format.
  • width is width of the source image in pixels.
  • height is height of the source image in pixels.
  • output is either a) path to a destination image, or b) - to write the data to the standard output. Destination image is written in raw NV12 format.
  • render_node is a path to the DRM render node.
  • es is either a) 31 for OpenGL ES 3.1 and compute shader implementation, or b) 20 for OpenGL ES 2.0 and fragment shader implementation.

Default value for -i is - making it to read from the standard input. Default value for -o is - making it write to the standard output. Default value for render_node is /dev/dri/renderD128. Default value for es is 31.

Usage

Just provide a proper commandline, i.e.:

./framesconv -i lenna.rgb -w 512 -h 512 -o /tmp/lenna.yuv
Colorspace conversion took 4 milliseconds

Bugs

Yes.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.