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


C++ FileHandle::size方法代码示例

本文整理汇总了C++中FileHandle::size方法的典型用法代码示例。如果您正苦于以下问题:C++ FileHandle::size方法的具体用法?C++ FileHandle::size怎么用?C++ FileHandle::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FileHandle的用法示例。


在下文中一共展示了FileHandle::size方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: run

    void run()
    {
        bool doDecode = false;

        static const int samples = 450*1024;
        static const int inputBufferSize = samples;
        static const int sampleSpaceBefore = 256;
        static const int sampleSpaceAfter = 256;

        FileHandle in = File("captured.zdr", true).openRead();
        UInt64 inputFileSizeRemaining = in.size();
        Array<Byte> inputBuffer(inputBufferSize);
        int inputBufferRemaining = 0;
        Byte* inputPointer = 0;
        z_stream zs;
        memset(&zs, 0, sizeof(z_stream));
        if (inflateInit(&zs) != Z_OK)
            throw Exception("inflateInit failed");

        Array<Byte> buffer(sampleSpaceBefore + samples + sampleSpaceAfter);
        Byte* b = &buffer[0] + sampleSpaceBefore;
        for (int i = 0; i < sampleSpaceBefore; ++i)
            b[i - sampleSpaceBefore] = 0;
        for (int i = 0; i < sampleSpaceAfter; ++i)
            b[i + samples] = 0;
        int outputBytesRemaining = samples;

        Vector outputSize;
        NTSCCaptureDecoder<UInt32> decoder;
         
        if (doDecode) 
            outputSize = Vector(1280, 720);
        else
            outputSize = Vector(1824, 253);
        Bitmap<UInt32> decoded(outputSize);
        if (doDecode)
            decoder.setOutputBuffer(
                decoded.subBitmap(Vector(160, 0), Vector(960, 720)));
        else
            decoder.setOutputBuffer(decoded);
        decoded.fill(0);
        decoder.setInputBuffer(b);
        decoder.setOutputPixelsPerLine(1140);
        decoder.setYScale(3);
        decoder.setDoDecode(doDecode);

        _handle = fopen("u:\\captured2.avi","wb");
        if (!_handle)
            throw Exception("Can't open file");

        _VectorCount = 1;
        _VectorTable[0].x = _VectorTable[0].y = 0;
        for (int s = 1; s <= 10; ++s) {
            for (int y = -s; y <= s; ++y)
                for (int x = -s; x <= s; ++x) {
                    if (abs(x) == s || abs(y) == s) {
                        _VectorTable[_VectorCount].x = x;
                        _VectorTable[_VectorCount].y = y;
                        ++_VectorCount;
                    }
                }
        }
        memset(&_zstream, 0, sizeof(_zstream));

        _pitch = outputSize.x + 2*MAX_VECTOR;
        if (deflateInit(&_zstream, 4) != Z_OK)
            throw Exception("deflateInit failed");

        _bufSize = 4*outputSize.x*outputSize.y + 2*(1+(outputSize.x/8)) * (1+(outputSize.y/8))+1024;
        _bufSize += _bufSize / 1000;

        _buf = malloc(_bufSize);
        if (!_buf)
            throw Exception("Out of memory");
        _index = (UInt8*)malloc(16*4096);
        if (!_buf)
            throw Exception("Out of memory");
        _indexsize = 16*4096;
        _indexused = 8;

        for (int i = 0; i < AVI_HEADER_SIZE; ++i)
            fputc(0, _handle);
        _frames = 0;
        _written = 0;
        _audioused = 0;
        _audiowritten = 0;

        int blockwidth = 16;
        int blockheight = 16;
        _pixelsize = 4;
        _bufsize = (outputSize.y + 2*MAX_VECTOR)*_pitch*_pixelsize+2048;

        _buf1.allocate(_bufsize);
        _buf2.allocate(_bufsize);
        _work.allocate(_bufsize);

        int xblocks = (outputSize.x/blockwidth);
        int xleft = outputSize.x % blockwidth;
        if (xleft)
            ++xblocks;
//.........这里部分代码省略.........
开发者ID:crtc-demos,项目名称:captoavi,代码行数:101,代码来源:captoavi.cpp


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