1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

fix(video): fix invalid VideoSource ID allocation

This commit fixes the an invalid ID allocation by VideoSource, before
this commit all VideoSources receives the same ID causing VideoFrame to
believe all frames belong to the same video source.

Additionally, this commit addresses issues with deprecated pixel
formats and silences libswscale warnings.
This commit is contained in:
initramfs 2016-08-04 19:51:15 +08:00
parent 607b8d5a20
commit 707f7af29a
No known key found for this signature in database
GPG Key ID: 78B8BDF87E9EF0AF
2 changed files with 41 additions and 1 deletions

View File

@ -97,6 +97,46 @@ VideoFrame::VideoFrame(IDType sourceID, AVFrame* sourceFrame, QRect dimensions,
sourceFrameKey(getFrameKey(dimensions.size(), pixFmt, sourceFrame->linesize[0])),
freeSourceFrame(freeSourceFrame)
{
// We override the pixel format in the case a deprecated one is used
switch(pixFmt)
{
case AV_PIX_FMT_YUVJ420P:
{
pixFmt = AV_PIX_FMT_YUV420P;
sourceFrame->color_range = AVCOL_RANGE_MPEG;
break;
}
case AV_PIX_FMT_YUVJ411P:
{
pixFmt = AV_PIX_FMT_YUV411P;
sourceFrame->color_range = AVCOL_RANGE_MPEG;
break;
}
case AV_PIX_FMT_YUVJ422P:
{
pixFmt = AV_PIX_FMT_YUV422P;
sourceFrame->color_range = AVCOL_RANGE_MPEG;
break;
}
case AV_PIX_FMT_YUVJ444P:
{
pixFmt = AV_PIX_FMT_YUV444P;
sourceFrame->color_range = AVCOL_RANGE_MPEG;
break;
}
case AV_PIX_FMT_YUVJ440P:
{
pixFmt = AV_PIX_FMT_YUV440P;
sourceFrame->color_range = AVCOL_RANGE_MPEG;
break;
}
}
frameBuffer[sourceFrameKey] = sourceFrame;
}

View File

@ -38,7 +38,7 @@ public:
using AtomicIDType = std::atomic_uint_fast64_t;
public:
VideoSource() : id(sourceIDs.fetch_add(std::memory_order_relaxed)){}
VideoSource() : id(sourceIDs++){}
virtual ~VideoSource() = default;
/**