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

fix: fix handling of multiple CC tracks #6076

Merged
merged 1 commit into from
Jan 10, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/cea/cea608_memory.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ shaka.cea.Cea608Memory = class {
* @return {?shaka.extern.ICaptionDecoder.ClosedCaption}
*/
forceEmit(startTime, endTime) {
const stream = `CC${(this.fieldNum_<< 1) | this.channelNum_ +1}`;
const stream = `CC${((this.fieldNum_<< 1) | this.channelNum_) + 1}`;
const topLevelCue = new shaka.text.Cue(
startTime, endTime, /* payload= */ '');
topLevelCue.lineInterpretation =
Expand Down
2 changes: 1 addition & 1 deletion lib/cea/cea_decoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ shaka.cea.CeaDecoder = class {
// Get the correct stream for this caption packet (CC1, ..., CC4)
const selectedChannel = fieldNum ?
this.currentField2Channel_ : this.currentField1Channel_;
const selectedMode = `CC${(fieldNum << 1) | selectedChannel + 1}`;
const selectedMode = `CC${((fieldNum << 1) | selectedChannel) + 1}`;
const selectedStream = this.cea608ModeToStream_.get(selectedMode);

// Check for bad frames (bad pairs). This can be two 0xff, two 0x00, or any
Expand Down
36 changes: 36 additions & 0 deletions test/cea/cea_decoder_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,42 @@ describe('CeaDecoder', () => {
decoder.clear();
});

it('painton captions on CC4', () => {
const controlCount = 0x03;
const captionData = 0xc0 | controlCount;
const paintonCaptionCC4Packet = new Uint8Array([
...atscCaptionInitBytes, captionData, /* padding= */ 0xff,
0xfd, 0x9d, 0x29, // Paint-on mode (RDC control code).
0xfd, 0xf4, 0xe5, // t, e
0xfd, 0x73, 0xf4, // s, t
]);

const startTimeCaption1 = 1;
const startTimeCaption2 = 2;
const expectedText = 'test';

const topLevelCue = new shaka.text.Cue(startTimeCaption1,
startTimeCaption2, '');
topLevelCue.line = 10;
topLevelCue.lineInterpretation =
shaka.text.Cue.lineInterpretation.PERCENTAGE;
topLevelCue.nestedCues = [
CeaUtils.createDefaultCue(
startTimeCaption1, startTimeCaption2, expectedText),
];

const expectedCaptions = [{
stream: 'CC4',
cue: topLevelCue,
}];

decoder.extract(paintonCaptionCC4Packet, startTimeCaption1);
decoder.extract(eraseDisplayedMemory, startTimeCaption2);
const captions = decoder.decode();

expect(captions).toEqual(expectedCaptions);
});

it('green and underlined popon caption data on CC3', () => {
const controlCount = 0x08;
const captionData = 0xc0 | controlCount;
Expand Down