/** * Initialize a temporary storage for the specified number of audio samples. * The conversion requires temporary storage due to the different format. * The number of audio samples to be allocated is specified in frame_size. * @param[out] converted_input_samples Array of converted samples. The * dimensions are reference, channel * (for multi-channel audio), sample. * @param output_codec_context Codec context of the output file * @param frame_size Number of samples to be converted in * each round * @return Error code (0 if successful) */ int init_converted_samples(byte ***converted_input_samples, AVCodecContext *output_codec_context, int frame_size) { int error; /* Allocate as many pointers as there are audio channels. * Each pointer will later point to the audio samples of the corresponding * channels (although it may be NULL for interleaved formats). */ if ((*converted_input_samples = (byte **)Marshal.AllocHGlobal(output_codec_context->channels * sizeof(IntPtr))) == null) { Console.WriteLine($"error: Could not allocate converted input sample pointers"); return(AVERROR(ENOMEM)); } /* Allocate memory for the samples of all channels in one consecutive * block for convenience. */ if ((error = av_samples_alloc(*converted_input_samples, null, output_codec_context->channels, frame_size, output_codec_context->sample_fmt, 0)) < 0) { Console.WriteLine($"error: Could not allocate converted input samples (error '{LibAVErrorToString(error)}')"); av_freep(&(*converted_input_samples)[0]); Marshal.FreeHGlobal((IntPtr)(*converted_input_samples)); return(error); } return(0); }
public MemoryManager(IntPtr ram) { _observedPages = new ConcurrentDictionary <long, IntPtr>(); Ram = ram; _ramPtr = (byte *)ram; _pageTable = (byte ***)Marshal.AllocHGlobal(PtLvl0Size * IntPtr.Size); for (int l0 = 0; l0 < PtLvl0Size; l0++) { _pageTable[l0] = null; } }
public AMemory(IntPtr Ram) { Monitors = new Dictionary <int, ArmMonitor>(); ObservedPages = new ConcurrentDictionary <long, IntPtr>(); this.Ram = Ram; RamPtr = (byte *)Ram; PageTable = (byte ***)Marshal.AllocHGlobal(PTLvl0Size * IntPtr.Size); for (int L0 = 0; L0 < PTLvl0Size; L0++) { PageTable[L0] = null; } }
protected virtual void Dispose(bool disposing) { if (_pageTable == null) { return; } for (int l0 = 0; l0 < PtLvl0Size; l0++) { if (_pageTable[l0] != null) { Marshal.FreeHGlobal((IntPtr)_pageTable[l0]); } _pageTable[l0] = null; } Marshal.FreeHGlobal((IntPtr)_pageTable); _pageTable = null; }
protected virtual void Dispose(bool disposing) { if (PageTable == null) { return; } for (int L0 = 0; L0 < PTLvl0Size; L0++) { if (PageTable[L0] != null) { Marshal.FreeHGlobal((IntPtr)PageTable[L0]); } PageTable[L0] = null; } Marshal.FreeHGlobal((IntPtr)PageTable); PageTable = null; }
public static byte *stbi_zlib_compress(byte *data, int data_len, int *out_len, int quality) { uint bitbuf = (uint)(0); int i; int j; int bitcount = (int)(0); byte * _out_ = null; byte ***hash_table = (byte ***)(malloc((ulong)(16384 * sizeof(byte **)))); if ((quality) < (5)) { quality = (int)(5); } if ((((_out_) == null) || ((((int *)(_out_) - 2)[1] + (1)) >= (((int *)(_out_) - 2)[0])))) { stbiw__sbgrowf((void **)(&(_out_)), (int)(1), sizeof(byte)); } (_out_)[((int *)(_out_) - 2)[1]++] = (byte)(0x78); if ((((_out_) == null) || ((((int *)(_out_) - 2)[1] + (1)) >= (((int *)(_out_) - 2)[0])))) { stbiw__sbgrowf((void **)(&(_out_)), (int)(1), sizeof(byte)); } (_out_)[((int *)(_out_) - 2)[1]++] = (byte)(0x5e); { bitbuf |= (uint)((1) << bitcount); bitcount += (int)(1); _out_ = stbiw__zlib_flushf(_out_, &bitbuf, &bitcount); } { bitbuf |= (uint)((1) << bitcount); bitcount += (int)(2); _out_ = stbiw__zlib_flushf(_out_, &bitbuf, &bitcount); } for (i = (int)(0); (i) < (16384); ++i) { hash_table[i] = null; } i = (int)(0); while ((i) < (data_len - 3)) { int h = (int)(stbiw__zhash(data + i) & (16384 - 1)); int best = (int)(3); byte * bestloc = null; byte **hlist = hash_table[h]; int n = (int)(hlist != null ? ((int *)(hlist) - 2)[1] : 0); for (j = (int)(0); (j) < (n); ++j) { if ((hlist[j] - data) > (i - 32768)) { int d = (int)(stbiw__zlib_countm(hlist[j], data + i, (int)(data_len - i))); if ((d) >= (best)) { best = (int)(d); bestloc = hlist[j]; } } } if (((hash_table[h]) != null) && ((((int *)(hash_table[h]) - 2)[1]) == (2 * quality))) { memmove(hash_table[h], hash_table[h] + quality, (ulong)(sizeof(byte *) * quality)); ((int *)(hash_table[h]) - 2)[1] = (int)(quality); } if ((((hash_table[h]) == null) || ((((int *)(hash_table[h]) - 2)[1] + (1)) >= (((int *)(hash_table[h]) - 2)[0])))) { stbiw__sbgrowf((void **)(&(hash_table[h])), (int)(1), sizeof(byte *)); } (hash_table[h])[((int *)(hash_table[h]) - 2)[1]++] = (data + i); if ((bestloc) != null) { h = (int)(stbiw__zhash(data + i + 1) & (16384 - 1)); hlist = hash_table[h]; n = (int)(hlist != null ? ((int *)(hlist) - 2)[1] : 0); for (j = (int)(0); (j) < (n); ++j) { if ((hlist[j] - data) > (i - 32767)) { int e = (int)(stbiw__zlib_countm(hlist[j], data + i + 1, (int)(data_len - i - 1))); if ((e) > (best)) { bestloc = null; break; } } } } if ((bestloc) != null) { int d = (int)(data + i - bestloc); for (j = (int)(0); (best) > (lengthc[j + 1] - 1); ++j) { } if (j + 257 <= 143) { bitbuf |= (uint)((stbiw__zlib_bitrev((int)(0x30 + (j + 257)), (int)(8))) << bitcount); bitcount += (int)(8); _out_ = stbiw__zlib_flushf(_out_, &bitbuf, &bitcount); } else if (j + 257 <= 255) { bitbuf |= (uint)((stbiw__zlib_bitrev((int)(0x190 + (j + 257) - 144), (int)(9))) << bitcount); bitcount += (int)(9); _out_ = stbiw__zlib_flushf(_out_, &bitbuf, &bitcount); } else if (j + 257 <= 279) { bitbuf |= (uint)((stbiw__zlib_bitrev((int)(0 + (j + 257) - 256), (int)(7))) << bitcount); bitcount += (int)(7); _out_ = stbiw__zlib_flushf(_out_, &bitbuf, &bitcount); } else { bitbuf |= (uint)((stbiw__zlib_bitrev((int)(0xc0 + (j + 257) - 280), (int)(8))) << bitcount); bitcount += (int)(8); _out_ = stbiw__zlib_flushf(_out_, &bitbuf, &bitcount); } if ((lengtheb[j]) != 0) { bitbuf |= (uint)((best - lengthc[j]) << bitcount); bitcount += (int)(lengtheb[j]); _out_ = stbiw__zlib_flushf(_out_, &bitbuf, &bitcount); } for (j = (int)(0); (d) > (distc[j + 1] - 1); ++j) { } { bitbuf |= (uint)((stbiw__zlib_bitrev((int)(j), (int)(5))) << bitcount); bitcount += (int)(5); _out_ = stbiw__zlib_flushf(_out_, &bitbuf, &bitcount); } if ((disteb[j]) != 0) { bitbuf |= (uint)((d - distc[j]) << bitcount); bitcount += (int)(disteb[j]); _out_ = stbiw__zlib_flushf(_out_, &bitbuf, &bitcount); } i += (int)(best); } else { if (data[i] <= 143) { bitbuf |= (uint)((stbiw__zlib_bitrev((int)(0x30 + (data[i])), (int)(8))) << bitcount); bitcount += (int)(8); _out_ = stbiw__zlib_flushf(_out_, &bitbuf, &bitcount); } else { bitbuf |= (uint)((stbiw__zlib_bitrev((int)(0x190 + (data[i]) - 144), (int)(9))) << bitcount); bitcount += (int)(9); _out_ = stbiw__zlib_flushf(_out_, &bitbuf, &bitcount); } ++i; } } for (; (i) < (data_len); ++i) { if (data[i] <= 143) { bitbuf |= (uint)((stbiw__zlib_bitrev((int)(0x30 + (data[i])), (int)(8))) << bitcount); bitcount += (int)(8); _out_ = stbiw__zlib_flushf(_out_, &bitbuf, &bitcount); } else { bitbuf |= (uint)((stbiw__zlib_bitrev((int)(0x190 + (data[i]) - 144), (int)(9))) << bitcount); bitcount += (int)(9); _out_ = stbiw__zlib_flushf(_out_, &bitbuf, &bitcount); } } if (256 <= 143) { bitbuf |= (uint)((stbiw__zlib_bitrev((int)(0x30 + (256)), (int)(8))) << bitcount); bitcount += (int)(8); _out_ = stbiw__zlib_flushf(_out_, &bitbuf, &bitcount); } else if (256 <= 255) { bitbuf |= (uint)((stbiw__zlib_bitrev((int)(0x190 + (256) - 144), (int)(9))) << bitcount); bitcount += (int)(9); _out_ = stbiw__zlib_flushf(_out_, &bitbuf, &bitcount); } else if (256 <= 279) { bitbuf |= (uint)((stbiw__zlib_bitrev((int)(0 + (256) - 256), (int)(7))) << bitcount); bitcount += (int)(7); _out_ = stbiw__zlib_flushf(_out_, &bitbuf, &bitcount); } else { bitbuf |= (uint)((stbiw__zlib_bitrev((int)(0xc0 + (256) - 280), (int)(8))) << bitcount); bitcount += (int)(8); _out_ = stbiw__zlib_flushf(_out_, &bitbuf, &bitcount); } while ((bitcount) != 0) { bitbuf |= (uint)((0) << bitcount); bitcount += (int)(1); _out_ = stbiw__zlib_flushf(_out_, &bitbuf, &bitcount); } for (i = (int)(0); (i) < (16384); ++i) { if ((hash_table[i]) != null) { free(((int *)(hash_table[i]) - 2)); } } free(hash_table); { uint s1 = (uint)(1); uint s2 = (uint)(0); int blocklen = (int)(data_len % 5552); j = (int)(0); while ((j) < (data_len)) { for (i = (int)(0); (i) < (blocklen); ++i) { s1 += (uint)(data[j + i]); s2 += (uint)(s1); } s1 %= (uint)(65521); s2 %= (uint)(65521); j += (int)(blocklen); blocklen = (int)(5552); } if ((((_out_) == null) || ((((int *)(_out_) - 2)[1] + (1)) >= (((int *)(_out_) - 2)[0])))) { stbiw__sbgrowf((void **)(&(_out_)), (int)(1), sizeof(byte)); } (_out_)[((int *)(_out_) - 2)[1]++] = ((byte)((s2 >> 8) & 0xff)); if ((((_out_) == null) || ((((int *)(_out_) - 2)[1] + (1)) >= (((int *)(_out_) - 2)[0])))) { stbiw__sbgrowf((void **)(&(_out_)), (int)(1), sizeof(byte)); } (_out_)[((int *)(_out_) - 2)[1]++] = ((byte)((s2) & 0xff)); if ((((_out_) == null) || ((((int *)(_out_) - 2)[1] + (1)) >= (((int *)(_out_) - 2)[0])))) { stbiw__sbgrowf((void **)(&(_out_)), (int)(1), sizeof(byte)); } (_out_)[((int *)(_out_) - 2)[1]++] = ((byte)((s1 >> 8) & 0xff)); if ((((_out_) == null) || ((((int *)(_out_) - 2)[1] + (1)) >= (((int *)(_out_) - 2)[0])))) { stbiw__sbgrowf((void **)(&(_out_)), (int)(1), sizeof(byte)); } (_out_)[((int *)(_out_) - 2)[1]++] = ((byte)((s1) & 0xff)); } *out_len = (int)(((int *)(_out_) - 2)[1]); memmove(((int *)(_out_) - 2), _out_, (ulong)(*out_len)); return((byte *)((int *)(_out_) - 2)); }
public static extern int av_samples_alloc_array_and_samples(byte ***audio_data, int *linesize, int nb_channels, int nb_samples, libavutil.AVSampleFormat sample_fmt, int align);
static extern private unsafe int OpenMPI_MPI_Init2(int *argc, byte ***argv);
public static extern int UserTopoGetCellStrAttrVec(UserTopoUnstrctGeomStruct *Ud, int *CellIdVec, int NumCellId, byte *AttrName, byte ***AttrValueVec);
public static unsafe void Method3(byte ***x) { }
public bool ListAuxiliaryStates(byte ***aux, void *state) { throw new NotImplementedException(); }
public bool ListArguments(byte ***args, void *state) { throw new NotImplementedException(); }