2010-05-20 20 views

उत्तर

8

एक त्वरित Google खोज कहती है: नहीं। लेकिन example encoder ऐसा लगता है कि इसे पी/आमंत्रण का उपयोग करके सी # में आसानी से अनुवाद करने योग्य होना चाहिए। Encoder Algorithm Interface काफी प्रबंधनीय दिखता है। और अगर सबकुछ विफल रहता है तो हमेशा सी ++/सीएलआई होता है। कोडप्लेक्स प्रोजेक्ट कौन शुरू करता है? :-)

अद्यतन: अभी तक, एक हैकिश, प्राथमिक कामकाजी प्रोटोटाइप .NET API है। ये रहा:

#include "vpx_codec.h" 

#define VPX_CODEC_DISABLE_COMPAT 1 
#include "vpx_encoder.h" 
#include "vp8cx.h" 

#define vp8iface (&vpx_codec_vp8_cx_algo) 

using namespace System; 

namespace WebM 
{ 
    namespace VP8 
    { 
     namespace Native 
     { 
      public ref class VP8Codec 
      { 
      private: 
       vpx_codec_ctx_t* ctx; 

       VP8Codec(vpx_codec_ctx_t* ctx) 
       { 
        this->ctx = ctx; 
       } 

      public: 
       ~VP8Codec() 
       { 
        vpx_codec_destroy(ctx); 
        delete ctx; 
       } 

       property String^ LastError 
       { 
        String^ get() 
        { 
         return gcnew String(vpx_codec_error(ctx)); 
        } 
       } 

       property String^ LastErrorDetail 
       { 
        String^ get() 
        { 
         return gcnew String(vpx_codec_error_detail(ctx)); 
        } 
       } 

       int Encode() 
       { 
        // TODO: do actual encoding 
        return 
         vpx_codec_encode(ctx, NULL, 0, 1, 0, VPX_DL_REALTIME); 
       } 

       static VP8Codec^ CreateEncoder() // TODO: add 'config' argument 
       { 
        vpx_codec_ctx_t* ctx; 
        vpx_codec_enc_cfg_t cfg; 

        if(vpx_codec_enc_config_default(vp8iface, &cfg, 0)) 
        { 
         return nullptr; // TODO: throw exception 
        } 

        ctx = new vpx_codec_ctx_t; 

        if (vpx_codec_enc_init(ctx, vp8iface, &cfg, 0)) 
        { 
         delete ctx; 
         return nullptr; // TODO: throw exception 
        } 

        return gcnew VP8Codec(ctx); 
       } 

       static property int Version 
       { 
        int get() 
        { 
         return vpx_codec_version(); 
        } 
       } 

       static property String^ VersionString 
       { 
        String^ get() 
        { 
         return gcnew String(vpx_codec_version_str()); 
        } 
       } 

       static property String^ BuildConfig 
       { 
        String^ get() 
        { 
         return gcnew String(vpx_codec_build_config()); 
        } 
       } 

       static String^ GetErrorDescription(int errorCode) 
       { 
        return gcnew String(
         vpx_codec_err_to_string((vpx_codec_err_t)errorCode)); 
       } 

       static property String^ IfaceName 
       { 
        String^ get() 
        { 
         return gcnew String(vpx_codec_iface_name(vp8iface)); 
        } 
       } 
      }; 
     } 
    } 
} 

आप libvpx Windows build से vpxmtd.lib के खिलाफ इस लिंक करने के लिए सक्षम होना चाहिए। मैं एक चेतावनी से छुटकारा पाने में सक्षम नहीं था, लेकिन अब तक यह काम करता प्रतीत होता है। मेरा सी ++/सीएलआई थोड़ी जंगली है, हालांकि, कोड में कुछ मेमोरी लीक हो सकती हैं।

टेस्ट कार्यक्रम:

namespace WebM.VP8 
{ 
    using System; 

    using WebM.VP8.Native; 

    public class Program 
    { 
     public static void Main() 
     { 
      using (var encoder = VP8Codec.CreateEncoder()) 
      { 
       Console.WriteLine(encoder.Encode()); 
      } 
     } 
    } 
} 
+1

बहुत उपयोगी। बहुत बहुत धन्यवाद। –

+0

हाय! आपने परियोजना के .lib संदर्भ को कैसे जोड़ा? जब मैं vs2010 में कोई संदर्भ जोड़ने का प्रयास करता हूं तो यह .lib संकुल नहीं लेता है: –

+0

कोई भी घर? :) –