af7f8e21 by jrivera

Simplify rendition selection by removing redundant conditionals

1 parent 0384848b
...@@ -632,7 +632,6 @@ videojs.HlsHandler.prototype.selectPlaylist = function () { ...@@ -632,7 +632,6 @@ videojs.HlsHandler.prototype.selectPlaylist = function () {
632 now = +new Date(), 632 now = +new Date(),
633 i, 633 i,
634 variant, 634 variant,
635 oldvariant,
636 bandwidthBestVariant, 635 bandwidthBestVariant,
637 resolutionPlusOne, 636 resolutionPlusOne,
638 resolutionBestVariant, 637 resolutionBestVariant,
...@@ -689,7 +688,6 @@ videojs.HlsHandler.prototype.selectPlaylist = function () { ...@@ -689,7 +688,6 @@ videojs.HlsHandler.prototype.selectPlaylist = function () {
689 // iterate through the bandwidth-filtered playlists and find 688 // iterate through the bandwidth-filtered playlists and find
690 // best rendition by player dimension 689 // best rendition by player dimension
691 while (i--) { 690 while (i--) {
692 oldvariant = variant;
693 variant = bandwidthPlaylists[i]; 691 variant = bandwidthPlaylists[i];
694 692
695 // ignore playlists without resolution information 693 // ignore playlists without resolution information
...@@ -700,9 +698,9 @@ videojs.HlsHandler.prototype.selectPlaylist = function () { ...@@ -700,9 +698,9 @@ videojs.HlsHandler.prototype.selectPlaylist = function () {
700 continue; 698 continue;
701 } 699 }
702 700
703
704 // since the playlists are sorted, the first variant that has 701 // since the playlists are sorted, the first variant that has
705 // dimensions less than or equal to the player size is the best 702 // dimensions less than or equal to the player size is the best
703
706 if (variant.attributes.RESOLUTION.width === width && 704 if (variant.attributes.RESOLUTION.width === width &&
707 variant.attributes.RESOLUTION.height === height) { 705 variant.attributes.RESOLUTION.height === height) {
708 // if we have the exact resolution as the player use it 706 // if we have the exact resolution as the player use it
...@@ -711,14 +709,14 @@ videojs.HlsHandler.prototype.selectPlaylist = function () { ...@@ -711,14 +709,14 @@ videojs.HlsHandler.prototype.selectPlaylist = function () {
711 break; 709 break;
712 } else if (variant.attributes.RESOLUTION.width < width && 710 } else if (variant.attributes.RESOLUTION.width < width &&
713 variant.attributes.RESOLUTION.height < height) { 711 variant.attributes.RESOLUTION.height < height) {
714 // if we don't have an exact match, see if we have a good higher quality variant to use 712 // if both dimensions are less than the player use the
715 if (oldvariant && oldvariant.attributes && oldvariant.attributes.RESOLUTION && 713 // previous (next-largest) variant
716 oldvariant.attributes.RESOLUTION.width && oldvariant.attributes.RESOLUTION.height) {
717 resolutionPlusOne = oldvariant;
718 }
719 resolutionBestVariant = variant;
720 break; 714 break;
721 } 715 }
716
717 // we still haven't found a good match so keep a reference
718 // to the previous variant for the next loop iteration
719 resolutionPlusOne = variant;
722 } 720 }
723 721
724 // fallback chain of variants 722 // fallback chain of variants
......