Skip to content
This repository has been archived by the owner on Feb 12, 2023. It is now read-only.

Commit

Permalink
fix(video): fix invalid VideoSource ID allocation
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
initramfs committed Aug 4, 2016
1 parent 607b8d5 commit 707f7af
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
40 changes: 40 additions & 0 deletions src/video/videoframe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/video/videosource.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class VideoSource : public QObject
using AtomicIDType = std::atomic_uint_fast64_t;

public:
VideoSource() : id(sourceIDs.fetch_add(std::memory_order_relaxed)){}
VideoSource() : id(sourceIDs++){}

virtual ~VideoSource() = default;
/**
Expand Down

0 comments on commit 707f7af

Please sign in to comment.