public int AudioDec(byte[] inData, ref byte[] outData) { //lock (this) { if (_isReleased) { return(0); } // var size = System.Diagnostics.Process.GetCurrentProcess().PrivateMemorySize64; BFrame bframe = new BFrame(); //bframe.Buff = FunctionEx.BytesToIntPtr(inData); //bframe.Size = inData.Length; // IntPtr pbframe = FunctionEx.StructToIntPtr(bframe); IntPtr pbframe = IntPtr.Zero; var decSize = ffimp_audio_decode(pAVObj, inData, inData.Length, ref pbframe); bframe = FunctionEx.IntPtrToStruct <BFrame>(pbframe, 0, Marshal.SizeOf(bframe)); outData = FunctionEx.IntPtrToBytes(bframe.Buff, 0, bframe.Size); return(bframe.Size); //} }
public void Release() { //lock (this) //{ _isReleased = true; try { var avmode = new AVModel() { context = FunctionEx.IntPtrToStruct <AVModel>(pAVObj).context, }; lock (this) ffimp_free_avobj(FunctionEx.StructToIntPtr(avmode)); avmode = new AVModel() { codec = FunctionEx.IntPtrToStruct <AVModel>(pAVObj).codec, }; lock (this) ffimp_free_avobj(FunctionEx.StructToIntPtr(avmode)); //ffimp_free_avobj(pAVObj); if (_ffscale != null) { _ffscale.Release(); } Marshal.FreeHGlobal(pOutBuf); } catch (Exception e) { Console.WriteLine("ffimp error:{0}", e); } //} }
private void InitConfiguration() { var ptr = faacEncGetCurrentConfiguration(_handle); var pConfiguration = FunctionEx.IntPtrToStruct <faacEncConfiguration>(ptr); pConfiguration.inputFormat = 1; pConfiguration.outputFormat = 1; pConfiguration.useTns = 1; pConfiguration.useLfe = 0; pConfiguration.aacObjectType = 2; pConfiguration.shortctl = 0; pConfiguration.quantqual = 80; pConfiguration.bandWidth = 0; pConfiguration.bitRate = (uint)_bitrate; FunctionEx.IntPtrSetValue(ptr, pConfiguration); faacEncSetConfiguration(_handle, ptr); }