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

CEA608: Limiting duplicated command checks to immediate frames #5355

Merged
merged 1 commit into from
Jan 15, 2019

Conversation

zsmatyas
Copy link
Contributor

@zsmatyas zsmatyas commented Jan 9, 2019

Reported in #3860
For failing examples see the github link above.

[Problem]
We drop matching control codes even if they are not received on
consecutive frames.

The specification says
"(4) If the first transmission of a control code pair passes parity,
it is acted upon within one video frame. If the NEXT frame contains
a perfect repeat of the same pair, the redundant code is ignored."

Keyword is the NEXT. The frames must arrive immediately after
each other.

See https://www.law.cornell.edu/cfr/text/47/79.101

[Solution]
Set an additional flag when any data is processed. Control code
duplication checks should be limited only for the first control
byte pairs processed after any control code.

[Test]
Sarnoff tests have equivalent CEA708 and CEA608 Streams.

}
continue;
}

// If we've reached this point then there is data to process; flag that work has been done.
captionDataProcessed = true;
Copy link
Contributor Author

@zsmatyas zsmatyas Jan 9, 2019

Choose a reason for hiding this comment

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

I moved this line above, as I think it should be set for any invalid caption as well. That will cause the screen update, I do not see a reason why we do not want to update the screen for invalid captions.

Copy link
Contributor

Choose a reason for hiding this comment

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

What does doing this fix? captionDataProcessed is already set to true on L332 if there's a valid->invalid transition. For invalid->invalid the screen will already be blank, so updating the screen wont do anything useful?

Copy link
Contributor Author

@zsmatyas zsmatyas Jan 9, 2019

Choose a reason for hiding this comment

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

I just wanted to reduce redundancy, instead of setting the flag inside and after this if block, we can achieve the same by setting it before the block, can't we?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the visual result is the same, but in the case that the encoder has turned captions off by flipping the validity bit you're causing a whole load of unnecessary work to happen on every single frame.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

}
continue;
}

// If we've reached this point then there is data to process; flag that work has been done.
captionDataProcessed = true;
Copy link
Contributor

Choose a reason for hiding this comment

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

What does doing this fix? captionDataProcessed is already set to true on L332 if there's a valid->invalid transition. For invalid->invalid the screen will already be blank, so updating the screen wont do anything useful?

@@ -230,6 +230,7 @@
private boolean repeatableControlSet;
private byte repeatableControlCc1;
private byte repeatableControlCc2;
private boolean dataProcessedSinceLastRepeatableControl = true;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why does this default to true? Ditto for flush. We haven't seen any data at all in these cases, so I don't think it makes sense for it to be true. Comment may be obsolete if you can get rid of the field as per comment below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The very first "repeatable control" should not be handled as a repetition: default = true.

}
continue;
}

// If we've reached this point then there is data to process; flag that work has been done.
captionDataProcessed = true;
if (dataProcessedSinceLastRepeatableControl) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you understand what this bit of existing code is doing (which is kept in this change; I'm posting this comment here because GitHub doesn't let me comment on the line I want to comment on):

I can't figure out what it's supposed to be doing. Perhaps it was an attempt to implement what you're now doing properly, and so becomes unnecessary?

Either way, does it work to get rid of both that bit of code and dataProcessedSinceLastRepeatableControl, and just do this here:

boolean repeatedControlPossible = repeatableControlSet;
repeatableControlSet = false;

and then pass repeatedControlPossible as an argument to handleCtrl? The line that sets repeatableControlSet = false inside handleCtrl would also go away.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • repeatableControlSet seems to only save the value between 2 iterations of the loop.
  • This part is probably only disabling the check for duplications between two calls of decode():
    if (!isRepeatableControl) {
        repeatableControlSet = false;
      }

I do not see why that is necessary at the moment. If 608 bytes are the first ones in each packet (as 608 bytes have fixed bandwidth), then 708 bytes are next to each other, then 2 calls to decode() probably cannot contain originally consecutive bytes in the analogue CEA stream.

Your proposal seems logical, I do not seem any drawbacks of that solution, let me update the code.

(Unfortunately, I cannot run full test cycles including various live content, sarnoff test cases etc. for every code change separately, but I will run them as soon as we have more - maybe all changes merged.)

// If we've reached this point then there is data to process; flag that work has been done.
captionDataProcessed = true;
boolean repeatedControlPossible = repeatableControlSet;
repeatableControlSet = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should these lines go above the block that handles invalid captions? I doubt it's correct to de-duplicate repeated commands that have invalid data in between. Not sure though :).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I had these checks a few line above this current position before and it failed some live streams. My theory was that the original content was made for 30FPS, and when they insert extra frames to be able to play it in 60FPS, they insert zero byte pairs for the new empty frames. Zero check is a little bit earlier, I do not think it would make a difference having this before or after the validity check if it is always after the zero-byte-pair check.

Copy link
Contributor

Choose a reason for hiding this comment

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

I was thinking it should go after the zero check and before the validity check. In case captions are toggled off by flipping the validity bit after a repeatable command, and then when captions are toggled on again the first piece of data happens to be the same repeatable command. Seems like an edge case, but may as well handle it given it's just moving the lines up a little?

Copy link
Contributor

Choose a reason for hiding this comment

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

I will move this up as part of the merge.

@ojw28
Copy link
Contributor

ojw28 commented Jan 10, 2019

Two pending comments (the one above, and the one about putting captionDataProcessed back). Otherwise good to merge; thanks!

Reported in google#3860
For failing examples see the github link above.

[Problem]
We drop matching control codes even if they are not received on
consecutive frames.

The specification says
"(4) If the first transmission of a control code pair passes parity,
it is acted upon within one video frame. If the NEXT frame contains
a perfect repeat of the same pair, the redundant code is ignored."

Keyword is the NEXT. The frames must arrive immediately after
each other.

See https://www.law.cornell.edu/cfr/text/47/79.101

[Solution]
Set an additional flag when any data is processed. Control code
duplication checks should be limited only for the first control
byte pairs processed after any control code.

[Test]
Sarnoff tests have equivalent CEA708 and CEA608 Streams.
@zsmatyas
Copy link
Contributor Author

Have I addressed all comments? It is hard to follow after I force pushed changes.

@ojw28
Copy link
Contributor

ojw28 commented Jan 10, 2019

Think so yes; thanks!

@ojw28 ojw28 merged commit fff6023 into google:dev-v2 Jan 15, 2019
ojw28 added a commit that referenced this pull request Jan 15, 2019
PiperOrigin-RevId: 229364147
@zsmatyas zsmatyas deleted the dev-v2 branch January 15, 2019 21:34
@google google locked and limited conversation to collaborators May 16, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants