pstStream->pstPack[i].pu8Addr详解

/******************************************************************************
* funciton : save H264 stream
******************************************************************************/
HI_S32 SAMPLE_COMM_VENC_SaveH264(FILE* fpH264File, VENC_STREAM_S *pstStream)
{
    HI_S32 i;

    
    for (i = 0; i < pstStream->u32PackCount; i++)
    {
       //swann add for test 20181115
       #if ORTP_ENABLE
        rtpSend(pRtpSession,pstStream->pstPack[i].pu8Addr, pstStream->pstPack[i].u32Len);
       #else
        
        
        fwrite(pstStream->pstPack[i].pu8Addr+pstStream->pstPack[i].u32Offset,
               pstStream->pstPack[i].u32Len-pstStream->pstPack[i].u32Offset, 1, fpH264File);

        fflush(fpH264File);
        
        #endif
    }
    

    return HI_SUCCESS;
}

查C语言优先级表得知:-> [] . 处于同一优先级,因此从左到右解析;

1)pstStream->pstPack

typedef struct hiVENC_STREAM_S
{
    VENC_PACK_S *pstPack;                           /*stream pack attribute*/
    HI_U32      u32PackCount;                       /*the pack number of one frame stream*/
    HI_U32      u32Seq;                             /*the list number of stream*/

    union
    {
        VENC_STREAM_INFO_H264_S  stH264Info;         /*the stream info of h264*/
        VENC_STREAM_INFO_JPEG_S  stJpegInfo;         /*the stream info of jpeg*/
        VENC_STREAM_INFO_MPEG4_S stMpeg4Info;       /*the stream info of mpeg4*/
        VENC_STREAM_INFO_H265_S  stH265Info;        /*the stream info of h265*/
    };
}VENC_STREAM_S;
2)pstStream->pstPack[i]的意义:
注意到前面有
            /*******************************************************
                     step 2.1 : query how many packs in one-frame stream.
                    *******************************************************/
                    memset(&stStream, 0, sizeof(stStream));
                    s32Ret = HI_MPI_VENC_Query(i, &stStat);//stStat,为了获取当前帧的编码好的码流包个数。

                    /*******************************************************
                     step 2.3 : malloc corresponding number of pack nodes.
                    *******************************************************/
                    stStream.pstPack = (VENC_PACK_S*)malloc(sizeof(VENC_PACK_S) * stStat.u32CurPacks);
                    /*******************************************************
                     step 2.4 : call mpi to get one-frame stream
                    *******************************************************/
                    stStream.u32PackCount = stStat.u32CurPacks;
                    s32Ret = HI_MPI_VENC_GetStream(i, &stStream, HI_TRUE);
stStream.pstPack为一个指针,指向malloc申请的sizeof(VENC_PACK_S) * stStat.u32CurPacks大小的内存的首地址;
效果等同于创建了一个VENC_PACK_S结构体数组,数组有stStat.u32CurPacks个元素,每个数组元素为结构体VENC_PACK_S类型
typedef struct hiVENC_PACK_S
{
    HI_U32   u32PhyAddr;                         /*the physics address of stream*/
    HI_U8   *pu8Addr;                            /*the virtual address of stream*/
    HI_U32   u32Len;                             /*the length of stream*/
    
    HI_U64   u64PTS;                                /*PTS*/
    HI_BOOL  bFrameEnd;                             /*frame end*/
    
    VENC_DATA_TYPE_U  DataType;                     /*the type of stream*/
    HI_U32   u32Offset;

    HI_U32 u32DataNum;
    VENC_PACK_INFO_S stPackInfo[8];
}VENC_PACK_S;
因此pstStream->pstPack[i]表示访问VENC_PACK_S结构体数组中的第i个元素

3)pstStream->pstPack[i].pu8Addr

访问结构体中的    HI_U8 *pu8Addr; /*the virtual address of stream*/

猜你喜欢

转载自www.cnblogs.com/ordinary-world/p/10056513.html
8 I