I am using below code to convert from VAAPI to YUV420 format.
AVFrame* src, * dst;
SwsContext* conversion_context_ = sws_getContext(videoDecoder_->width(), videoDecoder_->height(), AV_PIX_FMT_VAAPI,scaler_->getWidth(), scaler_->getHeight(), AV_PIX_FMT_YUV420P,(int)SWS_BICUBIC,
nullptr, nullptr, nullptr); <------------- This function is returning NULL value.
sws_scale(conversion_context_,
(uint8_t const * const *)src->data, src->linesize, 0, (int)height,
dst->data, dst->linesize);
Can some one tell me why I am getting NULL value of SwsContext's pointer?
Fixed this issue by using below code,
SwsContext* conversion_context_ = sws_getContext(videoDecoder_->width(), videoDecoder_->height(), AV_PIX_FMT_NV12 ,scaler_->getWidth(), scaler_->getHeight(), AV_PIX_FMT_YUV420P,(int)SWS_BICUBIC,
nullptr, nullptr, nullptr);
So instead of AV_PIX_FMT_VAAPI option, I used AV_PIX_FMT_NV12.