当前位置: 首页>>代码示例>>C++>>正文


C++ DCBuffer::getPtrFree方法代码示例

本文整理汇总了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;
//.........这里部分代码省略.........
开发者ID:vijayskumar,项目名称:bigdata-virtual-microscope,代码行数:101,代码来源:f-ppmpartitioner.cpp


注:本文中的DCBuffer::getPtrFree方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。