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


C++ XRef::Decode方法代码示例

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


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

示例1: TSLeak

void AVMuxerTest::TSLeak()
{
	// avformat_write_trailer() isn't called on every file for .ts files. This caused
	// a leak. The solution is to call it in dtor after file/buffer is done.

    XRef<H264Decoder> d = new H264Decoder( GetFastH264DecoderOptions() );
    d->SetOutputWidth( 640 );
    d->SetOutputHeight( 360 );
    XRef<H264Encoder> e = new H264Encoder( GetHLSH264EncoderOptions( 250000, 640, 360, 15, 1, 15 ) );
    XRef<AVMuxer> c = new AVMuxer( e->GetOptions(),
                                   "foo.ts",
                                   AVMuxer::OUTPUT_LOCATION_BUFFER );

    c->SetExtraData( e->GetExtraData() );

    for( int i = 0; i < NUM_FRAMES_IN_GOP; i++ )
    {
        int index = i % NUM_FRAMES_IN_GOP;

        XIRef<Packet> pkt = new Packet( gop[index].frame, gop[index].frameSize, false );
        d->Decode( pkt );
        e->EncodeYUV420P( d->Get() );
        c->WriteVideoPacket( e->Get(), ((i % 15) == 0) ? true : false );
    }

    XIRef<XMemory> buffer = new XMemory;
    c->FinalizeBuffer(buffer);
}
开发者ID:MultiSight,项目名称:avkit,代码行数:28,代码来源:AVMuxerTest.cpp

示例2: TestBuffer

void AVMuxerTest::TestBuffer()
{
    XRef<H264Decoder> d = new H264Decoder( GetFastH264DecoderOptions() );
    d->SetOutputWidth( 640 );
    d->SetOutputHeight( 360 );
    XRef<H264Encoder> e = new H264Encoder( GetFastH264EncoderOptions( 250000, 640, 360, 15, 1, 15 ) );
    XRef<AVMuxer> c = new AVMuxer( e->GetOptions(),
                                   "foo.mp4",
                                   AVMuxer::OUTPUT_LOCATION_BUFFER );

    c->SetExtraData( e->GetExtraData() );

    for( int i = 0; i < NUM_FRAMES_IN_GOP; i++ )
    {
        int index = i % NUM_FRAMES_IN_GOP;

        XIRef<Packet> pkt = new Packet( gop[index].frame, gop[index].frameSize, false );
        d->Decode( pkt );
        e->EncodeYUV420P( d->Get() );
        c->WriteVideoPacket( e->Get(), ((i % 15) == 0) ? true : false );
    }

    XIRef<XMemory> buffer = new XMemory;
    c->FinalizeBuffer( buffer );
}
开发者ID:MultiSight,项目名称:avkit,代码行数:25,代码来源:AVMuxerTest.cpp

示例3: Create

void TranscodeExport::Create( XIRef<XMemory> output )
{
    XString tempFileName = _GetTMPName( _fileName );

    // If their is only 1 export in progress (us), but the temp file exists then it means we were interrupted
    // (either a power issue, or a segfault) and we should delete the temporary.
    if( _exportsInProgress == 1 )
    {
        if( XPath::Exists(tempFileName) )
            unlink(tempFileName.c_str());
    }

    if( XPath::Exists(tempFileName) )
        X_THROW(("Export in progress exception: %s", tempFileName.c_str()));

    bool outputToFile = (output.IsEmpty()) ? true : false;
    H264Decoder decoder( GetFastH264DecoderOptions() );
    XRef<YUV420PToARGB24> yuvToARGB = new YUV420PToARGB24;
    XRef<ARGB24ToYUV420P> argbToYUV = new ARGB24ToYUV420P;
    XRef<H264Transcoder> transcoder;
    XRef<H264Encoder> encoder;
    XRef<AVMuxer> muxer;
    XRef<ExportOverlay> ov;
    bool wroteToContainer = false;

    auto lastProgressTime = steady_clock::now();

    // We are going to count how many decoding or encoding exceptions we get... If it
    // ever exceeds some large threshold, we bail on this export.
    int64_t codingExceptions = 0;

    XString recorderURI;
    while( _recorderURLS.GetNextURL( recorderURI ) )
    {
        auto now = steady_clock::now();
        if( wroteToContainer && duration_cast<seconds>(now-lastProgressTime).count() > 2 )
        {
            _progress( _recorderURLS.PercentComplete() );
            lastProgressTime = now;
        }
        
        try
        {
            XIRef<XMemory> responseBuffer = FRAME_STORE_CLIENT::FetchMedia( _config->GetRecorderIP(),
                                                                            _config->GetRecorderPort(),
                                                                            recorderURI );

            ResultParser resultParser;

            resultParser.Parse( responseBuffer );

            FRAME_STORE_CLIENT::ResultStatistics stats = resultParser.GetStatistics();

            // If we are not provided with a bit rate or a frame rate, we use the sources values.
            if( _bitRate == 0 )
                _bitRate = stats.averageBitRate;
            
            if( _maxRate == 0 )
                _maxRate = 2 * stats.averageBitRate;

            if( _bufSize == 0 )
                _bufSize = 2 * stats.averageBitRate;

            if( _frameRate == 0.0 )
                _frameRate = stats.frameRate;

            // Fix for ffmpeg's inability to make files with fps < 6.0. Don't believe me? Try these 2 commands and play
            // output in vlc:
            //
            //   # generate a test movie of the game of life in life.mp4
            //   ffmpeg -f lavfi -i life -frames:v 1000 life.mp4
            //   # transcode and drop framerate of life.mp4 to 1 fps. output.mp4 won't play in vlc and will have a weird
            //   # pause at the beginning for other players.
            //   ffmpeg -i life.mp4 -vf fps=fps=1/1 -vcodec h264 output.mp4
            //
            if( _frameRate < 6.0 )
                _frameRate = 6.0;

            int outputTimeBaseNum = 0;
            int outputTimeBaseDen = 0;
            int inputTimeBaseNum = 0;
            int inputTimeBaseDen = 0;

            AVKit::DToQ( (1/stats.frameRate), inputTimeBaseNum, inputTimeBaseDen );
            AVKit::DToQ( (1/_frameRate), outputTimeBaseNum, outputTimeBaseDen );

            if( transcoder.IsEmpty() )
            {
                transcoder = new H264Transcoder( inputTimeBaseNum, inputTimeBaseDen,
                                                 outputTimeBaseNum, outputTimeBaseDen,
                                                 _speed,
                                                 // if our input is key only, enable decode skipping...
                                                 _recorderURLS.KeyFrameOnly() );
            }

            double secondsPer = AVKit::QToD(inputTimeBaseNum, inputTimeBaseDen) / (AVKit::QToD(inputTimeBaseNum, inputTimeBaseDen) / (AVKit::QToD(outputTimeBaseNum, outputTimeBaseDen) * _speed));
            int traversalNum = 0;
            int traversalDen = 0;

            AVKit::DToQ( secondsPer, traversalNum, traversalDen );
//.........这里部分代码省略.........
开发者ID:MultiSight,项目名称:exporty,代码行数:101,代码来源:TranscodeExport.cpp


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