使用できますsws_scale
。
実際、RGB から YUV への変換にシェーダーは必要ありません。私を信じてください、それは非常に異なるパフォーマンスをするつもりはありません.
swsContext = sws_getContext(WIDTH, HEIGHT, AV_PIX_FMT_RGBA, WIDTH, HEIGHT, AV_PIX_FMT_YUV, SWS_BICUBIC, 0, 0, 0 );
sws_scale(swsContext, (const uint8_t * const *)sourcePictureRGB.data, sourcePictureRGB.linesize, 0, codecContext->height, destinyPictureYUV.data, destinyPictureYUV.linesize);
のデータはdestinyPictureYUV
、コーデックに移動する準備が整います。
このサンプルでは、destinyPictureYUVAVFrame
を塗りつぶします。次のように設定してみてください。
AVFrame * frame;
AVPicture destinyPictureYUV;
avpicture_alloc(&destinyPictureYUV, codecContext->pix_fmt, newCodecContext->width, newCodecContext->height);
// THIS is what you want probably
*reinterpret_cast<AVPicture *>(frame) = destinyPictureYUV;
このセットアップでは、必要に応じて、GPU で既に YUV に変換したデータで埋めることもできます... 必要な方法を選択できます。