문제

FFMPEG의 AVFRAME에 대한 포인터가 주어졌습니다 avcodec_decode_video() 기능 이미지를 DirectX 표면에 어떻게 복사합니까? (적절한 크기의 DX X8R8G8B8 표면에 대한 포인터가 있다고 가정합니다.)

감사.

남자.

도움이 되었습니까?

해결책

ffmpeg의 img_convert () 함수를 사용하여 이미지를 표면에 동시에 복사하여 RGB 형식으로 변환 할 수 있습니다. 다음은 비슷한 일을 한 최근의 프로젝트에서 붙여진 몇 줄의 코드가 있습니다 (DirectX 대신 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();
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top