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 ============================
On 12-04-17 7:15 PM, Gustav Gonz?lez wrote:> http://www.maefloresta.com/tmp/example.cpp > > The point where I am stuck starts at this comment: > // LOOK HERE (line 313)This file is only 304 lines long.> 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.You did see there's already (more accurate) code to do this in png2theora.c? See rgb_to_yuv in https://svn.xiph.org/trunk/theora/examples/png2theora.c if you don't have the latest version. In particular, decimation isn't the best way to do chroma subsampling. :)> 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.I didn't try compiling your code, but those types should be equivalent under Qt. Perhaps the corruption is coming from the elsewhere in the conversion code. -r
After several days of trials and errors playing with code from many places, finally I could write a very basic example based on the png2theora.c file Here is the code, although it already works it can be enhanced a lot, so I?m posting these files just for those curious programmers interested in this specific topic (Qt + libtheora): http://www.maefloresta.com/portal/files/theora.pro.txt http://www.maefloresta.com/portal/files/theora.cpp.txt I hope this can be handy for someone else. -- ===========================? Gustav Gonzalez ? xtingray at gmail.com ============================