本文整理汇总了C++中UArray_size函数的典型用法代码示例。如果您正苦于以下问题:C++ UArray_size函数的具体用法?C++ UArray_size怎么用?C++ UArray_size使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了UArray_size函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IoMP3Decoder_inputCallback
static enum mad_flow IoMP3Decoder_inputCallback(void *data, struct mad_stream *stream)
{
IoMP3Decoder *self = data;
struct mad_decoder *decoder = &(DATA(self)->decoder);
IoMessage_locals_performOn_(DATA(self)->willProcessMessage, self, self);
if (DATA(self)->isRunning)
{
UArray *ba = IoSeq_rawUArray(DATA(self)->inputBuffer);
UArray_removeRange(ba, 0, DATA(self)->lastInputPos);
{
size_t size = UArray_size(ba);
UArray_setSize_(ba, size + MAD_BUFFER_GUARD);
memset(UArray_bytes(ba) + size, 0x0, MAD_BUFFER_GUARD);
UArray_setSize_(ba, size);
}
if (UArray_size(ba) == 0)
{
return MAD_FLOW_CONTINUE;
}
DATA(self)->lastInputPos = UArray_size(ba);
mad_stream_buffer(stream, UArray_bytes(ba), UArray_size(ba));
}
return DATA(self)->isRunning ? MAD_FLOW_CONTINUE : MAD_FLOW_STOP;
}
示例2: IO_METHOD
IO_METHOD(IoSeq, inclusiveSlice)
{
/*doc Sequence inclusiveSlice(inclusiveStartIndex, inclusiveEndIndex)
Returns a new string containing the subset of the
receiver from the inclusiveStartIndex to the inclusiveEndIndex. The inclusiveEndIndex argument
is optional. If not given, it is assumed to be the end of the string.
*/
long fromIndex = IoMessage_locals_longArgAt_(m, locals, 0);
long last = UArray_size(DATA(self));
UArray *ba;
if (IoMessage_argCount(m) > 1)
{
last = IoMessage_locals_longArgAt_(m, locals, 1);
}
if (last == -1)
{
last = UArray_size(DATA(self));
}
else
{
last = last + 1;
}
ba = UArray_slice(DATA(self), fromIndex, last);
if (ISSYMBOL(self))
{
return IoState_symbolWithUArray_copy_(IOSTATE, ba, 0);
}
return IoSeq_newWithUArray_copy_(IOSTATE, ba, 0);
}
示例3: IOCB
IoObject *IoAsyncRequest_write(IoAsyncRequest *self, IoObject *locals, IoMessage *m)
{
/*doc AsyncRequest write(fileOffset, aSeq, bufferOffset, numberOfBytesToWrite)
Submits an async write request. Returns nil on error, self otherwise.
*/
int r;
IoSeq *data;
UArray *ba;
int bufferOffset;
int bytesToWrite;
IOCB(self)->aio_offset = (size_t)CNUMBER(IoMessage_locals_numberArgAt_(m, locals, 0));
data = IoMessage_locals_seqArgAt_(m, locals, 1);
ba = IoSeq_rawUArray(data);
bufferOffset = IoMessage_locals_intArgAt_(m, locals, 2);
bytesToWrite = IoMessage_locals_intArgAt_(m, locals, 3);
if (bytesToWrite > UArray_size(ba) - bufferOffset)
{
bytesToWrite = UArray_size(ba) - bufferOffset;
}
IOCB(self)->aio_nbytes = bytesToWrite;
IOCB(self)->aio_buf = realloc(IOCB_BUFFER(self), bytesToWrite);
memcpy(IOCB_BUFFER(self), UArray_bytes(ba), bytesToWrite);
r = aio_write(IOCB(self));
return r == 0 ? self : IONIL(self);
}
示例4: Image_setData_width_height_componentCount_
void Image_setData_width_height_componentCount_(Image *self, UArray *ba, int width, int height, int componentCount)
{
int size = width * height * componentCount;
if (size != UArray_size(ba))
{
printf("Image_setData_width_height_componentCount_() error - %i x %i x %i = %i, but buffer is %i\n",
width, height, componentCount, size, (int)UArray_size(ba));
return;
}
Image_copyUArray_(self, ba);
self->width = width;
self->height = height;
self->componentCount = componentCount;
}
示例5: IO_METHOD
IO_METHOD(IoSeq, replaceFirstSeq)
{
/*doc Sequence replaceFirstSeq(aSequence, anotherSequence, optionalStartIndex)
Returns a new Sequence with the first occurance of aSequence
replaced with anotherSequence in the receiver. If optionalStartIndex is
provided, the search for aSequence begins at that index. Returns self.
*/
IoSeq *subSeq = IoMessage_locals_seqArgAt_(m, locals, 0);
IoSeq *otherSeq = IoMessage_locals_seqArgAt_(m, locals, 1);
size_t startIndex = 0;
if (IoMessage_argCount(m) > 2)
{
startIndex = IoMessage_locals_longArgAt_(m, locals, 2);
}
IO_ASSERT_NOT_SYMBOL(self);
{
UArray *a = DATA(self);
UArray *b = DATA(subSeq);
UArray *c = DATA(otherSeq);
long i = UArray_find_from_(a, b, startIndex);
if(i != -1)
{
UArray_removeRange(a, i, UArray_size(b));
UArray_at_putAll_(a, i, c);
}
}
return self;
}
示例6: IOBOOL
IoObject *IoSeq_isEmpty(IoSeq *self, IoObject *locals, IoMessage *m)
{
/*doc Sequence isEmpty
Returns true if the size of the receiver is 0, false otherwise.
*/
return IOBOOL(self, UArray_size(DATA(self)) == 0);
}
示例7: IoMP3Decoder_outputCallback
static enum mad_flow IoMP3Decoder_outputCallback(void *data,
struct mad_header const *header,
struct mad_pcm *pcm)
{
IoMP3Decoder *self = data;
UArray *ba = IoSeq_rawUArray(DATA(self)->outputBuffer);
unsigned int oldSize = UArray_size(ba);
unsigned int newSize = oldSize + (pcm->length * 2 * sizeof(float));
UArray_setSize_(ba, newSize);
if (!DATA(self)->isRunning)
{
return MAD_FLOW_STOP;
}
// MAD data is in 4 byte signed ints
// and on separated (not interleaved channels)
// so we interleave them here
{
float *out = (float *)(UArray_bytes(ba) + oldSize);
unsigned int nsamples = pcm->length;
mad_fixed_t const *left = pcm->samples[0];
mad_fixed_t const *right = pcm->samples[1];
if (pcm->channels == 2)
{
// this would be much faster as a vector op
while (nsamples --)
{
*out = ((float)(*left)) / INT_MAX;
out ++;
*out = ((float)(*right)) / INT_MAX;
out ++;
left ++;
right ++;
}
}
else
{
while (nsamples --)
{
float f = ((float)(*left)) / INT_MAX;
*out = f;
out ++;
*out = f;
out ++;
left ++;
}
}
}
IoMessage_locals_performOn_(DATA(self)->didProcessMessage, self, self);
return DATA(self)->isRunning ? MAD_FLOW_CONTINUE : MAD_FLOW_STOP;
}
示例8: BStream_readUint8
uint8_t BStream_readUint8(BStream *self)
{
if (self->index < UArray_size(self->ba))
{
unsigned char b = UArray_bytes(self->ba)[self->index];
self->index ++;
return b;
}
return 0;
}
示例9:
unsigned char *BStream_readDataOfLength_(BStream *self, size_t length)
{
if (self->index + length <= UArray_size(self->ba))
{
unsigned char *b = (unsigned char *)UArray_bytes(self->ba) + self->index;
self->index += length;
return b;
}
return NULL;
}
示例10: Image_load
void Image_load(Image *self)
{
if (strcmp(self->fileType, "png")==0)
{
PNGImage *image = PNGImage_new();
PNGImage_setExternalUArray_(image, self->byteArray);
PNGImage_path_(image, self->path);
PNGImage_load(image);
Image_error_(self, PNGImage_error(image));
self->width = PNGImage_width(image);
self->height = PNGImage_height(image);
self->componentCount = PNGImage_components(image);
PNGImage_free(image);
}
else if (strcmp(self->fileType, "jpg")==0)
{
JPGImage *image = JPGImage_new();
JPGImage_setExternalUArray_(image, self->byteArray);
JPGImage_path_(image, self->path);
JPGImage_decodingWidthHint_(image, self->decodingWidthHint);
JPGImage_decodingHeightHint_(image, self->decodingHeightHint);
JPGImage_load(image);
Image_error_(self, JPGImage_error(image));
self->width = JPGImage_width(image);
self->height = JPGImage_height(image);
self->componentCount = JPGImage_components(image);
JPGImage_free(image);
}
else if (strcmp(self->fileType, "tif")==0 || strcmp(self->fileType, "tiff")==0)
{
TIFFImage *image = TIFFImage_new();
TIFFImage_setExternalUArray_(image, self->byteArray);
TIFFImage_path_(image, self->path);
TIFFImage_load(image);
Image_error_(self, TIFFImage_error(image));
self->width = TIFFImage_width(image);
self->height = TIFFImage_height(image);
self->componentCount = TIFFImage_components(image);
TIFFImage_free(image);
}
else
{
Image_error_(self, "unknown file type");
}
if (UArray_size(self->byteArray) == 0)
{
Image_error_(self, "error reading file");
}
Image_makeRGBA(self);
}
示例11: items
IoObject *IoSeq_size(IoSeq *self, IoObject *locals, IoMessage *m)
{
/*doc Sequence size
Returns the length in number of items (which may or may not
be the number of bytes, depending on the item type) of the receiver. For example,
<p>
<pre>
"abc" size == 3
</pre>
*/
return IONUMBER(UArray_size(DATA(self)));
}
示例12: AudioDevice_swapWriteBuffers
int AudioDevice_swapWriteBuffers(AudioDevice *self)
{
/* clear the current buffer */
UArray_setSize_(self->writeBuffer, 0);
self->writeFrame = 0;
/* swap if the next one has data */
if (UArray_size(self->nextWriteBuffer))
{
void *b = self->writeBuffer;
self->writeBuffer = self->nextWriteBuffer;
self->nextWriteBuffer = b;
//printf("swapping buffers self->needsData = 1\n");
self->needsData = 1;
}
return 0;
}
示例13: UArray_replace_with_
void UArray_replace_with_(UArray *self, const UArray *a1, const UArray *a2)
{
long i;
size_t start = 0;
UArray visible = UArray_stackRange(self, start, self->size);
if (UArray_size(a1) == 0) return;
while ((i = UArray_find_(&visible, a1)) != -1)
{
size_t index = start + i;
UArray_removeRange(self, index, a1->size);
UArray_at_putAll_(self, index, a2);
start = index + a2->size;
visible = UArray_stackRange(self, start, self->size - start);
}
UArray_changed(self);
}
示例14: DATA
IoObject *IoZlibEncoder_process(IoZlibEncoder *self, IoObject *locals, IoMessage *m)
{
/*doc ZlibEncoder process
Process the inputBuffer and appends the result to the outputBuffer.
The processed inputBuffer is empties except for the spare bytes at
the end which don't fit into a cipher block.
*/
z_stream *strm = DATA(self)->strm;
UArray *input = IoObject_rawGetMutableUArraySlot(self, locals, m, IOSYMBOL("inputBuffer"));
UArray *output = IoObject_rawGetMutableUArraySlot(self, locals, m, IOSYMBOL("outputBuffer"));
uint8_t *inputBytes = (uint8_t *)UArray_bytes(input);
size_t inputSize = UArray_sizeInBytes(input);
if (inputSize)
{
int ret;
size_t oldOutputSize = UArray_size(output);
size_t outputRoom = (inputSize * 2);
uint8_t *outputBytes;
UArray_setSize_(output, oldOutputSize + outputRoom);
outputBytes = (uint8_t *)UArray_bytes(output) + oldOutputSize;
strm->next_in = inputBytes;
strm->avail_in = inputSize;
strm->next_out = outputBytes;
strm->avail_out = outputRoom;
ret = deflate(strm, Z_NO_FLUSH);
//assert(ret != Z_STREAM_ERROR);
{
size_t outputSize = outputRoom - strm->avail_out;
UArray_setSize_(output, oldOutputSize + outputSize);
}
UArray_setSize_(input, 0);
}
return self;
}
示例15: DATA
IoObject *IoLZOEncoder_process(IoLZOEncoder *self, IoObject *locals, IoMessage *m)
{
/*doc LZOEncoder process
Process the inputBuffer and appends the result to the outputBuffer.
The processed inputBuffer is emptied except for the spare bytes at
the end which don't fit into a cipher block.
*/
lzo_align_t __LZO_MMODEL *wrkmem = DATA(self)->wrkmem;
UArray *input = IoObject_rawGetMutableUArraySlot(self, locals, m, IOSYMBOL("inputBuffer"));
UArray *output = IoObject_rawGetMutableUArraySlot(self, locals, m, IOSYMBOL("outputBuffer"));
unsigned char *inputBytes = (uint8_t *)UArray_bytes(input);
size_t inputSize = UArray_sizeInBytes(input);
if (inputSize)
{
int r;
size_t oldOutputSize = UArray_size(output);
lzo_uint outputRoom = (inputSize + inputSize / 64 + 16 + 3);
unsigned char *outputBytes;
UArray_setSize_(output, oldOutputSize + outputRoom);
outputBytes = (uint8_t *)UArray_bytes(output) + oldOutputSize;
r = lzo1x_1_compress(inputBytes, inputSize, outputBytes, &outputRoom, wrkmem);
// r = lzo1x_decompress(in, in_len, out, &out_len, wrkmem);
if (r != LZO_E_OK)
{
IoState_error_(IOSTATE, m, "LZO compression failed: %d", r);
}
UArray_setSize_(output, oldOutputSize + outputRoom);
UArray_setSize_(input, 0);
}
return self;
}