FFMPEG الإطار دايركت السطحية
سؤال
وبالنظر إلى مؤشر إلى AVFrame من avcodec_decode_video
FFMPEG ل() وظيفة كيف يمكنني نسخ الصورة إلى سطح دايركت؟ (عند وجود لدي مؤشر إلى سطح DX X8R8G8B8 بحجم مناسب.)
وشكرا.
وجون.
المحلول
ويمكنك استخدام وظيفة FFMPEG في img_convert () لنسخ في وقت واحد صورة لسطح وتحويله إلى صيغة RGB. وهنا بضعة أسطر من التعليمات البرمجية لصق من مشروع حديث من الألغام التي فعلت شيئا مماثلا (وإن كنت تستخدم SDL بدلا من DirectX):
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();
لا تنتمي إلى StackOverflow