[vlc-devel] [PATCH 3/4] adaptive: don't fail if no suitable resolution matches constraints

Pierre Ynard linkfanel at yahoo.fr
Sun Nov 8 01:08:33 CET 2020


This changes the semantics of --adaptive-maxheight
and --adaptive-maxwidth and aligns them with those of
--preferred-resolution: the current behavior that strictly conforms to
resolution constraints and results in no playback at all, rather than
trying a best effort, is not terribly useful.


diff --git a/modules/demux/adaptive/logic/Representationselectors.cpp b/modules/demux/adaptive/logic/Representationselectors.cpp
index 1c2ac34..5889b3f 100644
--- a/modules/demux/adaptive/logic/Representationselectors.cpp
+++ b/modules/demux/adaptive/logic/Representationselectors.cpp
@@ -43,11 +43,7 @@ RepresentationSelector::~RepresentationSelector()
 BaseRepresentation * RepresentationSelector::lowest(BaseAdaptationSet *adaptSet) const
 {
     std::vector<BaseRepresentation *> reps = adaptSet->getRepresentations();
-    /* No maxsize check here */
-    BaseRepresentation *rep = (reps.empty()) ? NULL : *(reps.begin());
-    if(rep && rep->getWidth() <= maxwidth && rep->getHeight() <= maxheight)
-        return rep;
-    return NULL;
+    return (reps.empty()) ? NULL : *(reps.begin());
 }
 
 BaseRepresentation * RepresentationSelector::highest(BaseAdaptationSet *adaptSet) const
@@ -60,7 +56,7 @@ BaseRepresentation * RepresentationSelector::highest(BaseAdaptationSet *adaptSet
         if( (*it)->getWidth() <= maxwidth && (*it)->getHeight() <= maxheight )
             return *it;
     }
-    return NULL;
+    return lowest(adaptSet);
 }
 
 BaseRepresentation * RepresentationSelector::higher(BaseAdaptationSet *adaptSet, BaseRepresentation *rep) const
@@ -102,12 +98,12 @@ BaseRepresentation * RepresentationSelector::select(std::vector<BaseRepresentati
     std::vector<BaseRepresentation *>::const_iterator repIt;
     for(repIt=reps.begin(); repIt!=reps.end(); ++repIt)
     {
-        if( (*repIt)->getWidth() > maxwidth || (*repIt)->getHeight() > maxheight )
-            continue;
-
         if ( !lowest || (*repIt)->getBandwidth() < lowest->getBandwidth())
             lowest = *repIt;
 
+        if( (*repIt)->getWidth() > maxwidth || (*repIt)->getHeight() > maxheight )
+            continue;
+
         if ( (*repIt)->getBandwidth() < maxbitrate &&
              (*repIt)->getBandwidth() > minbitrate )
         {
-- 
Pierre Ynard
"Une âme dans un corps, c'est comme un dessin sur une feuille de papier."


More information about the vlc-devel mailing list