Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
MomentaMedia
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
景炳强
MomentaMedia
Commits
b5827fb1
Commit
b5827fb1
authored
Dec 03, 2022
by
景炳强
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support 4K input
parent
02accdae
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
123 additions
and
5 deletions
+123
-5
MomentaMedia/include/Threads/ProcessThread.h
+9
-2
MomentaMedia/include/Utils/Common.h
+3
-0
MomentaMedia/src/BlackMagicDesign/DeckLinkOutputDevice.cpp
+8
-2
MomentaMedia/src/MomentaMedia.cpp
+7
-0
MomentaMedia/src/NDI/NDIOutputThread.cpp
+7
-0
MomentaMedia/src/Threads/CaptureThread.cpp
+6
-0
MomentaMedia/src/Threads/ProcessThread.cpp
+50
-1
MomentaMedia/src/Utils/Image.cpp
+33
-0
No files found.
MomentaMedia/include/Threads/ProcessThread.h
View file @
b5827fb1
...
...
@@ -19,8 +19,6 @@ const QString MODE_ACK = "checked_ok";
#define CROP720WIDTH 720
#define CROPHEIGHT 1080
#define USE_1080P 1
class
RoiMessage
{
public
:
...
...
@@ -126,6 +124,14 @@ public:
return
*
this
;
}
RoiMessage
(
int
X
,
int
Y
,
int
W
,
int
H
)
:
x
(
X
),
y
(
Y
),
w
(
W
),
h
(
H
),
timecode
(
0
)
{}
bool
IsValid
()
{
return
x
>
0
&&
y
>
0
&&
w
>
0
&&
h
>
0
;
...
...
@@ -179,6 +185,7 @@ private:
void
WorkCutImage720p
(
std
::
shared_ptr
<
Image
>&
pImage
,
RoiMessage
&
roi
);
void
cutRun
();
void
cutRunFront
();
void
cutRunFrontFixedRegion
();
private
:
//SampleQueue<Image> taskPrerollQueue;
SampleQueue
<
std
::
shared_ptr
<
Image
>>
taskImageQueue
;
...
...
MomentaMedia/include/Utils/Common.h
View file @
b5827fb1
...
...
@@ -3,6 +3,9 @@
#include "DeckLinkAPI.h"
#include <QDateTime.h>
#define USE_4K 1
#define USE_1080P 1
long
GetRowBytesFromPixelFormat
(
long
width
,
BMDPixelFormat
pixelFormat
);
...
...
MomentaMedia/src/BlackMagicDesign/DeckLinkOutputDevice.cpp
View file @
b5827fb1
...
...
@@ -144,6 +144,12 @@ bool DeckLinkOutputDevice::StartPlayback(BMDDisplayMode displayMode, bool enable
#else
outputDisplayMode
=
BMDDisplayMode
::
bmdModeHD720p50
;
#endif
#if USE_4K
outputDisplayMode
=
bmdModeHD1080i50
;
#endif
// Pass through RP188 timecode and VANC from input frame. VITC timecode is forwarded with VANC
BMDVideoOutputFlags
outputFlags
=
(
BMDVideoOutputFlags
)(
bmdVideoOutputRP188
|
bmdVideoOutputVANC
);
ComPtr
<
IDeckLinkDisplayMode
>
deckLinkDisplayMode
;
...
...
@@ -530,7 +536,7 @@ void DeckLinkOutputDevice::checkEndOfPreroll()
void
DeckLinkOutputDevice
::
AddFrame
(
std
::
shared_ptr
<
Image
>
image
)
{
START_SLOT_TIME_COUNTER
if
(
!
image
->
IsValid
())
if
(
!
image
->
IsValid
())
return
;
if
(
outputVideoFrameQueue
.
Size
()
>=
4
)
...
...
@@ -540,7 +546,7 @@ void DeckLinkOutputDevice::AddFrame(std::shared_ptr<Image> image)
{
outputVideoFrameQueue
.
Reset
();
}
if
(
image
)
outputVideoFrameQueue
.
Push
(
image
);
if
(
image
)
outputVideoFrameQueue
.
Push
(
image
);
END_SLOT_TIME_COUNTER
}
void
DeckLinkOutputDevice
::
AddAudioFrame
(
std
::
shared_ptr
<
AudioPacket
>
audio_packet
)
...
...
MomentaMedia/src/MomentaMedia.cpp
View file @
b5827fb1
...
...
@@ -10,6 +10,7 @@
#include "Utils/CustomEvents.h"
#include "Utils/Image.h"
#include "DeckLinkAPI.h"
#include "Utils/Common.h"
int
OutputDeleyTime
=
5
;
...
...
@@ -246,9 +247,15 @@ void MomentaMedia::AddDevice(ComPtr<IDeckLink>& deckLink)
deviceIdStr
=
rx
.
cap
(
0
);
int
deviceId
=
deviceIdStr
.
toInt
();
#if USE_4K
if
(
deviceName
.
contains
(
"DeckLink 8K Pro (1)"
)
||
deviceName
.
contains
(
"DeckLink 8K Pro (2)"
))
#else
if
(
deviceId
<
5
)
#endif
{
// Input Device
bool
active
=
IsDeviceActive
(
deckLink
);
InputDevices
[
deckLink
]
=
(
active
?
DeviceState
::
Available
:
DeviceState
::
Inactive
);
...
...
MomentaMedia/src/NDI/NDIOutputThread.cpp
View file @
b5827fb1
...
...
@@ -6,6 +6,8 @@
#include <cstdlib>
#include <atomic>
#include "NDI/NDIOutputThread.h"
#include "Utils/Common.h"
#include "libyuv.h"
extern
qint64
StartTimeStamp
;
...
...
@@ -94,7 +96,12 @@ void NDIOutputThread::run()
START_TIME_COUNTER
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
);
#endif
//qDebug() << "wgt-----------------------------"<<"ndi(" << NDISenderName << ")timestamp : " << frame->getInputFrameCurTimeStamp() - StartTimeStamp << "\n";
//Frame.timestamp = frame->getInputFrameCurTimeStamp();
Frame
.
timestamp
=
frame
->
getInputFrameSequence
();
...
...
MomentaMedia/src/Threads/CaptureThread.cpp
View file @
b5827fb1
#include "Threads/CaptureThread.h"
#include "Utils/Common.h"
static
int64_t
GetCurrTimeMS
()
{
...
...
@@ -61,8 +62,13 @@ void CaptureThread::AddFrame(ComPtr<IDeckLinkVideoInputFrame> videoFrame, const
if
(
videoFrame
->
GetWidth
()
<=
0
||
videoFrame
->
GetHeight
()
<=
0
)
return
;
#if USE_4K
if
(
videoFrame
->
GetWidth
()
!=
3840
||
videoFrame
->
GetHeight
()
!=
2160
)
return
;
#else
if
(
videoFrame
->
GetWidth
()
!=
1920
||
videoFrame
->
GetHeight
()
!=
1080
)
return
;
#endif
if
(
taskQueue
.
size
()
>=
4
)
qDebug
()
<<
"CaptureThread::AddFrame::qsize::"
<<
idx
<<
"
\t
"
<<
taskQueue
.
size
()
<<
"
\n
"
;
...
...
MomentaMedia/src/Threads/ProcessThread.cpp
View file @
b5827fb1
#include "Threads/ProcessThread.h"
#include "opencv2/opencv.hpp"
#include "libyuv.h"
#include "Utils//Common.h"
#define CUTBUFFERMAXSIZE 125*2
...
...
@@ -126,6 +127,29 @@ void ProcessThread::ReadDatagrams()
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
()
{
bool
continue_flag
=
false
;
...
...
@@ -458,6 +482,7 @@ void ProcessThread::run()
{
//cutRun();
cutRunFront
();
//cutRunFrontFixedRegion();
}
void
ProcessThread
::
WorkCutImage
(
std
::
shared_ptr
<
Image
>&
pImage
,
RoiMessage
&
roi
)
...
...
@@ -500,7 +525,31 @@ void ProcessThread::WorkCutImage(std::shared_ptr<Image>& pImage, RoiMessage& roi
// qDebug() << "ProcessThread::run::qsize::" << idx << "\t" << taskImageQueue.Size() << "\n";
//qDebug() << "ROI- " << idx << " " << roi.X() << " " << roi.Y() << " " << roi.Width() << " " << roi.Height() << "\n";
#if USE_1080P
#if USE_4K
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";
size_t
size
=
roi
.
Width
()
*
roi
.
Height
()
<<
2
;
uint8_t
*
buff1
=
new
uint8_t
[
size
];
...
...
MomentaMedia/src/Utils/Image.cpp
View file @
b5827fb1
#include "Utils/Image.h"
#include "Utils/ComPtr.h"
#include "opencv2/core.hpp"
#include "Utils/Common.h"
Image
::
Image
()
:
mat
()
{
...
...
@@ -9,40 +10,72 @@ Image::Image() : mat()
Image
::
Image
(
IDeckLinkVideoInputFrame
*
videoFrame
)
{
#if USE_4K
if
(
videoFrame
->
GetWidth
()
!=
3840
||
videoFrame
->
GetHeight
()
!=
2160
)
{
return
;
}
#else
if
(
videoFrame
->
GetWidth
()
!=
1920
||
videoFrame
->
GetHeight
()
!=
1080
)
{
return
;
}
#endif
inVideoFrame
=
MakeComPtr
<
DeckLinkInputVideoFrame
>
(
videoFrame
);
ConvertDeckLinkVideoFrame2Mat
(
inVideoFrame
,
mat
);
}
Image
::
Image
(
ComPtr
<
DeckLinkInputVideoFrame
>
videoFrame
)
{
#if USE_4K
if
(
videoFrame
->
GetWidth
()
!=
3840
||
videoFrame
->
GetHeight
()
!=
2160
)
{
return
;
}
#else
if
(
videoFrame
->
GetWidth
()
!=
1920
||
videoFrame
->
GetHeight
()
!=
1080
)
{
return
;
}
#endif
inVideoFrame
=
videoFrame
;
ConvertDeckLinkVideoFrame2Mat
(
videoFrame
,
mat
);
}
Image
::
Image
(
ComPtr
<
IDeckLinkVideoInputFrame
>
videoFrame
)
{
#if USE_4K
if
(
videoFrame
->
GetWidth
()
!=
3840
||
videoFrame
->
GetHeight
()
!=
2160
)
{
return
;
}
#else
if
(
videoFrame
->
GetWidth
()
!=
1920
||
videoFrame
->
GetHeight
()
!=
1080
)
{
return
;
}
#endif
inVideoFrame
=
MakeComPtr
<
DeckLinkInputVideoFrame
>
(
videoFrame
.
Get
());
ConvertDeckLinkVideoFrame2Mat
(
inVideoFrame
,
mat
);
}
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
)
{
return
;
}
#endif
inVideoFrame
=
MakeComPtr
<
DeckLinkInputVideoFrame
>
(
videoFrame
.
Get
());
ConvertDeckLinkVideoFrame2Mat
(
inVideoFrame
,
mat
);
}
...
...
景炳强
@jingbingqiang
mentioned in commit
11f91a59
Dec 05, 2022
mentioned in commit
11f91a59
mentioned in commit 11f91a59507fd1e105c0ad46877748be8d161a3e
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment