The tutorial is wrong, you'll need to remove the libjpeg files from your devkitPPC install - there should be nothing in there except the files distributed by devkitPro, Sadly there also appears to be no source code for libogc_jpeg which makes it a bit awkward to convert this tutorial into something reasonable - especially since there appear to be wii/cube specific additions over and above the official libjpeg.
We have a selection of prebuilt libraries for wii/gamecube, including libjpeg, found at
http://sourceforge.net/projects/devkitp ... tlibs/ppc/ . These archives should be extracted to <path/to>/devkitpro/portlibs/ppc. When using them add $(PORTILIBS) to LIBDIRS in the Makefile & add the appropriate lib to LIBS.
Code: Select all
#---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project
#---------------------------------------------------------------------------------
LIBS := -lwiiuse -lbte -logc -ljpeg -lm
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS := $(PORTLIBS)
I don't have time right now to dig into this very deeply (currently moving house) so I haven't managed to put together a working example but I have some code snippets that might help.
Code: Select all
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <jpeglib.h>
// include generated by build
#include "testcard_jpg.h"
...
struct jpeg_decompress_struct cinfo;
memset(&cinfo,0,sizeof(cinfo));
jpeg_mem_src(&cinfo,(u8*)testcard_jpg,testcard_jpg_size);
jpeg_read_header(&cinfo, TRUE);
jpeg_start_decompress(&cinfo);
int row_stride = cinfo.output_width * cinfo.output_components;
JSAMPARRAY buffer = (*cinfo.mem->alloc_sarray)((j_common_ptr) &cinfo, JPOOL_IMAGE, row_stride, 1);
while (cinfo.output_scanline < cinfo.output_height) {
(void) jpeg_read_scanlines(&cinfo, buffer, 1);
}
jpeg_finish_decompress(&cinfo);
The decompressed scanline data will need to be converted from rgb to Y1CbY2Cr in order to display it via XFB, something like this.
Code: Select all
//---------------------------------------------------------------------------------
// convert two RGB pixels to one Y1CbY2Cr.
//---------------------------------------------------------------------------------
u32 rgb2yuv (u8 r1, u8 g1, u8 b1, u8 r2, u8 g2, u8 b2) {
//---------------------------------------------------------------------------------
int y1, cb1, cr1, y2, cb2, cr2, cb, cr;
y1 = (299 * r1 + 587 * g1 + 114 * b1) / 1000;
cb1 = (-16874 * r1 - 33126 * g1 + 50000 * b1 + 12800000) / 100000;
cr1 = (50000 * r1 - 41869 * g1 - 8131 * b1 + 12800000) / 100000;
y2 = (299 * r2 + 587 * g2 + 114 * b2) / 1000;
cb2 = (-16874 * r2 - 33126 * g2 + 50000 * b2 + 12800000) / 100000;
cr2 = (50000 * r2 - 41869 * g2 - 8131 * b2 + 12800000) / 100000;
cb = (cb1 + cb2) >> 1;
cr = (cr1 + cr2) >> 1;
return (y1 << 24) | (cb << 16) | (y2 << 8) | cr;
}
The reason you see a blank screen on Dolphin is because the demo writes directly to the framebuffer. If you go into the Graphics configuration, under hacks, select Real External Frame Buffer.