请教下,使用st提供的历程,libjpeg 库解码 ???
本帖最后由 hpdell 于 2016-1-11 15:50 编辑各位大侠们,使用st官网提供的libjpeg解码库时,程序运行到
typedef unsigned char JOCTET; // 这个是libjpeg 库里面的原始定义
GLOBAL(void)
jpeg_stdio_src (j_decompress_ptr cinfo, FILE * infile)
{
my_src_ptr src;
/* The source object and input buffer are made permanent so that a series
* of JPEG images can be read from the same file by calling jpeg_stdio_src
* only before the first one.(If we discarded the buffer at the end of
* one image, we'd likely lose the start of the next one.)
* This makes it unsafe to use this manager and a different source
* manager serially with the same JPEG object.Caveat programmer.
*/
if (cinfo->src == NULL) { /* first time for this JPEG object? */
cinfo->src = (struct jpeg_source_mgr *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
SIZEOF(my_source_mgr));
src = (my_src_ptr) cinfo->src;
src->buffer = (JOCTET *) // 程序运行此处时,程序跑飞了,不知是为何???????????????
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
INPUT_BUF_SIZE * SIZEOF(JOCTET));
}
src = (my_src_ptr) cinfo->src;
src->pub.init_source = init_source;
src->pub.fill_input_buffer = fill_input_buffer;
src->pub.skip_input_data = skip_input_data;
src->pub.resync_to_restart = jpeg_resync_to_restart; /* use default method */
src->pub.term_source = term_source;
src->infile = infile;
src->pub.bytes_in_buffer = 0; /* forces fill_input_buffer on first read */
src->pub.next_input_byte = NULL; /* until buffer loaded */
}
JOCTET *
就一个指针啊?指针的内存空间呢? wolfgang2015 发表于 2016-1-12 10:14
JOCTET *
就一个指针啊?指针的内存空间呢?
我加大了 Heap_Size这个设置,上面的可以运行过去,但是后来又在这个
/* Step 5: start decompressor */
jpeg_start_decompress(&cinfo); 这个函数里面运行时程序跑飞了,哎,看来这个库解码需要的内存很大啊,
Heap_Size 这个目前加大到了 0x8000 这么大,但是整个程序还是没有正常运行起来,看来这个库解码还是得放弃了,太占用资源了
你们有没有什么好的方法解码jpeg 格式的图片文件啊 ??
终于搞定了,原来是 程序 申请内存的问题造成的 hpdell 发表于 2017-5-30 15:07
终于搞定了,原来是 程序 申请内存的问题造成的
请问最后是怎样解决的?可以分享一下吗?
页:
[1]