[theora] png2theora.c + QImage

Gustav González xtingray at gmail.com
Tue Apr 17 19:15:24 PDT 2012


Hello there,

I have been working on an alternative version of the png2theora example:
The basic idea is to change the input of the program, using a QImage
[1] variable
instead of a png array.

This is my base file:
http://www.maefloresta.com/tmp/example.cpp

The point where I am stuck starts at this comment:
// LOOK HERE (line 313)

And here is the issue: QImage supports RGB images, so my first task is
to transform
the content of the QImage variable from RGB to YUV.

Here is the code I already use to do the trick with a ffmpeg API and it works:
http://www.maefloresta.com/tmp/rgb2yuv.txt

The function prototype is this:
void RGBtoYUV420P(const uint8_t *bufferRGB, uint8_t *yuv, uint
iRGBIncrement, bool bSwapRGB, int width, int height)

Now, to write a theora frame I'm trying to use the function from the
example (png2theora.c):
static int theora_write_frame(unsigned long w, unsigned long h,
unsigned char *yuv, int last)

So, what is my problem?
In the function RGBtoYUV420P(), my input variable to save the YUV data
is: uint8_t *yuv
In the function theora_write_frame(), my input variable for the YUV
data must be: unsigned char *yuv

As you already noticed it, I have to deal with a conflict of types. I
was trying to cast the yuv variable from
"uint8_t" to "unsigned char" and vice versa with no luck. The ogv file
exported is always corrupted.

How can I fix my example file to make it work? Any suggestion?

Thanks.

[1] http://qt-project.org/doc/qt-5.0/qimage.html

-- 
============================
  Gustav Gonzalez
  xtingray at gmail.com
============================


More information about the theora mailing list