Skip to content

Commit

Permalink
Fix mp4 edts trace info
Browse files Browse the repository at this point in the history
1. Media time is signed value
2. Media time is in unit of mdhd time scale. Since mdhd comes after
edts, we don't know mdhd_TimeScale yet when handle edts. Give a hint
to user on which time scale to use.

Fix #1441
  • Loading branch information
quink-black committed Oct 19, 2021
1 parent 16ef046 commit b998ecf
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Source/MediaInfo/File__Analyze.h
Original file line number Diff line number Diff line change
Expand Up @@ -574,10 +574,12 @@ public :
void Get_B2 (int16u &Info, const char* Name);
void Get_B3 (int32u &Info, const char* Name);
void Get_B4 (int32u &Info, const char* Name);
void Get_B4S (int32s &Info, const char* Name);
void Get_B5 (int64u &Info, const char* Name);
void Get_B6 (int64u &Info, const char* Name);
void Get_B7 (int64u &Info, const char* Name);
void Get_B8 (int64u &Info, const char* Name);
void Get_B8S (int64s &Info, const char* Name);
void Get_B16 (int128u &Info, const char* Name);
void Get_BF2 (float32 &Info, const char* Name);
void Get_BF4 (float32 &Info, const char* Name);
Expand Down
19 changes: 19 additions & 0 deletions Source/MediaInfo/File__Analyze_Buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,16 @@ void File__Analyze::Get_B4(int32u &Info, const char* Name)
Element_Offset+=4;
}

//---------------------------------------------------------------------------
void File__Analyze::Get_B4S(int32s &Info, const char* Name)
{
INTEGRITY_SIZE_ATLEAST_INT(4);
Info=BigEndian2int32s(Buffer+Buffer_Offset+(size_t)Element_Offset);
if (Trace_Activated)
Param(Name, Info);
Element_Offset+=4;
}

//---------------------------------------------------------------------------
void File__Analyze::Get_B5(int64u &Info, const char* Name)
{
Expand Down Expand Up @@ -223,6 +233,15 @@ void File__Analyze::Get_B8(int64u &Info, const char* Name)
Element_Offset+=8;
}

//---------------------------------------------------------------------------
void File__Analyze::Get_B8S(int64s &Info, const char* Name)
{
INTEGRITY_SIZE_ATLEAST_INT(8);
Info=BigEndian2int64s(Buffer+Buffer_Offset+(size_t)Element_Offset);
if (Trace_Activated) Param(Name, Info);
Element_Offset+=8;
}

//---------------------------------------------------------------------------
void File__Analyze::Get_B16(int128u &Info, const char* Name)
{
Expand Down
2 changes: 1 addition & 1 deletion Source/MediaInfo/Multiple/File_Mpeg4.h
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ private :
struct edts_struct
{
int64u Duration;
int64u Delay;
int64s Delay;
int32u Rate;
};
std::vector<edts_struct> edts;
Expand Down
15 changes: 14 additions & 1 deletion Source/MediaInfo/Multiple/File_Mpeg4_Elements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1469,6 +1469,19 @@ void File_Mpeg4::Data_Parse()
Get_B8(_INFO, _NAME); \
} \

// Bigendian signed
#define Get_BS_DEPENDOFVERSION(_INFO, _NAME) \
{ \
if (Version==0) \
{ \
int32s Info; \
Get_B4S(Info, _NAME); \
_INFO=Info; \
} \
else \
Get_B8S(_INFO, _NAME); \
} \

#define Get_DATE1904_DEPENDOFVERSION(_INFO, _NAME) \
{ \
if (Version==0) \
Expand Down Expand Up @@ -3856,7 +3869,7 @@ void File_Mpeg4::moov_trak_edts_elst()
stream::edts_struct edts;
Element_Begin1("Entry");
Get_B_DEPENDOFVERSION(edts.Duration, "Track duration"); Param_Info2C(moov_mvhd_TimeScale, (int64u)edts.Duration*1000/moov_mvhd_TimeScale, " ms");
Get_B_DEPENDOFVERSION(edts.Delay, "Media time"); Param_Info2C(moov_mvhd_TimeScale && (edts.Delay!=(int32u)-1), (int64u)edts.Delay*1000/moov_mvhd_TimeScale, " ms");
Get_BS_DEPENDOFVERSION(edts.Delay, "Media time"); Param_Info2C(edts.Delay > 0, edts.Delay, " / media header time scale");
Get_B4 (edts.Rate, "Media rate"); Param_Info1(((float)edts.Rate)/0x10000);
Element_End0();

Expand Down

0 comments on commit b998ecf

Please sign in to comment.