2008-11-26 36 views
2

FFMPEG의 avcodec_decode_video() 함수에서 가져온 AVFrame에 대한 포인터가 있으면 DirectX 표면에 이미지를 어떻게 복사합니까? (내가 DX X8R8G8B8 표면에 적절한 크기의 포인터를 가지고 있다고 가정하십시오.)FFMPEG DirectX 표면의 프레임

고마워요.

존.

답변

4

FFMPEG의 img_convert() 함수를 사용하여 이미지를 표면에 동시에 복사하고 RGB 형식으로 변환 할 수 있습니다. (I 대신 다이렉트의 SDL을 사용하고 있지만) 여기에 비슷한 일을했다 내 최근 프로젝트에서 붙여 넣은 몇 줄의 코드입니다 :

AVFrame *frame; 
    avcodec_decode_video(_ffcontext, frame, etc...); 

    lockYourSurface(); 
    uint8_t *buf = getPointerToYourSurfacePixels(); 

// Create an AVPicture structure which contains a pointer to the RGB surface. 
    AVPicture pict; 

    memset(&pict, 0, sizeof(pict)); 

    avpicture_fill(&pict, buf, PIX_FMT_RGB32, 
        _ffcontext->width, _ffcontext->height); 



// Convert the image into RGB and copy to the surface. 
    img_convert(&pict, PIX_FMT_RGB32, (AVPicture *)frame, 
       _context->pix_fmt, _context->width, _context->height); 


    unlockYourSurface(); 
+0

덕분에, 아담. 그게 제가 끝내었던 것입니다. :) –