[vlc-commits] [Git][videolan/vlc][master] 3 commits: demux: adaptive: fix debug build

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Fri Dec 5 06:58:57 UTC 2025



Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC


Commits:
e1350213 by François Cartegnie at 2025-12-05T07:11:46+01:00
demux: adaptive: fix debug build

- - - - -
a671c7f0 by François Cartegnie at 2025-12-05T07:11:46+01:00
demux: adaptive: set buffering level to committed dts on invalid PCR

Allows progression when we force set pcr to invalid

- - - - -
7a103f0c by François Cartegnie at 2025-12-05T07:11:46+01:00
demux: adaptive: handle broken PCR source at fakeesout level

- - - - -


6 changed files:

- modules/demux/adaptive/Streams.cpp
- modules/demux/adaptive/plumbing/CommandsQueue.cpp
- modules/demux/adaptive/plumbing/FakeESOut.cpp
- modules/demux/adaptive/plumbing/FakeESOut.hpp
- modules/demux/adaptive/test/plumbing/CommandsQueue.cpp
- modules/demux/dash/mpd/IsoffMainParser.cpp


Changes:

=====================================
modules/demux/adaptive/Streams.cpp
=====================================
@@ -278,6 +278,7 @@ bool AbstractStream::startDemux()
 
     demuxersource->Reset();
     demuxfirstchunk = true;
+    fakeEsOut()->setPCRTrusted(format != StreamFormat::Type::MPEG2TS);
     demuxer = createDemux(format);
     if(!demuxer && format != StreamFormat())
         msg_Err(p_realdemux, "Failed to create demuxer %p %s", (void *)demuxer,


=====================================
modules/demux/adaptive/plumbing/CommandsQueue.cpp
=====================================
@@ -351,8 +351,18 @@ void CommandsQueue::Schedule( AbstractCommand *command, EsType )
     else if( command->getType() == ES_OUT_SET_GROUP_PCR )
     {
         if(command->getTimes().continuous != VLC_TICK_INVALID)
+        {
             bufferinglevel = command->getTimes();
-        LockedCommit();
+            LockedCommit();
+        }
+        else
+        {
+            /* Try to use the reordered/committed tail when the pcr was invalid */
+            LockedCommit();
+            if(!commands.empty() &&
+                commands.back().second->getTimes().continuous != VLC_TICK_INVALID)
+                bufferinglevel = commands.back().second->getTimes();
+        }
         commands.push_back( Queueentry(nextsequence++, command) );
     }
     else


=====================================
modules/demux/adaptive/plumbing/FakeESOut.cpp
=====================================
@@ -148,6 +148,8 @@ FakeESOut::FakeESOut( es_out_t *es, AbstractCommandsQueue *queue,
     associated.b_timestamp_set = false;
     expected.b_timestamp_set = false;
     priority = ES_PRIORITY_SELECTABLE_MIN;
+    pcrstatus = PcrStatus::Valid;
+    pcrcomparison = VLC_TICK_INVALID;
     vlc_mutex_init(&lock);
 }
 
@@ -383,6 +385,12 @@ void FakeESOut::setSrcID( const SrcID &s )
     srcID = s;
 }
 
+void FakeESOut::setPCRTrusted( bool b )
+{
+    pcrstatus = b ? PcrStatus::Valid : PcrStatus::WaitingFirst;
+    pcrcomparison = VLC_TICK_INVALID;
+}
+
 void FakeESOut::schedulePCRReset()
 {
     AbstractCommand *command = commandsfactory->creatEsOutControlResetPCRCommand();
@@ -651,6 +659,8 @@ int FakeESOut::esOutSend(es_out_id_t *p_es, block_t *p_block)
         times = synchronizationReference.second.segment;
         times.offsetBy(p_block->i_dts - times.demux);
         assert(times.media != VLC_TICK_INVALID);
+        /* For bogus PCR */
+        pcrcomparison = p_block->i_dts;
     }
 
    AbstractCommand *command = commandsfactory->createEsOutSendCommand( es_id, times, p_block );
@@ -696,7 +706,8 @@ int FakeESOut::esOutControl(int i_query, va_list args)
 
             SegmentTimes times;
 
-            if(synchronizationReference.second.segment.demux != VLC_TICK_INVALID)
+            if( pcrstatus != PcrStatus::WaitingFirst &&
+                synchronizationReference.second.segment.demux != VLC_TICK_INVALID )
             {
                 pcr = fixTimestamp( pcr );
 
@@ -707,6 +718,26 @@ int FakeESOut::esOutControl(int i_query, va_list args)
             }
             else pcr = VLC_TICK_INVALID;
 
