0

Has any one compiled lib x264 using CLI backend for gcc compiler? (Compiled x264 into .net dll)

R Samuel Klatchko
  • 74,869
  • 16
  • 134
  • 187
Rella
  • 65,003
  • 109
  • 363
  • 636
  • I don't find this very likely. Out of curiosity, why can't you p/invoke the library - is it just too large to wrap. (how many methods/structs in particular would you need to wrap, because if it's a reasonable amount I'll help you do it.) – Mark H Jul 13 '10 at 03:08
  • @Mark H: all I want is minimum for encoding of frames (frame by frame)... So at least ones that are listed in this sample http://stackoverflow.com/questions/2940671/how-to-encode-series-of-images-into-h264-using-x264-api-c-c/2940700#2940700 x264_param_t, X264_RC_CRF, x264_t*, picture_t, x264_nal_t*, x264_param_default_preset(); x264_param_apply_profile(); x264_encoder_open(); x264_picture_alloc(); x264_encoder_encode(); – Rella Jul 13 '10 at 03:15
  • ok, `x264_param_t` is huge, but I'll give it a shot anyway. No promises. – Mark H Jul 13 '10 at 03:38
  • mail me or post here - if you'd do it - it'd be grate! superior0 at ya dot ru – Rella Jul 13 '10 at 03:40
  • If you already have a built x264.dll you could upload, it'd make alot easier for me to test btw. – Mark H Jul 13 '10 at 04:10

1 Answers1

1

Are you using C99 features? If not, Visual C++ with the /clr:pure option should do the trick. You will need a little bit of C++/CLI mixed in to define your entrypoints that other .NET projects can call, but those can be in completely separate files (you can share entire C-only source files with native projects).

EDIT: Basic guide to making this work:

  • In Visual Studio, create a C++/CLI Class Library project
  • Add all your C source files to the project
  • In Project Configuration, set the include path so your headers are found
  • In Project Configuration, also set "Use of Common Language Runtime" to /clr:pure
  • In the .cpp file created by the new project wizard, add #include directive for the header files which prototype the functions you want to use.
  • In the ref class created by the new project wizard (in the aforementioned .cpp file), add some functions (maybe static functions) which call your C library functions.
  • Compile, add this .DLL as a reference of your C# project, and enjoy

As a hint, instead of creating a forwarding function in the ref class for every function in the library, you may want to make functions that do useful work (for the particular definition of useful for your particular project) by calling a bunch of library functions.

You'll probably want to get comfortable with the marshal_as template which is good for converting .NET System::String into C strings and back again.

Ben Voigt
  • 277,958
  • 43
  • 419
  • 720