带 JNA 的 x264 编码器

发布于 2024-10-12 12:12:42 字数 1199 浏览 8 评论 0原文

我一直忙于围绕 x264.dll 创建 JNA 包装器。我的 x264_param_t 有以下类:

http://pastebin.com/Mh4JkVpP

但是,当我尝试初始化时我的 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:

http://pastebin.com/Mh4JkVpP

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我很OK 2024-10-19 12:12:42

不要注释掉 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文