+            /* Offset/Bad PCR handling */
+            if( pcrstatus == PcrStatus::WaitingFirst )
+            {
+                pcrstatus = PcrStatus::Evaluating;
+            }
+            else if( pcrstatus == PcrStatus::Evaluating &&
+                pcrcomparison != VLC_TICK_INVALID && pcr != VLC_TICK_INVALID )
+            {
+                if( std::llabs(pcr - pcrcomparison) > vlc_tick_from_sec(2) )
+                    pcrstatus = PcrStatus::Broken;
+                else
+                    pcrstatus = PcrStatus::Valid;
+            }
+
+            if( pcrstatus == PcrStatus::Broken )
+            {
+                times = SegmentTimes();
+                pcr = VLC_TICK_INVALID;
+            }
+
             AbstractCommand *command = commandsfactory->createEsOutControlPCRCommand( i_group, times, pcr );
             if( likely(command) )
             {


=====================================
modules/demux/adaptive/plumbing/FakeESOut.hpp
=====================================
@@ -118,6 +118,7 @@ namespace adaptive
             bool hasSynchronizationReference() const;
             void setSynchronizationReference(const SynchronizationReference &);
             void setSrcID( const SrcID & );
+            void setPCRTrusted( bool );
             void schedulePCRReset();
             void scheduleAllForDeletion(); /* Queue Del commands for non Del issued ones */
             void recycleAll(); /* Cancels all commands and send fakees for recycling */
@@ -145,6 +146,14 @@ namespace adaptive
             vlc_tick_t timestamps_offset;
             int priority;
             bool b_in_commands_group;
+            enum class PcrStatus
+            {
+                WaitingFirst,
+                Evaluating,
+                Valid,
+                Broken,
+            } pcrstatus;
+            vlc_tick_t pcrcomparison;
             std::list<FakeESOutID *> fakeesidlist;
             std::list<FakeESOutID *> recycle_candidates;
             std::list<FakeESOutID *> declared;


=====================================
modules/demux/adaptive/test/plumbing/CommandsQueue.cpp
=====================================
@@ -318,6 +318,27 @@ int CommandsQueue_test()
         }
         queue.Process(DT(VLC_TICK_0 + OFFSET + vlc_tick_from_sec(0)));
         Expect(esout.output.size() == 1);
+        queue.Abort(true);
+        esout.cleanup();
+
+        /* PCR handling when set to INVALID */
+        for(size_t i=0; i<3; i++)
+        {
+            block_t *data = block_Alloc(0);
+            Expect(data);
+            data->i_dts = VLC_TICK_0 + vlc_tick_from_sec(i);
+            cmd = factory.createEsOutSendCommand(id0, SegmentTimes(), data);
+            queue.Schedule(cmd);
+        }
+        Expect(queue.getDemuxedAmount(DT(VLC_TICK_0)).continuous == 0);
+        Expect(queue.getBufferingLevel().continuous == VLC_TICK_INVALID);
+        cmd = factory.createEsOutControlPCRCommand(0, SegmentTimes(), VLC_TICK_INVALID);
+        queue.Schedule(cmd);
+        Expect(queue.getDemuxedAmount(DT(VLC_TICK_0)).continuous == vlc_tick_from_sec(2));
+        Expect(queue.getBufferingLevel().continuous == VLC_TICK_0 + vlc_tick_from_sec(2));
+        queue.Process(DT(VLC_TICK_0 + vlc_tick_from_sec(5)));
+        Expect(esout.output.size() == 3);
+
 
     } catch(...) {
         delete id0;


=====================================
modules/demux/dash/mpd/IsoffMainParser.cpp
=====================================
@@ -346,7 +346,7 @@ void    IsoffMainParser::parseAdaptationSets  (MPD *mpd, Node *periodNode, BaseP
 
 #ifdef ADAPTATIVE_ADVANCED_DEBUG
         if(adaptationSet->description.empty())
-            adaptationSet->description.Set(adaptationSet->getID().str());
+            adaptationSet->description = adaptationSet->getID().str();
 #endif
 
         if(!adaptationSet->getRepresentations().empty())



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/c08a9690dcd91808c182440e7aadfd01139e4253...7a103f0ca2fe99b8dc629605e112f322e7e2ca21

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/c08a9690dcd91808c182440e7aadfd01139e4253...7a103f0ca2fe99b8dc629605e112f322e7e2ca21
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list