你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。

请教下,使用st提供的历程,libjpeg 库解码 ???

[复制链接]
hpdell 提问时间:2016-1-11 15:47 /
本帖最后由 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 */
}

收藏 评论4 发布时间:2016-1-11 15:47

举报

4个回答
wolfgang 回答时间:2016-1-12 10:14:10
JOCTET *
就一个指针啊?指针的内存空间呢?
hpdell 回答时间:2016-1-12 14:30:55
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:49
终于搞定了,原来是 程序 申请内存的问题造成的
KinSang Lam 回答时间:2021-7-17 10:00:48
hpdell 发表于 2017-5-30 15:07
终于搞定了,原来是 程序 申请内存的问题造成的

请问最后是怎样解决的?可以分享一下吗?

所属标签

相似问题

关于
我们是谁
投资者关系
意法半导体可持续发展举措
创新与技术
意法半导体官网
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
官方最新发布
STM32N6 AI生态系统
STM32MCU,MPU高性能GUI
ST ACEPACK电源模块
意法半导体生物传感器
STM32Cube扩展软件包
关注我们
st-img 微信公众号
st-img 手机版