带 JNA 的 x264 编码器
我一直忙于围绕 x264.dll 创建 JNA 包装器。我的 x264_param_t 有以下类:
但是,当我尝试初始化时我的 x264_param_t 就像
x264_param_t param_t = new x264_param_t;
我收到以下错误:
Exception in thread "main" java.lang.IllegalArgumentException: Can't determine size of nested structure: Can't instantiate class anotherReversed.x264_param_t$Vui (java.lang.InstantiationException: anotherReversed.x264_param_t$Vui)
at com.sun.jna.Structure.calculateSize(Structure.java:790)
at com.sun.jna.Structure.allocateMemory(Structure.java:287)
at com.sun.jna.Structure.<init>(Structure.java:177)
at com.sun.jna.Structure.<init>(Structure.java:167)
at com.sun.jna.Structure.<init>(Structure.java:163)
at com.sun.jna.Structure.<init>(Structure.java:154)
at anotherReversed.x264_param_t.<init>(x264_param_t.java:7)
如果我在其父类构造函数中注释掉 Vui,则实例化正常。我想知道这个嵌套结构有什么不同,因为还有另外两个结构(即 Rc 和 Analytics )以相同的方式嵌套。但不知何故,JNA 无法找到 Vui 所需的大小。有什么指点吗?
编辑: 似乎所有其他嵌套结构( analysis 和 rc )也没有初始化。我想知道为什么?
I have been busy creating a JNA wrapper around x264.dll. I have the following class for my x264_param_t:
However, when I try to initialize my x264_param_t like that
x264_param_t param_t = new x264_param_t;
I get the following error:
Exception in thread "main" java.lang.IllegalArgumentException: Can't determine size of nested structure: Can't instantiate class anotherReversed.x264_param_t$Vui (java.lang.InstantiationException: anotherReversed.x264_param_t$Vui)
at com.sun.jna.Structure.calculateSize(Structure.java:790)
at com.sun.jna.Structure.allocateMemory(Structure.java:287)
at com.sun.jna.Structure.<init>(Structure.java:177)
at com.sun.jna.Structure.<init>(Structure.java:167)
at com.sun.jna.Structure.<init>(Structure.java:163)
at com.sun.jna.Structure.<init>(Structure.java:154)
at anotherReversed.x264_param_t.<init>(x264_param_t.java:7)
If I comment out the Vui in it's parent class constructor, the instantiation is ok. I wonder what is different with EXACTLY this nested structure, as there are 2 others (namely Rc and Analyse ) that are nested in the same way. Somehow, though, JNA isn't able to find the required size for Vui. Any pointers?
Edit:
It seems that all the other nested structs (analyse and rc ) were also not initialized. I wonder why?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不要注释掉 Vui,而是用 Pointer 替换它,并检查其他两个结构是否已填充。
这些结构被定义为 x264_param_t 结构中的内部结构,也许 JNA 有问题。仔细查看 x264_param_t.toString() 的输出,因为它打印计算出的内存偏移量。
我希望您能在 jna 邮件列表
编辑
Instead of commenting out Vui, replace it with a Pointer and check if the other two structures are filled.
These structures are defined as inner structures within the x264_param_t struct, maybe JNA has problems with it. Take a closer look at the output of x264_param_t.toString(), as it prints calculated memory offsets.
I hope you'll find better answers at the jna mailing list
EDIT A dirty hack to solve the problem: use an array of ints or just dump all variables from the inner struct instead of using a separate class.