jpeg错误打印结构
struct jpeg_error_mgr {
/* Error exit handler: does not return to caller */
JMETHOD(void, error_exit, (j_common_ptr cinfo));
/* Conditionally emit a trace or warning message */
JMETHOD(void, emit_message, (j_common_ptr cinfo, int msg_level));
/* Routine that actually outputs a trace or error message */
JMETHOD(void, output_message, (j_common_ptr cinfo));
/* Format a message string for the most recent JPEG error or message */
JMETHOD(void, format_message, (j_common_ptr cinfo, char * buffer));
#define JMSG_LENGTH_MAX 200 /* recommended size of format_message buffer */
/* Reset error state variables at start of a new image */
JMETHOD(void, reset_error_mgr, (j_common_ptr cinfo)); /* The message ID code and any parameters are saved here.
* A message can have one string parameter or up to 8 int parameters.
*/
int msg_code;//取之参考http://www.cnblogs.com/black-mamba/p/6754493.html
#define JMSG_STR_PARM_MAX 80
union {
int i[];
char s[JMSG_STR_PARM_MAX];
} msg_parm; /* Standard state variables for error facility */ int trace_level; /* max msg_level that will be displayed */ /* For recoverable corrupt-data errors, we emit a warning message,
* but keep going unless emit_message chooses to abort. emit_message
* should count warnings in num_warnings. The surrounding application
* can check for bad data by seeing if num_warnings is nonzero at the
* end of processing.
*/
long num_warnings; /* number of corrupt-data warnings */ /* These fields point to the table(s) of error message strings.
* An application can change the table pointer to switch to a different
* message list (typically, to change the language in which errors are
* reported). Some applications may wish to add additional error codes
* that will be handled by the JPEG library error mechanism; the second
* table pointer is used for this purpose.
*
* First table includes all errors generated by JPEG library itself.
* Error code 0 is reserved for a "no such error string" message.
*/
const char * const * jpeg_message_table; /* Library errors */
int last_jpeg_message; /* Table contains strings 0..last_jpeg_message */
/* Second table can be added by application (see cjpeg/djpeg for example).
* It contains strings numbered first_addon_message..last_addon_message.
*/
const char * const * addon_message_table; /* Non-library errors */
int first_addon_message; /* code for first string in addon table */
int last_addon_message; /* code for last string in addon table */
};
jpeg_error_mgr结构体中的函数指针是在调用jpeg_std_error()后被初始化的。可自定义这些函数指针也可使用默认函数。
注意msg_parm支持一个字符串或8个int参数。
jerror.h中包含了一些错误打印宏,下面以ERREXIT1为例进行说明:
#define ERREXIT1(cinfo,code,p1) \
((cinfo)->err->msg_code = (code), \
(cinfo)->err->msg_parm.i[] = (p1), \
(*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo)))
实际应用中遇到了这么个打印“Improper call to JPEG library in state 202”,那么,这句话是怎么打印出来的呢?
cinfo.err = jpeg_std_error(&jerr);
cinfo.global_state = ;
(&cinfo)->err->msg_code = (JERR_BAD_STATE);
(&cinfo)->err->msg_parm.i[] = ((&cinfo)->global_state);
((*(&cinfo)->err->error_exit)) ((j_common_ptr) (&cinfo)); //ERREXIT1(&cinfo, JERR_BAD_STATE, (&cinfo)->global_state);
line3~5是line7的展开式。第5行中的*间接访问操作符可以不用(http://www.cnblogs.com/black-mamba/p/6765231.html)
<jpegint.h>中包含global_state的值:
/* Values of global_state field (jdapi.c has some dependencies on ordering!) */
#define CSTATE_START 100 /* after create_compress */
#define CSTATE_SCANNING 101 /* start_compress done, write_scanlines OK */
#define CSTATE_RAW_OK 102 /* start_compress done, write_raw_data OK */
#define CSTATE_WRCOEFS 103 /* jpeg_write_coefficients done */
#define DSTATE_START 200 /* after create_decompress */
#define DSTATE_INHEADER 201 /* reading header markers, no SOS yet */
#define DSTATE_READY 202 /* found SOS, ready for start_decompress */
#define DSTATE_PRELOAD 203 /* reading multiscan file in start_decompress*/
#define DSTATE_PRESCAN 204 /* performing dummy pass for 2-pass quant */
#define DSTATE_SCANNING 205 /* start_decompress done, read_scanlines OK */
#define DSTATE_RAW_OK 206 /* start_decompress done, read_raw_data OK */
#define DSTATE_BUFIMAGE 207 /* expecting jpeg_start_output */
#define DSTATE_BUFPOST 208 /* looking for SOS/EOI in jpeg_finish_output */
#define DSTATE_RDCOEFS 209 /* reading file in jpeg_read_coefficients */
#define DSTATE_STOPPING 210 /* looking for EOI in jpeg_finish_decompress */
<jerror.c>
该文件中error_exit()->output_message()->format_message()有如此调用关系。
jpeg错误打印结构的更多相关文章
- yaf项目将500错误打印到页面上
一般在yaf项目调试的时候,如果代码有错误,页面只会响应500错误,但看不到哪里报了什么错误,通过开启yaf的一个配置可以将错误信息显示在页面上. 打开项目的index.php入口文件,在开头加入如下 ...
- iOS 打印结构体
关于OC直接打印结构体,点(CGRect,CGSize,CGPoint,UIOffset)等数据类型,我们完全可以把其转换为OC对象来进项打印调试,而不必对结构体中的成员变量进行打印.就好比我们可以使 ...
- nsstring打印结构体
// // main.m // 09-常用结构体 // // Created by apple on 14-3-20. // Copyright (c) 2014年 apple. All ri ...
- 【FAQ】【JSP】HTTP Status 500 - Summary(问题排查时候应该仔细分析所有的错误打印说明)
Question 1.HTTP Status 500 - Unable to compile class for JSP:'***' cannot be resolved to a type 原因分析 ...
- 打印 Go 结构体(struct)信息:fmt.Printf("%+v", user)
package main import "fmt" // 用户 type User struct { Id int Name string Age int } func main( ...
- 读取bin文件,并且按结构体赋值打印
目标:读取一个bin文件,并且将bin文件中的数据,按字节对齐赋值给结构体,并且打印出结构体的内容 目前思路是简单的先将bin文件数据一次性读到一个数组中,再将数组强制转换为结构体 ] FILE *f ...
- 窥探Swift编程之错误处理与异常抛出
在Swift 2.0版本中,Swift语言对其错误处理进行了新的设计,当然了,重新设计后的结果使得该错误处理系统用起来更爽.今天博客的主题就是系统的搞一下Swift中的错误处理,以及看一下Swift中 ...
- 网上关于sort结构体排序都不完整,我来写一个完整版的 2014-08-09 16:50 60人阅读 评论(0) 收藏
主要参考sort函数_百度文库, 但是那篇有错误 2.结构体排序,a升,b降,c降 平板视图 打印? 01 #include <iostream> 02 #include <algo ...
- C#实现无物理边距真正可打印区域的绘图\打印程序开发
经常在开发实际的应用程序中,需要用到图形绘制和打印程序.如何实现完整的精确打印和绘图是需要注意许多细节地方的.最近在遇到打印问题的时候,仔细研究一阵,总结这篇博文,写得有点杂乱,看文要还请费点神. 基 ...
随机推荐
- SVN 文件删除及恢复
SVN 文件删除及恢复 在TortoiseSVN管理的项目中删除文件的方法: 1. 在客户端按delete删除(OS中删除,不通过SVN) ● 未提交之前一旦Update则被删 ...
- UML及其StarUML介绍
http://blog.csdn.net/monkey_d_meng/article/details/6005764 http://www.uml.org.cn/oobject/200901203.a ...
- DBA_SEGMENTS - 查看数据库对象所分配的物理存储空间
SELECT SEGMENT_NAME,SEGMENT_TYPE,<code>TABLESPACE_NAME</code>,EXTENTS,BLOCKS,BYTES/1024/ ...
- Android Studio使用过程中Java类突然报红,但项目可运行解决方案
1.点击File->Invalidate Caches / Restart... 2.重启Gradle,清除缓存 3.Clean Project
- 客户端连接Redis
首先下载Jedis http://mvnrepository.com/artifact/redis.clients/jedis 然后脚本如下: package redistest; import ja ...
- Shell--nl命令
nl命令在linux系统中用来计算文件中行号.nl 可以将输出的文件内容自动的加上行号!其默认的结果与 cat -n 有点不太一样, nl 可以将行号做比较多的显示设计,包括位数与是否自动补齐 0 等 ...
- 转:ios学习指南
著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注明出处.作者:Franz Fang链接:https://www.zhihu.com/question/20264108/answer/302 ...
- 我的mac OSX bash_profile文件
A typical install of OS X won't create a .bash_profile for you. When you want to run functions from ...
- C#趣味程序---求两个数的最大公约数和最小公倍数
using System; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { Cons ...
- 恼人的The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved...错误,无奈用Struts的bean:write替代了JSTL的C:out
一个应用中有两个页面使用了JSTL的c:out输出,就类似这么简单三句 <c:if test="${!empty error}"> <h2>&l ...