开发学院手机开发Android 开发 Android jpeglib库在内存中实现解码 阅读

Android jpeglib库在内存中实现解码

 2010-09-10 00:39:00 来源:WEB开发网   
核心提示:num_bytes -= (long) src->pub.bytes_in_buffer;(void) fill_input_buffer(cinfo);/* note we assume that fill_input_buffer will never return FALSE,* so suspension

num_bytes -= (long) src->pub.bytes_in_buffer;

(void) fill_input_buffer(cinfo);

/* note we assume that fill_input_buffer will never return FALSE,

* so suspension need not be handled.

*/

}

src->pub.next_input_byte += (size_t) num_bytes;

src->pub.bytes_in_buffer -= (size_t) num_bytes;

}

}

请注意显示地调用了fill_input_buffer,而不是调用注册给 source manager的回调函数。这样做是不严谨的,虽然只支持文件输入的情况下,这样写没有任何问题,但是如果我们增加其他的输入方式的话(比如内存数据输入),这样写将不会调用到我们注册给Source manager的fill_input_buffer回调函数。所以如上的代码修改为:

METHODDEF(void)

skip_input_data (j_decompress_ptr cinfo, long num_bytes)

{

my_src_ptr src = (my_src_ptr) cinfo->src;

/* Just a dumb implementation for now. Could use fseek() except

* it doesn't work on pipes. Not clear that being smart is worth

* any trouble anyway --- large skips are infrequent.

*/

if (num_bytes > 0) {

while (num_bytes > (long) src->pub.bytes_in_buffer) {

num_bytes -= (long) src->pub.bytes_in_buffer;

//(void) fill_input_buffer(cinfo);

(void) src->pub.fill_input_buffer(cinfo);

/* note we assume that fill_input_buffer will never return FALSE,

* so suspension need not be handled.

*/

}

src->pub.next_input_byte += (size_t) num_bytes;

src->pub.bytes_in_buffer -= (size_t) num_bytes;

}

}

调用我们注册的回调函数来读取数据。

最好我们需要实现一个供用户用内存jpeg数据初始化source manager的接口。我的定义如下:

/*

* This function improve the library can use the jpeg memory block as source.

*/

GLOBAL(void)

jpeg_stdio_buffer_src (j_decompress_ptr cinfo, UINT8 * buffer, UINT32

上一页  1 2 3 4 5  下一页

Tags:Android jpeglib 内存

编辑录入:coldstar [复制链接] [打 印]
[]
  • 好
  • 好的评价 如果觉得好,就请您
      0%(0)
  • 差
  • 差的评价 如果觉得差,就请您
      0%(0)
赞助商链接