Linux高精度定时器调整帧率

在835手机连接1080p@60摄像头时遇到帧率不稳问题,表现为帧间隔时间不均匀。为解决此问题,采用Linux的timer_create创建高精度定时器,每16.66毫秒发送一帧,确保60fps帧率,但引入50毫秒延迟。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

发现835手机外接1080p@60摄像头时,帧率不稳定(burst)。现象是如果统计一千帧,帧率是60fps,但是如果打印两帧之间的间隔,发现有时候间隔是3毫秒,有时是9ms。这样导致UI处理不过来,而Android GraphicBuffer在queueBuffer时,最多只能缓存一帧,而丢弃前面的帧

status_t BufferQueueProducer::queueBuffer(int slot,
        const QueueBufferInput &input, QueueBufferOutput *output) {
    ATRACE_CALL();
    ATRACE_BUFFER_INDEX(slot);

    ................................................

    sp<IConsumerListener> frameAvailableListener;
    sp<IConsumerListener> frameReplacedListener;
    int callbackTicket = 0;
    uint64_t currentFrameNumber = 0;
    BufferItem item;
    { // Autolock scope
        Mutex::Autolock lock(mCore->mMutex);

        .........................................

        output->bufferReplaced = false;
        if (mCore->mQueue.empty()) {
            // When the queue is empty, we can ignore mDequeueBufferCannotBlock
            // and simply queue this buffer
            mCore->mQueue.push_back(item);
            frameAvailableListener = mCore->mConsumerListener;
        } else {
            // When the queue is not empty, we need to look at the last buffer
            // in the queue to see if we need to replace it
            const
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值