本文整理汇总了C++中memory_cptr::get_buffer方法的典型用法代码示例。如果您正苦于以下问题:C++ memory_cptr::get_buffer方法的具体用法?C++ memory_cptr::get_buffer怎么用?C++ memory_cptr::get_buffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类memory_cptr
的用法示例。
在下文中一共展示了memory_cptr::get_buffer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: compression_x
memory_cptr
header_removal_compressor_c::do_compress(memory_cptr const &buffer) {
if (!m_bytes || (0 == m_bytes->get_size()))
return buffer;
size_t size = m_bytes->get_size();
if (buffer->get_size() < size)
throw mtx::compression_x(boost::format(Y("Header removal compression not possible because the buffer contained %1% bytes "
"which is less than the size of the headers that should be removed, %2%.")) % buffer->get_size() % size);
unsigned char *buffer_ptr = buffer->get_buffer();
unsigned char *bytes_ptr = m_bytes->get_buffer();
if (memcmp(buffer_ptr, bytes_ptr, size)) {
std::string b_buffer, b_bytes;
size_t i;
for (i = 0; size > i; ++i) {
b_buffer += (boost::format(" %|1$02x|") % static_cast<unsigned int>(buffer_ptr[i])).str();
b_bytes += (boost::format(" %|1$02x|") % static_cast<unsigned int>(bytes_ptr[i])).str();
}
throw mtx::compression_x(boost::format(Y("Header removal compression not possible because the buffer did not start with the bytes that should be removed. "
"Wanted bytes:%1%; found:%2%.")) % b_bytes % b_buffer);
}
return memory_c::clone(buffer->get_buffer() + size, buffer->get_size() - size);
}
示例2: switch
void
vc1::es_parser_c::handle_packet(memory_cptr packet) {
uint32_t marker = get_uint32_be(packet->get_buffer());
switch (marker) {
case VC1_MARKER_SEQHDR:
handle_sequence_header_packet(packet);
break;
case VC1_MARKER_ENTRYPOINT:
handle_entrypoint_packet(packet);
break;
case VC1_MARKER_FRAME:
handle_frame_packet(packet);
break;
case VC1_MARKER_SLICE:
handle_slice_packet(packet);
break;
case VC1_MARKER_FIELD:
handle_field_packet(packet);
break;
case VC1_MARKER_ENDOFSEQ:
handle_end_of_sequence_packet(packet);
break;
default:
handle_unknown_packet(marker, packet);
break;
}
}
示例3:
void
wav_pcm_demuxer_c::process(int64_t len) {
if (0 >= len)
return;
m_ptzr->process(new packet_t(new memory_c(m_buffer->get_buffer(), len, false)));
}
示例4:
void
xtr_oggvorbis_c::handle_frame(memory_cptr &frame,
KaxBlockAdditions *,
int64_t,
int64_t,
int64_t,
int64_t,
bool,
bool,
bool) {
m_content_decoder.reverse(frame, CONTENT_ENCODING_SCOPE_BLOCK);
ogg_packet op;
op.packet = frame->get_buffer();
op.bytes = frame->get_size();
int64_t this_block_size = vorbis_packet_blocksize(&m_vorbis_info, &op);
if (-1 != m_previous_block_size) {
m_queued_granulepos = m_samples;
m_samples += (this_block_size + m_previous_block_size) / 4;
}
m_previous_end = m_samples * 1000000000 / m_sfreq;
m_previous_block_size = this_block_size;
queue_frame(frame, 0);
}
示例5: mxverb
void
xtr_ivf_c::handle_frame(memory_cptr &frame,
KaxBlockAdditions *,
int64_t timecode,
int64_t,
int64_t,
int64_t,
bool,
bool,
bool) {
m_content_decoder.reverse(frame, CONTENT_ENCODING_SCOPE_BLOCK);
uint64_t frame_number = timecode * m_frame_rate_num / m_frame_rate_den / 1000000000ull;
mxverb(2, boost::format("timecode %1% num %2% den %3% frame_number %4% calculated back %5%\n")
% timecode % m_frame_rate_num % m_frame_rate_den % frame_number
% (frame_number * 1000000000ull * m_frame_rate_den / m_frame_rate_num));
ivf::frame_header_t frame_header;
put_uint32_le(&frame_header.frame_size, frame->get_size());
put_uint32_le(&frame_header.timestamp, frame_number);
m_out->write(&frame_header, sizeof(frame_header));
m_out->write(frame->get_buffer(), frame->get_size());
++m_frame_count;
}
示例6: return
std::string
vc1_info_c::create_checksum_info(memory_cptr packet) {
if (!g_opt_checksum)
return "";
return (boost::format(Y(" checksum 0x%|1$08x|")) % calc_adler32(packet->get_buffer(), packet->get_size())).str();
}
示例7: in
static std::shared_ptr<std::vector<std::string> >
extract_vorbis_comments(const memory_cptr &mem) {
std::shared_ptr<std::vector<std::string> > comments(new std::vector<std::string>);
mm_mem_io_c in(mem->get_buffer(), mem->get_size());
uint32_t i, n, len;
try {
in.skip(7); // 0x03 "vorbis"
n = in.read_uint32_le(); // vendor_length
in.skip(n); // vendor_string
n = in.read_uint32_le(); // user_comment_list_length
comments->reserve(n);
for (i = 0; i < n; i++) {
len = in.read_uint32_le();
memory_cptr buffer(new memory_c((unsigned char *)safemalloc(len + 1), len + 1));
if (in.read(buffer->get_buffer(), len) != len)
throw false;
comments->push_back(std::string((char *)buffer->get_buffer(), len));
}
} catch(...) {
}
return comments;
}
示例8: while
std::vector<memory_cptr>
unlace_memory_xiph(memory_cptr &buffer) {
if (1 > buffer->get_size())
throw mtx::mem::lacing_x("Buffer too small");
std::vector<int> sizes;
unsigned char *ptr = buffer->get_buffer();
unsigned char *end = buffer->get_buffer() + buffer->get_size();
size_t last_size = buffer->get_size();
size_t num_blocks = ptr[0] + 1;
size_t i;
++ptr;
for (i = 0; (num_blocks - 1) > i; ++i) {
int size = 0;
while ((ptr < end) && (*ptr == 255)) {
size += 255;
++ptr;
}
if (ptr >= end)
throw mtx::mem::lacing_x("End-of-buffer while reading the block sizes");
size += *ptr;
++ptr;
sizes.push_back(size);
last_size -= size;
}
sizes.push_back(last_size - (ptr - buffer->get_buffer()));
std::vector<memory_cptr> blocks;
for (i = 0; sizes.size() > i; ++i) {
if ((ptr + sizes[i]) > end)
throw mtx::mem::lacing_x("End-of-buffer while assigning the blocks");
blocks.push_back(memory_cptr(new memory_c(ptr, sizes[i], false)));
ptr += sizes[i];
}
return blocks;
}
示例9:
size_t
mm_io_c::write(const memory_cptr &buffer,
size_t size,
size_t offset) {
size = std::min(buffer->get_size() - offset, size);
if (write(buffer->get_buffer() + offset, size) != size)
throw mtx::mm_io::end_of_file_x();
return size;
}
示例10: memcpy
void
header_removal_compressor_c::decompress(memory_cptr &buffer) {
if (!m_bytes.is_set() || (0 == m_bytes->get_size()))
return;
memory_cptr new_buffer = memory_c::alloc(buffer->get_size() + m_bytes->get_size());
memcpy(new_buffer->get_buffer(), m_bytes->get_buffer(), m_bytes->get_size());
memcpy(new_buffer->get_buffer() + m_bytes->get_size(), buffer->get_buffer(), buffer->get_size());
buffer = new_buffer;
}
示例11: memcpy
memory_cptr
header_removal_compressor_c::do_decompress(memory_cptr const &buffer) {
if (!m_bytes || (0 == m_bytes->get_size()))
return buffer;
memory_cptr new_buffer = memory_c::alloc(buffer->get_size() + m_bytes->get_size());
memcpy(new_buffer->get_buffer(), m_bytes->get_buffer(), m_bytes->get_size());
memcpy(new_buffer->get_buffer() + m_bytes->get_size(), buffer->get_buffer(), buffer->get_size());
return new_buffer;
}
示例12: sizeof
void
xtr_oggkate_c::handle_frame(memory_cptr &frame,
KaxBlockAdditions *,
int64_t timecode,
int64_t,
int64_t,
int64_t,
bool,
bool,
bool) {
m_content_decoder.reverse(frame, CONTENT_ENCODING_SCOPE_BLOCK);
ogg_packet op;
op.b_o_s = 0;
op.e_o_s = (frame->get_size() == 1) && (frame->get_buffer()[0] == 0x7f);
op.packetno = m_packetno;
op.packet = frame->get_buffer();
op.bytes = frame->get_size();
/* we encode the backlink in the granulepos */
float f_timecode = timecode / 1000000000.0;
int64_t g_backlink = 0;
if (op.bytes >= static_cast<long>(1 + 3 * sizeof(int64_t)))
g_backlink = get_uint64_le(op.packet + 1 + 2 * sizeof(int64_t));
float f_backlink = g_backlink * (float)m_kate_id_header.gden / m_kate_id_header.gnum;
float f_base = f_timecode - f_backlink;
float f_offset = f_timecode - f_base;
int64_t g_base = (int64_t)(f_base * m_kate_id_header.gnum / m_kate_id_header.gden);
int64_t g_offset = (int64_t)(f_offset * m_kate_id_header.gnum / m_kate_id_header.gden);
op.granulepos = (g_base << m_kate_id_header.kfgshift) | g_offset;
ogg_stream_packetin(&m_os, &op);
flush_pages(); /* Kate is a data packet per page */
++m_packetno;
}
示例13: mxinfo
void
vc1_info_c::handle_sequence_header_packet(memory_cptr packet) {
std::string checksum = create_checksum_info(packet);
mxinfo(boost::format(Y("Sequence header at %1% size %2%%3%\n")) % m_stream_pos % packet->get_size() % checksum);
m_seqhdr_found = vc1::parse_sequence_header(packet->get_buffer(), packet->get_size(), m_seqhdr);
if (g_opt_sequence_headers) {
if (m_seqhdr_found)
dump_sequence_header(m_seqhdr);
else
mxinfo(Y(" parsing failed\n"));
}
}
示例14:
void
analyze_header_removal_compressor_c::compress(memory_cptr &buffer) {
++m_packet_counter;
if (!m_bytes.is_set()) {
m_bytes = memory_cptr(buffer->clone());
return;
}
unsigned char *current = buffer->get_buffer();
unsigned char *saved = m_bytes->get_buffer();
size_t i, new_size = 0;
for (i = 0; i < std::min(buffer->get_size(), m_bytes->get_size()); ++i, ++new_size)
if (current[i] != saved[i])
break;
m_bytes->set_size(new_size);
}
示例15: memcmp
void
vc1::es_parser_c::handle_sequence_header_packet(memory_cptr packet) {
flush_frame();
add_pre_frame_extra_data(packet);
vc1::sequence_header_t seqhdr;
if (!vc1::parse_sequence_header(packet->get_buffer(), packet->get_size(), seqhdr))
return;
m_seqhdr_changed = !m_seqhdr_found || (packet->get_size() != m_raw_seqhdr->get_size()) || memcmp(packet->get_buffer(), m_raw_seqhdr->get_buffer(), packet->get_size());
memcpy(&m_seqhdr, &seqhdr, sizeof(vc1::sequence_header_t));
m_raw_seqhdr = memory_cptr(packet->clone());
m_seqhdr_found = true;
if (!m_default_duration_forced && m_seqhdr.framerate_flag && (0 != m_seqhdr.framerate_num) && (0 != m_seqhdr.framerate_den))
m_default_duration = 1000000000ll * m_seqhdr.framerate_num / m_seqhdr.framerate_den;
}