1
votes

I'm porting a few larger video codecs to Renderscript. I have just manage to port libx264 and have it encode to a raw H.264 stream. I did that by merging the library using CIL and making globals static, as well as porting Androids own libc string and some stdio functions (merging) and a heap allocation function that use a preallocated buffer.

Now I want to port libvpx. This library uses variable arguments to more central functions than libx264 did (basically the only part I needed to comment out in libx264 was the logging the rest is just configured correct and a few macro definitions to replace things).

So my question is has anyone any tip of how to use variable argument lists for static functions in Renderscript? Google state that Renderscript is C99 compliant so it must be possible in some manner. If anyone have a suggestion for a hack for this let me know if it is not currently supported.

/Harald

1

1 Answers

0
votes

In your SDK directory, you can find that the header stdarg.h is in fact included at ./android-sdks/platform-tools/renderscript/clang-include/stdarg.h. If you add

#include "stdarg.h" 

with you normal include statements, the compiler seems to understand what you are talking about. I have no practical way of testing this beyond compile though.

[EDIT] I just received a "llvm-rs-cc.exe has stopped working" message in windows. The stack dump from the console says that it failed when parsing the sample function I added to see if varargs would compile. Here is the stack dump. The compiler crashes every time. My guess is that it is supported in theory but that the compiler does not handle it properly.

Stack dump:
0.  engine.rs:882:32: current parser token ';'
1.  engine.rs:876:1: parsing function body 'average'
2.  engine.rs:876:1: in compound statement ('{}')

After deleting the function but leaving the header include, the following makes it into the console (without the crash):

C:\android-sdks\platform-tools\renderscript\clang-include\stdarg.h:30:9: error: unknown type name '__builtin_va_list'
C:\android-sdks\platform-tools\renderscript\clang-include\stdarg.h:48:9: error: unknown type name '__builtin_va_list'