本文整理汇总了C++中DCBuffer::getPtrFree方法的典型用法代码示例。如果您正苦于以下问题:C++ DCBuffer::getPtrFree方法的具体用法?C++ DCBuffer::getPtrFree怎么用?C++ DCBuffer::getPtrFree使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DCBuffer
的用法示例。
在下文中一共展示了DCBuffer::getPtrFree方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: process
int ocvm_ppm_partitioner::process()
{
cout << "ocvm_ppm_partitioner: invoked \n";
double before = dcmpi_doubletime();
uint u;
FILE * f_dim;
int i, j;
std::string input_filename = get_param("input_filename");
std::string host_scratch_filename = get_param("host_scratch_filename");
HostScratch host_scratch(host_scratch_filename);
std::string output_filename = get_param("output_filename");
std::string dim_timestamp = get_param("dim_timestamp");
int nnodes = host_scratch.components.size();
PPMDescriptor ppm(input_filename);
if (ppm.pixels_y < nnodes) {
std::cerr << "ERROR: can't handle such a tiny image"
<< " at " << __FILE__ << ":" << __LINE__
<< std::endl << std::flush;
exit(1);
}
std::cout << "ppm.pixels_x: " << ppm.pixels_x << endl;
std::cout << "ppm.pixels_y: " << ppm.pixels_y << endl;
int output_tiles = nnodes;
int8 sz = 3 * ppm.pixels_x * ppm.pixels_y;
while ((sz / output_tiles) > MB_2) {
output_tiles *= 2;
}
std::cout << "output_tiles " << output_tiles << endl;
int chunks_per_host = output_tiles / nnodes;
int pixel_rows_per_tile_norm = ppm.pixels_y / output_tiles;
int pixel_rows_per_tile_rem = ppm.pixels_y % output_tiles;
int pixel_rows_per_tile_last = ppm.pixels_y - (pixel_rows_per_tile_norm *
(output_tiles-1));
std::cout << pixel_rows_per_tile_norm << endl;
std::cout << pixel_rows_per_tile_rem << endl;
std::cout << pixel_rows_per_tile_last << endl;
int hostid = 0;
int ckthisid = 0;
std::vector<int> dims_y;
std::vector<std::string> parts;
for (int t = 0; t < output_tiles; t++) {
int pixel_rows = pixel_rows_per_tile_norm;
if (t == output_tiles-1) {
pixel_rows = pixel_rows_per_tile_last;
}
else if (pixel_rows_per_tile_rem) {
pixel_rows_per_tile_rem--;
pixel_rows += 1;
pixel_rows_per_tile_last--;
}
dims_y.push_back(pixel_rows);
//std::cout << "malloc of "<<(pixel_rows * ppm.pixels_x * 3)<<endl;
unsigned char * data_rgb =
new unsigned char[pixel_rows * ppm.pixels_x * 3];
std::string output_prefix =
(host_scratch.components[hostid])[1] + "/" +
dim_timestamp + "/" + dcmpi_file_basename(input_filename)
+ ".";
int x = 0;
int y = t;
std::string output_fn =
output_prefix + "x" +
tostr(x) + "_y" +
tostr(y);
char partline[4096];
snprintf(partline, sizeof(partline),
"part %d %d %d %s %s",
x,
y,
0,
((host_scratch.components[hostid])[0]).c_str(),
output_fn.c_str());
parts.push_back(partline);
int npixels = pixel_rows * ppm.pixels_x;
int chunk_sz = npixels*3;
DCBuffer * outb = new DCBuffer(8+output_fn.size() + 8+1+
chunk_sz);
outb->pack("ss", output_fn.c_str(), "w");
ppm.getrows(pixel_rows, data_rgb);
// convert from RGB to planar BGR
unsigned char * dest = (unsigned char*)outb->getPtrFree();
for (int chan = 0; chan < 3; chan++) {
unsigned char * src = data_rgb + (2 - chan);
for (int v = 0; v < npixels; v++) {
*dest = *src;
dest++;
src += 3;
}
}
outb->incrementUsedSize(chunk_sz);
write_nocopy(outb, "towriter_" + tostr(hostid));
delete[] data_rgb;
ckthisid++;
if (ckthisid==chunks_per_host) {
ckthisid=0;
//.........这里部分代码省略.........