本文整理汇总了C++中MemoryBuffer::size方法的典型用法代码示例。如果您正苦于以下问题:C++ MemoryBuffer::size方法的具体用法?C++ MemoryBuffer::size怎么用?C++ MemoryBuffer::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MemoryBuffer
的用法示例。
在下文中一共展示了MemoryBuffer::size方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: copy
bool MemoryBuffer::copy(const MemoryBuffer& buf)
{
bool ret;
if ((ret = resize(buf.size()))) {
copyData(buf.dataPtr<uint8_t>(), buf.size());
}
return ret;
}
示例2: assemble
void assemble(const char *binfname, void *fin)
{
MemoryBuffer buffer;
assemble_to_buffer(&buffer, fin);
// Buffer compression logic.
sp_file_hdr_t *header = (sp_file_hdr_t *)buffer.bytes();
size_t region_size = header->imagesize - header->dataoffs;
size_t zbuf_max = compressBound(region_size);
Bytef *zbuf = (Bytef *)malloc(zbuf_max);
uLong new_disksize = zbuf_max;
int err = compress2(
zbuf,
&new_disksize,
(Bytef *)(buffer.bytes() + header->dataoffs),
region_size,
Z_BEST_COMPRESSION
);
if (err != Z_OK) {
free(zbuf);
pc_printf("Unable to compress, error %d\n", err);
pc_printf("Falling back to no compression.\n");
splat_to_binary(binfname, buffer.bytes(), buffer.size());
return;
}
header->disksize = new_disksize + header->dataoffs;
header->compression = SmxConsts::FILE_COMPRESSION_GZ;
buffer.rewind(header->dataoffs);
buffer.write(zbuf, new_disksize);
free(zbuf);
splat_to_binary(binfname, buffer.bytes(), buffer.size());
}
示例3: process
DecoderStatus AacDecoder::process(Packet*packet){
FXlong fs = packet->stream_position;
FXbool eos = packet->flags&FLAG_EOS;
long unsigned int samplerate;
FXuchar channels;
NeAACDecFrameInfo frame;
if (packet->flags&AAC_FLAG_CONFIG) {
handle = NeAACDecOpen();
if (NeAACDecInit2(handle,packet->data(),packet->size(),&samplerate,&channels)<0){
packet->unref();
return DecoderError;
}
return DecoderOk;
}
else {
buffer.append(packet->data(),packet->size());
packet->unref();
if (handle==NULL) {
handle = NeAACDecOpen();
long n = NeAACDecInit(handle,buffer.data(),buffer.size(),&samplerate,&channels);
if (n<0) return DecoderError;
else if (n>0) buffer.readBytes(n);
af.set(AP_FORMAT_S16,samplerate,channels);
engine->output->post(new ConfigureEvent(af,Codec::AAC));
}
}
if (buffer.size()<FAAD_MIN_STREAMSIZE*2) {
return DecoderOk;
}
do {
if (out==NULL){
out = engine->decoder->get_output_packet();
if (out==NULL) return DecoderInterrupted;
out->af = af;
out->stream_position = fs;
out->stream_length = packet->stream_length;
}
void * outbuffer = out->ptr();
NeAACDecDecode2(handle,&frame,buffer.data(),buffer.size(),&outbuffer,out->availableFrames()*out->af.framesize());
if (frame.bytesconsumed>0) {
buffer.readBytes(frame.bytesconsumed);
}
if (frame.error > 0) {
GM_DEBUG_PRINT("[aac] error %d (%ld): %s\n",frame.error,frame.bytesconsumed,faacDecGetErrorMessage(frame.error));
}
if (frame.samples) {
fs+=(frame.samples/frame.channels);
out->wroteFrames((frame.samples/frame.channels));
if (out->availableFrames()==0) {
engine->output->post(out);
out=NULL;
}
}
}
while(buffer.size()>(2*FAAD_MIN_STREAMSIZE) && frame.bytesconsumed);
if (eos) {
if (out) {
engine->output->post(out);
out=NULL;
}
engine->output->post(new ControlEvent(End,packet->stream));
}
return DecoderOk;
}