Example #1
0
s32 cellPngDecCreate(ppu_thread& ppu, PPHandle handle, PThreadInParam threadInParam, PThreadOutParam threadOutParam)
{
	cellPngDec.warning("cellPngDecCreate(handle=**0x%x, threadInParam=*0x%x, threadOutParam=*0x%x)", handle, threadInParam, threadOutParam);
	return pngDecCreate(ppu, handle, threadInParam, threadOutParam);
}
Example #2
0
s32 cellPngDecExtCreate(PPUThread& ppu, PPHandle handle, PThreadInParam threadInParam, PThreadOutParam threadOutParam, PExtThreadInParam extThreadInParam, PExtThreadOutParam extThreadOutParam)
{
	cellPngDec.warning("cellPngDecCreate(mainHandle=**0x%x, threadInParam=*0x%x, threadOutParam=*0x%x, extThreadInParam=*0x%x, extThreadOutParam=*0x%x)", handle, threadInParam, threadOutParam, extThreadInParam, extThreadOutParam);
	return pngDecCreate(ppu, handle, threadInParam, threadOutParam, extThreadInParam, extThreadOutParam);
}
Example #3
0
static s32 decodePNG(pngDecSource *src,pngData *out)
{
	s32 mHandle,sHandle,ret;
	u32 space_allocated;
	u64 bytes_per_line;
	pngDecInfo DecInfo;
	pngDecInParam inParam;
	pngDecOutParam outParam;
	pngDecDataInfo DecDataInfo;
	pngDecThreadInParam InThdParam;
	pngDecThreadOutParam OutThdParam;

	InThdParam.enable = 0;
	InThdParam.ppu_prio = 512;
	InThdParam.spu_prio = 200;
	InThdParam.malloc_func = __get_addr32(__get_opd32(png_malloc));
	InThdParam.malloc_arg = 0; // no args
	InThdParam.free_func = __get_addr32(__get_opd32(png_free));
	InThdParam.free_arg = 0; // no args

	ret= pngDecCreate(&mHandle, &InThdParam, &OutThdParam);

	out->bmp_out = NULL;
	if(ret==0) {
		ret = pngDecOpen(mHandle,&sHandle,src,&space_allocated);
		if(ret==0) {
			ret = pngDecReadHeader(mHandle,sHandle,&DecInfo);
			if(ret==0) {
				inParam.cmd_ptr = 0;
				inParam.mode = PNGDEC_TOP_TO_BOTTOM;
				inParam.space = PNGDEC_ARGB;
				inParam.bit_depth = 8;
				inParam.pack_flag = 1;
				if(DecInfo.space==PNGDEC_GRAYSCALE_ALPHA || DecInfo.space==PNGDEC_RGBA || DecInfo.chunk_info&0x10)
					inParam.alpha_select = 0;
				else
					inParam.alpha_select = 1;

				inParam.alpha = 0xff;

				ret = pngDecSetParameter(mHandle,sHandle,&inParam,&outParam);
			}

			if(ret==0) {
				out->pitch = bytes_per_line = outParam.width*4;
				//out->bmp_out = malloc(out->pitch*outParam.height);
				out->bmp_out = rsxMemalign(64, out->pitch*outParam.height);
				if(!out->bmp_out)
					ret = -1;
				else {
					memset(out->bmp_out,0,(bytes_per_line*outParam.height));
					
					ret = pngDecDecodeData(mHandle,sHandle,out->bmp_out,&bytes_per_line,&DecDataInfo);
					if(ret==0 && DecDataInfo.status==0) {
						out->width = outParam.width;
						out->height = outParam.height;

						ret = 0;
					}
				}
			}
			pngDecClose(mHandle,sHandle);
		}
		if(ret && out->bmp_out) {
			free(out->bmp_out);
			out->bmp_out = NULL;
		}

		pngDecDestroy(mHandle);
	}
	return ret;
}