ffmpeg实现RTSP摄像头翻转

xingyun86 1月前 189

RTSP摄像头翻转

if (m_bFlip == true)
{
    pAVFrame->data[0] += pAVFrame->linesize[0] * (pAVCodecContext->height - 1);
    pAVFrame->linesize[0] = -pAVFrame->linesize[0];
    pAVFrame->data[1] += pAVFrame->linesize[1] * (pAVCodecContext->height / 2 - 1);
    pAVFrame->linesize[1] = -pAVFrame->linesize[1];
    pAVFrame->data[2] += pAVFrame->linesize[2] * (pAVCodecContext->height / 2 - 1);
    pAVFrame->linesize[2] = -pAVFrame->linesize[2];
    av_image_copy_to_buffer((unsigned char*)pRotateBuffer, pAVCodecContext->width * pAVCodecContext->height * 4, (const uint8_t* const*)pAVFrame->data, (const int*)pAVFrame->linesize, pAVCodecContext->pix_fmt, pAVCodecContext->width, pAVCodecContext->height, 1);
    pAVFrameFlip->width = pAVFrame->width;
    pAVFrameFlip->height = pAVFrame->height;
    xvDisplay->RenderYUV420P((const uint8_t**)pAVFrameFlip->data, pAVFrameFlip->width, pAVFrameFlip->height, W_X_H, HW_X_HH);
}  
else
{
    xvDisplay->RenderYUV420P((const uint8_t**)pAVFrame->data, pAVFrame->width, pAVFrame->height, W_X_H, HW_X_HH);

}

void RenderYUV420P(const uint8_t* src[], int width, int height, int w_x_h, int hw_x_hh) {
    memcpy((uint8_t*)(p_xv_image->data + p_xv_image->offsets[0]), src[0], w_x_h);
    memcpy((uint8_t*)(p_xv_image->data + p_xv_image->offsets[2]), src[1], hw_x_hh);
    memcpy((uint8_t*)(p_xv_image->data + p_xv_image->offsets[1]), src[2], hw_x_hh);
    XvPutImage(p_display, p_base_id, p_window, p_gc, p_xv_image, 0, 0, p_device_width, p_device_height, 0, 0, width, height);
}


×
打赏作者
最新回复 (0)
只看楼主
全部楼主
返回