Skip to content

Commit

Permalink
Simulator has information about the video frame format
Browse files Browse the repository at this point in the history
  • Loading branch information
JeromeMartinez authored and g-maxime committed Jun 6, 2024
1 parent 89b10f0 commit 0e06994
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions Source/Common/SimulatorWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ struct ctl
// MKV info
size_t Track_Pos = 0;
decklink_frame Decklink_Sim;
struct track {
string CodecID;
int32u FourCC = 0;
};
vector<track> Tracks;

// MKV parsing
uint64_t Get_EB();
Expand Down Expand Up @@ -97,9 +102,12 @@ struct ctl
MATROSKA_ELEMENT(Segment_Cluster_Timestamp);
MATROSKA_ELEMENT(Segment_Tracks);
MATROSKA_ELEMENT(Segment_Tracks_TrackEntry);
MATROSKA_ELEMENT(Segment_Tracks_TrackEntry_CodecID);
MATROSKA_ELEMENT(Segment_Tracks_TrackEntry_Video);
MATROSKA_ELEMENT(Segment_Tracks_TrackEntry_Video_PixelWidth);
MATROSKA_ELEMENT(Segment_Tracks_TrackEntry_Video_PixelHeight);
MATROSKA_ELEMENT(Segment_Tracks_TrackEntry_Video_ColourSpace);
MATROSKA_ELEMENT(Segment_Tracks_TrackEntry_CodecPrivate);
MATROSKA_ELEMENT(Void);
};

Expand Down Expand Up @@ -148,12 +156,15 @@ ELEMENT_CASE( 2E, Segment_Tracks_TrackEntry)
ELEMENT_END()

ELEMENT_BEGIN(Segment_Tracks_TrackEntry)
ELEMENT_VOID( 6, Segment_Tracks_TrackEntry_CodecID)
ELEMENT_CASE( 60, Segment_Tracks_TrackEntry_Video)
ELEMENT_VOID( 23A2, Segment_Tracks_TrackEntry_CodecPrivate)
ELEMENT_END()

ELEMENT_BEGIN(Segment_Tracks_TrackEntry_Video)
ELEMENT_VOID( 30, Segment_Tracks_TrackEntry_Video_PixelWidth)
ELEMENT_VOID( 3A, Segment_Tracks_TrackEntry_Video_PixelHeight)
ELEMENT_VOID( 0EB524, Segment_Tracks_TrackEntry_Video_ColourSpace)
ELEMENT_END()


Expand Down Expand Up @@ -332,6 +343,8 @@ void ctl::Segment_Cluster_Timestamp()
//---------------------------------------------------------------------------
void ctl::Segment_Tracks()
{
Tracks.push_back({});

IsList = true;
}

Expand All @@ -341,6 +354,12 @@ void ctl::Segment_Tracks_TrackEntry()
IsList = true;
}

//---------------------------------------------------------------------------
void ctl::Segment_Tracks_TrackEntry_CodecID()
{
Tracks.back().CodecID.assign((const char*)Buffer + Buffer_Offset, Levels[Level].Offset_End - Buffer_Offset);
}

//---------------------------------------------------------------------------
void ctl::Segment_Tracks_TrackEntry_Video()
{
Expand Down Expand Up @@ -371,6 +390,20 @@ void ctl::Segment_Tracks_TrackEntry_Video_PixelHeight()
Decklink_Sim.Height = Data;
}

//---------------------------------------------------------------------------
void ctl::Segment_Tracks_TrackEntry_Video_ColourSpace()
{
if (Levels[Level].Offset_End - Buffer_Offset == 4)
Tracks.back().FourCC = (((uint32_t)Buffer[Buffer_Offset]) << 24) | ((uint32_t)Buffer[Buffer_Offset + 1] << 16) | (((uint32_t)Buffer[Buffer_Offset + 2]) << 8) | ((uint32_t)Buffer[Buffer_Offset + 3]);
}

//---------------------------------------------------------------------------
void ctl::Segment_Tracks_TrackEntry_CodecPrivate()
{
if (Levels[Level].Offset_End - Buffer_Offset == 40 && Buffer[Buffer_Offset] == 40 && Buffer[Buffer_Offset + 1] == 0 && Buffer[Buffer_Offset + 2] == 0 && Buffer[Buffer_Offset + 3] == 0 && Tracks.back().CodecID == "V_MS/VFW/FOURCC")
Tracks.back().FourCC = (((uint32_t)Buffer[Buffer_Offset + 16]) << 24) | ((uint32_t)Buffer[Buffer_Offset + 17] << 16) | (((uint32_t)Buffer[Buffer_Offset + 18]) << 8) | ((uint32_t)Buffer[Buffer_Offset + 19]);
}

//---------------------------------------------------------------------------
void ctl::Void()
{
Expand Down

0 comments on commit 0e06994

Please sign in to comment.