Skip to content

Commit

Permalink
fix(TTML): Clip to video when extent is not present (#6086)
Browse files Browse the repository at this point in the history
Fixes #4793
  • Loading branch information
avelad committed Jan 11, 2024
1 parent 9802f65 commit 2862228
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
5 changes: 5 additions & 0 deletions lib/text/ttml_text_parser.js
Expand Up @@ -491,6 +491,11 @@ shaka.text.TtmlTextParser = class {
region.viewportAnchorX = region.viewportAnchorX * 100 /
globalWidth;
}
} else if (!extent) {
region.width = 100 - region.viewportAnchorX;
region.widthUnits = shaka.text.CueRegion.units.PERCENTAGE;
region.height = 100 - region.viewportAnchorY;
region.heightUnits = shaka.text.CueRegion.units.PERCENTAGE;
}

region.viewportAnchorUnits = percentage || globalWidth != null ?
Expand Down
32 changes: 16 additions & 16 deletions test/text/ttml_text_parser_unit.js
Expand Up @@ -638,8 +638,8 @@ describe('TtmlTextParser', () => {
id: 'subtitleArea',
viewportAnchorX: 50,
viewportAnchorY: 16,
width: 100,
height: 100,
width: 50,
height: 84,
},
startTime: 62.05,
endTime: 3723.2,
Expand All @@ -666,8 +666,8 @@ describe('TtmlTextParser', () => {
region: {
viewportAnchorX: 50,
viewportAnchorY: 16,
width: 100,
height: 100,
width: 50,
height: 84,
},
startTime: 62.05,
endTime: 3723.2,
Expand All @@ -694,8 +694,8 @@ describe('TtmlTextParser', () => {
region: {
viewportAnchorX: 50,
viewportAnchorY: 16,
width: 100,
height: 100,
width: 50,
height: 84,
},
startTime: 62.05,
endTime: 3723.2,
Expand Down Expand Up @@ -872,8 +872,8 @@ describe('TtmlTextParser', () => {
viewportAnchorY: 16,
regionAnchorX: 0,
regionAnchorY: 0,
width: 100,
height: 100,
width: 50,
height: 84,
heightUnits: CueRegion.units.PERCENTAGE,
widthUnits: CueRegion.units.PERCENTAGE,
viewportAnchorUnits: CueRegion.units.PERCENTAGE,
Expand Down Expand Up @@ -945,8 +945,8 @@ describe('TtmlTextParser', () => {
id: 'subtitleArea',
viewportAnchorX: 50,
viewportAnchorY: 16,
width: 100,
height: 100,
width: 50,
height: 84,
},
startTime: 62.05,
endTime: 3723.2,
Expand All @@ -973,8 +973,8 @@ describe('TtmlTextParser', () => {
region: {
viewportAnchorX: 50,
viewportAnchorY: 16,
width: 100,
height: 100,
width: 50,
height: 84,
},
startTime: 62.05,
endTime: 3723.2,
Expand All @@ -1001,8 +1001,8 @@ describe('TtmlTextParser', () => {
region: {
viewportAnchorX: 50,
viewportAnchorY: 16,
width: 100,
height: 100,
width: 50,
height: 84,
},
startTime: 62.05,
endTime: 3723.2,
Expand Down Expand Up @@ -1032,8 +1032,8 @@ describe('TtmlTextParser', () => {
id: 'subtitleArea',
viewportAnchorX: 12.2,
viewportAnchorY: 50.005,
width: 100,
height: 100,
width: 87.8,
height: 49.995,
},
startTime: 62.05,
endTime: 3723.2,
Expand Down

0 comments on commit 2862228

Please sign in to comment.