Changeset 397

Show
Ignore:
Timestamp:
04/01/07 14:00:38 (2 years ago)
Author:
dconrad
Message:

SimpleBlock? support

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/MatroskaImport.h

    r393 r397  
    8787        // adds the all the frames in the block group to the sample table if it exists,  
    8888        // the media otherwise. If this track type is subtitle, also inserts it into the track. 
    89         void AddBlock(KaxBlockGroup &blockGroup); 
     89        void AddBlock(KaxInternalBlock &block, uint32 duration, short flags); 
    9090         
    9191        // this adds all the samples added through AddBlock() to the track that aren't already 
     
    115115        // parses the first frame of a supported data format to determine codec parameters, 
    116116        // which can be more correct than the codec headers. 
    117         void ParseFirstBlock(KaxBlock &block); 
     117        void ParseFirstBlock(KaxInternalBlock &block); 
    118118         
    119119        // Since the duration in Matroska files is generally rather unreliable, rely only on 
  • trunk/MatroskaImportPrivate.cpp

    r393 r397  
    703703        cluster.InitTimecode(uint64(clusterTime), timecodeScale); 
    704704         
    705         KaxBlockGroup *blockGroup = FindChild<KaxBlockGroup>(cluster); 
    706         while (blockGroup && blockGroup->GetSize() > 0) { 
    707                 KaxBlock & block = GetChild<KaxBlock>(*blockGroup); 
    708                 block.SetParent(cluster); 
    709                  
    710                 for (int i = 0; i < tracks.size(); i++) { 
    711                         if (tracks[i].number == block.TrackNum()) { 
    712                                 tracks[i].AddBlock(*blockGroup); 
    713                                 break; 
     705        for (int i = 0; i < cluster.ListSize(); i++) { 
     706                const EbmlId & elementID = EbmlId(*cluster[i]); 
     707                KaxInternalBlock *block = NULL; 
     708                uint32_t duration = 0; 
     709                short flags = 0; 
     710                 
     711                if (elementID == KaxBlockGroup::ClassInfos.GlobalId) { 
     712                        KaxBlockGroup & blockGroup = *static_cast<KaxBlockGroup *>(cluster[i]); 
     713                        block = &GetChild<KaxBlock>(blockGroup); 
     714                        duration = uint32(GetChild<KaxBlockDuration>(blockGroup)); 
     715                        flags = blockGroup.ReferenceCount() > 0 ? mediaSampleNotSync : 0; 
     716                         
     717                } else if (elementID == KaxSimpleBlock::ClassInfos.GlobalId) { 
     718                        KaxSimpleBlock & simpleBlock = *static_cast<KaxSimpleBlock *>(cluster[i]); 
     719                        block = &simpleBlock; 
     720                        if (!simpleBlock.IsKeyframe()) 
     721                                flags |= mediaSampleNotSync; 
     722                        if (simpleBlock.IsDiscardable()) 
     723                                flags |= mediaSampleDroppable; 
     724                } 
     725                 
     726                if (block) { 
     727                        block->SetParent(cluster); 
     728                         
     729                        for (int i = 0; i < tracks.size(); i++) { 
     730                                if (tracks[i].number == block->TrackNum()) { 
     731                                        tracks[i].AddBlock(*block, duration, flags); 
     732                                        break; 
     733                                } 
    714734                        } 
    715735                } 
    716                  
    717                 blockGroup = &GetNextChild<KaxBlockGroup>(cluster, *blockGroup); 
    718736        } 
    719737         
     
    812830} 
    813831 
    814 void MatroskaTrack::ParseFirstBlock(KaxBlock &block) 
     832void MatroskaTrack::ParseFirstBlock(KaxInternalBlock &block) 
    815833{ 
    816834        AudioStreamBasicDescription asbd = {0}; 
     
    838856} 
    839857 
    840 void MatroskaTrack::AddBlock(KaxBlockGroup &blockGroup) 
    841 
    842         KaxBlock & block = GetChild<KaxBlock>(blockGroup); 
    843         KaxBlockDuration & blockDuration = GetChild<KaxBlockDuration>(blockGroup); 
    844          
     858void MatroskaTrack::AddBlock(KaxInternalBlock &block, uint32 duration, short flags) 
     859
    845860        if (!seenFirstBlock) { 
    846861                ParseFirstBlock(block); 
     
    865880                MatroskaFrame newFrame; 
    866881                newFrame.timecode = block.GlobalTimecode() / timecodeScale; 
    867                 newFrame.duration = uint32(blockDuration)
     882                newFrame.duration = duration
    868883                newFrame.offset = block.GetDataPosition(i); 
    869884                newFrame.size = block.GetFrameSize(i); 
    870                 newFrame.flags = blockGroup.ReferenceCount() > 0 ? mediaSampleNotSync : 0
     885                newFrame.flags = flags
    871886 
    872887                if (type == track_subtitle) {