diff --git a/lib/cea/cea608_memory.js b/lib/cea/cea608_memory.js index ff1e5a2e98..12ae686ab0 100644 --- a/lib/cea/cea608_memory.js +++ b/lib/cea/cea608_memory.js @@ -84,8 +84,10 @@ shaka.cea.Cea608Memory = class { startTime, endTime, /* payload= */ ''); topLevelCue.lineInterpretation = shaka.text.Cue.lineInterpretation.PERCENTAGE; - const maxRows = shaka.cea.Cea608Memory.CC_ROWS + 1; - topLevelCue.line = this.row_ / maxRows * 100; + const line = shaka.cea.Cea608Memory.ROW_TO_LINE_CONVERSION_.get(this.row_); + if (line) { + topLevelCue.line = line; + } return shaka.cea.CeaUtils.getParsedCaption( topLevelCue, stream, this.rows_, startTime, endTime); } @@ -320,3 +322,12 @@ shaka.cea.Cea608Memory.CharSet.ExtendedPortugueseGerman = new Map([ [0x38, 'Å'], [0x39, 'å'], [0x3a, 'Ø'], [0x3b, 'ø'], [0x3c, '┌'], [0x3d, '┐'], [0x3e, '└'], [0x3f, '┘'], ]); + +/** + * @private @const {!Map} + */ +shaka.cea.Cea608Memory.ROW_TO_LINE_CONVERSION_ = new Map([ + [1, 10], [2, 15.33], [3, 20.66], [4, 26], [5, 31.33], [6, 36.66], [7, 42], + [8, 47.33], [9, 52.66], [10, 58], [11, 63.33], [12, 68.66], [13, 74], + [14, 79.33], [15, 84.66], +]); diff --git a/test/cea/cea608_memory_unit.js b/test/cea/cea608_memory_unit.js index 208008786a..88185260fd 100644 --- a/test/cea/cea608_memory_unit.js +++ b/test/cea/cea608_memory_unit.js @@ -31,7 +31,7 @@ describe('Cea608Memory', () => { const caption = memory.forceEmit(startTime, endTime); const topLevelCue = new shaka.text.Cue(startTime, endTime, ''); - topLevelCue.line = 6.25; + topLevelCue.line = 10; topLevelCue.lineInterpretation = shaka.text.Cue.lineInterpretation.PERCENTAGE; topLevelCue.nestedCues = [ @@ -82,7 +82,7 @@ describe('Cea608Memory', () => { } const topLevelCue = new shaka.text.Cue(startTime, endTime, ''); - topLevelCue.line = 6.25; + topLevelCue.line = 10; topLevelCue.lineInterpretation = shaka.text.Cue.lineInterpretation.PERCENTAGE; topLevelCue.nestedCues = [ @@ -119,7 +119,7 @@ describe('Cea608Memory', () => { } const topLevelCue = new shaka.text.Cue(startTime, endTime, ''); - topLevelCue.line = 6.25; + topLevelCue.line = 10; topLevelCue.lineInterpretation = shaka.text.Cue.lineInterpretation.PERCENTAGE; topLevelCue.nestedCues = [ @@ -173,7 +173,7 @@ describe('Cea608Memory', () => { // ... // So we expect that test\n\ntest is emitted const topLevelCue = new shaka.text.Cue(startTime, endTime, ''); - topLevelCue.line = 37.5; + topLevelCue.line = 36.66; topLevelCue.lineInterpretation = shaka.text.Cue.lineInterpretation.PERCENTAGE; topLevelCue.nestedCues = [ @@ -217,7 +217,7 @@ describe('Cea608Memory', () => { memory.eraseChar(); // Erase the last 't' from 'testt' const topLevelCue = new shaka.text.Cue(startTime, endTime, ''); - topLevelCue.line = 6.25; + topLevelCue.line = 10; topLevelCue.lineInterpretation = shaka.text.Cue.lineInterpretation.PERCENTAGE; topLevelCue.nestedCues = [ @@ -291,7 +291,7 @@ describe('Cea608Memory', () => { // Expected text is 's\nt\nt\ne' const topLevelCue = new shaka.text.Cue(startTime, endTime, ''); - topLevelCue.line = 31.25; + topLevelCue.line = 31.33; topLevelCue.lineInterpretation = shaka.text.Cue.lineInterpretation.PERCENTAGE; topLevelCue.nestedCues = [ @@ -338,7 +338,7 @@ describe('Cea608Memory', () => { // Expected text is 't\ne\ns\nt' const topLevelCue = new shaka.text.Cue(startTime, endTime, ''); - topLevelCue.line = 31.25; + topLevelCue.line = 31.33; topLevelCue.lineInterpretation = shaka.text.Cue.lineInterpretation.PERCENTAGE; topLevelCue.nestedCues = [ @@ -385,7 +385,7 @@ describe('Cea608Memory', () => { // Expected text is 't\ne\ns\nt' const topLevelCue = new shaka.text.Cue(startTime, endTime, ''); - topLevelCue.line = 31.25; + topLevelCue.line = 31.33; topLevelCue.lineInterpretation = shaka.text.Cue.lineInterpretation.PERCENTAGE; topLevelCue.nestedCues = [ diff --git a/test/cea/cea_decoder_unit.js b/test/cea/cea_decoder_unit.js index 6bd2a20e6e..4eeeff88f8 100644 --- a/test/cea/cea_decoder_unit.js +++ b/test/cea/cea_decoder_unit.js @@ -65,7 +65,7 @@ describe('CeaDecoder', () => { const topLevelCue = new shaka.text.Cue( startTimeCaption1, startTimeCaption2, ''); - topLevelCue.line = 81.25; + topLevelCue.line = 74; topLevelCue.lineInterpretation = shaka.text.Cue.lineInterpretation.PERCENTAGE; topLevelCue.nestedCues = [ @@ -113,7 +113,7 @@ describe('CeaDecoder', () => { // Since there are three style changes, there should be three nested cues. const topLevelCue = new shaka.text.Cue( startTimeCaption1, startTimeCaption2, ''); - topLevelCue.line = 6.25; + topLevelCue.line = 10; topLevelCue.lineInterpretation = shaka.text.Cue.lineInterpretation.PERCENTAGE; @@ -166,7 +166,7 @@ describe('CeaDecoder', () => { // A single nested cue containing yellow, italicized text. const topLevelCue = new shaka.text.Cue(startTimeCaption1, startTimeCaption2, ''); - topLevelCue.line = 12.5; + topLevelCue.line = 15.33; topLevelCue.lineInterpretation = shaka.text.Cue.lineInterpretation.PERCENTAGE; topLevelCue.nestedCues = [ @@ -208,7 +208,7 @@ describe('CeaDecoder', () => { const topLevelCue = new shaka.text.Cue(startTimeCaption1, startTimeCaption2, ''); - topLevelCue.line = 6.25; + topLevelCue.line = 10; topLevelCue.lineInterpretation = shaka.text.Cue.lineInterpretation.PERCENTAGE; topLevelCue.nestedCues = [ @@ -243,7 +243,7 @@ describe('CeaDecoder', () => { const topLevelCue = new shaka.text.Cue(startTimeCaption1, startTimeCaption2, ''); - topLevelCue.line = 6.25; + topLevelCue.line = 10; topLevelCue.lineInterpretation = shaka.text.Cue.lineInterpretation.PERCENTAGE; topLevelCue.nestedCues = [ @@ -315,7 +315,7 @@ describe('CeaDecoder', () => { // Top level cue corresponding to the first closed caption. const topLevelCue1 = new shaka.text.Cue( /* startTime= */ time1, /* endTime= */ time2, ''); - topLevelCue1.line = 93.75; + topLevelCue1.line = 84.66; topLevelCue1.lineInterpretation = shaka.text.Cue.lineInterpretation.PERCENTAGE; topLevelCue1.nestedCues = [ @@ -326,7 +326,7 @@ describe('CeaDecoder', () => { // Top level cue corresponding to the second closed caption. const topLevelCue2 = new shaka.text.Cue( /* startTime= */ time2, /* endTime= */ time3, ''); - topLevelCue2.line = 93.75; + topLevelCue2.line = 84.66; topLevelCue2.lineInterpretation = shaka.text.Cue.lineInterpretation.PERCENTAGE; topLevelCue2.nestedCues = [ @@ -343,7 +343,7 @@ describe('CeaDecoder', () => { // Top level cue corresponding to the third closed caption. const topLevelCue3 = new shaka.text.Cue( /* startTime= */ time3, /* endTime= */ time4, ''); - topLevelCue3.line = 93.75; + topLevelCue3.line = 84.66; topLevelCue3.lineInterpretation = shaka.text.Cue.lineInterpretation.PERCENTAGE; topLevelCue3.nestedCues = [ @@ -360,7 +360,7 @@ describe('CeaDecoder', () => { // Top level cue corresponding to the fourth closed caption. const topLevelCue4 = new shaka.text.Cue( /* startTime= */ time4, /* endTime= */ time5, ''); - topLevelCue4.line = 93.75; + topLevelCue4.line = 84.66; topLevelCue4.lineInterpretation = shaka.text.Cue.lineInterpretation.PERCENTAGE; topLevelCue4.nestedCues = [ @@ -433,7 +433,7 @@ describe('CeaDecoder', () => { // Top level cue corresponding to the first closed caption. const topLevelCue1 = new shaka.text.Cue(/* startTime= */ 1, /* endTime= */ 2, ''); - topLevelCue1.line = 93.75; + topLevelCue1.line = 84.66; topLevelCue1.lineInterpretation = shaka.text.Cue.lineInterpretation.PERCENTAGE; topLevelCue1.nestedCues = [ @@ -444,7 +444,7 @@ describe('CeaDecoder', () => { // Top level cue corresponding to the second closed caption. const topLevelCue2 = new shaka.text.Cue(/* startTime= */ 2, /* endTime= */ 3, ''); - topLevelCue2.line = 25; + topLevelCue2.line = 26; topLevelCue2.lineInterpretation = shaka.text.Cue.lineInterpretation.PERCENTAGE; topLevelCue2.nestedCues = [