Skip to content

Commit

Permalink
Merge pull request #2131 from JeromeMartinez/EXR_TimeCode
Browse files Browse the repository at this point in the history
EXR: support of time code and frame rate
  • Loading branch information
JeromeMartinez authored Oct 18, 2024
2 parents d77639f + 42b93d2 commit 5373188
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
52 changes: 52 additions & 0 deletions Source/MediaInfo/Image/File_Exr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,27 @@
//---------------------------------------------------------------------------
#include "MediaInfo/Image/File_Exr.h"
#include "MediaInfo/MediaInfo_Config_MediaInfo.h"
#include "MediaInfo/TimeCode.h"
//---------------------------------------------------------------------------

namespace MediaInfoLib
{


//***************************************************************************
// Utils
//***************************************************************************

//---------------------------------------------------------------------------
static unsigned BCD_to_Decimal(unsigned Value)
{
int Tens=Value>>4;
int Units=Value&0xF;
if (Tens>=10 || Units>=10)
return (unsigned)-1;
return Tens*10+Units;
}

//***************************************************************************
// Infos
//***************************************************************************
Expand Down Expand Up @@ -233,8 +249,12 @@ void File_Exr::Data_Parse()
dataWindow();
else if (name=="displayWindow" && type=="box2i" && Element_Size==16)
displayWindow();
else if (name=="framesPerSecond" && type=="rational" && Element_Size==8)
framesPerSecond();
else if (name=="pixelAspectRatio" && type=="float" && Element_Size==4)
pixelAspectRatio();
else if (name=="timeCode" && type=="timecode" && Element_Size==8)
timeCode();
else
Skip_XX(Element_Size, "value");
}
Expand Down Expand Up @@ -423,6 +443,18 @@ void File_Exr::displayWindow ()
}
}

//---------------------------------------------------------------------------
void File_Exr::framesPerSecond()
{
//Parsing
int32u n, d;
Get_L4 (n, "n");
Get_L4 (d, "d");

//Filling
Fill(StreamKind_Last, 0, "FrameRate", ((float)n)/d);
}

//---------------------------------------------------------------------------
void File_Exr::pixelAspectRatio ()
{
Expand All @@ -435,6 +467,26 @@ void File_Exr::pixelAspectRatio ()
Fill(StreamKind_Last, 0, "PixelAspectRatio", value?value:1, 3);
}

//---------------------------------------------------------------------------
void File_Exr::timeCode ()
{
//Parsing
int32u timeAndFlags;
Get_L4 (timeAndFlags, "timeAndFlags");
Skip_L4( "userData");

//Filling
//21HHhhhh0MMMmmmmfSSSsssscdFFffff
auto HH = BCD_to_Decimal((timeAndFlags >> 24) & 0x3F);
auto MM = BCD_to_Decimal((timeAndFlags >> 16) & 0x7F);
auto SS = BCD_to_Decimal((timeAndFlags >> 8) & 0x7F);
auto FF = BCD_to_Decimal((timeAndFlags ) & 0x3F);
auto Field = ((timeAndFlags >> 15 ) & 0x01);
auto Drop = ((timeAndFlags >> 6 ) & 0x01);
TimeCode TC(HH, MM, SS, FF, 99, TimeCode::flags().DropFrame(Drop).Field(Field));
Fill(StreamKind_Last, 0, "TimeCode", TC.ToString());
}

} //NameSpace

#endif //MEDIAINFO_EXR_YES
2 changes: 2 additions & 0 deletions Source/MediaInfo/Image/File_Exr.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ private :
void compression();
void dataWindow();
void displayWindow();
void framesPerSecond();
void pixelAspectRatio();
void timeCode();

//Temp
std::string name;
Expand Down

0 comments on commit 5373188

Please sign in to comment.