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


C++ VideoFrame::setFromMemory方法代码示例

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


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

示例1: videoFrameSize

void
ShmHolder::renderFrame(VideoFrame& src) noexcept
{
    const auto width = src.width();
    const auto height = src.height();
    const auto format = VIDEO_PIXFMT_BGRA;
    const auto frameSize = videoFrameSize(format, width, height);

    if (!resizeArea(frameSize)) {
        RING_ERR("ShmHolder[%s]: could not resize area",
                 openedName_.c_str());
        return;
    }

    {
        VideoFrame dst;
        VideoScaler scaler;

        dst.setFromMemory(area_->data + area_->writeOffset, format, width, height);
        scaler.scale(src, dst);
    }

    {
        SemGuardLock lk {area_->mutex};

        ++area_->frameGen;
        std::swap(area_->readOffset, area_->writeOffset);
        ::sem_post(&area_->frameGenMutex);
    }
}
开发者ID:asadsalman,项目名称:ring-daemon,代码行数:30,代码来源:sinkclient.cpp

示例2: defined

void
SinkClient::update(Observable<std::shared_ptr<VideoFrame>>* /*obs*/,
                   const std::shared_ptr<VideoFrame>& frame_p)
{
    auto& f = *frame_p;

#ifdef DEBUG_FPS
    auto currentTime = std::chrono::system_clock::now();
    const std::chrono::duration<double> seconds = currentTime - lastFrameDebug_;
    ++frameCount_;
    if (seconds.count() > 1) {
        std::ostringstream fps;
        fps << frameCount_ / seconds.count();
        // Send the framerate in smartInfo
        Smartools::getInstance().setFrameRate(id_, fps.str());
        frameCount_ = 0;
        lastFrameDebug_ = currentTime;
    }
#endif

#if HAVE_SHM
    // Send the resolution in smartInfo
    Smartools::getInstance().setResolution(id_, f.width(), f.height());
    shm_->renderFrame(f);
#endif

    if (target_.pull) {
        VideoFrame dst;
        VideoScaler scaler;
        const int width = f.width();
        const int height = f.height();
#if (defined(__ANDROID__) || defined(__APPLE__))
        const int format = VIDEO_PIXFMT_RGBA;
#else
        const int format = VIDEO_PIXFMT_BGRA;
#endif
        const auto bytes = videoFrameSize(format, width, height);

        if (bytes > 0) {
            if (auto buffer_ptr = target_.pull(bytes)) {
                buffer_ptr->format = libav_utils::libav_pixel_format(format);
                buffer_ptr->width = width;
                buffer_ptr->height = height;
                dst.setFromMemory(buffer_ptr->ptr, format, width, height);
                scaler_->scale(f, dst);
                target_.push(std::move(buffer_ptr));
            }
        }
    }
}
开发者ID:asadsalman,项目名称:ring-daemon,代码行数:50,代码来源:sinkclient.cpp


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