#include <VideoFile.h>
Public Member Functions | |
VideoPicture & | operator= (VideoPicture const &original) |
bool | allocate (int w, int h, enum PixelFormat format=PIX_FMT_RGB24) |
char * | getBuffer () const |
int | getWidth () const |
int | getHeight () const |
bool | isAllocated () const |
void | saveToPPM (QString filename="videoPicture.ppm") const |
enum PixelFormat | getFormat () const |
Friends | |
class | VideoFile |
The VideoPicture RGB buffer can then be used for OpenGL texturing. Here is an example code:
const VideoPicture *vp = is->getPictureAtIndex(newtexture); if (vp->isAllocated()) { glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, vp->getWidth(), vp->getHeight(), 0, GL_RGB, GL_UNSIGNED_BYTE, vp->getBuffer() ); }
Definition at line 48 of file VideoFile.h.
bool VideoPicture::allocate | ( | int | w, | |
int | h, | |||
enum PixelFormat | format = PIX_FMT_RGB24 | |||
) |
Allocate the frame (w x h pixels) and resets to black.
The pixel format is usually PIX_FMT_RGB24 or PIX_FMT_RGBA for OpenGL texturing, but depends on the format requested when instanciating the VideoFile.
w | Width of the frame | |
h | Height of the frame | |
format | Internal pixel format of the buffer. PIX_FMT_RGB24 by default, PIX_FMT_RGBA if there is alpha channel, or another format from libavutil/pixfmt.h. |
char* VideoPicture::getBuffer | ( | ) | const [inline] |
Get a pointer to the buffer containing the frame.
If the buffer is allocated in the PIX_FMT_RGB24 pixel format, it is a Width x Height x 3 array of unsigned bytes (char or uint8_t) . This buffer is directly applicable as a GL_RGB OpenGL texture.
If the buffer is allocated in the PIX_FMT_RGBA pixel format, it is a Width x Height x 4 array of unsigned bytes (char or uint8_t) . This buffer is directly applicable as a GL_RGBA OpenGL texture.
Internal representation of buffers for other formats are described in libswscale/swscale.h and libavutil/pixfmt.h.
Definition at line 94 of file VideoFile.h.
enum PixelFormat VideoPicture::getFormat | ( | ) | const [inline] |
Internal pixel format of the buffer.
This is usually PIX_FMT_RGB24 or PIX_FMT_RGBA for OpenGL texturing, but depends on the pixel format requested when instanciating the VideoFile.
Pixel format should be tested before applying texture, e.g.:
if ( vp->getFormat() == PIX_FMT_RGBA) glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, vp->getWidth(), vp->getHeight(), 0, GL_RGBA, GL_UNSIGNED_BYTE, vp->getBuffer() );
Definition at line 141 of file VideoFile.h.
int VideoPicture::getHeight | ( | ) | const [inline] |
Get the height of the picture.
Definition at line 110 of file VideoFile.h.
int VideoPicture::getWidth | ( | ) | const [inline] |
Get the width of the picture.
Definition at line 102 of file VideoFile.h.
bool VideoPicture::isAllocated | ( | ) | const [inline] |
Tells if the picture was allocated and contains a frame in the buffer.
Definition at line 118 of file VideoFile.h.
VideoPicture& VideoPicture::operator= | ( | VideoPicture const & | original | ) |
Copy operator if target is already allocated, it should have the same dimensions
void VideoPicture::saveToPPM | ( | QString | filename = "videoPicture.ppm" |
) | const |
Creates and saves a .ppm image file with the current buffer (if full).