vcu-sw-ctrl流程

以官方vcu-sw-ctrl的encode例子解析。

一. 基本流程

  1. FileInfo, Settings , cfg 等参数配置的解析,验证,计算,需要对参数细节了解,与流程关系不大。

  2. 生成CIpDevice设备 (muc device),实际后面反复使用的是m_pScheduler 和 m_pAllocator 。关系如图一所示。

    m_pAllocator是dma申请的buf。绑定到一起后就推流了?

    vcu-sw-ctrl流程

                                                                                                    图 一

  3. 通过配置生成内存池StreamBufPool -> 取出pStream。

    通过AL_Encoder_PutStreamBuffer配置为,encoder输出用的内存池。

    SrcBufPool,encoder 输入的内存池。 输入源文件 YuvFile -> SrcYuv -> SrcBufPool.

    pSrcConv, shouldConvert ,判断输入文件格式是否需要转换。

    QpBufPool内存池,AL_Encoder_Process(hEnc, Src, QpBuf),encoder 处理时用的内存池,具体不清楚。

     

  4. unique_ptr<EncoderSink> enc,创建编码器。

    EncoderSink -> AL_Encoder_Create -> AL_Common_Encoder_CreateChannel -> AL_ISchedulerEnc_CreateChannel -> createChannel -> AL_Driver_PostMessage, Rtos_CreateThread(&WaitForStatus, chan)

    由于编码器是堵塞的(blocking)不睡眠,内存送给encoder后,线程返回,通过WaitForStatus线程,查询处理是否完成,完成后调用挂在的后处理回调函数

     

  5. 输入输出都配置好后,编码器开始处理。

    sendInputFileTo -> ProcessFrame -> AL_Encoder_Process -> AL_Common_Encoder_Process -> AL_ISchedulerEnc_EncodeOneFrame -> encodeOneFrame -> AL_Driver_PostMessage

    WaitForStatus -> getStatusMsg -> chan->CBs.pfnEndEncodingCallBack -> EndEncoding -> pCtx->tLayerCtx[iLayerID].callback.func -> EndEncoding -> EncoderSink::processOutput -> m_done

    按照如上所示,编码流程处理完毕。

     

  6. 手册中的处理流程vcu-sw-ctrl流程vcu-sw-ctrl流程