wiki:Component/FbController

SocLib Components General Index

Component description

This component is a common utility component.

This creates a frame buffer, it uses soclib-fb from the utilities for a SDL-based viewer window.

For now, the only supported mode are YUV-422 and YUV-420. This may change in the future.

User may directly modify a shared-memory buffer, and update it to screen on-demand.

Component usage

Object

soclib::common::FbController *fb;

Instanciation

    soclib::common::FbController(
        const std::string &basename,
        unsigned long width,
        unsigned long height,
        int subsampling );
basename
The name of the created framebuffer window
width
Width of the window
height
Height of the window
subsampling
YUV subsampling, valid values are 422 and 420

Usage

    const unsigned long width = 320;
    const unsigned long height = 240;

    soclib::common::FbController fb("fb0", width, height, 422);

    ...

// sample setter function:

void set(soclib::common::FbController &fb, int line, int column, uint8_t y, uint8_t u, uint8_t v)
{
    uint8_t* buffer = (uint8_t*)fb.surface();
    const unsigned long width = fb.m_width;
    const unsigned long height = fb.m_height;

    buffer[                 line*width  +column  ] = y;
    buffer[width*height    +line*width/2+column/2] = u;
    buffer[width*height*3/2+line*width/2+column/2] = v;

    fb->update();
}
Last modified 15 years ago Last modified on Feb 24, 2009, 11:38:36 AM