Skip to content

Commit c195ef5

Browse files
authored
Handles num_invalid across unsigned GOPs (#470)
and can therefore move the code of final stats prints into the while loop.
1 parent 9f1a7c8 commit c195ef5

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

lib/src/sv_auth.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -773,6 +773,14 @@ validate_authenticity(signed_video_t *self, bu_list_item_t *sei)
773773
// Collect statistics from the bu_list. This is used to validate the GOP and provide additional
774774
// information to the user.
775775
bool has_valid_bu = bu_list_get_stats(self->bu_list, sei, &num_invalid, &num_missed);
776+
// Stats may be collected across multiple GOPs, therefore, remove previous stats
777+
// when deciding upon validation result.
778+
num_invalid -= validation_flags->num_invalid;
779+
// TODO: Workaround for special cases where intermediate GOPs are verified without SEI.
780+
if (num_invalid < 0) {
781+
num_invalid = 0;
782+
}
783+
validation_flags->num_invalid += num_invalid;
776784
DEBUG_LOG("Number of invalid Bitstream Units = %d.", num_invalid);
777785
DEBUG_LOG("Number of missed Bitstream Units = %d.", num_missed);
778786
// Update the counted Bitstream Units part of this validation, since it may have changed.
@@ -1240,6 +1248,10 @@ maybe_validate_gop(signed_video_t *self, bu_info_t *bu)
12401248
validation_flags->has_auth_result = true;
12411249
// All statistics but pending BUs have already been collected.
12421250
latest->number_of_pending_picture_nalus = bu_list_num_pending_items(bu_list);
1251+
DEBUG_LOG("Validated GOP as %s", kAuthResultValidStr[latest->authenticity]);
1252+
DEBUG_LOG("Expected Bitstream Units = %d", latest->number_of_expected_picture_nalus);
1253+
DEBUG_LOG("Received Bitstream Units = %d", latest->number_of_received_picture_nalus);
1254+
DEBUG_LOG(" Pending Bitstream Units = %d", latest->number_of_pending_picture_nalus);
12431255
}
12441256
if (latest->authenticity == SV_AUTH_RESULT_NOT_SIGNED) {
12451257
// Only report "stream is unsigned" in the accumulated report.
@@ -1265,16 +1277,6 @@ maybe_validate_gop(signed_video_t *self, bu_info_t *bu)
12651277
// Re-compute number of pending BUs.
12661278
latest->number_of_pending_picture_nalus = bu_list_num_pending_items(bu_list);
12671279
}
1268-
1269-
if (!validation_flags->waiting_for_signature) {
1270-
// All statistics but pending BUs have already been collected.
1271-
DEBUG_LOG("Validated GOP as %s", kAuthResultValidStr[latest->authenticity]);
1272-
DEBUG_LOG(
1273-
"Expected number of Bitstream Units = %d", latest->number_of_expected_picture_nalus);
1274-
DEBUG_LOG(
1275-
"Received number of Bitstream Units = %d", latest->number_of_received_picture_nalus);
1276-
DEBUG_LOG("Number of pending Bitstream Units = %d", latest->number_of_pending_picture_nalus);
1277-
}
12781280
SV_CATCH()
12791281
SV_DONE(status)
12801282

0 commit comments

Comments
 (0)