Fixed bug: vertical FEC/CTL packet was missing when both H/V were to be done #965
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The problem was that the criteria for whether the vertical FEC control packet should be emitted were based on a comparison against the earliest top FEC group base sequence, which was written in the characteristic data of the horizontal source group. As horizontal was checked first, after it was decided that the FEC control packet is required, it updated the base, as required for a case when an FEC control packet was shipped. This base, however, was also used for vertical groups to check, which column the given sequence number belongs to. Unfortunately, after updating the base for the horizontal groups, the effective group offset was negative (in the past), in which case the check for a necessity for a vertical FEC control packet was avoided, in result the FEC control packet wasn't shipped at all.
The solution was to invert the order of checks: now first the vertical groups are checked with the horizontal base not yet updated so that this is always shipped when needed. Next time the function is called, it will find out that vertical packet is no longer needed (already shipped) and therefore will check now for horizontal packet and effectively update the base.
You can see in the logs that it still happens that a check for necessity for FEC control packet due to having the column offset in the past - but never when the vertical group is full, which means that vertical control packet would be still avoided this time anyway by this very reason.