Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mkvalidator: Fix parsing of Video element and checking of cues #39

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libmatroska2/matroska/matroska.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ EBML_DLL err_t MATROSKA_BlockGetFrame(const matroska_block *Block, size_t FrameN
EBML_DLL err_t MATROSKA_BlockAppendFrame(matroska_block *Block, const matroska_frame *Frame, timecode_t ClusterTimecode);


EBML_DLL ebml_element *MATROSKA_GetNextBlockForTimecode(matroska_cluster *Cluster, const ebml_element *Current, timecode_t Timecode, int16_t Track, int Outer);
EBML_DLL matroska_block *MATROSKA_GetBlockForTimecode(matroska_cluster *Cluster, timecode_t Timecode, int16_t Track);
EBML_DLL void MATROSKA_LinkClusterBlocks(matroska_cluster *Cluster, ebml_master *RSegmentInfo, ebml_master *Tracks, bool_t KeepUnmatched);

Expand Down
29 changes: 17 additions & 12 deletions libmatroska2/matroskamain.c
Original file line number Diff line number Diff line change
Expand Up @@ -739,15 +739,15 @@ timecode_t MATROSKA_CueTimecode(const matroska_cuepoint *Cue)

filepos_t MATROSKA_CuePosInSegment(const matroska_cuepoint *Cue)
{
ebml_element *TimeCode;
ebml_element *ClusterPosition;
assert(EBML_ElementIsType((ebml_element*)Cue, &MATROSKA_ContextCuePoint));
TimeCode = EBML_MasterFindChild((ebml_master*)Cue,&MATROSKA_ContextCueTrackPositions);
if (!TimeCode)
return INVALID_TIMECODE_T;
TimeCode = EBML_MasterFindChild((ebml_master*)TimeCode,&MATROSKA_ContextCueClusterPosition);
if (!TimeCode)
return INVALID_TIMECODE_T;
return EBML_IntegerValue((ebml_integer*)TimeCode);
ClusterPosition = EBML_MasterFindChild((ebml_master*)Cue,&MATROSKA_ContextCueTrackPositions);
if (!ClusterPosition)
return INVALID_FILEPOS_T;
ClusterPosition = EBML_MasterFindChild((ebml_master*)ClusterPosition,&MATROSKA_ContextCueClusterPosition);
if (!ClusterPosition)
return INVALID_FILEPOS_T;
return EBML_IntegerValue((ebml_integer*)ClusterPosition);
}

err_t MATROSKA_CuePointUpdate(matroska_cuepoint *Cue, ebml_element *Segment)
Expand Down Expand Up @@ -789,10 +789,10 @@ err_t MATROSKA_CuePointUpdate(matroska_cuepoint *Cue, ebml_element *Segment)
return ERR_NONE;
}

matroska_block *MATROSKA_GetBlockForTimecode(matroska_cluster *Cluster, timecode_t Timecode, int16_t Track)
ebml_element *MATROSKA_GetNextBlockForTimecode(matroska_cluster *Cluster, const ebml_element *Current, timecode_t Timecode, int16_t Track, int Outer)
{
ebml_element *Block, *GBlock;
for (Block = EBML_MasterChildren(Cluster);Block;Block=EBML_MasterNext(Block))
for (Block = Current ? EBML_MasterNext(Current) : EBML_MasterChildren(Cluster); Block; Block = EBML_MasterNext(Block))
{
if (EBML_ElementIsType(Block, &MATROSKA_ContextBlockGroup))
{
Expand All @@ -803,7 +803,7 @@ matroska_block *MATROSKA_GetBlockForTimecode(matroska_cluster *Cluster, timecode
if (MATROSKA_BlockTrackNum((matroska_block*)GBlock) == Track &&
MATROSKA_BlockTimecode((matroska_block*)GBlock) == Timecode)
{
return (matroska_block*)GBlock;
return Outer ? Block : GBlock;
}
}
}
Expand All @@ -813,13 +813,18 @@ matroska_block *MATROSKA_GetBlockForTimecode(matroska_cluster *Cluster, timecode
if (MATROSKA_BlockTrackNum((matroska_block*)Block) == Track &&
MATROSKA_BlockTimecode((matroska_block*)Block) == Timecode)
{
return (matroska_block*)Block;
return Block;
}
}
}
return NULL;
}

matroska_block *MATROSKA_GetBlockForTimecode(matroska_cluster *Cluster, timecode_t Timecode, int16_t Track)
{
return (matroska_block*)MATROSKA_GetNextBlockForTimecode(Cluster, NULL, Timecode, Track, 0);
}

void MATROSKA_LinkClusterBlocks(matroska_cluster *Cluster, ebml_master *RSegmentInfo, ebml_master *Tracks, bool_t KeepUnmatched)
{
ebml_element *Block, *GBlock,*NextBlock;
Expand Down
Loading