-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Conversation
} | ||
continue; | ||
} | ||
|
||
// If we've reached this point then there is data to process; flag that work has been done. | ||
captionDataProcessed = true; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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):
ExoPlayer/library/core/src/main/java/com/google/android/exoplayer2/text/cea/Cea608Decoder.java
Line 329 in 71f72c5
if (!isRepeatableControl) { |
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.
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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 :).
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
Two pending comments (the one above, and the one about putting |
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.
Have I addressed all comments? It is hard to follow after I force pushed changes. |
Think so yes; thanks! |
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.