VirtualBox

Changeset 75030 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Oct 24, 2018 11:43:09 AM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
126071
Message:

VideoRec/Main: Extended the cue list with positions on a per-track basis.

Location:
trunk/src/VBox/Main
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/WebMWriter.h

    r74992 r75030  
    289289
    290290    /**
     291     * Structure for a single cue point track position entry.
     292     */
     293    struct WebMCueTrackPosEntry
     294    {
     295        WebMCueTrackPosEntry(uint64_t a_offCluster)
     296            : offCluster(a_offCluster) { }
     297
     298        /** Offset (in bytes) of the related cluster containing the given position. */
     299        uint64_t offCluster;
     300    };
     301
     302    /** Map for keeping track position entries for a single cue point.
     303     *  The key is the track number (*not* UUID!). */
     304    typedef std::map<uint8_t, WebMCueTrackPosEntry *> WebMCueTrackPosMap;
     305
     306    /**
    291307     * Structure for keeping a cue point.
    292308     */
    293309    struct WebMCuePoint
    294310    {
    295         WebMCuePoint(WebMTrack *a_pTrack, uint64_t a_offCluster, WebMTimecodeAbs a_tcAbs)
    296             : pTrack(a_pTrack)
    297             , offCluster(a_offCluster), tcAbs(a_tcAbs) { }
    298 
    299         /** Associated track. */
    300         WebMTrack      *pTrack;
    301         /** Offset (in bytes) of the related cluster containing the given position. */
    302         uint64_t        offCluster;
     311        WebMCuePoint(WebMTimecodeAbs a_tcAbs)
     312            : tcAbs(a_tcAbs) { }
     313
     314        virtual ~WebMCuePoint()
     315        {
     316            Clear();
     317        }
     318
     319        void Clear(void)
     320        {
     321            WebMCueTrackPosMap::iterator itTrackPos = Pos.begin();
     322            while (itTrackPos != Pos.end())
     323            {
     324                WebMCueTrackPosEntry *pTrackPos = itTrackPos->second;
     325                AssertPtr(pTrackPos);
     326                delete pTrackPos;
     327
     328                Pos.erase(itTrackPos);
     329                itTrackPos = Pos.begin();
     330            }
     331
     332            Assert(Pos.empty());
     333        }
     334
     335        /** Map containing all track positions for this specific cue point. */
     336        WebMCueTrackPosMap Pos;
    303337        /** Absolute time code according to the segment time base. */
    304         WebMTimecodeAbs tcAbs;
    305     };
     338        WebMTimecodeAbs    tcAbs;
     339    };
     340
     341    /** List of cue points. */
     342    typedef std::list<WebMCuePoint *> WebMCuePointList;
    306343
    307344    /**
     
    383420        uint64_t                        offCues;
    384421        /** List of cue points. Needed for seeking table. */
    385         std::list<WebMCuePoint>         lstCues;
     422        WebMCuePointList                lstCuePoints;
    386423
    387424        /** Total number of clusters. */
  • trunk/src/VBox/Main/src-client/WebMWriter.cpp

    r74912 r75030  
    680680                      Cluster.uID, Cluster.tcAbsStartMs, mapAbsPTSMs, Cluster.offStart));
    681681
    682             if (CurSeg.cClusters)
    683                 AssertMsg(Cluster.tcAbsStartMs, ("[C%RU64] @ %RU64 starting timecode is 0 which is invalid\n",
    684                                                  Cluster.uID, Cluster.offStart));
     682            /* Insert cue points for all tracks if a new cluster has been started. */
     683            WebMCuePoint *pCuePoint = new WebMCuePoint(Cluster.tcAbsStartMs);
    685684
    686685            WebMTracks::iterator itTrack = CurSeg.mapTracks.begin();
    687686            while (itTrack != CurSeg.mapTracks.end())
    688687            {
    689                 /* Insert cue points for all tracks if a new cluster has been started. */
    690                 WebMCuePoint cue(itTrack->second /* pTrack */, Cluster.offStart, Cluster.tcAbsStartMs);
    691                 CurSeg.lstCues.push_back(cue);
    692 
     688                pCuePoint->Pos[itTrack->first] = new WebMCueTrackPosEntry(Cluster.offStart);
    693689                ++itTrack;
    694690            }
     691
     692            CurSeg.lstCuePoints.push_back(pCuePoint);
    695693
    696694            subStart(MkvElem_Cluster)
     
    731729                && (pBlock->Data.fFlags & VBOX_WEBM_BLOCK_FLAG_KEY_FRAME))
    732730            {
    733                 WebMCuePoint cue(pBlock->pTrack, Cluster.offStart, Cluster.tcAbsStartMs);
    734                 CurSeg.lstCues.push_back(cue);
     731                /* Insert cue points for all tracks if a new cluster has been started. */
     732                WebMCuePoint *pCuePoint = new WebMCuePoint(CurSeg.tcAbsLastWrittenMs);
     733
     734                WebMTracks::iterator itTrack = CurSeg.mapTracks.begin();
     735                while (itTrack != CurSeg.mapTracks.end())
     736                {
     737                    pCuePoint->Pos[itTrack->first] = new WebMCueTrackPosEntry(Cluster.offStart);
     738                    ++itTrack;
     739                }
     740
     741                CurSeg.lstCuePoints.push_back(pCuePoint);
    735742            }
    736743
     
    784791    subStart(MkvElem_Cues);
    785792
    786     std::list<WebMCuePoint>::iterator itCuePoint = CurSeg.lstCues.begin();
    787     while (itCuePoint != CurSeg.lstCues.end())
    788     {
    789         /* Sanity. */
    790         AssertPtr(itCuePoint->pTrack);
    791 
    792         LogFunc(("CuePoint @ %RU64: Track #%RU8 (Cluster @ %RU64, tcAbs=%RU64)\n",
    793                  RTFileTell(getFile()), itCuePoint->pTrack->uTrack,
    794                  itCuePoint->offCluster, itCuePoint->tcAbs));
     793    WebMCuePointList::iterator itCuePoint = CurSeg.lstCuePoints.begin();
     794    while (itCuePoint != CurSeg.lstCuePoints.end())
     795    {
     796        WebMCuePoint *pCuePoint = (*itCuePoint);
     797        AssertPtr(pCuePoint);
     798
     799        LogFunc(("CuePoint @ %RU64: %zu tracks, tcAbs=%RU64)\n",
     800                 RTFileTell(getFile()), pCuePoint->Pos.size(), pCuePoint->tcAbs));
    795801
    796802        subStart(MkvElem_CuePoint)
    797             .serializeUnsignedInteger(MkvElem_CueTime,                itCuePoint->tcAbs)
    798             .subStart(MkvElem_CueTrackPositions)
    799                 .serializeUnsignedInteger(MkvElem_CueTrack,           itCuePoint->pTrack->uTrack)
    800                 .serializeUnsignedInteger(MkvElem_CueClusterPosition, itCuePoint->offCluster - CurSeg.offStart, 8)
    801                 .subEnd(MkvElem_CueTrackPositions)
    802             .subEnd(MkvElem_CuePoint);
    803 
    804         itCuePoint++;
     803            .serializeUnsignedInteger(MkvElem_CueTime, pCuePoint->tcAbs);
     804
     805            WebMCueTrackPosMap::iterator itTrackPos = pCuePoint->Pos.begin();
     806            while (itTrackPos != pCuePoint->Pos.end())
     807            {
     808                WebMCueTrackPosEntry *pTrackPos = itTrackPos->second;
     809                AssertPtr(pTrackPos);
     810
     811                LogFunc(("TrackPos (track #%RU32) @ %RU64, offCluster=%RU64)\n",
     812                         itTrackPos->first, RTFileTell(getFile()), pTrackPos->offCluster));
     813
     814                subStart(MkvElem_CueTrackPositions)
     815                    .serializeUnsignedInteger(MkvElem_CueTrack,           itTrackPos->first)
     816                    .serializeUnsignedInteger(MkvElem_CueClusterPosition, pTrackPos->offCluster - CurSeg.offStart, 8)
     817                    .subEnd(MkvElem_CueTrackPositions);
     818
     819                ++itTrackPos;
     820            }
     821
     822        subEnd(MkvElem_CuePoint);
     823
     824        ++itCuePoint;
    805825    }
    806826
     
    872892    const WebMTimecodeAbs tcAbsDurationMs = CurSeg.tcAbsLastWrittenMs - CurSeg.tcAbsStartMs;
    873893
    874     if (!CurSeg.lstCues.empty())
     894    if (!CurSeg.lstCuePoints.empty())
    875895    {
    876896        LogFunc(("tcAbsDurationMs=%RU64\n", tcAbsDurationMs));
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette