bool ok = connect(
m_vedio, &VedioFFmpeg::frameChanged, this, [](QSharedPointer<YUV420Frame> frame)
{ qDebug() << "Received frameChanged signal with frame: " << frame.data(); });
//信号发射
bool VedioFFmpeg::ToRGB(const AVFrame *aframe, uint8_t *m_pixels[], int *m_ptich, int outwidth, int outheight)
{
vedio_frame_mutex.lock();
if (!Vavformtctx)
{
vedio_frame_mutex.unlock();
return false;
}
Vcodecctx =
Vavformtctx->streams[this->VedioStream]->codec;
Vswsctx = sws_getCachedContext(Vswsctx, aframe->width, aframe->height, (enum AVPixelFormat)aframe->format, outwidth, outheight,
AV_PIX_FMT_RGBA, // 输出像素格式
SWS_BILINEAR, // 输出像素算法
NULL, NULL, NULL);
if (!Vswsctx)
{
vedio_frame_mutex.unlock();
printf("sws_getCachedContext failed\n");
return false;
}
// uint8_t *dst_data[AV_NUM_DATA_POINTERS] = {0};
// dst_data[0] = (uint8_t *)buffer;
// int linesize[AV_NUM_DATA_POINTERS] = {0};
// linesize[0] = outwidth * 4;
int h = sws_scale(Vswsctx, aframe->data, aframe->linesize, 0, aframe->height, m_pixels, m_ptich);
// if (h > 0)
// {
// printf("decode of success: %d\n)", h);
QSharedPointer<YUV420Frame> frame = QSharedPointer<YUV420Frame>::create(m_pixels[0], aframe->width, aframe->height);
emit frameChanged(frame);
// }
vedio_frame_mutex.unlock();
return true;
}
无法触发槽函数执行