[vlc-commits] adaptive: don't fail if no suitable resolution matches constraints

Pierre Ynard git at videolan.org
Mon Nov 9 20:46:08 CET 2020


vlc/vlc-3.0 | branch: master | Pierre Ynard <linkfanel at yahoo.fr> | Sun Nov  8 01:08:33 2020 +0100| [81991a47f579d0184ee16764f4d4b667dd7e2d28] | committer: Francois Cartegnie

adaptive: don't fail if no suitable resolution matches constraints

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.

Signed-off-by: Francois Cartegnie <fcvlcdev at free.fr>
(cherry picked from commit 927cf8821951113260ee14d210c35a257501032b)

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=81991a47f579d0184ee16764f4d4b667dd7e2d28
---

 modules/demux/adaptive/logic/Representationselectors.cpp | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/modules/demux/adaptive/logic/Representationselectors.cpp b/modules/demux/adaptive/logic/Representationselectors.cpp
index 1c2ac3473c..5889b3f199 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 )
         {



More information about the vlc-commits mailing list