DoubleLi

qq: 517712484 wx: ldbgliet

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

1.第一种

        m_pFrameVideoOut = av_frame_alloc();
        m_pFrameVideoOut->format = AV_PIX_FMT_BGR24;
        m_pFrameVideoOut->width = m_VideoCodecCtx->width;
        m_pFrameVideoOut->height = m_VideoCodecCtx->height;
        if (av_image_alloc(m_pFrameVideoOut->data, m_pFrameVideoOut->linesize, m_pFrameVideoOut->width, m_pFrameVideoOut->height, AV_PIX_FMT_BGR24, 16) < 0)
        {
            return ;
        }

2.第二种

        m_pFrameVideoOut = av_frame_alloc();
        m_pFrameVideoOut->format = AV_PIX_FMT_BGR24;
        m_pFrameVideoOut->width = m_VideoCodecCtx->width;
        m_pFrameVideoOut->height = m_VideoCodecCtx->height;
        av_frame_get_buffer(m_pFrameVideoOut, 16);

 

3.第三种

    int bufferSize = av_image_get_buffer_size(AV_PIX_FMT_YUV420P, nWidth, nHeight, 1);;
    m_InputFrame = av_frame_alloc();
    m_InputFrame->width = nWidth;
    m_InputFrame->height = nHeight;
    m_InputFrame->format = AV_PIX_FMT_YUV420P;
    m_Buffer = (unsigned char *)av_malloc(bufferSize);
    av_image_fill_arrays(m_InputFrame->data, m_InputFrame->linesize, m_Buffer, AV_PIX_FMT_YUV420P, nWidth, nHeight, 1);

posted on 2021-07-20 10:49  DoubleLi  阅读(393)  评论(0编辑  收藏  举报