Commit 11f91a59 by 景炳强

Revert "support 4K input"

This reverts commit b5827fb1.
parent b5827fb1
...@@ -19,6 +19,8 @@ const QString MODE_ACK = "checked_ok"; ...@@ -19,6 +19,8 @@ const QString MODE_ACK = "checked_ok";
#define CROP720WIDTH 720 #define CROP720WIDTH 720
#define CROPHEIGHT 1080 #define CROPHEIGHT 1080
#define USE_1080P 1
class RoiMessage class RoiMessage
{ {
public: public:
...@@ -124,14 +126,6 @@ public: ...@@ -124,14 +126,6 @@ public:
return *this; return *this;
} }
RoiMessage(int X, int Y, int W, int H)
:x(X),
y(Y),
w(W),
h(H),
timecode(0) {}
bool IsValid() bool IsValid()
{ {
return x > 0 && y > 0 && w > 0 && h > 0; return x > 0 && y > 0 && w > 0 && h > 0;
...@@ -185,7 +179,6 @@ private: ...@@ -185,7 +179,6 @@ private:
void WorkCutImage720p(std::shared_ptr<Image>& pImage, RoiMessage& roi); void WorkCutImage720p(std::shared_ptr<Image>& pImage, RoiMessage& roi);
void cutRun(); void cutRun();
void cutRunFront(); void cutRunFront();
void cutRunFrontFixedRegion();
private: private:
//SampleQueue<Image> taskPrerollQueue; //SampleQueue<Image> taskPrerollQueue;
SampleQueue<std::shared_ptr<Image>> taskImageQueue; SampleQueue<std::shared_ptr<Image>> taskImageQueue;
......
...@@ -3,9 +3,6 @@ ...@@ -3,9 +3,6 @@
#include "DeckLinkAPI.h" #include "DeckLinkAPI.h"
#include <QDateTime.h> #include <QDateTime.h>
#define USE_4K 1
#define USE_1080P 1
long GetRowBytesFromPixelFormat(long width, BMDPixelFormat pixelFormat); long GetRowBytesFromPixelFormat(long width, BMDPixelFormat pixelFormat);
......
...@@ -144,12 +144,6 @@ bool DeckLinkOutputDevice::StartPlayback(BMDDisplayMode displayMode, bool enable ...@@ -144,12 +144,6 @@ bool DeckLinkOutputDevice::StartPlayback(BMDDisplayMode displayMode, bool enable
#else #else
outputDisplayMode = BMDDisplayMode::bmdModeHD720p50; outputDisplayMode = BMDDisplayMode::bmdModeHD720p50;
#endif #endif
#if USE_4K
outputDisplayMode = bmdModeHD1080i50;
#endif
// Pass through RP188 timecode and VANC from input frame. VITC timecode is forwarded with VANC // Pass through RP188 timecode and VANC from input frame. VITC timecode is forwarded with VANC
BMDVideoOutputFlags outputFlags = (BMDVideoOutputFlags)(bmdVideoOutputRP188 | bmdVideoOutputVANC); BMDVideoOutputFlags outputFlags = (BMDVideoOutputFlags)(bmdVideoOutputRP188 | bmdVideoOutputVANC);
ComPtr<IDeckLinkDisplayMode> deckLinkDisplayMode; ComPtr<IDeckLinkDisplayMode> deckLinkDisplayMode;
...@@ -536,8 +530,8 @@ void DeckLinkOutputDevice::checkEndOfPreroll() ...@@ -536,8 +530,8 @@ void DeckLinkOutputDevice::checkEndOfPreroll()
void DeckLinkOutputDevice::AddFrame(std::shared_ptr<Image> image) void DeckLinkOutputDevice::AddFrame(std::shared_ptr<Image> image)
{ {
START_SLOT_TIME_COUNTER START_SLOT_TIME_COUNTER
if (!image->IsValid()) if(!image->IsValid())
return; return;
if (outputVideoFrameQueue.Size() >= 4) if (outputVideoFrameQueue.Size() >= 4)
qDebug() << "DeckLinkOutputDevice::AddFrame video---qsize:" << "\t" << outputVideoFrameQueue.Size() << "\n"; qDebug() << "DeckLinkOutputDevice::AddFrame video---qsize:" << "\t" << outputVideoFrameQueue.Size() << "\n";
...@@ -546,7 +540,7 @@ void DeckLinkOutputDevice::AddFrame(std::shared_ptr<Image> image) ...@@ -546,7 +540,7 @@ void DeckLinkOutputDevice::AddFrame(std::shared_ptr<Image> image)
{ {
outputVideoFrameQueue.Reset(); outputVideoFrameQueue.Reset();
} }
if (image) outputVideoFrameQueue.Push(image); if(image) outputVideoFrameQueue.Push(image);
END_SLOT_TIME_COUNTER END_SLOT_TIME_COUNTER
} }
void DeckLinkOutputDevice::AddAudioFrame(std::shared_ptr<AudioPacket> audio_packet) void DeckLinkOutputDevice::AddAudioFrame(std::shared_ptr<AudioPacket> audio_packet)
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include "Utils/CustomEvents.h" #include "Utils/CustomEvents.h"
#include "Utils/Image.h" #include "Utils/Image.h"
#include "DeckLinkAPI.h" #include "DeckLinkAPI.h"
#include "Utils/Common.h"
int OutputDeleyTime = 5; int OutputDeleyTime = 5;
...@@ -247,15 +246,9 @@ void MomentaMedia::AddDevice(ComPtr<IDeckLink>& deckLink) ...@@ -247,15 +246,9 @@ void MomentaMedia::AddDevice(ComPtr<IDeckLink>& deckLink)
deviceIdStr = rx.cap(0); deviceIdStr = rx.cap(0);
int deviceId = deviceIdStr.toInt(); int deviceId = deviceIdStr.toInt();
#if USE_4K
if (deviceName.contains("DeckLink 8K Pro (1)") ||
deviceName.contains("DeckLink 8K Pro (2)"))
#else
if(deviceId < 5) if(deviceId < 5)
#endif
{ {
// Input Device // Input Device
bool active = IsDeviceActive(deckLink); bool active = IsDeviceActive(deckLink);
InputDevices[deckLink] = (active ? DeviceState::Available : DeviceState::Inactive); InputDevices[deckLink] = (active ? DeviceState::Available : DeviceState::Inactive);
......
...@@ -6,8 +6,6 @@ ...@@ -6,8 +6,6 @@
#include <cstdlib> #include <cstdlib>
#include <atomic> #include <atomic>
#include "NDI/NDIOutputThread.h" #include "NDI/NDIOutputThread.h"
#include "Utils/Common.h"
#include "libyuv.h"
extern qint64 StartTimeStamp; extern qint64 StartTimeStamp;
...@@ -96,12 +94,7 @@ void NDIOutputThread::run() ...@@ -96,12 +94,7 @@ void NDIOutputThread::run()
START_TIME_COUNTER START_TIME_COUNTER
if(frame->IsValid()) if(frame->IsValid())
{ {
#if USE_4K
libyuv::ARGBScale(frame->GetBytes(), 3840 << 2, 3840, 2160,
Frame.p_data, 1920 << 2, 1920, 1080, libyuv::FilterMode::kFilterNone);
#else
frame->Fill(Frame.p_data, Frame.xres * Frame.yres * 4); frame->Fill(Frame.p_data, Frame.xres * Frame.yres * 4);
#endif
//qDebug() << "wgt-----------------------------"<<"ndi(" << NDISenderName << ")timestamp : " << frame->getInputFrameCurTimeStamp() - StartTimeStamp << "\n"; //qDebug() << "wgt-----------------------------"<<"ndi(" << NDISenderName << ")timestamp : " << frame->getInputFrameCurTimeStamp() - StartTimeStamp << "\n";
//Frame.timestamp = frame->getInputFrameCurTimeStamp(); //Frame.timestamp = frame->getInputFrameCurTimeStamp();
Frame.timestamp = frame->getInputFrameSequence(); Frame.timestamp = frame->getInputFrameSequence();
......
#include "Threads/CaptureThread.h" #include "Threads/CaptureThread.h"
#include "Utils/Common.h"
static int64_t GetCurrTimeMS() static int64_t GetCurrTimeMS()
{ {
...@@ -62,13 +61,8 @@ void CaptureThread::AddFrame(ComPtr<IDeckLinkVideoInputFrame> videoFrame, const ...@@ -62,13 +61,8 @@ void CaptureThread::AddFrame(ComPtr<IDeckLinkVideoInputFrame> videoFrame, const
if (videoFrame->GetWidth() <=0 || videoFrame->GetHeight() <= 0) if (videoFrame->GetWidth() <=0 || videoFrame->GetHeight() <= 0)
return; return;
#if USE_4K
if (videoFrame->GetWidth() != 3840 || videoFrame->GetHeight() != 2160)
return;
#else
if (videoFrame->GetWidth() != 1920 || videoFrame->GetHeight() != 1080) if (videoFrame->GetWidth() != 1920 || videoFrame->GetHeight() != 1080)
return; return;
#endif
if (taskQueue.size() >= 4) if (taskQueue.size() >= 4)
qDebug() << "CaptureThread::AddFrame::qsize::" << idx << "\t" << taskQueue.size() << "\n"; qDebug() << "CaptureThread::AddFrame::qsize::" << idx << "\t" << taskQueue.size() << "\n";
......
#include "Threads/ProcessThread.h" #include "Threads/ProcessThread.h"
#include "opencv2/opencv.hpp" #include "opencv2/opencv.hpp"
#include "libyuv.h" #include "libyuv.h"
#include "Utils//Common.h"
#define CUTBUFFERMAXSIZE 125*2 #define CUTBUFFERMAXSIZE 125*2
...@@ -127,29 +126,6 @@ void ProcessThread::ReadDatagrams() ...@@ -127,29 +126,6 @@ void ProcessThread::ReadDatagrams()
END_SLOT_TIME_COUNTER END_SLOT_TIME_COUNTER
} }
void ProcessThread::cutRunFrontFixedRegion()
{
RoiMessage roiMsg(560, 0, 800, 1080);
while (true)
{
std::shared_ptr<Image> image = nullptr;
if (taskImageQueue.WaitFor()) {
if (taskImageQueue.Front(image))
{
if (!image)
{
taskImageQueue.Pop();
continue;
}
WorkCutImage(image, roiMsg);
taskImageQueue.Pop();
}
}
}
}
void ProcessThread::cutRunFront() void ProcessThread::cutRunFront()
{ {
bool continue_flag = false; bool continue_flag = false;
...@@ -482,7 +458,6 @@ void ProcessThread::run() ...@@ -482,7 +458,6 @@ void ProcessThread::run()
{ {
//cutRun(); //cutRun();
cutRunFront(); cutRunFront();
//cutRunFrontFixedRegion();
} }
void ProcessThread::WorkCutImage(std::shared_ptr<Image>& pImage, RoiMessage& roi) void ProcessThread::WorkCutImage(std::shared_ptr<Image>& pImage, RoiMessage& roi)
...@@ -525,31 +500,7 @@ void ProcessThread::WorkCutImage(std::shared_ptr<Image>& pImage, RoiMessage& roi ...@@ -525,31 +500,7 @@ void ProcessThread::WorkCutImage(std::shared_ptr<Image>& pImage, RoiMessage& roi
// qDebug() << "ProcessThread::run::qsize::" << idx << "\t" << taskImageQueue.Size() << "\n"; // qDebug() << "ProcessThread::run::qsize::" << idx << "\t" << taskImageQueue.Size() << "\n";
//qDebug() << "ROI- " << idx << " " << roi.X() << " " << roi.Y() << " " << roi.Width() << " " << roi.Height() << "\n"; //qDebug() << "ROI- " << idx << " " << roi.X() << " " << roi.Y() << " " << roi.Width() << " " << roi.Height() << "\n";
#if USE_4K #if USE_1080P
size_t size = roi.Width() * roi.Height() << 2 << 2;
uint8_t * buff1 = new uint8_t[size];
libyuv::ConvertToARGB(pImage->GetBytes(), (3840 * 2160 << 2), buff1, (roi.Height() << 2 << 1),
roi.X() << 1, roi.Y() << 1, 3840, 2160, roi.Width() << 1, roi.Height() << 1,
libyuv::kRotate90, libyuv::FOURCC_ARGB);
uint8_t * buff2 = new uint8_t[1440 * 1080 << 2];
libyuv::ARGBScale(buff1, (roi.Height() << 2 << 1), roi.Height() << 1, roi.Width() << 1,
buff2, 1440 << 2, 1440, 1080, libyuv::FilterMode::kFilterNone);
uint8_t * buff3 = new uint8_t[1920 * 1080 << 2];
memset(buff3, 0, (1920 * 1080 << 2));
libyuv::ARGBCopy(buff2, 1440 << 2, (buff3 + BlackBottomHeight * 4), 1920 << 2, 1440, 1080);
cv::Mat bgra = cv::Mat(1080, 1920, CV_8UC4, buff3);
pImage->SetMat(bgra);
delete[] buff1;
delete[] buff2;
delete[] buff3;
emit PushFrame(pImage);
#elif USE_1080P
//qDebug() << "wgt------------idx:" << idx << ",cut image of timestamp : " << pImage->getInputFrameCurTimeStamp() << ", cur image of x : " << roi.X() << "\n"; //qDebug() << "wgt------------idx:" << idx << ",cut image of timestamp : " << pImage->getInputFrameCurTimeStamp() << ", cur image of x : " << roi.X() << "\n";
size_t size = roi.Width() * roi.Height() << 2; size_t size = roi.Width() * roi.Height() << 2;
uint8_t* buff1 = new uint8_t[size]; uint8_t* buff1 = new uint8_t[size];
......
#include "Utils/Image.h" #include "Utils/Image.h"
#include "Utils/ComPtr.h" #include "Utils/ComPtr.h"
#include "opencv2/core.hpp" #include "opencv2/core.hpp"
#include "Utils/Common.h"
Image::Image() : mat() Image::Image() : mat()
{ {
...@@ -10,72 +9,40 @@ Image::Image() : mat() ...@@ -10,72 +9,40 @@ Image::Image() : mat()
Image::Image(IDeckLinkVideoInputFrame* videoFrame) Image::Image(IDeckLinkVideoInputFrame* videoFrame)
{ {
#if USE_4K
if (videoFrame->GetWidth() != 3840 || videoFrame->GetHeight() != 2160)
{
return;
}
#else
if(videoFrame->GetWidth() != 1920 || videoFrame->GetHeight() != 1080) if(videoFrame->GetWidth() != 1920 || videoFrame->GetHeight() != 1080)
{ {
return; return;
} }
#endif
inVideoFrame = MakeComPtr<DeckLinkInputVideoFrame>(videoFrame); inVideoFrame = MakeComPtr<DeckLinkInputVideoFrame>(videoFrame);
ConvertDeckLinkVideoFrame2Mat(inVideoFrame, mat); ConvertDeckLinkVideoFrame2Mat(inVideoFrame, mat);
} }
Image::Image(ComPtr<DeckLinkInputVideoFrame> videoFrame) Image::Image(ComPtr<DeckLinkInputVideoFrame> videoFrame)
{ {
#if USE_4K
if (videoFrame->GetWidth() != 3840 || videoFrame->GetHeight() != 2160)
{
return;
}
#else
if (videoFrame->GetWidth() != 1920 || videoFrame->GetHeight() != 1080) if (videoFrame->GetWidth() != 1920 || videoFrame->GetHeight() != 1080)
{ {
return; return;
} }
#endif
inVideoFrame = videoFrame; inVideoFrame = videoFrame;
ConvertDeckLinkVideoFrame2Mat(videoFrame, mat); ConvertDeckLinkVideoFrame2Mat(videoFrame, mat);
} }
Image::Image(ComPtr<IDeckLinkVideoInputFrame> videoFrame) Image::Image(ComPtr<IDeckLinkVideoInputFrame> videoFrame)
{ {
#if USE_4K
if (videoFrame->GetWidth() != 3840 || videoFrame->GetHeight() != 2160)
{
return;
}
#else
if (videoFrame->GetWidth() != 1920 || videoFrame->GetHeight() != 1080) if (videoFrame->GetWidth() != 1920 || videoFrame->GetHeight() != 1080)
{ {
return; return;
} }
#endif
inVideoFrame = MakeComPtr<DeckLinkInputVideoFrame>(videoFrame.Get()); inVideoFrame = MakeComPtr<DeckLinkInputVideoFrame>(videoFrame.Get());
ConvertDeckLinkVideoFrame2Mat(inVideoFrame, mat); ConvertDeckLinkVideoFrame2Mat(inVideoFrame, mat);
} }
Image::Image(ComPtr<IDeckLinkVideoInputFrame> videoFrame, const qint64& curtimestamp, const qint64& sequence):inputFrameCurTimeStamp(curtimestamp),sequenceNum(sequence) Image::Image(ComPtr<IDeckLinkVideoInputFrame> videoFrame, const qint64& curtimestamp, const qint64& sequence):inputFrameCurTimeStamp(curtimestamp),sequenceNum(sequence)
{ {
#if USE_4K
if (videoFrame->GetWidth() != 3840 || videoFrame->GetHeight() != 2160)
{
return;
}
#else
if (videoFrame->GetWidth() != 1920 || videoFrame->GetHeight() != 1080) if (videoFrame->GetWidth() != 1920 || videoFrame->GetHeight() != 1080)
{ {
return; return;
} }
#endif
inVideoFrame = MakeComPtr<DeckLinkInputVideoFrame>(videoFrame.Get()); inVideoFrame = MakeComPtr<DeckLinkInputVideoFrame>(videoFrame.Get());
ConvertDeckLinkVideoFrame2Mat(inVideoFrame, mat); ConvertDeckLinkVideoFrame2Mat(inVideoFrame, mat);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment