开发者

x264 encoder with JNA

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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