Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ABR): Allow some downscale when use restrictToElementSize or restrictToScreenSize #5631

Merged
merged 3 commits into from Sep 12, 2023

Conversation

avelad
Copy link
Collaborator

@avelad avelad commented Sep 11, 2023

Closes: #5335
Closes: #5101

@avelad avelad added type: enhancement New feature or request priority: P2 Smaller impact or easy workaround labels Sep 11, 2023
@avelad avelad added this to the v4.5 milestone Sep 11, 2023
@shaka-bot
Copy link
Collaborator

shaka-bot commented Sep 11, 2023

Incremental code coverage: 28.21%

lib/abr/simple_abr_manager.js Outdated Show resolved Hide resolved
if (resolution.height >= maxHeight || resolution.width >= maxWidth) {
maxHeight = resolution.height;
maxWidth = resolution.width;
if (resolution.height >= maxHeight && resolution.width >= maxWidth) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand your logic here. On the previous two lines, we set maxHeight and maxWidth to resolution.height and resolution.width, so this condition is always true on this line. Right?

Overall, I would find this easier to review and verify with some comments in the code. Thanks!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a comment with an example for explanatory purposes.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this code would result in the behavior you explain in the comments, of looking for the smallest resolution that will "fit" the given max resolution. Given that it happens after maxWidth and maxHeight are re-defined, the inner if-condition is really testing resolution.height >= resolution.height && resolution.width >= resolution.width, which will only be false if the resolution is undefined, and thus it will cause the first resolution where EITHER width or height fits to be picked.

I think you probably just want to make the inner if-clause the outer check, and make it always break. Like...

if (resolution.height >= maxHeight && resolution.width >= maxWidth) {
  maxHeight = resolution.height;
  maxWidth = resolution.width;
  break;
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok.. I changed it!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes much more sense to me. Thanks!

@avelad avelad dismissed joeyparrish’s stale review September 12, 2023 10:52

Reviewed by Theodore

@avelad avelad merged commit cad1ac8 into shaka-project:main Sep 12, 2023
15 checks passed
@avelad avelad deleted the abr-restrictTo-improvements branch September 12, 2023 12:28
@siarheipashkevich
Copy link

@avelad hi, in the 4.5.0 version only low track selected for this manifest (there is no any changes when I changed my ethernet throttling):

<?xml version="1.0" encoding="UTF-8"?>
<MPD xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:mpeg:dash:schema:mpd:2011" xmlns:cenc="urn:mpeg:cenc:2013" xsi:schemaLocation="urn:mpeg:dash:schema:mpd:2011 http://standards.iso.org/ittf/PubliclyAvailableStandards/MPEG-DASH_schema_files/DASH-MPD.xsd" type="static" minBufferTime="PT30S" profiles="urn:mpeg:dash:profile:isoff-main:2011" mediaPresentationDuration="PT5M13.792S">
  <Period start="PT0S" duration="PT5M13.792S" id="1">
    <AdaptationSet mimeType="video/mp4" frameRate="60000/1001" segmentAlignment="true" subsegmentAlignment="true" startWithSAP="1" subsegmentStartsWithSAP="1" bitstreamSwitching="false">
      <Representation id="1" width="1920" height="1080" bandwidth="8000000" codecs="avc1.64002a">
        <BaseURL>ducks_8000kbps.mp4</BaseURL>
        <SegmentBase indexRange="761-2684">
          <Initialization range="0-760"/>
        </SegmentBase>
      </Representation>
      <Representation id="2" width="1920" height="1080" bandwidth="4000000" codecs="avc1.64002a">
        <BaseURL>ducks_4000kbps.mp4</BaseURL>
        <SegmentBase indexRange="761-2684">
          <Initialization range="0-760"/>
        </SegmentBase>
      </Representation>
      <Representation id="3" width="1920" height="1080" bandwidth="1200000" codecs="avc1.64002a">
        <BaseURL>ducks_1200kbps.mp4</BaseURL>
        <SegmentBase indexRange="761-2684">
          <Initialization range="0-760"/>
        </SegmentBase>
      </Representation>
      <Representation id="4" width="1920" height="1080" bandwidth="400000" codecs="avc1.64002a">
        <BaseURL>ducks_400kbps.mp4</BaseURL>
        <SegmentBase indexRange="760-2683">
          <Initialization range="0-759"/>
        </SegmentBase>
      </Representation>
    </AdaptationSet>
    <AdaptationSet mimeType="audio/mp4" lang="und" segmentAlignment="0">
      <Representation id="5" bandwidth="96000" audioSamplingRate="48000" codecs="mp4a.40.2">
        <BaseURL>ducks_sd_2.mp4</BaseURL>
        <SegmentBase indexRange="658-2581">
          <Initialization range="0-657"/>
        </SegmentBase>
        <AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2"/>
      </Representation>
    </AdaptationSet>
  </Period>
</MPD>

But when I switched back to the 4.4.3 version the ABR working correctly for this manifest. What am I doing wrong?

FYI @theodab @joeyparrish

@shaka-bot shaka-bot added the status: archived Archived and locked; will not be updated label Nov 11, 2023
@shaka-project shaka-project locked as resolved and limited conversation to collaborators Nov 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
priority: P2 Smaller impact or easy workaround status: archived Archived and locked; will not be updated type: enhancement New feature or request
Projects
None yet
5 participants