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(CEA): Add support to vertical position in CEA-608 #5531

Merged
merged 1 commit into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/cea/cea608_memory.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ shaka.cea.Cea608Memory = class {
const stream = `CC${(this.fieldNum_<< 1) | this.channelNum_ +1}`;
const topLevelCue = new shaka.text.Cue(
startTime, endTime, /* payload= */ '');
topLevelCue.lineInterpretation =
shaka.text.Cue.lineInterpretation.PERCENTAGE;
const maxRows = shaka.cea.Cea608Memory.CC_ROWS + 1;
topLevelCue.line = this.row_ / maxRows * 100;
return shaka.cea.CeaUtils.getParsedCaption(
topLevelCue, stream, this.rows_, startTime, endTime);
}
Expand Down
24 changes: 24 additions & 0 deletions test/cea/cea608_memory_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ describe('Cea608Memory', () => {
const caption = memory.forceEmit(startTime, endTime);

const topLevelCue = new shaka.text.Cue(startTime, endTime, '');
topLevelCue.line = 6.25;
topLevelCue.lineInterpretation =
shaka.text.Cue.lineInterpretation.PERCENTAGE;
topLevelCue.nestedCues = [
CeaUtils.createDefaultCue(startTime, endTime, text),
];
Expand Down Expand Up @@ -79,6 +82,9 @@ describe('Cea608Memory', () => {
}

const topLevelCue = new shaka.text.Cue(startTime, endTime, '');
topLevelCue.line = 6.25;
topLevelCue.lineInterpretation =
shaka.text.Cue.lineInterpretation.PERCENTAGE;
topLevelCue.nestedCues = [
CeaUtils.createDefaultCue(startTime, endTime, expectedText),
];
Expand Down Expand Up @@ -113,6 +119,9 @@ describe('Cea608Memory', () => {
}

const topLevelCue = new shaka.text.Cue(startTime, endTime, '');
topLevelCue.line = 6.25;
topLevelCue.lineInterpretation =
shaka.text.Cue.lineInterpretation.PERCENTAGE;
topLevelCue.nestedCues = [
CeaUtils.createStyledCue(startTime, endTime,
expectedText, /* underline= */ true,
Expand Down Expand Up @@ -164,6 +173,9 @@ describe('Cea608Memory', () => {
// ...
// So we expect that test\n\ntest is emitted
const topLevelCue = new shaka.text.Cue(startTime, endTime, '');
topLevelCue.line = 37.5;
topLevelCue.lineInterpretation =
shaka.text.Cue.lineInterpretation.PERCENTAGE;
topLevelCue.nestedCues = [
CeaUtils.createDefaultCue(startTime, endTime, text),
CeaUtils.createLineBreakCue(startTime, endTime),
Expand Down Expand Up @@ -205,6 +217,9 @@ describe('Cea608Memory', () => {
memory.eraseChar(); // Erase the last 't' from 'testt'

const topLevelCue = new shaka.text.Cue(startTime, endTime, '');
topLevelCue.line = 6.25;
topLevelCue.lineInterpretation =
shaka.text.Cue.lineInterpretation.PERCENTAGE;
topLevelCue.nestedCues = [
CeaUtils.createDefaultCue(startTime, endTime, expectedText),
];
Expand Down Expand Up @@ -276,6 +291,9 @@ describe('Cea608Memory', () => {

// Expected text is 's\nt\nt\ne'
const topLevelCue = new shaka.text.Cue(startTime, endTime, '');
topLevelCue.line = 31.25;
topLevelCue.lineInterpretation =
shaka.text.Cue.lineInterpretation.PERCENTAGE;
topLevelCue.nestedCues = [
CeaUtils.createDefaultCue(startTime, endTime, 's'),
CeaUtils.createLineBreakCue(startTime, endTime),
Expand Down Expand Up @@ -320,6 +338,9 @@ describe('Cea608Memory', () => {

// Expected text is 't\ne\ns\nt'
const topLevelCue = new shaka.text.Cue(startTime, endTime, '');
topLevelCue.line = 31.25;
topLevelCue.lineInterpretation =
shaka.text.Cue.lineInterpretation.PERCENTAGE;
topLevelCue.nestedCues = [
CeaUtils.createDefaultCue(startTime, endTime, 't'),
CeaUtils.createLineBreakCue(startTime, endTime),
Expand Down Expand Up @@ -364,6 +385,9 @@ describe('Cea608Memory', () => {

// Expected text is 't\ne\ns\nt'
const topLevelCue = new shaka.text.Cue(startTime, endTime, '');
topLevelCue.line = 31.25;
topLevelCue.lineInterpretation =
shaka.text.Cue.lineInterpretation.PERCENTAGE;
topLevelCue.nestedCues = [
CeaUtils.createDefaultCue(startTime, endTime, 't'),
CeaUtils.createLineBreakCue(startTime, endTime),
Expand Down
33 changes: 33 additions & 0 deletions test/cea/cea_decoder_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ describe('CeaDecoder', () => {

const topLevelCue = new shaka.text.Cue(
startTimeCaption1, startTimeCaption2, '');
topLevelCue.line = 81.25;
topLevelCue.lineInterpretation =
shaka.text.Cue.lineInterpretation.PERCENTAGE;
topLevelCue.nestedCues = [
CeaUtils.createStyledCue(
startTimeCaption1, startTimeCaption2, expectedText,
Expand Down Expand Up @@ -110,6 +113,9 @@ 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.lineInterpretation =
shaka.text.Cue.lineInterpretation.PERCENTAGE;

topLevelCue.nestedCues = [
CeaUtils.createDefaultCue(
Expand Down Expand Up @@ -160,6 +166,9 @@ describe('CeaDecoder', () => {
// A single nested cue containing yellow, italicized text.
const topLevelCue = new shaka.text.Cue(startTimeCaption1,
startTimeCaption2, '');
topLevelCue.line = 12.5;
topLevelCue.lineInterpretation =
shaka.text.Cue.lineInterpretation.PERCENTAGE;
topLevelCue.nestedCues = [
CeaUtils.createStyledCue(
startTimeCaption1, startTimeCaption2, expectedText,
Expand Down Expand Up @@ -199,6 +208,9 @@ describe('CeaDecoder', () => {

const topLevelCue = new shaka.text.Cue(startTimeCaption1,
startTimeCaption2, '');
topLevelCue.line = 6.25;
topLevelCue.lineInterpretation =
shaka.text.Cue.lineInterpretation.PERCENTAGE;
topLevelCue.nestedCues = [
CeaUtils.createDefaultCue(
startTimeCaption1, startTimeCaption2, expectedText),
Expand Down Expand Up @@ -231,6 +243,9 @@ describe('CeaDecoder', () => {

const topLevelCue = new shaka.text.Cue(startTimeCaption1,
startTimeCaption2, '');
topLevelCue.line = 6.25;
topLevelCue.lineInterpretation =
shaka.text.Cue.lineInterpretation.PERCENTAGE;
topLevelCue.nestedCues = [
CeaUtils.createDefaultCue(
startTimeCaption1, startTimeCaption2, expectedText),
Expand Down Expand Up @@ -300,6 +315,9 @@ 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.lineInterpretation =
shaka.text.Cue.lineInterpretation.PERCENTAGE;
topLevelCue1.nestedCues = [
CeaUtils.createDefaultCue(
/* startTime= */ time1, /* endTime= */ time2, /* payload= */ '1.'),
Expand All @@ -308,6 +326,9 @@ 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.lineInterpretation =
shaka.text.Cue.lineInterpretation.PERCENTAGE;
topLevelCue2.nestedCues = [
CeaUtils.createDefaultCue(
/* startTime= */ time2, /* endTime= */ time3, /* payload= */ '1.'),
Expand All @@ -322,6 +343,9 @@ 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.lineInterpretation =
shaka.text.Cue.lineInterpretation.PERCENTAGE;
topLevelCue3.nestedCues = [
CeaUtils.createDefaultCue(
/* startTime= */ time3, /* endTime= */ time4, /* payload= */ '2.'),
Expand All @@ -336,6 +360,9 @@ 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.lineInterpretation =
shaka.text.Cue.lineInterpretation.PERCENTAGE;
topLevelCue4.nestedCues = [
CeaUtils.createDefaultCue(
/* startTime= */ time4, /* endTime= */ time5, /* payload= */ '3.'),
Expand Down Expand Up @@ -406,6 +433,9 @@ 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.lineInterpretation =
shaka.text.Cue.lineInterpretation.PERCENTAGE;
topLevelCue1.nestedCues = [
CeaUtils.createDefaultCue(
/* startTime= */ 1, /* endTime= */ 2, /* payload= */ '1.'),
Expand All @@ -414,6 +444,9 @@ 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.lineInterpretation =
shaka.text.Cue.lineInterpretation.PERCENTAGE;
topLevelCue2.nestedCues = [
CeaUtils.createDefaultCue(
/* startTime= */ 2, /* endTime= */ 3, /* payload= */ '1.'),
Expand Down